[Xfce4-commits] <midori:master> Add KatzeArray::update and call it after import
Christian Dywan
noreply at xfce.org
Wed Jan 19 21:58:03 CET 2011
Updating branch refs/heads/master
to 84beea9108bd00722202e5bdbb7f663cf35da760 (commit)
from f0d2c49355317bc498277749a97c1aaa28871f9c (commit)
commit 84beea9108bd00722202e5bdbb7f663cf35da760
Author: Christian Dywan <christian at twotoasts.de>
Date: Wed Jan 19 21:58:26 2011 +0100
Add KatzeArray::update and call it after import
This new function and according signal allow one
update of the treeview after importing directly
into the database.
katze/katze-array.c | 42 +++++++++++++++++++++++++++++++++++++++++-
katze/katze-array.h | 3 +++
midori/midori-browser.c | 1 +
panels/midori-bookmarks.c | 13 +++++++++++++
4 files changed, 58 insertions(+), 1 deletions(-)
diff --git a/katze/katze-array.c b/katze/katze-array.c
index 35bc537..76638df 100644
--- a/katze/katze-array.c
+++ b/katze/katze-array.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2008-2010 Christian Dywan <christian at twotoasts.de>
+ Copyright (C) 2008-2011 Christian Dywan <christian at twotoasts.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -50,6 +50,9 @@ struct _KatzeArrayClass
gint index);
void
(*clear) (KatzeArray* array);
+
+ void
+ (*update) (KatzeArray* array);
};
G_DEFINE_TYPE (KatzeArray, katze_array, KATZE_TYPE_ITEM);
@@ -59,6 +62,7 @@ enum {
REMOVE_ITEM,
MOVE_ITEM,
CLEAR,
+ UPDATE,
LAST_SIGNAL
};
@@ -175,6 +179,25 @@ katze_array_class_init (KatzeArrayClass* class)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+ /**
+ * KatzeArray::update:
+ * @array: the object on which the signal is emitted
+ *
+ * The array changed and any display widgets should
+ * be updated.
+ *
+ * Since: 0.3.0
+ **/
+ signals[UPDATE] = g_signal_new (
+ "update",
+ G_TYPE_FROM_CLASS (class),
+ (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ 0,
+ 0,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
gobject_class = G_OBJECT_CLASS (class);
gobject_class->finalize = katze_array_finalize;
@@ -485,3 +508,20 @@ katze_array_clear (KatzeArray* array)
g_signal_emit (array, signals[CLEAR], 0);
}
+
+/**
+ * katze_array_update:
+ * @array: a #KatzeArray
+ *
+ * Indicates that the array changed and any display
+ * widgets should be updated.
+ *
+ * Since: 0.3.0
+ **/
+void
+katze_array_update (KatzeArray* array)
+{
+ g_return_if_fail (KATZE_IS_ARRAY (array));
+
+ g_signal_emit (array, signals[UPDATE], 0);
+}
diff --git a/katze/katze-array.h b/katze/katze-array.h
index 0593bec..a2f601c 100644
--- a/katze/katze-array.h
+++ b/katze/katze-array.h
@@ -119,6 +119,9 @@ extern GList* kalistglobal;
void
katze_array_clear (KatzeArray* array);
+void
+katze_array_update (KatzeArray* array);
+
G_END_DECLS
#endif /* __KATZE_ARRAY_H__ */
diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index 0e78307..802806a 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -4118,6 +4118,7 @@ _action_bookmarks_import_activate (GtkAction* action,
g_error_free (error);
}
midori_bookmarks_import_array_db (db, browser->bookmarks, selected);
+ katze_array_update (browser->bookmarks);
g_free (selected);
g_free (path);
}
diff --git a/panels/midori-bookmarks.c b/panels/midori-bookmarks.c
index 3e0924f..d8c70da 100644
--- a/panels/midori-bookmarks.c
+++ b/panels/midori-bookmarks.c
@@ -310,6 +310,17 @@ midori_bookmarks_remove_item_cb (KatzeArray* array,
}
static void
+midori_bookmarks_update_cb (KatzeArray* array,
+ MidoriBookmarks* bookmarks)
+{
+ GtkTreeModel* model = gtk_tree_view_get_model (GTK_TREE_VIEW (bookmarks->treeview));
+ gtk_tree_store_clear (GTK_TREE_STORE (model));
+ midori_bookmarks_read_from_db_to_model (bookmarks,
+ GTK_TREE_STORE (model), NULL, NULL, bookmarks->filter);
+}
+
+
+static void
midori_bookmarks_row_changed_cb (GtkTreeModel* model,
GtkTreePath* path,
GtkTreeIter* iter,
@@ -498,6 +509,8 @@ midori_bookmarks_set_app (MidoriBookmarks* bookmarks,
G_CALLBACK (midori_bookmarks_add_item_cb), bookmarks);
g_signal_connect (bookmarks->array, "remove-item",
G_CALLBACK (midori_bookmarks_remove_item_cb), bookmarks);
+ g_signal_connect (bookmarks->array, "update",
+ G_CALLBACK (midori_bookmarks_update_cb), bookmarks);
g_signal_connect_after (model, "row-changed",
G_CALLBACK (midori_bookmarks_row_changed_cb),
bookmarks);
More information about the Xfce4-commits
mailing list