[krb5-auth-dialog] main-window: Don't abuse principal column



commit fe97486dd606b081ee9d6e6b82eddb93d42be974
Author: Guido Günther <agx sigxcpu org>
Date:   Tue Feb 9 15:46:43 2021 +0100

    main-window: Don't abuse principal column
    
    Don't store the information that the cache is empty inside
    the tree view. This makes it shortened when there's little
    horizontal space and looks odd in general.

 src/ka-kerberos.c                  |  8 --------
 src/ka-main-window.c               | 33 +++++++++++++++++++++++++++++++++
 src/resources/ui/ka-main-window.ui | 17 +++++++++++++----
 3 files changed, 46 insertions(+), 12 deletions(-)
---
diff --git a/src/ka-kerberos.c b/src/ka-kerberos.c
index 76baf83..12697cc 100644
--- a/src/ka-kerberos.c
+++ b/src/ka-kerberos.c
@@ -308,20 +308,12 @@ ka_get_service_tickets (GtkListStore * tickets, gboolean hide_conf_tickets)
     ret = krb5_cc_start_seq_get (kcontext, ccache, &cursor);
     if (ret == KRB5_FCC_NOFILE) {
         ka_log_error_message_at_level (G_LOG_LEVEL_INFO, "krb5_cc_start_seq_get", kcontext, ret);
-
-        gtk_list_store_append (tickets, &iter);
-        gtk_list_store_set (tickets, &iter,
-                            PRINCIPAL_COLUMN, _("Your ticket cache is currently empty"),
-                            FORWARDABLE_COLUMN, FALSE,
-                            RENEWABLE_COLUMN, FALSE,
-                            PROXIABLE_COLUMN, FALSE, -1);
         retval = TRUE;
         goto out;
     } else if (ret) {
         goto out;
     }
 
-
     while ((ret = krb5_cc_next_cred (kcontext, ccache, &cursor, &creds)) == 0) {
         gboolean renewable, proxiable, forwardable;
 
diff --git a/src/ka-main-window.c b/src/ka-main-window.c
index f975ab9..e877a1a 100644
--- a/src/ka-main-window.c
+++ b/src/ka-main-window.c
@@ -65,12 +65,36 @@ ticket_btn_clicked(GtkButton* btn G_GNUC_UNUSED, gpointer user_data)
 }
 
 
+static void
+on_row_inserted(GtkTreeModel *model,
+                GtkTreePath  *unused,
+                GtkTreeIter  *iter,
+                GtkStack     *stack)
+{
+    gtk_stack_set_visible_child_name(stack, "tickets");
+}
+
+
+static void
+on_row_deleted(GtkTreeModel *model,
+               GtkTreePath  *unused,
+               GtkStack     *stack)
+{
+    GtkTreeIter iter;
+
+    if (!gtk_tree_model_get_iter_first(model, &iter))
+        gtk_stack_set_visible_child_name(stack, "message");
+}
+
+
+
 GtkApplicationWindow *
 ka_main_window_create (KaApplet *applet)
 {
     GtkCellRenderer *text_renderer, *toggle_renderer;
     GtkTreeViewColumn *column;
     GtkTreeView *tickets_view;
+    GtkStack *stack;
     GtkBuilder *builder;
 
     tickets = gtk_list_store_new (N_COLUMNS,
@@ -143,6 +167,15 @@ ka_main_window_create (KaApplet *applet)
         g_object_set (column, "expand", TRUE, NULL);
     }
 
+    stack = GTK_STACK (gtk_builder_get_object (builder, "stack"));
+    g_signal_connect(tickets, "row-inserted",
+                     G_CALLBACK(on_row_inserted),
+                     stack);
+    g_signal_connect(tickets, "row-deleted",
+                     G_CALLBACK(on_row_deleted),
+                     stack);
+    on_row_deleted(GTK_TREE_MODEL(tickets), NULL, stack);
+
     g_signal_connect (applet, "krb-ccache-changed",
                       G_CALLBACK(ccache_changed_cb),
                       NULL);
diff --git a/src/resources/ui/ka-main-window.ui b/src/resources/ui/ka-main-window.ui
index 427f8a7..3ababfa 100644
--- a/src/resources/ui/ka-main-window.ui
+++ b/src/resources/ui/ka-main-window.ui
@@ -51,22 +51,31 @@
     <property name="default-width">700</property>
     <signal name="delete-event" handler="ka_main_window_hide" swapped="no"/>
     <child>
-      <object class="GtkGrid" id="grid1">
+      <object class="GtkStack" id="stack">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="border_width">5</property>
+       <property name="transition_type">slide-down</property>
         <child>
           <object class="GtkTreeView" id="krb5_tickets_treeview">
             <property name="visible">True</property>
             <property name="can_focus">True</property>
-            <property name="expand">True</property>
             <child internal-child="selection">
               <object class="GtkTreeSelection" id="treeview-selection"/>
             </child>
           </object>
           <packing>
-            <property name="left_attach">0</property>
-            <property name="top_attach">0</property>
+            <property name="name">tickets</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Your ticket cache is currently empty</property>
+          </object>
+          <packing>
+            <property name="name">message</property>
           </packing>
         </child>
       </object>


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