Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Gtk+/Gnome Application Development
Prev Home Next

The GtkWidgetClass Struct

There are a truly huge number of class functions in GtkWidgetClass. Thankfully, in most cases you only have to override a few of them. Here is the code:


typedef struct _GtkWidgetClass GtkWidgetClass;

struct _GtkWidgetClass
{
  GtkObjectClass parent_class;
  
  guint activate_signal;

  guint set_scroll_adjustments_signal;
  
  /* Basics */
  void (* show)                (GtkWidget      *widget);
  void (* show_all)            (GtkWidget      *widget);
  void (* hide)                (GtkWidget      *widget);
  void (* hide_all)            (GtkWidget      *widget);
  void (* map)                 (GtkWidget      *widget);
  void (* unmap)               (GtkWidget      *widget);
  void (* realize)             (GtkWidget      *widget);
  void (* unrealize)           (GtkWidget      *widget);
  void (* draw)                (GtkWidget      *widget,
                                GdkRectangle   *area);
  void (* draw_focus)          (GtkWidget      *widget);
  void (* draw_default)        (GtkWidget      *widget);
  void (* size_request)        (GtkWidget      *widget,
                                GtkRequisition *requisition);
  void (* size_allocate)       (GtkWidget      *widget,
                                GtkAllocation  *allocation);
  void (* state_changed)       (GtkWidget      *widget,
                                GtkStateType    previous_state);
  void (* parent_set)          (GtkWidget      *widget,
                                GtkWidget      *previous_parent);
  void (* style_set)           (GtkWidget      *widget,
                                GtkStyle       *previous_style);
  
  /* Accelerators */
  gint (* add_accelerator)     (GtkWidget      *widget,
                                guint           accel_signal_id,
                                GtkAccelGroup  *accel_group,
                                guint           accel_key,
                                GdkModifierType accel_mods,
                                GtkAccelFlags   accel_flags);
  void (* remove_accelerator)  (GtkWidget      *widget,
                                GtkAccelGroup  *accel_group,
                                guint           accel_key,
                                GdkModifierType accel_mods);

  /* Explicit focus */
  void (* grab_focus)          (GtkWidget      *widget);
  
  /* Events */
  gint (* event)                   (GtkWidget          *widget,
                                    GdkEvent           *event);
  gint (* button_press_event)      (GtkWidget          *widget,
                                    GdkEventButton     *event);
  gint (* button_release_event)    (GtkWidget          *widget,
                                    GdkEventButton     *event);
  gint (* motion_notify_event)     (GtkWidget          *widget,
                                    GdkEventMotion     *event);
  gint (* delete_event)            (GtkWidget          *widget,
                                    GdkEventAny        *event);
  gint (* destroy_event)           (GtkWidget          *widget,
                                    GdkEventAny        *event);
  gint (* expose_event)            (GtkWidget          *widget,
                                    GdkEventExpose     *event);
  gint (* key_press_event)         (GtkWidget          *widget,
                                    GdkEventKey        *event);
  gint (* key_release_event)       (GtkWidget          *widget,
                                    GdkEventKey        *event);
  gint (* enter_notify_event)      (GtkWidget          *widget,
                                    GdkEventCrossing   *event);
  gint (* leave_notify_event)      (GtkWidget          *widget,
                                    GdkEventCrossing   *event);
  gint (* configure_event)         (GtkWidget          *widget,
                                    GdkEventConfigure  *event);
  gint (* focus_in_event)          (GtkWidget          *widget,
                                    GdkEventFocus      *event);
  gint (* focus_out_event)         (GtkWidget          *widget,
                                    GdkEventFocus      *event);
  gint (* map_event)               (GtkWidget          *widget,
                                    GdkEventAny        *event);
  gint (* unmap_event)             (GtkWidget          *widget,
                                    GdkEventAny        *event);
  gint (* property_notify_event)   (GtkWidget          *widget,
                                    GdkEventProperty   *event);
  gint (* selection_clear_event)   (GtkWidget          *widget,
                                    GdkEventSelection  *event);
  gint (* selection_request_event) (GtkWidget          *widget,
                                    GdkEventSelection  *event);
  gint (* selection_notify_event)  (GtkWidget          *widget,
                                    GdkEventSelection  *event);
  gint (* proximity_in_event)      (GtkWidget          *widget,
                                    GdkEventProximity  *event);
  gint (* proximity_out_event)     (GtkWidget          *widget,
                                    GdkEventProximity  *event);
  gint (* visibility_notify_event)  (GtkWidget         *widget,
                                     GdkEventVisibility *event);
  gint (* client_event)            (GtkWidget          *widget,
                                    GdkEventClient     *event);
  gint (* no_expose_event)         (GtkWidget          *widget,
                                    GdkEventAny        *event);

  /* Selection */
  void (* selection_get)           (GtkWidget          *widget,
                                    GtkSelectionData   *selection_data,
                                    guint               info,
                                    guint               time);
  void (* selection_received)      (GtkWidget          *widget,
                                    GtkSelectionData   *selection_data,
                                    guint               time);

  /* Source side drag signals */
  void (* drag_begin)              (GtkWidget          *widget,
                                    GdkDragContext     *context);
  void (* drag_end)                (GtkWidget          *widget,
                                    GdkDragContext     *context);
  void (* drag_data_get)           (GtkWidget          *widget,
                                    GdkDragContext     *context,
                                    GtkSelectionData   *selection_data,
                                    guint               info,
                                    guint               time);
  void (* drag_data_delete)        (GtkWidget          *widget,
                                    GdkDragContext     *context);

  /* Target side drag signals */
  void (* drag_leave)              (GtkWidget          *widget,
                                    GdkDragContext     *context,
                                    guint               time);
  gboolean (* drag_motion)         (GtkWidget          *widget,
                                    GdkDragContext     *context,
                                    gint                x,
                                    gint                y,
                                    guint               time);
  gboolean (* drag_drop)           (GtkWidget          *widget,
                                    GdkDragContext     *context,
                                    gint                x,
                                    gint                y,
                                    guint               time);
  void (* drag_data_received)      (GtkWidget          *widget,
                                    GdkDragContext     *context,
                                    gint                x,
                                    gint                y,
                                    GtkSelectionData   *selection_data,
                                    guint               info,
                                    guint               time);
  
  /* Action signals */
  void (* debug_msg)               (GtkWidget          *widget,
                                    const gchar        *string);

  /* Padding for future expansion */
  GtkFunction pad1;
  GtkFunction pad2;
  GtkFunction pad3;
  GtkFunction pad4;
};
      

Most of the functions in GtkWidgetClass are registered as default handlers for signals. The exceptions are show_all and hide_all, which are class functions only. Of course, GtkWidgetClass inherits the five class functions and single signal ("destroy") from GtkObjectClass. This chapter will describe the important methods in more detail; also, the section called Events in the chapter called GDK Basics is important for understanding the event methods. the section called GtkWidget In Detail describes the default implementation of each method in some detail.

Gtk+/Gnome Application Development
Prev Home Next

 
 
  Published under free license. Design by Interspire