Use mnemonics in panel menu items

This commit is contained in:
Arnaud Renevier 2008-08-10 14:17:21 +02:00 committed by Christian Dywan
parent 9a8c7d047f
commit cb0dd889e0
5 changed files with 45 additions and 21 deletions

View file

@ -34,16 +34,20 @@ stock_items_init (void)
{
static GtkStockItem items[] =
{
{ STOCK_BOOKMARKS },
{ STOCK_CONSOLE },
{ STOCK_EXTENSION },
{ STOCK_NEWS_FEED },
{ STOCK_LOCK_OPEN },
{ STOCK_LOCK_SECURE },
{ STOCK_LOCK_BROKEN },
{ STOCK_PAGE_HOLDER },
{ STOCK_SCRIPT },
{ STOCK_THEME },
{ STOCK_STYLE },
{ STOCK_TRANSFER },
{ STOCK_USER_TRASH },
{ STOCK_BOOKMARK, N_("Bookmark"), 0, 0, NULL },
{ STOCK_BOOKMARK, N_("_Bookmark"), 0, 0, NULL },
{ STOCK_BOOKMARK_ADD, N_("_Add Bookmark"), 0, 0, NULL },
{ STOCK_FORM_FILL, N_("_Form Fill"), 0, 0, NULL },
{ STOCK_HOMEPAGE, N_("_Homepage"), 0, 0, NULL },

View file

@ -30,9 +30,15 @@ KatzeXbelItem* bookmarks;
in order to reduce the amount of warnings */
#define STOCK_BOOKMARK GTK_STOCK_FILE /* "stock_bookmark" "bookmark-web" */
#define STOCK_BOOKMARKS "vcard"
#define STOCK_CONSOLE "terminal"
#define STOCK_EXTENSION GTK_STOCK_EXECUTE /* "extension" */
#define STOCK_FORM_FILL GTK_STOCK_JUSTIFY_FILL /* "insert-text" "form-fill" */
#define STOCK_HISTORY "document-open-recent"
#define STOCK_NEWS_FEED "news-feed"
#define STOCK_PAGE_HOLDER GTK_STOCK_CONVERT
#define STOCK_STYLE "gnome-settings-theme"
#define STOCK_TRANSFER "package"
/* We assume that these legacy icon names are usually present */
@ -46,7 +52,6 @@ KatzeXbelItem* bookmarks;
#define STOCK_SCRIPT "stock_script"
#define STOCK_SEND "stock_mail-send"
#define STOCK_TAB_NEW "stock_new-tab"
#define STOCK_THEME "gnome-settings-theme"
#define STOCK_USER_TRASH "gnome-stock-trash"
#define STOCK_WINDOW_NEW "stock_new-window"

View file

@ -3491,14 +3491,14 @@ midori_browser_init (MidoriBrowser* browser)
gtk_widget_show_all (toolbar);
midori_panel_append_page (MIDORI_PANEL (browser->panel),
box, toolbar,
"vcard", _("Bookmarks"));
STOCK_BOOKMARKS, _("Bookmarks"), _("_Bookmarks"));
/* Transfers */
GtkWidget* panel = midori_web_view_new ();
gtk_widget_show (panel);
midori_panel_append_page (MIDORI_PANEL (browser->panel),
panel, NULL,
"package", _("Transfers"));
STOCK_TRANSFER, _("Transfers"), _("_Transfers"));
/* Console */
browser->panel_console = midori_console_new ();
@ -3507,14 +3507,14 @@ midori_browser_init (MidoriBrowser* browser)
gtk_widget_show (toolbar);
midori_panel_append_page (MIDORI_PANEL (browser->panel),
browser->panel_console, toolbar,
"terminal", _("Console"));
STOCK_CONSOLE, _("Console"), _("_Console"));
/* History */
panel = midori_web_view_new ();
gtk_widget_show (panel);
midori_panel_append_page (MIDORI_PANEL (browser->panel),
panel, NULL,
"document-open-recent", _("History"));
STOCK_HISTORY, _("History"), _("_History"));
/* Pageholder */
browser->panel_pageholder = g_object_new (MIDORI_TYPE_WEB_VIEW,
@ -3523,7 +3523,7 @@ midori_browser_init (MidoriBrowser* browser)
gtk_widget_show (browser->panel_pageholder);
midori_panel_append_page (MIDORI_PANEL (browser->panel),
browser->panel_pageholder, NULL,
GTK_STOCK_CONVERT, _("Pageholder"));
STOCK_PAGE_HOLDER, _("Pageholder"), _("_Pageholder"));
/* Userscripts */
panel = midori_addons_new (GTK_WIDGET (browser), MIDORI_ADDON_USER_SCRIPTS);
@ -3532,7 +3532,7 @@ midori_browser_init (MidoriBrowser* browser)
gtk_widget_show (toolbar);
midori_panel_append_page (MIDORI_PANEL (browser->panel),
panel, toolbar,
STOCK_SCRIPT, _("Userscripts"));
STOCK_SCRIPT, _("Userscripts"), _("_Userscripts"));
/* Userstyles */
/*panel = midori_addons_new (GTK_WIDGET (browser), MIDORI_ADDON_USER_STYLES);
gtk_widget_show (panel);
@ -3540,7 +3540,7 @@ midori_browser_init (MidoriBrowser* browser)
gtk_widget_show (toolbar);
midori_panel_append_page (MIDORI_PANEL (browser->panel),
panel, toolbar,
"", _("Userstyles"));*/
STOCK_STYLE, _("Userstyles"), _("_Userstyles"));*/
/* Extensions */
panel = midori_addons_new (GTK_WIDGET (browser), MIDORI_ADDON_EXTENSIONS);
@ -3549,7 +3549,7 @@ midori_browser_init (MidoriBrowser* browser)
gtk_widget_show (toolbar);
midori_panel_append_page (MIDORI_PANEL (browser->panel),
panel, toolbar,
STOCK_EXTENSION, _("Extensions"));
STOCK_EXTENSION, _("Extensions"), _("_Extensions"));
/* Notebook, containing all web_views */
browser->notebook = gtk_notebook_new ();

