gtk+ r22184 - in trunk: . gtk
- From: federico svn gnome org
- To: svn-commits-list gnome org
- Subject: gtk+ r22184 - in trunk: . gtk
- Date: Fri, 23 Jan 2009 00:55:07 +0000 (UTC)
Author: federico
Date: Fri Jan 23 00:55:07 2009
New Revision: 22184
URL: http://svn.gnome.org/viewvc/gtk+?rev=22184&view=rev
Log:
GtkFileChooserEntry: fix the computation of 'complete but not unique' and appending a '/' to unique directory names
2009-01-22 Federico Mena Quintero <federico novell com>
Fix the computation of "complete but unique" in
GtkFileChooserEntry. Fix the case where "/" was not appended to a
unique directory name during explicit Tab completion.
* gtk/gtkfilechooserentry.c (maybe_append_separator_to_file):
Return whether anything was appended as well as the new string
itself.
(find_common_prefix): Oops, only turn on
is_complete_not_unique_ret if we had a unique match!
(append_common_prefix): If we appended a directory separator, we
*did* expand the common prefix, so we are not in the "nothing
inserted" case.
Signed-off-by: Federico Mena Quintero <federico novell com>
Modified:
trunk/ChangeLog
trunk/gtk/gtkfilechooserentry.c
Modified: trunk/gtk/gtkfilechooserentry.c
==============================================================================
--- trunk/gtk/gtkfilechooserentry.c (original)
+++ trunk/gtk/gtkfilechooserentry.c Fri Jan 23 00:55:07 2009
@@ -146,7 +146,8 @@
gpointer data);
static char *maybe_append_separator_to_file (GtkFileChooserEntry *chooser_entry,
GFile *file,
- gchar *display_name);
+ gchar *display_name,
+ gboolean *appended);
typedef enum {
REFRESH_UP_TO_CURSOR_POSITION,
@@ -324,6 +325,7 @@
char *display_name;
GFile *file;
gint pos;
+ gboolean dummy;
gtk_tree_model_get (model, iter,
DISPLAY_NAME_COLUMN, &display_name,
@@ -338,7 +340,7 @@
return FALSE;
}
- display_name = maybe_append_separator_to_file (chooser_entry, file, display_name);
+ display_name = maybe_append_separator_to_file (chooser_entry, file, display_name, &dummy);
pos = chooser_entry->file_part_pos;
@@ -450,15 +452,18 @@
* return a new one if needed. Otherwise, it will return the old one.
* You should be safe calling
*
- * display_name = maybe_append_separator_to_file (entry, file, display_name);
+ * display_name = maybe_append_separator_to_file (entry, file, display_name, &appended);
* ...
* g_free (display_name);
*/
static char *
maybe_append_separator_to_file (GtkFileChooserEntry *chooser_entry,
GFile *file,
- gchar *display_name)
+ gchar *display_name,
+ gboolean *appended)
{
+ *appended = FALSE;
+
if (!g_str_has_suffix (display_name, G_DIR_SEPARATOR_S) && file)
{
GFileInfo *info;
@@ -471,6 +476,7 @@
{
gchar *tmp = display_name;
display_name = g_strconcat (tmp, G_DIR_SEPARATOR_S, NULL);
+ *appended = TRUE;
g_free (tmp);
}
@@ -609,7 +615,7 @@
if (G_IS_DIR_SEPARATOR (display_name[len - 1]))
len--;
- if (strncmp (*common_prefix_ret, display_name, len) == 0)
+ if (*unique_file_ret == NULL && strncmp (*common_prefix_ret, display_name, len) == 0)
*is_complete_not_unique_ret = TRUE;
g_free (display_name);
@@ -702,21 +708,23 @@
if (unique_file)
{
if (!char_after_cursor_is_directory_separator (chooser_entry))
- common_prefix = maybe_append_separator_to_file (chooser_entry,
- unique_file,
- common_prefix);
+ {
+ gboolean appended;
+
+ common_prefix = maybe_append_separator_to_file (chooser_entry,
+ unique_file,
+ common_prefix,
+ &appended);
+ if (appended)
+ prefix_expands_the_file_part = TRUE;
+ }
g_object_unref (unique_file);
- if (common_prefix)
- {
- if (prefix_expands_the_file_part)
- result = COMPLETED_UNIQUE;
- else
- result = NOTHING_INSERTED_UNIQUE;
- }
+ if (prefix_expands_the_file_part)
+ result = COMPLETED_UNIQUE;
else
- result = INVALID_INPUT;
+ result = NOTHING_INSERTED_UNIQUE;
have_result = TRUE;
}
@@ -1322,8 +1330,9 @@
{
gchar *display_name = g_strdup (g_file_info_get_display_name (info));
GtkTreeIter iter;
+ gboolean dummy;
- display_name = maybe_append_separator_to_file (chooser_entry, file, display_name);
+ display_name = maybe_append_separator_to_file (chooser_entry, file, display_name, &dummy);
gtk_list_store_append (chooser_entry->completion_store, &iter);
gtk_list_store_set (chooser_entry->completion_store, &iter,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]