]> Pileus Git - ~andy/gtk/commitdiff
Add ALREADY_EXISTS error code. Return an error code when the shortcut
authorTommi Komulainen <tommi.komulainen@iki.fi>
Mon, 10 Oct 2005 14:29:03 +0000 (14:29 +0000)
committerTommi Komulainen <tko@src.gnome.org>
Mon, 10 Oct 2005 14:29:03 +0000 (14:29 +0000)
2005-10-10  Tommi Komulainen  <tommi.komulainen@iki.fi>

* gtk/gtkfilechooser.h (GtkFileChooserError): Add ALREADY_EXISTS error
code.
* gtk/gtkfilechooserdefault.c
(gtk_file_chooser_default_add_shortcut_folder): Return an error code
when the shortcut already exists in the sidebar.  (#147521)

ChangeLog
ChangeLog.pre-2-10
gtk/gtkfilechooser.h
gtk/gtkfilechooserdefault.c

index d6e42d5d40c5fbd0c446c7d1777d2dd92768b9da..f3d469d9cebade15350c76125d0b0c3e53cacb81 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2005-10-10  Tommi Komulainen  <tommi.komulainen@iki.fi>
+
+       * gtk/gtkfilechooser.h (GtkFileChooserError): Add ALREADY_EXISTS error
+       code.
+       * gtk/gtkfilechooserdefault.c
+       (gtk_file_chooser_default_add_shortcut_folder): Return an error code
+       when the shortcut already exists in the sidebar.  (#147521)
+
 2005-10-09  Matthias Clasen  <mclasen@redhat.com>
 
        * tests/testcombo.c: Demonstrate how to use custom widgets in
index d6e42d5d40c5fbd0c446c7d1777d2dd92768b9da..f3d469d9cebade15350c76125d0b0c3e53cacb81 100644 (file)
@@ -1,3 +1,11 @@
+2005-10-10  Tommi Komulainen  <tommi.komulainen@iki.fi>
+
+       * gtk/gtkfilechooser.h (GtkFileChooserError): Add ALREADY_EXISTS error
+       code.
+       * gtk/gtkfilechooserdefault.c
+       (gtk_file_chooser_default_add_shortcut_folder): Return an error code
+       when the shortcut already exists in the sidebar.  (#147521)
+
 2005-10-09  Matthias Clasen  <mclasen@redhat.com>
 
        * tests/testcombo.c: Demonstrate how to use custom widgets in
index 9148fa670be91dd0b1d9d60a65668b50dbbe2b0a..5b233878b3c33e8852012ae6195a62c5ef892fb1 100644 (file)
@@ -55,7 +55,8 @@ GType gtk_file_chooser_get_type (void) G_GNUC_CONST;
 
 typedef enum {
   GTK_FILE_CHOOSER_ERROR_NONEXISTENT,
-  GTK_FILE_CHOOSER_ERROR_BAD_FILENAME
+  GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
+  GTK_FILE_CHOOSER_ERROR_ALREADY_EXISTS
 } GtkFileChooserError;
 
 GQuark gtk_file_chooser_error_quark (void);
index 8ef9aaf3f6ceab84eb157e5ae6be2006ef1e29eb..dc1649462b677ab381ab61b30ddbd27659794d75 100644 (file)
@@ -5846,6 +5846,23 @@ gtk_file_chooser_default_add_shortcut_folder (GtkFileChooser    *chooser,
   if (!check_is_folder (impl->file_system, path, error))
     return FALSE;
 
+  /* Avoid adding duplicates */
+  pos = shortcut_find_position (impl, path);
+  if (pos >= 0 && pos < shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS_SEPARATOR))
+    {
+      gchar *uri;
+
+      uri = gtk_file_system_path_to_uri (impl->file_system, path);
+      g_set_error (error,
+                  GTK_FILE_CHOOSER_ERROR,
+                  GTK_FILE_CHOOSER_ERROR_ALREADY_EXISTS,
+                  _("shortcut %s already exists"),
+                  uri);
+      g_free (uri);
+
+      return FALSE;
+    }
+
   pos = shortcuts_get_pos_for_shortcut_folder (impl, impl->num_shortcuts);
 
   result = shortcuts_insert_path (impl, pos, FALSE, NULL, path, NULL, FALSE, error);