From 8102e79dafec13d9ee50905dfbb0dab89a3ffb1b Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Sun, 7 Jun 1998 13:44:34 +0000 Subject: [PATCH] feature check menu items in the compatibility code (this required me to Sun Jun 7 14:34:31 1998 Tim Janik * gtk/gtkitemfactory.c (gtk_item_factory_create_menu_entries): feature check menu items in the compatibility code (this required me to remove the "" part from the menu item name, grrr). --- ChangeLog | 6 ++++++ ChangeLog.pre-2-0 | 6 ++++++ ChangeLog.pre-2-10 | 6 ++++++ ChangeLog.pre-2-2 | 6 ++++++ ChangeLog.pre-2-4 | 6 ++++++ ChangeLog.pre-2-6 | 6 ++++++ ChangeLog.pre-2-8 | 6 ++++++ glib/glib.h | 9 +++++++++ gtk/gtkitemfactory.c | 43 ++++++++++++++++++++++++++++++++++++------- gtk/gtkitemfactory.h | 2 +- 10 files changed, 88 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7698fffd0e..b090455242 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sun Jun 7 14:34:31 1998 Tim Janik + + * gtk/gtkitemfactory.c (gtk_item_factory_create_menu_entries): feature + check menu items in the compatibility code (this required me to remove + the "" part from the menu item name, grrr). + 1998-06-07 Marius Vollmer * gdk/gdk.h (gdk_color_copy, gdk_color_free): New prototypes. diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 7698fffd0e..b090455242 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,9 @@ +Sun Jun 7 14:34:31 1998 Tim Janik + + * gtk/gtkitemfactory.c (gtk_item_factory_create_menu_entries): feature + check menu items in the compatibility code (this required me to remove + the "" part from the menu item name, grrr). + 1998-06-07 Marius Vollmer * gdk/gdk.h (gdk_color_copy, gdk_color_free): New prototypes. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 7698fffd0e..b090455242 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +Sun Jun 7 14:34:31 1998 Tim Janik + + * gtk/gtkitemfactory.c (gtk_item_factory_create_menu_entries): feature + check menu items in the compatibility code (this required me to remove + the "" part from the menu item name, grrr). + 1998-06-07 Marius Vollmer * gdk/gdk.h (gdk_color_copy, gdk_color_free): New prototypes. diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 7698fffd0e..b090455242 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,9 @@ +Sun Jun 7 14:34:31 1998 Tim Janik + + * gtk/gtkitemfactory.c (gtk_item_factory_create_menu_entries): feature + check menu items in the compatibility code (this required me to remove + the "" part from the menu item name, grrr). + 1998-06-07 Marius Vollmer * gdk/gdk.h (gdk_color_copy, gdk_color_free): New prototypes. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 7698fffd0e..b090455242 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,9 @@ +Sun Jun 7 14:34:31 1998 Tim Janik + + * gtk/gtkitemfactory.c (gtk_item_factory_create_menu_entries): feature + check menu items in the compatibility code (this required me to remove + the "" part from the menu item name, grrr). + 1998-06-07 Marius Vollmer * gdk/gdk.h (gdk_color_copy, gdk_color_free): New prototypes. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 7698fffd0e..b090455242 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,9 @@ +Sun Jun 7 14:34:31 1998 Tim Janik + + * gtk/gtkitemfactory.c (gtk_item_factory_create_menu_entries): feature + check menu items in the compatibility code (this required me to remove + the "" part from the menu item name, grrr). + 1998-06-07 Marius Vollmer * gdk/gdk.h (gdk_color_copy, gdk_color_free): New prototypes. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 7698fffd0e..b090455242 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,9 @@ +Sun Jun 7 14:34:31 1998 Tim Janik + + * gtk/gtkitemfactory.c (gtk_item_factory_create_menu_entries): feature + check menu items in the compatibility code (this required me to remove + the "" part from the menu item name, grrr). + 1998-06-07 Marius Vollmer * gdk/gdk.h (gdk_color_copy, gdk_color_free): New prototypes. diff --git a/glib/glib.h b/glib/glib.h index c57aece366..6dada46852 100644 --- a/glib/glib.h +++ b/glib/glib.h @@ -162,6 +162,15 @@ #define G_GNUC_CONST #endif /* !__GNUC__ */ +/* Hacker macro to place breakpoints for x86 machines. + * Actuall use is strongly deprecated of course ;) + */ +#if defined (__i386__) +#define G_BREAKPOINT() G_STMT_START{ __asm__ ("int $03"); }G_STMT_END +#else /* !__i386__ */ +#define G_BREAKPOINT() +#endif /* __i386__ */ + /* Wrap the __PRETTY_FUNCTION__ and __FUNCTION__ variables with macros, * so we can refer to them as strings unconditionally. */ diff --git a/gtk/gtkitemfactory.c b/gtk/gtkitemfactory.c index 9ea6314e3e..7b71e8ed67 100644 --- a/gtk/gtkitemfactory.c +++ b/gtk/gtkitemfactory.c @@ -1028,21 +1028,26 @@ void gtk_item_factory_create_menu_entries (guint n_entries, GtkMenuEntry *entries) { - static GtkPatternSpec pspec = { 42, 0 }; + static GtkPatternSpec pspec_separator = { 42, 0 }; + static GtkPatternSpec pspec_check = { 42, 0 }; guint i; if (!n_entries) return; g_return_if_fail (entries != NULL); - if (pspec.pattern_length == 0) - gtk_pattern_spec_init (&pspec, "**"); + if (pspec_separator.pattern_length == 0) + { + gtk_pattern_spec_init (&pspec_separator, "**"); + gtk_pattern_spec_init (&pspec_check, "**"); + } for (i = 0; i < n_entries; i++) { GtkItemFactory *ifactory; GtkItemFactoryEntry entry; gchar *path; + gchar *cpath; path = entries[i].path; ifactory = gtk_item_factory_from_path (path); @@ -1057,17 +1062,41 @@ gtk_item_factory_create_menu_entries (guint n_entries, while (*path != '>') path++; path++; + cpath = NULL; entry.path = path; entry.accelerator = entries[i].accelerator; entry.callback = entries[i].callback; entry.callback_action = 0; - entry.item_type = (gtk_pattern_match_string (&pspec, path) ? - (gpointer) key_type_separator_item : - NULL); - + if (gtk_pattern_match_string (&pspec_separator, path)) + entry.item_type = (gpointer) key_type_separator_item; + else if (!gtk_pattern_match_string (&pspec_check, path)) + entry.item_type = NULL; + else + { + gboolean in_brace = FALSE; + gchar *c; + + cpath = g_new (gchar, strlen (path)); + c = cpath; + while (*path != 0) + { + if (*path == '<') + in_brace = TRUE; + else if (*path == '>') + in_brace = FALSE; + else if (!in_brace) + *(c++) = *path; + path++; + } + *c = 0; + entry.item_type = (gpointer) key_type_toggle_item; + entry.path = cpath; + } + gtk_item_factory_create_item (ifactory, &entry, entries[i].callback_data, 2); entries[i].widget = gtk_item_factory_get_widget (ifactory, entries[i].path); + g_free (cpath); } } diff --git a/gtk/gtkitemfactory.h b/gtk/gtkitemfactory.h index aad4ee6355..45dc181518 100644 --- a/gtk/gtkitemfactory.h +++ b/gtk/gtkitemfactory.h @@ -187,7 +187,7 @@ void gtk_item_factory_popup_with_data(GtkItemFactory *ifactory, gpointer gtk_item_factory_popup_data (GtkItemFactory *ifactory); gpointer gtk_item_factory_popup_data_from_widget (GtkWidget *widget); -/* Compatibility functions for ol GtkMenuFactory code +/* Compatibility functions for deprecated GtkMenuFactory code */ GtkItemFactory* gtk_item_factory_from_path (const gchar *path); void gtk_item_factory_create_menu_entries (guint n_entries,