gtk-file-chooser-button

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

gtk-file-chooser-button

Koenraad Lelong-2
Hi,
I wanted to use a gtk_file_chooser_button, but I couldn't because
gtk_file_chooser_button_new doesn't exist (v2.0.3 and svn-version). So I
added it (and some others) in gtkfilechooser.inc (see enclosed diff). Is
this the right place ? I still have to find out how to get the file-name
out of the control.
If this patch gets included, would it be backported to 2.0.3 ? Since I
need 2.0.3 for my arm-board and svn is broken for arm-linux I would like
to have it. If it is not possible I will have to patch it myself every
time I get a new 2.0.3.
Regards,
Koenraad Lelong.

Index: fpc/packages/extra/gtk2/gtk+/gtk/gtkfilechooser.inc
===================================================================
--- fpc/packages/extra/gtk2/gtk+/gtk/gtkfilechooser.inc (revision 3714)
+++ fpc/packages/extra/gtk2/gtk+/gtk/gtkfilechooser.inc (working copy)
@@ -31,6 +31,9 @@
 
 function GTK_FILE_CHOOSER_ERROR : TGQuark;
 
+function gtk_file_chooser_button_new(title:Pgchar; action:TGtkFileChooserAction):PGtkWidget;cdecl;external gtklib name 'gtk_file_chooser_button_new';
+function gtk_file_chooser_button_new_with_backend(title:Pgchar; action:TGtkFileChooserAction;backend:Pgchar):PGtkWidget;cdecl;external gtklib name 'gtk_file_chooser_button_new_with_backend';
+function gtk_file_chooser_button_new_with_dialog(dialog:PGtkWidget):PGtkWidget;cdecl;external gtklib name 'gtk_file_chooser_button_new_with_dialog';
 
 
 function gtk_file_chooser_get_type:GType;cdecl;external gtklib name 'gtk_file_chooser_get_type';

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: gtk-file-chooser-button

Michalis Kamburelis
Koenraad Lelong wrote:
> Hi,
> I wanted to use a gtk_file_chooser_button, but I couldn't because
> gtk_file_chooser_button_new doesn't exist (v2.0.3 and svn-version). So I
> added it (and some others) in gtkfilechooser.inc (see enclosed diff). Is
> this the right place ?

I think it should go to separate file gtkfilechooserbutton.inc, to
follow C header convention: it's defined in gtk/gtkfilechooserbutton.h.
You should add this file to gtkincludes.inc somewhere under {$IFDEF
HasGTK2_6} --- for example right after the line {$include
gtkfilechooserentry.inc}.

> I still have to find out how to get the file-name
> out of the control.

You just use the functions of GtkFileChooser, because
GtkFileChooserButton implements GtkFileChooser interface. Translating to
Pascal small example from
[http://developer.gimp.org/api/2.0/gtk/GtkFileChooserButton.html]:

{ Example 6. Create a button to let the user select a file in /etc }
var
  button: PGtkWidget;
begin
  button := gtk_file_chooser_button_new ('Select a file',
                                        GTK_FILE_CHOOSER_ACTION_OPEN);
  gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (button),
                                       '/etc');
end;

So you should be able to just cast "button" to GtkFileChooser and use
all gtk_file_chooser_xxx functions, see
[http://developer.gimp.org/api/2.0/gtk/GtkFileChooser.html].

Michalis
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal