aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-03-16 10:17:13 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-03-16 10:17:13 +0800
commit066b7b5e9f417376dde95f7220ba94bdd11070a0 (patch)
tree759abca99d436833aa13ec4f1e34bdf9dde2312d
parentb171dcc269b1926fe27e25bfd9c1c7bb04a0b727 (diff)
downloadgsoc2013-evolution-066b7b5e9f417376dde95f7220ba94bdd11070a0.tar
gsoc2013-evolution-066b7b5e9f417376dde95f7220ba94bdd11070a0.tar.gz
gsoc2013-evolution-066b7b5e9f417376dde95f7220ba94bdd11070a0.tar.bz2
gsoc2013-evolution-066b7b5e9f417376dde95f7220ba94bdd11070a0.tar.lz
gsoc2013-evolution-066b7b5e9f417376dde95f7220ba94bdd11070a0.tar.xz
gsoc2013-evolution-066b7b5e9f417376dde95f7220ba94bdd11070a0.tar.zst
gsoc2013-evolution-066b7b5e9f417376dde95f7220ba94bdd11070a0.zip
Allow for per-item closures and also instead of taking a const char
2002-03-15 Jeffrey Stedfast <fejj@ximian.com> * gal/gal/widgets/e-popup-menu.c: Allow for per-item closures and also instead of taking a const char *pixname, take a GtkWidget *pixmap instead. * gal/widgets/e-categories.c: Update to sync up with changes made to the EPopupMenu Api. svn path=/trunk/; revision=16182
-rw-r--r--widgets/misc/e-popup-menu.c66
-rw-r--r--widgets/misc/e-popup-menu.h11
2 files changed, 40 insertions, 37 deletions
diff --git a/widgets/misc/e-popup-menu.c b/widgets/misc/e-popup-menu.c
index 592842437d..fd64f451da 100644
--- a/widgets/misc/e-popup-menu.c
+++ b/widgets/misc/e-popup-menu.c
@@ -66,11 +66,11 @@ gnome_app_helper_gettext (const gchar *str)
* Creates an item with an optional icon
*/
static GtkWidget *
-make_item (GtkMenu *menu, const char *name, const char *pixname)
+make_item (GtkMenu *menu, const char *name, GtkWidget *pixmap)
{
GtkWidget *label, *item;
guint label_accel;
-
+
if (*name == '\0')
return gtk_menu_item_new ();
@@ -82,7 +82,7 @@ make_item (GtkMenu *menu, const char *name, const char *pixname)
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_widget_show (label);
- item = pixname ? gtk_pixmap_menu_item_new () : gtk_menu_item_new ();
+ item = pixmap ? gtk_pixmap_menu_item_new () : gtk_menu_item_new ();
gtk_container_add (GTK_CONTAINER (item), label);
if (label_accel != GDK_VoidSymbol){
@@ -93,78 +93,80 @@ make_item (GtkMenu *menu, const char *name, const char *pixname)
label_accel, 0,
GTK_ACCEL_LOCKED);
}
-
- if (pixname){
- GtkWidget *pixmap = gnome_stock_pixmap_widget (item, pixname);
-
+
+ if (pixmap){
gtk_widget_show (pixmap);
- gtk_pixmap_menu_item_set_pixmap (
- GTK_PIXMAP_MENU_ITEM (item), pixmap);
+ gtk_pixmap_menu_item_set_pixmap (GTK_PIXMAP_MENU_ITEM (item), pixmap);
}
-
+
return item;
}
GtkMenu *
-e_popup_menu_create (EPopupMenu *menu_list, guint32 disable_mask, guint32 hide_mask, void *closure)
+e_popup_menu_create (EPopupMenu *menu_list, guint32 disable_mask, guint32 hide_mask, void *default_closure)
{
GtkMenu *menu = GTK_MENU (gtk_menu_new ());
- gboolean last_item_seperator = TRUE;
- gint last_non_seperator = -1;
- gint i;
+ gboolean last_item_separator = TRUE;
+ int last_non_separator = -1;
+ int i;
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;
+ last_non_separator = i;
}
}
- for (i = 0; i <= last_non_seperator; i++) {
- gboolean seperator;
+ for (i = 0; i <= last_non_separator; i++) {
+ gboolean separator;
- seperator = !strcmp ("", menu_list[i].name);
+ separator = !strcmp ("", menu_list[i].name);
- if ((!(seperator && last_item_seperator)) && !(menu_list [i].disable_mask & hide_mask)) {
+ if ((!(separator && last_item_separator)) && !(menu_list [i].disable_mask & hide_mask)) {
GtkWidget *item;
- item = make_item (menu, seperator ? "" : L_(menu_list[i].name), menu_list[i].pixname);
+ if (!separator)
+ item = make_item (menu, L_(menu_list[i].name), menu_list[i].pixmap);
+ else
+ item = make_item (menu, "", NULL);
+
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);
+ menu_list[i].closure ? menu_list[i].closure : default_closure);
} else {
/* submenu */
GtkMenu *submenu;
-
- submenu = e_popup_menu_create (menu_list[i].submenu, disable_mask, hide_mask, closure);
-
+
+ submenu = e_popup_menu_create (menu_list[i].submenu, disable_mask, hide_mask,
+ default_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);
-
- last_item_seperator = seperator;
+
+ last_item_separator = separator;
}
}
-
+
return menu;
}
void
-e_popup_menu_run (EPopupMenu *menu_list, GdkEvent *event, guint32 disable_mask, guint32 hide_mask, void *closure)
+e_popup_menu_run (EPopupMenu *menu_list, GdkEvent *event, guint32 disable_mask, guint32 hide_mask, void *default_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);
+ menu = e_popup_menu_create (menu_list, disable_mask, hide_mask, default_closure);
e_popup_menu (menu, event);
}
diff --git a/widgets/misc/e-popup-menu.h b/widgets/misc/e-popup-menu.h
index e621279345..66435b9ecf 100644
--- a/widgets/misc/e-popup-menu.h
+++ b/widgets/misc/e-popup-menu.h
@@ -32,15 +32,16 @@
BEGIN_GNOME_DECLS
-#define E_POPUP_SEPARATOR { "", NULL, (NULL), NULL, 0 }
-#define E_POPUP_TERMINATOR { NULL, NULL, (NULL), NULL, 0 }
+#define E_POPUP_SEPARATOR { "", NULL, (NULL), NULL, NULL, 0 }
+#define E_POPUP_TERMINATOR { NULL, NULL, (NULL), NULL, NULL, 0 }
typedef struct _EPopupMenu EPopupMenu;
struct _EPopupMenu {
char *name;
- char *pixname;
+ GtkWidget *pixmap;
void (*fn) (GtkWidget *widget, void *closure);
+ void *closure;
EPopupMenu *submenu;
guint32 disable_mask;
};
@@ -48,13 +49,13 @@ struct _EPopupMenu {
GtkMenu *e_popup_menu_create (EPopupMenu *menu_list,
guint32 disable_mask,
guint32 hide_mask,
- void *closure);
+ void *default_closure);
void e_popup_menu_run (EPopupMenu *menu_list,
GdkEvent *event,
guint32 disable_mask,
guint32 hide_mask,
- void *closure);
+ void *default_closure);
END_GNOME_DECLS