gtk+ r19836 - trunk/gtk



Author: federico
Date: Thu Mar 13 00:41:17 2008
New Revision: 19836
URL: http://svn.gnome.org/viewvc/gtk+?rev=19836&view=rev

Log:
Stubs for all cases of completion feedback

Signed-off-by: Federico Mena Quintero <federico gnu org>


Modified:
   trunk/gtk/gtkfilechooserentry.c

Modified: trunk/gtk/gtkfilechooserentry.c
==============================================================================
--- trunk/gtk/gtkfilechooserentry.c	(original)
+++ trunk/gtk/gtkfilechooserentry.c	Thu Mar 13 00:41:17 2008
@@ -437,6 +437,7 @@
 find_common_prefix (GtkFileChooserEntry *chooser_entry,
 		    gchar               **common_prefix_ret,
 		    GtkFilePath         **unique_path_ret,
+		    gboolean             *is_complete_not_unique_ret,
 		    GError              **error)
 {
   GtkEditable *editable;
@@ -449,9 +450,7 @@
 
   *common_prefix_ret = NULL;
   *unique_path_ret = NULL;
-
-  if (chooser_entry->completion_store == NULL)
-    return;
+  *is_complete_not_unique_ret = FALSE;
 
   editable = GTK_EDITABLE (chooser_entry);
 
@@ -508,7 +507,10 @@
 		  p++;
 		  q++;
 		}
-		  
+
+	      if (*p == '\0' || *q == '\0')
+		*is_complete_not_unique_ret = TRUE;
+
 	      *p = '\0';
 
 	      gtk_file_path_free (*unique_path_ret);
@@ -543,14 +545,18 @@
 {
   gchar *common_prefix;
   GtkFilePath *unique_path;
+  gboolean is_complete_not_unique;
   GError *error;
   CommonPrefixResult result;
   gboolean have_result;
 
   clear_completions (chooser_entry);
 
+  if (chooser_entry->completion_store == NULL)
+    return NO_MATCH;
+
   error = NULL;
-  if (!find_common_prefix (chooser_entry, &common_prefix, &unique_path, &error))
+  if (!find_common_prefix (chooser_entry, &common_prefix, &unique_path, &is_complete_not_unique, &error))
     {
       if (show_errors)
 	{
@@ -573,7 +579,7 @@
       gtk_file_path_free (unique_path);
 
       if (common_prefix)
-	result = UNIQUE_PREFIX_APPENDED;
+	result = COMPLETED_UNIQUE;
       else
 	result = INVALID_INPUT;
 
@@ -581,10 +587,11 @@
     }
   else
     {
-      /* FIXME:  if there was no unique_path, but there was a common_prefix,
-       * then we *may* have "complete but not unique".  find_common_prefix()
-       * needs to say if the match was a complete entry, or a partial one.
-       */
+      if (is_complete_not_unique)
+	{
+	  result = COMPLETE_BUT_NOT_UNIQUE;
+	  have_result = TRUE;
+	}
     }
 
   printf ("common prefix: \"%s\"\n",
@@ -627,14 +634,14 @@
       if (have_result)
 	return result;
       else
-	return PREFIX_APPENDED;
+	return COMPLETED;
     }
   else
     {
       if (have_result)
 	return result;
       else
-	return NO_COMMON_PREFIX;
+	return NO_MATCH;
     }
 }
 
@@ -714,6 +721,14 @@
 }
 
 static void
+pop_up_completion_feedback (GtkFileChooserEntry *chooser_entry,
+			    const gchar         *feedback)
+{
+  /* FIXME: use a popup window of some sort */
+  printf ("COMPLETION: %s\n", feedback);
+}
+
+static void
 explicitly_complete (GtkFileChooserEntry *chooser_entry)
 {
   CommonPrefixResult result;
@@ -732,18 +747,25 @@
 
   switch (result)
     {
-    case PREFIX_APPENDED:
+    case INVALID_INPUT:
+      /* We already beeped in append_common_prefix(); do nothing here */
       break;
 
-    case UNIQUE_PREFIX_APPENDED:
+    case NO_MATCH:
+      pop_up_completion_feedback (chooser_entry, _("No match"));
       break;
 
-    case INVALID_INPUT:
+    case COMPLETED:
+      /* Nothing to do */
+      break;
+
+    case COMPLETED_UNIQUE:
+      /* Nothing to do */
       break;
 
-    case NO_COMMON_PREFIX:
+    case COMPLETE_BUT_NOT_UNIQUE:
       /* FIXME: pop up the suggestion window */
-      /* FIXME: we need to distinguish between "no match" and "many matches" */
+      pop_up_completion_feedback (chooser_entry, _("Complete, but not unique"));
       break;
 
     default:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]