diff options
author | Jeffrey Stedfast <fejj@helixcode.com> | 2000-11-07 07:07:04 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2000-11-07 07:07:04 +0800 |
commit | 3729117ec62a483b1ddc59d6a1dd4167694cde2b (patch) | |
tree | b12ec132e71f91edf7f45e93e3bbbfbd4c4f20a4 /widgets | |
parent | cf0bdc7f09cff0ac8b834b3784655cd9a612ee4c (diff) | |
download | gsoc2013-evolution-3729117ec62a483b1ddc59d6a1dd4167694cde2b.tar gsoc2013-evolution-3729117ec62a483b1ddc59d6a1dd4167694cde2b.tar.gz gsoc2013-evolution-3729117ec62a483b1ddc59d6a1dd4167694cde2b.tar.bz2 gsoc2013-evolution-3729117ec62a483b1ddc59d6a1dd4167694cde2b.tar.lz gsoc2013-evolution-3729117ec62a483b1ddc59d6a1dd4167694cde2b.tar.xz gsoc2013-evolution-3729117ec62a483b1ddc59d6a1dd4167694cde2b.tar.zst gsoc2013-evolution-3729117ec62a483b1ddc59d6a1dd4167694cde2b.zip |
Add a submenu field to struct EPopupMenu.
2000-11-06 Jeffrey Stedfast <fejj@helixcode.com>
* gal/widgets/e-popup-menu.h: Add a submenu field to struct
EPopupMenu.
* gal/widgets/e-popup-menu.c (e_popup_menu_create): If the menu
item has a submenu field, create the submenu and attach it.
* configure.in: Bumped the micro-version because of some changes
to e-popup-menu's structure.
svn path=/trunk/; revision=6461
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/misc/e-popup-menu.c | 63 | ||||
-rw-r--r-- | widgets/misc/e-popup-menu.h | 17 |
2 files changed, 46 insertions, 34 deletions
diff --git a/widgets/misc/e-popup-menu.c b/widgets/misc/e-popup-menu.c index 2421578dfd..875182f4c6 100644 --- a/widgets/misc/e-popup-menu.c +++ b/widgets/misc/e-popup-menu.c @@ -2,9 +2,10 @@ /* * e-popup-menu.c: popup menu display nnn * - * Author: + * Authors: * Miguel de Icaza (miguel@kernel.org) * Jody Goldberg (jgoldberg@home.com) + * Jeffrey Stedfast <fejj@helixcode.com> * * (C) 2000 Helix Code, Inc. */ @@ -57,58 +58,66 @@ make_item (GtkMenu *menu, const char *name, const char *pixname) } GtkMenu * -e_popup_menu_create (EPopupMenu *menu_list, int disable_mask, int hide_mask, void *closure) +e_popup_menu_create (EPopupMenu *menu_list, guint32 disable_mask, guint32 hide_mask, void *closure) { GtkMenu *menu = GTK_MENU (gtk_menu_new ()); - int i; gboolean last_item_seperator = TRUE; gint last_non_seperator = -1; - + gint i; + for (i = 0; menu_list[i].name; i++) { - if (strcmp("", menu_list[i].name) && !(menu_list [i].disable_mask & hide_mask)) { + if (strcmp ("", menu_list[i].name) && !(menu_list [i].disable_mask & hide_mask)) { last_non_seperator = i; } } - + for (i = 0; i <= last_non_seperator; i++) { - GtkWidget *item; gboolean seperator; - - seperator = !strcmp("", menu_list[i].name); - + + seperator = !strcmp ("", menu_list[i].name); + if ((!(seperator && last_item_seperator)) && !(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) + GtkWidget *item; + + item = make_item (menu, menu_list[i].name, menu_list[i].pixname); + gtk_menu_append (menu, item); + + if (!menu_list[i].submenu) { + if (menu_list[i].fn) + gtk_signal_connect (GTK_OBJECT (item), "activate", + GTK_SIGNAL_FUNC (menu_list[i].fn), + closure); + } else { + /* submenu */ + GtkMenu *submenu; + + submenu = e_popup_menu_create (menu_list[i].submenu, disable_mask, hide_mask, closure); + + gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), GTK_WIDGET (submenu)); + } + + if (menu_list[i].disable_mask & disable_mask) gtk_widget_set_sensitive (item, FALSE); - + gtk_widget_show (item); - gtk_menu_append (menu, item); } + last_item_seperator = seperator; } - + return menu; } void -e_popup_menu_run (EPopupMenu *menu_list, GdkEventButton *event, int disable_mask, int hide_mask, void *closure) +e_popup_menu_run (EPopupMenu *menu_list, GdkEventButton *event, guint32 disable_mask, guint32 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, 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 7039d59835..be78965a83 100644 --- a/widgets/misc/e-popup-menu.h +++ b/widgets/misc/e-popup-menu.h @@ -4,22 +4,25 @@ #include <gtk/gtkwidget.h> -typedef struct { +typedef struct _EPopupMenu EPopupMenu; + +struct _EPopupMenu { char *name; char *pixname; void (*fn) (GtkWidget *widget, void *closure); - int disable_mask; -} EPopupMenu; + EPopupMenu *submenu; + guint32 disable_mask; +}; GtkMenu *e_popup_menu_create (EPopupMenu *menu_list, - int disable_mask, - int hide_mask, + guint32 disable_mask, + guint32 hide_mask, void *closure); void e_popup_menu_run (EPopupMenu *menu_list, GdkEventButton *event, - int disable_mask, - int hide_mask, + guint32 disable_mask, + guint32 hide_mask, void *closure); #endif /* E_POPUP_MENU_H */ |