diff options
Diffstat (limited to 'src/ka-main-window.c')
-rw-r--r-- | src/ka-main-window.c | 82 |
1 files changed, 20 insertions, 62 deletions
diff --git a/src/ka-main-window.c b/src/ka-main-window.c index b841b3e..efcec63 100644 --- a/src/ka-main-window.c +++ b/src/ka-main-window.c @@ -2,7 +2,7 @@ * * Krb5 Auth Applet -- Acquire and release kerberos tickets * - * (C) 2009,2011 Guido Guenther <agx@sigxcpu.org> + * (C) 2009,2011,2013 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 @@ -31,68 +31,21 @@ #include "ka-preferences.h" static GtkListStore *tickets; -static GtkWindow *main_window; +static GtkApplicationWindow *main_window; static void -ccache_changed_cb (KaApplet* applet G_GNUC_UNUSED, +ccache_changed_cb (KaApplet* applet, gpointer user_data G_GNUC_UNUSED) { - KA_DEBUG("Refreshing ticket list"); - ka_get_service_tickets (tickets); -} - -static void -menuitem_close_cb (GtkMenuItem *menuitem G_GNUC_UNUSED, - gpointer user_data G_GNUC_UNUSED) -{ - ka_main_window_hide(); -} + gboolean conf_tickets; -static void -menuitem_preferences_cb (GtkMenuItem *menuitem G_GNUC_UNUSED, - gpointer user_data G_GNUC_UNUSED) -{ - ka_preferences_window_show (main_window); -} - -static void -menuitem_about_cb (GtkMenuItem *menuitem G_GNUC_UNUSED, - gpointer user_data G_GNUC_UNUSED) -{ - ka_show_about (); -} - -static void -menuitem_help_contents_cb (GtkMenuItem *menuitem G_GNUC_UNUSED, - gpointer user_data G_GNUC_UNUSED) -{ - ka_show_help (gtk_window_get_screen (main_window), NULL, NULL); -} - - -static void -ka_main_window_create_menu (KaApplet *applet, GtkBuilder *xml) -{ - GtkMenuItem *item; - -#define CONNECT_MENU(name) \ - item = GTK_MENU_ITEM (gtk_builder_get_object (xml, \ - "menuitem_" #name)); \ - g_signal_connect (item, \ - "activate", \ - G_CALLBACK(menuitem_ ##name## _cb), \ - applet) - - CONNECT_MENU(close); - CONNECT_MENU(preferences); - CONNECT_MENU(about); - CONNECT_MENU(help_contents); - -#undef CONNECT_MENU + KA_DEBUG("Refreshing ticket list"); + g_object_get(applet, KA_PROP_NAME_CONF_TICKETS, &conf_tickets, NULL); + ka_get_service_tickets (tickets, !conf_tickets); } -GtkWindow * +GtkApplicationWindow * ka_main_window_create (KaApplet *applet, GtkBuilder *xml) { GtkCellRenderer *text_renderer, *toggle_renderer; @@ -106,7 +59,10 @@ ka_main_window_create (KaApplet *applet, GtkBuilder *xml) G_TYPE_BOOLEAN, G_TYPE_BOOLEAN); main_window = - GTK_WINDOW (gtk_builder_get_object (xml, "krb5_main_window")); + GTK_APPLICATION_WINDOW (gtk_builder_get_object (xml, + "krb5_main_window")); + g_object_set(main_window, "application", applet, NULL); + tickets_view = GTK_TREE_VIEW (gtk_builder_get_object (xml, "krb5_tickets_treeview")); gtk_tree_view_set_model (GTK_TREE_VIEW (tickets_view), @@ -159,18 +115,20 @@ ka_main_window_create (KaApplet *applet, GtkBuilder *xml) G_CALLBACK(ccache_changed_cb), NULL); - ka_main_window_create_menu(applet, xml); return main_window; } void -ka_main_window_show () +ka_main_window_show (KaApplet *applet) { - if (ka_get_service_tickets (tickets)) { - gtk_window_present (main_window); + gboolean conf_tickets; + + g_object_get(applet, KA_PROP_NAME_CONF_TICKETS, &conf_tickets, NULL); + if (ka_get_service_tickets (tickets, !conf_tickets)) { + 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, @@ -178,7 +136,7 @@ ka_main_window_show () _ ("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); |