diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-08-09 13:10:40 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-08-09 13:10:40 +0800 |
commit | e367caf0428dd69039dedcea8d2376dcba94101d (patch) | |
tree | 35b2f7a69621a2602902dd9e0c9e5a6dec254111 /widgets/misc | |
parent | 0efeeb2a5d70be6a777f0eaddd4f10a08af6c363 (diff) | |
download | gsoc2013-evolution-e367caf0428dd69039dedcea8d2376dcba94101d.tar.gz gsoc2013-evolution-e367caf0428dd69039dedcea8d2376dcba94101d.tar.zst gsoc2013-evolution-e367caf0428dd69039dedcea8d2376dcba94101d.zip |
Added a hide_mask argument to the two popup menu functions.
2000-08-09 Christopher James Lahey <clahey@helixcode.com>
* e-popup-menu.c, e-popup-menu.h: Added a hide_mask argument to
the two popup menu functions.
svn path=/trunk/; revision=4625
Diffstat (limited to 'widgets/misc')
-rw-r--r-- | widgets/misc/e-popup-menu.c | 60 | ||||
-rw-r--r-- | widgets/misc/e-popup-menu.h | 3 |
2 files changed, 40 insertions, 23 deletions
diff --git a/widgets/misc/e-popup-menu.c b/widgets/misc/e-popup-menu.c index 192d234371..619f40a22d 100644 --- a/widgets/misc/e-popup-menu.c +++ b/widgets/misc/e-popup-menu.c @@ -1,6 +1,7 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * e-popup-menu.c: popup menu display - * +nnn * * Author: * Miguel de Icaza (miguel@kernel.org) * Jody Goldberg (jgoldberg@home.com) @@ -46,7 +47,7 @@ make_item (GtkMenu *menu, const char *name, const char *pixname) if (pixname){ GtkWidget *pixmap = gnome_stock_pixmap_widget (item, pixname); - + gtk_widget_show (pixmap); gtk_pixmap_menu_item_set_pixmap ( GTK_PIXMAP_MENU_ITEM (item), pixmap); @@ -56,43 +57,56 @@ make_item (GtkMenu *menu, const char *name, const char *pixname) } GtkMenu * -e_popup_menu_create (EPopupMenu *menu_list, int disable_mask, void *closure) +e_popup_menu_create (EPopupMenu *menu_list, int disable_mask, int hide_mask, void *closure) { GtkMenu *menu = GTK_MENU (gtk_menu_new ()); int i; - - for (i = 0; menu_list [i].name; i++){ + gboolean last_item_separator = TRUE; + gint last_non_separator = -1; + + for (i = 0; menu_list[i].name; i++) { + if (strcmp("", menu_list[i].name) && !(menu_list [i].disable_mask & hide_mask)) { + last_non_seperator = i; + } + } + + for (i = 0; i < last_non_separator; i++) { GtkWidget *item; - - item = make_item (menu, menu_list [i].name, - menu_list [i].pixname); - - if (menu_list [i].fn) - gtk_signal_connect ( - GTK_OBJECT (item), "activate", - GTK_SIGNAL_FUNC (menu_list [i].fn), - closure); - - if (menu_list [i].disable_mask & disable_mask) - gtk_widget_set_sensitive (item, FALSE); - - gtk_widget_show (item); - gtk_menu_append (menu, item); + gboolean separator; + + separator = !strcmp("", menu_list[i].name); + + if ((!(separator && last_separator)) && !(menu_list [i].disable_mask & hide_mask)) { + + item = make_item (menu, menu_list [i].name, + menu_list [i].pixname); + + if (menu_list [i].fn) + gtk_signal_connect ( + GTK_OBJECT (item), "activate", + GTK_SIGNAL_FUNC (menu_list [i].fn), + closure); + + if (menu_list [i].disable_mask & disable_mask) + gtk_widget_set_sensitive (item, FALSE); + + gtk_widget_show (item); + gtk_menu_append (menu, item); + } } return menu; - } void -e_popup_menu_run (EPopupMenu *menu_list, GdkEventButton *event, int disable_mask, void *closure) +e_popup_menu_run (EPopupMenu *menu_list, GdkEventButton *event, int disable_mask, int hide_mask, void *closure) { GtkMenu *menu; g_return_if_fail (menu_list != NULL); g_return_if_fail (event != NULL); - menu = e_popup_menu_create (menu_list, disable_mask, closure); + menu = e_popup_menu_create (menu_list, disable_mask, hide_mask, closure); e_popup_menu (menu, event); } diff --git a/widgets/misc/e-popup-menu.h b/widgets/misc/e-popup-menu.h index b911717424..ed54a632a5 100644 --- a/widgets/misc/e-popup-menu.h +++ b/widgets/misc/e-popup-menu.h @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ #ifndef E_POPUP_MENU_H #define E_POPUP_MENU_H @@ -12,11 +13,13 @@ typedef struct { GtkMenu *e_popup_menu_create (EPopupMenu *menu_list, int disable_mask, + int hide_mask, void *closure); void e_popup_menu_run (EPopupMenu *menu_list, GdkEventButton *event, int disable_mask, + int hide_mask, void *closure); #endif /* E_POPUP_MENU_H */ |