Blame SOURCES/0012-chooser-switch-to-browse-selection-mode.patch

2fc437
From bead5672f65d9a579143de16a7c72e701a346cce Mon Sep 17 00:00:00 2001
2fc437
From: Ray Strode <rstrode@redhat.com>
2fc437
Date: Fri, 31 Mar 2017 15:22:06 -0400
2fc437
Subject: [PATCH 12/13] chooser: switch to browse selection mode
2fc437
2fc437
The chooser is a host browser after all. It makes not sense to
2fc437
have an unselected item.
2fc437
---
2fc437
 chooser/gdm-host-chooser-widget.c | 9 ++++++++-
2fc437
 1 file changed, 8 insertions(+), 1 deletion(-)
2fc437
2fc437
diff --git a/chooser/gdm-host-chooser-widget.c b/chooser/gdm-host-chooser-widget.c
2fc437
index b8924618..f8aabf3e 100644
2fc437
--- a/chooser/gdm-host-chooser-widget.c
2fc437
+++ b/chooser/gdm-host-chooser-widget.c
2fc437
@@ -124,89 +124,96 @@ find_known_host (GdmHostChooserWidget *widget,
2fc437
                  GdmAddress           *address)
2fc437
 {
2fc437
         GSList         *li;
2fc437
         GdmChooserHost *host;
2fc437
 
2fc437
         for (li = widget->priv->chooser_hosts; li != NULL; li = li->next) {
2fc437
                 host = li->data;
2fc437
                 if (gdm_address_equal (gdm_chooser_host_get_address (host), address)) {
2fc437
                         goto out;
2fc437
                 }
2fc437
         }
2fc437
 
2fc437
         host = NULL;
2fc437
  out:
2fc437
 
2fc437
         return host;
2fc437
 }
2fc437
 
2fc437
 static void
2fc437
 browser_add_host (GdmHostChooserWidget *widget,
2fc437
                   GdmChooserHost       *host)
2fc437
 {
2fc437
         char         *hostname;
2fc437
         char         *name;
2fc437
         char         *desc;
2fc437
         char         *label;
2fc437
         GtkTreeModel *model;
2fc437
         GtkTreeIter   iter;
2fc437
         gboolean      res;
2fc437
 
2fc437
+        GtkTreeSelection  *selection;
2fc437
+
2fc437
         g_assert (host != NULL);
2fc437
 
2fc437
         if (! gdm_chooser_host_get_willing (host)) {
2fc437
                 gtk_widget_set_sensitive (GTK_WIDGET (widget), TRUE);
2fc437
                 return;
2fc437
         }
2fc437
 
2fc437
         res = gdm_address_get_hostname (gdm_chooser_host_get_address (host), &hostname);
2fc437
         if (! res) {
2fc437
                 gdm_address_get_numeric_info (gdm_chooser_host_get_address (host), &hostname, NULL);
2fc437
         }
2fc437
 
2fc437
         name = g_markup_escape_text (hostname, -1);
2fc437
         desc = g_markup_escape_text (gdm_chooser_host_get_description (host), -1);
2fc437
         label = g_strdup_printf ("%s\n%s", name, desc);
2fc437
         g_free (name);
2fc437
         g_free (desc);
2fc437
 
2fc437
         model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget->priv->treeview));
2fc437
 
2fc437
         gtk_list_store_append (GTK_LIST_STORE (model), &iter);
2fc437
         gtk_list_store_set (GTK_LIST_STORE (model),
2fc437
                             &iter,
2fc437
                             CHOOSER_LIST_ICON_COLUMN, NULL,
2fc437
                             CHOOSER_LIST_LABEL_COLUMN, label,
2fc437
                             CHOOSER_LIST_HOST_COLUMN, host,
2fc437
                             -1);
2fc437
         g_free (label);
2fc437
 
2fc437
+        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget->priv->treeview));
2fc437
+        if (!gtk_tree_selection_get_selected (selection, NULL, NULL)) {
2fc437
+                gtk_tree_selection_select_iter (selection, &iter);
2fc437
+        }
2fc437
+
2fc437
 }
2fc437
 
2fc437
 static gboolean
2fc437
 decode_packet (GIOChannel           *source,
2fc437
                GIOCondition          condition,
2fc437
                GdmHostChooserWidget *widget)
