[Xfce4-commits] <midori:master> Add 'New tab behavior' preference

Christian Dywan noreply at xfce.org
Tue Mar 12 18:10:02 CET 2013


Updating branch refs/heads/master
         to b45f64c770d91c6787826bed7f261253ebb33347 (commit)
       from c7a512af88c511db7fcb0c07f0e6b9698ddec316 (commit)

commit b45f64c770d91c6787826bed7f261253ebb33347
Author: Paweł Forysiuk <tuxator at o2.pl>
Date:   Tue Mar 12 18:07:10 2013 +0100

    Add 'New tab behavior' preference
    
    Fixes: https://bugs.launchpad.net/midori/+bug/909425

 midori/midori-preferences.c |    4 +++
 midori/midori-websettings.c |   60 +++++++++++++++++++++++++++++++++++++++++++
 midori/midori-websettings.h |   15 ++++++++++
 3 files changed, 79 insertions(+), 0 deletions(-)

diff --git a/midori/midori-preferences.c b/midori/midori-preferences.c
index 11678cd..f8c318e 100644
--- a/midori/midori-preferences.c
+++ b/midori/midori-preferences.c
@@ -434,6 +434,10 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
     INDENTED_ADD (label);
     button = katze_property_proxy (settings, "open-new-pages-in", NULL);
     SPANNED_ADD (button);
+    label = gtk_label_new (_("New tab behavior:"));
+    INDENTED_ADD (label);
+    button = katze_property_proxy (settings, "new-tab-type", "custom-tabhome");
+    SPANNED_ADD (button);
     button = katze_property_proxy (settings, "close-buttons-on-tabs", NULL);
     gtk_button_set_label (GTK_BUTTON (button), _("Close Buttons on Tabs"));
     INDENTED_ADD (button);
diff --git a/midori/midori-websettings.c b/midori/midori-websettings.c
index 132b526..f24ccc0 100644
--- a/midori/midori-websettings.c
+++ b/midori/midori-websettings.c
@@ -39,6 +39,7 @@ struct _MidoriWebSettings
 
     MidoriToolbarStyle toolbar_style : 3;
     MidoriStartup load_on_startup : 2;
+    MidoriNewTabType new_tab_type: 3;
     MidoriPreferredEncoding preferred_encoding : 3;
     gint close_buttons_left;
     MidoriNewPage open_new_pages_in : 2;
@@ -76,6 +77,7 @@ enum
     PROP_TOOLBAR_STYLE,
 
     PROP_LOAD_ON_STARTUP,
+    PROP_NEW_TAB,
     PROP_PREFERRED_ENCODING,
 
     PROP_CLOSE_BUTTONS_LEFT,
@@ -115,6 +117,25 @@ midori_startup_get_type (void)
 }
 
 GType
