Commit ebb5465c authored by Hans Breuer's avatar Hans Breuer Committed by Hans Breuer

adapt to add -> insert_bookmark change. Also merged some crossplatform

2004-02-28  Hans Breuer  <hans@breuer.org>

	* gtk/gtkfilesystemwin32.c : adapt to add -> insert_bookmark
	change. Also merged some crossplatform code from
	gtkfilesystemunix.c
	* gtk/gtk.def : updated externals

	* gtk/makefile.msc.in : added gtkfilechooserembed.obj
parent 75aa148d
2004-02-28 Hans Breuer <hans@breuer.org>
* gtk/gtkfilesystemwin32.c : adapt to add -> insert_bookmark
change. Also merged some crossplatform code from
gtkfilesystemunix.c
* gtk/gtk.def : updated externals
* gtk/makefile.msc.in : added gtkfilechooserembed.obj
2004-02-28 Hans Breuer <hans@breuer.org>
* gdk/win32/gdkdnd-win32.c : set current_dest_drag to NULL
......
2004-02-28 Hans Breuer <hans@breuer.org>
* gtk/gtkfilesystemwin32.c : adapt to add -> insert_bookmark
change. Also merged some crossplatform code from
gtkfilesystemunix.c
* gtk/gtk.def : updated externals
* gtk/makefile.msc.in : added gtkfilechooserembed.obj
2004-02-28 Hans Breuer <hans@breuer.org>
* gdk/win32/gdkdnd-win32.c : set current_dest_drag to NULL
......
2004-02-28 Hans Breuer <hans@breuer.org>
* gtk/gtkfilesystemwin32.c : adapt to add -> insert_bookmark
change. Also merged some crossplatform code from
gtkfilesystemunix.c
* gtk/gtk.def : updated externals
* gtk/makefile.msc.in : added gtkfilechooserembed.obj
2004-02-28 Hans Breuer <hans@breuer.org>
* gdk/win32/gdkdnd-win32.c : set current_dest_drag to NULL
......
2004-02-28 Hans Breuer <hans@breuer.org>
* gtk/gtkfilesystemwin32.c : adapt to add -> insert_bookmark
change. Also merged some crossplatform code from
gtkfilesystemunix.c
* gtk/gtk.def : updated externals
* gtk/makefile.msc.in : added gtkfilechooserembed.obj
2004-02-28 Hans Breuer <hans@breuer.org>
* gdk/win32/gdkdnd-win32.c : set current_dest_drag to NULL
......
2004-02-28 Hans Breuer <hans@breuer.org>
* gtk/gtkfilesystemwin32.c : adapt to add -> insert_bookmark
change. Also merged some crossplatform code from
gtkfilesystemunix.c
* gtk/gtk.def : updated externals
* gtk/makefile.msc.in : added gtkfilechooserembed.obj
2004-02-28 Hans Breuer <hans@breuer.org>
* gdk/win32/gdkdnd-win32.c : set current_dest_drag to NULL
......
......@@ -690,7 +690,6 @@ EXPORTS
gtk_file_chooser_get_filename
gtk_file_chooser_get_filenames
gtk_file_chooser_get_filter
gtk_file_chooser_get_folder_mode
gtk_file_chooser_get_local_only
gtk_file_chooser_get_preview_filename
gtk_file_chooser_get_preview_uri
......@@ -716,7 +715,6 @@ EXPORTS
gtk_file_chooser_set_extra_widget
gtk_file_chooser_set_filename
gtk_file_chooser_set_filter
gtk_file_chooser_set_folder_mode
gtk_file_chooser_set_local_only
gtk_file_chooser_set_preview_widget
gtk_file_chooser_set_preview_widget_active
......@@ -773,13 +771,13 @@ EXPORTS
gtk_file_selection_set_filename
gtk_file_selection_set_select_multiple
gtk_file_selection_show_fileop_buttons
gtk_file_system_add_bookmark
gtk_file_system_error_quark
gtk_file_system_filename_to_path
gtk_file_system_get_folder
gtk_file_system_get_parent
gtk_file_system_get_type
gtk_file_system_get_volume_for_path
gtk_file_system_insert_bookmark
gtk_file_system_list_bookmarks
gtk_file_system_list_volumes
gtk_file_system_make_path
......
......@@ -145,8 +145,9 @@ static GdkPixbuf *gtk_file_system_win32_render_icon (GtkFileSystem *file_sys
gint pixel_size,
GError **error);
static gboolean gtk_file_system_win32_add_bookmark (GtkFileSystem *file_system,
static gboolean gtk_file_system_win32_insert_bookmark (GtkFileSystem *file_system,
const GtkFilePath *path,
gint position,
GError **error);
static gboolean gtk_file_system_win32_remove_bookmark (GtkFileSystem *file_system,
const GtkFilePath *path,
......@@ -266,7 +267,7 @@ gtk_file_system_win32_iface_init (GtkFileSystemIface *iface)
iface->uri_to_path = gtk_file_system_win32_uri_to_path;
iface->filename_to_path = gtk_file_system_win32_filename_to_path;
iface->render_icon = gtk_file_system_win32_render_icon;
iface->add_bookmark = gtk_file_system_win32_add_bookmark;
iface->insert_bookmark = gtk_file_system_win32_insert_bookmark;
iface->remove_bookmark = gtk_file_system_win32_remove_bookmark;
iface->list_bookmarks = gtk_file_system_win32_list_bookmarks;
}
......@@ -507,14 +508,15 @@ gtk_file_system_win32_make_path (GtkFileSystem *file_system,
const gchar *display_name,
GError **error)
{
gchar *base_filename;
const char *base_filename;
gchar *filename;
gchar *full_filename;
GError *tmp_error = NULL;
GtkFilePath *result;
base_filename = filename_from_path (base_path);
base_filename = gtk_file_path_get_string (base_path);
g_return_val_if_fail (base_filename != NULL, NULL);
g_return_val_if_fail (g_path_is_absolute (base_filename), NULL);
filename = g_filename_from_utf8 (display_name, -1, NULL, NULL, &tmp_error);
if (!filename)
......@@ -526,14 +528,12 @@ gtk_file_system_win32_make_path (GtkFileSystem *file_system,
tmp_error->message);
g_error_free (tmp_error);
g_free (base_filename);
return NULL;
}
full_filename = g_build_filename (base_filename, filename, NULL);
result = filename_to_path (full_filename);
g_free (base_filename);
g_free (filename);
g_free (full_filename);
......@@ -621,12 +621,13 @@ gtk_file_system_win32_parse (GtkFileSystem *file_system,
gchar **file_part,
GError **error)
{
char *base_filename;
const char *base_filename;
gchar *last_slash;
gboolean result = FALSE;
base_filename = filename_from_path (base_path);
base_filename = gtk_file_path_get_string (base_path);
g_return_val_if_fail (base_filename != NULL, FALSE);
g_return_val_if_fail (g_path_is_absolute (base_filename), FALSE);
last_slash = strrchr (str, G_DIR_SEPARATOR);
if (!last_slash)
......@@ -677,8 +678,6 @@ gtk_file_system_win32_parse (GtkFileSystem *file_system,
}
}
g_free (base_filename);
return result;
}
......@@ -718,7 +717,8 @@ static gboolean
bookmarks_serialize (GSList **bookmarks,
gchar *uri,
gboolean add,
GError **error)
gint position,
GError **error)
{
gchar *filename;
gboolean ok = TRUE;
......@@ -752,21 +752,36 @@ bookmarks_serialize (GSList **bookmarks,
}
if (ok && (f = fopen (filename, "wb")) != NULL)
{
if (add)
{
/* g_slist_insert() and our insert semantics are
* compatible, but maybe we should check for
* positon > length ?
*
*/
if (!g_slist_find_custom (list, uri, strcmp))
list = g_slist_insert (list, g_strdup (uri), position);
else
{
g_set_error (error,
GTK_FILE_SYSTEM_ERROR,
GTK_FILE_SYSTEM_ERROR_ALREADY_EXISTS,
"%s already exists in the bookmarks list",
uri);
ok = FALSE;
}
}
for (entry = list; entry != NULL; entry = entry->next)
{
gchar *line = entry->data;
if (strcmp (line, uri) != 0)
/* to remove the given uri */
if (!add && strcmp (line, uri) != 0)
{
fputs (line, f);
fputs ("\n", f);
}
}
if (add)
{
fputs (uri, f);
fputs ("\n", f);
}
fclose (f);
}
else if (ok && error)
......@@ -947,12 +962,15 @@ gtk_file_system_win32_render_icon (GtkFileSystem *file_system,
static GSList *_bookmarks = NULL;
static gboolean
gtk_file_system_win32_add_bookmark (GtkFileSystem *file_system,
gtk_file_system_win32_insert_bookmark (GtkFileSystem *file_system,
const GtkFilePath *path,
gint position,
GError **error)
{
gchar *uri = gtk_file_system_win32_path_to_uri (file_system, path);
gboolean ret = bookmarks_serialize (&_bookmarks, uri, TRUE, error);
gboolean ret = bookmarks_serialize (&_bookmarks, uri, TRUE, position, error);
if (ret)
g_signal_emit_by_name (file_system, "bookmarks-changed", 0);
g_free (uri);
return ret;
......@@ -964,7 +982,9 @@ gtk_file_system_win32_remove_bookmark (GtkFileSystem *file_system,
GError **error)
{
gchar *uri = gtk_file_system_win32_path_to_uri (file_system, path);
gboolean ret = bookmarks_serialize (&_bookmarks, uri, FALSE, error);
gboolean ret = bookmarks_serialize (&_bookmarks, uri, FALSE, 0, error);
if (ret)
g_signal_emit_by_name (file_system, "bookmarks-changed", 0);
g_free (uri);
return ret;
}
......@@ -976,7 +996,7 @@ gtk_file_system_win32_list_bookmarks (GtkFileSystem *file_system)
GSList *entry;
if (bookmarks_serialize (&_bookmarks, "", FALSE, NULL))
if (bookmarks_serialize (&_bookmarks, "", FALSE, 0, NULL))
{
for (entry = _bookmarks; entry != NULL; entry = entry->next)
{
......
......@@ -104,6 +104,7 @@ gtk_OBJECTS = \
gtkfilechooser.obj \
gtkfilechooserdefault.obj \
gtkfilechooserdialog.obj \
gtkfilechooserembed.obj \
gtkfilechooserentry.obj \
gtkfilechooserutils.obj \
gtkfilechooserwidget.obj \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment