[simple-scan/wip/cdavis/consistency-updates: 6/14] app-window: Use HdyStatusPage for consistent styling
- From: Bartosz <bkosiorek src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [simple-scan/wip/cdavis/consistency-updates: 6/14] app-window: Use HdyStatusPage for consistent styling
- Date: Fri, 12 Feb 2021 11:52:51 +0000 (UTC)
commit b5c3eeaeeb58a3113241a149cb8b028c0e984782
Author: Christopher Davis <brainblasted disroot org>
Date: Wed Feb 10 10:16:18 2021 -0800
app-window: Use HdyStatusPage for consistent styling
We have a pattern for pages with an icon, title, and
custom children in GNOME. Libhandy provides a pre-built
widget so we can keep things consistent.
data/ui/app-window.ui | 60 +++++++++------------------------------------------
meson.build | 2 +-
src/app-window.vala | 24 ++++++++++-----------
3 files changed, 23 insertions(+), 63 deletions(-)
---
diff --git a/data/ui/app-window.ui b/data/ui/app-window.ui
index fbedef5a..5fd0a0a5 100644
--- a/data/ui/app-window.ui
+++ b/data/ui/app-window.ui
@@ -730,68 +730,28 @@
<property name="can_focus">False</property>
<property name="vexpand">True</property>
<child>
- <object class="GtkAlignment">
+ <object class="HdyStatusPage" id="status_page">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xscale">0</property>
- <property name="yscale">0</property>
+ <property name="icon_name">org.gnome.SimpleScan-symbolic</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="orientation">vertical</property>
- <property name="spacing">10</property>
- <child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="has_focus">True</property>
- <property name="is_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="opacity">0.5</property>
- <property name="pixel_size">120</property>
- <property name="icon_name">org.gnome.SimpleScan-symbolic</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="GtkLabel" id="status_primary_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- <attribute name="scale" value="1.5"/>
- </attributes>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="spacing">12</property>
<child>
<object class="GtkLabel" id="status_secondary_label">
- <property name="can_focus">False</property>
+ <property name="visible">False</property>
+ <property name="wrap">True</property>
+ <property name="wrap-mode">word-char</property>
+ <property name="justify">center</property>
+ <property name="use-markup">True</property>
<property name="track_visited_links">False</property>
<signal name="activate-link" handler="status_label_activate_link_cb" swapped="no"/>
<style>
- <class name="dim-label"/>
+ <class name="body"/>
+ <class name="description"/>
</style>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
</child>
<child>
<object class="GtkBox" id="device_buttons_box">
diff --git a/meson.build b/meson.build
index 8543cbda..fb7507c7 100644
--- a/meson.build
+++ b/meson.build
@@ -23,7 +23,7 @@ glib_dep = dependency ('glib-2.0', version: '>= 2.38')
gtk_dep = dependency ('gtk+-3.0', version: '>=3.22')
gmodule_dep = dependency ('gmodule-export-2.0')
gthread_dep = dependency ('gthread-2.0')
-libhandy_dep = dependency ('libhandy-1', version: '>=1.0.0')
+libhandy_dep = dependency ('libhandy-1', version: '>=1.1.0')
zlib_dep = dependency ('zlib')
cairo_dep = dependency ('cairo')
gdk_pixbuf_dep = dependency ('gdk-pixbuf-2.0')
diff --git a/src/app-window.vala b/src/app-window.vala
index f765e864..7c7661d1 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -54,7 +54,9 @@ public class AppWindow : Hdy.ApplicationWindow
[GtkChild]
private Gtk.Stack stack;
[GtkChild]
- private Gtk.Label status_primary_label;
+ private Hdy.StatusPage status_page;
+ [GtkChild]
+ private Gtk.Label status_secondary_label;
[GtkChild]
private Gtk.ListStore device_model;
[GtkChild]
@@ -62,8 +64,6 @@ public class AppWindow : Hdy.ApplicationWindow
[GtkChild]
private Gtk.ComboBox device_combo;
[GtkChild]
- private Gtk.Label status_secondary_label;
- [GtkChild]
private Gtk.Box main_vbox;
[GtkChild]
private Gtk.RadioMenuItem custom_crop_menuitem;
@@ -251,16 +251,16 @@ public class AppWindow : Hdy.ApplicationWindow
scan_button.sensitive = false;
if (!have_devices)
{
- status_primary_label.set_text (/* Label shown when searching for scanners */
- _("Searching for Scanners…"));
+ status_page.set_title (/* Label shown when searching for scanners */
+ _("Searching for Scanners…"));
status_secondary_label.visible = false;
device_buttons_box.visible = false;
}
else if (get_selected_device () != null)
{
scan_button.sensitive = true;
- status_primary_label.set_text (/* Label shown when detected a scanner */
- _("Ready to Scan"));
+ status_page.set_title (/* Label shown when detected a scanner */
+ _("Ready to Scan"));
status_secondary_label.set_text (get_selected_device_label ());
status_secondary_label.visible = false;
device_buttons_box.visible = true;
@@ -269,8 +269,8 @@ public class AppWindow : Hdy.ApplicationWindow
}
else if (this.missing_driver != null)
{
- status_primary_label.set_text (/* Warning displayed when no drivers are installed but a
compatible scanner is detected */
- _("Additional software needed"));
+ status_page.set_title (/* Warning displayed when no drivers are installed but a compatible
scanner is detected */
+ _("Additional software needed"));
/* Instructions to install driver software */
status_secondary_label.set_markup (_("You need to <a href=\"install-firmware\">install driver
software</a> for your scanner."));
status_secondary_label.visible = true;
@@ -279,7 +279,7 @@ public class AppWindow : Hdy.ApplicationWindow
else
{
/* Warning displayed when no scanners are detected */
- status_primary_label.set_text (_("No scanners detected"));
+ status_page.set_title (_("No scanners detected"));
/* Hint to user on why there are no scanners detected */
status_secondary_label.set_text (_("Please check your scanner is connected and powered on"));
status_secondary_label.visible = true;
@@ -832,8 +832,8 @@ public class AppWindow : Hdy.ApplicationWindow
private void scan (ScanOptions options)
{
- status_primary_label.set_text (/* Label shown when scan started */
- _("Contacting scanner…"));
+ status_page.set_title (/* Label shown when scan started */
+ _("Contacting scanner…"));
device_buttons_box.visible = true;
device_buttons_box.sensitive = false;
start_scan (get_selected_device (), options);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]