GtkWidget* panel_pageholder;
GtkWidget* notebook;
+ GtkWidget* inspector;
+ GtkWidget* inspector_view;
+
GtkWidget* find;
GtkWidget* find_text;
GtkToolItem* find_case;
"stock-id", GTK_STOCK_STOP,
"tooltip", _("Stop loading the current page"), NULL);
gtk_widget_show (browser->progressbar);
- if (!GTK_WIDGET_VISIBLE (browser->statusbar) && !GTK_WIDGET_VISIBLE (browser->navigationbar))
+ if (!GTK_WIDGET_VISIBLE (browser->statusbar)
+ && !GTK_WIDGET_VISIBLE (browser->navigationbar))
gtk_widget_show (browser->navigationbar);
action = _action_by_name (browser, "Location");
midori_location_action_set_progress (MIDORI_LOCATION_ACTION (action),
message, line, source_id);
}
+static void
+midori_view_attach_inspector_cb (GtkWidget* view,
+ GtkWidget* inspector_view,
+ MidoriBrowser* browser)
+{
+ GtkWidget* scrolled = gtk_widget_get_parent (browser->inspector_view);
+ gtk_container_remove (GTK_CONTAINER (scrolled), browser->inspector_view);
+ gtk_container_add (GTK_CONTAINER (scrolled), inspector_view);
+ browser->inspector_view = inspector_view;
+}
+
static void
midori_view_new_tab_cb (GtkWidget* view,
const gchar* uri,
midori_view_activate_action_cb, browser,
"signal::console-message",
midori_view_console_message_cb, browser,
+ "signal::attach-inspector",
+ midori_view_attach_inspector_cb, browser,
"signal::new-tab",
midori_view_new_tab_cb, browser,
"signal::new-window",
N_("Find the next occurrence of a word or phrase"), G_CALLBACK (_action_find_next_activate) },
{ "FindPrevious", GTK_STOCK_GO_BACK,
N_("Find _Previous"), "<Ctrl><Shift>g",
- N_("Find the previous occurrence of a word or phrase"), G_CALLBACK (_action_find_previous_activate) },
+ N_("Find the previous occurrence of a word or phrase"),
+ G_CALLBACK (_action_find_previous_activate) },
{ "FindQuick", GTK_STOCK_FIND,
N_("_Quick Find"), "period",
N_("Quickly jump to a word or phrase"), NULL/*G_CALLBACK (_action_find_quick_activate)*/ },
N_("View the source code of the page"), G_CALLBACK (_action_source_view_activate) },
{ "SelectionSourceView", NULL,
N_("View Selection Source"), "",
- N_("View the source code of the selection"), NULL/*G_CALLBACK (_action_selection_source_view_activate)*/ },
+ N_("View the source code of the selection"),
+ NULL/*G_CALLBACK (_action_selection_source_view_activate)*/ },
{ "Fullscreen", GTK_STOCK_FULLSCREEN,
NULL, "F11",
N_("Toggle fullscreen view"), G_CALLBACK (_action_fullscreen_activate) },
N_("Clear the entire history"), G_CALLBACK (_action_history_clear_activate) },
{ "HistoryAddBookmark", STOCK_BOOKMARK_ADD,
NULL, "",
- N_("Add the selected history item as a bookmark"), G_CALLBACK (_action_history_add_bookmark_activate) },
+ N_("Add the selected history item as a bookmark"),
+ G_CALLBACK (_action_history_add_bookmark_activate) },
{ "Tools", NULL, N_("_Tools") },
{ "ManageSearchEngines", GTK_STOCK_PROPERTIES,
N_("_Manage Search Engines"), "<Ctrl><Alt>s",
static const GtkToggleActionEntry toggle_entries[] = {
{ "PrivateBrowsing", NULL,
N_("P_rivate Browsing"), "",
- N_("Don't save any private data while browsing"), NULL/*G_CALLBACK (_action_private_browsing_activate)*/,
+ N_("Don't save any private data while browsing"),
+ NULL/*G_CALLBACK (_action_private_browsing_activate)*/,
FALSE },
{ "Menubar", NULL,
static void
midori_browser_init (MidoriBrowser* browser)
{
+ GtkWidget* vbox;
+ GtkUIManager* ui_manager;
+ GError* error;
+ GtkAction* action;
+ GtkWidget* menuitem;
+ GtkSettings* gtk_settings;
+ GtkWidget* hbox;
+ GtkWidget* hpaned;
+ GtkWidget* vpaned;
+ GtkWidget* box;
+ GtkTreeViewColumn* column;
+ GtkCellRenderer* renderer_text;
+ GtkCellRenderer* renderer_pixbuf;
+ GtkTreeStore* treestore;
+ GtkWidget* treeview;
+ GtkWidget* toolbar;
GtkToolItem* toolitem;
+ GtkWidget* panel;
GtkRcStyle* rcstyle;
- GtkAction* action;
+ GtkWidget* scrolled;
browser->net = katze_net_new ();
G_CALLBACK (midori_browser_destroy_cb), NULL);
gtk_window_set_icon_name (GTK_WINDOW (browser), "web-browser");
gtk_window_set_title (GTK_WINDOW (browser), g_get_application_name ());
- GtkWidget* vbox = gtk_vbox_new (FALSE, 0);
+ vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (browser), vbox);
gtk_widget_show (vbox);
entries, entries_n, browser);
gtk_action_group_add_toggle_actions (browser->action_group,
toggle_entries, toggle_entries_n, browser);
- GtkUIManager* ui_manager = gtk_ui_manager_new ();
+ ui_manager = gtk_ui_manager_new ();
gtk_ui_manager_insert_action_group (ui_manager, browser->action_group, 0);
gtk_window_add_accel_group (GTK_WINDOW (browser),
gtk_ui_manager_get_accel_group (ui_manager));
- GError* error = NULL;
+ error = NULL;
if (!gtk_ui_manager_add_ui_from_string (ui_manager, ui_markup, -1, &error))
{
/* TODO: Should this be a message dialog? When does this happen? */
/* Create the menubar */
browser->menubar = gtk_ui_manager_get_widget (ui_manager, "/menubar");
- GtkWidget* menuitem = gtk_menu_item_new ();
+ menuitem = gtk_menu_item_new ();
gtk_widget_show (menuitem);
browser->throbber = katze_throbber_new ();
gtk_widget_show (browser->throbber);
browser->navigationbar = gtk_ui_manager_get_widget (
ui_manager, "/toolbar_navigation");
/* FIXME: settings should be connected with screen changes */
- GtkSettings* gtk_settings = gtk_widget_get_settings (GTK_WIDGET (browser));
+ gtk_settings = gtk_widget_get_settings (GTK_WIDGET (browser));
if (gtk_settings)
g_signal_connect (gtk_settings, "notify::gtk-toolbar-style",
G_CALLBACK (midori_browser_navigationbar_notify_style_cb), browser);
G_CALLBACK (midori_browser_toolbar_popup_context_menu_cb), browser);
/* Superuser warning */
- GtkWidget* hbox;
if ((hbox = sokoke_superuser_warning_new ()))
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
/* Create the panel */
- GtkWidget* hpaned = gtk_hpaned_new ();
+ hpaned = gtk_hpaned_new ();
g_signal_connect (hpaned, "notify::position",
G_CALLBACK (midori_panel_notify_position_cb),
browser);
gtk_paned_pack1 (GTK_PANED (hpaned), browser->panel, FALSE, FALSE);
/* Bookmarks */
- GtkWidget* box = gtk_vbox_new (FALSE, 0);
- GtkTreeViewColumn* column;
- GtkCellRenderer* renderer_text;
- GtkCellRenderer* renderer_pixbuf;
- GtkTreeStore* treestore = gtk_tree_store_new (1, KATZE_TYPE_ITEM);
- GtkWidget* treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (treestore));
+ box = gtk_vbox_new (FALSE, 0);
+ treestore = gtk_tree_store_new (1, KATZE_TYPE_ITEM);
+ treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (treestore));
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
column = gtk_tree_view_column_new ();
renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
gtk_box_pack_start (GTK_BOX (box), treeview, TRUE, TRUE, 0);
browser->panel_bookmarks = treeview;
gtk_widget_show_all (box);
- GtkWidget* toolbar = gtk_ui_manager_get_widget (ui_manager,
- "/toolbar_bookmarks");
+ toolbar = gtk_ui_manager_get_widget (ui_manager, "/toolbar_bookmarks");
_action_set_sensitive (browser, "BookmarkAdd", FALSE);
gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_MENU);
gtk_widget_show_all (toolbar);
STOCK_BOOKMARKS, _("Bookmarks"));
/* Transfers */
- GtkWidget* panel = midori_view_new (browser->net);
+ panel = midori_view_new (browser->net);
gtk_widget_show (panel);
midori_panel_append_page (MIDORI_PANEL (browser->panel),
panel, NULL,
STOCK_EXTENSIONS, _("Extensions"));
/* Notebook, containing all views */
+ vpaned = gtk_vpaned_new ();
+ gtk_paned_pack2 (GTK_PANED (hpaned), vpaned, FALSE, FALSE);
+ gtk_widget_show (vpaned);
browser->notebook = gtk_notebook_new ();
/* Remove the inner border between scrollbars and the window border */
rcstyle = gtk_rc_style_new ();
gtk_widget_modify_style (browser->notebook, rcstyle);
g_object_unref (rcstyle);
gtk_notebook_set_scrollable (GTK_NOTEBOOK (browser->notebook), TRUE);
- gtk_paned_pack2 (GTK_PANED (hpaned), browser->notebook, FALSE, FALSE);
+ gtk_paned_pack2 (GTK_PANED (vpaned), browser->notebook, FALSE, FALSE);
g_signal_connect_after (browser->notebook, "switch-page",
G_CALLBACK (gtk_notebook_switch_page_cb),
browser);
gtk_widget_show (browser->notebook);
+ /* Inspector container */
+ browser->inspector = gtk_vbox_new (FALSE, 0);
+ gtk_paned_pack2 (GTK_PANED (vpaned), browser->inspector, TRUE, TRUE);
+ 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_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+ GTK_SHADOW_ETCHED_IN);
+ gtk_box_pack_start (GTK_BOX (browser->inspector),
+ scrolled, TRUE, TRUE, 0);
+ browser->inspector_view = webkit_web_view_new ();
+ gtk_container_add (GTK_CONTAINER (scrolled), browser->inspector_view);
+ gtk_widget_show_all (browser->inspector);
+
/* Incremental findbar */
browser->find = gtk_toolbar_new ();
gtk_toolbar_set_icon_size (GTK_TOOLBAR (browser->find), GTK_ICON_SIZE_MENU);
enum {
ACTIVATE_ACTION,
CONSOLE_MESSAGE,
+ ATTACH_INSPECTOR,
WINDOW_OBJECT_CLEARED,
NEW_TAB,
NEW_WINDOW,
G_TYPE_INT,
G_TYPE_STRING);
+ signals[ATTACH_INSPECTOR] = g_signal_new (
+ "attach-inspector",
+ G_TYPE_FROM_CLASS (class),
+ (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ 0,
+ 0,
+ NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ GTK_TYPE_WIDGET);
+
signals[WINDOW_OBJECT_CLEARED] = g_signal_new (
"window-object-cleared",
G_TYPE_FROM_CLASS (class),
return view->progress;
}
+#ifdef WEBKIT_CHECK_VERSION
+#if WEBKIT_CHECK_VERSION (1, 0, 3)
+static WebKitWebView*
+webkit_web_inspector_inspect_web_view_cb (WebKitWebInspector* inspector,
+ WebKitWebView* web_view,
+ MidoriView* view)
+{
+ gchar* title;
+ GtkWidget* window;
+ GtkWidget* toplevel;
+ GdkScreen* screen;
+ gint width, height;
+ GtkIconTheme* icon_theme;
+ GdkPixbuf* icon;
+ GdkPixbuf* gray_icon;
+ GtkWidget* inspector_view;
+
+ title = g_strdup_printf (_("Inspect page - %s"), "");
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title (GTK_WINDOW (window), title);
+ g_free (title);
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view));
+ if (GTK_WIDGET_TOPLEVEL (toplevel))
+ {
+ gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (toplevel));
+ screen = gtk_window_get_screen (GTK_WINDOW (toplevel));
+ width = gdk_screen_get_width (screen) / 1.7;
+ height = gdk_screen_get_height (screen) / 1.7;
+ gtk_window_set_default_size (GTK_WINDOW (window), width, height);
+ }
+
+ /* Attempt to make a gray version of the icon on the fly */
+ icon_theme = gtk_icon_theme_get_for_screen (
+ gtk_widget_get_screen (GTK_WIDGET (view)));
+ icon = gtk_icon_theme_load_icon (icon_theme, "midori", 32,
+ GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
+ if (icon)
+ {
+ gray_icon = gdk_pixbuf_copy (icon);
+ if (gray_icon)
+ {
+ gdk_pixbuf_saturate_and_pixelate (gray_icon, gray_icon, 0.1, FALSE);
+ gtk_window_set_icon (GTK_WINDOW (window), gray_icon);
+ g_object_unref (gray_icon);
+ }
+ g_object_unref (icon);
+ }
+ else
+ gtk_window_set_icon_name (GTK_WINDOW (window), "midori");
+ inspector_view = webkit_web_view_new ();
+ gtk_container_add (GTK_CONTAINER (window), inspector_view);
+
+ /* FIXME: Implement web inspector signals properly
+ FIXME: Save and restore window size
+ FIXME: Update window title with URI */
+ gtk_widget_show_all (window);
+ /* inspector_view = webkit_web_view_new ();
+ gtk_widget_show (inspector_view);
+ g_signal_emit (view, signals[ATTACH_INSPECTOR], 0, inspector_view); */
+ return WEBKIT_WEB_VIEW (inspector_view);
+}
+#endif
+#endif
+
static void
midori_view_construct_web_view (MidoriView* view)
{
WebKitWebFrame* web_frame;
+ #ifdef WEBKIT_CHECK_VERSION
+ #if WEBKIT_CHECK_VERSION (1, 0, 3)
+ WebKitWebInspector* inspector;
+ #endif
+ #endif
view->web_view = webkit_web_view_new ();
gtk_widget_show (view->web_view);
gtk_container_add (GTK_CONTAINER (view), view->web_view);
+
+ #ifdef WEBKIT_CHECK_VERSION
+ #if WEBKIT_CHECK_VERSION (1, 0, 3)
+ inspector = webkit_web_view_get_inspector (WEBKIT_WEB_VIEW (view->web_view));
+ g_object_connect (inspector,
+ "signal::inspect-web-view",
+ webkit_web_inspector_inspect_web_view_cb, view,
+ NULL);
+ #endif
+ #endif
}
/**