root / src / menu.h @ 3072
History | View | Annotate | Download (4.5 kB)
| 1 | /*
|
|---|---|
| 2 | * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client |
| 3 | * Copyright (C) 1999-2012 Hiroyuki Yamamoto |
| 4 | * |
| 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. |
| 9 | * |
| 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. |
| 14 | * |
| 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. |
| 18 | */ |
| 19 | |
| 20 | #ifndef __MENU_H__
|
| 21 | #define __MENU_H__
|
| 22 | |
| 23 | #include <glib.h> |
| 24 | #include <gtk/gtkwidget.h> |
| 25 | #include <gtk/gtkitemfactory.h> |
| 26 | #include <gtk/gtkmenu.h> |
| 27 | #include <gtk/gtkmenushell.h> |
| 28 | #include <gtk/gtkoptionmenu.h> |
| 29 | #include <gtk/gtkimagemenuitem.h> |
| 30 | #include <gtk/gtkradiomenuitem.h> |
| 31 | |
| 32 | #define MENU_VAL_ID "Sylpheed::Menu::ValueID" |
| 33 | |
| 34 | #define MENUITEM_ADD(menu, menuitem, label, data) \
|
| 35 | { \
|
| 36 | if (label) \
|
| 37 | menuitem = gtk_menu_item_new_with_label(label); \ |
| 38 | else { \
|
| 39 | menuitem = gtk_menu_item_new(); \ |
| 40 | gtk_widget_set_sensitive(menuitem, FALSE); \ |
| 41 | } \ |
| 42 | gtk_widget_show(menuitem); \ |
| 43 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); \ |
| 44 | if (data) \
|
| 45 | g_object_set_data(G_OBJECT(menuitem), \ |
| 46 | MENU_VAL_ID, \ |
| 47 | GINT_TO_POINTER(data)); \ |
| 48 | } |
| 49 | |
| 50 | #define MENUITEM_ADD_WITH_MNEMONIC(menu, menuitem, label, data) \
|
| 51 | { \
|
| 52 | if (label) \
|
| 53 | menuitem = gtk_menu_item_new_with_mnemonic(label); \ |
| 54 | else { \
|
| 55 | menuitem = gtk_menu_item_new(); \ |
| 56 | gtk_widget_set_sensitive(menuitem, FALSE); \ |
| 57 | } \ |
| 58 | gtk_widget_show(menuitem); \ |
| 59 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); \ |
| 60 | if (data) \
|
| 61 | g_object_set_data(G_OBJECT(menuitem), \ |
| 62 | MENU_VAL_ID, \ |
| 63 | GINT_TO_POINTER(data)); \ |
| 64 | } |
| 65 | |
| 66 | #define MENUITEM_ADD_FROM_STOCK(menu, menuitem, label, data) \
|
| 67 | { \
|
| 68 | if (label) \
|
| 69 | menuitem = gtk_image_menu_item_new_from_stock(label, NULL); \
|
| 70 | else { \
|
| 71 | menuitem = gtk_menu_item_new(); \ |
| 72 | gtk_widget_set_sensitive(menuitem, FALSE); \ |
| 73 | } \ |
| 74 | gtk_widget_show(menuitem); \ |
| 75 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); \ |
| 76 | if (data) \
|
| 77 | g_object_set_data(G_OBJECT(menuitem), \ |
| 78 | MENU_VAL_ID, \ |
| 79 | GINT_TO_POINTER(data)); \ |
| 80 | } |
| 81 | |
| 82 | #define MENUITEM_ADD_RADIO(menu, menuitem, widget, label, data) \
|
| 83 | { \
|
| 84 | if (label) { \
|
| 85 | if (widget) \
|
| 86 | menuitem = gtk_radio_menu_item_new_with_mnemonic_from_widget \ |
| 87 | (GTK_RADIO_MENU_ITEM(widget), label); \ |
| 88 | else \
|
| 89 | menuitem = gtk_radio_menu_item_new_with_mnemonic \ |
| 90 | (NULL, label); \
|
| 91 | } else { \
|
| 92 | menuitem = gtk_menu_item_new(); \ |
| 93 | gtk_widget_set_sensitive(menuitem, FALSE); \ |
| 94 | } \ |
| 95 | gtk_widget_show(menuitem); \ |
| 96 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); \ |
| 97 | if (data) \
|
| 98 | g_object_set_data(G_OBJECT(menuitem), \ |
| 99 | MENU_VAL_ID, \ |
| 100 | GINT_TO_POINTER(data)); \ |
| 101 | } |
| 102 | |
| 103 | #define menu_set_insensitive_all(menu_shell) \
|
| 104 | menu_set_sensitive_all(menu_shell, FALSE); |
| 105 | |
| 106 | GtkWidget *menubar_create (GtkWidget *window, |
| 107 | GtkItemFactoryEntry *entries, |
| 108 | guint n_entries, |
| 109 | const gchar *path,
|
| 110 | gpointer data); |
| 111 | GtkWidget *menu_create_items (GtkItemFactoryEntry *entries, |
| 112 | guint n_entries, |
| 113 | const gchar *path,
|
| 114 | GtkItemFactory **factory, |
| 115 | gpointer data); |
| 116 | |
| 117 | GString *menu_factory_get_rc (const gchar *path);
|
| 118 | void menu_factory_clear_rc (const gchar *rc_str); |
| 119 | void menu_factory_copy_rc (const gchar *src_path, |
| 120 | const gchar *dest_path);
|
| 121 | |
| 122 | void menu_set_sensitive (GtkItemFactory *ifactory,
|
| 123 | const gchar *path,
|
| 124 | gboolean sensitive); |
| 125 | void menu_set_sensitive_all (GtkMenuShell *menu_shell,
|
| 126 | gboolean sensitive); |
| 127 | |
| 128 | void menu_set_active (GtkItemFactory *ifactory,
|
| 129 | const gchar *path,
|
| 130 | gboolean is_active); |
| 131 | |
| 132 | void menu_button_position (GtkMenu *menu,
|
| 133 | gint *x, |
| 134 | gint *y, |
| 135 | gboolean *push_in, |
| 136 | gpointer user_data); |
| 137 | void menu_widget_position (GtkMenu *menu,
|
| 138 | gint *x, |
| 139 | gint *y, |
| 140 | gboolean *push_in, |
| 141 | gpointer user_data); |
| 142 | |
| 143 | gint menu_find_option_menu_index(GtkOptionMenu *optmenu, |
| 144 | gpointer data, |
| 145 | GCompareFunc func); |
| 146 | |
| 147 | gint menu_get_option_menu_active_index |
| 148 | (GtkOptionMenu *optmenu); |
| 149 | |
| 150 | #endif /* __MENU_H__ */ |