From 44bc12c305e7137e3b10f7ba86b383e249022a43 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Wed, 19 Mar 2008 14:46:08 +0100 Subject: [PATCH] Add common context menu items and cleanup. Add the actions UndoTabClose, BookmarkNew, SaveAs, SourceView and Print to the context menu. Also add UndoTabClose to the Go menu, remove STOCK_SOURCE_VIEW and remove ui.h which is obsolete. --- src/global.h | 1 - src/main.c | 1 - src/midori-browser.c | 36 +++++++++++++++++++++++++----------- src/midori-webview.c | 17 +++++++++++++++-- src/ui.h | 15 --------------- 5 files changed, 40 insertions(+), 30 deletions(-) delete mode 100644 src/ui.h diff --git a/src/global.h b/src/global.h index e81bc630..971f2651 100644 --- a/src/global.h +++ b/src/global.h @@ -40,7 +40,6 @@ MidoriWebSettings* webSettings; #define STOCK_NEWSFEED "gtk-index" // "newsfeed" #define STOCK_PLUGINS GTK_STOCK_CONVERT // "plugin" #define STOCK_POPUPS_BLOCKED "popup-hidden" -#define STOCK_SOURCE_VIEW "stock_view-html-source" // "view-source" #define STOCK_TAB_CLOSE GTK_STOCK_CLOSE // "tab-close" #define STOCK_WINDOW_CLOSE GTK_STOCK_CLOSE // "window-close" diff --git a/src/main.c b/src/main.c index 2fdf1854..ff7f45ed 100644 --- a/src/main.c +++ b/src/main.c @@ -47,7 +47,6 @@ static void stock_items_init(void) { STOCK_NEWSFEED, "Newsfeed", 0, 0, NULL }, { STOCK_PLUGINS, "_Plugins", 0, 0, NULL }, { STOCK_POPUPS_BLOCKED, "Blocked Popups", 0, 0, NULL }, - { STOCK_SOURCE_VIEW, "View Source", 0, 0, NULL }, { STOCK_TAB_CLOSE, "C_lose Tab", 0, 0, NULL }, { STOCK_TAB_NEW, "New _Tab", 0, 0, NULL }, { STOCK_WINDOW_CLOSE, "_Close Window", 0, 0, NULL }, diff --git a/src/midori-browser.c b/src/midori-browser.c index fafc3acb..71ca4749 100644 --- a/src/midori-browser.c +++ b/src/midori-browser.c @@ -396,13 +396,24 @@ midori_web_view_populate_popup_cb (GtkWidget* web_view, if (!uri && !webkit_web_view_has_selection (WEBKIT_WEB_VIEW (web_view))) { - // TODO: menu items - // UndoTabClose - // sep - // BookmarkNew - // SaveAs - // SourceView - // Print + GtkAction* action = _action_by_name (browser, "UndoTabClose"); + GtkWidget* menuitem = gtk_action_create_menu_item (action); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); + menuitem = gtk_separator_menu_item_new (); + gtk_widget_show (menuitem); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); + action = _action_by_name (browser, "BookmarkNew"); + menuitem = gtk_action_create_menu_item (action); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); + action = _action_by_name (browser, "SaveAs"); + menuitem = gtk_action_create_menu_item (action); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); + action = _action_by_name (browser, "SourceView"); + menuitem = gtk_action_create_menu_item (action); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); + action = _action_by_name (browser, "Print"); + menuitem = gtk_action_create_menu_item (action); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); } } @@ -1920,10 +1931,10 @@ static const GtkActionEntry entries[] = { { "ZoomNormal", GTK_STOCK_ZOOM_100, NULL, "0", "hm?", NULL/*G_CALLBACK (_action_zoom_normal_activate)*/ }, - { "SourceView", STOCK_SOURCE_VIEW, - NULL, "", + { "SourceView", NULL, + "View Source", "", "hm?", /*G_CALLBACK (_action_source_view_activate)*/ }, - { "SelectionSourceView", STOCK_SOURCE_VIEW, + { "SelectionSourceView", NULL, "View Selection Source", "", "hm?", NULL/*G_CALLBACK (_action_selection_source_view_activate)*/ }, { "Fullscreen", GTK_STOCK_FULLSCREEN, @@ -2151,6 +2162,7 @@ static const gchar* ui_markup = "" "" "" + "" "" "" "" @@ -2669,7 +2681,9 @@ midori_browser_set_property (GObject* object, case PROP_SETTINGS: katze_object_assign (priv->settings, g_value_get_object (value)); g_object_ref (priv->settings); - // FIXME: Assign settings to each web view + gtk_container_foreach (GTK_CONTAINER (priv->notebook), + (GtkCallback*) midori_web_view_set_settings, + priv->settings); break; case PROP_TRASH: ; // FIXME: Disconnect handlers diff --git a/src/midori-webview.c b/src/midori-webview.c index 4b2e250c..c61ad92c 100644 --- a/src/midori-webview.c +++ b/src/midori-webview.c @@ -458,7 +458,6 @@ midori_web_view_menu_new_tab_activate_cb (GtkWidget* widget, MidoriWebView* web_view) { const gchar* uri = g_object_get_data (G_OBJECT (widget), "uri"); - g_print ("selected: %s\n", uri); g_signal_emit (web_view, signals[NEW_TAB], 0, uri); } @@ -503,7 +502,7 @@ webkit_web_view_populate_popup_cb (GtkWidget* web_view, G_CALLBACK (midori_web_view_menu_new_tab_activate_cb), web_view); gtk_widget_show (menuitem); } - // FIXME: We are leaking 'text' which is not const be should be. + // FIXME: We are leaking 'text' which is not const but should be. } } @@ -755,6 +754,20 @@ midori_web_view_new (void) return GTK_WIDGET (web_view); } +/** + * midori_web_view_set_settings: + * @web_view: a #MidoriWebView + * @web_settings: a #MidoriWebSettings + * + * Assigns a settings instance to the web view. + **/ +void +midori_web_view_set_settings (MidoriWebView* web_view, + MidoriWebSettings* web_settings) +{ + g_object_set (web_view, "settings", web_settings, NULL); +} + /** * midori_web_view_get_proxy_menu_item: * @web_view: a #MidoriWebView diff --git a/src/ui.h b/src/ui.h deleted file mode 100644 index bc5d6a8b..00000000 --- a/src/ui.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - Copyright (C) 2007 Christian Dywan - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - See the file COPYING for the full license text. -*/ - -#ifndef __UI_H__ -#define __UI_H__ 1 - -#endif /* !__UI_H__ */