From c571a6394f6feb622dd758d04a3b0ed7cbabfa23 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Tue, 25 May 2010 18:50:16 +0200 Subject: [PATCH] Don't pass around KatzeNet instances anymore The KatzeNet is always a singleton, no need to pass it around. --- extensions/feed-panel/feed-panel.c | 4 ---- extensions/feed-panel/main.c | 8 +------- katze/katze-net.c | 15 +++++++++++---- midori/midori-browser.c | 19 ++++++------------- midori/midori-view.c | 15 +++++---------- 5 files changed, 23 insertions(+), 38 deletions(-) diff --git a/extensions/feed-panel/feed-panel.c b/extensions/feed-panel/feed-panel.c index 8ef29d69..26fbb261 100644 --- a/extensions/feed-panel/feed-panel.c +++ b/extensions/feed-panel/feed-panel.c @@ -30,7 +30,6 @@ struct _FeedPanel GtkWidget* webview; GtkWidget* delete; GdkPixbuf* pixbuf; - KatzeNet* net; }; struct _FeedPanelClass @@ -750,7 +749,6 @@ feed_panel_finalize (GObject* object) FeedPanel* panel = FEED_PANEL (object); g_object_unref (panel->pixbuf); - g_object_unref (panel->net); } static void @@ -826,8 +824,6 @@ feed_panel_init (FeedPanel* panel) gtk_icon_factory_add_default (factory); g_object_unref (factory); - panel->net = katze_net_new (); - model = gtk_tree_store_new (1, KATZE_TYPE_ITEM); treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model)); panel->treeview = treeview; diff --git a/extensions/feed-panel/main.c b/extensions/feed-panel/main.c index 499a4e09..4695225e 100644 --- a/extensions/feed-panel/main.c +++ b/extensions/feed-panel/main.c @@ -40,7 +40,6 @@ typedef struct MidoriExtension* extension; GtkWidget* panel; KatzeArray* feeds; - KatzeNet* net; GSList* parsers; guint source_id; @@ -96,8 +95,6 @@ feed_deactivate_cb (MidoriExtension* extension, g_source_remove (priv->source_id); g_slist_foreach (priv->parsers, (GFunc)g_free, NULL); g_slist_free (priv->parsers); - if (priv->feeds) - g_object_unref (priv->net); if (priv->feeds) g_object_unref (priv->feeds); gtk_widget_destroy (priv->panel); @@ -286,7 +283,7 @@ update_feed (FeedPrivate* priv, netpriv->extension = priv->extension; netpriv->feed = KATZE_ARRAY (feed); - katze_net_load_uri (priv->net, + katze_net_load_uri (NULL, katze_item_get_uri (feed), (KatzeNetStatusCb) feed_status_cb, (KatzeNetTransferCb) feed_transfer_cb, @@ -437,7 +434,6 @@ feed_app_add_browser_cb (MidoriApp* app, GtkWidget* addon; GtkActionGroup* action_group; GtkAction* action; - KatzeNet* net; KatzeArray* feeds; KatzeArray* feed; FeedPrivate* priv; @@ -453,14 +449,12 @@ feed_app_add_browser_cb (MidoriApp* app, midori_panel_append_page (MIDORI_PANEL (panel), MIDORI_VIEWABLE (addon)); g_object_unref (panel); - net = katze_net_new (); feeds = katze_array_new (KATZE_TYPE_ARRAY); feed_panel_add_feeds (FEED_PANEL (addon), KATZE_ITEM (feeds)); priv->extension = extension; priv->browser = browser; priv->panel = addon; - priv->net = net; priv->feeds = feeds; priv->parsers = g_slist_prepend (priv->parsers, atom_init_parser ()); priv->parsers = g_slist_prepend (priv->parsers, rss_init_parser ()); diff --git a/katze/katze-net.c b/katze/katze-net.c index d781b9b8..6467832f 100644 --- a/katze/katze-net.c +++ b/katze/katze-net.c @@ -77,6 +77,8 @@ katze_net_finalize (GObject* object) * Instantiates a new #KatzeNet instance. * * Return value: a new #KatzeNet + * + * Deprecated: 0.2.7 **/ KatzeNet* katze_net_new (void) @@ -102,14 +104,14 @@ katze_net_new (void) * * Return value: a session, or %NULL * - * Since: 0.1.3 + * Deprecated: 0.2.7: Use webkit_get_default_session (). **/ gpointer katze_net_get_session (KatzeNet* net) { g_return_val_if_fail (KATZE_IS_NET (net), NULL); - return net->session; + return webkit_get_default_session (); } typedef struct @@ -147,6 +149,9 @@ katze_net_get_cached_path (KatzeNet* net, gchar* cached_filename; gchar* cached_path; + if (!net) + net = katze_net_new (); + if (subfolder) cache_path = g_build_filename (net->cache_path, subfolder, NULL); else @@ -301,7 +306,7 @@ katze_net_default_cb (KatzeNetPriv* priv) /** * katze_net_load_uri: - * @net: a #KatzeNet + * @net: a #KatzeNet, or %NULL * @uri: an URI string * @status_cb: function to call for status information * @transfer_cb: function to call upon transfer @@ -330,12 +335,14 @@ katze_net_load_uri (KatzeNet* net, KatzeNetPriv* priv; SoupMessage* msg; - g_return_if_fail (KATZE_IS_NET (net)); g_return_if_fail (uri != NULL); if (!status_cb && !transfer_cb) return; + if (net == NULL) + net = katze_net_new (); + request = g_new0 (KatzeNetRequest, 1); request->uri = g_strdup (uri); request->mime_type = NULL; diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 586a2add..534a2a05 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -104,8 +104,6 @@ struct _MidoriBrowser KatzeArray* history; gboolean show_tabs; - KatzeNet* net; - gboolean show_navigationbar; gboolean show_statusbar; gboolean speed_dial_in_new_tabs; @@ -1100,7 +1098,7 @@ midori_browser_save_uri (MidoriBrowser* browser, webkit_download_start (download); g_free (destination); #else - katze_net_load_uri (browser->net, uri, NULL, + katze_net_load_uri (NULL, uri, NULL, (KatzeNetTransferCb)midori_browser_save_transfer_cb, filename); #endif @@ -3765,7 +3763,7 @@ _action_source_view_activate (GtkAction* action, GtkWidget* source; GtkWidget* web_view; - source = midori_view_new (browser->net); + source = midori_view_new (NULL); midori_view_set_settings (MIDORI_VIEW (source), browser->settings); midori_view_set_uri (MIDORI_VIEW (source), ""); web_view = midori_view_get_web_view (MIDORI_VIEW (source)); @@ -3800,7 +3798,7 @@ _action_source_view_activate (GtkAction* action, g_free (filename); return; } - katze_net_load_uri (browser->net, uri, NULL, + katze_net_load_uri (NULL, uri, NULL, (KatzeNetTransferCb)midori_browser_source_transfer_cb, browser); g_free (text_editor); } @@ -4903,7 +4901,7 @@ midori_browser_clear_private_data_response_cb (GtkWidget* dialog, button = g_object_get_data (G_OBJECT (dialog), "cookies"); if (gtk_toggle_button_get_active (button)) { - SoupSession* session = katze_net_get_session (browser->net); + SoupSession* session = webkit_get_default_session (); SoupSessionFeature* jar = soup_session_get_feature (session, SOUP_TYPE_COOKIE_JAR); GSList* cookies = soup_cookie_jar_all_cookies (SOUP_COOKIE_JAR (jar)); @@ -5449,7 +5447,7 @@ midori_browser_notebook_button_press_event_after_cb (GtkNotebook* notebook, view = g_object_new (MIDORI_TYPE_VIEW, "settings", browser->settings, - "net", browser->net, NULL); + NULL); midori_view_set_uri (MIDORI_VIEW (view), ""); gtk_widget_show (view); g_object_set_data (G_OBJECT (view), "midori-view-append", (void*)1); @@ -6233,8 +6231,6 @@ midori_browser_init (MidoriBrowser* browser) GtkWidget* scrolled; GtkWidget* icon; - browser->net = katze_net_new (); - browser->settings = midori_web_settings_new (); browser->proxy_array = katze_array_new (KATZE_TYPE_ARRAY); browser->bookmarks = NULL; @@ -6790,8 +6786,6 @@ midori_browser_finalize (GObject* object) katze_object_assign (browser->search_engines, NULL); katze_object_assign (browser->history, NULL); - katze_object_assign (browser->net, NULL); - katze_assign (browser->news_aggregator, NULL); G_OBJECT_CLASS (midori_browser_parent_class)->finalize (object); @@ -7509,7 +7503,6 @@ midori_browser_add_item (MidoriBrowser* browser, view = g_object_new (MIDORI_TYPE_VIEW, "title", title, "settings", browser->settings, - "net", browser->net, NULL); midori_view_set_uri (MIDORI_VIEW (view), uri); gtk_widget_show (view); @@ -7551,7 +7544,7 @@ midori_browser_add_uri (MidoriBrowser* browser, g_return_val_if_fail (uri != NULL, -1); view = g_object_new (MIDORI_TYPE_VIEW, "settings", browser->settings, - "net", browser->net, NULL); + NULL); midori_view_set_uri (MIDORI_VIEW (view), uri); gtk_widget_show (view); diff --git a/midori/midori-view.c b/midori/midori-view.c index cc183b2c..dd66fd1d 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -887,7 +887,7 @@ _midori_web_view_load_icon (MidoriView* view) icon_uri = g_strdup_printf ("%s/favicon.ico", view->uri); } - icon_file = katze_net_get_cached_path (view->net, icon_uri, "icons"); + icon_file = katze_net_get_cached_path (NULL, icon_uri, "icons"); if (g_hash_table_lookup_extended (view->memory, icon_file, NULL, (gpointer)&pixbuf)) { @@ -910,7 +910,7 @@ _midori_web_view_load_icon (MidoriView* view) priv->icon_uri = icon_uri; priv->view = view; - katze_net_load_uri (view->net, icon_uri, + katze_net_load_uri (NULL, icon_uri, (KatzeNetStatusCb)katze_net_icon_status_cb, (KatzeNetTransferCb)katze_net_icon_transfer_cb, priv); } @@ -2600,7 +2600,6 @@ webkit_web_view_create_web_view_cb (GtkWidget* web_view, else { new_view = g_object_new (MIDORI_TYPE_VIEW, - "net", view->net, "settings", view->settings, NULL); midori_view_construct_web_view (new_view); @@ -2967,8 +2966,6 @@ midori_view_set_property (GObject* object, break; case PROP_NET: katze_object_assign (view->net, g_value_dup_object (value)); - if (!view->net) - view->net = katze_net_new (); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -3047,7 +3044,7 @@ midori_view_focus_in_event (GtkWidget* widget, /** * midori_view_new: - * @net: a #KatzeNet + * @net: a #KatzeNet, or %NULL * * Creates a new view. * @@ -3056,9 +3053,7 @@ midori_view_focus_in_event (GtkWidget* widget, GtkWidget* midori_view_new (KatzeNet* net) { - g_return_val_if_fail (!net || KATZE_IS_NET (net), NULL); - - return g_object_new (MIDORI_TYPE_VIEW, "net", net, NULL); + return g_object_new (MIDORI_TYPE_VIEW, NULL); } static void @@ -3986,7 +3981,7 @@ midori_view_tab_label_menu_duplicate_tab_cb (GtkWidget* menuitem, { MidoriNewView where = MIDORI_NEW_VIEW_TAB; GtkWidget* new_view = g_object_new (MIDORI_TYPE_VIEW, - "net", view->net, "settings", view->settings, NULL); + "settings", view->settings, NULL); midori_view_set_uri (MIDORI_VIEW (new_view), midori_view_get_display_uri (view)); gtk_widget_show (new_view); -- 2.39.5