summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorTim Janik <timj@gtk.org>1998-06-07 13:44:34 +0000
committerTim Janik <timj@src.gnome.org>1998-06-07 13:44:34 +0000
commit8102e79dafec13d9ee50905dfbb0dab89a3ffb1b (patch)
treee20e51f35c1f987b82bdae7210330852fa448215 /gtk
parent50a9ba1f26725f87e634acc309d70839cde64672 (diff)
downloadgdk-pixbuf-8102e79dafec13d9ee50905dfbb0dab89a3ffb1b.tar.gz
feature check menu items in the compatibility code (this required me to
Sun Jun 7 14:34:31 1998 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.c (gtk_item_factory_create_menu_entries): feature check menu items in the compatibility code (this required me to remove the "<check>" part from the menu item name, grrr).
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkitemfactory.c43
-rw-r--r--gtk/gtkitemfactory.h2
2 files changed, 37 insertions, 8 deletions
diff --git a/gtk/gtkitemfactory.c b/gtk/gtkitemfactory.c
index 9ea6314e3..7b71e8ed6 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, "*<separator>*");
+ if (pspec_separator.pattern_length == 0)
+ {
+ gtk_pattern_spec_init (&pspec_separator, "*<separator>*");
+ gtk_pattern_spec_init (&pspec_check, "*<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 aad4ee635..45dc18151 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,