[Xfce4-commits] <midori:master> Optionally open panels in standalone windows by default

Christian Dywan noreply at xfce.org
Sun Nov 29 14:12:11 CET 2009


Updating branch refs/heads/master
         to 5a65ed6253a2a33be6690d7db878e6e777de9a09 (commit)
       from 565e32599e362056cb8cd8be960d1c60aa258487 (commit)

commit 5a65ed6253a2a33be6690d7db878e6e777de9a09
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sat Nov 28 23:53:49 2009 +0100

    Optionally open panels in standalone windows by default

 midori/midori-browser.c     |   10 ++++-
 midori/midori-panel.c       |   80 ++++++++++++++++++++++++++++++++----------
 midori/midori-preferences.c |    6 +---
 midori/midori-websettings.c |   24 +++++++++++++
 4 files changed, 94 insertions(+), 26 deletions(-)

diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index 6066072..c2e3fdb 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -6239,7 +6239,8 @@ _midori_browser_update_settings (MidoriBrowser* browser)
     gboolean remember_last_window_size;
     gint last_window_width, last_window_height;
     MidoriWindowState last_window_state;
-    gboolean compact_sidepanel, show_panel_controls, right_align_sidepanel;
+    gboolean compact_sidepanel, show_panel_controls;
+    gboolean right_align_sidepanel, open_panels_in_windows;
     gint last_panel_position, last_panel_page;
     gboolean show_menubar, show_bookmarkbar;
     gboolean show_panel, show_transferbar;
@@ -6262,6 +6263,7 @@ _midori_browser_update_settings (MidoriBrowser* browser)
                   "compact-sidepanel", &compact_sidepanel,
                   "show-panel-controls", &show_panel_controls,
                   "right-align-sidepanel", &right_align_sidepanel,
+                  "open-panels-in-windows", &open_panels_in_windows,
                   "last-panel-position", &last_panel_position,
                   "last-panel-page", &last_panel_page,
                   "show-menubar", &show_menubar,
