aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/misc')
-rw-r--r--widgets/misc/e-popup-menu.c63
-rw-r--r--widgets/misc/e-popup-menu.h17
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 */