...
 
Commits (53)
......@@ -4,4 +4,8 @@ JP Rosevear <jpr@novell.com>
Scott Reeves <sreeves@novell.com>
Contributors:
Rodney Dawes
Jaap A. Haitsma
Jonh Wendell
William Jon McCann
Larry Ewing
2005-06-04 Jim Krehl <jimmyk@novell.com>
* libslab/libslab-utils.c
* libslab/bookmark-agent.c:
Applied modified patch from Darren Kenny to fix BGO #439398. Checks
for NULL values before freeing or printing.
2007-05-08 Scott Reeves <sreeves@novell.com>
* control-center/
* main-menu/etc/gnome-*.desktop:
Actually remove control-center dir.
Add proper categories to .desktop files
2007-04-09 Scott Reeves <sreeves@novell.com>
* configure.in
* main-menu/etc/system-items.xbel
* libslab/Makefile.am
* Makefile.am:
Fix for BNC#255943
Remove CC from g-m-m since it's now shipped by g-c-c
2007-03-29 Jim Krehl <jimmyk@novell.com>
* main-menu/src/main-menu-ui.c:
Only make tiles for local files until remote files can be handled
without blocking.
* main-menu/src/main-menu-migration.c:
Ensure local data exists before creating files.
* main-menu/etc/applications.xbel
* main-menu/etc/places.xbel
* main-menu/etc/system-items.xbel:
Include ranking info in the .xbel file.
* libslab/bookmark-agent.c:
Fix (instead of ignore) corrupted .xbel files.
2007-03-23 Jim Krehl <jimmyk@novell.com>
* libslab/app-resizer.c
* libslab/search-context-picker.c
* libslab/app-shell.c:
Applied patch from Larry Ewing to fix some memory leaks, BNC #244456.
* main-menu/etc/empty.ods
* main-menu/etc/Makefile.am
* libslab/bookmark-agent.c:
Applied patch from Larry Ewing to create valid, empty .ods file, BNC
#249188.
2007-03-18 Jim Krehl <jimmyk@novell.com>
* main-menu/src/main-menu-ui.c
* libslab/libslab-utils.c
* libslab/libslab-utils.h:
Make the menu abide by /apps/panel/global/disable_{log_out,lock_screen}
in gconf.
* libslab/application-tile.c:
Set the Upgrade/Uninstall action flags appropriately.
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:
Fix for BNC#250415 - name some widgets to allow for custom theming
2007-03-08 Scott Reeves <sreeves@novell.com>
* main-menu/src/main-menu-ui.c
* main-menu/src/bookmark-tile-table.c
* libslab/application-tile.c
* libslab/slab-gnome-util.c
* libslab/nameplate-tile.c
* libslab/slab-gnome-util.h
* libslab/nameplate-tile.h
* libslab/libslab-utils.c
* libslab/directory-tile.c
* libslab/document-tile.c
* libslab/document-tile.h:
Various memory leak and array bounds overwrite fixes.
Check properly for g-m-m with version-2 changes
2007-02-28 Jim Krehl <jimmyk@novell.com>
* libslab/document-tile.c
* libslab/directory-tile.c:
Remove extra line separators in the context menu, BNC #240238.
* main-menu/src/user-dirs-tile-table.c:
Properly handle search bookmarks, BNC #246798.
2007-02-26 Jim Krehl <jimmyk@novell.com>
The commit merges in the "version-2" branch. Many things have been
updated/changed for this version ...
* main-menu/src/bookmark-tile-table.c
* main-menu/src/bookmark-tile-table.h
* main-menu/src/main-menu.c
* main-menu/src/main-menu-ui.c
* main-menu/src/main-menu-ui.h
* main-menu/src/recent-apps-tile-table.c
* main-menu/src/recent-apps-tile-table.h
* main-menu/src/recent-docs-tile-table.c
* main-menu/src/recent-docs-tile-table.h
* main-menu/src/system-tile-table.c
* main-menu/src/system-tile-table.h
* main-menu/src/tile-table.c
* main-menu/src/tile-table.h
* main-menu/src/user-apps-tile-table.c
* main-menu/src/user-apps-tile-table.h
* main-menu/src/user-dirs-tile-table.c
* main-menu/src/user-dirs-tile-table.h
* main-menu/src/user-docs-tile-table.c
* main-menu/src/user-docs-tile-table.h:
There are now 3 types of items shown in the main section of the menu:
Applications, Documents, and Places. Applications and Documents can be
either "Favorite" or "Recent". Places corresponds to the list of
default places and user bookmarked places as in the FileChooser dialog.
* main-menu/src/slab-window.glade:
The main-menu is now defined by a glade file.
* main-menu/etc/applications.xbel
* main-menu/etc/documents.xbel
* main-menu/etc/places.xbel
* main-menu/etc/slab.schemas.in.in
* main-menu/etc/system-items.xbel
* main-menu/etc/gnome-screensaver-lock.desktop
* main-menu/etc/gnome-session-kill.desktop
* main-menu/src/main-menu-migration.h
* main-menu/src/main-menu-migration.c:
The lists of user bookmarked Applications and Documents, as well as the
list of system items is now maintained in XBEL files in the user's data
dir. Because of the new storage scheme, migration needs to be done to
preserve user prefs over upgrade. The system area now only references
.desktop files so for items like "Lock Screen" for which there is no
.desktop file the main-menu provides one.
* main-menu/src/main-menu-common.h
* main-menu/src/main-menu-engine.c
* main-menu/src/text-button.c
* main-menu/src/text-button.h
* main-menu/src/file-area-widget.c
* main-menu/src/main-menu-conf.c
* main-menu/src/file-area-widget.h
* main-menu/src/main-menu-conf.h
* main-menu/src/slab-window.c
* main-menu/src/slab-window.h:
These files are no longer pertinent.
* nautilus-main-menu/nautilus-main-menu.c:
Added a nautilus menu extension so that one can bookmark a document
with nautilus.
This update fixes/obsoletes a number of bugs:
* BGO #378793 - g-s-m is no longer opened by the disk space tile.
* BGO #382004 - PANEL_APPLET_EXPAND_MINOR added to panel applet flags.
* BGO #394372 - Ellipses removed.
* BGO #394377 - Recent/Favorite tables have been stacked to compact
them.
* BGO #394384 - Places menu added.
* BGO #394411 - "More <items> ..." button positioning tied to bottom.
* BGO #394488 - Side panel rotation follows text rotation convention.
* BGO #394750 - Properly handle multi-monitor screens.
* BGO #394817 - Do not squash keyboard events on the panel button.
2007-02-22 Scott Reeves <sreeves@novell.com>
* libslab/slab-gnome-util.c
* libslab/app-shell.c
* libslab/app-resizer.c
* libslab/application-tile.c:
start of performance optimization work.
valgrind work for memory leaks.
Patch from Jens Granseuer for leaks - BGO 396110
Fix leaks for BGO 395014 based on patch from Paolo Borelli
2007-02-21 Scott Reeves <sreeves@novell.com>
* libslab/app-resizer.c
* libslab/app-shell.c
* libslab/document-tile.c
* main-menu/src/network-status-agent.c:
valgrind work for memory leaks.
Patch from Kjartan Maraas for compiler warnings and leak - BGO 400533
A11y fix. Based on patch from Patrick Wade for BGO 399238
2007-02-15 Scott Reeves <sreeves@novell.com>
* main-menu/src/system-tile.c
* main-menu/src/slab-window.c
* control-center/src/control-center.c
* libslab/application-tile.c
* libslab/slab-gnome-util.c
* libslab/slab-gnome-util.h
* libslab/document-tile.c
* libslab/shell-window.c
* libslab/slab-section.c
* libslab/app-shell.c:
Use smaller icons in CC - Partial fix for BGO 405078
Patch from Brandon Wright for overdrawn text - BGO 403856
Fix memory leaks - BGO 402563 and BNC 229190
Don't crash (on debug builds) when no menu file - BGO 407825
Check for NULL gconf prefix - BGO 406255
2007-02-14 Rodney Dawes <dobey@novell.com>
* libslab/tile.c (tile_expose): Revert previous patch, as it doesn't
actually seem to fix the text color, and causes #407481
Fixes #407481
Reopens #398079
2007-02-12 Rodney Dawes <dobey@novell.com>
* libslab/tile.c (tile_expose): Modify the fg color to use the
SELECTED fg color, if the tile is in the SELECTED state
Fixes #398079
2007-02-09 Jim Krehl <jimmyk@novell.com>
* main-menu/src/main-menu-ui.c:
Connect to the proper AboutDialog signal to close, BNC #212495, BGO
#389715.
2007-02-01 Scott Reeves <sreeves@novell.com>
* main-menu/etc/slab.schemas.in.in
* libslab/application-tile.c
......@@ -21,7 +288,6 @@
system-tile's launched twice.
* libslab/application-tile.c: - When no GenericName is present then
just show and center the Name
2007-01-19 Scott Reeves <sreeves@novell.com>
* control-center/src/control-center.c
......
......@@ -6,12 +6,9 @@ endif
SUBDIRS = \
libslab \
application-browser/etc \
application-browser/src \
control-center/etc \
control-center/src \
main-menu/etc \
main-menu/src \
applet \
application-browser \
data \
$(NAUTILUS_DIR) \
patch \
po
......
......@@ -11,24 +11,22 @@ AM_CPPFLAGS = \
-DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\"
main_menu_SOURCES = \
directory-tile.c directory-tile.h \
directory-tile-model.c directory-tile-model.h \
document-tile.c document-tile.h \
eggaccelerators.c eggaccelerators.h \
file-area-widget.c file-area-widget.h \
hard-drive-status-tile.c hard-drive-status-tile.h \
file-tile-model.c file-tile-model.h \
main-menu.c \
main-menu-common.h \
main-menu-engine.c \
main-menu-ui.c \
main-menu-conf.c main-menu-conf.h \
network-status-tile.c network-status-tile.h \
network-status-agent.c network-status-agent.h \
network-status-info.c network-status-info.h \
slab-window.c slab-window.h \
main-menu-migration.c main-menu-migration.h \
main-menu-ui.c main-menu-ui.h \
network-tile.c network-tile.h \
network-tile-model.c network-tile-model.h \
storage-tile.c storage-tile.h \
storage-tile-model.c storage-tile-model.h \
system-tile.c system-tile.h \
text-button.c text-button.h \
tile-table.c tile-table.h \
tomboykeybinder.c tomboykeybinder.h
main_menu_LDADD = \
$(MAIN_MENU_LIBS) \
$(GLADE_LIBS) \
$(top_builddir)/libslab/libslab.la
$(top_builddir)/libslab/.libs/libslab.la
#include "directory-tile-model.h"
#include <glib/gi18n.h>
#include <string.h>
#include <libgnomevfs/gnome-vfs.h>
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
#include "libslab-utils.h"
typedef struct {
gchar *uri;
TileAttribute *icon_id_attr;
TileAttribute *name_attr;
TileAttribute *is_local_attr;
TileAttribute *can_delete_attr;
guint enable_delete_monitor_id;
} DirectoryTileModelPrivate;
#define PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DIRECTORY_TILE_MODEL_TYPE, DirectoryTileModelPrivate))
#define OPEN_IN_FILE_BROWSER_CMD_KEY "/desktop/gnome/applications/main-menu/file-area/file_mgr_open_cmd"
#define SEND_TO_CMD_KEY "/desktop/gnome/applications/main-menu/file-area/file_send_to_cmd"
#define ENABLE_DELETE_KEY_DIR "/apps/nautilus/preferences"
#define ENABLE_DELETE_KEY ENABLE_DELETE_KEY_DIR "/enable_delete"
#define DEFAULT_ICON_ID "gnome-fs-directory"
static void this_class_init (DirectoryTileModelClass *);
static void this_init (DirectoryTileModel *);
static void finalize (GObject *);
static void update_model (DirectoryTileModel *);
static gboolean is_home_dir (DirectoryTileModel *);
static gboolean is_documents_dir (DirectoryTileModel *);
static gboolean is_desktop_dir (DirectoryTileModel *);
static gboolean dir_is_local (DirectoryTileModel *);
static void volume_monitor_destroy_cb (gpointer, GObject *);
static void uri_attr_notify_cb (GObject *, GParamSpec *, gpointer);
static void enable_delete_notify_cb (GConfClient *, guint, GConfEntry *, gpointer);
static GnomeVFSVolumeMonitor *volume_monitor = NULL;
static GObjectClass *this_parent_class = NULL;
GType
directory_tile_model_get_type ()
{
static GType type_id = 0;
if (G_UNLIKELY (type_id == 0))
type_id = g_type_register_static_simple (
TILE_MODEL_TYPE, "DirectoryTileModel",
sizeof (DirectoryTileModelClass), (GClassInitFunc) this_class_init,
sizeof (DirectoryTileModel), (GInstanceInitFunc) this_init, 0);
return type_id;
}
DirectoryTileModel *
directory_tile_model_new (const gchar *uri)
{
DirectoryTileModel *this;
DirectoryTileModelPrivate *priv;
this = g_object_new (DIRECTORY_TILE_MODEL_TYPE, NULL);
tile_attribute_set_string (tile_model_get_uri_attr (TILE_MODEL (this)), uri);
priv = PRIVATE (this);
priv->uri = g_strdup (uri);
priv->icon_id_attr = tile_attribute_new (G_TYPE_STRING);
priv->name_attr = tile_attribute_new (G_TYPE_STRING);
priv->is_local_attr = tile_attribute_new (G_TYPE_BOOLEAN);
priv->can_delete_attr = tile_attribute_new (G_TYPE_BOOLEAN);
update_model (this);
tile_attribute_set_boolean (
priv->can_delete_attr,
GPOINTER_TO_INT (libslab_get_gconf_value (ENABLE_DELETE_KEY)));
priv->enable_delete_monitor_id = libslab_gconf_notify_add (
ENABLE_DELETE_KEY, enable_delete_notify_cb, this);
g_signal_connect (
tile_model_get_uri_attr (TILE_MODEL (this)), "notify::" TILE_ATTRIBUTE_VALUE_PROP,
G_CALLBACK (uri_attr_notify_cb), this);
return this;
}
TileAttribute *
directory_tile_model_get_icon_id_attr (DirectoryTileModel *this)
{
return PRIVATE (this)->icon_id_attr;
}
TileAttribute *
directory_tile_model_get_name_attr (DirectoryTileModel *this)
{
return PRIVATE (this)->name_attr;
}
TileAttribute *
directory_tile_model_get_is_local_attr (DirectoryTileModel *this)
{
return PRIVATE (this)->is_local_attr;
}
TileAttribute *
directory_tile_model_get_can_delete_attr (DirectoryTileModel *this)
{
return PRIVATE (this)->can_delete_attr;
}
void
directory_tile_model_open (DirectoryTileModel *this)
{
DirectoryTileModelPrivate *priv = PRIVATE (this);
gchar *cmd_template;
gchar *cmd;
cmd_template = (gchar *) libslab_get_gconf_value (OPEN_IN_FILE_BROWSER_CMD_KEY);
cmd = libslab_string_replace_once (cmd_template, "FILE_URI", priv->uri);
libslab_spawn_command (cmd);
g_free (cmd);
g_free (cmd_template);
}
void
directory_tile_model_send_to (DirectoryTileModel *this)
{
DirectoryTileModelPrivate *priv = PRIVATE (this);
gchar *cmd_template;
gchar *cmd;
gchar *filename;
gchar *dirname;
gchar *basename;
filename = g_filename_from_uri (priv->uri, NULL, NULL);
dirname = g_path_get_dirname (filename);
basename = g_path_get_basename (filename);
cmd_template = (gchar *) libslab_get_gconf_value (SEND_TO_CMD_KEY);
cmd = libslab_string_replace_once (cmd_template, "DIRNAME", dirname);
g_free (cmd_template);
cmd_template = cmd;
cmd = libslab_string_replace_once (cmd_template, "BASENAME", basename);
g_free (cmd_template);
libslab_spawn_command (cmd);
g_free (cmd);
g_free (filename);
g_free (dirname);
g_free (basename);
}
void
directory_tile_model_trash (DirectoryTileModel *this)
{
DirectoryTileModelPrivate *priv = PRIVATE (this);
GnomeVFSURI *src_uri;
GnomeVFSURI *trash_uri;
gchar *file_name;
gchar *trash_uri_str;
GnomeVFSResult retval;
src_uri = gnome_vfs_uri_new (priv->uri);
gnome_vfs_find_directory (
src_uri, GNOME_VFS_DIRECTORY_KIND_TRASH, & trash_uri, FALSE, FALSE, 0777);
if (! trash_uri) {
g_warning ("unable to find trash location\n");
return;
}
file_name = gnome_vfs_uri_extract_short_name (src_uri);
if (! file_name) {
g_warning ("unable to extract short name from [%s]\n", priv->uri);
return;
}
trash_uri = gnome_vfs_uri_append_file_name (trash_uri, file_name);
retval = gnome_vfs_xfer_uri (
src_uri, trash_uri,
GNOME_VFS_XFER_REMOVESOURCE, GNOME_VFS_XFER_ERROR_MODE_ABORT,
GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE, NULL, NULL);
if (retval != GNOME_VFS_OK) {
trash_uri_str = gnome_vfs_uri_to_string (trash_uri, GNOME_VFS_URI_HIDE_NONE);
g_warning ("unable to move [%s] to the trash [%s]\n", priv->uri, trash_uri_str);
g_free (trash_uri_str);
}
gnome_vfs_uri_unref (src_uri);
gnome_vfs_uri_unref (trash_uri);
g_free (file_name);
}
void
directory_tile_model_delete (DirectoryTileModel *this)
{
DirectoryTileModelPrivate *priv = PRIVATE (this);
GnomeVFSURI *src_uri;
GList *list = NULL;
GnomeVFSResult retval;
src_uri = gnome_vfs_uri_new (priv->uri);
list = g_list_append (list, src_uri);
retval = gnome_vfs_xfer_delete_list (
list, GNOME_VFS_XFER_ERROR_MODE_ABORT, GNOME_VFS_XFER_REMOVESOURCE, NULL, NULL);
if (retval != GNOME_VFS_OK)
g_warning ("unable to delete [%s]\n", priv->uri);
gnome_vfs_uri_unref (src_uri);
g_list_free (list);
}
static void
this_class_init (DirectoryTileModelClass *this_class)
{
G_OBJECT_CLASS (this_class)->finalize = finalize;
g_type_class_add_private (this_class, sizeof (DirectoryTileModelPrivate));
this_parent_class = g_type_class_peek_parent (this_class);
}
static void
this_init (DirectoryTileModel *this)
{
DirectoryTileModelPrivate *priv = PRIVATE (this);
GConfClient *client;
priv->uri = NULL;
priv->icon_id_attr = NULL;
priv->name_attr = NULL;
priv->is_local_attr = NULL;
priv->can_delete_attr = NULL;
priv->enable_delete_monitor_id = 0;
client = gconf_client_get_default ();
gconf_client_add_dir (client, ENABLE_DELETE_KEY_DIR, GCONF_CLIENT_PRELOAD_NONE, NULL);
g_object_unref (client);
if (! volume_monitor) {
volume_monitor = gnome_vfs_get_volume_monitor ();
g_object_weak_ref (G_OBJECT (volume_monitor), volume_monitor_destroy_cb, NULL);
}
else
gnome_vfs_volume_monitor_ref (volume_monitor);
}
static void
finalize (GObject *g_obj)
{
DirectoryTileModelPrivate *priv = PRIVATE (g_obj);
GConfClient *client;
g_free (priv->uri);
g_object_unref (priv->icon_id_attr);
g_object_unref (priv->name_attr);
g_object_unref (priv->is_local_attr);
g_object_unref (priv->can_delete_attr);
gnome_vfs_volume_monitor_unref (volume_monitor);
libslab_gconf_notify_remove (priv->enable_delete_monitor_id);
client = gconf_client_get_default ();
gconf_client_remove_dir (client, ENABLE_DELETE_KEY_DIR, NULL);
g_object_unref (client);
G_OBJECT_CLASS (this_parent_class)->finalize (g_obj);
}
static void
update_model (DirectoryTileModel *this)
{
DirectoryTileModelPrivate *priv = PRIVATE (this);
gchar *basename;
gchar *path;
gchar *buf;
gchar *tag_open_ptr = NULL;
gchar *tag_close_ptr = NULL;
gchar *search_string = NULL;
if (is_home_dir (this)) {
tile_attribute_set_string (priv->icon_id_attr, "gnome-fs-home");
tile_attribute_set_string (priv->name_attr, _("Home"));
}
else if (is_documents_dir (this)) {
tile_attribute_set_string (priv->icon_id_attr, DEFAULT_ICON_ID);
tile_attribute_set_string (priv->name_attr, _("Documents"));
}
else if (is_desktop_dir (this)) {
tile_attribute_set_string (priv->icon_id_attr, "gnome-fs-desktop");
tile_attribute_set_string (priv->name_attr, _("Desktop"));
}
else if (! libslab_strcmp (priv->uri, "file:///")) {
tile_attribute_set_string (priv->icon_id_attr, "drive-harddisk");
tile_attribute_set_string (priv->name_attr, _("File System"));
}
else if (! libslab_strcmp (priv->uri, "network:")) {
tile_attribute_set_string (priv->icon_id_attr, "network-workgroup");
tile_attribute_set_string (priv->name_attr, _("Network Servers"));
}
else if (g_str_has_prefix (priv->uri, "x-nautilus-search")) {
tile_attribute_set_string (priv->icon_id_attr, "system-search");
path = g_build_filename (
g_get_home_dir (), ".nautilus", "searches", & priv->uri [21], NULL);
if (g_file_test (path, G_FILE_TEST_EXISTS)) {
g_file_get_contents (path, & buf, NULL, NULL);
if (buf) {
tag_open_ptr = strstr (buf, "<text>");
tag_close_ptr = strstr (buf, "</text>");
}
if (tag_open_ptr && tag_close_ptr) {
tag_close_ptr [0] = '\0';
search_string = g_strdup_printf ("\"%s\"", & tag_open_ptr [6]);
tag_close_ptr [0] = 'a';
}
g_free (buf);
}
if (search_string)
tile_attribute_set_string (priv->name_attr, search_string);
else
tile_attribute_set_string (priv->name_attr, _("Search"));
g_free (path);
}
else {
tile_attribute_set_string (priv->icon_id_attr, DEFAULT_ICON_ID);
path = g_filename_from_uri (priv->uri, NULL, NULL);
basename = g_path_get_basename (path);
tile_attribute_set_string (priv->name_attr, basename);
g_free (path);
g_free (basename);
}
tile_attribute_set_boolean (priv->is_local_attr, dir_is_local (this));
}
static gboolean
is_home_dir (DirectoryTileModel *this)
{
gchar *uri_home;
gboolean retval;
uri_home = g_filename_to_uri (g_get_home_dir (), NULL, NULL);
retval = ! libslab_strcmp (PRIVATE (this)->uri, uri_home);
g_free (uri_home);
return retval;
}
static gboolean
is_documents_dir (DirectoryTileModel *this)
{
gchar *uri_docs;
gchar *path;
gboolean retval;
path = g_build_filename (g_get_home_dir (), "Documents", NULL);
uri_docs = g_filename_to_uri (path, NULL, NULL);
retval = ! libslab_strcmp (PRIVATE (this)->uri, uri_docs);
g_free (path);
g_free (uri_docs);
return retval;
}
static gboolean
is_desktop_dir (DirectoryTileModel *this)
{
gchar *uri_desk;
gchar *path;
gboolean retval;
path = g_build_filename (g_get_home_dir (), "Desktop", NULL);
uri_desk = g_filename_to_uri (path, NULL, NULL);
retval = ! libslab_strcmp (PRIVATE (this)->uri, uri_desk);
g_free (path);
g_free (uri_desk);
return retval;
}
static gboolean
dir_is_local (DirectoryTileModel *this)
{
DirectoryTileModelPrivate *priv = PRIVATE (this);
GList *mounts;
GnomeVFSVolume *vol;
gchar *mount_point;
GnomeVFSURI *gvfs_uri;
gboolean is_local = TRUE;
GList *node;
if (! g_str_has_prefix (priv->uri, "file://"))
return FALSE;
mounts = gnome_vfs_volume_monitor_get_mounted_volumes (volume_monitor);
for (node = mounts; is_local && node; node = node->next) {
vol = (GnomeVFSVolume *) node->data;
if (gnome_vfs_volume_get_device_type (vol) == GNOME_VFS_DEVICE_TYPE_NFS) {
mount_point = gnome_vfs_volume_get_activation_uri (vol);
is_local = ! g_str_has_prefix (priv->uri, mount_point);
g_free (mount_point);
}
}
if (is_local) {
gvfs_uri = gnome_vfs_uri_new (priv->uri);
is_local = gnome_vfs_uri_is_local (gvfs_uri);
gnome_vfs_uri_unref (gvfs_uri);
}
g_list_foreach (mounts, (GFunc) gnome_vfs_volume_unref, NULL);
g_list_free (mounts);
return is_local;
}
static void
volume_monitor_destroy_cb (gpointer data, GObject *g_obj)
{
volume_monitor = NULL;
}
static void
uri_attr_notify_cb (GObject *g_obj, GParamSpec *pspec, gpointer data)
{
DirectoryTileModel *this = DIRECTORY_TILE_MODEL (data);
DirectoryTileModelPrivate *priv = PRIVATE (this);
const gchar *uri;
uri = tile_model_get_uri (TILE_MODEL (this));
if (libslab_strcmp (uri, priv->uri)) {
g_free (priv->uri);
priv->uri = g_strdup (uri);
update_model (this);
}
}
static void
enable_delete_notify_cb (GConfClient *client, guint conn_id,
GConfEntry *entry, gpointer data)
{
tile_attribute_set_boolean (
PRIVATE (data)->can_delete_attr,
GPOINTER_TO_INT (libslab_get_gconf_value (ENABLE_DELETE_KEY)));
}
#ifndef __DIRECTORY_TILE_MODEL_H__
#define __DIRECTORY_TILE_MODEL_H__
#include "tile-model.h"
#include "tile-attribute.h"
G_BEGIN_DECLS
#define DIRECTORY_TILE_MODEL_TYPE (directory_tile_model_get_type ())
#define DIRECTORY_TILE_MODEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), DIRECTORY_TILE_MODEL_TYPE, DirectoryTileModel))
#define DIRECTORY_TILE_MODEL_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), DIRECTORY_TILE_MODEL_TYPE, DirectoryTileModelClass))
#define IS_DIRECTORY_TILE_MODEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), DIRECTORY_TILE_MODEL_TYPE))
#define IS_DIRECTORY_TILE_MODEL_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), DIRECTORY_TILE_MODEL_TYPE))
#define DIRECTORY_TILE_MODEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DIRECTORY_TILE_MODEL_TYPE, DirectoryTileModelClass))
typedef struct {
TileModel tile_model;
} DirectoryTileModel;
typedef struct {
TileModelClass tile_model_class;
} DirectoryTileModelClass;
GType directory_tile_model_get_type (void);
DirectoryTileModel *directory_tile_model_new (const gchar *uri);
TileAttribute *directory_tile_model_get_icon_id_attr (DirectoryTileModel *this);
TileAttribute *directory_tile_model_get_name_attr (DirectoryTileModel *this);
TileAttribute *directory_tile_model_get_is_local_attr (DirectoryTileModel *this);
TileAttribute *directory_tile_model_get_can_delete_attr (DirectoryTileModel *this);
void directory_tile_model_open (DirectoryTileModel *this);
void directory_tile_model_send_to (DirectoryTileModel *this);
void directory_tile_model_trash (DirectoryTileModel *this);
void directory_tile_model_delete (DirectoryTileModel *this);
G_END_DECLS
#endif
#include "directory-tile.h"
#include <glib/gi18n.h>
#include "directory-tile-model.h"
#include "tile-button-view.h"
#include "context-menu-view.h"
#include "tile-attribute.h"
#include "tile-control.h"
#include "libslab-utils.h"
typedef struct {
DirectoryTileModel *model;
TileButtonView *view;
TileControl *uri_control;
TileControl *icon_control;
TileControl *name_control;
TileControl *send_to_menu_item_control;
TileControl *can_delete_control;
} DirectoryTilePrivate;
#define PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DIRECTORY_TILE_TYPE, DirectoryTilePrivate))
static void this_class_init (DirectoryTileClass *);
static void this_init (DirectoryTile *);
static void finalize (GObject *);
static GtkWidget *get_widget (Tile *);
static gboolean equals (Tile *, gconstpointer);
static void clicked_cb (GtkButton *, gpointer);
static void open_item_activate_cb (GtkMenuItem *, gpointer);
static void send_to_item_activate_cb (GtkMenuItem *, gpointer);
static void trash_item_activate_cb (GtkMenuItem *, gpointer);
static void delete_item_activate_cb (GtkMenuItem *, gpointer);
static void send_to_trigger (TileAttribute *, TileAttribute *, gpointer);
static void can_delete_trigger (TileAttribute *, TileAttribute *, gpointer);
static TileClass *this_parent_class = NULL;
GType
directory_tile_get_type ()
{
static GType type_id = 0;
if (G_UNLIKELY (type_id == 0))
type_id = g_type_register_static_simple (
TILE_TYPE, "DirectoryTile",
sizeof (DirectoryTileClass), (GClassInitFunc) this_class_init,
sizeof (DirectoryTile), (GInstanceInitFunc) this_init, 0);
return type_id;
}
DirectoryTile *
directory_tile_new (const gchar *uri)
{
DirectoryTile *this;
DirectoryTilePrivate *priv;
ContextMenuView *menu;
GtkWidget *menu_item;
GtkWidget *menu_item_child;
TileAttribute *menu_attr;
this = g_object_new (DIRECTORY_TILE_TYPE, NULL);
priv = PRIVATE (this);
priv->model = directory_tile_model_new (uri);
priv->view = tile_button_view_new (1);
menu = context_menu_view_new ();
g_object_ref (G_OBJECT (priv->view));
g_object_ref (G_OBJECT (menu));
tile_button_view_add_context_menu (priv->view, GTK_MENU (menu));
g_signal_connect (priv->view, "clicked", G_CALLBACK (clicked_cb), this);
priv->uri_control = tile_control_new (
tile_model_get_uri_attr (TILE_MODEL (priv->model)),
tile_button_view_get_uri_attr (priv->view));
priv->icon_control = tile_control_new (
directory_tile_model_get_icon_id_attr (priv->model),
tile_button_view_get_icon_id_attr (priv->view));
priv->name_control = tile_control_new (
directory_tile_model_get_name_attr (priv->model),
tile_button_view_get_header_text_attr (priv->view, 0));
/* make open app menu-item */
menu_item = gtk_menu_item_new_with_label (_("<b>Open</b>"));
menu_item_child = gtk_bin_get_child (GTK_BIN (menu_item));
gtk_label_set_use_markup (GTK_LABEL (menu_item_child), TRUE);
menu_attr = context_menu_view_add_menu_item (menu, menu_item);
g_signal_connect (menu_item, "activate", G_CALLBACK (open_item_activate_cb), this);
/* insert separator */
gtk_menu_append (GTK_MENU (menu), gtk_separator_menu_item_new ());
/* make send-to menu-item */
menu_item = gtk_menu_item_new_with_label (_("Send To..."));
menu_attr = context_menu_view_add_menu_item (menu, menu_item);
g_signal_connect (menu_item, "activate", G_CALLBACK (send_to_item_activate_cb), this);
priv->send_to_menu_item_control = tile_control_new_with_trigger_func (
directory_tile_model_get_is_local_attr (priv->model), menu_attr,
send_to_trigger, NULL);
/* insert separator */
gtk_menu_append (GTK_MENU (menu), gtk_separator_menu_item_new ());
/* make trash menu-item */
menu_item = gtk_menu_item_new_with_label (_("Move to Trash"));
gtk_menu_append (GTK_MENU (menu), menu_item);
g_signal_connect (menu_item, "activate", G_CALLBACK (trash_item_activate_cb), this);
/* make delete menu-item */
menu_item = gtk_menu_item_new_with_label (_("Delete"));
menu_attr = context_menu_view_add_menu_item (menu, menu_item);
g_signal_connect (menu_item, "activate", G_CALLBACK (delete_item_activate_cb), this);
priv->can_delete_control = tile_control_new_with_trigger_func (
directory_tile_model_get_can_delete_attr (priv->model), menu_attr,
can_delete_trigger, NULL);
gtk_widget_show_all (GTK_WIDGET (menu));
return this;
}
static void
this_class_init (DirectoryTileClass *this_class)
{
TileClass *tile_class = TILE_CLASS (this_class);
G_OBJECT_CLASS (this_class)->finalize = finalize;
tile_class->get_widget = get_widget;
tile_class->equals = equals;
g_type_class_add_private (this_class, sizeof (DirectoryTilePrivate));
this_parent_class = g_type_class_peek_parent (this_class);
}
static void
this_init (DirectoryTile *this)
{
DirectoryTilePrivate *priv = PRIVATE (this);
priv->model = NULL;
priv->view = NULL;
priv->uri_control = NULL;
priv->icon_control = NULL;
priv->name_control = NULL;
priv->can_delete_control = NULL;
}
static void
finalize (GObject *g_obj)
{
DirectoryTilePrivate *priv = PRIVATE (g_obj);
g_object_unref (priv->model);
if (G_IS_OBJECT (priv->view))
g_object_unref (priv->view);
g_object_unref (priv->uri_control);
g_object_unref (priv->icon_control);
g_object_unref (priv->name_control);
g_object_unref (priv->can_delete_control);
G_OBJECT_CLASS (this_parent_class)->finalize (g_obj);
}
static GtkWidget *
get_widget (Tile *this)
{
return GTK_WIDGET (PRIVATE (this)->view);
}
static gboolean
equals (Tile *this, gconstpointer that)
{
const gchar *uri_this;
const gchar *uri_that;
uri_this = tile_model_get_uri (TILE_MODEL (PRIVATE (this)->model));
if (IS_DIRECTORY_TILE (that))
uri_that = tile_model_get_uri (TILE_MODEL (PRIVATE (that)->model));
else
uri_that = (const gchar *) that;
return libslab_strcmp (uri_this, uri_that) == 0;
}
static void
clicked_cb (GtkButton *button, gpointer data)
{
directory_tile_model_open (PRIVATE (data)->model);
tile_action_triggered (TILE (data), TILE_ACTION_LAUNCHES_APP);
}
static void
open_item_activate_cb (GtkMenuItem *menu_item, gpointer data)
{
directory_tile_model_open (PRIVATE (data)->model);
tile_action_triggered (TILE (data), TILE_ACTION_LAUNCHES_APP);
}
static void
send_to_item_activate_cb (GtkMenuItem *menu_item, gpointer data)
{
directory_tile_model_send_to (PRIVATE (data)->model);
tile_action_triggered (TILE (data), TILE_ACTION_LAUNCHES_APP);
}
static void
trash_item_activate_cb (GtkMenuItem *menu_item, gpointer data)
{
directory_tile_model_trash (PRIVATE (data)->model);
}
static void
delete_item_activate_cb (GtkMenuItem *menu_item, gpointer data)
{
directory_tile_model_delete (PRIVATE (data)->model);
}
static void
send_to_trigger (TileAttribute *src, TileAttribute *dst, gpointer data)
{
if (g_value_get_boolean (tile_attribute_get_value (src)))
tile_attribute_set_status (dst, TILE_ATTRIBUTE_ACTIVE);
else
tile_attribute_set_status (dst, TILE_ATTRIBUTE_INACTIVE);
}
static void
can_delete_trigger (TileAttribute *src, TileAttribute *dst, gpointer data)
{
if (g_value_get_boolean (tile_attribute_get_value (src)))
tile_attribute_set_status (dst, TILE_ATTRIBUTE_ACTIVE);
else
tile_attribute_set_status (dst, TILE_ATTRIBUTE_HIDDEN);
}
#ifndef __DIRECTORY_TILE_H__
#define __DIRECTORY_TILE_H__
#include "tile.h"
G_BEGIN_DECLS
#define DIRECTORY_TILE_TYPE (directory_tile_get_type ())
#define DIRECTORY_TILE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), DIRECTORY_TILE_TYPE, DirectoryTile))
#define DIRECTORY_TILE_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), DIRECTORY_TILE_TYPE, DirectoryTileClass))
#define IS_DIRECTORY_TILE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), DIRECTORY_TILE_TYPE))
#define IS_DIRECTORY_TILE_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), DIRECTORY_TILE_TYPE))
#define DIRECTORY_TILE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DIRECTORY_TILE_TYPE, DirectoryTileClass))
typedef struct {
Tile tile;
} DirectoryTile;
typedef struct {
TileClass tile_class;
} DirectoryTileClass;
GType directory_tile_get_type (void);
DirectoryTile *directory_tile_new (const gchar *uri);
G_END_DECLS
#endif
#include "document-tile.h"
#include <glib/gi18n.h>
#include <libgnomevfs/gnome-vfs.h>
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
#include "file-tile-model.h"
#include "tile-button-view.h"
#include "context-menu-view.h"
#include "tile-attribute.h"
#include "tile-control.h"
#include "libslab-utils.h"
#include "bookmark-agent.h"
typedef struct {
FileTileModel *model;
TileButtonView *view;
TileControl *uri_control;
TileControl *icon_control;
TileControl *name_hdr_control;
TileControl *mtime_hdr_control;
TileControl *tooltip_control;
TileControl *open_menu_item_control;
TileControl *send_to_menu_item_control;
TileControl *is_in_store_control;
TileControl *store_status_control;
TileControl *can_delete_control;
} DocumentTilePrivate;
#define PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DOCUMENT_TILE_TYPE, DocumentTilePrivate))
static void this_class_init (DocumentTileClass *);
static void this_init (DocumentTile *);
static void finalize (GObject *);
static GtkWidget *get_widget (Tile *);
static gboolean equals (Tile *, gconstpointer);
static void clicked_cb (GtkButton *, gpointer);
static void open_item_activate_cb (GtkMenuItem *, gpointer);
static void open_in_fb_item_activate_cb (GtkMenuItem *, gpointer);
static void rename_item_activate_cb (GtkMenuItem *, gpointer);
static void send_to_item_activate_cb (GtkMenuItem *, gpointer);
static void user_store_item_activate_cb (GtkMenuItem *, gpointer);
static void trash_item_activate_cb (GtkMenuItem *, gpointer);
static void delete_item_activate_cb (GtkMenuItem *, gpointer);
static void view_name_attr_notify_cb (GObject *, GParamSpec *, gpointer);
static void mtime_trigger (TileAttribute *, TileAttribute *, gpointer);
static void filename_trigger (TileAttribute *, TileAttribute *, gpointer);
static void tooltip_trigger (TileAttribute *, TileAttribute *, gpointer);
static void app_trigger (TileAttribute *, TileAttribute *, gpointer);
static void send_to_trigger (TileAttribute *, TileAttribute *, gpointer);
static void is_in_store_trigger (TileAttribute *, TileAttribute *, gpointer);
static void store_status_trigger (TileAttribute *, TileAttribute *, gpointer);
static void can_delete_trigger (TileAttribute *, TileAttribute *, gpointer);
static TileClass *this_parent_class = NULL;
GType
document_tile_get_type ()
{
static GType type_id = 0;
if (G_UNLIKELY (type_id == 0))
type_id = g_type_register_static_simple (
TILE_TYPE, "DocumentTile",
sizeof (DocumentTileClass), (GClassInitFunc) this_class_init,
sizeof (DocumentTile), (GInstanceInitFunc) this_init, 0);
return type_id;
}
DocumentTile *
document_tile_new (const gchar *uri)
{
DocumentTile *this;
DocumentTilePrivate *priv;
ContextMenuView *menu;
GtkWidget *menu_item;
TileAttribute *menu_attr;
this = g_object_new (DOCUMENT_TILE_TYPE, NULL);
priv = PRIVATE (this);
priv->model = file_tile_model_new (uri);
priv->view = tile_button_view_new (2);
menu = context_menu_view_new ();
g_object_ref (G_OBJECT (priv->view));
g_object_ref (G_OBJECT (menu));
tile_button_view_add_context_menu (priv->view, GTK_MENU (menu));
priv->uri_control = tile_control_new (
tile_model_get_uri_attr (TILE_MODEL (priv->model)),
tile_button_view_get_uri_attr (priv->view));
priv->icon_control = tile_control_new (
file_tile_model_get_icon_id_attr (priv->model),
tile_button_view_get_icon_id_attr (priv->view));
priv->name_hdr_control = tile_control_new_with_trigger_func (
tile_model_get_uri_attr (TILE_MODEL (priv->model)),
tile_button_view_get_header_text_attr (priv->view, 0),
filename_trigger, NULL);
priv->mtime_hdr_control = tile_control_new_with_trigger_func (
file_tile_model_get_mtime_attr (priv->model),
tile_button_view_get_header_text_attr (priv->view, 1),
mtime_trigger, NULL);
priv->tooltip_control = tile_control_new_with_trigger_func (
tile_model_get_uri_attr (TILE_MODEL (priv->model)),
tile_button_view_get_tooltip_attr (priv->view),
tooltip_trigger, NULL);
/* make open in default app menu-item */
menu_item = gtk_menu_item_new ();
menu_attr = context_menu_view_add_menu_item (menu, menu_item);
g_signal_connect (menu_item, "activate", G_CALLBACK (open_item_activate_cb), this);
priv->open_menu_item_control = tile_control_new_with_trigger_func (
file_tile_model_get_app_attr (priv->model), menu_attr, app_trigger, NULL);
/* make open in file browser menu-item */
menu_item = gtk_menu_item_new_with_label (_("Open in File Manager"));
gtk_menu_append (GTK_MENU (menu), menu_item);
g_signal_connect (menu_item, "activate", G_CALLBACK (open_in_fb_item_activate_cb), this);
/* insert separator */
gtk_menu_append (GTK_MENU (menu), gtk_separator_menu_item_new ());
/* make rename menu-item */
menu_item = gtk_menu_item_new_with_label (_("Rename..."));