Patches for gtkwidget.[ch]



Hi,

Following the instructions posted in the gtk+ HACKING file, I'm posting this
patch against Gtk 1.2.7.  I've been unable to get to ftp.gimp.org to upload this
patch or to read the instructions there for naming patches.

Basically this patch adds a signal to gtkwidget (replacing one of the padded
placeholder signals at the end of the class definition).

The signal simply allows triggering a widget signal handler and passing data
through it.  In other words, an application would connect a signal handler
for to a widget for the "user_action" signal.

The user_action handler has the signature

   void handler(GtkWidget *w, gpointer emitter_data, gpointer data)

The signal handler can be triggered anywhere in the application by
using the function.

  gtk_widget_user_action (GtkWidget *widget, gpointer emitter_data)

This allows the emitter to trigger a widget with arbitrary data.
I feel this is needed this for easily triggering widgets via menu-item,
toolbar-button, and keypress.  Currently doing this is simply too
unwieldy.

I'm happy to justify this patch at greater length if anyone is interested (grin)
Thanks,
Kent

*** gtkwidget.h	Mon Feb 28 15:14:34 2000
--- gtkwidget.h	Tue Feb 29 07:45:35 2000
***************
*** 389,396 ****
    void (* debug_msg)		   (GtkWidget	       *widget,
  				    const gchar	       *string);
  
    /* Padding for future expandsion */
-   GtkFunction pad1;
    GtkFunction pad2;
    GtkFunction pad3;
    GtkFunction pad4;
--- 389,398 ----
    void (* debug_msg)		   (GtkWidget	       *widget,
  				    const gchar	       *string);
  
+   void (* user_action)		    (GtkWidget      *widget,
+ 				     gpointer       *emit_data);
+ 
    /* Padding for future expandsion */
    GtkFunction pad2;
    GtkFunction pad3;
    GtkFunction pad4;
***************
*** 635,640 ****
--- 637,645 ----
  					    guint     *path_length,
  					    gchar    **path,
  					    gchar    **path_reversed);
+ 
+ void	     gtk_widget_user_action	   (GtkWidget *widget,
+ 					    gpointer act_data);
  
  #if	defined (GTK_TRACE_OBJECTS) && defined (__GNUC__)
  #  define gtk_widget_ref gtk_object_ref
*** gtkwidget.c.original	Mon Feb 28 15:14:30 2000
--- gtkwidget.c	Mon Feb 28 15:17:50 2000
***************
*** 97,102 ****
--- 97,103 ----
    NO_EXPOSE_EVENT,
    VISIBILITY_NOTIFY_EVENT,
    DEBUG_MSG,
+   USER_ACTION,
    LAST_SIGNAL
  };
  
***************
*** 717,722 ****
--- 718,732 ----
  		    GTK_TYPE_NONE, 1,
  		    GTK_TYPE_STRING);
  
+   widget_signals[USER_ACTION] =
+     gtk_signal_new ("user_action",
+ 		    GTK_RUN_LAST | GTK_RUN_ACTION,
+ 		    object_class->type,
+ 		    GTK_SIGNAL_OFFSET (GtkWidgetClass, user_action),
+ 		    gtk_marshal_NONE__POINTER,
+ 		    GTK_TYPE_NONE, 1,
+ 		    GTK_TYPE_POINTER);
+  
    gtk_object_class_add_signals (object_class, widget_signals, LAST_SIGNAL);
  
    object_class->set_arg = gtk_widget_set_arg;
***************
*** 779,784 ****
--- 789,796 ----
    klass->no_expose_event = NULL;
  
    klass->debug_msg = gtk_widget_debug_msg;
+ 
+   klass->user_action = NULL;
  }
  
  static void
***************
*** 4980,4982 ****
--- 4992,5004 ----
        g_strreverse (*path_p);
      }
  }
+ 
+ void
+ gtk_widget_user_action (GtkWidget *widget, gpointer act_data)
+ {
+   g_return_if_fail (widget != NULL);
+   g_return_if_fail (GTK_IS_WIDGET (widget));
+   
+   gtk_signal_emit (GTK_OBJECT (widget), widget_signals[USER_ACTION], act_data);
+ }
+ 


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