Allow hiding the menubar and showing it again

This commit is contained in:
Christian Dywan 2008-10-12 22:09:49 +02:00
parent 552854c11f
commit 36a99b9d22
4 changed files with 47 additions and 56 deletions

View file

@ -1407,6 +1407,10 @@ midori_browser_toolbar_popup_context_menu_cb (GtkWidget* toolbar,
GtkWidget* menuitem;
menu = gtk_menu_new ();
menuitem = sokoke_action_create_popup_menu_item (
_action_by_name (browser, "Menubar"));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
menuitem = sokoke_action_create_popup_menu_item (
_action_by_name (browser, "Navigationbar"));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
@ -1550,6 +1554,15 @@ _action_preferences_activate (GtkAction* action,
}
}
static void
_action_menubar_activate (GtkToggleAction* action,
MidoriBrowser* browser)
{
gboolean active = gtk_toggle_action_get_active (action);
g_object_set (browser->settings, "show-menubar", active, NULL);
sokoke_widget_set_visible (browser->menubar, active);
}
static void
_action_navigationbar_activate (GtkToggleAction* action,
MidoriBrowser* browser)
@ -3014,6 +3027,10 @@ static const GtkToggleActionEntry toggle_entries[] = {
N_("Don't save any private data while browsing"), NULL/*G_CALLBACK (_action_private_browsing_activate)*/,
FALSE },
{ "Menubar", NULL,
N_("_Menubar"), "",
N_("Show menubar"), G_CALLBACK (_action_menubar_activate),
FALSE },
{ "Navigationbar", NULL,
N_("_Navigationbar"), "",
N_("Show navigationbar"), G_CALLBACK (_action_navigationbar_activate),
@ -3120,6 +3137,7 @@ static const gchar* ui_markup =
"</menu>"
"<menu action='View'>"
"<menu action='Toolbars'>"
"<menuitem action='Menubar'/>"
"<menuitem action='Navigationbar'/>"
"<menuitem action='Bookmarkbar'/>"
"<menuitem action='Transferbar'/>"
@ -3408,7 +3426,8 @@ midori_browser_init (MidoriBrowser* browser)
menuitem = gtk_separator_menu_item_new ();
gtk_widget_show (menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (browser->menu_tools), menuitem);
gtk_widget_show (browser->menubar);
gtk_widget_hide (browser->menubar);
_action_set_sensitive (browser, "SaveAs", FALSE);
_action_set_sensitive (browser, "PrivateBrowsing", FALSE);
_action_set_sensitive (browser, "FindQuick", FALSE);
@ -3823,7 +3842,8 @@ _midori_browser_update_settings (MidoriBrowser* browser)
gboolean remember_last_window_size;
gint last_window_width, last_window_height;
gint last_panel_position, last_panel_page;
gboolean show_navigationbar, show_bookmarkbar, show_panel, show_statusbar;
gboolean show_menubar, show_navigationbar, show_bookmarkbar;
gboolean show_panel, show_statusbar;
MidoriToolbarStyle toolbar_style;
gchar* toolbar_items;
gint last_web_search;
@ -3839,6 +3859,7 @@ _midori_browser_update_settings (MidoriBrowser* browser)
"last-window-height", &last_window_height,
"last-panel-position", &last_panel_position,
"last-panel-page", &last_panel_page,
"show-menubar", &show_menubar,
"show-navigationbar", &show_navigationbar,
"show-bookmarkbar", &show_bookmarkbar,
"show-panel", &show_panel,
@ -3883,6 +3904,7 @@ _midori_browser_update_settings (MidoriBrowser* browser)
midori_view_set_uri (MIDORI_VIEW (browser->panel_pageholder),
last_pageholder_uri);
_action_set_active (browser, "Menubar", show_menubar);
_action_set_active (browser, "Navigationbar", show_navigationbar);
_action_set_active (browser, "Bookmarkbar", show_bookmarkbar);
_action_set_active (browser, "Panel", show_panel);

View file

@ -28,6 +28,7 @@ struct _MidoriWebSettings
gint last_web_search;
gchar* last_pageholder_uri;
gboolean show_menubar;
gboolean show_navigationbar;
gboolean show_bookmarkbar;
gboolean show_panel;
@ -82,6 +83,7 @@ enum
PROP_LAST_WEB_SEARCH,
PROP_LAST_PAGEHOLDER_URI,
PROP_SHOW_MENUBAR,
PROP_SHOW_NAVIGATIONBAR,
PROP_SHOW_BOOKMARKBAR,
PROP_SHOW_PANEL,
@ -301,6 +303,14 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
flags));
g_object_class_install_property (gobject_class,
PROP_SHOW_MENUBAR,
g_param_spec_boolean (
"show-menubar",
_("Show Menubar"),
_("Whether to show the menubar"),
TRUE,
flags));
g_object_class_install_property (gobject_class,
PROP_SHOW_NAVIGATIONBAR,
@ -677,6 +687,9 @@ midori_web_settings_set_property (GObject* object,
katze_assign (web_settings->last_pageholder_uri, g_value_dup_string (value));
break;
case PROP_SHOW_MENUBAR:
web_settings->show_menubar = g_value_get_boolean (value);
break;
case PROP_SHOW_NAVIGATIONBAR:
web_settings->show_navigationbar = g_value_get_boolean (value);
break;
@ -837,6 +850,9 @@ midori_web_settings_get_property (GObject* object,
g_value_set_string (value, web_settings->last_pageholder_uri);
break;
case PROP_SHOW_MENUBAR:
g_value_set_boolean (value, web_settings->show_menubar);
break;
case PROP_SHOW_NAVIGATIONBAR:
g_value_set_boolean (value, web_settings->show_navigationbar);
break;
@ -962,53 +978,3 @@ midori_web_settings_new (void)
return web_settings;
}
/**
* midori_web_settings_copy:
*
* Copies an existing #MidoriWebSettings instance.
*
* Return value: a new #MidoriWebSettings
**/
MidoriWebSettings*
midori_web_settings_copy (MidoriWebSettings* web_settings)
{
g_return_val_if_fail (MIDORI_IS_WEB_SETTINGS (web_settings), NULL);
MidoriWebSettings* copy;
copy = MIDORI_WEB_SETTINGS (webkit_web_settings_copy (
WEBKIT_WEB_SETTINGS (web_settings)));
g_object_set (copy,
"load-on-startup", web_settings->load_on_startup,
"homepage", web_settings->homepage,
"download-folder", web_settings->download_folder,
"download-manager", web_settings->download_manager,
"location-entry-search", web_settings->location_entry_search,
"preferred-encoding", web_settings->preferred_encoding,
"toolbar-style", web_settings->toolbar_style,
"toolbar-items", web_settings->toolbar_items,
"show-web-search", web_settings->show_web_search,
"show-new-tab", web_settings->show_new_tab,
"show-trash", web_settings->show_trash,
"close-buttons-on-tabs", web_settings->close_buttons_on_tabs,
"open-new-pages-in", web_settings->open_new_pages_in,
"middle-click-opens-selection", web_settings->middle_click_opens_selection,
"open-tabs-in-the-background", web_settings->open_tabs_in_the_background,
"open-popups-in-tabs", web_settings->open_popups_in_tabs,
"accept-cookies", web_settings->accept_cookies,
"original-cookies-only", web_settings->original_cookies_only,
"maximum-cookie-age", web_settings->maximum_cookie_age,
"remember-last-visited-pages", web_settings->remember_last_visited_pages,
"maximum-history-age", web_settings->maximum_history_age,
"remember-last-form-inputs", web_settings->remember_last_form_inputs,
"remember-last-downloaded-files", web_settings->remember_last_downloaded_files,
"cache-size", web_settings->cache_size,
NULL);
return copy;
}

View file

@ -115,9 +115,6 @@ midori_web_settings_get_type (void);
MidoriWebSettings*
midori_web_settings_new (void);
MidoriWebSettings*
midori_web_settings_copy (MidoriWebSettings* web_settings);
G_END_DECLS
#endif /* __MIDORI_WEB_SETTINGS_H__ */

View file

@ -590,7 +590,13 @@ sokoke_action_create_popup_menu_item (GtkAction* action)
"sensitive", &sensitive,
"visible", &visible,
NULL);
if (stock_id)
if (GTK_IS_TOGGLE_ACTION (action))
{
menuitem = gtk_check_menu_item_new_with_mnemonic (label);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem),
gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
}
else if (stock_id)
{
if (label)
{