Share net between browser and views

This commit is contained in:
Christian Dywan 2008-10-27 04:23:41 +01:00
parent f5f1946c89
commit 4a3501a279
3 changed files with 42 additions and 31 deletions

View file

@ -1845,7 +1845,7 @@ _action_source_view_activate (GtkAction* action,
{ {
uri = g_strdup_printf ("view-source:%s", uri = g_strdup_printf ("view-source:%s",
midori_view_get_display_uri (MIDORI_VIEW (view))); midori_view_get_display_uri (MIDORI_VIEW (view)));
source_view = midori_view_new (); source_view = midori_view_new (browser->net);
midori_view_set_settings (MIDORI_VIEW (source_view), browser->settings); midori_view_set_settings (MIDORI_VIEW (source_view), browser->settings);
midori_view_set_uri (MIDORI_VIEW (source_view), uri); midori_view_set_uri (MIDORI_VIEW (source_view), uri);
midori_view_notify_icon_cb (MIDORI_VIEW (source_view), NULL, browser); midori_view_notify_icon_cb (MIDORI_VIEW (source_view), NULL, browser);
@ -3687,7 +3687,7 @@ midori_browser_init (MidoriBrowser* browser)
STOCK_BOOKMARKS, _("Bookmarks")); STOCK_BOOKMARKS, _("Bookmarks"));
/* Transfers */ /* Transfers */
GtkWidget* panel = midori_view_new (); GtkWidget* panel = midori_view_new (browser->net);
gtk_widget_show (panel); gtk_widget_show (panel);
midori_panel_append_page (MIDORI_PANEL (browser->panel), midori_panel_append_page (MIDORI_PANEL (browser->panel),
panel, NULL, panel, NULL,
@ -3741,7 +3741,7 @@ midori_browser_init (MidoriBrowser* browser)
STOCK_HISTORY, _("History")); STOCK_HISTORY, _("History"));
/* Pageholder */ /* Pageholder */
browser->panel_pageholder = midori_view_new (); browser->panel_pageholder = midori_view_new (browser->net);
midori_view_set_settings (MIDORI_VIEW (browser->panel_pageholder), midori_view_set_settings (MIDORI_VIEW (browser->panel_pageholder),
browser->settings); browser->settings);
gtk_widget_show (browser->panel_pageholder); gtk_widget_show (browser->panel_pageholder);
@ -4357,8 +4357,7 @@ midori_browser_set_property (GObject* object,
g_signal_handlers_disconnect_by_func (browser->settings, g_signal_handlers_disconnect_by_func (browser->settings,
midori_browser_settings_notify, midori_browser_settings_notify,
browser); browser);
katze_object_assign (browser->settings, g_value_get_object (value)); katze_object_assign (browser->settings, g_value_dup_object (value));
g_object_ref (browser->settings);
_midori_browser_update_settings (browser); _midori_browser_update_settings (browser);
g_signal_connect (browser->settings, "notify", g_signal_connect (browser->settings, "notify",
G_CALLBACK (midori_browser_settings_notify), browser); G_CALLBACK (midori_browser_settings_notify), browser);
@ -4367,8 +4366,7 @@ midori_browser_set_property (GObject* object,
break; break;
case PROP_BOOKMARKS: case PROP_BOOKMARKS:
; /* FIXME: Disconnect handlers */ ; /* FIXME: Disconnect handlers */
katze_object_assign (browser->bookmarks, g_value_get_object (value)); katze_object_assign (browser->bookmarks, g_value_dup_object (value));
g_object_ref (browser->bookmarks);
g_object_set (_action_by_name (browser, "Bookmarks"), "array", g_object_set (_action_by_name (browser, "Bookmarks"), "array",
browser->bookmarks, NULL); browser->bookmarks, NULL);
midori_browser_load_bookmarks (browser); midori_browser_load_bookmarks (browser);
@ -4376,8 +4374,7 @@ midori_browser_set_property (GObject* object,
break; break;
case PROP_TRASH: case PROP_TRASH:
; /* FIXME: Disconnect handlers */ ; /* FIXME: Disconnect handlers */
katze_object_assign (browser->trash, g_value_get_object (value)); katze_object_assign (browser->trash, g_value_dup_object (value));
g_object_ref (browser->trash);
g_object_set (_action_by_name (browser, "Trash"), "array", g_object_set (_action_by_name (browser, "Trash"), "array",
browser->trash, NULL); browser->trash, NULL);
/* FIXME: Connect to updates */ /* FIXME: Connect to updates */
@ -4385,8 +4382,7 @@ midori_browser_set_property (GObject* object,
break; break;
case PROP_SEARCH_ENGINES: case PROP_SEARCH_ENGINES:
; /* FIXME: Disconnect handlers */ ; /* FIXME: Disconnect handlers */
katze_object_assign (browser->search_engines, g_value_get_object (value)); katze_object_assign (browser->search_engines, g_value_dup_object (value));
g_object_ref (browser->search_engines);
midori_search_action_set_search_engines (MIDORI_SEARCH_ACTION ( midori_search_action_set_search_engines (MIDORI_SEARCH_ACTION (
_action_by_name (browser, "Search")), browser->search_engines); _action_by_name (browser, "Search")), browser->search_engines);
/* FIXME: Connect to updates */ /* FIXME: Connect to updates */
@ -4402,8 +4398,7 @@ midori_browser_set_property (GObject* object,
break; break;
case PROP_HISTORY: case PROP_HISTORY:
; /* FIXME: Disconnect handlers */ ; /* FIXME: Disconnect handlers */
katze_object_assign (browser->history, g_value_get_object (value)); katze_object_assign (browser->history, g_value_dup_object (value));
g_object_ref (browser->history);
midori_browser_load_history (browser); midori_browser_load_history (browser);
g_object_set (_action_by_name (browser, "RecentlyVisited"), "array", g_object_set (_action_by_name (browser, "RecentlyVisited"), "array",
browser->history, NULL); browser->history, NULL);

View file

@ -99,7 +99,8 @@ enum
PROP_PROGRESS, PROP_PROGRESS,
PROP_ZOOM_LEVEL, PROP_ZOOM_LEVEL,
PROP_STATUSBAR_TEXT, PROP_STATUSBAR_TEXT,
PROP_SETTINGS PROP_SETTINGS,
PROP_NET
}; };
enum { enum {
@ -418,6 +419,15 @@ midori_view_class_init (MidoriViewClass* class)
"The associated settings", "The associated settings",
MIDORI_TYPE_WEB_SETTINGS, MIDORI_TYPE_WEB_SETTINGS,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_NET,
g_param_spec_object (
"net",
"Net",
"The associated net",
KATZE_TYPE_NET,
G_PARAM_READWRITE));
} }
static void static void
@ -979,21 +989,19 @@ midori_view_finalize (GObject* object)
g_signal_handlers_disconnect_by_func (view->settings, g_signal_handlers_disconnect_by_func (view->settings,
midori_view_settings_notify_cb, view); midori_view_settings_notify_cb, view);
g_free (view->uri); katze_assign (view->uri, NULL);
g_free (view->title); katze_assign (view->title, NULL);
if (view->icon) katze_object_assign (view->icon, NULL);
g_object_unref (view->icon); katze_assign (view->statusbar_text, NULL);
g_free (view->statusbar_text); katze_assign (view->link_uri, NULL);
g_free (view->link_uri); katze_assign (view->selected_text, NULL);
g_free (view->selected_text);
if (view->settings)
g_object_unref (view->settings);
if (view->item)
g_object_unref (view->item);
g_free (view->download_manager); katze_object_assign (view->settings, NULL);
katze_object_assign (view->item, NULL);
g_object_unref (view->net); katze_assign (view->download_manager, NULL);
katze_object_assign (view->net, NULL);
/* web_frame = webkit_web_view_get_main_frame /* web_frame = webkit_web_view_get_main_frame
(WEBKIT_WEB_VIEW (view->web_view)); (WEBKIT_WEB_VIEW (view->web_view));
@ -1039,6 +1047,11 @@ midori_view_set_property (GObject* object,
case PROP_SETTINGS: case PROP_SETTINGS:
midori_view_set_settings (view, g_value_get_object (value)); midori_view_set_settings (view, g_value_get_object (value));
break; break;
case PROP_NET:
katze_object_assign (view->net, g_value_dup_object (value));
if (!view->net)
view->net = katze_net_new ();
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;
@ -1076,6 +1089,9 @@ midori_view_get_property (GObject* object,
case PROP_SETTINGS: case PROP_SETTINGS:
g_value_set_object (value, view->settings); g_value_set_object (value, view->settings);
break; break;
case PROP_NET:
g_value_set_object (value, view->net);
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;
@ -1084,16 +1100,16 @@ midori_view_get_property (GObject* object,
/** /**
* midori_view_new: * midori_view_new:
* @view: a #MidoriView * @net: a #KatzeNet
* *
* Creates a new view. * Creates a new view.
* *
* Return value: a new #MidoriView * Return value: a new #MidoriView
**/ **/
GtkWidget* GtkWidget*
midori_view_new (void) midori_view_new (KatzeNet* net)
{ {
return g_object_new (MIDORI_TYPE_VIEW, NULL); return g_object_new (MIDORI_TYPE_VIEW, "net", net, NULL);
} }
static void static void

View file

@ -51,7 +51,7 @@ GType
midori_view_get_type (void); midori_view_get_type (void);
GtkWidget* GtkWidget*
midori_view_new (void); midori_view_new (KatzeNet* net);
void void
midori_view_set_settings (MidoriView* view, midori_view_set_settings (MidoriView* view,