[gtksourceview/gnome-3-10] Completion: do not show "All" when only one provider



commit 21e07b8952cc217f673a937c85e09ea084a99115
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun Oct 6 15:00:06 2013 +0200

    Completion: do not show "All" when only one provider
    
    In the bottom bar of the completion window, at the right of the Details
    button, there is an icon and a label to show on which provider we are.
    When there is only one provider, all the proposals are shown. Displaying
    the "All" label in this case is useless, and users don't know what it
    means. So it's better to display nothing in this case.

 gtksourceview/gtksourcecompletion.c |   29 ++++++++++++++++-------------
 1 files changed, 16 insertions(+), 13 deletions(-)
---
diff --git a/gtksourceview/gtksourcecompletion.c b/gtksourceview/gtksourcecompletion.c
index 9257f3d..326aae9 100644
--- a/gtksourceview/gtksourcecompletion.c
+++ b/gtksourceview/gtksourcecompletion.c
@@ -742,10 +742,21 @@ update_selection_label (GtkSourceCompletion *completion)
        guint pos;
        guint num;
        gchar *name;
-       GtkSourceCompletionProvider *visible = get_visible_provider (completion);
+       gchar *selection_text;
+       GtkSourceCompletionProvider *visible;
 
        get_num_visible_providers (completion, &num, &pos);
 
+       if (num <= 1)
+       {
+               /* At most one provider. All the proposals are shown. */
+               gtk_image_clear (completion->priv->selection_image);
+               gtk_widget_hide (GTK_WIDGET (completion->priv->selection_label));
+               return;
+       }
+
+       visible = get_visible_provider (completion);
+
        if (visible == NULL)
        {
                /* Translators: "All" is used as a label in the status bar of the
@@ -764,19 +775,11 @@ update_selection_label (GtkSourceCompletion *completion)
                                           gtk_source_completion_provider_get_icon (visible));
        }
 
-       if (num > 1)
-       {
-               gchar *tmp = g_strdup_printf ("<small>%s (%d/%d)</small>", name, pos + 1, num + 1);
-               gtk_label_set_markup (completion->priv->selection_label, tmp);
-               g_free (tmp);
-       }
-       else
-       {
-               gchar *tmp = g_strdup_printf ("<small>%s</small>", name);
-               gtk_label_set_markup (completion->priv->selection_label, tmp);
-               g_free (tmp);
-       }
+       selection_text = g_strdup_printf ("<small>%s (%d/%d)</small>", name, pos + 1, num + 1);
+       gtk_label_set_markup (completion->priv->selection_label, selection_text);
+       gtk_widget_show (GTK_WIDGET (completion->priv->selection_label));
 
+       g_free (selection_text);
        g_free (name);
 }
 


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