Add an Open external pages in Preference

This commit is contained in:
Christian Dywan 2008-10-20 08:50:16 +02:00
parent e848d1df6e
commit 2fccaa1bea
5 changed files with 93 additions and 28 deletions

View file

@ -210,6 +210,8 @@ midori_browser_message_received_cb (UniqueApp* instance,
UniqueResponse response;
MidoriBrowser* browser;
gchar** uris;
MidoriNewPage open_external_pages_in;
gboolean first;
switch (command)
{
@ -244,10 +246,35 @@ midori_browser_message_received_cb (UniqueApp* instance,
response = UNIQUE_RESPONSE_FAIL;
else
{
g_object_get (app->settings, "open-external-pages-in",
&open_external_pages_in, NULL);
if (open_external_pages_in == MIDORI_NEW_PAGE_WINDOW)
{
browser = g_object_new (MIDORI_TYPE_BROWSER,
"settings", app->settings,
"bookmarks", app->bookmarks,
"trash", app->trash,
"search-engines", app->search_engines,
"history", app->history,
NULL);
midori_app_add_browser (app, browser);
gtk_window_set_screen (GTK_WINDOW (app->browser),
unique_message_data_get_screen (message));
gtk_widget_show (GTK_WIDGET (browser));
}
else
browser = app->browser;
first = (open_external_pages_in == MIDORI_NEW_PAGE_CURRENT);
while (*uris)
{
midori_browser_set_current_page (app->browser,
midori_browser_add_uri (app->browser, *uris));
if (first)
{
midori_browser_set_current_uri (browser, *uris);
first = FALSE;
}
else
midori_browser_set_current_page (browser,
midori_browser_add_uri (browser, *uris));
uris++;
}
/* g_strfreev (uris); */

View file

@ -154,17 +154,6 @@ _action_set_active (MidoriBrowser* browser,
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), active);
}
static void
_midori_browser_open_uri (MidoriBrowser* browser,
const gchar* uri)
{
GtkWidget* view;
view = midori_browser_get_current_tab (browser);
if (view)
midori_view_set_uri (MIDORI_VIEW (view), uri);
}
static void
_toggle_tabbar_smartly (MidoriBrowser* browser)
{
@ -1169,7 +1158,7 @@ _action_open_activate (GtkAction* action,
{
uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
gchar* folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
_midori_browser_open_uri (browser, uri);
midori_browser_set_current_uri (browser, uri);
g_free (last_dir);
last_dir = folder;
@ -1472,7 +1461,7 @@ _action_history_activate_item (GtkAction* action,
KatzeItem* item,
MidoriBrowser* browser)
{
_midori_browser_open_uri (browser, katze_item_get_uri (item));
midori_browser_set_current_uri (browser, katze_item_get_uri (item));
}
static void
@ -1494,7 +1483,7 @@ _action_bookmarks_activate_item (GtkAction* action,
KatzeItem* item,
MidoriBrowser* browser)
{
_midori_browser_open_uri (browser, katze_item_get_uri (item));
midori_browser_set_current_uri (browser, katze_item_get_uri (item));
gtk_widget_grab_focus (midori_browser_get_current_tab (browser));
}
@ -1712,7 +1701,7 @@ _action_homepage_activate (GtkAction* action,
gchar* homepage;
g_object_get (browser->settings, "homepage", &homepage, NULL);
_midori_browser_open_uri (browser, homepage);
midori_browser_set_current_uri (browser, homepage);
g_free (homepage);
}
@ -1734,7 +1723,7 @@ _action_location_active_changed (GtkAction* action,
if (index > -1)
{
uri = midori_location_action_get_uri (MIDORI_LOCATION_ACTION (action));
_midori_browser_open_uri (browser, uri);
midori_browser_set_current_uri (browser, uri);
}
}
@ -1781,7 +1770,7 @@ _action_location_submit_uri (GtkAction* action,
midori_browser_set_current_page (browser, n);
}
else
_midori_browser_open_uri (browser, new_uri);
midori_browser_set_current_uri (browser, new_uri);
g_free (new_uri);
gtk_widget_grab_focus (midori_browser_get_current_tab (browser));
}
@ -1793,7 +1782,7 @@ midori_browser_menu_feed_item_activate_cb (GtkWidget* widget,
const gchar* uri;
uri = g_object_get_data (G_OBJECT (widget), "uri");
_midori_browser_open_uri (browser, uri);
midori_browser_set_current_uri (browser, uri);
}
static void
@ -1889,7 +1878,7 @@ _action_search_submit (GtkAction* action,
if (new_tab)
midori_browser_add_uri (browser, search);
else
_midori_browser_open_uri (browser, search);
midori_browser_set_current_uri (browser, search);
g_free (search);
g_free (location_entry_search);
@ -1941,7 +1930,7 @@ midori_panel_bookmarks_row_activated_cb (GtkTreeView* treeview,
gtk_tree_model_get (model, &iter, 0, &item, -1);
uri = katze_item_get_uri (item);
if (uri && *uri)
_midori_browser_open_uri (browser, uri);
midori_browser_set_current_uri (browser, uri);
}
}
@ -2053,7 +2042,7 @@ midori_panel_history_row_activated_cb (GtkTreeView* treeview,
if (KATZE_IS_ITEM (item))
{
uri = katze_item_get_uri (item);
_midori_browser_open_uri (browser, uri);
midori_browser_set_current_uri (browser, uri);
}
g_object_unref (item);
}
@ -2308,7 +2297,7 @@ midori_browser_menu_bookmarks_item_activate_cb (GtkWidget* widget,
KatzeItem* item;
item = (KatzeItem*)g_object_get_data (G_OBJECT (widget), "KatzeItem");
_midori_browser_open_uri (browser, katze_item_get_uri (item));
midori_browser_set_current_uri (browser, katze_item_get_uri (item));
gtk_widget_grab_focus (midori_browser_get_current_tab (browser));
}
@ -2657,7 +2646,7 @@ _action_bookmark_open_activate (GtkAction* action,
gtk_tree_model_get (model, &iter, 0, &item, -1);
uri = katze_item_get_uri (item);
if (uri && *uri)
_midori_browser_open_uri (browser, uri);
midori_browser_set_current_uri (browser, uri);
}
}
@ -2743,7 +2732,7 @@ _action_history_open_activate (GtkAction* action,
gtk_tree_model_get (model, &iter, 0, &item, -1);
uri = katze_item_get_uri (item);
if (uri && *uri)
_midori_browser_open_uri (browser, uri);
midori_browser_set_current_uri (browser, uri);
g_object_unref (item);
}
}
@ -4142,7 +4131,7 @@ midori_browser_set_property (GObject* object,
switch (prop_id)
{
case PROP_URI:
_midori_browser_open_uri (browser, g_value_get_string (value));
midori_browser_set_current_uri (browser, g_value_get_string (value));
break;
case PROP_TAB:
midori_browser_set_current_tab (browser, g_value_get_object (value));
@ -4387,6 +4376,29 @@ midori_browser_activate_action (MidoriBrowser* browser,
g_signal_emit (browser, signals[ACTIVATE_ACTION], 0, name);
}
/**
* midori_browser_set_current_uri:
* @browser: a #MidoriBrowser
* @uri: an URI
*
* Loads the specified URI in the current view.
*
* If the current view is opaque, and cannot load
* new pages, it will automatically open a new tab.
**/
void
midori_browser_set_current_uri (MidoriBrowser* browser,
const gchar* uri)
{
GtkWidget* view;
g_return_if_fail (MIDORI_IS_BROWSER (browser));
g_return_if_fail (uri);
view = midori_browser_get_current_tab (browser);
midori_view_set_uri (MIDORI_VIEW (view), uri);
}
/**
* midori_browser_get_current_uri:
* @browser: a #MidoriBrowser

View file

@ -93,6 +93,10 @@ void
midori_browser_activate_action (MidoriBrowser* browser,
const gchar* name);
void
midori_browser_set_current_uri (MidoriBrowser* browser,
const gchar* uri);
const gchar*
midori_browser_get_current_uri (MidoriBrowser* browser);

View file

@ -83,7 +83,7 @@ midori_preferences_init (MidoriPreferences* preferences)
preferences->notebook = NULL;
dialog_title = g_strdup_printf (_("%s Preferences"),
dialog_title = g_strdup_printf (_("Preferences for %s"),
g_get_application_name ());
g_object_set (preferences,
"icon-name", GTK_STOCK_PREFERENCES,
@ -419,6 +419,10 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
INDENTED_ADD (button, 0, 1, 3, 4);
FRAME_NEW (_("Browsing"));
TABLE_NEW (3, 2);
label = katze_property_label (settings, "open-external-pages-in");
INDENTED_ADD (label, 0, 1, 0, 1);
button = katze_property_proxy (settings, "open-external-pages-in", NULL);
FILLED_ADD (button, 1, 2, 0, 1);
/* label = katze_property_label (settings, "open-new-pages-in");
INDENTED_ADD (label, 0, 1, 0, 1);
button = katze_property_proxy (settings, "open-new-pages-in", NULL);

View file

@ -51,6 +51,7 @@ struct _MidoriWebSettings
gboolean close_buttons_on_tabs;
MidoriNewPage open_new_pages_in;
MidoriNewPage open_external_pages_in;
gboolean middle_click_opens_selection;
gboolean open_tabs_in_the_background;
gboolean open_tabs_next_to_current;
@ -106,6 +107,7 @@ enum
PROP_CLOSE_BUTTONS_ON_TABS,
PROP_OPEN_NEW_PAGES_IN,
PROP_OPEN_EXTERNAL_PAGES_IN,
PROP_MIDDLE_CLICK_OPENS_SELECTION,
PROP_OPEN_TABS_IN_THE_BACKGROUND,
PROP_OPEN_TABS_NEXT_TO_CURRENT,
@ -491,6 +493,16 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
MIDORI_NEW_PAGE_TAB,
G_PARAM_READABLE));
g_object_class_install_property (gobject_class,
PROP_OPEN_EXTERNAL_PAGES_IN,
g_param_spec_enum (
"open-external-pages-in",
_("Open external pages in"),
_("Where to open externally opened pages"),
MIDORI_TYPE_NEW_PAGE,
MIDORI_NEW_PAGE_TAB,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_MIDDLE_CLICK_OPENS_SELECTION,
g_param_spec_boolean (
@ -770,6 +782,9 @@ midori_web_settings_set_property (GObject* object,
case PROP_OPEN_NEW_PAGES_IN:
web_settings->open_new_pages_in = g_value_get_enum (value);
break;
case PROP_OPEN_EXTERNAL_PAGES_IN:
web_settings->open_external_pages_in = g_value_get_enum (value);
break;
case PROP_MIDDLE_CLICK_OPENS_SELECTION:
web_settings->middle_click_opens_selection = g_value_get_boolean (value);
break;
@ -913,6 +928,9 @@ midori_web_settings_get_property (GObject* object,
case PROP_OPEN_NEW_PAGES_IN:
g_value_set_enum (value, web_settings->open_new_pages_in);
break;
case PROP_OPEN_EXTERNAL_PAGES_IN:
g_value_set_enum (value, web_settings->open_external_pages_in);
break;
case PROP_MIDDLE_CLICK_OPENS_SELECTION:
g_value_set_boolean (value, web_settings->middle_click_opens_selection);
break;