View file

@ -339,6 +339,7 @@ midori_panel_menu_item_activate_cb (GtkWidget* widget,
* @toolbar: a toolbar widget, or %NULL
* @icon: a stock ID or icon name, or %NULL
* @label: a string to use as the label, or %NULL
* @mnemonic: a string to use as a mnemonic, or %NULL
*
* Appends a new page to the panel. If @toolbar is specified it will
* be packaged above @child.
@ -348,6 +349,9 @@ midori_panel_menu_item_activate_cb (GtkWidget* widget,
*
* If @label is given, it is used as the label of this page.
*
* If @mnemonic is given, it is used in labels with mnemonics
* such as menu items. See gtk_label_new_with_mnemonic().
*
* In the case of an error, -1 is returned.
*
* Return value: the index of the new page, or -1
@ -357,20 +361,30 @@ midori_panel_append_page (MidoriPanel* panel,
GtkWidget* child,
GtkWidget* toolbar,
const gchar* icon,
const gchar* label)
const gchar* label,
const gchar* mnemonic)
{
GtkWidget* scrolled;
GtkWidget* widget;
GObjectClass* gobject_class;
guint n;
const gchar* text;
const gchar* text_mnemonic;
GtkToolItem* toolitem;
GtkWidget* image;
GtkWidget* menuitem;
g_return_val_if_fail (MIDORI_IS_PANEL (panel), -1);
g_return_val_if_fail (GTK_IS_WIDGET (child), -1);
g_return_val_if_fail (!toolbar || GTK_IS_WIDGET (toolbar), -1);
GtkWidget* scrolled = gtk_scrolled_window_new (NULL, NULL);
scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
GTK_WIDGET_SET_FLAGS (scrolled, GTK_CAN_FOCUS);
gtk_widget_show (scrolled);
GtkWidget* widget;
GObjectClass* gobject_class = G_OBJECT_GET_CLASS (child);
gobject_class = G_OBJECT_GET_CLASS (child);
if (GTK_WIDGET_CLASS (gobject_class)->set_scroll_adjustments_signal)
widget = child;
else
@ -387,13 +401,13 @@ midori_panel_append_page (MidoriPanel* panel,
gtk_widget_show (toolbar);
gtk_container_add (GTK_CONTAINER (panel->toolbook), toolbar);
guint n = midori_panel_page_num (panel, child);
n = midori_panel_page_num (panel, child);
const gchar* text = label ? label : _("Untitled");
text = label ? label : _("Untitled");
text_mnemonic = mnemonic ? mnemonic : _("_Untitled");
g_object_set_data (G_OBJECT (child), "label", (gchar*)text);
GtkWidget* image;
GtkToolItem* toolitem = gtk_radio_tool_button_new (panel->group);
toolitem = gtk_radio_tool_button_new (panel->group);
panel->group = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (
toolitem));
gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem), text);
@ -410,7 +424,7 @@ midori_panel_append_page (MidoriPanel* panel,
if (panel->menu)
{
GtkWidget* menuitem = gtk_image_menu_item_new_with_label (text);
menuitem = gtk_image_menu_item_new_with_mnemonic (text_mnemonic);
if (icon)
{
image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_MENU);

View file

@ -58,7 +58,8 @@ midori_panel_append_page (MidoriPanel* panel,
GtkWidget* child,
GtkWidget* toolbar,
const gchar* icon,
const gchar* label);
const gchar* label,
const gchar* mnemonic);
gint
midori_panel_get_current_page (MidoriPanel* panel);