...
 
Commits (17)
......@@ -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,9 +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;
GSList *list;
GError *error = NULL;
if (! priv->desktop_item) {
priv->desktop_item = load_desktop_item_from_unknown (TILE (this)->uri);
......@@ -341,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);
......@@ -391,29 +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;
if(!use_new_prefix)
key = SLAB_USER_SPECIFIED_APPS_KEY;
else
key = "/apps/main-menu/file-area/user_specified_apps";
if ((list = get_slab_gconf_slist (key))) {
free_slab_gconf_slist_of_strings (list);
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 */
......@@ -430,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
......@@ -458,14 +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);
if (error) {
g_warning ("error monitoring %s [%s]\n", SLAB_USER_SPECIFIED_APPS_KEY, error->message);
g_error_free (error);
}
gtk_widget_show_all (GTK_WIDGET (TILE (this)->context_menu));
}
......@@ -523,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);
......@@ -535,34 +516,27 @@ static void
add_to_user_list (ApplicationTile *this)
{
ApplicationTilePrivate *priv = APPLICATION_TILE_GET_PRIVATE (this);
GList *tiles;
BookmarkItem *item;
tiles = libslab_get_user_app_uris ();
if (! g_list_find_custom (tiles, TILE (this)->uri, (GCompareFunc) libslab_strcmp)) {
tiles = g_list_append (tiles, TILE (this)->uri);
libslab_save_app_uris (tiles);
}
priv->is_in_user_list = TRUE;
item = g_new0 (BookmarkItem, 1);
item->uri = TILE (this)->uri;
item->mime_type = "application/x-desktop";
bookmark_agent_add_item (priv->agent, item);
g_list_free (tiles);
priv->is_bookmarked = TRUE;
}
static void
remove_from_user_list (ApplicationTile *this)
{
ApplicationTilePrivate *priv = APPLICATION_TILE_GET_PRIVATE (this);
GList *tiles;
tiles = libslab_get_user_app_uris ();
tiles = g_list_remove_link (tiles, g_list_find_custom (tiles, TILE (this)->uri, (GCompareFunc) libslab_strcmp));
libslab_save_app_uris (tiles);
priv->is_in_user_list = FALSE;
bookmark_agent_remove_item (priv->agent, TILE (this)->uri);
g_list_free (tiles);
priv->is_bookmarked = FALSE;
}
static void
......@@ -756,16 +730,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
......@@ -853,22 +865,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 *, 6);
TILE (this)->n_actions = 6;
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),
gnome_vfs_mime_application_get_exec (priv->default_app));
if (priv->is_bookmarked)
bookmark_agent_remove_item (priv->agent, tile->uri);
else {
item = g_new0 (BookmarkItem, 1);
item->uri = tile->uri;
item->mime_type = priv->mime_type;
item->mtime = priv->modified;
item->app_name = (gchar *) gnome_vfs_mime_application_get_name (priv->default_app);
item->app_exec = (gchar *) gnome_vfs_mime_application_get_exec (priv->default_app);
bookmark_agent_add_item (priv->agent, item);
g_free (item);
}
update_user_list_menu_item (this);
}
......@@ -866,22 +897,7 @@ send_to_trigger (Tile *tile, TileEvent *event, TileAction *action)
}
static void
docs_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)
{
DocumentTile *this = DOCUMENT_TILE (user_data);
DocumentTilePrivate *priv = DOCUMENT_TILE_GET_PRIVATE (this);
gboolean is_in_user_list_current;
is_in_user_list_current = libslab_user_docs_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 (DOCUMENT_TILE (user_data));
}
/* eggbookmarkfile.h: parsing and building desktop bookmarks
*
* Copyright (C) 2005-2006 Emmanuele Bassi
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
*/
#ifndef __EGG_BOOKMARK_FILE_H__
#define __EGG_BOOKMARK_FILE_H__
#include <glib/gerror.h>
#include <time.h>
G_BEGIN_DECLS
/* GError enumeration
*/
#define EGG_BOOKMARK_FILE_ERROR (egg_bookmark_file_error_quark ())
typedef enum
{
EGG_BOOKMARK_FILE_ERROR_INVALID_URI,
EGG_BOOKMARK_FILE_ERROR_INVALID_VALUE,
EGG_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED,
EGG_BOOKMARK_FILE_ERROR_URI_NOT_FOUND,
EGG_BOOKMARK_FILE_ERROR_DUPLICATE_URI,
EGG_BOOKMARK_FILE_ERROR_READ,
EGG_BOOKMARK_FILE_ERROR_UNKNOWN_ENCODING,
EGG_BOOKMARK_FILE_ERROR_WRITE,
EGG_BOOKMARK_FILE_ERROR_FILE_NOT_FOUND
} EggBookmarkFileError;
GQuark egg_bookmark_file_error_quark (void);
/*
* EggBookmarkFile
*/
typedef struct _EggBookmarkFile EggBookmarkFile;
EggBookmarkFile *egg_bookmark_file_new (void);
void egg_bookmark_file_free (EggBookmarkFile *bookmark);
gboolean egg_bookmark_file_load_from_file (EggBookmarkFile *bookmark,
const gchar *filename,
GError **error);
gboolean egg_bookmark_file_load_from_data (EggBookmarkFile *bookmark,
const gchar *data,
gsize length,
GError **error);
gboolean egg_bookmark_file_load_from_data_dirs (EggBookmarkFile *bookmark,
const gchar *file,
gchar **full_path,
GError **error);
gchar * egg_bookmark_file_to_data (EggBookmarkFile *bookmark,
gsize *length,
GError **error) G_GNUC_MALLOC;
gboolean egg_bookmark_file_to_file (EggBookmarkFile *bookmark,
const gchar *filename,
GError **error);
void egg_bookmark_file_set_title (EggBookmarkFile *bookmark,
const gchar *uri,
const gchar *title);
gchar * egg_bookmark_file_get_title (EggBookmarkFile *bookmark,
const gchar *uri,
GError **error) G_GNUC_MALLOC;
void egg_bookmark_file_set_description (EggBookmarkFile *bookmark,
const gchar *uri,
const gchar *description);
gchar * egg_bookmark_file_get_description (EggBookmarkFile *bookmark,
const gchar *uri,
GError **error) G_GNUC_MALLOC;
void egg_bookmark_file_set_mime_type (EggBookmarkFile *bookmark,
const gchar *uri,
const gchar *mime_type);
gchar * egg_bookmark_file_get_mime_type (EggBookmarkFile *bookmark,
const gchar *uri,
GError **error) G_GNUC_MALLOC;
void egg_bookmark_file_set_groups (EggBookmarkFile *bookmark,
const gchar *uri,
const gchar **groups,
gsize length);
void egg_bookmark_file_add_group (EggBookmarkFile *bookmark,
const gchar *uri,
const gchar *group);
gboolean egg_bookmark_file_has_group (EggBookmarkFile *bookmark,
const gchar *uri,
const gchar *group,
GError **error);
gchar ** egg_bookmark_file_get_groups (EggBookmarkFile *bookmark,
const gchar *uri,
gsize *length,
GError **error) G_GNUC_MALLOC;
void egg_bookmark_file_add_application (EggBookmarkFile *bookmark,
const gchar *uri,
const gchar *name,
const gchar *exec);
gboolean egg_bookmark_file_has_application (EggBookmarkFile *bookmark,
const gchar *uri,
const gchar *name,
GError **error);
gchar ** egg_bookmark_file_get_applications (EggBookmarkFile *bookmark,
const gchar *uri,
gsize *length,
GError **error) G_GNUC_MALLOC;
gboolean egg_bookmark_file_set_app_info (EggBookmarkFile *bookmark,
const gchar *uri,
const gchar *name,
const gchar *exec,
gint count,
time_t stamp,
GError **error);
gboolean egg_bookmark_file_get_app_info (EggBookmarkFile *bookmark,
const gchar *uri,
const gchar *name,
gchar **exec,
guint *count,
time_t *stamp,
GError **error);
void egg_bookmark_file_set_is_private (EggBookmarkFile *bookmark,
const gchar *uri,
gboolean is_private);
gboolean egg_bookmark_file_get_is_private (EggBookmarkFile *bookmark,
const gchar *uri,
GError **error);
void egg_bookmark_file_set_icon (EggBookmarkFile *bookmark,
const gchar *uri,
const gchar *href,
const gchar *mime_type);
gboolean egg_bookmark_file_get_icon (EggBookmarkFile *bookmark,
const gchar *uri,
gchar **href,
gchar **mime_type,
GError **error);
void egg_bookmark_file_set_added (EggBookmarkFile *bookmark,
const gchar *uri,
time_t added);
time_t egg_bookmark_file_get_added (EggBookmarkFile *bookmark,
const gchar *uri,
GError **error);
void egg_bookmark_file_set_modified (EggBookmarkFile *bookmark,
const gchar *uri,
time_t modified);
time_t egg_bookmark_file_get_modified (EggBookmarkFile *bookmark,
const gchar *uri,
GError **error);
void egg_bookmark_file_set_visited (EggBookmarkFile *bookmark,
const gchar *uri,
time_t visited);
time_t egg_bookmark_file_get_visited (EggBookmarkFile *bookmark,
const gchar *uri,
GError **error);
gboolean egg_bookmark_file_has_item (EggBookmarkFile *bookmark,
const gchar *uri);
gint egg_bookmark_file_get_size (EggBookmarkFile *bookmark);
gchar ** egg_bookmark_file_get_uris (EggBookmarkFile *bookmark,
gsize *length) G_GNUC_MALLOC;
gboolean egg_bookmark_file_remove_group (EggBookmarkFile *bookmark,
const gchar *uri,
const gchar *group,
GError **error);
gboolean egg_bookmark_file_remove_application (EggBookmarkFile *bookmark,
const gchar *uri,
const gchar *name,
GError **error);
void egg_bookmark_file_remove_item (EggBookmarkFile *bookmark,
const gchar *uri,
GError **error);
gboolean egg_bookmark_file_move_item (EggBookmarkFile *bookmark,
const gchar *old_uri,
const gchar *new_uri,
GError **error);
G_END_DECLS
#endif /* __EGG_BOOKMARK_FILE_H__ */
/* gbookmarkfile.h: parsing and building desktop bookmarks
*
* Copyright (C) 2005-2006 Emmanuele Bassi
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
*/
#ifndef __LIBSLAB_BOOKMARK_FILE_H__
#define __LIBSLAB_BOOKMARK_FILE_H__
#include <glib/gerror.h>
#include <time.h>
G_BEGIN_DECLS
/* GError enumeration
*/
#define LIBSLAB_BOOKMARK_FILE_ERROR (libslab_bookmark_file_error_quark ())
typedef enum
{
LIBSLAB_BOOKMARK_FILE_ERROR_INVALID_URI,
LIBSLAB_BOOKMARK_FILE_ERROR_INVALID_VALUE,
LIBSLAB_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED,
LIBSLAB_BOOKMARK_FILE_ERROR_URI_NOT_FOUND,
LIBSLAB_BOOKMARK_FILE_ERROR_READ,
LIBSLAB_BOOKMARK_FILE_ERROR_UNKNOWN_ENCODING,
LIBSLAB_BOOKMARK_FILE_ERROR_WRITE,
LIBSLAB_BOOKMARK_FILE_ERROR_FILE_NOT_FOUND
} LibSlabBookmarkFileError;
GQuark libslab_bookmark_file_error_quark (void);
/*
* LibSlabBookmarkFile
*/
typedef struct _LibSlabBookmarkFile LibSlabBookmarkFile;
LibSlabBookmarkFile *libslab_bookmark_file_new (void);
void libslab_bookmark_file_free (LibSlabBookmarkFile *bookmark);
gboolean libslab_bookmark_file_load_from_file (LibSlabBookmarkFile *bookmark,
const gchar *filename,
GError **error);
gboolean libslab_bookmark_file_load_from_data (LibSlabBookmarkFile *bookmark,
const gchar *data,
gsize length,
GError **error);
gboolean libslab_bookmark_file_load_from_data_dirs (LibSlabBookmarkFile *bookmark,
const gchar *file,
gchar **full_path,
GError **error);
gchar * libslab_bookmark_file_to_data (LibSlabBookmarkFile *bookmark,
gsize *length,
GError **error) G_GNUC_MALLOC;
gboolean libslab_bookmark_file_to_file (LibSlabBookmarkFile *bookmark,
const gchar *filename,
GError **error);
void libslab_bookmark_file_set_title (LibSlabBookmarkFile *bookmark,
const gchar *uri,
const gchar *title);
gchar * libslab_bookmark_file_get_title (LibSlabBookmarkFile *bookmark,
const gchar *uri,
GError **error) G_GNUC_MALLOC;
void libslab_bookmark_file_set_description (LibSlabBookmarkFile *bookmark,
const gchar *uri,
const gchar *description);
gchar * libslab_bookmark_file_get_description (LibSlabBookmarkFile *bookmark,
const gchar *uri,
GError **error) G_GNUC_MALLOC;
void libslab_bookmark_file_set_mime_type (LibSlabBookmarkFile *bookmark,
const gchar *uri,
const gchar *mime_type);
gchar * libslab_bookmark_file_get_mime_type (LibSlabBookmarkFile *bookmark,
const gchar *uri,
GError **error) G_GNUC_MALLOC;
void libslab_bookmark_file_set_groups (LibSlabBookmarkFile *bookmark,
const gchar *uri,
const gchar **groups,
gsize length);
void libslab_bookmark_file_add_group (LibSlabBookmarkFile *bookmark,
const gchar *uri,
const gchar *group);
gboolean libslab_bookmark_file_has_group (LibSlabBookmarkFile *bookmark,
const gchar *uri,
const gchar *group,
GError **error);
gchar ** libslab_bookmark_file_get_groups (LibSlabBookmarkFile *bookmark,
const gchar *uri,
gsize *length,
GError **error) G_GNUC_MALLOC;
void libslab_bookmark_file_add_application (LibSlabBookmarkFile *bookmark,
const gchar *uri,
const gchar *name,
const gchar *exec);
gboolean libslab_bookmark_file_has_application (LibSlabBookmarkFile *bookmark,
const gchar *uri,
const gchar *name,
GError **error);
gchar ** libslab_bookmark_file_get_applications (LibSlabBookmarkFile *bookmark,
const gchar *uri,
gsize *length,
GError **error) G_GNUC_MALLOC;
gboolean libslab_bookmark_file_set_app_info (LibSlabBookmarkFile *bookmark,
const gchar *uri,
const gchar *name,
const gchar *exec,
gint count,
time_t stamp,
GError **error);
gboolean libslab_bookmark_file_get_app_info (LibSlabBookmarkFile *bookmark,
const gchar *uri,
const gchar *name,
gchar **exec,
guint *count,
time_t *stamp,
GError **error);
void libslab_bookmark_file_set_is_private (LibSlabBookmarkFile *bookmark,
const gchar *uri,
gboolean is_private);
gboolean libslab_bookmark_file_get_is_private (LibSlabBookmarkFile *bookmark,
const gchar *uri,
GError **error);
void libslab_bookmark_file_set_icon (LibSlabBookmarkFile *bookmark,
const gchar *uri,
const gchar *href,
const gchar *mime_type);
gboolean libslab_bookmark_file_get_icon (LibSlabBookmarkFile *bookmark,
const gchar *uri,
gchar **href,
gchar **mime_type,
GError **error);
void libslab_bookmark_file_set_added (LibSlabBookmarkFile *bookmark,
const gchar *uri,
time_t added);
time_t libslab_bookmark_file_get_added (LibSlabBookmarkFile *bookmark,
const gchar *uri,
GError **error);
void libslab_bookmark_file_set_modified (LibSlabBookmarkFile *bookmark,
const gchar *uri,
time_t modified);
time_t libslab_bookmark_file_get_modified (LibSlabBookmarkFile *bookmark,
const gchar *uri,
GError **error);
void libslab_bookmark_file_set_visited (LibSlabBookmarkFile *bookmark,
const gchar *uri,
time_t visited);
time_t libslab_bookmark_file_get_visited (LibSlabBookmarkFile *bookmark,
const gchar *uri,
GError **error);
gboolean libslab_bookmark_file_has_item (LibSlabBookmarkFile *bookmark,
const gchar *uri);
gint libslab_bookmark_file_get_size (LibSlabBookmarkFile *bookmark);
gchar ** libslab_bookmark_file_get_uris (LibSlabBookmarkFile *bookmark,
gsize *length) G_GNUC_MALLOC;
gboolean libslab_bookmark_file_remove_group (LibSlabBookmarkFile *bookmark,
const gchar *uri,
const gchar *group,
GError **error);
gboolean libslab_bookmark_file_remove_application (LibSlabBookmarkFile *bookmark,
const gchar *uri,
const gchar *name,
GError **error);
gboolean libslab_bookmark_file_remove_item (LibSlabBookmarkFile *bookmark,
const gchar *uri,
GError **error);
gboolean libslab_bookmark_file_move_item (LibSlabBookmarkFile *bookmark,
const gchar *old_uri,
const gchar *new_uri,
GError **error);
G_END_DECLS
#endif /* __LIBSLAB_BOOKMARK_FILE_H__ */
......@@ -8,34 +8,8 @@
#include <gconf/gconf-value.h>
#include <libgnome/gnome-url.h>
#define GLOBAL_XDG_PATH_ENV_VAR "XDG_DATA_DIRS"
#define DEFAULT_GLOBAL_XDG_PATH "/usr/local/share:/usr/share"
#define DEFAULT_USER_XDG_DIR ".local/share"
#define TOP_CONFIG_DIR PACKAGE
#define SYSTEM_BOOKMARK_FILENAME "system-items.xbel"
#define APPS_BOOKMARK_FILENAME "applications.xbel"
#define DOCS_BOOKMARK_FILENAME "documents.xbel"
#define DIRS_BOOKMARK_FILENAME "places.xbel"
#define DISABLE_TERMINAL_GCONF_KEY "/desktop/gnome/lockdown/disable_command_line"
#define MODIFIABLE_SYSTEM_GCONF_KEY "/desktop/gnome/applications/main-menu/lock-down/user_modifiable_system_area"
#define MODIFIABLE_APPS_GCONF_KEY "/desktop/gnome/applications/main-menu/lock-down/user_modifiable_apps"
#define MODIFIABLE_DOCS_GCONF_KEY "/desktop/gnome/applications/main-menu/lock-down/user_modifiable_docs"
#define MODIFIABLE_DIRS_GCONF_KEY "/desktop/gnome/applications/main-menu/lock-down/user_modifiable_dirs"
#define DESKTOP_ITEM_TERMINAL_EMULATOR_FLAG "TerminalEmulator"
static gchar *get_data_file_path (const gchar *, gboolean);
static gboolean store_has_uri (const gchar *, const gchar *);
static GList *get_uri_list (const gchar *);
static void save_uri_list (const gchar *, const GList *);
static void remove_bookmark_item (const gchar *, const gchar *, const gchar *);
static GnomeVFSMonitorHandle *add_store_file_monitor (const gchar *,
GnomeVFSMonitorCallback,
gpointer);
#define ALTERNATE_DOCPATH_KEY "DocPath"
#define ALTERNATE_DOCPATH_KEY "DocPath"
gboolean
libslab_gtk_image_set_by_id (GtkImage *image, const gchar *id)
......@@ -230,40 +204,6 @@ libslab_get_current_time_millis ()
return 1000L * t_curr.tv_sec + t_curr.tv_usec / 1000L;
}
void
libslab_cclosure_marshal_VOID__POINTER_POINTER (GClosure *closure,
GValue *retval,
guint n_param,
const GValue *param,
gpointer invocation_hint,
gpointer marshal_data)
{
libslab_marshal_func_VOID__POINTER_POINTER callback;
GCClosure *cc = (GCClosure *) closure;
gpointer data_0, data_1;
g_return_if_fail (n_param == 3);
if (G_CCLOSURE_SWAP_DATA (closure)) {
data_0 = closure->data;
data_1 = g_value_peek_pointer (param);
}
else {
data_0 = g_value_peek_pointer (param);
data_1 = closure->data;
}
if (marshal_data)
callback = (libslab_marshal_func_VOID__POINTER_POINTER) marshal_data;
else
callback = (libslab_marshal_func_VOID__POINTER_POINTER) cc->callback;
callback (
data_0, g_value_peek_pointer (param + 1),
g_value_peek_pointer (param + 2), data_1);
}
gint
libslab_strcmp (const gchar *a, const gchar *b)
{
......@@ -507,315 +447,6 @@ libslab_handle_g_error (GError **error, const gchar *msg_format, ...)
g_free (msg);
}
GList *
libslab_get_system_item_uris ()
{
GList *uris;
gchar *path;
path = get_data_file_path (SYSTEM_BOOKMARK_FILENAME, FALSE);
uris = get_uri_list (path);
g_free (path);
return uris;
}
GList *
libslab_get_user_app_uris ()
{
GList *uris;
gchar *path;
path = get_data_file_path (APPS_BOOKMARK_FILENAME, FALSE);
uris = get_uri_list (path);
g_free (path);
return uris;
}
GList *
libslab_get_user_doc_uris ()
{
GList *uris;
gchar *path;
path = get_data_file_path (DOCS_BOOKMARK_FILENAME, FALSE);
uris = get_uri_list (path);
g_free (path);
return uris;
}
void
libslab_save_system_item_uris (const GList *uris)
{
save_uri_list (SYSTEM_BOOKMARK_FILENAME, uris);
}
void
libslab_save_app_uris (const GList *uris)
{
save_uri_list (APPS_BOOKMARK_FILENAME, uris);
}
void
libslab_save_doc_uris (const GList *uris)
{
save_uri_list (DOCS_BOOKMARK_FILENAME, uris);
}
GnomeVFSMonitorHandle *
libslab_add_system_item_monitor (GnomeVFSMonitorCallback callback, gpointer user_data)
{
return add_store_file_monitor (SYSTEM_BOOKMARK_FILENAME, callback, user_data);
}
GnomeVFSMonitorHandle *
libslab_add_apps_monitor (GnomeVFSMonitorCallback callback, gpointer user_data)
{
return add_store_file_monitor (APPS_BOOKMARK_FILENAME, callback, user_data);
}
GnomeVFSMonitorHandle *
libslab_add_docs_monitor (GnomeVFSMonitorCallback callback, gpointer user_data)
{
return add_store_file_monitor (DOCS_BOOKMARK_FILENAME, callback, user_data);
}
static GList *
get_uri_list (const gchar *path)
{
#ifdef USE_G_BOOKMARK
GBookmarkFile *bm_file;
#else
EggBookmarkFile *bm_file;
#endif
gchar **uris_array;
GList *uris_list = NULL;
GError *error = NULL;
gint i;
if (! path)
return NULL;
#ifdef USE_G_BOOKMARK
bm_file = g_bookmark_file_new ();
g_bookmark_file_load_from_file (bm_file, path, & error);
#else
bm_file = egg_bookmark_file_new ();
egg_bookmark_file_load_from_file (bm_file, path, & error);
#endif
if (! error) {
#ifdef USE_G_BOOKMARK
uris_array = g_bookmark_file_get_uris (bm_file, NULL);
#else
uris_array = egg_bookmark_file_get_uris (bm_file, NULL);
#endif
for (i = 0; uris_array [i]; ++i)
uris_list = g_list_append (uris_list, g_strdup (uris_array [i]));
}
else
libslab_handle_g_error (
& error, "%s: couldn't load bookmark file [%s]", G_STRFUNC, path);
g_strfreev (uris_array);
#ifdef USE_G_BOOKMARK
g_bookmark_file_free (bm_file);
#else
egg_bookmark_file_free (bm_file);
#endif
return uris_list;
}
gchar *
libslab_get_system_item_store_path (gboolean writeable)
{
return get_data_file_path (SYSTEM_BOOKMARK_FILENAME, writeable);
}
gchar *
libslab_get_user_apps_store_path (gboolean writeable)
{
return get_data_file_path (APPS_BOOKMARK_FILENAME, writeable);
}
gchar *
libslab_get_user_docs_store_path (gboolean writeable)
{
return get_data_file_path (DOCS_BOOKMARK_FILENAME, writeable);
}
gchar *
libslab_get_user_dirs_store_path (gboolean writeable)
{
return get_data_file_path (DIRS_BOOKMARK_FILENAME, writeable);
}
void
libslab_remove_system_item (const gchar *uri)
{
gchar *path_old;
gchar *path_new;
path_old = libslab_get_system_item_store_path (FALSE);
path_new = libslab_get_system_item_store_path (TRUE);
remove_bookmark_item (path_old, path_new, uri);
g_free (path_new);
g_free (path_old);
}
void
libslab_remove_user_doc (const gchar *uri)
{
gchar *path_old;
gchar *path_new;
path_old = libslab_get_user_docs_store_path (FALSE);
path_new = libslab_get_user_docs_store_path (TRUE);
remove_bookmark_item (path_old, path_new, uri);
g_free (path_new);
g_free (path_old);
}
static void
remove_bookmark_item (const gchar *path_old, const gchar *path_new, const gchar *uri)
{
LibSlabBookmarkFile *bm_file;
GError *error = NULL;
bm_file = libslab_bookmark_file_new ();
libslab_bookmark_file_load_from_file (bm_file, path_old, & error);
if (! error) {
libslab_bookmark_file_remove_item (bm_file, uri, NULL);
libslab_bookmark_file_to_file (bm_file, path_new, & error);
if (error)
libslab_handle_g_error (
& error,
"%s: couldn't save bookmark file [%s]",
G_STRFUNC, path_new);
}
else
libslab_handle_g_error (
& error,
"%s: couldn't open bookmark file [%s]",
G_STRFUNC, path_old);
libslab_bookmark_file_free (bm_file);
}
void
libslab_add_user_doc (const gchar *uri, const gchar *mime_type, time_t modified,
const gchar *app_name, const gchar *app_exec)
{
LibSlabBookmarkFile *bm_file;
gchar *path_old;
gchar *path_new;
GError *error = NULL;
path_old = libslab_get_user_docs_store_path (FALSE);
path_new = libslab_get_user_docs_store_path (TRUE);
bm_file = libslab_bookmark_file_new ();
libslab_bookmark_file_load_from_file (bm_file, path_old, & error);
if (! error) {
libslab_bookmark_file_set_mime_type (bm_file, uri, mime_type);
libslab_bookmark_file_set_modified (bm_file, uri, modified);
libslab_bookmark_file_add_application (bm_file, uri, app_name, app_exec);
libslab_bookmark_file_to_file (bm_file, path_new, & error);
if (error)
libslab_handle_g_error (
& error,
"%s: couldn't save bookmark file [%s]",
G_STRFUNC, path_new);
}
else
libslab_handle_g_error (
& error,
"%s: couldn't open bookmark file [%s]",
G_STRFUNC, path_old);
libslab_bookmark_file_free (bm_file);
}
gboolean
libslab_system_item_store_has_uri (const gchar *uri)
{
gchar *path;
gboolean exists;
path = libslab_get_system_item_store_path (FALSE);
exists = store_has_uri (path, uri);
g_free (path);
return exists;
}
gboolean
libslab_user_apps_store_has_uri (const gchar *uri)
{
gchar *path;
gboolean exists;
path = libslab_get_user_apps_store_path (FALSE);
exists = store_has_uri (path, uri);
g_free (path);
return exists;
}
gboolean
libslab_user_docs_store_has_uri (const gchar *uri)
{
gchar *path;
gboolean exists;
path = libslab_get_user_docs_store_path (FALSE);
exists = store_has_uri (path, uri);
g_free (path);
return exists;
}
gboolean
libslab_desktop_item_is_a_terminal (const gchar *uri)
{
......@@ -875,163 +506,3 @@ libslab_spawn_command (const gchar *cmd)
g_strfreev (argv);
}
static gboolean
store_has_uri (const gchar *path, const gchar *uri)
{
LibSlabBookmarkFile *bm_file;
gboolean exists = FALSE;
GError *error = NULL;
bm_file = libslab_bookmark_file_new ();
libslab_bookmark_file_load_from_file (bm_file, path, & error);
if (! error)
exists = libslab_bookmark_file_has_item (bm_file, uri);
else
libslab_handle_g_error (
& error,
"%s: couldn't open bookmark file [%s]",
G_STRFUNC, path);
libslab_bookmark_file_free (bm_file);
return exists;
}
static void
save_uri_list (const gchar *filename, const GList *uris)
{
#ifdef USE_G_BOOKMARK
GBookmarkFile *bm_file;
#else
EggBookmarkFile *bm_file;
#endif
gchar *path;
gchar *uri;
const GList *node;
GError *error = NULL;
path = get_data_file_path (filename, TRUE);
#ifdef USE_G_BOOKMARK
bm_file = g_bookmark_file_new ();
#else
bm_file = egg_bookmark_file_new ();
#endif