+midori_newtab_get_type (void)
+{
+    static GType type = 0;
+    if (!type)
+    {
+        static const GEnumValue values[] = {
+         { MIDORI_NEWTAB_BLANK_PAGE, "MIDORI_NEWTAB_BLANK_PAGE", N_("Show Blank Page") },
+         { MIDORI_NEWTAB_HOMEPAGE, "MIDORI_NEWTAB_HOMEPAGE", N_("Show Homepage") },
+         { MIDORI_NEWTAB_SEARCH, "MIDORI_NEWTAB_SEARCH", N_("Show default Search Engine") },
+         { MIDORI_NEWTAB_SPEED_DIAL, "MIDORI_NEWTAB_SPEED_DIAL", N_("Show Speed Dial") },
+         { MIDORI_NEWTAB_CUSTOM, "MIDORI_NEWTAB_CUSTOM", N_("Show custom page") },
+         { 0, NULL, NULL }
+        };
+        type = g_enum_register_static ("MidoriNewTabType", values);
+    };
+    return type;
+}
+
+GType
 midori_preferred_encoding_get_type (void)
 {
     static GType type = 0;
@@ -294,6 +315,16 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
                                      flags));
 
     g_object_class_install_property (gobject_class,
+                                     PROP_NEW_TAB,
+                                     g_param_spec_enum (
+                                     "new-tab-type",
+                                     "New tab behavior:",
+                                     "What to show in newly opened tabs",
+                                     MIDORI_TYPE_NEWTAB,
+                                     MIDORI_NEWTAB_SPEED_DIAL,
+                                     flags));
+
+    g_object_class_install_property (gobject_class,
                                      PROP_PREFERRED_ENCODING,
                                      g_param_spec_enum (
                                      "preferred-encoding",
@@ -707,6 +738,27 @@ midori_web_settings_get_system_name (gchar** architecture,
     #endif
 }
 
+static const gchar*
+get_uri_for_new_tab (MidoriWebSettings* web_settings,
+                     MidoriNewTabType   new_tab_type)
+{
+    switch (new_tab_type)
+    {
+        case MIDORI_NEWTAB_BLANK_PAGE:
+            return "about:blank";
+        case MIDORI_NEWTAB_HOMEPAGE:
+            return "about:home";
+        case MIDORI_NEWTAB_SEARCH:
+            return "about:search";
+        case MIDORI_NEWTAB_CUSTOM:
+            return midori_settings_get_tabhome (MIDORI_SETTINGS (web_settings));
+        case MIDORI_NEWTAB_SPEED_DIAL:
+            return "about:dial";
+        default:
+            g_assert_not_reached ();
+    }
+}
+
 static gchar*
 generate_ident_string (MidoriWebSettings* web_settings,
                        MidoriIdentity     identify_as)
@@ -968,6 +1020,11 @@ midori_web_settings_set_property (GObject*      object,
         g_object_set (web_settings, "WebKitWebSettings::user-agent",
                                     web_settings->ident_string, NULL);
         break;
+    case PROP_NEW_TAB:
+        web_settings->new_tab_type = g_value_get_enum (value);
+        const gchar* tabhome = get_uri_for_new_tab (web_settings, web_settings->new_tab_type);
+        midori_settings_set_tabhome (MIDORI_SETTINGS (web_settings), tabhome);
+        break;
     case PROP_PREFERRED_LANGUAGES:
         katze_assign (web_settings->http_accept_language, g_value_dup_string (value));
         g_object_set (web_settings, "spell-checking-languages",
@@ -1120,6 +1177,9 @@ midori_web_settings_get_property (GObject*    object,
         }
         g_value_set_string (value, web_settings->ident_string);
         break;
+    case PROP_NEW_TAB:
+        g_value_set_enum (value, web_settings->new_tab_type);
+        break;
     case PROP_PREFERRED_LANGUAGES:
         g_value_set_string (value, web_settings->http_accept_language);
         break;
diff --git a/midori/midori-websettings.h b/midori/midori-websettings.h
index ccceaef..897ad14 100644
--- a/midori/midori-websettings.h
+++ b/midori/midori-websettings.h
@@ -62,6 +62,21 @@ midori_startup_get_type (void) G_GNUC_CONST;
 
 typedef enum
 {
+    MIDORI_NEWTAB_BLANK_PAGE,
+    MIDORI_NEWTAB_HOMEPAGE,
+    MIDORI_NEWTAB_SEARCH,
+    MIDORI_NEWTAB_SPEED_DIAL,
+    MIDORI_NEWTAB_CUSTOM,
+} MidoriNewTabType;
+
+GType
+midori_newtab_get_type (void) G_GNUC_CONST;
+
+#define MIDORI_TYPE_NEWTAB \
+    (midori_newtab_get_type ())
+
+typedef enum
+{
     MIDORI_ENCODING_CHINESE /* Traditional */,
     MIDORI_ENCODING_CHINESE_SIMPLIFIED,
     MIDORI_ENCODING_JAPANESE,


More information about the Xfce4-commits mailing list