Re: constructing groups of radio actions



Am Sam, 2003-09-13 um 01.33 schrieb Federico Mena Quintero:
> On Thu, 2003-09-11 at 22:22 +0200, Matthias Clasen wrote:
> > In order to overcome this problem, I'd like to change the signature of
> > the add_radio_actions() to
> > 
> > void
> > gtk_action_group_add_radio_actions (GtkActionGroup      *action_group,
> >                                     GtkRadioActionEntry *entries,
> >                                     guint                n_entries,
> >                                     gint                 current_value,
> >                                     GCallback            on_change,
> >                                     gpointer             user_data);
> > 
> > Then we could set the inital value before connecting the callback.
> 
> This would be very useful.  Having to block signal handlers at object
> creation time is painful.

We face the same problem with toggle actions. Therefore I'd like to
expand my proposal to cover that as well. On the bad side, this patch
brings the _add_actions() api even further away from the "one array of
entries" ideal. On the good side, it allows us to simplify the
GtkActionEntry further by removing the is_toggle flag. I'll commit this
in a few days if nobody objects.

Matthias





Index: gtkactiongroup.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkactiongroup.h,v
retrieving revision 1.4
diff -u -p -r1.4 gtkactiongroup.h
--- gtkactiongroup.h	27 Aug 2003 22:22:27 -0000	1.4
+++ gtkactiongroup.h	14 Sep 2003 22:00:04 -0000
@@ -44,6 +44,7 @@ typedef struct _GtkActionGroup        Gt
 typedef struct _GtkActionGroupPrivate GtkActionGroupPrivate;
 typedef struct _GtkActionGroupClass   GtkActionGroupClass;
 typedef struct _GtkActionEntry        GtkActionEntry;
+typedef struct _GtkToggleActionEntry  GtkToggleActionEntry;
 typedef struct _GtkRadioActionEntry   GtkRadioActionEntry;
 
 struct _GtkActionGroup
@@ -71,15 +72,23 @@ struct _GtkActionGroupClass
 
 struct _GtkActionEntry 
 {
-  gchar *name;
-  gchar *stock_id;
-  gchar *label;
-  gchar *accelerator;
-  gchar *tooltip;
-
-  GCallback callback;
+  gchar     *name;
+  gchar     *stock_id;
+  gchar     *label;
+  gchar     *accelerator;
+  gchar     *tooltip;
+  GCallback  callback;
+};
 
-  gboolean is_toggle;
+struct _GtkToggleActionEntry 
+{
+  gchar     *name;
+  gchar     *stock_id;
+  gchar     *label;
+  gchar     *accelerator;
+  gchar     *tooltip;
+  GCallback  callback;
+  gboolean   is_active;
 };
 
 struct _GtkRadioActionEntry 
@@ -89,8 +98,7 @@ struct _GtkRadioActionEntry 
   gchar *label;
   gchar *accelerator;
   gchar *tooltip;
-
-  gint  value; 
+  gint   value; 
 };
 
 GType           gtk_action_group_get_type      (void);
@@ -110,9 +118,14 @@ void            gtk_action_group_add_act
 						    GtkActionEntry      *entries,
 						    guint                n_entries,
 						    gpointer             user_data);
+void            gtk_action_group_add_toggle_actions (GtkActionGroup       *action_group,
+						     GtkToggleActionEntry *entries,
+						     guint                 n_entries,
+						     gpointer              user_data);
 void            gtk_action_group_add_radio_actions (GtkActionGroup      *action_group,
 						    GtkRadioActionEntry *entries,
 						    guint                n_entries,
+						    gint                 value,
 						    GCallback            on_change,
                                                     gpointer             user_data);
 void            gtk_action_group_add_actions_full  (GtkActionGroup      *action_group,
@@ -120,9 +133,15 @@ void            gtk_action_group_add_act
 						    guint                n_entries,
 						    gpointer             user_data,
 						    GDestroyNotify       destroy);
+void            gtk_action_group_add_toggle_actions_full  (GtkActionGroup      *action_group,
+							   GtkToggleActionEntry      *entries,
+							   guint                n_entries,
+							   gpointer             user_data,
+							   GDestroyNotify       destroy);
 void            gtk_action_group_add_radio_actions_full (GtkActionGroup      *action_group,
 						         GtkRadioActionEntry *entries,
 						         guint                n_entries,
+							 gint                 value,
 						         GCallback            on_change,
                                                          gpointer             user_data,
 							 GDestroyNotify       destroy);


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