diff options
author | Matthias Clasen <mclasen@redhat.com> | 2014-02-13 00:14:42 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2014-02-13 00:14:42 -0500 |
commit | 6578c9d876b6a40003696f773acd801fbfa73921 (patch) | |
tree | c5a10fa2ec030119dcd4866284676d4229ffc393 /gtk/gtkappchooserwidget.c | |
parent | 3e02f52031c5101c1cf308fd2fea5f1c39ad25f9 (diff) | |
download | gtk+-6578c9d876b6a40003696f773acd801fbfa73921.tar.gz |
Modernize the app chooser dialog
This is according to suggestions in
https://bugzilla.gnome.org/show_bug.cgi?id=724218
Diffstat (limited to 'gtk/gtkappchooserwidget.c')
-rw-r--r-- | gtk/gtkappchooserwidget.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/gtk/gtkappchooserwidget.c b/gtk/gtkappchooserwidget.c index 213a8b25d6..652f934960 100644 --- a/gtk/gtkappchooserwidget.c +++ b/gtk/gtkappchooserwidget.c @@ -38,6 +38,7 @@ #include "gtktreemodelsort.h" #include "gtkorientable.h" #include "gtkscrolledwindow.h" +#include "gtklabel.h" #include <string.h> #include <glib/gi18n-lib.h> @@ -81,6 +82,8 @@ struct _GtkAppChooserWidgetPrivate { GtkWidget *program_list; GtkListStore *program_list_store; + GtkWidget *no_apps_label; + GtkWidget *no_apps; GtkTreeViewColumn *column; GtkCellRenderer *padding_renderer; @@ -438,7 +441,7 @@ gtk_app_chooser_sort_func (GtkTreeModel *model, goto out; } - /* they're both recommended/falback or not, so if one is a heading, wins */ + /* they're both recommended/fallback or not, so if one is a heading, wins */ if (a_heading) { retval = -1; @@ -660,15 +663,13 @@ add_no_applications_label (GtkAppChooserWidget *self) { gchar *text = NULL, *desc = NULL; const gchar *string; - GtkTreeIter iter; if (self->priv->default_text == NULL) { if (self->priv->content_type) desc = g_content_type_get_description (self->priv->content_type); - string = text = g_strdup_printf (_("No applications available to open ā%sā"), - desc); + string = text = g_strdup_printf (_("No applications found for ā%sā."), desc); g_free (desc); } else @@ -676,11 +677,7 @@ add_no_applications_label (GtkAppChooserWidget *self) string = self->priv->default_text; } - gtk_list_store_append (self->priv->program_list_store, &iter); - gtk_list_store_set (self->priv->program_list_store, &iter, - COLUMN_HEADING_TEXT, string, - COLUMN_HEADING, TRUE, - -1); + gtk_label_set_text (GTK_LABEL (self->priv->no_apps_label), string); g_free (text); } @@ -693,7 +690,8 @@ gtk_app_chooser_widget_select_first (GtkAppChooserWidget *self) GtkTreeModel *model; model = gtk_tree_view_get_model (GTK_TREE_VIEW (self->priv->program_list)); - gtk_tree_model_get_iter_first (model, &iter); + if (!gtk_tree_model_get_iter_first (model, &iter)) + return; while (info == NULL) { @@ -791,7 +789,14 @@ gtk_app_chooser_widget_real_add_items (GtkAppChooserWidget *self) } if (!apps_added) - add_no_applications_label (self); + { + add_no_applications_label (self); + gtk_widget_show (self->priv->no_apps); + } + else + { + gtk_widget_hide (self->priv->no_apps); + } gtk_app_chooser_widget_select_first (self); @@ -1110,6 +1115,8 @@ gtk_app_chooser_widget_class_init (GtkAppChooserWidgetClass *klass) gtk_widget_class_bind_template_child_private (widget_class, GtkAppChooserWidget, column); gtk_widget_class_bind_template_child_private (widget_class, GtkAppChooserWidget, padding_renderer); gtk_widget_class_bind_template_child_private (widget_class, GtkAppChooserWidget, secondary_padding); + gtk_widget_class_bind_template_child_private (widget_class, GtkAppChooserWidget, no_apps_label); + gtk_widget_class_bind_template_child_private (widget_class, GtkAppChooserWidget, no_apps); gtk_widget_class_bind_template_callback (widget_class, refresh_and_emit_app_selected); gtk_widget_class_bind_template_callback (widget_class, program_list_selection_activated); gtk_widget_class_bind_template_callback (widget_class, widget_button_press_event_cb); |