[gnome-software/1385-version-history-dialog-has-non-rounded-corners] gs-app-version-history-dialog: Turn it to HdyWindow descendant
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1385-version-history-dialog-has-non-rounded-corners] gs-app-version-history-dialog: Turn it to HdyWindow descendant
- Date: Wed, 15 Sep 2021 13:29:19 +0000 (UTC)
commit 4aae39e10bb76c484064db7c3b4fb40b9409807f
Author: Milan Crha <mcrha redhat com>
Date: Wed Sep 15 15:24:04 2021 +0200
gs-app-version-history-dialog: Turn it to HdyWindow descendant
This will present the window consistently with the other similar windows
in the Software.
Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1385
src/gs-app-version-history-dialog.c | 37 +++++++++++++++++++++++++++++++++---
src/gs-app-version-history-dialog.h | 2 +-
src/gs-app-version-history-dialog.ui | 30 +++++++++++++++++++----------
src/gs-details-page.c | 4 ----
4 files changed, 55 insertions(+), 18 deletions(-)
---
diff --git a/src/gs-app-version-history-dialog.c b/src/gs-app-version-history-dialog.c
index 8b61b7c2b..b845df360 100644
--- a/src/gs-app-version-history-dialog.c
+++ b/src/gs-app-version-history-dialog.c
@@ -8,6 +8,8 @@
#include "config.h"
+#include <handy.h>
+
#include "gs-app-version-history-dialog.h"
#include "gnome-software-private.h"
@@ -17,12 +19,12 @@
struct _GsAppVersionHistoryDialog
{
- GtkDialog parent_instance;
+ HdyWindow parent_instance;
GsApp *app;
GtkWidget *listbox;
};
-G_DEFINE_TYPE (GsAppVersionHistoryDialog, gs_app_version_history_dialog, GTK_TYPE_DIALOG)
+G_DEFINE_TYPE (GsAppVersionHistoryDialog, gs_app_version_history_dialog, HDY_TYPE_WINDOW)
static void
populate_version_history (GsAppVersionHistoryDialog *dialog,
@@ -61,6 +63,35 @@ populate_version_history (GsAppVersionHistoryDialog *dialog,
}
}
+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
gs_app_version_history_dialog_init (GsAppVersionHistoryDialog *dialog)
{
@@ -75,6 +106,7 @@ gs_app_version_history_dialog_class_init (GsAppVersionHistoryDialogClass *klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/Software/gs-app-version-history-dialog.ui");
gtk_widget_class_bind_template_child (widget_class, GsAppVersionHistoryDialog, listbox);
+ gtk_widget_class_bind_template_callback (widget_class, key_press_event_cb);
}
GtkWidget *
@@ -83,7 +115,6 @@ gs_app_version_history_dialog_new (GtkWindow *parent, GsApp *app)
GsAppVersionHistoryDialog *dialog;
dialog = g_object_new (GS_TYPE_APP_VERSION_HISTORY_DIALOG,
- "use-header-bar", TRUE,
"transient-for", parent,
"modal", TRUE,
NULL);
diff --git a/src/gs-app-version-history-dialog.h b/src/gs-app-version-history-dialog.h
index 6abed18e2..39081fe6a 100644
--- a/src/gs-app-version-history-dialog.h
+++ b/src/gs-app-version-history-dialog.h
@@ -16,7 +16,7 @@ G_BEGIN_DECLS
#define GS_TYPE_APP_VERSION_HISTORY_DIALOG (gs_app_version_history_dialog_get_type ())
-G_DECLARE_FINAL_TYPE (GsAppVersionHistoryDialog, gs_app_version_history_dialog, GS,
APP_VERSION_HISTORY_DIALOG, GtkDialog)
+G_DECLARE_FINAL_TYPE (GsAppVersionHistoryDialog, gs_app_version_history_dialog, GS,
APP_VERSION_HISTORY_DIALOG, HdyWindow)
GtkWidget *gs_app_version_history_dialog_new (GtkWindow *parent,
GsApp *app);
diff --git a/src/gs-app-version-history-dialog.ui b/src/gs-app-version-history-dialog.ui
index ede850ad2..fd3d5df31 100644
--- a/src/gs-app-version-history-dialog.ui
+++ b/src/gs-app-version-history-dialog.ui
@@ -2,21 +2,31 @@
<interface>
<requires lib="gtk+" version="3.10"/>
<requires lib="handy" version="1.0"/>
- <template class="GsAppVersionHistoryDialog" parent="GtkDialog">
+ <template class="GsAppVersionHistoryDialog" parent="HdyWindow">
+ <property name="modal">True</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">Version History</property>
- <property name="default_width">550</property>
- <property name="default_height">600</property>
- <property name="width_request">360</property>
- <property name="height_request">400</property>
- <property name="use_header_bar">1</property>
- <child internal-child="headerbar">
- <object class="HdyHeaderBar"/>
- </child>
- <child internal-child="vbox">
+ <property name="type_hint">dialog</property>
+ <property name="default-width">550</property>
+ <property name="default-height">600</property>
+ <property name="width-request">360</property>
+ <property name="height-request">400</property>
+ <signal name="key-press-event" handler="key_press_event_cb" after="yes" swapped="no"/>
+ <child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="border_width">0</property>
+ <child>
+ <object class="HdyHeaderBar">
+ <property name="show_close_button">True</property>
+ <property name="visible">True</property>
+ <property name="valign">start</property>
+ <property name="title" bind-source="GsAppVersionHistoryDialog" bind-property="title"
bind-flags="sync-create"/>
+ </object>
+ </child>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 2bfd57b92..c26e92c10 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -1178,10 +1178,6 @@ version_history_list_row_activated_cb (GtkListBox *list_box,
dialog = gs_app_version_history_dialog_new (GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET
(list_box), GTK_TYPE_WINDOW)),
self->app);
gs_shell_modal_dialog_present (self->shell, GTK_WINDOW (dialog));
-
- /* just destroy */
- g_signal_connect_swapped (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), dialog);
}
static void gs_details_page_addon_selected_cb (GsAppAddonRow *row, GParamSpec *pspec, GsDetailsPage *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]