[libslab] bnc#187879 - Let one clear the recent-documents list
- From: Federico Mena Quintero <federico src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libslab] bnc#187879 - Let one clear the recent-documents list
- Date: Fri, 28 Aug 2009 00:04:28 +0000 (UTC)
commit 42043b8e0225004cb5dc6e09da995da5e88e6a03
Author: David Liang <dliang novell com>
Date: Thu Aug 27 18:33:09 2009 -0500
bnc#187879 - Let one clear the recent-documents list
Signed-off-by: Federico Mena Quintero <federico novell com>
libslab/bookmark-agent.c | 39 +++++++++++++++++++++++++++++++++++--
libslab/bookmark-agent.h | 3 +-
libslab/document-tile.c | 47 ++++++++++++++++++++++++++++++++++++++-------
3 files changed, 77 insertions(+), 12 deletions(-)
---
diff --git a/libslab/bookmark-agent.c b/libslab/bookmark-agent.c
index bdd418a..d9c8617 100644
--- a/libslab/bookmark-agent.c
+++ b/libslab/bookmark-agent.c
@@ -220,7 +220,7 @@ bookmark_agent_move_item (BookmarkAgent *this, const gchar *uri, const gchar *ur
}
void
-bookmark_agent_remove_item (BookmarkAgent *this, const gchar *uri)
+bookmark_agent_purge_items (BookmarkAgent *this)
{
BookmarkAgentPrivate *priv = PRIVATE (this);
@@ -229,11 +229,44 @@ bookmark_agent_remove_item (BookmarkAgent *this, const gchar *uri)
GError *error = NULL;
gchar **uris = NULL;
- gint rank_i;
+ gsize uris_len;
gint i;
+ g_return_if_fail (priv->user_modifiable);
+
+ uris = g_bookmark_file_get_uris (priv->store, &uris_len);
+ if (TYPE_IS_RECENT (priv->type)) {
+ for (i = 0; i < uris_len; i++) {
+ gtk_recent_manager_remove_item (gtk_recent_manager_get_default (), uris [i], & error);
+ if (error)
+ libslab_handle_g_error (
+ & error, "%s: unable to remove [%s] from %s.",
+ G_STRFUNC, priv->store_path, uris [i]);
+ }
+ } else {
+ for (i = 0; i < uris_len; i++) {
+ g_bookmark_file_remove_item (priv->store, uris [i], NULL);
+ }
+ save_store (this);
+ }
+ g_strfreev (uris);
+}
- g_return_if_fail (priv->user_modifiable);
+void
+bookmark_agent_remove_item (BookmarkAgent *this, const gchar *uri)
+{
+ BookmarkAgentPrivate *priv = PRIVATE (this);
+
+ gint rank;
+
+ GError *error = NULL;
+
+ gchar **uris = NULL;
+ gint rank_i;
+ gint i;
+
+
+ g_return_if_fail (priv->user_modifiable);
if (! bookmark_agent_has_item (this, uri))
return;
diff --git a/libslab/bookmark-agent.h b/libslab/bookmark-agent.h
index 391389e..5f7e9cc 100644
--- a/libslab/bookmark-agent.h
+++ b/libslab/bookmark-agent.h
@@ -80,7 +80,8 @@ void bookmark_agent_move_item (BookmarkAgent *this, const gchar *u
void bookmark_agent_remove_item (BookmarkAgent *this, const gchar *uri);
void bookmark_agent_reorder_items (BookmarkAgent *this, const gchar **uris);
-void bookmark_agent_update_from_bookmark_file (BookmarkAgent *this, GBookmarkFile *store);
+void bookmark_agent_update_from_bookmark_file (BookmarkAgent *this, GBookmarkFile *store);
+void bookmark_agent_purge_items (BookmarkAgent *this);
void bookmark_item_free (BookmarkItem *item);
diff --git a/libslab/document-tile.c b/libslab/document-tile.c
index 26fdc36..ec92a50 100644
--- a/libslab/document-tile.c
+++ b/libslab/document-tile.c
@@ -55,6 +55,8 @@ static void open_with_default_trigger (Tile *, TileEvent *, TileAction *);
static void open_in_file_manager_trigger (Tile *, TileEvent *, TileAction *);
static void rename_trigger (Tile *, TileEvent *, TileAction *);
static void move_to_trash_trigger (Tile *, TileEvent *, TileAction *);
+static void remove_recent_item (Tile *, TileEvent *, TileAction *);
+static void purge_recent_items (Tile *, TileEvent *, TileAction *);
static void delete_trigger (Tile *, TileEvent *, TileAction *);
static void user_docs_trigger (Tile *, TileEvent *, TileAction *);
static void send_to_trigger (Tile *, TileEvent *, TileAction *);
@@ -109,14 +111,14 @@ document_tile_new_force_icon (const gchar *in_uri, const gchar *mime_type, time_
DocumentTile *this;
DocumentTilePrivate *priv;
- this = (DocumentTile *) document_tile_new (in_uri, mime_type, modified);
+ this = (DocumentTile *) document_tile_new (BOOKMARK_STORE_USER_DOCS, in_uri, mime_type, modified);
priv = DOCUMENT_TILE_GET_PRIVATE (this);
priv->force_icon_name = g_strdup (icon);
return GTK_WIDGET (this);
}
GtkWidget *
-document_tile_new (const gchar *in_uri, const gchar *mime_type, time_t modified)
+document_tile_new (BookmarkStoreType bookmark_store_type, const gchar *in_uri, const gchar *mime_type, time_t modified)
{
DocumentTile *this;
DocumentTilePrivate *priv;
@@ -179,11 +181,11 @@ document_tile_new (const gchar *in_uri, const gchar *mime_type, time_t modified)
priv->mime_type = g_strdup (mime_type);
priv->modified = modified;
priv->header_bin = GTK_BIN (header);
+ priv->agent = bookmark_agent_get_instance (bookmark_store_type);
document_tile_private_setup (this);
-
- TILE (this)->actions = g_new0 (TileAction *, 7);
- TILE (this)->n_actions = 7;
+ TILE (this)->actions = g_new0 (TileAction *, DOCUMENT_TILE_ACTION_NUM_OF_ACTIONS);
+ TILE (this)->n_actions = DOCUMENT_TILE_ACTION_NUM_OF_ACTIONS;
menu_ctnr = GTK_CONTAINER (TILE (this)->context_menu);
@@ -297,6 +299,23 @@ document_tile_new (const gchar *in_uri, const gchar *mime_type, time_t modified)
gtk_container_add (menu_ctnr, menu_item);
}
+ if (!priv->is_bookmarked) {
+ /* clean item from menu */
+ action = tile_action_new (TILE (this), remove_recent_item, _("Remove from recent menu"), 0);
+ TILE (this)->actions[DOCUMENT_TILE_ACTION_CLEAN_ITEM] = action;
+
+ menu_item = GTK_WIDGET (tile_action_get_menu_item (action));
+ gtk_container_add (menu_ctnr, menu_item);
+
+ /* clean all the items from menu */
+
+ action = tile_action_new (TILE (this), purge_recent_items, _("Purge all the recent items"), 0);
+ TILE (this)->actions[DOCUMENT_TILE_ACTION_CLEAN_ALL] = action;
+
+ menu_item = GTK_WIDGET (tile_action_get_menu_item (action));
+ gtk_container_add (menu_ctnr, menu_item);
+ }
+
gtk_widget_show_all (GTK_WIDGET (TILE (this)->context_menu));
accessible = gtk_widget_get_accessible (GTK_WIDGET (this));
@@ -343,8 +362,6 @@ document_tile_private_setup (DocumentTile *this)
g_object_unref (client);
- priv->agent = bookmark_agent_get_instance (BOOKMARK_STORE_USER_DOCS);
-
priv->notify_signal_id = g_signal_connect (
G_OBJECT (priv->agent), "notify", G_CALLBACK (agent_notify_cb), this);
}
@@ -715,7 +732,7 @@ update_user_list_menu_item (DocumentTile *this)
if (! action)
return;
- priv->is_bookmarked = bookmark_agent_has_item (priv->agent, TILE (this)->uri);
+ priv->is_bookmarked = bookmark_agent_has_item (bookmark_agent_get_instance (BOOKMARK_STORE_USER_DOCS), TILE (this)->uri);
if (priv->is_bookmarked)
tile_action_set_menu_item_label (action, _("Remove from Favorites"));
@@ -943,6 +960,20 @@ rename_trigger (Tile *tile, TileEvent *event, TileAction *action)
}
static void
+remove_recent_item (Tile *tile, TileEvent *event, TileAction *action)
+{
+ DocumentTilePrivate *priv = DOCUMENT_TILE_GET_PRIVATE (tile);
+ bookmark_agent_remove_item (priv->agent, TILE (tile)->uri);
+}
+
+static void
+purge_recent_items (Tile *tile, TileEvent *event, TileAction *action)
+{
+ DocumentTilePrivate *priv = DOCUMENT_TILE_GET_PRIVATE (tile);
+ bookmark_agent_purge_items (priv->agent);
+}
+
+static void
move_to_trash_trigger (Tile *tile, TileEvent *event, TileAction *action)
{
DocumentTilePrivate *priv = DOCUMENT_TILE_GET_PRIVATE (tile);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]