Clean up handling of bookmarks like the history before

This commit is contained in:
Christian Dywan 2008-12-21 20:44:31 +01:00
parent a495cc7a5a
commit 995be8e6da

View file

@ -3586,8 +3586,6 @@ midori_browser_set_history (MidoriBrowser* browser,
if (history) if (history)
g_object_ref (history); g_object_ref (history);
katze_object_assign (browser->history, history); katze_object_assign (browser->history, history);
g_signal_connect (browser->history, "clear",
G_CALLBACK (midori_browser_history_clear_cb), browser);
midori_browser_history_clear_cb (browser->history, browser); midori_browser_history_clear_cb (browser->history, browser);
@ -3597,6 +3595,9 @@ midori_browser_set_history (MidoriBrowser* browser,
if (!browser->history) if (!browser->history)
return; return;
g_signal_connect (browser->history, "clear",
G_CALLBACK (midori_browser_history_clear_cb), browser);
treeview = GTK_TREE_VIEW (browser->panel_history); treeview = GTK_TREE_VIEW (browser->panel_history);
treemodel = gtk_tree_view_get_model (treeview); treemodel = gtk_tree_view_get_model (treeview);
_tree_store_insert_history_item (GTK_TREE_STORE (treemodel), _tree_store_insert_history_item (GTK_TREE_STORE (treemodel),
@ -4370,13 +4371,41 @@ bookmarks_model_insert_folder (GtkTreeStore* treestore,
} }
static void static void
midori_browser_load_bookmarks (MidoriBrowser* browser) midori_browser_bookmarks_clear_cb (KatzeArray* bookmarks,
MidoriBrowser* browser)
{
GtkTreeView* treeview;
GtkTreeStore* store;
GtkAction* location_action;
treeview = GTK_TREE_VIEW (browser->panel_bookmarks);
store = GTK_TREE_STORE (gtk_tree_view_get_model (treeview));
gtk_tree_store_clear (store);
}
static void
midori_browser_set_bookmarks (MidoriBrowser* browser,
KatzeArray* bookmarks)
{ {
guint i, n; guint i, n;
KatzeItem* item; KatzeItem* item;
GtkTreeModel* treestore; GtkTreeModel* treestore;
// FIXME: Clear bookmark panel if (browser->bookmarks == bookmarks)
return;
if (browser->bookmarks)
g_signal_handlers_disconnect_by_func (browser->bookmarks,
midori_browser_bookmarks_clear_cb,
browser);
if (bookmarks)
g_object_ref (bookmarks);
katze_object_assign (browser->bookmarks, bookmarks);
midori_browser_bookmarks_clear_cb (browser->bookmarks, browser);
g_object_set (_action_by_name (browser, "Bookmarks"), "array",
browser->bookmarks, NULL);
_action_set_sensitive (browser, "BookmarkAdd", FALSE); _action_set_sensitive (browser, "BookmarkAdd", FALSE);
@ -4393,6 +4422,8 @@ midori_browser_load_bookmarks (MidoriBrowser* browser)
G_CALLBACK (browser_bookmarks_add_item_cb), browser); G_CALLBACK (browser_bookmarks_add_item_cb), browser);
g_signal_connect (browser->bookmarks, "remove-item", g_signal_connect (browser->bookmarks, "remove-item",
G_CALLBACK (browser_bookmarks_remove_item_cb), browser); G_CALLBACK (browser_bookmarks_remove_item_cb), browser);
g_signal_connect (browser->bookmarks, "clear",
G_CALLBACK (midori_browser_bookmarks_clear_cb), browser);
treestore = gtk_tree_view_get_model (GTK_TREE_VIEW (browser->panel_bookmarks)); treestore = gtk_tree_view_get_model (GTK_TREE_VIEW (browser->panel_bookmarks));
bookmarks_model_insert_folder (GTK_TREE_STORE (treestore), bookmarks_model_insert_folder (GTK_TREE_STORE (treestore),
@ -4437,12 +4468,7 @@ midori_browser_set_property (GObject* object,
(GtkCallback) midori_view_set_settings, browser->settings); (GtkCallback) midori_view_set_settings, browser->settings);
break; break;
case PROP_BOOKMARKS: case PROP_BOOKMARKS:
/* FIXME: Disconnect handlers */ midori_browser_set_bookmarks (browser, g_value_get_object (value));
katze_object_assign (browser->bookmarks, g_value_dup_object (value));
g_object_set (_action_by_name (browser, "Bookmarks"), "array",
browser->bookmarks, NULL);
midori_browser_load_bookmarks (browser);
/* FIXME: Connect to updates */
break; break;
case PROP_TRASH: case PROP_TRASH:
/* FIXME: Disconnect handlers */ /* FIXME: Disconnect handlers */
@ -4469,9 +4495,7 @@ midori_browser_set_property (GObject* object,
} }
break; break;
case PROP_HISTORY: case PROP_HISTORY:
/* FIXME: Disconnect handlers */
midori_browser_set_history (browser, g_value_get_object (value)); midori_browser_set_history (browser, g_value_get_object (value));
/* FIXME: Connect to updates */
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);