aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--ChangeLog.ja6
-rw-r--r--src/mainwindow.c92
-rw-r--r--src/menu.h80
4 files changed, 132 insertions, 52 deletions
diff --git a/ChangeLog b/ChangeLog
index de0a2d12..df4b2df7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2007-04-12
+ * src/menu.h
+ src/mainwindow.c: added toolbar style switch to the context menu of
+ the toolbar.
+
+2007-04-12
+
* src/addressbook.c
src/editbook.c: use 'Address Book' instead of 'Addressbook'.
diff --git a/ChangeLog.ja b/ChangeLog.ja
index 8d8af1cc..feb1189f 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,5 +1,11 @@
2007-04-12
+ * src/menu.h
+ src/mainwindow.c: ツールバーのコンテキストメニューにツールバー
+ スタイルの切り替えを追加。
+
+2007-04-12
+
* src/addressbook.c
src/editbook.c: 'Addressbook' ではなく 'Address Book' を使用する
ようにした。
diff --git a/src/mainwindow.c b/src/mainwindow.c
index 72eea493..1227344d 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -129,6 +129,9 @@ static GtkWidget *main_window_toolbar_create (MainWindow *mainwin);
static GtkWidget *main_window_toolbar_create_from_list
(MainWindow *mainwin,
GList *item_list);
+static void main_window_toolbar_toggle_menu_set_active
+ (MainWindow *mainwin,
+ ToolbarStyle style);
/* callback functions */
static void toolbar_inc_cb (GtkWidget *widget,
@@ -1098,29 +1101,8 @@ MainWindow *main_window_create(SeparateType type)
(ifactory, "/View/Character encoding/Auto detect");
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
- switch (prefs_common.toolbar_style) {
- case TOOLBAR_NONE:
- menuitem = gtk_item_factory_get_item
- (ifactory, "/View/Show or hide/Toolbar/None");
- break;
- case TOOLBAR_ICON:
- menuitem = gtk_item_factory_get_item
- (ifactory, "/View/Show or hide/Toolbar/Icon");
- break;
- case TOOLBAR_TEXT:
- menuitem = gtk_item_factory_get_item
- (ifactory, "/View/Show or hide/Toolbar/Text");
- break;
- case TOOLBAR_BOTH:
- menuitem = gtk_item_factory_get_item
- (ifactory, "/View/Show or hide/Toolbar/Icon and text");
- break;
- case TOOLBAR_BOTH_HORIZ:
- menuitem = gtk_item_factory_get_item
- (ifactory, "/View/Show or hide/Toolbar/Text at the right of icon");
- break;
- }
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
+ main_window_toolbar_toggle_menu_set_active
+ (mainwin, prefs_common.toolbar_style);
gtk_widget_hide(summaryview->search_hbox);
menuitem = gtk_item_factory_get_item
@@ -2609,6 +2591,40 @@ static GtkWidget *main_window_toolbar_create_from_list(MainWindow *mainwin,
return toolbar;
}
+static void main_window_toolbar_toggle_menu_set_active(MainWindow *mainwin,
+ ToolbarStyle style)
+{
+ GtkWidget *menuitem = NULL;
+ GtkItemFactory *ifactory = mainwin->menu_factory;
+
+ switch (style) {
+ case TOOLBAR_NONE:
+ menuitem = gtk_item_factory_get_item
+ (ifactory, "/View/Show or hide/Toolbar/None");
+ break;
+ case TOOLBAR_ICON:
+ menuitem = gtk_item_factory_get_item
+ (ifactory, "/View/Show or hide/Toolbar/Icon");
+ break;
+ case TOOLBAR_TEXT:
+ menuitem = gtk_item_factory_get_item
+ (ifactory, "/View/Show or hide/Toolbar/Text");
+ break;
+ case TOOLBAR_BOTH:
+ menuitem = gtk_item_factory_get_item
+ (ifactory, "/View/Show or hide/Toolbar/Icon and text");
+ break;
+ case TOOLBAR_BOTH_HORIZ:
+ menuitem = gtk_item_factory_get_item
+ (ifactory, "/View/Show or hide/Toolbar/Text at the right of icon");
+ break;
+ }
+
+ if (menuitem)
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
+ TRUE);
+}
+
/* callback functions */
static void toolbar_inc_cb (GtkWidget *widget,
@@ -2759,6 +2775,18 @@ static void toolbar_prefs_account_cb(GtkWidget *widget, gpointer data)
prefs_account_open_cb(mainwin, 0, NULL);
}
+static void toolbar_toggle(GtkWidget *widget, gpointer data)
+{
+ MainWindow *mainwin = (MainWindow *)data;
+ ToolbarStyle style;
+
+ if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)))
+ return;
+
+ style = (ToolbarStyle)g_object_get_data(G_OBJECT(widget), MENU_VAL_ID);
+ main_window_toolbar_toggle_menu_set_active(mainwin, style);
+}
+
static void toolbar_customize(GtkWidget *widget, gpointer data)
{
MainWindow *mainwin = (MainWindow *)data;
@@ -2808,10 +2836,28 @@ static gboolean toolbar_button_pressed(GtkWidget *widget, GdkEventButton *event,
menu = gtk_menu_new();
gtk_widget_show(menu);
+#define SET_TOOLBAR_MENU(text, style, widget) \
+{ \
+ MENUITEM_ADD_RADIO(menu, menuitem, widget, text, style); \
+ if (prefs_common.toolbar_style == style) \
+ gtk_check_menu_item_set_active \
+ (GTK_CHECK_MENU_ITEM(menuitem), TRUE); \
+ g_signal_connect(G_OBJECT(menuitem), "activate", \
+ G_CALLBACK(toolbar_toggle), mainwin); \
+}
+
+ SET_TOOLBAR_MENU(_("Icon _and text"), TOOLBAR_BOTH, NULL);
+ SET_TOOLBAR_MENU(_("Text at the _right of icon"), TOOLBAR_BOTH_HORIZ,
+ menuitem);
+ SET_TOOLBAR_MENU(_("_Icon"), TOOLBAR_ICON, menuitem);
+ SET_TOOLBAR_MENU(_("_Text"), TOOLBAR_TEXT, menuitem);
+ SET_TOOLBAR_MENU(_("_None"), TOOLBAR_NONE, menuitem);
+ MENUITEM_ADD(menu, menuitem, NULL, NULL);
MENUITEM_ADD_WITH_MNEMONIC(menu, menuitem, _("_Customize toolbar..."),
0);
g_signal_connect(G_OBJECT(menuitem), "activate",
G_CALLBACK(toolbar_customize), mainwin);
+
g_signal_connect(G_OBJECT(menu), "selection_done",
G_CALLBACK(gtk_widget_destroy), NULL);
diff --git a/src/menu.h b/src/menu.h
index 92d8d5df..3df3c832 100644
--- a/src/menu.h
+++ b/src/menu.h
@@ -1,6 +1,6 @@
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2007 Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,39 +26,61 @@
#include <gtk/gtkmenu.h>
#include <gtk/gtkmenushell.h>
#include <gtk/gtkoptionmenu.h>
+#include <gtk/gtkradiomenuitem.h>
#define MENU_VAL_ID "Sylpheed::Menu::ValueID"
-#define MENUITEM_ADD(menu, menuitem, label, data) \
-{ \
- if (label) \
- menuitem = gtk_menu_item_new_with_label(label); \
- else { \
- menuitem = gtk_menu_item_new(); \
- gtk_widget_set_sensitive(menuitem, FALSE); \
- } \
- gtk_widget_show(menuitem); \
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); \
- if (data) \
- g_object_set_data(G_OBJECT(menuitem), \
- MENU_VAL_ID, \
- GINT_TO_POINTER(data)); \
+#define MENUITEM_ADD(menu, menuitem, label, data) \
+{ \
+ if (label) \
+ menuitem = gtk_menu_item_new_with_label(label); \
+ else { \
+ menuitem = gtk_menu_item_new(); \
+ gtk_widget_set_sensitive(menuitem, FALSE); \
+ } \
+ gtk_widget_show(menuitem); \
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); \
+ if (data) \
+ g_object_set_data(G_OBJECT(menuitem), \
+ MENU_VAL_ID, \
+ GINT_TO_POINTER(data)); \
}
-#define MENUITEM_ADD_WITH_MNEMONIC(menu, menuitem, label, data) \
-{ \
- if (label) \
- menuitem = gtk_menu_item_new_with_mnemonic(label); \
- else { \
- menuitem = gtk_menu_item_new(); \
- gtk_widget_set_sensitive(menuitem, FALSE); \
- } \
- gtk_widget_show(menuitem); \
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); \
- if (data) \
- g_object_set_data(G_OBJECT(menuitem), \
- MENU_VAL_ID, \
- GINT_TO_POINTER(data)); \
+#define MENUITEM_ADD_WITH_MNEMONIC(menu, menuitem, label, data) \
+{ \
+ if (label) \
+ menuitem = gtk_menu_item_new_with_mnemonic(label); \
+ else { \
+ menuitem = gtk_menu_item_new(); \
+ gtk_widget_set_sensitive(menuitem, FALSE); \
+ } \
+ gtk_widget_show(menuitem); \
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); \
+ if (data) \
+ g_object_set_data(G_OBJECT(menuitem), \
+ MENU_VAL_ID, \
+ GINT_TO_POINTER(data)); \
+}
+
+#define MENUITEM_ADD_RADIO(menu, menuitem, widget, label, data) \
+{ \
+ if (label) { \
+ if (widget) \
+ menuitem = gtk_radio_menu_item_new_with_mnemonic_from_widget \
+ (GTK_RADIO_MENU_ITEM(widget), label); \
+ else \
+ menuitem = gtk_radio_menu_item_new_with_mnemonic \
+ (NULL, label); \
+ } else { \
+ menuitem = gtk_menu_item_new(); \
+ gtk_widget_set_sensitive(menuitem, FALSE); \
+ } \
+ gtk_widget_show(menuitem); \
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); \
+ if (data) \
+ g_object_set_data(G_OBJECT(menuitem), \
+ MENU_VAL_ID, \
+ GINT_TO_POINTER(data)); \
}
#define menu_set_insensitive_all(menu_shell) \