From: Tor Lillqvist Date: Sat, 31 Aug 2002 17:33:43 +0000 (+0000) Subject: Use cygwin_conv_to_posix_path(). (gtk_file_selection_dir_activate): Call X-Git-Url: http://pileus.org/git/?a=commitdiff_plain;h=732c20523692251af6875a34b5a0fe62a5dfc9b8;p=~andy%2Fgtk Use cygwin_conv_to_posix_path(). (gtk_file_selection_dir_activate): Call 2002-08-31 Tor Lillqvist * Include + + * Include * gdk/win32/gdkwindow-win32.c (RegisterGdkClass): Use MAX_PATH diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 2893b28d2..1f628a6e3 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,11 @@ +2002-08-31 Tor Lillqvist + + * Include * gdk/win32/gdkwindow-win32.c (RegisterGdkClass): Use MAX_PATH diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 2893b28d2..1f628a6e3 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,11 @@ +2002-08-31 Tor Lillqvist + + * Include * gdk/win32/gdkwindow-win32.c (RegisterGdkClass): Use MAX_PATH diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 2893b28d2..1f628a6e3 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,11 @@ +2002-08-31 Tor Lillqvist + + * Include * gdk/win32/gdkwindow-win32.c (RegisterGdkClass): Use MAX_PATH diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 2893b28d2..1f628a6e3 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,11 @@ +2002-08-31 Tor Lillqvist + + * Include * gdk/win32/gdkwindow-win32.c (RegisterGdkClass): Use MAX_PATH diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 2893b28d2..1f628a6e3 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,11 @@ +2002-08-31 Tor Lillqvist + + * Include * gdk/win32/gdkwindow-win32.c (RegisterGdkClass): Use MAX_PATH diff --git a/gtk/gtkfilesel.c b/gtk/gtkfilesel.c index 2b060c606..f8be98bf6 100644 --- a/gtk/gtkfilesel.c +++ b/gtk/gtkfilesel.c @@ -94,6 +94,10 @@ #endif #endif /* G_OS_WIN32 */ +#ifdef G_WITH_CYGWIN +#include /* For cygwin_conv_to_posix_path */ +#endif + #define DIR_LIST_WIDTH 180 #define DIR_LIST_HEIGHT 180 #define FILE_LIST_WIDTH 180 @@ -433,7 +437,7 @@ static gint cmpl_errno; * instance translate: * x:\somepath\file.jpg * to: - * //x/somepath/file.jpg + * /cygdrive/x/somepath/file.jpg * * Replace the path in the selection text field. * Return a boolean value concerning whether a @@ -443,46 +447,19 @@ static int translate_win32_path (GtkFileSelection *filesel) { int updated = 0; - gchar *path; + const gchar *path; + gchar newPath[MAX_PATH]; /* * Retrieve the current path */ path = gtk_entry_get_text (GTK_ENTRY (filesel->selection_entry)); - /* - * Translate only if this looks like a DOS-ish - * path... First handle any drive letters. - */ - if (isalpha (path[0]) && (path[1] == ':')) { - /* - * This part kind of stinks... It isn't possible - * to know if there is enough space in the current - * string for the extra character required in this - * conversion. Assume that there isn't enough space - * and use the set function on the text field to - * set the newly created string. - */ - gchar *newPath = g_strdup_printf ("//%c/%s", path[0], (path + 3)); - gtk_entry_set_text (GTK_ENTRY (filesel->selection_entry), newPath); - - path = newPath; - updated = 1; - } + cygwin_conv_to_posix_path (path, newPath); + updated = (strcmp (path, newPath) != 0); - /* - * Now, replace backslashes with forward slashes - * if necessary. - */ - if (strchr (path, '\\')) - { - int index; - for (index = 0; path[index] != '\0'; index++) - if (path[index] == '\\') - path[index] = '/'; - - updated = 1; - } + if (updated) + gtk_entry_set_text (GTK_ENTRY (filesel->selection_entry), newPath); return updated; } @@ -1918,17 +1895,26 @@ get_real_filename (gchar *filename, /* Check to see if the selection was a drive selector */ if (isalpha (filename[0]) && (filename[1] == ':')) { - /* It is... map it to a CYGWIN32 drive */ - gchar *temp_filename = g_strdup_printf ("//%c/", tolower (filename[0])); + gchar temp_filename[MAX_PATH]; + int len; + cygwin_conv_to_posix_path (filename, temp_filename); + + /* we need trailing '/'. */ + len = strlen (temp_filename); + if (len > 0 && temp_filename[len-1] != '/') + { + temp_filename[len] = '/'; + temp_filename[len+1] = '\0'; + } + if (free_old) g_free (filename); - return temp_filename; + return g_strdup (temp_filename); } -#else - return filename; #endif /* G_WITH_CYGWIN */ + return filename; } static void @@ -1945,7 +1931,6 @@ gtk_file_selection_file_activate (GtkTreeView *tree_view, gtk_tree_model_get_iter (model, &iter, path); gtk_tree_model_get (model, &iter, FILE_COLUMN, &filename, -1); filename = get_real_filename (filename, TRUE); - gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), filename); gtk_button_clicked (GTK_BUTTON (fs->ok_button)); @@ -1965,6 +1950,7 @@ gtk_file_selection_dir_activate (GtkTreeView *tree_view, gtk_tree_model_get_iter (model, &iter, path); gtk_tree_model_get (model, &iter, DIR_COLUMN, &filename, -1); + filename = get_real_filename (filename, TRUE); gtk_file_selection_populate (fs, filename, FALSE, FALSE); g_free (filename); }