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>
29 #include <gtk/gtkcheckmenuitem.h>
34 static gchar *menu_translate(const gchar *path, gpointer data);
36 GtkWidget *menubar_create(GtkWidget *window, GtkItemFactoryEntry *entries,
37 guint n_entries, const gchar *path, gpointer data)
39 GtkItemFactory *factory;
40 GtkAccelGroup *accel_group;
42 accel_group = gtk_accel_group_new();
43 factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, path, accel_group);
44 gtk_item_factory_set_translate_func(factory, menu_translate,
46 gtk_item_factory_create_items(factory, n_entries, entries, data);
47 gtk_accel_group_attach(accel_group, GTK_OBJECT(window));
49 return gtk_item_factory_get_widget(factory, path);
52 GtkWidget *menu_create_items(GtkItemFactoryEntry *entries,
53 guint n_entries, const gchar *path,
54 GtkItemFactory **factory, gpointer data)
56 *factory = gtk_item_factory_new(GTK_TYPE_MENU, path, NULL);
57 gtk_item_factory_set_translate_func(*factory, menu_translate,
59 gtk_item_factory_create_items(*factory, n_entries, entries, data);
61 return gtk_item_factory_get_widget(*factory, path);
64 static gchar *menu_translate(const gchar *path, gpointer data)
68 retval = gettext(path);
73 void menu_set_sensitive(GtkItemFactory *ifactory, const gchar *path,
78 g_return_if_fail(ifactory != NULL);
80 widget = gtk_item_factory_get_item(ifactory, path);
81 gtk_widget_set_sensitive(widget, sensitive);
84 void menu_set_insensitive_all(GtkMenuShell *menu_shell)
88 for (cur = menu_shell->children; cur != NULL; cur = cur->next)
89 gtk_widget_set_sensitive(GTK_WIDGET(cur->data), FALSE);
92 void menu_set_toggle(GtkItemFactory *ifactory, const gchar *path,
97 g_return_if_fail(ifactory != NULL);
99 widget = gtk_item_factory_get_item(ifactory, path);
100 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(widget), active);