Re: Notes from GTK+ BOF



> EscoFileChooserButton is the current classname.
>
> API:
>    - GtkFileChooser + std. constructors (new, new_with_filesystem).
>    - "title" property (for dialog).
>    - "active" property (for visibility of dialog).
>
> Look:
>    - Similar to GtkComboBox(Entry), only with a dialog behind the
> button instead of a pulldown
>     - Varies by file-chooser action (on-the-fly):
> 	+ GtkToggleButton w/ a basename label and the stock "open" icon for
> OPEN/SELECT.
>	    [ thefile.txt       | o ]
>	+ _GtkFileChooserEntry w/ the "open" icon togglebutton for SAVE/CREATE.
>	    [_thefile.txt______][ o ]
>
> Behavior:
>     - Autocomplete using _GtkFileChooserEntry.
>     - clicking togglebutton/"active" property opens
> GtkFileChooserDialog.
>     - proper signal filtering (update-preview always, others on
> Ok/Cancel)

I have tried this now, and I think it works nicely and fits with the other 
pickers we have. Only some minor nits (see patch below): 

- It needs to override show_all and hide_all, otherwise 
  gtk_widget_show_all() is messing up the internally managed 
  child visibility.  
- I think the dnd behaviour should match the file chooser one, it should
  accept files in open or save mode, and folders in select or create folder
  mode. Currently, it seems to always accept both.
- The structure of the source code (statics - vfuncs - public api) is currently 
  a bit different from the usual GTK+ conventions, but that will be easy enough
  to rearrange when importing.

I will put this into cvs HEAD later this week, if nobody objects.

Matthias


--- /home/boston/mclasen/esco/escofilechooserbutton.c	2004-07-13 11:35:42.000000000 -0400
+++ escofilechooserbutton.c	2004-07-13 11:34:40.261794008 -0400
@@ -73,6 +73,15 @@
   PROP_ACTIVE
 };
 
+enum
+{
+  CURRENT_FOLDER_CHANGED,
+  FILE_ACTIVATED,
+  SELECTION_CHANGED,
+  CHANGED,
+  LAST_SIGNAL
+};
+
 
 /* ******************** *
  *  Private Structures  *
@@ -547,7 +556,6 @@
   gtk_dialog_add_button (GTK_DIALOG (priv->dialog), GTK_STOCK_OK, GTK_RESPONSE_ACCEPT);
   g_signal_connect (priv->dialog, "delete-event", G_CALLBACK (dialog_delete_event_cb), object);
   g_signal_connect (priv->dialog, "response", G_CALLBACK (dialog_response_cb), object);
-  g_object_set_qdata (object, GTK_FILE_CHOOSER_DELEGATE_QUARK, priv->dialog);
   priv->dialog_folder_changed_id =
     g_signal_connect (priv->dialog, "current-folder-changed",
 		      G_CALLBACK (dialog_current_folder_changed_cb), object);
@@ -718,6 +726,20 @@
     }
 }
 
+/* We override show_all and hide_all since we have internal widgets that
+ * shouldn't be shown when you call show_all().
+ */
+static void
+esco_file_chooser_button_show_all (GtkWidget *widget)
+{
+  gtk_widget_show (widget);
+}
+
+static void
+esco_file_chooser_button_hide_all (GtkWidget *widget)
+{
+  gtk_widget_hide (widget);
+}
 
 /* ***************** *
  *  GType Functions  *
@@ -741,6 +763,8 @@
   gtkobject_class->destroy = esco_file_chooser_button_destroy;
 
   widget_class->drag_data_received = esco_file_chooser_button_drag_data_received;
+  widget_class->show_all = esco_file_chooser_button_show_all;
+  widget_class->hide_all = esco_file_chooser_button_hide_all;
 
   g_object_class_install_property (gobject_class, PROP_TITLE,
 				   g_param_spec_string ("title", "Title",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]