[Xfce4-commits] <gigolo:master> Display the folder as part of the URI for bookmarks in tooltips

Enrico Tröger noreply at xfce.org
Sun Oct 4 21:42:09 CEST 2009


Updating branch refs/heads/master
         to b830b73b2ad0c543177060537f123ae5109bd94c (commit)
       from dfed14533d77228b05210a80c0a668652abb6202 (commit)

commit b830b73b2ad0c543177060537f123ae5109bd94c
Author: Enrico Tröger <enrico at xfce.org>
Date:   Sun Oct 4 21:37:03 2009 +0200

    Display the folder as part of the URI for bookmarks in tooltips

 src/backendgvfs.c |   43 +++++++++++++++++++++++++++++++++++--------
 src/backendgvfs.h |    2 +-
 src/window.c      |    4 +++-
 3 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/src/backendgvfs.c b/src/backendgvfs.c
index 75b5cbe..8ce95cd 100644
--- a/src/backendgvfs.c
+++ b/src/backendgvfs.c
@@ -25,6 +25,9 @@
 
 #include "common.h"
 #include "backendgvfs.h"
+#include "bookmark.h"
+#include "settings.h"
+#include "window.h"
 #include "mountoperation.h"
 
 typedef struct _GigoloBackendGVFSPrivate			GigoloBackendGVFSPrivate;
@@ -35,6 +38,7 @@ typedef struct _GigoloBackendGVFSPrivate			GigoloBackendGVFSPrivate;
 enum
 {
     PROP_0,
+    PROP_PARENT,
     PROP_STORE
 };
 
