2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999,2000 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #include <gtk/gtkwidget.h>
26 #include <gtk/gtkmenu.h>
27 #include <gtk/gtkmenubar.h>
28 #include <gtk/gtkitemfactory.h>
33 static gchar *menu_translate(const gchar *path, gpointer data);
35 GtkWidget *menubar_create(GtkWidget *window, GtkItemFactoryEntry *entries,
36 guint n_entries, const gchar *path, gpointer data)
38 GtkItemFactory *factory;
39 GtkAccelGroup *accel_group;
41 accel_group = gtk_accel_group_new();
42 factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, path, accel_group);
43 gtk_item_factory_set_translate_func(factory, menu_translate,
45 gtk_item_factory_create_items(factory, n_entries, entries, data);
46 gtk_accel_group_attach(accel_group, GTK_OBJECT(window));
48 return gtk_item_factory_get_widget(factory, path);
51 GtkWidget *menu_create_items(GtkItemFactoryEntry *entries,
52 guint n_entries, const gchar *path,
53 GtkItemFactory **factory, gpointer data)
55 *factory = gtk_item_factory_new(GTK_TYPE_MENU, path, NULL);
56 gtk_item_factory_set_translate_func(*factory, menu_translate,
58 gtk_item_factory_create_items(*factory, n_entries, entries, data);
60 return gtk_item_factory_get_widget(*factory, path);
63 static gchar *menu_translate(const gchar *path, gpointer data)
67 retval = gettext(path);
72 void menu_set_sensitive(GtkItemFactory *ifactory, const gchar *path,
77 g_return_if_fail(ifactory != NULL);
79 widget = gtk_item_factory_get_item(ifactory, path);
80 gtk_widget_set_sensitive(widget, sensitive);
83 void menu_set_insensitive_all(GtkMenuShell *menu_shell)
87 for (cur = menu_shell->children; cur != NULL; cur = cur->next)
88 gtk_widget_set_sensitive(GTK_WIDGET(cur->data), FALSE);