root / src / menu.h @ 3072
History | View | Annotate | Download (4.5 kB)
| 1 | 1 | hiro | /*
|
|---|---|---|---|
| 2 | 1 | hiro | * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client |
| 3 | 3032 | hiro | * Copyright (C) 1999-2012 Hiroyuki Yamamoto |
| 4 | 1 | hiro | * |
| 5 | 1 | hiro | * This program is free software; you can redistribute it and/or modify |
| 6 | 1 | hiro | * it under the terms of the GNU General Public License as published by |
| 7 | 1 | hiro | * the Free Software Foundation; either version 2 of the License, or |
| 8 | 1 | hiro | * (at your option) any later version. |
| 9 | 1 | hiro | * |
| 10 | 1 | hiro | * This program is distributed in the hope that it will be useful, |
| 11 | 1 | hiro | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | 1 | hiro | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | 1 | hiro | * GNU General Public License for more details. |
| 14 | 1 | hiro | * |
| 15 | 1 | hiro | * You should have received a copy of the GNU General Public License |
| 16 | 1 | hiro | * along with this program; if not, write to the Free Software |
| 17 | 1 | hiro | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 | 1 | hiro | */ |
| 19 | 1 | hiro | |
| 20 | 1 | hiro | #ifndef __MENU_H__
|
| 21 | 1 | hiro | #define __MENU_H__
|
| 22 | 1 | hiro | |
| 23 | 1 | hiro | #include <glib.h> |
| 24 | 1 | hiro | #include <gtk/gtkwidget.h> |
| 25 | 1 | hiro | #include <gtk/gtkitemfactory.h> |
| 26 | 1 | hiro | #include <gtk/gtkmenu.h> |
| 27 | 1 | hiro | #include <gtk/gtkmenushell.h> |
| 28 | 1 | hiro | #include <gtk/gtkoptionmenu.h> |
| 29 | 2906 | hiro | #include <gtk/gtkimagemenuitem.h> |
| 30 | 1629 | hiro | #include <gtk/gtkradiomenuitem.h> |
| 31 | 1 | hiro | |
| 32 | 1 | hiro | #define MENU_VAL_ID "Sylpheed::Menu::ValueID" |
| 33 | 1 | hiro | |
| 34 | 1629 | hiro | #define MENUITEM_ADD(menu, menuitem, label, data) \
|
| 35 | 1629 | hiro | { \
|
| 36 | 1629 | hiro | if (label) \
|
| 37 | 1629 | hiro | menuitem = gtk_menu_item_new_with_label(label); \ |
| 38 | 1629 | hiro | else { \
|
| 39 | 1629 | hiro | menuitem = gtk_menu_item_new(); \ |
| 40 | 1629 | hiro | gtk_widget_set_sensitive(menuitem, FALSE); \ |
| 41 | 1629 | hiro | } \ |
| 42 | 1629 | hiro | gtk_widget_show(menuitem); \ |
| 43 | 1629 | hiro | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); \ |
| 44 | 1629 | hiro | if (data) \
|
| 45 | 1629 | hiro | g_object_set_data(G_OBJECT(menuitem), \ |
| 46 | 1629 | hiro | MENU_VAL_ID, \ |
| 47 | 1629 | hiro | GINT_TO_POINTER(data)); \ |
| 48 | 909 | hiro | } |
| 49 | 909 | hiro | |
| 50 | 1629 | hiro | #define MENUITEM_ADD_WITH_MNEMONIC(menu, menuitem, label, data) \
|
| 51 | 1629 | hiro | { \
|
| 52 | 1629 | hiro | if (label) \
|
| 53 | 1629 | hiro | menuitem = gtk_menu_item_new_with_mnemonic(label); \ |
| 54 | 1629 | hiro | else { \
|
| 55 | 1629 | hiro | menuitem = gtk_menu_item_new(); \ |
| 56 | 1629 | hiro | gtk_widget_set_sensitive(menuitem, FALSE); \ |
| 57 | 1629 | hiro | } \ |
| 58 | 1629 | hiro | gtk_widget_show(menuitem); \ |
| 59 | 1629 | hiro | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); \ |
| 60 | 1629 | hiro | if (data) \
|
| 61 | 1629 | hiro | g_object_set_data(G_OBJECT(menuitem), \ |
| 62 | 1629 | hiro | MENU_VAL_ID, \ |
| 63 | 1629 | hiro | GINT_TO_POINTER(data)); \ |
| 64 | 1 | hiro | } |
| 65 | 1 | hiro | |
| 66 | 2906 | hiro | #define MENUITEM_ADD_FROM_STOCK(menu, menuitem, label, data) \
|
| 67 | 2906 | hiro | { \
|
| 68 | 2906 | hiro | if (label) \
|
| 69 | 2906 | hiro | menuitem = gtk_image_menu_item_new_from_stock(label, NULL); \
|
| 70 | 2906 | hiro | else { \
|
| 71 | 2906 | hiro | menuitem = gtk_menu_item_new(); \ |
| 72 | 2906 | hiro | gtk_widget_set_sensitive(menuitem, FALSE); \ |
| 73 | 2906 | hiro | } \ |
| 74 | 2906 | hiro | gtk_widget_show(menuitem); \ |
| 75 | 2906 | hiro | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); \ |
| 76 | 2906 | hiro | if (data) \
|
| 77 | 2906 | hiro | g_object_set_data(G_OBJECT(menuitem), \ |
| 78 | 2906 | hiro | MENU_VAL_ID, \ |
| 79 | 2906 | hiro | GINT_TO_POINTER(data)); \ |
| 80 | 2906 | hiro | } |
| 81 | 2906 | hiro | |
| 82 | 1629 | hiro | #define MENUITEM_ADD_RADIO(menu, menuitem, widget, label, data) \
|
| 83 | 1629 | hiro | { \
|
| 84 | 1629 | hiro | if (label) { \
|
| 85 | 1629 | hiro | if (widget) \
|
| 86 | 1629 | hiro | menuitem = gtk_radio_menu_item_new_with_mnemonic_from_widget \ |
| 87 | 1629 | hiro | (GTK_RADIO_MENU_ITEM(widget), label); \ |
| 88 | 1629 | hiro | else \
|
| 89 | 1629 | hiro | menuitem = gtk_radio_menu_item_new_with_mnemonic \ |
| 90 | 1629 | hiro | (NULL, label); \
|
| 91 | 1629 | hiro | } else { \
|
| 92 | 1629 | hiro | menuitem = gtk_menu_item_new(); \ |
| 93 | 1629 | hiro | gtk_widget_set_sensitive(menuitem, FALSE); \ |
| 94 | 1629 | hiro | } \ |
| 95 | 1629 | hiro | gtk_widget_show(menuitem); \ |
| 96 | 1629 | hiro | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); \ |
| 97 | 1629 | hiro | if (data) \
|
| 98 | 1629 | hiro | g_object_set_data(G_OBJECT(menuitem), \ |
| 99 | 1629 | hiro | MENU_VAL_ID, \ |
| 100 | 1629 | hiro | GINT_TO_POINTER(data)); \ |
| 101 | 1629 | hiro | } |
| 102 | 1629 | hiro | |
| 103 | 1 | hiro | #define menu_set_insensitive_all(menu_shell) \
|
| 104 | 1 | hiro | menu_set_sensitive_all(menu_shell, FALSE); |
| 105 | 1 | hiro | |
| 106 | 1 | hiro | GtkWidget *menubar_create (GtkWidget *window, |
| 107 | 1 | hiro | GtkItemFactoryEntry *entries, |
| 108 | 1 | hiro | guint n_entries, |
| 109 | 1 | hiro | const gchar *path,
|
| 110 | 1 | hiro | gpointer data); |
| 111 | 1 | hiro | GtkWidget *menu_create_items (GtkItemFactoryEntry *entries, |
| 112 | 1 | hiro | guint n_entries, |
| 113 | 1 | hiro | const gchar *path,
|
| 114 | 1 | hiro | GtkItemFactory **factory, |
| 115 | 1 | hiro | gpointer data); |
| 116 | 1 | hiro | |
| 117 | 1 | hiro | GString *menu_factory_get_rc (const gchar *path);
|
| 118 | 1 | hiro | void menu_factory_clear_rc (const gchar *rc_str); |
| 119 | 1 | hiro | void menu_factory_copy_rc (const gchar *src_path, |
| 120 | 1 | hiro | const gchar *dest_path);
|
| 121 | 1 | hiro | |
| 122 | 1 | hiro | void menu_set_sensitive (GtkItemFactory *ifactory,
|
| 123 | 1 | hiro | const gchar *path,
|
| 124 | 1 | hiro | gboolean sensitive); |
| 125 | 1 | hiro | void menu_set_sensitive_all (GtkMenuShell *menu_shell,
|
| 126 | 1 | hiro | gboolean sensitive); |
| 127 | 1 | hiro | |
| 128 | 1 | hiro | void menu_set_active (GtkItemFactory *ifactory,
|
| 129 | 1 | hiro | const gchar *path,
|
| 130 | 1 | hiro | gboolean is_active); |
| 131 | 1 | hiro | |
| 132 | 1 | hiro | void menu_button_position (GtkMenu *menu,
|
| 133 | 1 | hiro | gint *x, |
| 134 | 1 | hiro | gint *y, |
| 135 | 1 | hiro | gboolean *push_in, |
| 136 | 1 | hiro | gpointer user_data); |
| 137 | 3029 | hiro | void menu_widget_position (GtkMenu *menu,
|
| 138 | 3029 | hiro | gint *x, |
| 139 | 3029 | hiro | gint *y, |
| 140 | 3029 | hiro | gboolean *push_in, |
| 141 | 3029 | hiro | gpointer user_data); |
| 142 | 1 | hiro | |
| 143 | 1 | hiro | gint menu_find_option_menu_index(GtkOptionMenu *optmenu, |
| 144 | 1 | hiro | gpointer data, |
| 145 | 1 | hiro | GCompareFunc func); |
| 146 | 1 | hiro | |
| 147 | 1 | hiro | gint menu_get_option_menu_active_index |
| 148 | 1 | hiro | (GtkOptionMenu *optmenu); |
| 149 | 1 | hiro | |
| 150 | 1 | hiro | #endif /* __MENU_H__ */ |