[krb5-auth-dialog] Make the tickets dialog the main window



commit 47bdf47feaa0a4b5fd9fd05e96f4b1f4a4eca49c
Author: Guido GÃnther <agx sigxcpu org>
Date:   Sun Sep 4 15:31:44 2011 +0200

    Make the tickets dialog the main window
    
    instead of a dialog

 po/POTFILES.in                         |    2 +-
 src/Makefile.am                        |    4 +-
 src/ka-applet.c                        |   10 +++---
 src/ka-dialog.c                        |    2 +-
 src/{ka-tickets.c => ka-main-window.c} |   35 +++++++++++-------
 src/{ka-tickets.h => ka-main-window.h} |    5 ++-
 src/krb5-auth-dialog.ui                |   61 ++++++-------------------------
 7 files changed, 45 insertions(+), 74 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 279ce6d..52800c9 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -4,7 +4,7 @@ src/ka-pwdialog.c
 src/dummy-strings.c
 src/ka-applet.c
 src/ka-tools.c
-src/ka-tickets.c
+src/ka-main-window.c
 src/krb5-auth-dialog.desktop.in
 src/krb5-auth-dialog.schemas.in
 secmem/util.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 65d2a92..abfef3d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -40,8 +40,8 @@ krb5_auth_dialog_SOURCES =	\
 	ka-dbus.h		\
 	ka-tools.c		\
 	ka-tools.h		\
-	ka-tickets.c		\
-	ka-tickets.h		\
+	ka-main-window.c	\
+	ka-main-window.h	\
 	ka-plugin.c		\
 	ka-plugin.h		\
 	ka-plugin-loader.c	\
diff --git a/src/ka-applet.c b/src/ka-applet.c
index 60e0f1c..b6216d3 100644
--- a/src/ka-applet.c
+++ b/src/ka-applet.c
@@ -27,7 +27,7 @@
 #include "ka-gconf-tools.h"
 #include "ka-gconf.h"
 #include "ka-tools.h"
-#include "ka-tickets.h"
+#include "ka-main-window.h"
 #include "ka-plugin-loader.h"
 #include "ka-closures.h"
 #include <libnotify/notify.h>
@@ -456,8 +456,8 @@ ka_notify_ticket_action_cb (NotifyNotification *notification G_GNUC_UNUSED,
         KA_DEBUG ("Removing ccache");
         ka_destroy_ccache (self);
     } else if (strcmp (action, "ka-list-tickets") == 0) {
-        KA_DEBUG ("Listing tickets");
-        ka_tickets_dialog_run ();
+        KA_DEBUG ("Showing main window");
+        ka_main_window_show ();
     } else {
         g_warning ("unkonwn action for callback");
     }
@@ -771,7 +771,7 @@ static void
 ka_applet_cb_show_tickets (GtkMenuItem *menuitem G_GNUC_UNUSED,
                            gpointer user_data G_GNUC_UNUSED)
 {
-    ka_tickets_dialog_run ();
+    ka_main_window_show ();
 }
 
 
@@ -1028,7 +1028,7 @@ ka_applet_create ()
     applet->priv->gconf = ka_gconf_init (applet);
     g_return_val_if_fail (applet->priv->gconf != NULL, NULL);
 
-    ka_tickets_dialog_create (applet->priv->uixml);
+    ka_main_window_create (applet->priv->uixml);
     applet->priv->loader = ka_plugin_loader_create (applet);
     g_return_val_if_fail (applet->priv->loader != NULL, NULL);
 
diff --git a/src/ka-dialog.c b/src/ka-dialog.c
index fffd2fd..72c346b 100644
--- a/src/ka-dialog.c
+++ b/src/ka-dialog.c
@@ -40,7 +40,7 @@
 #include "ka-pwdialog.h"
 #include "ka-dbus.h"
 #include "ka-tools.h"
-#include "ka-tickets.h"
+#include "ka-main-window.h"
 
 #ifdef ENABLE_NETWORK_MANAGER
 #include <nm-client.h>
