[krb5-auth-dialog] Make KaPwDialog a proper child of GtkDialog
- From: Guido Günther <guidog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [krb5-auth-dialog] Make KaPwDialog a proper child of GtkDialog
- Date: Sun, 26 Oct 2014 13:50:46 +0000 (UTC)
commit f3c9e040f0ac85193fd33c44f9ac8c96d9a87565
Author: Guido Günther <agx sigxcpu org>
Date: Thu Oct 23 21:09:19 2014 +0200
Make KaPwDialog a proper child of GtkDialog
This gives us variants with and without header bar for free.
.gitignore | 1 +
configure.ac | 3 +
src/Makefile.am | 10 ++
src/ka-applet.c | 4 +-
src/ka-pwdialog.c | 55 ++++++------
src/ka-pwdialog.h | 2 +-
src/krb5-auth-dialog.gresource.xml | 6 ++
src/krb5-auth-dialog.ui | 163 ------------------------------------
src/resources/ui/ka-pwdialog.ui | 150 +++++++++++++++++++++++++++++++++
9 files changed, 201 insertions(+), 193 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 0da4552..8eb8ad0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,4 +35,5 @@ intltool-extract.in
intltool-merge.in
intltool-update.in
gnome-doc-utils.make
+src/resources.c
src/krb5-auth-dialog.appdata.xml
diff --git a/configure.ac b/configure.ac
index f203b50..1b9dc31 100644
--- a/configure.ac
+++ b/configure.ac
@@ -41,6 +41,9 @@ dnl GNOME_MAINTAINER_MODE_DEFINES
GLIB_GSETTINGS
+GLIB_COMPILE_RESOURCES=`$PKG_CONFIG --variable glib_compile_resources gio-2.0`
+AC_SUBST(GLIB_COMPILE_RESOURCES)
+
dnl --enable-debug=(yes|no)
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug=no/yes],[enable debugging output]),[],[enable_debug=no])
diff --git a/src/Makefile.am b/src/Makefile.am
index 78aa1d9..8d0a062 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -57,6 +57,7 @@ krb5_auth_dialog_SOURCES = \
ka-entry-buffer.h \
ka-entry-buffer.c \
dummy-strings.c \
+ resources.c \
$(NULL)
krb5_auth_dialog_CPPFLAGS = \
@@ -109,14 +110,23 @@ EXTRA_DIST = \
$(appdata_in_files) \
org.gnome.KrbAuthDialog.gschema.xml \
krb5-auth-dialog.1.in \
+ krb5-auth-dialog.gresource.xml \
$(NULL)
CLEANFILES = $(schema_DATA) \
$(service_DATA) \
$(appdata_DATA) \
+ resources.c \
$(NULL)
DISTCLEANFILES = \
krb5-auth-dialog.desktop \
$(NULL)
+BUILT_SOURCES = \
+ resources.c \
+ $(NULL)
+
+resources.c: krb5-auth-dialog.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES)
--sourcedir=$(srcdir)/resources --generate-dependencies $(srcdir)/krb5-auth-dialog.gresource.xml)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/krb5-auth-dialog.gresource.xml \
+ --target=$@ --sourcedir=$(srcdir)/resources --generate-source
diff --git a/src/ka-applet.c b/src/ka-applet.c
index 08c9080..d63cd35 100644
--- a/src/ka-applet.c
+++ b/src/ka-applet.c
@@ -408,7 +408,7 @@ ka_applet_dispose (GObject *object)
applet->priv->tray_icon = NULL;
}
if (applet->priv->pwdialog) {
- g_object_unref (applet->priv->pwdialog);
+ gtk_widget_destroy (GTK_WIDGET(applet->priv->pwdialog));
applet->priv->pwdialog = NULL;
}
if (applet->priv->uixml) {
@@ -1198,7 +1198,7 @@ ka_applet_create ()
}
gtk_builder_connect_signals (applet->priv->uixml, NULL);
- applet->priv->pwdialog = ka_pwdialog_create (applet->priv->uixml);
+ applet->priv->pwdialog = ka_pwdialog_create ();
g_return_val_if_fail (applet->priv->pwdialog != NULL, NULL);
applet->priv->settings = ka_settings_init (applet);
diff --git a/src/ka-pwdialog.c b/src/ka-pwdialog.c
index 7653a4d..a54ce07 100644
--- a/src/ka-pwdialog.c
+++ b/src/ka-pwdialog.c
@@ -27,28 +27,28 @@
#include "ka-entry-buffer.h"
struct _KaPwDialog {
- GObject parent;
+ GtkDialog parent;
KaPwDialogPrivate *priv;
};
struct _KaPwDialogClass {
- GObjectClass parent;
+ GtkDialogClass parent;
};
-G_DEFINE_TYPE (KaPwDialog, ka_pwdialog, G_TYPE_OBJECT);
-
struct _KaPwDialogPrivate {
/* The password dialog */
- GtkWidget *dialog; /* the password dialog itself */
GtkWidget *status_label; /* the wrong password/timeout label */
GtkWidget *krb_label; /* krb5 passwort prompt label */
+ GtkWidget *entry_hbox; /* hbox for the pw entry */
GtkWidget *pw_entry; /* password entry field */
+
gboolean persist; /* don't hide the dialog when creds are still valid */
gboolean grabbed; /* keyboard grabbed? */
GtkWidget *error_dialog; /* error dialog */
};
+G_DEFINE_TYPE_WITH_PRIVATE (KaPwDialog, ka_pwdialog, GTK_TYPE_DIALOG);
static void
ka_pwdialog_init (KaPwDialog *pwdialog)
@@ -56,6 +56,8 @@ ka_pwdialog_init (KaPwDialog *pwdialog)
pwdialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (pwdialog,
KA_TYPE_PWDIALOG,
KaPwDialogPrivate);
+
+ gtk_widget_init_template (GTK_WIDGET (pwdialog));
}
static void
@@ -67,18 +69,25 @@ ka_pwdialog_finalize (GObject *object)
gtk_widget_destroy (pwdialog->priv->error_dialog);
pwdialog->priv->error_dialog = NULL;
- if (parent_class->finalize != NULL)
- parent_class->finalize (object);
+ parent_class->finalize (object);
}
static void
ka_pwdialog_class_init (KaPwDialogClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = ka_pwdialog_finalize;
- g_type_class_add_private (klass, sizeof (KaPwDialogPrivate));
+ /* Bind class to template
+ */
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/krb5-auth-dialog/ui/ka-pwdialog.ui");
+
+ gtk_widget_class_bind_template_child_private (widget_class, KaPwDialog, status_label);
+ gtk_widget_class_bind_template_child_private (widget_class, KaPwDialog, krb_label);
+ gtk_widget_class_bind_template_child_private (widget_class, KaPwDialog, entry_hbox);
}
static KaPwDialog *
@@ -193,29 +202,27 @@ window_state_changed (GtkWidget *win, GdkEventWindowState *event,
gint
ka_pwdialog_run (KaPwDialog *self)
{
- GtkWidget *dialog = self->priv->dialog;
-
/* cleanup old error dialog, if present (e.g. user didn't acknowledge
* the error but clicked the tray icon again) */
if (self->priv->error_dialog)
gtk_widget_hide (self->priv->error_dialog);
/* make sure we pop up on top */
- gtk_window_set_keep_above (GTK_WINDOW (dialog), TRUE);
+ gtk_window_set_keep_above (GTK_WINDOW (self), TRUE);
/*
* grab the keyboard so that people don't accidentally type their
* passwords in other windows.
*/
- g_signal_connect (dialog, "map-event", G_CALLBACK (grab_keyboard), self);
- g_signal_connect (dialog, "unmap-event", G_CALLBACK (ungrab_keyboard),
+ g_signal_connect (self, "map-event", G_CALLBACK (grab_keyboard), self);
+ g_signal_connect (self, "unmap-event", G_CALLBACK (ungrab_keyboard),
self);
- g_signal_connect (dialog, "window-state-event",
+ g_signal_connect (self, "window-state-event",
G_CALLBACK (window_state_changed), self);
gtk_widget_grab_focus (self->priv->pw_entry);
- gtk_widget_show (dialog);
- return gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_show (GTK_WIDGET (self));
+ return gtk_dialog_run (GTK_DIALOG (self));
}
@@ -245,7 +252,7 @@ ka_pwdialog_hide (const KaPwDialog *pwdialog, gboolean force)
{
KA_DEBUG ("PW Dialog persist: %d", pwdialog->priv->persist);
if (!pwdialog->priv->persist || force)
- gtk_widget_hide (pwdialog->priv->dialog);
+ gtk_widget_hide (GTK_WIDGET (pwdialog));
}
const gchar *
@@ -349,26 +356,20 @@ ka_error_dialog_new (void)
KaPwDialog *
-ka_pwdialog_create (GtkBuilder *xml)
+ka_pwdialog_create (void)
{
KaPwDialog *pwdialog = ka_pwdialog_new ();
KaEntryBuffer *buffer = ka_entry_buffer_new ();
KaPwDialogPrivate *priv = pwdialog->priv;
- GtkWidget *entry_hbox = NULL;
- priv->dialog = GTK_WIDGET (gtk_builder_get_object (xml, "krb5_dialog"));
- priv->status_label =
- GTK_WIDGET (gtk_builder_get_object (xml, "krb5_status_label"));
- priv->krb_label =
- GTK_WIDGET (gtk_builder_get_object (xml, "krb5_message_label"));
+ priv->error_dialog = ka_error_dialog_new ();
+
priv->pw_entry =
GTK_WIDGET (gtk_entry_new_with_buffer (GTK_ENTRY_BUFFER (buffer)));
gtk_entry_set_visibility (GTK_ENTRY (priv->pw_entry), FALSE);
g_object_unref (buffer);
- priv->error_dialog = ka_error_dialog_new ();
- entry_hbox = GTK_WIDGET (gtk_builder_get_object (xml, "entry_hbox"));
- gtk_container_add (GTK_CONTAINER (entry_hbox), priv->pw_entry);
+ gtk_container_add (GTK_CONTAINER (priv->entry_hbox), priv->pw_entry);
gtk_entry_set_activates_default (GTK_ENTRY (priv->pw_entry), TRUE);
gtk_widget_show (priv->pw_entry);
diff --git a/src/ka-pwdialog.h b/src/ka-pwdialog.h
index 5af1117..e874bf0 100644
--- a/src/ka-pwdialog.h
+++ b/src/ka-pwdialog.h
@@ -45,7 +45,7 @@ typedef struct _KaPwDialogPrivate KaPwDialogPrivate;
GType ka_pwdialog_get_type (void);
/* public functions */
-KaPwDialog *ka_pwdialog_create (GtkBuilder *xml);
+KaPwDialog *ka_pwdialog_create (void);
/* setup everything for the next prompting */
void ka_pwdialog_setup (KaPwDialog *pwdialog, const gchar *krb5prompt,
diff --git a/src/krb5-auth-dialog.gresource.xml b/src/krb5-auth-dialog.gresource.xml
new file mode 100644
index 0000000..a6f3eea
--- /dev/null
+++ b/src/krb5-auth-dialog.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/krb5-auth-dialog">
+ <file preprocess="xml-stripblanks">ui/ka-pwdialog.ui</file>
+ </gresource>
+</gresources>
diff --git a/src/krb5-auth-dialog.ui b/src/krb5-auth-dialog.ui
index 44621e0..50fd5bc 100644
--- a/src/krb5-auth-dialog.ui
+++ b/src/krb5-auth-dialog.ui
@@ -30,169 +30,6 @@
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
- <object class="GtkDialog" id="krb5_dialog">
- <property name="can_focus">False</property>
- <property name="border_width">6</property>
- <property name="title" translatable="yes">Kerberos Authentication</property>
- <property name="resizable">False</property>
- <property name="window_position">center-always</property>
- <property name="type_hint">dialog</property>
-
- <child type="titlebar">
- <object class="GtkHeaderBar" id="headerbar1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkButton" id="cancelbutton1">
- <property name="label">gtk-cancel</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="pack-type">start</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="krb5_renew_button">
- <property name="label" translatable="yes">_Renew Ticket</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="pack-type">end</property>
- </packing>
- </child>
- </object>>
- </child>
- <child internal-child="vbox">
- <object class="GtkBox" id="dialog-vbox2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkHBox" id="hbox1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">6</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkImage" id="image1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="yalign">0</property>
- <property name="icon_name">krb-valid-ticket</property>
- <property name="icon-size">6</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkAlignment" id="alignment4">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="bottom_padding">10</property>
- <child>
- <object class="GtkVBox" id="vbox2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkVBox" id="vbox1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkLabel" id="krb5_message_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="use_markup">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkVBox" id="vbox3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">3</property>
- <child>
- <object class="GtkHBox" id="entry_hbox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">3</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="krb5_status_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">1</property>
- <property name="label"><span size="smaller"> </span></property>
- <property name="use_markup">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- <action-widgets>
- <action-widget response="-6">cancelbutton1</action-widget>
- <action-widget response="-5">krb5_renew_button</action-widget>
- </action-widgets>
- </object>
<object class="GtkApplicationWindow" id="krb5_main_window">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Service Tickets</property>
diff --git a/src/resources/ui/ka-pwdialog.ui b/src/resources/ui/ka-pwdialog.ui
new file mode 100644
index 0000000..8b8a3a1
--- /dev/null
+++ b/src/resources/ui/ka-pwdialog.ui
@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.10 -->
+ <template class="KaPwDialog" parent="GtkDialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">6</property>
+ <property name="title" translatable="yes">Kerberos Authentication</property>
+ <property name="resizable">False</property>
+ <property name="window_position">center-always</property>
+ <property name="type_hint">dialog</property>
+
+ <child type="action">
+ <object class="GtkButton" id="cancelbutton1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Cancel</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child type="action">
+ <object class="GtkButton" id="krb5_renew_button">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Renew Ticket</property>
+ <property name="can-default">True</property>
+ <property name="has_default">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">6</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="yalign">0</property>
+ <property name="icon_name">krb-valid-ticket</property>
+ <property name="icon-size">6</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="bottom_padding">10</property>
+ <child>
+ <object class="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel" id="krb_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">3</property>
+ <child>
+ <object class="GtkHBox" id="entry_hbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">3</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="status_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label"><span size="smaller"> </span></property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="-6">cancelbutton1</action-widget>
+ <action-widget response="-5">krb5_renew_button</action-widget>
+ </action-widgets>
+ </template>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]