Add ALREADY_EXISTS error code. Return an error code when the shortcut

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)
This commit is contained in:
Tommi Komulainen 2005-10-10 14:29:03 +00:00 committed by Tommi Komulainen
parent 080fc7ecef
commit 8ad0abb867
4 changed files with 35 additions and 1 deletions

View 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

View 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

View 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);

View 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);