diff --git a/src/ka-tickets.c b/src/ka-main-window.c
similarity index 88%
rename from src/ka-tickets.c
rename to src/ka-main-window.c
index ce01fce..ee259c8 100644
--- a/src/ka-tickets.c
+++ b/src/ka-main-window.c
@@ -1,6 +1,8 @@
-/* Krb5 Auth Applet -- Acquire and release kerberos tickets
+/* -*- c-file-style: "linux"; c-basic-offset: 4; indent-tabs-mode: nil; -*- *
  *
- * (C) 2009 Guido Guenther <agx sigxcpu org>
+ * Krb5 Auth Applet -- Acquire and release kerberos tickets
+ *
+ * (C) 2009,2011 Guido Guenther <agx sigxcpu org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -23,14 +25,14 @@
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
-#include "ka-tickets.h"
+#include "ka-main-window.h"
 #include "ka-dialog.h"
 
 static GtkListStore *tickets;
-static GtkWidget *tickets_dialog;
+static GtkWidget *main_window;
 
 GtkWidget *
-ka_tickets_dialog_create (GtkBuilder *xml)
+ka_main_window_create (GtkBuilder *xml)
 {
     GtkCellRenderer *text_renderer, *toggle_renderer;
     GtkTreeView *tickets_view;
@@ -42,8 +44,8 @@ ka_tickets_dialog_create (GtkBuilder *xml)
                                   G_TYPE_BOOLEAN,
                                   G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
 
-    tickets_dialog =
-        GTK_WIDGET (gtk_builder_get_object (xml, "krb5_tickets_dialog"));
+    main_window =
+        GTK_WIDGET (gtk_builder_get_object (xml, "krb5_main_window"));
     tickets_view =
         GTK_TREE_VIEW (gtk_builder_get_object (xml, "krb5_tickets_treeview"));
     gtk_tree_view_set_model (GTK_TREE_VIEW (tickets_view),
@@ -88,19 +90,17 @@ ka_tickets_dialog_create (GtkBuilder *xml)
                                                 "active",
                                                 RENEWABLE_COLUMN,
                                                 NULL);
-    return tickets_dialog;
+    return main_window;
 }
 
 void
-ka_tickets_dialog_run ()
+ka_main_window_show ()
 {
     if (ka_get_service_tickets (tickets)) {
-        gtk_window_present (GTK_WINDOW (tickets_dialog));
-        gtk_dialog_run (GTK_DIALOG (tickets_dialog));
-        gtk_widget_hide (tickets_dialog);
+        gtk_window_present (GTK_WINDOW (main_window));
     } else {
         GtkWidget *message_dialog;
-
+        
         message_dialog = gtk_message_dialog_new (NULL,
                                                  GTK_DIALOG_DESTROY_WITH_PARENT,
                                                  GTK_MESSAGE_ERROR,
@@ -108,9 +108,16 @@ ka_tickets_dialog_run ()
                                                  _
                                                  ("Error displaying service ticket information"));
         gtk_window_set_resizable (GTK_WINDOW (message_dialog), FALSE);
-
+        
         g_signal_connect (message_dialog, "response",
                           G_CALLBACK (gtk_widget_destroy), NULL);
         gtk_widget_show (message_dialog);
     }
 }
+
+void
+ka_main_window_hide ()
+{
+    KA_DEBUG("Hiding main window");
+    gtk_widget_hide (main_window);
+}
diff --git a/src/ka-tickets.h b/src/ka-main-window.h
similarity index 89%
rename from src/ka-tickets.h
rename to src/ka-main-window.h
index 2a8aa3f..5f8cdd7 100644
--- a/src/ka-tickets.h
+++ b/src/ka-main-window.h
@@ -32,8 +32,9 @@ enum ticket_columns {
 };
 
 
-GtkWidget *ka_tickets_dialog_create (GtkBuilder *xml);
-void ka_tickets_dialog_run (void);
+GtkWidget *ka_main_window_create (GtkBuilder *xml);
+void ka_main_window_show (void);
+void ka_main_window_hide (void);
 
 
 #endif
diff --git a/src/krb5-auth-dialog.ui b/src/krb5-auth-dialog.ui
index f36f537..1265c03 100644
--- a/src/krb5-auth-dialog.ui
+++ b/src/krb5-auth-dialog.ui
@@ -151,66 +151,29 @@
       <action-widget response="-5">krb5_renew_button</action-widget>
     </action-widgets>
   </object>
-  <object class="GtkDialog" id="krb5_tickets_dialog">
-    <property name="border_width">5</property>
+  <object class="GtkWindow" id="krb5_main_window">
+    <property name="can_focus">False</property>
     <property name="title" translatable="yes">Service Tickets</property>
-    <property name="resizable">False</property>
-    <property name="type_hint">normal</property>
-    <child internal-child="vbox">
-      <object class="GtkVBox" id="tickets-vbox2">
+    <signal name="delete-event" handler="ka_main_window_hide" swapped="no"/>
+    <child>
+      <object class="GtkVBox" id="tickets-vbox1">
         <property name="visible">True</property>
-        <property name="orientation">vertical</property>
-        <property name="spacing">2</property>
+        <property name="can_focus">False</property>
         <child>
-          <object class="GtkVBox" id="tickets-vbox1">
-            <property name="visible">True</property>
-            <property name="orientation">vertical</property>
-            <child>
-              <object class="GtkTreeView" id="krb5_tickets_treeview">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-              </object>
-              <packing>
-                <property name="position">0</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child internal-child="action_area">
-          <object class="GtkHButtonBox" id="dialog-action_area">
+          <object class="GtkTreeView" id="krb5_tickets_treeview">
             <property name="visible">True</property>
-            <property name="layout_style">end</property>
-            <child>
-              <placeholder/>
-            </child>
-            <child>
-              <object class="GtkButton" id="krb5_tickets_ok">
-                <property name="label">gtk-close</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
+            <property name="can_focus">True</property>
+            <child internal-child="selection">
+              <object class="GtkTreeSelection" id="treeview-selection"/>
             </child>
           </object>
           <packing>
-            <property name="expand">False</property>
-            <property name="pack_type">end</property>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
             <property name="position">0</property>
           </packing>
         </child>
       </object>
     </child>
-    <action-widgets>
-      <action-widget response="0">krb5_tickets_ok</action-widget>
-    </action-widgets>
   </object>
 </interface>



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