[simple-scan] Split authorize dialog into its own .ui file
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [simple-scan] Split authorize dialog into its own .ui file
- Date: Wed, 17 May 2017 08:03:44 +0000 (UTC)
commit 3c7b77386a570776e82aa5cc9b219863e7e1176b
Author: Robert Ancell <robert ancell canonical com>
Date: Wed May 17 20:03:26 2017 +1200
Split authorize dialog into its own .ui file
src/authorize-dialog.ui | 141 +++++++++++++++++++++++++++++++++++++++++
src/simple-scan.gresource.xml | 1 +
src/simple-scan.ui | 136 ---------------------------------------
src/ui.vala | 49 +++++++++-----
4 files changed, 173 insertions(+), 154 deletions(-)
---
diff --git a/src/authorize-dialog.ui b/src/authorize-dialog.ui
new file mode 100644
index 0000000..c099563
--- /dev/null
+++ b/src/authorize-dialog.ui
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.20.0 -->
+<interface>
+ <requires lib="gtk+" version="3.10"/>
+ <template class="AuthorizeDialog" parent="GtkDialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">12</property>
+ <property name="resizable">False</property>
+ <property name="modal">True</property>
+ <property name="type_hint">normal</property>
+ <property name="urgency_hint">True</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="authorize_button">
+ <property name="label" translatable="yes" comments="Button to submit authorization
dialog">_Authorize</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">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">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="vbox5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="authorize_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" comments="This label is set dynamically and is not translated">To
connect to ? you need to authorize</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid" id="grid2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">6</property>
+ <child>
+ <object class="GtkEntry" id="username_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="invisible_char">●</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="password_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="visibility">False</property>
+ <property name="invisible_char">●</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="username_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" comments="Label beside username
entry">_Username for resource:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">username_entry</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="password_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" comments="Label beside password
entry">_Password:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">password_entry</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</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="0">authorize_button</action-widget>
+ </action-widgets>
+ </template>
+</interface>
diff --git a/src/simple-scan.gresource.xml b/src/simple-scan.gresource.xml
index 6536887..93eb564 100644
--- a/src/simple-scan.gresource.xml
+++ b/src/simple-scan.gresource.xml
@@ -3,5 +3,6 @@
<gresource prefix="/org/gnome/SimpleScan">
<file preprocess="xml-stripblanks">simple-scan.ui</file>
<file preprocess="xml-stripblanks">preferences.ui</file>
+ <file preprocess="xml-stripblanks">authorize-dialog.ui</file>
</gresource>
</gresources>
diff --git a/src/simple-scan.ui b/src/simple-scan.ui
index 85832cd..9c9fd27 100644
--- a/src/simple-scan.ui
+++ b/src/simple-scan.ui
@@ -2,142 +2,6 @@
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.10"/>
- <object class="GtkDialog" id="authorize_dialog">
- <property name="can_focus">False</property>
- <property name="border_width">12</property>
- <property name="resizable">False</property>
- <property name="modal">True</property>
- <property name="type_hint">normal</property>
- <property name="urgency_hint">True</property>
- <child internal-child="vbox">
- <object class="GtkBox" id="dialog-vbox1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">12</property>
- <child internal-child="action_area">
- <object class="GtkButtonBox" id="dialog-action_area1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="authorize_button">
- <property name="label" translatable="yes" comments="Button to submit authorization
dialog">_Authorize</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_underline">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">False</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="vbox5">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">5</property>
- <property name="orientation">vertical</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkLabel" id="authorize_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" comments="This label is set dynamically and is not translated">To
connect to ? you need to authorize</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkGrid" id="grid2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="row_spacing">6</property>
- <property name="column_spacing">6</property>
- <child>
- <object class="GtkEntry" id="username_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="invisible_char">●</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="password_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="visibility">False</property>
- <property name="invisible_char">●</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="username_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes" comments="Label beside username
entry">_Username for resource:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">username_entry</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="password_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes" comments="Label beside password
entry">_Password:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">password_entry</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</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="0">authorize_button</action-widget>
- </action-widgets>
- </object>
<object class="GtkImage" id="email_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
diff --git a/src/ui.vala b/src/ui.vala
index 4bafef2..f846533 100644
--- a/src/ui.vala
+++ b/src/ui.vala
@@ -109,15 +109,6 @@ public class UserInterface : Gtk.ApplicationWindow
[GtkChild]
private Gtk.RadioMenuItem photo_menuitem;
- [GtkChild]
- private Gtk.Dialog authorize_dialog;
- [GtkChild]
- private Gtk.Label authorize_label;
- [GtkChild]
- private Gtk.Entry username_entry;
- [GtkChild]
- private Gtk.Entry password_entry;
-
private string? missing_driver = null;
private Gtk.FileChooserDialog? save_dialog;
@@ -261,17 +252,14 @@ public class UserInterface : Gtk.ApplicationWindow
{
/* Label in authorization dialog. “%s” is replaced with the name of the resource requesting
authorization */
var description = _("Username and password required to access “%s”").printf (resource);
-
- username_entry.text = "";
- password_entry.text = "";
- authorize_label.set_text (description);
-
+ var authorize_dialog = new AuthorizeDialog (description);
authorize_dialog.visible = true;
+ authorize_dialog.transient_for = this;
authorize_dialog.run ();
- authorize_dialog.visible = false;
+ authorize_dialog.destroy ();
- username = username_entry.text;
- password = password_entry.text;
+ username = authorize_dialog.get_username ();
+ password = authorize_dialog.get_password ();
}
private void update_info_bar ()
@@ -1724,7 +1712,6 @@ public class UserInterface : Gtk.ApplicationWindow
book_view.show_menu.connect (show_page_menu_cb);
book_view.visible = true;
- authorize_dialog.transient_for = this;
preferences_dialog.transient_for = this;
/* Load previous state */
@@ -2534,3 +2521,29 @@ private class PageIcon : Gtk.DrawingArea
return true;
}
}
+
+[GtkTemplate (ui = "/org/gnome/SimpleScan/authorize-dialog.ui")]
+private class AuthorizeDialog : Gtk.Dialog
+{
+ [GtkChild]
+ private Gtk.Label authorize_label;
+ [GtkChild]
+ private Gtk.Entry username_entry;
+ [GtkChild]
+ private Gtk.Entry password_entry;
+
+ public AuthorizeDialog (string title)
+ {
+ authorize_label.set_text (title);
+ }
+
+ public string get_username ()
+ {
+ return username_entry.text;
+ }
+
+ public string get_password ()
+ {
+ return password_entry.text;
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]