Updated Spanish translation
[evolution.git] / e-util / e-popup-menu.c
blobfc2ec02e89936b888f52c961c4594dea7c7eb98b
1 /*
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
9 * for more details.
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/>.
15 * Authors:
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)
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
28 #include <libintl.h>
29 #include <string.h>
31 #include <gdk/gdkkeysyms.h>
32 #include <gtk/gtk.h>
34 #include "e-popup-menu.h"
37 * Creates an item with an optional icon
39 static void
40 make_item (GtkMenu *menu,
41 GtkMenuItem *item,
42 const gchar *name)
44 GtkWidget *label;
46 if (*name == '\0')
47 return;
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);
59 GtkMenu *
60 e_popup_menu_create_with_domain (EPopupMenu *menu_list,
61 guint32 disable_mask,
62 guint32 hide_mask,
63 gpointer default_closure,
64 const gchar *domain)
66 GtkMenu *menu = GTK_MENU (gtk_menu_new ());
67 gboolean last_item_separator = TRUE;
68 gint last_non_separator = -1;
69 gint i;
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++) {
78 gboolean separator;
80 separator = !strcmp ("", menu_list[i].name);
82 if ((!(separator && last_item_separator)) && !(menu_list[i].disable_mask & hide_mask)) {
83 GtkWidget *item = NULL;
85 if (!separator) {
86 item = gtk_menu_item_new ();
88 make_item (menu, GTK_MENU_ITEM (item), dgettext (domain, menu_list[i].name));
89 } else {
90 item = gtk_menu_item_new ();
93 gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
95 if (menu_list[i].fn)
96 g_signal_connect (
97 item, "activate",
98 G_CALLBACK (menu_list[i].fn),
99 default_closure);
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;
110 return menu;