2fc437
 {
2fc437
         struct sockaddr_storage clnt_ss;
2fc437
         GdmAddress             *address;
2fc437
         int                     ss_len;
2fc437
         XdmcpHeader             header;
2fc437
         int                     res;
2fc437
         static XdmcpBuffer      buf;
2fc437
         ARRAY8                  auth = {0};
2fc437
         ARRAY8                  host = {0};
2fc437
         ARRAY8                  stat = {0};
2fc437
         char                   *status;
2fc437
         GdmChooserHost         *chooser_host;
2fc437
 
2fc437
         status = NULL;
2fc437
         address = NULL;
2fc437
 
2fc437
         g_debug ("decode_packet: GIOCondition %d", (int)condition);
2fc437
 
2fc437
         if ( ! (condition & G_IO_IN)) {
2fc437
                 return TRUE;
2fc437
         }
2fc437
 
2fc437
         ss_len = (int) sizeof (clnt_ss);
2fc437
 
2fc437
@@ -777,61 +784,61 @@ on_row_activated (GtkTreeView          *tree_view,
2fc437
 {
2fc437
         g_signal_emit (widget, signals[HOST_ACTIVATED], 0);
2fc437
 }
2fc437
 
2fc437
 static void
2fc437
 gdm_host_chooser_widget_init (GdmHostChooserWidget *widget)
2fc437
 {
2fc437
         GtkWidget         *scrolled;
2fc437
         GtkTreeSelection  *selection;
2fc437
         GtkTreeViewColumn *column;
2fc437
         GtkTreeModel      *model;
2fc437
 
2fc437
         widget->priv = GDM_HOST_CHOOSER_WIDGET_GET_PRIVATE (widget);
2fc437
 
2fc437
         scrolled = gtk_scrolled_window_new (NULL, NULL);
2fc437
         gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
2fc437
                                              GTK_SHADOW_IN);
2fc437
         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
2fc437
                                         GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
2fc437
         gtk_box_pack_start (GTK_BOX (widget), scrolled, TRUE, TRUE, 0);
2fc437
 
2fc437
         widget->priv->treeview = gtk_tree_view_new ();
2fc437
         gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (widget->priv->treeview), FALSE);
2fc437
         g_signal_connect (widget->priv->treeview,
2fc437
                           "row-activated",
2fc437
                           G_CALLBACK (on_row_activated),
2fc437
                           widget);
2fc437
         gtk_container_add (GTK_CONTAINER (scrolled), widget->priv->treeview);
2fc437
 
2fc437
         selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget->priv->treeview));
2fc437
-        gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
2fc437
+        gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
2fc437
         g_signal_connect (selection, "changed",
2fc437
                           G_CALLBACK (on_host_selected),
2fc437
                           widget);
2fc437
 
2fc437
         model = (GtkTreeModel *)gtk_list_store_new (3,
2fc437
                                                     GDK_TYPE_PIXBUF,
2fc437
                                                     G_TYPE_STRING,
2fc437
                                                     G_TYPE_POINTER);
2fc437
         gtk_tree_view_set_model (GTK_TREE_VIEW (widget->priv->treeview), model);
2fc437
 
2fc437
         column = gtk_tree_view_column_new_with_attributes ("Icon",
2fc437
                                                            gtk_cell_renderer_pixbuf_new (),
2fc437
                                                            "pixbuf", CHOOSER_LIST_ICON_COLUMN,
2fc437
                                                            NULL);
2fc437
         gtk_tree_view_append_column (GTK_TREE_VIEW (widget->priv->treeview), column);
2fc437
 
2fc437
         column = gtk_tree_view_column_new_with_attributes ("Hostname",
2fc437
                                                            gtk_cell_renderer_text_new (),
2fc437
                                                            "markup", CHOOSER_LIST_LABEL_COLUMN,
2fc437
                                                            NULL);
2fc437
         gtk_tree_view_append_column (GTK_TREE_VIEW (widget->priv->treeview), column);
2fc437
 
2fc437
         gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model),
2fc437
                                               CHOOSER_LIST_LABEL_COLUMN,
2fc437
                                               GTK_SORT_ASCENDING);
2fc437
 }
2fc437
 
2fc437
 static void
2fc437
 gdm_host_chooser_widget_finalize (GObject *object)
2fc437
 {
2fc437
-- 
2fc437
2.12.0
2fc437