Stubs for all cases of completion feedback

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

svn path=/trunk/; revision=19836
This commit is contained in:
Federico Mena Quintero 2008-03-13 00:41:17 +00:00 committed by Federico Mena Quintero
parent 806cca3c9c
commit e5f8a4693e

View File

@ -437,6 +437,7 @@ static gboolean
find_common_prefix (GtkFileChooserEntry *chooser_entry, find_common_prefix (GtkFileChooserEntry *chooser_entry,
gchar **common_prefix_ret, gchar **common_prefix_ret,
GtkFilePath **unique_path_ret, GtkFilePath **unique_path_ret,
gboolean *is_complete_not_unique_ret,
GError **error) GError **error)
{ {
GtkEditable *editable; GtkEditable *editable;
@ -449,9 +450,7 @@ find_common_prefix (GtkFileChooserEntry *chooser_entry,
*common_prefix_ret = NULL; *common_prefix_ret = NULL;
*unique_path_ret = NULL; *unique_path_ret = NULL;
*is_complete_not_unique_ret = FALSE;
if (chooser_entry->completion_store == NULL)
return;
editable = GTK_EDITABLE (chooser_entry); editable = GTK_EDITABLE (chooser_entry);
@ -509,6 +508,9 @@ find_common_prefix (GtkFileChooserEntry *chooser_entry,
q++; q++;
} }
if (*p == '\0' || *q == '\0')
*is_complete_not_unique_ret = TRUE;
*p = '\0'; *p = '\0';
gtk_file_path_free (*unique_path_ret); gtk_file_path_free (*unique_path_ret);
@ -543,14 +545,18 @@ append_common_prefix (GtkFileChooserEntry *chooser_entry,
{ {
gchar *common_prefix; gchar *common_prefix;
GtkFilePath *unique_path; GtkFilePath *unique_path;
gboolean is_complete_not_unique;
GError *error; GError *error;
CommonPrefixResult result; CommonPrefixResult result;
gboolean have_result; gboolean have_result;
clear_completions (chooser_entry); clear_completions (chooser_entry);
if (chooser_entry->completion_store == NULL)
return NO_MATCH;
error = NULL; 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) if (show_errors)
{ {
@ -573,7 +579,7 @@ append_common_prefix (GtkFileChooserEntry *chooser_entry,
gtk_file_path_free (unique_path); gtk_file_path_free (unique_path);
if (common_prefix) if (common_prefix)
result = UNIQUE_PREFIX_APPENDED; result = COMPLETED_UNIQUE;
else else
result = INVALID_INPUT; result = INVALID_INPUT;
@ -581,10 +587,11 @@ append_common_prefix (GtkFileChooserEntry *chooser_entry,
} }
else else
{ {
/* FIXME: if there was no unique_path, but there was a common_prefix, if (is_complete_not_unique)
* 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. result = COMPLETE_BUT_NOT_UNIQUE;
*/ have_result = TRUE;
}
} }
printf ("common prefix: \"%s\"\n", printf ("common prefix: \"%s\"\n",
@ -627,14 +634,14 @@ append_common_prefix (GtkFileChooserEntry *chooser_entry,
if (have_result) if (have_result)
return result; return result;
else else
return PREFIX_APPENDED; return COMPLETED;
} }
else else
{ {
if (have_result) if (have_result)
return result; return result;
else else
return NO_COMMON_PREFIX; return NO_MATCH;
} }
} }
@ -713,6 +720,14 @@ gtk_file_chooser_entry_grab_focus (GtkWidget *widget)
_gtk_file_chooser_entry_select_filename (GTK_FILE_CHOOSER_ENTRY (widget)); _gtk_file_chooser_entry_select_filename (GTK_FILE_CHOOSER_ENTRY (widget));
} }
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 static void
explicitly_complete (GtkFileChooserEntry *chooser_entry) explicitly_complete (GtkFileChooserEntry *chooser_entry)
{ {
@ -732,18 +747,25 @@ explicitly_complete (GtkFileChooserEntry *chooser_entry)
switch (result) switch (result)
{ {
case PREFIX_APPENDED:
break;
case UNIQUE_PREFIX_APPENDED:
break;
case INVALID_INPUT: case INVALID_INPUT:
/* We already beeped in append_common_prefix(); do nothing here */
break; break;
case NO_COMMON_PREFIX: case NO_MATCH:
pop_up_completion_feedback (chooser_entry, _("No match"));
break;
case COMPLETED:
/* Nothing to do */
break;
case COMPLETED_UNIQUE:
/* Nothing to do */
break;
case COMPLETE_BUT_NOT_UNIQUE:
/* FIXME: pop up the suggestion window */ /* 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; break;
default: default: