2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU Lesser General Public License as published by
4 * the Free Software Foundation.
6 * This program is distributed in the hope that it will be useful, but
7 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
8 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * You should have received a copy of the GNU Lesser General Public License
12 * along with this program; if not, see <http://www.gnu.org/licenses/>.
16 * Miguel de Icaza <miguel@ximian.com>
17 * Jody Goldberg (jgoldberg@home.com)
18 * Jeffrey Stedfast <fejj@ximian.com>
20 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
31 #include <gdk/gdkkeysyms.h>
34 #include "e-popup-menu.h"
37 * Creates an item with an optional icon
40 make_item (GtkMenu
*menu
,
50 * Ugh. This needs to go into Gtk+
52 label
= gtk_label_new_with_mnemonic (name
);
53 gtk_misc_set_alignment (GTK_MISC (label
), 0.0, 0.5);
54 gtk_widget_show (label
);
56 gtk_container_add (GTK_CONTAINER (item
), label
);
60 e_popup_menu_create_with_domain (EPopupMenu
*menu_list
,
63 gpointer default_closure
,
66 GtkMenu
*menu
= GTK_MENU (gtk_menu_new ());
67 gboolean last_item_separator
= TRUE
;
68 gint last_non_separator
= -1;
71 for (i
= 0; menu_list
[i
].name
; i
++) {
72 if (strcmp ("", menu_list
[i
].name
) && !(menu_list
[i
].disable_mask
& hide_mask
)) {
73 last_non_separator
= i
;
77 for (i
= 0; i
<= last_non_separator
; i
++) {
80 separator
= !strcmp ("", menu_list
[i
].name
);
82 if ((!(separator
&& last_item_separator
)) && !(menu_list
[i
].disable_mask
& hide_mask
)) {
83 GtkWidget
*item
= NULL
;
86 item
= gtk_menu_item_new ();
88 make_item (menu
, GTK_MENU_ITEM (item
), dgettext (domain
, menu_list
[i
].name
));
90 item
= gtk_menu_item_new ();
93 gtk_menu_shell_append (GTK_MENU_SHELL (menu
), item
);
98 G_CALLBACK (menu_list
[i
].fn
),
101 if (menu_list
[i
].disable_mask
& disable_mask
)
102 gtk_widget_set_sensitive (item
, FALSE
);
104 gtk_widget_show (item
);
106 last_item_separator
= separator
;