Create MidoriView proxy item during initialization

This commit is contained in:
Alexander Butenko 2010-07-21 22:12:20 -04:00 committed by Christian Dywan
parent 87ac721127
commit 46c80ad2d1

View file

@ -657,7 +657,6 @@ midori_view_update_title (MidoriView* view)
if (view->menu_item) if (view->menu_item)
gtk_label_set_text (GTK_LABEL (gtk_bin_get_child (GTK_BIN ( gtk_label_set_text (GTK_LABEL (gtk_bin_get_child (GTK_BIN (
view->menu_item))), title); view->menu_item))), title);
if (view->item)
katze_item_set_name (view->item, title); katze_item_set_name (view->item, title);
#undef title #undef title
} }
@ -667,7 +666,6 @@ midori_view_apply_icon (MidoriView* view,
GdkPixbuf* icon, GdkPixbuf* icon,
const gchar* icon_name) const gchar* icon_name)
{ {
if (view->item)
katze_item_set_icon (view->item, icon_name); katze_item_set_icon (view->item, icon_name);
katze_object_assign (view->icon, icon); katze_object_assign (view->icon, icon);
g_object_notify (G_OBJECT (view), "icon"); g_object_notify (G_OBJECT (view), "icon");
@ -1004,15 +1002,14 @@ webkit_web_view_load_committed_cb (WebKitWebView* web_view,
uri = webkit_web_frame_get_uri (web_frame); uri = webkit_web_frame_get_uri (web_frame);
g_return_if_fail (uri != NULL); g_return_if_fail (uri != NULL);
katze_assign (view->uri, sokoke_format_uri_for_display (uri));
katze_assign (view->icon_uri, NULL); katze_assign (view->icon_uri, NULL);
/* FIXME: Create a proxy item if we don't have one. if (g_strcmp0 (uri, katze_item_get_uri (view->item)))
* We should either always create it, or not rely on it */ {
if (!view->item) katze_assign (view->uri, sokoke_format_uri_for_display (uri));
midori_view_get_proxy_item (view);
katze_item_set_uri (view->item, uri); katze_item_set_uri (view->item, uri);
}
katze_item_set_added (view->item, time (NULL)); katze_item_set_added (view->item, time (NULL));
g_object_notify (G_OBJECT (view), "uri"); g_object_notify (G_OBJECT (view), "uri");
@ -2736,7 +2733,6 @@ midori_view_hadjustment_notify_value_cb (GtkAdjustment* hadjustment,
MidoriView* view) MidoriView* view)
{ {
gint value = (gint)gtk_adjustment_get_value (hadjustment); gint value = (gint)gtk_adjustment_get_value (hadjustment);
if (view->item)
katze_item_set_meta_integer (view->item, "scrollh", value); katze_item_set_meta_integer (view->item, "scrollh", value);
} }
@ -2757,7 +2753,6 @@ midori_view_vadjustment_notify_value_cb (GtkAdjustment* vadjustment,
MidoriView* view) MidoriView* view)
{ {
gint value = (gint)gtk_adjustment_get_value (vadjustment); gint value = (gint)gtk_adjustment_get_value (vadjustment);
if (view->item)
katze_item_set_meta_integer (view->item, "scrollv", value); katze_item_set_meta_integer (view->item, "scrollv", value);
} }
@ -2801,7 +2796,8 @@ midori_view_init (MidoriView* view)
view->selected_text = NULL; view->selected_text = NULL;
view->news_feeds = katze_array_new (KATZE_TYPE_ITEM); view->news_feeds = katze_array_new (KATZE_TYPE_ITEM);
view->item = NULL; view->item = katze_item_new ();
view->scrollh = view->scrollv = -2; view->scrollh = view->scrollv = -2;
view->back_forward_set = FALSE; view->back_forward_set = FALSE;
@ -2814,6 +2810,8 @@ midori_view_init (MidoriView* view)
GTK_SHADOW_NONE); GTK_SHADOW_NONE);
gtk_container_add (GTK_CONTAINER (view), view->scrolled_window); gtk_container_add (GTK_CONTAINER (view), view->scrolled_window);
g_signal_connect (view->item, "meta-data-changed",
G_CALLBACK (midori_view_item_meta_data_changed), view);
g_signal_connect (view->scrolled_window, "notify::hadjustment", g_signal_connect (view->scrolled_window, "notify::hadjustment",
G_CALLBACK (midori_view_notify_hadjustment_cb), view); G_CALLBACK (midori_view_notify_hadjustment_cb), view);
g_signal_connect (view->scrolled_window, "notify::vadjustment", g_signal_connect (view->scrolled_window, "notify::vadjustment",
@ -2830,7 +2828,6 @@ midori_view_finalize (GObject* object)
if (view->settings) if (view->settings)
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);
if (view->item)
g_signal_handlers_disconnect_by_func (view->item, g_signal_handlers_disconnect_by_func (view->item,
midori_view_item_meta_data_changed, view); midori_view_item_meta_data_changed, view);
@ -2876,15 +2873,12 @@ midori_view_set_property (GObject* object,
break; break;
case PROP_MINIMIZED: case PROP_MINIMIZED:
view->minimized = g_value_get_boolean (value); view->minimized = g_value_get_boolean (value);
if (view->item)
{
g_signal_handlers_block_by_func (view->item, g_signal_handlers_block_by_func (view->item,
midori_view_item_meta_data_changed, view); midori_view_item_meta_data_changed, view);
katze_item_set_meta_integer (view->item, "minimized", katze_item_set_meta_integer (view->item, "minimized",
view->minimized ? 1 : -1); view->minimized ? 1 : -1);
g_signal_handlers_unblock_by_func (view->item, g_signal_handlers_unblock_by_func (view->item,
midori_view_item_meta_data_changed, view); midori_view_item_meta_data_changed, view);
}
if (view->tab_label) if (view->tab_label)
sokoke_widget_set_visible (view->tab_title, !view->minimized); sokoke_widget_set_visible (view->tab_title, !view->minimized);
break; break;
@ -3405,6 +3399,7 @@ midori_view_set_uri (MidoriView* view,
gchar* filepath; gchar* filepath;
katze_assign (view->uri, g_strdup ("")); katze_assign (view->uri, g_strdup (""));
katze_item_set_uri (view->item, "");
filepath = sokoke_find_data_filename ("midori/res/speeddial-head.html"); filepath = sokoke_find_data_filename ("midori/res/speeddial-head.html");
g_file_get_contents (filepath, &speed_dial_head, NULL, NULL); g_file_get_contents (filepath, &speed_dial_head, NULL, NULL);
@ -3608,7 +3603,6 @@ midori_view_set_uri (MidoriView* view,
WEBKIT_WEB_VIEW (view->web_view), data, view->uri); WEBKIT_WEB_VIEW (view->web_view), data, view->uri);
g_free (data); g_free (data);
g_object_notify (G_OBJECT (view), "uri"); g_object_notify (G_OBJECT (view), "uri");
if (view->item)
katze_item_set_uri (view->item, uri); katze_item_set_uri (view->item, uri);
return; return;
} }
@ -3626,7 +3620,6 @@ midori_view_set_uri (MidoriView* view,
NULL); NULL);
g_free (title); g_free (title);
g_object_notify (G_OBJECT (view), "uri"); g_object_notify (G_OBJECT (view), "uri");
if (view->item)
katze_item_set_uri (view->item, uri); katze_item_set_uri (view->item, uri);
} }
else if (g_str_has_prefix (uri, "javascript:")) else if (g_str_has_prefix (uri, "javascript:"))
@ -3651,7 +3644,6 @@ midori_view_set_uri (MidoriView* view,
{ {
katze_assign (view->uri, sokoke_format_uri_for_display (uri)); katze_assign (view->uri, sokoke_format_uri_for_display (uri));
g_object_notify (G_OBJECT (view), "uri"); g_object_notify (G_OBJECT (view), "uri");
if (view->item)
katze_item_set_uri (view->item, uri); katze_item_set_uri (view->item, uri);
webkit_web_view_open (WEBKIT_WEB_VIEW (view->web_view), uri); webkit_web_view_open (WEBKIT_WEB_VIEW (view->web_view), uri);
} }
@ -4349,8 +4341,7 @@ midori_view_item_meta_data_changed (KatzeItem* item,
* Retrieves a proxy item that can be used for bookmark storage as * Retrieves a proxy item that can be used for bookmark storage as
* well as session management. * well as session management.
* *
* The item is created on the first call and will be updated to reflect * The item reflects changes to the title and uri automatically.
* changes to the title and uri automatically.
* *
* Return value: the proxy #KatzeItem * Return value: the proxy #KatzeItem
**/ **/
@ -4359,12 +4350,6 @@ midori_view_get_proxy_item (MidoriView* view)
{ {
g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL); g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
if (!view->item)
{
view->item = katze_item_new ();
g_signal_connect (view->item, "meta-data-changed",
G_CALLBACK (midori_view_item_meta_data_changed), view);
}
return view->item; return view->item;
} }