[Xfce4-commits] <gigolo:master> allow editing bookmarks from the main window popup menu

Enrico Tröger noreply at xfce.org
Mon Jan 3 00:10:03 CET 2011


Updating branch refs/heads/master
         to 626550456eae93cf97626d36ccd9d41d9236174c (commit)
       from 065f3a6fd1b2d616abe4965cb0387769dc9c8dd0 (commit)

commit 626550456eae93cf97626d36ccd9d41d9236174c
Author: Enrico Tröger <enrico at xfce.org>
Date:   Fri Dec 31 01:15:14 2010 +0100

    allow editing bookmarks from the main window popup menu

 src/window.c |   36 ++++++++++++++++++++++++++++++------
 1 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/src/window.c b/src/window.c
index d69f924..9436021 100644
--- a/src/window.c
+++ b/src/window.c
@@ -606,6 +606,16 @@ static gboolean iter_is_bookmark(GigoloWindow *window, GtkTreeModel *model, GtkT
 }
 
 
+static void update_create_edit_bookmark_action_label(GtkAction *action, gboolean is_bookmark)
+{
+	gtk_action_set_sensitive(action, TRUE);
+	if (is_bookmark)
+		gtk_action_set_label(action, _("Edit _Bookmark"));
+	else
+		gtk_action_set_label(action, _("Create _Bookmark"));
+}
+
+
 static void update_sensitive_buttons(GigoloWindow *window, GtkTreeModel *model, GtkTreeIter *iter)
 {
 	GigoloWindowPrivate *priv = GIGOLO_WINDOW_GET_PRIVATE(window);
@@ -619,7 +629,7 @@ static void update_sensitive_buttons(GigoloWindow *window, GtkTreeModel *model,
 
 		gtk_action_set_sensitive(priv->action_connect, (ref_type != GIGOLO_WINDOW_REF_TYPE_MOUNT));
 		gtk_action_set_sensitive(priv->action_disconnect, (ref_type == GIGOLO_WINDOW_REF_TYPE_MOUNT));
-		gtk_action_set_sensitive(priv->action_bookmark_create, ! is_bookmark);
+		update_create_edit_bookmark_action_label(priv->action_bookmark_create, is_bookmark);
 		gtk_action_set_sensitive(priv->action_open, gigolo_settings_has_file_manager(priv->settings));
 		gtk_action_set_sensitive(priv->action_copyuri, (ref_type == GIGOLO_WINDOW_REF_TYPE_MOUNT));
 	}
@@ -871,16 +881,17 @@ static void action_create_bookmark_cb(G_GNUC_UNUSED GtkAction *button, GigoloWin
 		if (gigolo_backend_gvfs_is_mount(mnt))
 		{
 			gchar *uri, *name;
+			GigoloBookmark *bm;
+			GtkWidget *edit_dialog;
 
 			gigolo_backend_gvfs_get_name_and_uri_from_mount(mnt, &name, &uri);
 
-			if (gigolo_settings_get_bookmark_by_uri(priv->settings, uri) == NULL)
+			bm = gigolo_settings_get_bookmark_by_uri(priv->settings, uri);
+			if (bm == NULL)
 			{
-				GigoloBookmark *bm = gigolo_bookmark_new_from_uri(name, uri);
+				bm = gigolo_bookmark_new_from_uri(name, uri);
 				if (gigolo_bookmark_is_valid(bm))
 				{
-					GtkWidget *edit_dialog;
-
 					/* show the bookmark edit dialog and add the bookmark only if it was
 					 * not cancelled */
 					edit_dialog = gigolo_bookmark_edit_dialog_new_with_bookmark(
@@ -901,8 +912,21 @@ static void action_create_bookmark_cb(G_GNUC_UNUSED GtkAction *button, GigoloWin
 				g_object_unref(bm);
 			}
 			else
-				verbose("Bookmark for %s already exists", uri);
+			{
+				/* bookmark exists */
+				edit_dialog = gigolo_bookmark_edit_dialog_new_with_bookmark(
+					window, GIGOLO_BE_MODE_EDIT, bm);
+				if (gigolo_bookmark_edit_dialog_run(
+						GIGOLO_BOOKMARK_EDIT_DIALOG(edit_dialog)) == GTK_RESPONSE_OK)
+				{
+					/* this fills the values of the dialog into 'bm' */
+					g_object_set(edit_dialog, "bookmark-update", bm, NULL);
 
+					gigolo_window_update_bookmarks(window);
+					gigolo_settings_write(priv->settings, GIGOLO_SETTINGS_BOOKMARKS);
+				}
+				gtk_widget_destroy(edit_dialog);
+			}
 			g_free(uri);
 			g_free(name);
 		}



More information about the Xfce4-commits mailing list