[Xfce4-commits] <midori:master> Properly handle non-/ NULL speed dial in browser

Christian Dywan noreply at xfce.org
Tue Nov 27 01:26:02 CET 2012


Updating branch refs/heads/master
         to 1a1fe868c240abd041fd61179b2cf2ca55530afd (commit)
       from 276d64556ee7f45da724381772fd508f179ac623 (commit)

commit 1a1fe868c240abd041fd61179b2cf2ca55530afd
Author: Christian Dywan <christian at twotoasts.de>
Date:   Tue Nov 27 01:22:47 2012 +0100

    Properly handle non-/ NULL speed dial in browser

 midori/midori-browser.c |   17 +++++++++++------
 midori/midori-view.c    |    2 +-
 tests/browser.c         |    5 +----
 tests/tab.vala          |   19 +++++++------------
 4 files changed, 20 insertions(+), 23 deletions(-)

diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index ec12583..c4ca1b0 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -2304,10 +2304,11 @@ midori_browser_class_init (MidoriBrowserClass* class)
     */
     g_object_class_install_property (gobject_class,
                                      PROP_SPEED_DIAL,
-                                     g_param_spec_pointer (
+                                     g_param_spec_object (
                                      "speed-dial",
                                      "Speeddial",
                                      "Speed dial",
+                                     MIDORI_TYPE_SPEED_DIAL,
                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
     /**
@@ -6574,7 +6575,7 @@ midori_browser_finalize (GObject* object)
     katze_object_assign (browser->trash, NULL);
     katze_object_assign (browser->search_engines, NULL);
     katze_object_assign (browser->history, NULL);
-    browser->dial = NULL;
+    katze_object_assign (browser->dial, NULL);
 
     katze_assign (browser->news_aggregator, NULL);
 
@@ -7356,9 +7357,13 @@ midori_browser_set_property (GObject*      object,
         midori_browser_set_history (browser, g_value_get_object (value));
         break;
     case PROP_SPEED_DIAL:
-        browser->dial = g_value_get_pointer (value);
-        g_signal_connect (browser->dial, "refresh",
-            G_CALLBACK (midori_browser_speed_dial_refresh_cb), browser);
+        if (browser->dial != NULL)
+            g_signal_handlers_disconnect_by_func (browser->dial,
+                midori_browser_speed_dial_refresh_cb, browser);
+        katze_object_assign (browser->dial, g_value_dup_object (value));
+        if (browser->dial != NULL)
+            g_signal_connect (browser->dial, "refresh",
+                G_CALLBACK (midori_browser_speed_dial_refresh_cb), browser);
         break;
     case PROP_SHOW_TABS:
         browser->show_tabs = g_value_get_boolean (value);
@@ -7433,7 +7438,7 @@ midori_browser_get_property (GObject*    object,
         g_value_set_object (value, browser->history);
         break;
     case PROP_SPEED_DIAL:
-        g_value_set_pointer (value, browser->dial);
+        g_value_set_object (value, browser->dial);
         break;
     case PROP_SHOW_TABS:
         g_value_set_boolean (value, browser->show_tabs);
diff --git a/midori/midori-view.c b/midori/midori-view.c
index 9fc8898..84bc70e 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -3834,7 +3834,7 @@ midori_view_set_uri (MidoriView*  view,
             katze_item_set_meta_string (view->item, "mime-type", "text/html");
             katze_item_set_meta_integer (view->item, "delay", MIDORI_DELAY_UNDELAYED);
 
-            html = midori_speed_dial_get_html (dial, NULL);
+            html = dial != NULL ? midori_speed_dial_get_html (dial, NULL) : "";
             midori_view_set_html (view, html, NULL, NULL);
 
             #ifdef G_ENABLE_DEBUG
diff --git a/tests/browser.c b/tests/browser.c
index b505fcc..a9bb6a2 100644
--- a/tests/browser.c
+++ b/tests/browser.c
@@ -26,7 +26,6 @@ static void
 browser_create (void)
 {
     MidoriApp* app;
-    MidoriSpeedDial* dial;
     MidoriWebSettings* settings;
     MidoriBrowser* browser;
     gint n;
@@ -41,9 +40,8 @@ browser_create (void)
     g_test_log_set_fatal_handler (skip_gtk_bugs, NULL);
 
     app = midori_app_new ();
-    dial = midori_speed_dial_new ("/", NULL);
     settings = midori_web_settings_new ();
-    g_object_set (app, "speed-dial", dial, "settings", settings, NULL);
+    g_object_set (app, "settings", settings, NULL);
     browser = midori_app_create_browser (app);
     file = g_file_new_for_commandline_arg ("./data/about.css");
     uri = g_file_get_uri (file);
@@ -75,7 +73,6 @@ browser_create (void)
     gtk_widget_destroy (GTK_WIDGET (browser));
     g_object_unref (settings);
     g_object_unref (app);
-    g_object_unref (dial);
 }
 
 static void
diff --git a/tests/tab.vala b/tests/tab.vala
index 4695cae..95f6391 100644
--- a/tests/tab.vala
+++ b/tests/tab.vala
@@ -86,25 +86,20 @@ void tab_special () {
         msg.response_body.append_take ("<body></body>".data);
         });
 
-    var browser = new Gtk.Window (Gtk.WindowType.TOPLEVEL);
-    /*
-    var dial = new Midori.SpeedDial ("/", null);
-    var settings = new Midori.WebSettings ();
     var browser = new Midori.Browser ();
-    browser.set ("speed-dial", dial, "settings", settings);
-    */
+    var settings = new Midori.WebSettings ();
+    browser.set ("settings", settings);
     var tab = new Midori.View.with_title ();
     tab.settings = new Midori.WebSettings ();
     tab.settings.set ("enable-plugins", false);
-    browser.add (tab);
-    /* browser.add_tab (tab); */
+    browser.add_tab (tab);
     var loop = MainContext.default ();
 
-    /* tab.set_uri ("about:blank"); */
+    tab.set_uri ("about:blank");
     do { loop.iteration (true); } while (tab.load_status != Midori.LoadStatus.FINISHED);
     assert (tab.is_blank ());
     assert (!tab.can_view_source ());
-    /* FIXME assert (tab.special); */
+    assert (tab.special);
     assert (!tab.can_save ());
 
     tab.set_uri ("about:private");
@@ -146,13 +141,13 @@ void tab_special () {
 
     /* Mimic browser: SourceView with no external editor */
     var source = new Midori.View.with_title ();
-    browser.add (source);
+    browser.add_tab (source);
     source.web_view.set_view_source_mode (true);
     source.web_view.load_uri (test_url);
     do { loop.iteration (true); } while (source.load_status != Midori.LoadStatus.FINISHED);
     assert (!source.is_blank ());
     assert (!source.can_view_source ());
-    /* FIXME assert (!source.special); */
+    assert (!source.special);
     /* FIXME assert (source.can_save ()); */
     assert (source.web_view.get_view_source_mode ());
 


More information about the Xfce4-commits mailing list