Commit 8d841454 authored by Jim Krehl's avatar Jim Krehl

merged in bookmarks-reorg

svn path=/trunk/; revision=237
parent 5d48c6d5
2007-03-16 Jim Krehl <jimmyk@novell.com>
* main-menu/src/main-menu-ui.c
* main-menu/src/user-apps-tile-table.c
* main-menu/src/user-apps-tile-table.h
* main-menu/src/system-tile-table.c
* main-menu/src/system-tile-table.h
* main-menu/src/user-docs-tile-table.c
* main-menu/src/user-docs-tile-table.h
* main-menu/src/user-dirs-tile-table.c
* main-menu/src/user-dirs-tile-table.h
* main-menu/src/recent-apps-tile-table.c
* main-menu/src/recent-apps-tile-table.h
* main-menu/src/bookmark-tile-table.c
* main-menu/src/bookmark-tile-table.h
* main-menu/src/recent-docs-tile-table.c
* main-menu/src/recent-docs-tile-table.h
* main-menu/src/tile-table.c
* main-menu/src/tile-table.h:
Simplified the TileTable object to make it more generic. Stop loading
tiles after the table limit has been reached, this is to prevent delays
associated with large ~/.recently-used{,.xbel} files. Made the
TileTable more responsive to user changes, instead of waiting for those
changes to be written to the file system.
* main-menu/src/main-menu-migration.c
* main-menu/etc/documents.xbel
* libslab/application-tile.c
* libslab/libslab-utils.c
* libslab/libslab-utils.h
* libslab/libslab-bookmarkfile.c
* libslab/system-tile.c
* libslab/libslab-bookmarkfile.h
* libslab/eggbookmarkfile.c
* libslab/eggbookmarkfile.h
* libslab/bookmark-agent.c
* libslab/bookmark-agent.h
* libslab/document-tile.c
* libslab/bookmark-agent-libslab.h:
Created a BookmarkAgent class to manage various bookmark stores, i.e.
XBEL stores, ~/.recently-used, and ~/.gtk-bookmarks. Now all bookmark
store manipulation is centralized and coordinated. The rank of a
bookmark is now independent of serialized order. Now the bookmark
group is used to store it's placement within a table.
2007-03-15 Scott Reeves <sreeves@novell.com>
* libslab/slab-section.c
* libslab/app-shell.c:
......
......@@ -10,12 +10,15 @@ libslab_la_SOURCES = \
app-shell.c \
app-shell-startup.c \
application-tile.c \
bookmark-agent.h \
bookmark-agent-libslab.h \
bookmark-agent.c \
directory-tile.c \
document-tile.c \
double-click-detector.c \
double-click-detector.h \
eggbookmarkfile.c \
eggbookmarkfile.h \
libslab-bookmarkfile.c \
libslab-bookmarkfile.h \
egg-recent-item.c \
egg-recent-item.h \
egg-recent-model.c \
......@@ -24,8 +27,6 @@ libslab_la_SOURCES = \
libslab-utils.c \
libslab-utils.h \
nameplate-tile.c \
recent-files.c \
recent-files.h \
search-bar.c \
search-context-picker.c \
search-entry-watermark.h \
......
......@@ -25,10 +25,11 @@
#include <glib/gfileutils.h>
#include <glib/gstdio.h>
#include <gconf/gconf-client.h>
#include <unistd.h>
#include "slab-gnome-util.h"
#include "libslab-utils.h"
#include "bookmark-agent.h"
#include "themed-icon.h"
G_DEFINE_TYPE (ApplicationTile, application_tile, NAMEPLATE_TILE_TYPE)
......@@ -66,14 +67,11 @@ static gboolean verify_package_management_command (const gchar *);
static void run_package_management_command (ApplicationTile *, gchar *);
static void update_user_list_menu_item (ApplicationTile *);
static void agent_notify_cb (GObject *, GParamSpec *, gpointer);
static StartupStatus get_desktop_item_startup_status (GnomeDesktopItem *);
static void update_startup_menu_item (ApplicationTile *);
static void apps_store_monitor_cb (
GnomeVFSMonitorHandle *, const gchar *,
const gchar *, GnomeVFSMonitorEventType, gpointer);
typedef struct {
GnomeDesktopItem *desktop_item;
......@@ -82,10 +80,12 @@ typedef struct {
GtkIconSize image_size;
gboolean show_generic_name;
gboolean is_in_user_list;
StartupStatus startup_status;
GnomeVFSMonitorHandle *user_spec_monitor_handle;
BookmarkAgent *agent;
BookmarkStoreStatus agent_status;
gboolean is_bookmarked;
gulong notify_signal_id;
} ApplicationTilePrivate;
#define APPLICATION_TILE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), APPLICATION_TILE_TYPE, ApplicationTilePrivate))
......@@ -177,9 +177,10 @@ application_tile_init (ApplicationTile *tile)
priv->image_id = NULL;
priv->image_is_broken = TRUE;
priv->is_in_user_list = FALSE;
priv->user_spec_monitor_handle = NULL;
priv->agent = NULL;
priv->agent_status = BOOKMARK_STORE_ABSENT;
priv->is_bookmarked = FALSE;
priv->notify_signal_id = 0;
tile->name = tile->description = tile->gconf_prefix = NULL;
}
......@@ -212,8 +213,10 @@ application_tile_finalize (GObject *g_object)
priv->image_id = NULL;
}
if (priv->user_spec_monitor_handle)
gnome_vfs_monitor_cancel (priv->user_spec_monitor_handle);
if (priv->notify_signal_id)
g_signal_handler_disconnect (priv->agent, priv->notify_signal_id);
g_object_unref (G_OBJECT (priv->agent));
G_OBJECT_CLASS (application_tile_parent_class)->finalize (g_object);
}
......@@ -297,7 +300,7 @@ application_tile_setup (ApplicationTile *this, const gchar *gconf_prefix)
/*Fixme - need to address the entire gconf key location issue */
/*Fixme - this is just a temporary stop gap */
gboolean use_new_prefix;
gchar *testval;
if (! priv->desktop_item) {
priv->desktop_item = load_desktop_item_from_unknown (TILE (this)->uri);
......@@ -339,7 +342,12 @@ application_tile_setup (ApplicationTile *this, const gchar *gconf_prefix)
"gconf-prefix", gconf_prefix,
NULL);
priv->is_in_user_list = libslab_user_apps_store_has_uri (TILE (this)->uri);
priv->agent = bookmark_agent_get_instance (BOOKMARK_STORE_USER_APPS);
g_object_get (G_OBJECT (priv->agent), BOOKMARK_AGENT_STORE_STATUS_PROP, & priv->agent_status, NULL);
priv->notify_signal_id = g_signal_connect (
G_OBJECT (priv->agent), "notify", G_CALLBACK (agent_notify_cb), this);
priv->startup_status = get_desktop_item_startup_status (priv->desktop_item);
actions = g_new0 (TileAction *, 6);
......@@ -389,30 +397,7 @@ application_tile_setup (ApplicationTile *this, const gchar *gconf_prefix)
/* make "add/remove to favorites" action */
if (this->gconf_prefix && !g_str_has_prefix (this->gconf_prefix, "/desktop/"))
use_new_prefix = TRUE;
else
use_new_prefix = FALSE;
/* see if g-m-m is installed */
if(!use_new_prefix)
key = SLAB_APPLICATION_BROWSER_KEY;
else
key = "/apps/main-menu/application_browser";
if ((testval = get_slab_gconf_string (key))) {
g_free (testval);
action = tile_action_new (TILE (this), user_apps_trigger, NULL, 0);
actions [APPLICATION_TILE_ACTION_UPDATE_MAIN_MENU] = action;
update_user_list_menu_item (this);
menu_item = GTK_WIDGET (tile_action_get_menu_item (action));
gtk_container_add (menu_ctnr, menu_item);
} else
actions [APPLICATION_TILE_ACTION_UPDATE_MAIN_MENU] = NULL;
update_user_list_menu_item (this);
/* make "add/remove to startup" action */
......@@ -429,6 +414,11 @@ application_tile_setup (ApplicationTile *this, const gchar *gconf_prefix)
/* make upgrade action */
if (this->gconf_prefix && ! g_str_has_prefix (this->gconf_prefix, "/desktop/"))
use_new_prefix = TRUE;
else
use_new_prefix = FALSE;
if(!use_new_prefix)
key = SLAB_UPGRADE_PACKAGE_KEY;
else
......@@ -457,8 +447,6 @@ application_tile_setup (ApplicationTile *this, const gchar *gconf_prefix)
} else
actions [APPLICATION_TILE_ACTION_UNINSTALL_PACKAGE] = NULL;
priv->user_spec_monitor_handle = libslab_add_apps_monitor (apps_store_monitor_cb, this);
gtk_widget_show_all (GTK_WIDGET (TILE (this)->context_menu));
}
......@@ -516,7 +504,7 @@ user_apps_trigger (Tile *tile, TileEvent *event, TileAction *action)
ApplicationTile *this = APPLICATION_TILE (tile);
ApplicationTilePrivate *priv = APPLICATION_TILE_GET_PRIVATE (this);
if (priv->is_in_user_list)
if (priv->is_bookmarked)
remove_from_user_list (this);
else
add_to_user_list (this);
......@@ -528,37 +516,28 @@ static void
add_to_user_list (ApplicationTile *this)
{
ApplicationTilePrivate *priv = APPLICATION_TILE_GET_PRIVATE (this);
GList *tiles;
tiles = libslab_get_user_app_uris ();
if (! g_list_find_custom (tiles, TILE (this)->uri, (GCompareFunc) libslab_strcmp)) {
tiles = g_list_append (tiles, g_strdup (TILE (this)->uri));
libslab_save_app_uris (tiles);
}
BookmarkItem *item;
priv->is_in_user_list = TRUE;
item = g_new0 (BookmarkItem, 1);
item->uri = TILE (this)->uri;
item->mime_type = "application/x-desktop";
if (tiles)
free_list_of_strings (tiles);
bookmark_agent_add_item (priv->agent, item);
g_free (item);
priv->is_bookmarked = TRUE;
}
static void
remove_from_user_list (ApplicationTile *this)
{
ApplicationTilePrivate *priv = APPLICATION_TILE_GET_PRIVATE (this);
GList *tiles, *item;
tiles = libslab_get_user_app_uris ();
item = g_list_find_custom (tiles, TILE (this)->uri, (GCompareFunc) libslab_strcmp);
tiles = g_list_remove_link (tiles, item);
libslab_save_app_uris (tiles);
priv->is_in_user_list = FALSE;
bookmark_agent_remove_item (priv->agent, TILE (this)->uri);
if (item)
free_list_of_strings (item);
if (tiles)
free_list_of_strings (tiles);
priv->is_bookmarked = FALSE;
}
static void
......@@ -752,16 +731,54 @@ application_tile_get_desktop_item (ApplicationTile *tile)
static void
update_user_list_menu_item (ApplicationTile *this)
{
TileAction *action = TILE (this)->actions [APPLICATION_TILE_ACTION_UPDATE_MAIN_MENU];
ApplicationTilePrivate *priv = APPLICATION_TILE_GET_PRIVATE (this);
if (!action)
TileAction *action;
GtkWidget *item;
if (priv->agent_status == BOOKMARK_STORE_ABSENT) {
if (TILE (this)->actions [APPLICATION_TILE_ACTION_UPDATE_MAIN_MENU])
g_object_unref (TILE (this)->actions [APPLICATION_TILE_ACTION_UPDATE_MAIN_MENU]);
TILE (this)->actions [APPLICATION_TILE_ACTION_UPDATE_MAIN_MENU] = NULL;
}
else if (! TILE (this)->actions [APPLICATION_TILE_ACTION_UPDATE_MAIN_MENU]) {
TILE (this)->actions [APPLICATION_TILE_ACTION_UPDATE_MAIN_MENU] =
tile_action_new (TILE (this), user_apps_trigger, NULL, 0);
tile_action_set_menu_item_label (
TILE (this)->actions [APPLICATION_TILE_ACTION_UPDATE_MAIN_MENU], "blah");
item = GTK_WIDGET (tile_action_get_menu_item (
TILE (this)->actions [APPLICATION_TILE_ACTION_UPDATE_MAIN_MENU]));
gtk_menu_shell_insert (GTK_MENU_SHELL (TILE (this)->context_menu), item, 4);
gtk_widget_show_all (item);
}
else
/* do nothing */ ;
action = TILE (this)->actions [APPLICATION_TILE_ACTION_UPDATE_MAIN_MENU];
if (! action)
return;
if (priv->is_in_user_list)
priv->is_bookmarked = bookmark_agent_has_item (priv->agent, TILE (this)->uri);
if (priv->is_bookmarked)
tile_action_set_menu_item_label (action, _("Remove from Favorites"));
else
tile_action_set_menu_item_label (action, _("Add to Favorites"));
item = GTK_WIDGET (tile_action_get_menu_item (action));
if (! GTK_IS_MENU_ITEM (item))
return;
g_object_get (G_OBJECT (priv->agent), BOOKMARK_AGENT_STORE_STATUS_PROP, & priv->agent_status, NULL);
gtk_widget_set_sensitive (item, (priv->agent_status != BOOKMARK_STORE_DEFAULT_ONLY));
}
static StartupStatus
......@@ -849,22 +866,7 @@ header_size_allocate_cb (GtkWidget *widget, GtkAllocation *alloc, gpointer user_
}
static void
apps_store_monitor_cb (
GnomeVFSMonitorHandle *handle, const gchar *monitor_uri,
const gchar *info_uri, GnomeVFSMonitorEventType type, gpointer user_data)
agent_notify_cb (GObject *g_obj, GParamSpec *pspec, gpointer user_data)
{
ApplicationTile *this = APPLICATION_TILE (user_data);
ApplicationTilePrivate *priv = APPLICATION_TILE_GET_PRIVATE (this);
gboolean is_in_user_list_current;
is_in_user_list_current = libslab_user_apps_store_has_uri (TILE (this)->uri);
if (is_in_user_list_current == priv->is_in_user_list)
return;
priv->is_in_user_list = is_in_user_list_current;
update_user_list_menu_item (this);
update_user_list_menu_item (APPLICATION_TILE (user_data));
}
/*
* This file is part of the Main Menu.
*
* Copyright (c) 2007 Novell, Inc.
*
* The Main Menu is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* The Main Menu is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* the Main Menu; if not, write to the Free Software Foundation, Inc., 51
* Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __BOOKMARK_AGENT_LIBSLAB_H__
#define __BOOKMARK_AGENT_LIBSLAB_H__
#include <glib.h>
G_BEGIN_DECLS
#include "libslab-bookmarkfile.h"
#define GBookmarkFile LibSlabBookmarkFile
#define g_bookmark_file_new libslab_bookmark_file_new
#define g_bookmark_file_free libslab_bookmark_file_free
#define g_bookmark_file_load_from_file libslab_bookmark_file_load_from_file
#define g_bookmark_file_to_file libslab_bookmark_file_to_file
#define g_bookmark_file_has_item libslab_bookmark_file_has_item
#define g_bookmark_file_remove_item libslab_bookmark_file_remove_item
#define g_bookmark_file_get_uris libslab_bookmark_file_get_uris
#define g_bookmark_file_get_size libslab_bookmark_file_get_size
#define g_bookmark_file_get_title libslab_bookmark_file_get_title
#define g_bookmark_file_set_title libslab_bookmark_file_set_title
#define g_bookmark_file_get_mime_type libslab_bookmark_file_get_mime_type
#define g_bookmark_file_set_mime_type libslab_bookmark_file_set_mime_type
#define g_bookmark_file_get_modified libslab_bookmark_file_get_modified
#define g_bookmark_file_set_modified libslab_bookmark_file_set_modified
#define g_bookmark_file_get_icon libslab_bookmark_file_get_icon
#define g_bookmark_file_set_icon libslab_bookmark_file_set_icon
#define g_bookmark_file_get_applications libslab_bookmark_file_get_applications
#define g_bookmark_file_add_application libslab_bookmark_file_add_application
#define g_bookmark_file_get_app_info libslab_bookmark_file_get_app_info
#define g_bookmark_file_get_groups libslab_bookmark_file_get_groups
#define g_bookmark_file_add_group libslab_bookmark_file_add_group
#define g_bookmark_file_remove_group libslab_bookmark_file_remove_group
#define g_bookmark_file_move_item libslab_bookmark_file_move_item
G_END_DECLS
#endif
This diff is collapsed.
/*
* This file is part of the Main Menu.
*
* Copyright (c) 2007 Novell, Inc.
*
* The Main Menu is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* The Main Menu is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* the Main Menu; if not, write to the Free Software Foundation, Inc., 51
* Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __BOOKMARK_AGENT_H__
#define __BOOKMARK_AGENT_H__
#include <time.h>
#include <glib-object.h>
G_BEGIN_DECLS
#define BOOKMARK_AGENT_TYPE (bookmark_agent_get_type ())
#define BOOKMARK_AGENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), BOOKMARK_AGENT_TYPE, BookmarkAgent))
#define BOOKMARK_AGENT_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), BOOKMARK_AGENT_TYPE, BookmarkAgentClass))
#define IS_BOOKMARK_AGENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), BOOKMARK_AGENT_TYPE))
#define IS_BOOKMARK_AGENT_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), BOOKMARK_AGENT_TYPE))
#define BOOKMARK_AGENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), BOOKMARK_AGENT_TYPE, BookmarkAgentClass))
#define BOOKMARK_AGENT_STORE_STATUS_PROP "store-status"
#define BOOKMARK_AGENT_ITEMS_PROP "items"
typedef struct {
gchar *uri;
gchar *title;
gchar *mime_type;
time_t mtime;
gchar *icon;
gchar *app_name;
gchar *app_exec;
} BookmarkItem;
typedef enum {
BOOKMARK_STORE_DEFAULT_ONLY,
BOOKMARK_STORE_DEFAULT,
BOOKMARK_STORE_USER,
BOOKMARK_STORE_ABSENT
} BookmarkStoreStatus;
typedef enum {
BOOKMARK_STORE_USER_APPS = 0,
BOOKMARK_STORE_USER_DOCS = 1,
BOOKMARK_STORE_USER_DIRS = 2,
BOOKMARK_STORE_RECENT_APPS = 3,
BOOKMARK_STORE_RECENT_DOCS = 4,
BOOKMARK_STORE_SYSTEM = 5,
BOOKMARK_STORE_N_TYPES = 6
} BookmarkStoreType;
typedef struct {
GObject g_object;
} BookmarkAgent;
typedef struct {
GObjectClass g_object_class;
} BookmarkAgentClass;
GType bookmark_agent_get_type (void);
BookmarkAgent *bookmark_agent_get_instance (BookmarkStoreType type);
gboolean bookmark_agent_has_item (BookmarkAgent *this, const gchar *uri);
void bookmark_agent_add_item (BookmarkAgent *this, const BookmarkItem *item);
void bookmark_agent_move_item (BookmarkAgent *this, const gchar *uri, const gchar *uri_new);
void bookmark_agent_remove_item (BookmarkAgent *this, const gchar *uri);
void bookmark_agent_reorder_items (BookmarkAgent *this, const gchar **uris);
void bookmark_item_free (BookmarkItem *item);
G_END_DECLS
#endif
......@@ -33,7 +33,7 @@
#include "slab-gnome-util.h"
#include "gnome-utils.h"
#include "libslab-utils.h"
#include "recent-files.h"
#include "bookmark-agent.h"
#define GCONF_SEND_TO_CMD_KEY "/desktop/gnome/applications/main-menu/file-area/file_send_to_cmd"
#define GCONF_ENABLE_DELETE_KEY_DIR "/apps/nautilus/preferences"
......@@ -66,29 +66,28 @@ static gboolean rename_entry_key_release_cb (GtkWidget *, GdkEventKey *, gpointe
static void gconf_enable_delete_cb (GConfClient *, guint, GConfEntry *, gpointer);
static void docs_store_monitor_cb (GnomeVFSMonitorHandle *, const gchar *, const gchar *,
GnomeVFSMonitorEventType, gpointer);
static void agent_notify_cb (GObject *, GParamSpec *, gpointer);
typedef struct
{
gchar *basename;
gchar *mime_type;
time_t modified;
GnomeVFSMimeApplication *default_app;
GtkBin *header_bin;
gboolean renaming;
gboolean image_is_broken;
gboolean delete_enabled;
guint gconf_conn_id;
gboolean is_in_user_list;
GnomeVFSMonitorHandle *user_monitor;
MainMenuRecentMonitor *recent_monitor;
BookmarkAgent *agent;
BookmarkStoreStatus store_status;
gboolean is_bookmarked;
gulong notify_signal_id;
} DocumentTilePrivate;
static GnomeThumbnailFactory *thumbnail_factory = NULL;
......@@ -183,8 +182,8 @@ document_tile_new (const gchar *in_uri, const gchar *mime_type, time_t modified)
document_tile_private_setup (this);
TILE (this)->actions = g_new0 (TileAction *, DOCUMENT_TILE_ACTION_NUM_OF_ACTIONS);
TILE (this)->n_actions = DOCUMENT_TILE_ACTION_NUM_OF_ACTIONS;
TILE (this)->actions = g_new0 (TileAction *, 7);
TILE (this)->n_actions = 7;
menu_ctnr = GTK_CONTAINER (TILE (this)->context_menu);
......@@ -313,18 +312,19 @@ document_tile_new (const gchar *in_uri, const gchar *mime_type, time_t modified)
}
static void
document_tile_private_setup (DocumentTile *tile)
document_tile_private_setup (DocumentTile *this)
{
DocumentTilePrivate *priv = DOCUMENT_TILE_GET_PRIVATE (tile);
DocumentTilePrivate *priv = DOCUMENT_TILE_GET_PRIVATE (this);
GnomeVFSResult result;
GnomeVFSFileInfo *info;
GConfClient *client;
info = gnome_vfs_file_info_new ();
result = gnome_vfs_get_file_info (TILE (tile)->uri, info,
result = gnome_vfs_get_file_info (TILE (this)->uri, info,
GNOME_VFS_FILE_INFO_GET_MIME_TYPE | GNOME_VFS_FILE_INFO_FORCE_FAST_MIME_TYPE);
if (result == GNOME_VFS_OK)
......@@ -343,14 +343,14 @@ document_tile_private_setup (DocumentTile *tile)
gconf_client_add_dir (client, GCONF_ENABLE_DELETE_KEY_DIR, GCONF_CLIENT_PRELOAD_NONE, NULL);
priv->gconf_conn_id =
connect_gconf_notify (GCONF_ENABLE_DELETE_KEY, gconf_enable_delete_cb, tile);
connect_gconf_notify (GCONF_ENABLE_DELETE_KEY, gconf_enable_delete_cb, this);
g_object_unref (client);
priv->is_in_user_list = libslab_user_docs_store_has_uri (TILE (tile)->uri);
priv->agent = bookmark_agent_get_instance (BOOKMARK_STORE_USER_DOCS);
priv->user_monitor = libslab_add_docs_monitor (docs_store_monitor_cb, tile);
priv->recent_monitor = main_menu_recent_monitor_new ();
priv->notify_signal_id = g_signal_connect (
G_OBJECT (priv->agent), "notify", G_CALLBACK (agent_notify_cb), this);
}
static void
......@@ -358,17 +358,24 @@ document_tile_init (DocumentTile *tile)
{
DocumentTilePrivate *priv = DOCUMENT_TILE_GET_PRIVATE (tile);
priv->basename = NULL;
priv->mime_type = NULL;
priv->default_app = NULL;
priv->header_bin = NULL;
priv->renaming = FALSE;
priv->image_is_broken = TRUE;
priv->delete_enabled = FALSE;
priv->gconf_conn_id = 0;
priv->is_in_user_list = FALSE;
priv->user_monitor = NULL;
priv->recent_monitor = NULL;
priv->basename = NULL;
priv->mime_type = NULL;
priv->modified = 0;
priv->default_app = NULL;
priv->header_bin = NULL;
priv->renaming = FALSE;
priv->image_is_broken = TRUE;
priv->delete_enabled = FALSE;
priv->gconf_conn_id = 0;
priv->agent = NULL;
priv->store_status = BOOKMARK_STORE_DEFAULT;
priv->is_bookmarked = FALSE;
priv->notify_signal_id = 0;
}
static void
......@@ -383,6 +390,11 @@ document_tile_finalize (GObject *g_object)
gnome_vfs_mime_application_free (priv->default_app);
if (priv->notify_signal_id)
g_signal_handler_disconnect (priv->agent, priv->notify_signal_id);
g_object_unref (G_OBJECT (priv->agent));
client = gconf_client_get_default ();
gconf_client_notify_remove (client, priv->gconf_conn_id);
......@@ -390,12 +402,7 @@ document_tile_finalize (GObject *g_object)
g_object_unref (client);
g_object_unref (priv->recent_monitor);
if (priv->user_monitor)
gnome_vfs_monitor_cancel (priv->user_monitor);
(* G_OBJECT_CLASS (document_tile_parent_class)->finalize) (g_object);
G_OBJECT_CLASS (document_tile_parent_class)->finalize (g_object);
}
static void
......@@ -502,16 +509,32 @@ create_subheader (const gchar *desc)
static void
update_user_list_menu_item (DocumentTile *this)
{
TileAction *action = TILE (this)->actions [DOCUMENT_TILE_ACTION_UPDATE_MAIN_MENU];
DocumentTilePrivate *priv = DOCUMENT_TILE_GET_PRIVATE (this);
TileAction *action;
GtkMenuItem *item;
action = TILE (this)->actions [DOCUMENT_TILE_ACTION_UPDATE_MAIN_MENU];
if (! action)
return;
if (priv->is_in_user_list)
priv->is_bookmarked = bookmark_agent_has_item (priv->agent, TILE (this)->uri);
if (priv->is_bookmarked)
tile_action_set_menu_item_label (action, _("Remove from Favorites"));
else
tile_action_set_menu_item_label (action, _("Add to Favorites"));
item = tile_action_get_menu_item (action);
if (! GTK_IS_MENU_ITEM (item))
return;
g_object_get (G_OBJECT (priv->agent), BOOKMARK_AGENT_STORE_STATUS_PROP, & priv->store_status, NULL);
gtk_widget_set_sensitive (GTK_WIDGET (item), (priv->store_status != BOOKMARK_STORE_DEFAULT_ONLY));
}
static void
......@@ -556,7 +579,7 @@ rename_entry_activate_cb (GtkEntry *entry, gpointer user_data)
dst_uri_str = gnome_vfs_uri_to_string (dst_uri, GNOME_VFS_URI_HIDE_NONE);
if (retval == GNOME_VFS_OK) {
main_menu_rename_recent_file (priv->recent_monitor, TILE (tile)->uri, dst_uri_str);
bookmark_agent_move_item (priv->agent, TILE (tile)->uri, dst_uri_str);
g_free (priv->basename);
priv->basename = g_strdup (gtk_entry_get_text (entry));
......@@ -752,7 +775,7 @@ move_to_trash_trigger (Tile *tile, TileEvent *event, TileAction *action)
GNOME_VFS_XFER_ERROR_MODE_ABORT, GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE, NULL, NULL);
if (retval == GNOME_VFS_OK)
main_menu_remove_recent_file (priv->recent_monitor, TILE (tile)->uri);
bookmark_agent_remove_item (priv->agent, TILE (tile)->uri);
else {
trash_uri_str = gnome_vfs_uri_to_string (trash_uri, GNOME_VFS_URI_HIDE_NONE);
......@@ -787,7 +810,7 @@ delete_trigger (Tile *tile, TileEvent *event, TileAction *action)
GNOME_VFS_XFER_REMOVESOURCE, NULL, NULL);
if (retval == GNOME_VFS_OK)
main_menu_remove_recent_file (priv->recent_monitor, TILE (tile)->uri);
bookmark_agent_remove_item (priv->agent, TILE (tile)->uri);
else
g_warning ("unable to delete [%s]\n", TILE (tile)->uri);
......@@ -801,14 +824,22 @@ user_docs_trigger (Tile *tile, TileEvent *event, TileAction *action)
DocumentTile *this = DOCUMENT_TILE (tile);
DocumentTilePrivate *priv = DOCUMENT_TILE_GET_PRIVATE (this);
BookmarkItem *item;
if (priv->is_in_user_list)
libslab_remove_user_doc (tile->uri);
else
libslab_add_user_doc (
tile->uri, priv->mime_type, priv->modified,
gnome_vfs_mime_application_get_name (priv->default_app),