@@ -80,6 +84,7 @@ typedef struct BrowseData
 
 struct _GigoloBackendGVFSPrivate
 {
+	GtkWindow *parent;
 	GtkListStore *store;
 
 	gint browse_counter;
@@ -145,6 +150,15 @@ static void gigolo_backend_gvfs_class_init(GigoloBackendGVFSClass *klass)
 	g_type_class_add_private(klass, sizeof(GigoloBackendGVFSPrivate));
 
 	g_object_class_install_property(g_object_class,
+										PROP_PARENT,
+										g_param_spec_object(
+										"parent",
+										"Parent",
+										"Parent window",
+										GTK_TYPE_WINDOW,
+										G_PARAM_WRITABLE));
+
+	g_object_class_install_property(g_object_class,
 										PROP_STORE,
 										g_param_spec_object(
 										"store",
@@ -199,17 +213,26 @@ static void gigolo_backend_gvfs_finalize(GObject *object)
 }
 
 
-static gchar *get_tooltip_text(gpointer ref, gint ref_type, const gchar *type)
+static gchar *get_tooltip_text(GigoloBackendGVFS *backend, gpointer ref, gint ref_type, const gchar *type)
 {
 	gchar *result = NULL;
+	GigoloBackendGVFSPrivate *priv = GIGOLO_BACKEND_GVFS_GET_PRIVATE(backend);
 	switch (ref_type)
 	{
 		case GIGOLO_WINDOW_REF_TYPE_MOUNT:
 		{
 			gchar *uri, *name, *clean_uri;
+			GigoloBookmark *b;
+			GigoloSettings *settings;
 
 			gigolo_backend_gvfs_get_name_and_uri_from_mount(ref, &name, &uri);
 			clean_uri = g_uri_unescape_string(uri, G_URI_RESERVED_CHARS_ALLOWED_IN_USERINFO);
+
+			settings = gigolo_window_get_settings(GIGOLO_WINDOW(priv->parent));
+			b = gigolo_settings_get_bookmark_by_uri(settings, clean_uri);
+			if (b != NULL)
+				setptr(clean_uri, g_build_filename(clean_uri, gigolo_bookmark_get_folder(b), NULL));
+
 			result = g_strdup_printf(
 				_("<b>%s</b>\n\nURI: %s\nConnected: Yes\nService Type: %s"), name, clean_uri, type);
 
@@ -266,7 +289,7 @@ static void mount_volume_changed_cb(GVolumeMonitor *vm, G_GNUC_UNUSED GMount *mn
 		scheme_name = gigolo_describe_scheme(scheme);
 		uri = g_file_get_uri(file);
 		icon = g_mount_get_icon(mount);
-		tooltip_text = get_tooltip_text(mount, GIGOLO_WINDOW_REF_TYPE_MOUNT, scheme_name);
+		tooltip_text = get_tooltip_text(backend, mount, GIGOLO_WINDOW_REF_TYPE_MOUNT, scheme_name);
 
 		gtk_list_store_insert_with_values(priv->store, &iter, -1,
 				GIGOLO_WINDOW_COL_IS_MOUNTED, TRUE,
@@ -299,7 +322,7 @@ static void mount_volume_changed_cb(GVolumeMonitor *vm, G_GNUC_UNUSED GMount *mn
 		{
 			icon = g_volume_get_icon(volume);
 			vol_name = g_volume_get_name(volume);
-			tooltip_text = get_tooltip_text(volume, GIGOLO_WINDOW_REF_TYPE_VOLUME, NULL);
+			tooltip_text = get_tooltip_text(backend, volume, GIGOLO_WINDOW_REF_TYPE_VOLUME, NULL);
 
 			gtk_list_store_insert_with_values(priv->store, &iter, -1,
 					GIGOLO_WINDOW_COL_IS_MOUNTED, FALSE,
@@ -328,12 +351,18 @@ static void mount_volume_changed_cb(GVolumeMonitor *vm, G_GNUC_UNUSED GMount *mn
 static void gigolo_backend_gvfs_set_property(GObject *object, guint prop_id,
 											 const GValue *value, GParamSpec *pspec)
 {
+	GigoloBackendGVFSPrivate *priv = GIGOLO_BACKEND_GVFS_GET_PRIVATE(object);
+
 	switch (prop_id)
 	{
+	case PROP_PARENT:
+	{
+		priv->parent = g_value_get_object(value);
+		break;
+	}
 	case PROP_STORE:
 	{
 		GVolumeMonitor *gvm;
-		GigoloBackendGVFSPrivate *priv = GIGOLO_BACKEND_GVFS_GET_PRIVATE(object);
 
 		priv->store = g_value_get_object(value);
 
@@ -361,11 +390,9 @@ static void gigolo_backend_gvfs_init(G_GNUC_UNUSED GigoloBackendGVFS *self)
 }
 
 
-GigoloBackendGVFS *gigolo_backend_gvfs_new(GtkListStore *store)
+GigoloBackendGVFS *gigolo_backend_gvfs_new(void)
 {
-	GigoloBackendGVFS *backend = g_object_new(GIGOLO_BACKEND_GVFS_TYPE, "store", store, NULL);
-
-	return backend;
+	return g_object_new(GIGOLO_BACKEND_GVFS_TYPE, NULL);
 }
 
 
diff --git a/src/backendgvfs.h b/src/backendgvfs.h
index c949a33..b544ddf 100644
--- a/src/backendgvfs.h
+++ b/src/backendgvfs.h
@@ -86,7 +86,7 @@ enum
 
 
 GType				gigolo_backend_gvfs_get_type					(void);
-GigoloBackendGVFS*	gigolo_backend_gvfs_new							(GtkListStore *store);
+GigoloBackendGVFS*	gigolo_backend_gvfs_new							(void);
 
 gboolean			gigolo_backend_gvfs_is_mount					(gpointer mount);
 void				gigolo_backend_gvfs_get_name_and_uri_from_mount	(gpointer mount, gchar **name, gchar **uri);
diff --git a/src/window.c b/src/window.c
index 1295d43..7070dcb 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1415,7 +1415,7 @@ static void gigolo_window_init(GigoloWindow *window)
 	gtk_container_add(GTK_CONTAINER(priv->swin_iconview), priv->iconview);
 
 	/* Init the GVfs backend */
-	priv->backend_gvfs = gigolo_backend_gvfs_new(priv->store);
+	priv->backend_gvfs = gigolo_backend_gvfs_new();
 	g_signal_connect(priv->backend_gvfs, "mounts-changed", G_CALLBACK(mounts_changed_cb), window);
 	g_signal_connect(priv->backend_gvfs, "operation-failed",
 		G_CALLBACK(mount_operation_failed_cb), window);
@@ -1489,6 +1489,8 @@ GtkWidget *gigolo_window_new(GigoloSettings *settings)
 
 	g_object_set(priv->action_bookmarks, "settings", settings, NULL);
 
+	g_object_set(priv->backend_gvfs, "parent", window, "store", priv->store, NULL);
+
 	gigolo_window_set_toolbar_style(GIGOLO_WINDOW(window),
 		gigolo_settings_get_integer(settings, "toolbar-style"));
 	gigolo_window_set_toolbar_orientation(GIGOLO_WINDOW(window),



More information about the Xfce4-commits mailing list