Optionally open panels in standalone windows by default

This commit is contained in:
Christian Dywan 2009-11-28 23:53:49 +01:00
parent 565e32599e
commit 5a65ed6253
4 changed files with 94 additions and 26 deletions

View file

@ -6239,7 +6239,8 @@ _midori_browser_update_settings (MidoriBrowser* browser)
gboolean remember_last_window_size; gboolean remember_last_window_size;
gint last_window_width, last_window_height; gint last_window_width, last_window_height;
MidoriWindowState last_window_state; 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; gint last_panel_position, last_panel_page;
gboolean show_menubar, show_bookmarkbar; gboolean show_menubar, show_bookmarkbar;
gboolean show_panel, show_transferbar; gboolean show_panel, show_transferbar;
@ -6262,6 +6263,7 @@ _midori_browser_update_settings (MidoriBrowser* browser)
"compact-sidepanel", &compact_sidepanel, "compact-sidepanel", &compact_sidepanel,
"show-panel-controls", &show_panel_controls, "show-panel-controls", &show_panel_controls,
"right-align-sidepanel", &right_align_sidepanel, "right-align-sidepanel", &right_align_sidepanel,
"open-panels-in-windows", &open_panels_in_windows,
"last-panel-position", &last_panel_position, "last-panel-position", &last_panel_position,
"last-panel-page", &last_panel_page, "last-panel-page", &last_panel_page,
"show-menubar", &show_menubar, "show-menubar", &show_menubar,
@ -6336,7 +6338,8 @@ _midori_browser_update_settings (MidoriBrowser* browser)
g_object_set (browser->panel, "show-titles", !compact_sidepanel, g_object_set (browser->panel, "show-titles", !compact_sidepanel,
"show-controls", show_panel_controls, "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)), gtk_paned_set_position (GTK_PANED (gtk_widget_get_parent (browser->panel)),
last_panel_position); last_panel_position);
/* The browser may not yet be visible, which means that we can't set the /* 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, g_signal_handlers_unblock_by_func (browser->panel,
midori_panel_notify_show_controls_cb, browser); 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")) else if (name == g_intern_string ("always-show-tabbar"))
_toggle_tabbar_smartly (browser); _toggle_tabbar_smartly (browser);
else if (name == g_intern_string ("show-menubar")) else if (name == g_intern_string ("show-menubar"))

View file

@ -43,6 +43,7 @@ struct _MidoriPanel
gboolean show_titles; gboolean show_titles;
gboolean show_controls; gboolean show_controls;
gboolean right_aligned; gboolean right_aligned;
gboolean open_panels_in_windows;
}; };
struct _MidoriPanelClass struct _MidoriPanelClass
@ -67,6 +68,7 @@ enum
PROP_SHOW_TITLES, PROP_SHOW_TITLES,
PROP_SHOW_CONTROLS, PROP_SHOW_CONTROLS,
PROP_RIGHT_ALIGNED, PROP_RIGHT_ALIGNED,
PROP_OPEN_PANELS_IN_WINDOWS,
}; };
enum { enum {
@ -237,6 +239,22 @@ midori_panel_class_init (MidoriPanelClass* class)
"Whether the panel is aligned to the right", "Whether the panel is aligned to the right",
FALSE, FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); 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 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* scrolled = g_object_get_data (G_OBJECT (window), "scrolled");
GtkWidget* toolbar = g_object_get_data (G_OBJECT (scrolled), "panel-toolbar"); GtkWidget* toolbar = g_object_get_data (G_OBJECT (scrolled), "panel-toolbar");
GtkWidget* menuitem = g_object_get_data (G_OBJECT (scrolled), "panel-menuitem"); GtkWidget* menuitem = g_object_get_data (G_OBJECT (scrolled), "panel-menuitem");
GtkWidget* viewable = _midori_panel_child_for_scrolled (panel, scrolled);
GtkToolItem* toolitem; GtkToolItem* toolitem;
gint n; gint n;
@ -277,13 +296,9 @@ midori_panel_detached_window_delete_event_cb (GtkWidget* window,
gtk_container_remove (GTK_CONTAINER (vbox), scrolled); gtk_container_remove (GTK_CONTAINER (vbox), scrolled);
n = gtk_notebook_append_page (GTK_NOTEBOOK (panel->notebook), scrolled, NULL); n = gtk_notebook_append_page (GTK_NOTEBOOK (panel->notebook), scrolled, NULL);
g_object_unref (scrolled); g_object_unref (scrolled);
toolitem = midori_panel_construct_tool_item (panel, toolitem = midori_panel_construct_tool_item (panel, MIDORI_VIEWABLE (viewable));
MIDORI_VIEWABLE (_midori_panel_child_for_scrolled (panel, scrolled)));
if (menuitem) if (menuitem)
{
gtk_widget_show (menuitem);
g_object_set_data (G_OBJECT (menuitem), "toolitem", toolitem); g_object_set_data (G_OBJECT (menuitem), "toolitem", toolitem);
}
midori_panel_set_current_page (panel, n); midori_panel_set_current_page (panel, n);
return FALSE; return FALSE;
} }
@ -298,13 +313,9 @@ midori_panel_widget_destroy_cb (GtkWidget* viewable,
} }
static void static void
midori_panel_button_detach_clicked_cb (GtkWidget* toolbutton, midori_panel_detach_page (MidoriPanel* panel,
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 ( GtkToolItem* toolitem = gtk_toolbar_get_nth_item (
GTK_TOOLBAR (panel->toolbar), n); GTK_TOOLBAR (panel->toolbar), n);
const gchar* title = gtk_tool_button_get_label (GTK_TOOL_BUTTON (toolitem)); 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); GTK_NOTEBOOK (panel->toolbook), n);
GtkWidget* scrolled = gtk_notebook_get_nth_page ( GtkWidget* scrolled = gtk_notebook_get_nth_page (
GTK_NOTEBOOK (panel->notebook), n); GTK_NOTEBOOK (panel->notebook), n);
GtkWidget* menuitem = g_object_get_data (G_OBJECT (scrolled), "panel-menuitem");
GtkWidget* vbox = gtk_vbox_new (FALSE, 0); GtkWidget* vbox = gtk_vbox_new (FALSE, 0);
#if HAVE_HILDON #if HAVE_HILDON
GtkWidget* window = hildon_window_new (); GtkWidget* window = hildon_window_new ();
@ -328,8 +338,6 @@ midori_panel_button_detach_clicked_cb (GtkWidget* toolbutton,
gtk_container_add (GTK_CONTAINER (window), vbox); gtk_container_add (GTK_CONTAINER (window), vbox);
g_object_set_data (G_OBJECT (window), "scrolled", scrolled); g_object_set_data (G_OBJECT (window), "scrolled", scrolled);
gtk_window_set_title (GTK_WINDOW (window), title); gtk_window_set_title (GTK_WINDOW (window), title);
if (menuitem)
gtk_widget_hide (menuitem);
g_signal_handlers_disconnect_by_func ( g_signal_handlers_disconnect_by_func (
_midori_panel_child_for_scrolled (panel, scrolled), _midori_panel_child_for_scrolled (panel, scrolled),
midori_panel_widget_destroy_cb, toolitem); midori_panel_widget_destroy_cb, toolitem);
@ -351,12 +359,23 @@ midori_panel_button_detach_clicked_cb (GtkWidget* toolbutton,
toolitem = gtk_toolbar_get_nth_item (GTK_TOOLBAR (panel->toolbar), toolitem = gtk_toolbar_get_nth_item (GTK_TOOLBAR (panel->toolbar),
n > 0 ? n - 1 : 0); n > 0 ? n - 1 : 0);
if (!gtk_notebook_get_n_pages (GTK_NOTEBOOK (panel->notebook))) 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_signal_connect (window, "delete-event",
G_CALLBACK (midori_panel_detached_window_delete_event_cb), panel); G_CALLBACK (midori_panel_detached_window_delete_event_cb), panel);
gtk_widget_show (window); 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 static void
midori_panel_button_align_clicked_cb (GtkWidget* toolitem, midori_panel_button_align_clicked_cb (GtkWidget* toolitem,
MidoriPanel* panel) MidoriPanel* panel)
@ -510,6 +529,9 @@ midori_panel_set_property (GObject* object,
case PROP_RIGHT_ALIGNED: case PROP_RIGHT_ALIGNED:
midori_panel_set_right_aligned (panel, g_value_get_boolean (value)); midori_panel_set_right_aligned (panel, g_value_get_boolean (value));
break; break;
case PROP_OPEN_PANELS_IN_WINDOWS:
panel->open_panels_in_windows = g_value_get_boolean (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -548,6 +570,9 @@ midori_panel_get_property (GObject* object,
case PROP_RIGHT_ALIGNED: case PROP_RIGHT_ALIGNED:
g_value_set_boolean (value, panel->right_aligned); g_value_set_boolean (value, panel->right_aligned);
break; break;
case PROP_OPEN_PANELS_IN_WINDOWS:
g_value_set_boolean (value, panel->open_panels_in_windows);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -719,11 +744,27 @@ static void
midori_panel_action_activate_cb (GtkRadioAction* action, midori_panel_action_activate_cb (GtkRadioAction* action,
MidoriPanel* panel) 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);
/* 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); midori_panel_set_current_page (panel, n);
g_signal_emit (panel, signals[SWITCH_PAGE], 0, n); g_signal_emit (panel, signals[SWITCH_PAGE], 0, n);
gtk_widget_show (GTK_WIDGET (panel)); gtk_widget_show (GTK_WIDGET (panel));
}
} }
/** /**
@ -808,6 +849,7 @@ midori_panel_append_page (MidoriPanel* panel,
action = (GtkAction*)gtk_radio_action_new (action_name, action = (GtkAction*)gtk_radio_action_new (action_name,
midori_viewable_get_label (viewable), midori_viewable_get_label (viewable),
NULL, midori_viewable_get_stock_id (viewable), n); NULL, midori_viewable_get_stock_id (viewable), n);
g_object_set_data (G_OBJECT (action), "viewable", viewable);
g_signal_connect (action, "activate", g_signal_connect (action, "activate",
G_CALLBACK (midori_panel_action_activate_cb), panel); G_CALLBACK (midori_panel_action_activate_cb), panel);
if (panel->action_group) if (panel->action_group)

View file

@ -405,11 +405,7 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
GTK_WIDGET (parent) : GTK_WIDGET (preferences))) GTK_WIDGET (parent) : GTK_WIDGET (preferences)))
button = katze_property_proxy (settings, "kinetic-scrolling", NULL); button = katze_property_proxy (settings, "kinetic-scrolling", NULL);
else else
{ button = katze_property_proxy (settings, "open-panels-in-windows", NULL);
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"));
}
#else #else
button = katze_property_proxy (settings, "middle-click-opens-selection", NULL); button = katze_property_proxy (settings, "middle-click-opens-selection", NULL);
#endif #endif

View file

@ -50,6 +50,7 @@ struct _MidoriWebSettings
gboolean compact_sidepanel; gboolean compact_sidepanel;
gboolean show_panel_controls; gboolean show_panel_controls;
gboolean right_align_sidepanel; gboolean right_align_sidepanel;
gboolean open_panels_in_windows;
MidoriStartup load_on_startup; MidoriStartup load_on_startup;
gchar* homepage; gchar* homepage;
@ -125,6 +126,7 @@ enum
PROP_COMPACT_SIDEPANEL, PROP_COMPACT_SIDEPANEL,
PROP_SHOW_PANEL_CONTROLS, PROP_SHOW_PANEL_CONTROLS,
PROP_RIGHT_ALIGN_SIDEPANEL, PROP_RIGHT_ALIGN_SIDEPANEL,
PROP_OPEN_PANELS_IN_WINDOWS,
PROP_LOAD_ON_STARTUP, PROP_LOAD_ON_STARTUP,
PROP_HOMEPAGE, PROP_HOMEPAGE,
@ -567,6 +569,22 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
FALSE, FALSE,
flags)); 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, g_object_class_install_property (gobject_class,
PROP_LOAD_ON_STARTUP, PROP_LOAD_ON_STARTUP,
@ -1250,6 +1268,9 @@ midori_web_settings_set_property (GObject* object,
case PROP_RIGHT_ALIGN_SIDEPANEL: case PROP_RIGHT_ALIGN_SIDEPANEL:
web_settings->right_align_sidepanel = g_value_get_boolean (value); web_settings->right_align_sidepanel = g_value_get_boolean (value);
break; break;
case PROP_OPEN_PANELS_IN_WINDOWS:
web_settings->open_panels_in_windows = g_value_get_boolean (value);
break;
case PROP_LOAD_ON_STARTUP: case PROP_LOAD_ON_STARTUP:
web_settings->load_on_startup = g_value_get_enum (value); 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: case PROP_RIGHT_ALIGN_SIDEPANEL:
g_value_set_boolean (value, web_settings->right_align_sidepanel); g_value_set_boolean (value, web_settings->right_align_sidepanel);
break; break;
case PROP_OPEN_PANELS_IN_WINDOWS:
g_value_set_boolean (value, web_settings->open_panels_in_windows);
break;
case PROP_LOAD_ON_STARTUP: case PROP_LOAD_ON_STARTUP:
g_value_set_enum (value, web_settings->load_on_startup); g_value_set_enum (value, web_settings->load_on_startup);