[gnome-software: 1/2] first-run-dialog: Make it a HdyWindow and use HdyStatusPage
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 1/2] first-run-dialog: Make it a HdyWindow and use HdyStatusPage
- Date: Fri, 13 Aug 2021 15:16:06 +0000 (UTC)
commit 8fccc50698f61024bf3e99b3ecd53f0fdb735465
Author: Adrien Plazas <kekun plazas laposte net>
Date: Fri Aug 13 15:06:25 2021 +0200
first-run-dialog: Make it a HdyWindow and use HdyStatusPage
This makes it look more in line with the other dialogs.
src/gs-application.c | 2 --
src/gs-first-run-dialog.c | 39 +++++++++++++++++++---
src/gs-first-run-dialog.h | 3 +-
src/gs-first-run-dialog.ui | 83 +++++++++++++++-------------------------------
4 files changed, 62 insertions(+), 65 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index 2ddfaadfc..a289fc23e 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -240,8 +240,6 @@ gs_application_show_first_run_dialog (GsApplication *app)
dialog = gs_first_run_dialog_new ();
gs_shell_modal_dialog_present (app->shell, GTK_WINDOW (dialog));
g_settings_set_boolean (app->settings, "first-run", FALSE);
- g_signal_connect_swapped (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), dialog);
}
}
diff --git a/src/gs-first-run-dialog.c b/src/gs-first-run-dialog.c
index 560347900..923cf5fef 100644
--- a/src/gs-first-run-dialog.c
+++ b/src/gs-first-run-dialog.c
@@ -14,12 +14,41 @@
struct _GsFirstRunDialog
{
- GtkDialog parent_instance;
+ HdyWindow parent_instance;
GtkWidget *button;
};
-G_DEFINE_TYPE (GsFirstRunDialog, gs_first_run_dialog, GTK_TYPE_DIALOG)
+G_DEFINE_TYPE (GsFirstRunDialog, gs_first_run_dialog, HDY_TYPE_WINDOW)
+
+static gboolean
+key_press_event_cb (GtkWidget *sender,
+ GdkEvent *event,
+ HdyPreferencesWindow *self)
+{
+ guint keyval;
+ GdkModifierType state;
+ GdkKeymap *keymap;
+ GdkEventKey *key_event = (GdkEventKey *) event;
+
+ gdk_event_get_state (event, &state);
+
+ keymap = gdk_keymap_get_for_display (gtk_widget_get_display (sender));
+
+ gdk_keymap_translate_keyboard_state (keymap,
+ key_event->hardware_keycode,
+ state,
+ key_event->group,
+ &keyval, NULL, NULL, NULL);
+
+ if (keyval == GDK_KEY_Escape) {
+ gtk_window_close (GTK_WINDOW (self));
+
+ return GDK_EVENT_STOP;
+ }
+
+ return GDK_EVENT_PROPAGATE;
+}
static void
button_clicked_cb (GtkWidget *widget, GsFirstRunDialog *dialog)
@@ -49,12 +78,12 @@ gs_first_run_dialog_class_init (GsFirstRunDialogClass *klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/Software/gs-first-run-dialog.ui");
gtk_widget_class_bind_template_child (widget_class, GsFirstRunDialog, button);
+
+ gtk_widget_class_bind_template_callback (widget_class, key_press_event_cb);
}
GtkWidget *
gs_first_run_dialog_new (void)
{
- return GTK_WIDGET (g_object_new (GS_TYPE_FIRST_RUN_DIALOG,
- "use-header-bar", TRUE,
- NULL));
+ return GTK_WIDGET (g_object_new (GS_TYPE_FIRST_RUN_DIALOG, NULL));
}
diff --git a/src/gs-first-run-dialog.h b/src/gs-first-run-dialog.h
index 0419584c9..1254e0c2b 100644
--- a/src/gs-first-run-dialog.h
+++ b/src/gs-first-run-dialog.h
@@ -9,12 +9,13 @@
#pragma once
#include <gtk/gtk.h>
+#include <handy.h>
G_BEGIN_DECLS
#define GS_TYPE_FIRST_RUN_DIALOG (gs_first_run_dialog_get_type ())
-G_DECLARE_FINAL_TYPE (GsFirstRunDialog, gs_first_run_dialog, GS, FIRST_RUN_DIALOG, GtkDialog)
+G_DECLARE_FINAL_TYPE (GsFirstRunDialog, gs_first_run_dialog, GS, FIRST_RUN_DIALOG, HdyWindow)
GtkWidget *gs_first_run_dialog_new (void);
diff --git a/src/gs-first-run-dialog.ui b/src/gs-first-run-dialog.ui
index f3adacef2..012f76ea0 100644
--- a/src/gs-first-run-dialog.ui
+++ b/src/gs-first-run-dialog.ui
@@ -2,75 +2,44 @@
<!-- Generated with glade 3.18.1 -->
<interface>
<requires lib="gtk+" version="3.12"/>
- <template class="GsFirstRunDialog" parent="GtkDialog">
- <property name="title" translatable="yes">Welcome</property>
+ <template class="GsFirstRunDialog" parent="HdyWindow">
<property name="modal">True</property>
- <property name="resizable">False</property>
+ <property name="window_position">center</property>
<property name="destroy_with_parent">True</property>
+ <property name="icon_name">dialog-information</property>
+ <property name="title" translatable="yes">Welcome</property>
<property name="type_hint">dialog</property>
+ <property name="default-width">640</property>
+ <property name="default-height">576</property>
<property name="skip_taskbar_hint">True</property>
- <property name="use_header_bar">1</property>
- <child internal-child="headerbar">
- <object class="GtkHeaderBar">
- <property name="title" translatable="yes">Welcome</property>
- <property name="show_close_button">False</property>
- </object>
- </child>
- <child internal-child="vbox">
- <object class="GtkBox" id="dialog-vbox1">
- <property name="margin_start">55</property>
- <property name="margin_end">55</property>
- <property name="margin_top">44</property>
- <property name="orientation">vertical</property>
+ <signal name="key-press-event" handler="key_press_event_cb" after="yes" swapped="no"/>
+ <style>
+ <class name="toolbox"/>
+ </style>
+
+ <child>
+ <object class="HdyWindowHandle">
+ <property name="visible">True</property>
<child>
- <object class="GtkBox" id="box_empty">
+ <object class="HdyStatusPage">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="spacing">16</property>
+ <property name="icon_name">org.gnome.Software</property>
+ <property name="title" translatable="yes">Welcome to Software</property>
+ <property name="description" translatable="yes">Software lets you install all the software you
need, all from one place. See our recommendations, browse the categories, or search for the applications you
want.</property>
<child>
- <object class="GtkImage" id="image1">
+ <object class="GtkButton" id="button">
+ <property name="label" translatable="yes">_Browse Software</property>
<property name="visible">True</property>
- <property name="pixel_size">128</property>
- <property name="icon_name">org.gnome.Software</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="use_underline">True</property>
<style>
- <class name="icon-dropshadow"/>
+ <class name="suggested-action"/>
</style>
</object>
</child>
- <child>
- <object class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Welcome to Software</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- <attribute name="scale" value="1.7"/>
- </attributes>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="label2">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Software lets you install all the software you
need, all from one place. See our recommendations, browse the categories, or search for the applications you
want.</property>
- <property name="wrap">True</property>
- <property name="max_width_chars">48</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkButton" id="button">
- <property name="label" translatable="yes">_Browse Software</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
- <property name="margin_top">23</property>
- <property name="margin_bottom">26</property>
- <property name="use_underline">True</property>
- <style>
- <class name="suggested-action"/>
- </style>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]