@@ -6336,7 +6338,8 @@ _midori_browser_update_settings (MidoriBrowser* browser)
 
     g_object_set (browser->panel, "show-titles", !compact_sidepanel,
         "show-controls", show_panel_controls,
-        "right-aligned", right_align_sidepanel, NULL);
+        "right-aligned", right_align_sidepanel,
+        "open-panels-in-windows", open_panels_in_windows, NULL);
     gtk_paned_set_position (GTK_PANED (gtk_widget_get_parent (browser->panel)),
                             last_panel_position);
     /* The browser may not yet be visible, which means that we can't set the
@@ -6397,6 +6400,9 @@ midori_browser_settings_notify (MidoriWebSettings* web_settings,
         g_signal_handlers_unblock_by_func (browser->panel,
             midori_panel_notify_show_controls_cb, browser);
     }
+    else if (name == g_intern_string ("open-panels-in-windows"))
+        g_object_set (browser->panel, "open-panels-in-windows",
+                      g_value_get_boolean (&value), NULL);
     else if (name == g_intern_string ("always-show-tabbar"))
         _toggle_tabbar_smartly (browser);
     else if (name == g_intern_string ("show-menubar"))
diff --git a/midori/midori-panel.c b/midori/midori-panel.c
index 02e2f3d..bb1af4e 100644
--- a/midori/midori-panel.c
+++ b/midori/midori-panel.c
@@ -43,6 +43,7 @@ struct _MidoriPanel
     gboolean show_titles;
     gboolean show_controls;
     gboolean right_aligned;
+    gboolean open_panels_in_windows;
 };
 
 struct _MidoriPanelClass
@@ -67,6 +68,7 @@ enum
     PROP_SHOW_TITLES,
     PROP_SHOW_CONTROLS,
     PROP_RIGHT_ALIGNED,
+    PROP_OPEN_PANELS_IN_WINDOWS,
 };
 
 enum {
@@ -237,6 +239,22 @@ midori_panel_class_init (MidoriPanelClass* class)
                                      "Whether the panel is aligned to the right",
                                      FALSE,
                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+    /**
+     * MidoriWebSettings:open-panels-in-windows:
+     *
+     * Whether to open panels in separate windows.
+     *
+     * Since: 0.2.2
+     */
+    g_object_class_install_property (gobject_class,
+                                     PROP_OPEN_PANELS_IN_WINDOWS,
+                                     g_param_spec_boolean (
+                                     "open-panels-in-windows",
+                                     "Open panels in windows",
+        "Whether to open panels in standalone windows by default",
+                                     FALSE,
+                                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 }
 
 static void
@@ -266,6 +284,7 @@ midori_panel_detached_window_delete_event_cb (GtkWidget*   window,
     GtkWidget* scrolled = g_object_get_data (G_OBJECT (window), "scrolled");
     GtkWidget* toolbar = g_object_get_data (G_OBJECT (scrolled), "panel-toolbar");
     GtkWidget* menuitem = g_object_get_data (G_OBJECT (scrolled), "panel-menuitem");
+    GtkWidget* viewable = _midori_panel_child_for_scrolled (panel, scrolled);
     GtkToolItem* toolitem;
     gint n;
 
@@ -277,13 +296,9 @@ midori_panel_detached_window_delete_event_cb (GtkWidget*   window,
     gtk_container_remove (GTK_CONTAINER (vbox), scrolled);
     n = gtk_notebook_append_page (GTK_NOTEBOOK (panel->notebook), scrolled, NULL);
     g_object_unref (scrolled);
-    toolitem = midori_panel_construct_tool_item (panel,
-        MIDORI_VIEWABLE (_midori_panel_child_for_scrolled (panel, scrolled)));
+    toolitem = midori_panel_construct_tool_item (panel, MIDORI_VIEWABLE (viewable));
     if (menuitem)
-    {
-        gtk_widget_show (menuitem);
         g_object_set_data (G_OBJECT (menuitem), "toolitem", toolitem);
-    }
     midori_panel_set_current_page (panel, n);
     return FALSE;
 }
@@ -298,13 +313,9 @@ midori_panel_widget_destroy_cb (GtkWidget* viewable,
 }
 
 static void
-midori_panel_button_detach_clicked_cb (GtkWidget*   toolbutton,
-                                       MidoriPanel* panel)
+midori_panel_detach_page (MidoriPanel* panel,
+                          gint         n)
 {
-    /* FIXME: What happens when the browser is destroyed? */
-    /* FIXME: What about multiple browsers? */
-    /* FIXME: Should we remember if the child was detached? */
-    gint n = midori_panel_get_current_page (panel);
     GtkToolItem* toolitem = gtk_toolbar_get_nth_item (
         GTK_TOOLBAR (panel->toolbar), n);
     const gchar* title = gtk_tool_button_get_label (GTK_TOOL_BUTTON (toolitem));
@@ -312,7 +323,6 @@ midori_panel_button_detach_clicked_cb (GtkWidget*   toolbutton,
         GTK_NOTEBOOK (panel->toolbook), n);
     GtkWidget* scrolled = gtk_notebook_get_nth_page (
         GTK_NOTEBOOK (panel->notebook), n);
-    GtkWidget* menuitem = g_object_get_data (G_OBJECT (scrolled), "panel-menuitem");
     GtkWidget* vbox = gtk_vbox_new (FALSE, 0);
     #if HAVE_HILDON
     GtkWidget* window = hildon_window_new ();
@@ -328,8 +338,6 @@ midori_panel_button_detach_clicked_cb (GtkWidget*   toolbutton,
     gtk_container_add (GTK_CONTAINER (window), vbox);
     g_object_set_data (G_OBJECT (window), "scrolled", scrolled);
     gtk_window_set_title (GTK_WINDOW (window), title);
-    if (menuitem)
-        gtk_widget_hide (menuitem);
     g_signal_handlers_disconnect_by_func (
         _midori_panel_child_for_scrolled (panel, scrolled),
         midori_panel_widget_destroy_cb, toolitem);
@@ -351,13 +359,24 @@ midori_panel_button_detach_clicked_cb (GtkWidget*   toolbutton,
     toolitem = gtk_toolbar_get_nth_item (GTK_TOOLBAR (panel->toolbar),
                                          n > 0 ? n - 1 : 0);
     if (!gtk_notebook_get_n_pages (GTK_NOTEBOOK (panel->notebook)))
-        gtk_widget_set_sensitive (toolbutton, FALSE);
+        gtk_widget_set_sensitive (GTK_WIDGET (panel->button_detach), FALSE);
     g_signal_connect (window, "delete-event",
         G_CALLBACK (midori_panel_detached_window_delete_event_cb), panel);
     gtk_widget_show (window);
 }
 
 static void
+midori_panel_button_detach_clicked_cb (GtkWidget*   toolbutton,
+                                       MidoriPanel* panel)
+{
+    /* FIXME: What happens when the browser is destroyed? */
+    /* FIXME: What about multiple browsers? */
+    /* FIXME: Should we remember if the child was detached? */
+    gint n = midori_panel_get_current_page (panel);
+    midori_panel_detach_page (panel, n);
+}
+
+static void
 midori_panel_button_align_clicked_cb (GtkWidget*   toolitem,
                                       MidoriPanel* panel)
 {
@@ -510,6 +529,9 @@ midori_panel_set_property (GObject*      object,
     case PROP_RIGHT_ALIGNED:
         midori_panel_set_right_aligned (panel, g_value_get_boolean (value));
         break;
+    case PROP_OPEN_PANELS_IN_WINDOWS:
+        panel->open_panels_in_windows = g_value_get_boolean (value);
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
         break;
@@ -548,6 +570,9 @@ midori_panel_get_property (GObject*    object,
     case PROP_RIGHT_ALIGNED:
         g_value_set_boolean (value, panel->right_aligned);
         break;
+    case PROP_OPEN_PANELS_IN_WINDOWS:
+        g_value_set_boolean (value, panel->open_panels_in_windows);
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
         break;
@@ -719,11 +744,27 @@ static void
 midori_panel_action_activate_cb (GtkRadioAction* action,
                                  MidoriPanel*    panel)
 {
-    gint n = katze_object_get_int (action, "value");
+    GtkWidget* viewable = g_object_get_data (G_OBJECT (action), "viewable");
+    gint n = midori_panel_page_num (panel, viewable);
 
-    midori_panel_set_current_page (panel, n);
-    g_signal_emit (panel, signals[SWITCH_PAGE], 0, n);
-    gtk_widget_show (GTK_WIDGET (panel));
+    /* If the panel is detached, focus the window */
+    if (n == -1)
+    {
+        GtkWidget* toplevel = gtk_widget_get_toplevel (viewable);
+        gtk_window_present (GTK_WINDOW (toplevel));
+        return;
+    }
+
+    if (panel->open_panels_in_windows
+     && gtk_radio_action_get_current_value (action)
+     == katze_object_get_int (action, "value"))
+        midori_panel_detach_page (panel, n);
+    else
+    {
+        midori_panel_set_current_page (panel, n);
+        g_signal_emit (panel, signals[SWITCH_PAGE], 0, n);
+        gtk_widget_show (GTK_WIDGET (panel));
+    }
 }
 
 /**
@@ -808,6 +849,7 @@ midori_panel_append_page (MidoriPanel*    panel,
     action = (GtkAction*)gtk_radio_action_new (action_name,
         midori_viewable_get_label (viewable),
         NULL, midori_viewable_get_stock_id (viewable), n);
+    g_object_set_data (G_OBJECT (action), "viewable", viewable);
     g_signal_connect (action, "activate",
         G_CALLBACK (midori_panel_action_activate_cb), panel);
     if (panel->action_group)
diff --git a/midori/midori-preferences.c b/midori/midori-preferences.c
index b8d919e..c818f9d 100644
--- a/midori/midori-preferences.c
+++ b/midori/midori-preferences.c
@@ -405,11 +405,7 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
         GTK_WIDGET (parent) : GTK_WIDGET (preferences)))
         button = katze_property_proxy (settings, "kinetic-scrolling", NULL);
     else
-    {
-        button = katze_property_proxy (settings, "auto-shrink-images", NULL);
-        gtk_button_set_label (GTK_BUTTON (button), _("Shrink images automatically"));
-        gtk_widget_set_tooltip_text (button, _("Automatically shrink standalone images to fit"));
-    }
+        button = katze_property_proxy (settings, "open-panels-in-windows", NULL);
     #else
     button = katze_property_proxy (settings, "middle-click-opens-selection", NULL);
     #endif
diff --git a/midori/midori-websettings.c b/midori/midori-websettings.c
index 858fca2..e8ce8b9 100644
--- a/midori/midori-websettings.c
+++ b/midori/midori-websettings.c
@@ -50,6 +50,7 @@ struct _MidoriWebSettings
     gboolean compact_sidepanel;
     gboolean show_panel_controls;
     gboolean right_align_sidepanel;
+    gboolean open_panels_in_windows;
 
     MidoriStartup load_on_startup;
     gchar* homepage;
@@ -125,6 +126,7 @@ enum
     PROP_COMPACT_SIDEPANEL,
     PROP_SHOW_PANEL_CONTROLS,
     PROP_RIGHT_ALIGN_SIDEPANEL,
+    PROP_OPEN_PANELS_IN_WINDOWS,
 
     PROP_LOAD_ON_STARTUP,
     PROP_HOMEPAGE,
@@ -567,6 +569,22 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
                                      FALSE,
                                      flags));
 
+    /**
+     * MidoriWebSettings:open-panels-in-window:
+     *
+     * Whether to open panels in separate windows.
+     *
+     * Since: 0.2.2
+     */
+    g_object_class_install_property (gobject_class,
+                                     PROP_OPEN_PANELS_IN_WINDOWS,
+                                     g_param_spec_boolean (
+                                     "open-panels-in-windows",
+                                     _("Open panels in separate windows"),
+        _("Whether to always open panels in separate windows"),
+                                     FALSE,
+                                     flags));
+
 
     g_object_class_install_property (gobject_class,
                                      PROP_LOAD_ON_STARTUP,
@@ -1250,6 +1268,9 @@ midori_web_settings_set_property (GObject*      object,
     case PROP_RIGHT_ALIGN_SIDEPANEL:
         web_settings->right_align_sidepanel = g_value_get_boolean (value);
         break;
+    case PROP_OPEN_PANELS_IN_WINDOWS:
+        web_settings->open_panels_in_windows = g_value_get_boolean (value);
+        break;
 
     case PROP_LOAD_ON_STARTUP:
         web_settings->load_on_startup = g_value_get_enum (value);
@@ -1485,6 +1506,9 @@ midori_web_settings_get_property (GObject*    object,
     case PROP_RIGHT_ALIGN_SIDEPANEL:
         g_value_set_boolean (value, web_settings->right_align_sidepanel);
         break;
+    case PROP_OPEN_PANELS_IN_WINDOWS:
+        g_value_set_boolean (value, web_settings->open_panels_in_windows);
+        break;
 
     case PROP_LOAD_ON_STARTUP:
         g_value_set_enum (value, web_settings->load_on_startup);



More information about the Xfce4-commits mailing list