[Goodies-commits] r6381 - in sion/trunk: . src
Enrico Troeger
enrico at xfce.org
Mon Dec 29 19:15:54 CET 2008
Author: enrico
Date: 2008-12-29 18:15:54 +0000 (Mon, 29 Dec 2008)
New Revision: 6381
Modified:
sion/trunk/ChangeLog
sion/trunk/TODO
sion/trunk/src/bookmark.c
sion/trunk/src/common.c
sion/trunk/src/common.h
sion/trunk/src/window.c
Log:
Don't add the port number to URIs when it is the default port number.
Fix 'Create Bookmark' sensitiveness.
When using 'Create Bookmark' show a dialog to edit the new bookmark before saving it.
Modified: sion/trunk/ChangeLog
===================================================================
--- sion/trunk/ChangeLog 2008-12-29 18:15:28 UTC (rev 6380)
+++ sion/trunk/ChangeLog 2008-12-29 18:15:54 UTC (rev 6381)
@@ -1,3 +1,12 @@
+2008-12-29 Enrico Tröger <enrico(at)xfce(dot)org>
+
+ * src/common.c, src/common.h, src/bookmark.c, src/window.c:
+ Don't add the port number to URIs when it is the default port number.
+ Fix 'Create Bookmark' sensitiveness.
+ When using 'Create Bookmark' show a dialog to edit the new bookmark
+ before saving it.
+
+
2008-12-28 Enrico Tröger <enrico(at)xfce(dot)org>
* wscript, Makefile.am:
Modified: sion/trunk/TODO
===================================================================
--- sion/trunk/TODO 2008-12-29 18:15:28 UTC (rev 6380)
+++ sion/trunk/TODO 2008-12-29 18:15:54 UTC (rev 6381)
@@ -2,4 +2,3 @@
- libnotify - to notify about new mounts or disappeared mounts (ftp timeout, etc.)
- progressdialog when mounting
- allow usernames which include a '@' char
-- Fix 'Create Bookmark'
Modified: sion/trunk/src/bookmark.c
===================================================================
--- sion/trunk/src/bookmark.c 2008-12-29 18:15:28 UTC (rev 6380)
+++ sion/trunk/src/bookmark.c 2008-12-29 18:15:54 UTC (rev 6381)
@@ -288,7 +288,7 @@
g_return_val_if_fail(bookmark != NULL, NULL);
- if (priv->port > 0)
+ if (priv->port > 0 && priv->port != sion_get_default_port(priv->scheme))
{
port = g_strdup_printf(":%d", priv->port);
}
Modified: sion/trunk/src/common.c
===================================================================
--- sion/trunk/src/common.c 2008-12-29 18:15:28 UTC (rev 6380)
+++ sion/trunk/src/common.c 2008-12-29 18:15:54 UTC (rev 6381)
@@ -82,6 +82,21 @@
}
+guint sion_get_default_port(const gchar *scheme)
+{
+ if (sion_str_equal(scheme, "ftp"))
+ return 21;
+ else if (sion_str_equal(scheme, "sftp"))
+ return 22;
+ else if (sion_str_equal(scheme, "dav"))
+ return 80;
+ else if (sion_str_equal(scheme, "davs"))
+ return 443;
+
+ return 0;
+}
+
+
/* Are we running in Xfce? */
gboolean sion_is_desktop_xfce(void)
{
Modified: sion/trunk/src/common.h
===================================================================
--- sion/trunk/src/common.h 2008-12-29 18:15:28 UTC (rev 6380)
+++ sion/trunk/src/common.h 2008-12-29 18:15:54 UTC (rev 6381)
@@ -58,5 +58,6 @@
void sion_show_uri(const gchar *uri);
+guint sion_get_default_port(const gchar *scheme);
#endif /* __COMMON_H__ */
Modified: sion/trunk/src/window.c
===================================================================
--- sion/trunk/src/window.c 2008-12-29 18:15:28 UTC (rev 6380)
+++ sion/trunk/src/window.c 2008-12-29 18:15:54 UTC (rev 6381)
@@ -493,14 +493,13 @@
sion_backend_gvfs_get_name_and_uri_from_mount(ref, NULL, &uri);
- for (i = 0; i < bml->len; i++)
+ for (i = 0; i < bml->len && ! found; i++)
{
bm = g_ptr_array_index(bml, i);
tmp_uri = sion_bookmark_get_uri(bm);
- if (uri != NULL && tmp_uri != NULL && strcmp(uri, tmp_uri) == 0)
- {
+ if (sion_str_equal(uri, tmp_uri))
found = TRUE;
- }
+
g_free(tmp_uri);
}
g_free(uri);
@@ -525,7 +524,7 @@
//~ gtk_action_set_sensitive(priv->action_connect, (ref_type != SION_WINDOW_REF_TYPE_MOUNT));
//~ gtk_action_set_sensitive(priv->action_bookmarks_toolbar, (ref_type != SION_WINDOW_REF_TYPE_MOUNT));
gtk_action_set_sensitive(priv->action_disconnect, (ref_type == SION_WINDOW_REF_TYPE_MOUNT));
- gtk_action_set_sensitive(priv->action_bookmark_create, (ref_type == SION_WINDOW_REF_TYPE_MOUNT));
+ gtk_action_set_sensitive(priv->action_bookmark_create, ! is_bookmark);
gtk_action_set_sensitive(priv->action_open, sion_settings_has_file_manager(priv->settings));
}
else
@@ -729,21 +728,50 @@
gtk_tree_model_get(model, &iter, SION_WINDOW_COL_REF, &mnt, -1);
if (sion_backend_gvfs_is_mount(mnt))
{
- gchar *uri;
- gchar *name;
+ gchar *uri, *tmp_uri, *name;
+ guint i;
+ gboolean found = FALSE;
SionBookmark *bm;
+ SionBookmarkList *bml = sion_settings_get_bookmarks(priv->settings);
sion_backend_gvfs_get_name_and_uri_from_mount(mnt, &name, &uri);
- bm = sion_bookmark_new_from_uri(name, uri);
- if (sion_bookmark_is_valid(bm))
+ // check whether the current mount is already a bookmark ...
+ for (i = 0; i < bml->len && ! found; i++)
{
- g_ptr_array_add(sion_settings_get_bookmarks(priv->settings), bm);
- sion_window_update_bookmarks(window);
+ bm = g_ptr_array_index(bml, i);
+ tmp_uri = sion_bookmark_get_uri(bm);
+ if (sion_str_equal(uri, tmp_uri))
+ found = TRUE;
- /** TODO show message dialog */
+ g_free(tmp_uri);
}
+ // ... and add it if not
+ if (! found)
+ {
+ bm = sion_bookmark_new_from_uri(name, uri);
+ if (sion_bookmark_is_valid(bm))
+ {
+ GtkWidget *edit_dialog;
+
+ // show the bookmark edit dialog and add the bookmark only if it was
+ // not cancelled
+ edit_dialog = sion_bookmark_edit_dialog_new_with_bookmark(
+ GTK_WIDGET(window), SION_BE_MODE_EDIT, bm);
+ if (gtk_dialog_run(GTK_DIALOG(edit_dialog)) == GTK_RESPONSE_OK)
+ {
+ // this fills the values of the dialog into 'bm'
+ g_object_set(edit_dialog, "bookmark-update", bm, NULL);
+
+ g_ptr_array_add(sion_settings_get_bookmarks(priv->settings),
+ g_object_ref(bm));
+ sion_window_update_bookmarks(window);
+ }
+ gtk_widget_destroy(edit_dialog);
+ }
+ g_object_unref(bm);
+ }
else
- g_object_unref(bm);
+ verbose("Bookmark for %s already exists", uri);
g_free(uri);
g_free(name);
More information about the Goodies-commits
mailing list