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.
This commit is contained in:
parent
f0d2c49355
commit
84beea9108
4 changed files with 58 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (C) 2008-2010 Christian Dywan <christian@twotoasts.de>
|
Copyright (C) 2008-2011 Christian Dywan <christian@twotoasts.de>
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -50,6 +50,9 @@ struct _KatzeArrayClass
|
||||||
gint index);
|
gint index);
|
||||||
void
|
void
|
||||||
(*clear) (KatzeArray* array);
|
(*clear) (KatzeArray* array);
|
||||||
|
|
||||||
|
void
|
||||||
|
(*update) (KatzeArray* array);
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (KatzeArray, katze_array, KATZE_TYPE_ITEM);
|
G_DEFINE_TYPE (KatzeArray, katze_array, KATZE_TYPE_ITEM);
|
||||||
|
@ -59,6 +62,7 @@ enum {
|
||||||
REMOVE_ITEM,
|
REMOVE_ITEM,
|
||||||
MOVE_ITEM,
|
MOVE_ITEM,
|
||||||
CLEAR,
|
CLEAR,
|
||||||
|
UPDATE,
|
||||||
|
|
||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
|
@ -175,6 +179,25 @@ katze_array_class_init (KatzeArrayClass* class)
|
||||||
g_cclosure_marshal_VOID__VOID,
|
g_cclosure_marshal_VOID__VOID,
|
||||||
G_TYPE_NONE, 0);
|
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 = G_OBJECT_CLASS (class);
|
||||||
gobject_class->finalize = katze_array_finalize;
|
gobject_class->finalize = katze_array_finalize;
|
||||||
|
|
||||||
|
@ -485,3 +508,20 @@ katze_array_clear (KatzeArray* array)
|
||||||
|
|
||||||
g_signal_emit (array, signals[CLEAR], 0);
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -119,6 +119,9 @@ extern GList* kalistglobal;
|
||||||
void
|
void
|
||||||
katze_array_clear (KatzeArray* array);
|
katze_array_clear (KatzeArray* array);
|
||||||
|
|
||||||
|
void
|
||||||
|
katze_array_update (KatzeArray* array);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __KATZE_ARRAY_H__ */
|
#endif /* __KATZE_ARRAY_H__ */
|
||||||
|
|
|
@ -4118,6 +4118,7 @@ _action_bookmarks_import_activate (GtkAction* action,
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
}
|
}
|
||||||
midori_bookmarks_import_array_db (db, browser->bookmarks, selected);
|
midori_bookmarks_import_array_db (db, browser->bookmarks, selected);
|
||||||
|
katze_array_update (browser->bookmarks);
|
||||||
g_free (selected);
|
g_free (selected);
|
||||||
g_free (path);
|
g_free (path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,6 +309,17 @@ midori_bookmarks_remove_item_cb (KatzeArray* array,
|
||||||
GTK_TREE_STORE (model), NULL, NULL, bookmarks->filter);
|
GTK_TREE_STORE (model), NULL, NULL, bookmarks->filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static void
|
||||||
midori_bookmarks_row_changed_cb (GtkTreeModel* model,
|
midori_bookmarks_row_changed_cb (GtkTreeModel* model,
|
||||||
GtkTreePath* path,
|
GtkTreePath* path,
|
||||||
|
@ -498,6 +509,8 @@ midori_bookmarks_set_app (MidoriBookmarks* bookmarks,
|
||||||
G_CALLBACK (midori_bookmarks_add_item_cb), bookmarks);
|
G_CALLBACK (midori_bookmarks_add_item_cb), bookmarks);
|
||||||
g_signal_connect (bookmarks->array, "remove-item",
|
g_signal_connect (bookmarks->array, "remove-item",
|
||||||
G_CALLBACK (midori_bookmarks_remove_item_cb), bookmarks);
|
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_signal_connect_after (model, "row-changed",
|
||||||
G_CALLBACK (midori_bookmarks_row_changed_cb),
|
G_CALLBACK (midori_bookmarks_row_changed_cb),
|
||||||
bookmarks);
|
bookmarks);
|
||||||
|
|
Loading…
Reference in a new issue