Re: Which signal is emitted when the arrow in GtkComboBoxEntry() is pressed?



Hi Egon

This is a hack, but I it should work:

static void combo_toggle_func( GtkToggleButton
	*togglebutton, gpointer user_data )
{
	// Do your "menu" stuff
}

static void scan_children( GtkWidget *w,  gpointer data )
{
	if( GTK_IS_TOGGLE_BUTTON( w ) ) {
		g_print( "Found Button!\n" );
		g_signal_connect( w, "toggled",
			G_CALLBACK( combo_toggle_func ), NULL );
	}
}

gtk_container_forall( GTK_CONTAINER( my_combo ), scan_children, NULL );

I have also attached a patch to add a popup event (diff against v2.5.5).
Maybe you can try it and report results to the list, so it could be
included in the 2.6 release.

HTH

Jan-Marek

GtkComboBox popup patch:

--- gtkcombobox.c.old	2004-11-09 17:38:57.000000000 +0100
+++ gtkcombobox.c	2004-11-21 10:44:58.000000000 +0100
@@ -181,6 +181,7 @@

 enum {
   CHANGED,
+  POPUP,
   LAST_SIGNAL
 };

@@ -522,6 +523,15 @@
                   g_cclosure_marshal_VOID__VOID,
                   G_TYPE_NONE, 0);

+  combo_box_signals[POPUP] =
+    g_signal_new ("popup",
+                  G_OBJECT_CLASS_TYPE (klass),
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (GtkComboBoxClass, popup),
+                  NULL, NULL,
+                  _gtk_marshal_BOOLEAN__VOID,
+                  G_TYPE_BOOLEAN, 0);
+
   /* properties */
   g_object_class_install_property (object_class,
                                    PROP_MODEL,
@@ -1490,12 +1500,20 @@
 {
   gint x, y, width, height;
   GtkTreePath *path, *ppath;
+  gboolean do_popup = TRUE;

   g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));

   if (GTK_WIDGET_MAPPED (combo_box->priv->popup_widget))
     return;

+  g_signal_emit_by_name (combo_box, "popup", &do_popup);
+  if (do_popup == FALSE) {
+    gtk_toggle_button_set_active
+      (GTK_TOGGLE_BUTTON (combo_box->priv->button), FALSE);
+    return;
+  }
+
   if (GTK_IS_MENU (combo_box->priv->popup_widget))
     {
       gtk_combo_box_menu_popup (combo_box, 0, 0);
@@ -2593,10 +2611,18 @@
                                  gpointer        user_data)
 {
   GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
+  gboolean do_popup = TRUE;

   if (GTK_IS_MENU (combo_box->priv->popup_widget) &&
       event->type == GDK_BUTTON_PRESS && event->button == 1)
     {
+      g_signal_emit_by_name (combo_box, "popup", &do_popup);
+      if (do_popup == FALSE) {
+        gtk_toggle_button_set_active
+          (GTK_TOGGLE_BUTTON (combo_box->priv->button), FALSE);
+        return TRUE;
+      }
+
       if (combo_box->priv->focus_on_click &&
 	  !GTK_WIDGET_HAS_FOCUS (combo_box->priv->button))
 	gtk_widget_grab_focus (combo_box->priv->button);
--- gtkcombobox.h.old	2004-08-16 07:43:50.000000000 +0200
+++ gtkcombobox.h	2004-11-21 08:50:29.000000000 +0100
@@ -51,12 +51,12 @@

   /* signals */
   void     (* changed)          (GtkComboBox *combo_box);
+  gboolean (* popup)            (GtkComboBox *combo_box);

   /* Padding for future expansion */
   void (*_gtk_reserved0) (void);
   void (*_gtk_reserved1) (void);
   void (*_gtk_reserved2) (void);
-  void (*_gtk_reserved3) (void);
 };





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