[gnome-calendar/gbsneto/open-files: 1/6] calendar-management: Switch to HdyWindow
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/gbsneto/open-files: 1/6] calendar-management: Switch to HdyWindow
- Date: Mon, 16 Aug 2021 18:31:34 +0000 (UTC)
commit 8c71c60e8dc7a0eb16233cd236d0d081909148a7
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Aug 6 17:32:01 2021 -0300
calendar-management: Switch to HdyWindow
Make GcalCalendarManagementDialog an HdyWindow subclass,
and adapt the widgetry to work with the new parent class.
Use HdyHeaderBar everywhere.
.../gcal-calendar-management-dialog.c | 49 ++++++++++------------
.../gcal-calendar-management-dialog.h | 7 ++--
.../gcal-calendar-management-dialog.ui | 48 +++++++++++----------
.../gcal-calendar-management-page.c | 5 ++-
.../gcal-calendar-management-page.h | 4 +-
.../calendar-management/gcal-edit-calendar-page.c | 6 +--
.../calendar-management/gcal-new-calendar-page.c | 12 +++---
7 files changed, 67 insertions(+), 64 deletions(-)
---
diff --git a/src/gui/calendar-management/gcal-calendar-management-dialog.c
b/src/gui/calendar-management/gcal-calendar-management-dialog.c
index ded20cb1..7163cbbe 100644
--- a/src/gui/calendar-management/gcal-calendar-management-dialog.c
+++ b/src/gui/calendar-management/gcal-calendar-management-dialog.c
@@ -55,9 +55,9 @@ typedef enum
struct _GcalCalendarManagementDialog
{
- GtkDialog parent;
+ HdyWindow parent;
- GtkWidget *headerbar;
+ HdyHeaderBar *headerbar;
GtkWidget *notebook;
GtkWidget *stack;
@@ -77,7 +77,7 @@ static void on_page_switched_cb (GcalCalendarMa
GcalCalendar *calendar,
GcalCalendarManagementDialog *self);
-G_DEFINE_TYPE (GcalCalendarManagementDialog, gcal_calendar_management_dialog, GTK_TYPE_DIALOG)
+G_DEFINE_TYPE (GcalCalendarManagementDialog, gcal_calendar_management_dialog, HDY_TYPE_WINDOW)
enum
{
@@ -115,7 +115,7 @@ set_page (GcalCalendarManagementDialog *self,
gtk_stack_set_visible_child (GTK_STACK (self->stack), GTK_WIDGET (page));
gcal_calendar_management_page_activate (page, calendar);
- gtk_header_bar_set_title (GTK_HEADER_BAR (self->headerbar),
+ hdy_header_bar_set_title (self->headerbar,
gcal_calendar_management_page_get_title (page));
break;
}
@@ -184,35 +184,25 @@ on_page_switched_cb (GcalCalendarManagementPage *page,
GCAL_EXIT;
}
-static void
-on_dialog_response_signal_cb (GtkDialog *dialog,
- gint response_id,
- GcalCalendarManagementDialog *self)
-{
- set_page (self, "calendars", NULL);
- gtk_widget_hide (GTK_WIDGET (dialog));
-}
-
/*
- * GObject overrides
+ * GtkWidget overrides
*/
static void
-gcal_calendar_management_dialog_constructed (GObject *object)
+gcal_calendar_management_dialog_hide (GtkWidget *widget)
{
- GcalCalendarManagementDialog *self;
+ GcalCalendarManagementDialog *self = (GcalCalendarManagementDialog *) widget;
- self = GCAL_CALENDAR_MANAGEMENT_DIALOG (object);
+ set_page (self, "calendars", NULL);
- G_OBJECT_CLASS (gcal_calendar_management_dialog_parent_class)->constructed (object);
+ GTK_WIDGET_CLASS (gcal_calendar_management_dialog_parent_class)->hide (widget);
+}
- /* widget responses */
- gtk_dialog_set_default_response (GTK_DIALOG (object), GTK_RESPONSE_CANCEL);
- /* setup titlebar */
- gtk_window_set_titlebar (GTK_WINDOW (object), self->headerbar);
-}
+/*
+ * GObject overrides
+ */
static void
gcal_calendar_management_dialog_get_property (GObject *object,
@@ -262,10 +252,11 @@ gcal_calendar_management_dialog_class_init (GcalCalendarManagementDialogClass *k
g_type_ensure (E_TYPE_SOURCE_LOCAL);
- object_class->constructed = gcal_calendar_management_dialog_constructed;
object_class->get_property = gcal_calendar_management_dialog_get_property;
object_class->set_property = gcal_calendar_management_dialog_set_property;
+ widget_class->hide = gcal_calendar_management_dialog_hide;
+
properties[PROP_CONTEXT] = g_param_spec_object ("context",
"Context",
"The context object of the application",
@@ -278,8 +269,6 @@ gcal_calendar_management_dialog_class_init (GcalCalendarManagementDialogClass *k
gtk_widget_class_bind_template_child (widget_class, GcalCalendarManagementDialog, headerbar);
gtk_widget_class_bind_template_child (widget_class, GcalCalendarManagementDialog, stack);
-
- gtk_widget_class_bind_template_callback (widget_class, on_dialog_response_signal_cb);
}
static void
@@ -287,3 +276,11 @@ gcal_calendar_management_dialog_init (GcalCalendarManagementDialog *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
}
+
+HdyHeaderBar*
+gcal_calendar_management_dialog_get_titlebar (GcalCalendarManagementDialog *self)
+{
+ g_return_val_if_fail (GCAL_IS_CALENDAR_MANAGEMENT_DIALOG (self), NULL);
+
+ return HDY_HEADER_BAR (self->headerbar);
+}
diff --git a/src/gui/calendar-management/gcal-calendar-management-dialog.h
b/src/gui/calendar-management/gcal-calendar-management-dialog.h
index 77b2244a..8bae5a54 100644
--- a/src/gui/calendar-management/gcal-calendar-management-dialog.h
+++ b/src/gui/calendar-management/gcal-calendar-management-dialog.h
@@ -19,12 +19,11 @@
#pragma once
-#include <glib-object.h>
#include "gcal-application.h"
#include "gcal-manager.h"
#include <libecal/libecal.h>
-#include <gtk/gtk.h>
+#include <handy.h>
G_BEGIN_DECLS
@@ -35,6 +34,8 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GcalCalendarManagementDialog,
gcal_calendar_management_dialog,
GCAL, CALENDAR_MANAGEMENT_DIALOG,
- GtkDialog)
+ HdyWindow)
+
+HdyHeaderBar* gcal_calendar_management_dialog_get_titlebar (GcalCalendarManagementDialog *self);
G_END_DECLS
diff --git a/src/gui/calendar-management/gcal-calendar-management-dialog.ui
b/src/gui/calendar-management/gcal-calendar-management-dialog.ui
index db24f5ff..cb277102 100644
--- a/src/gui/calendar-management/gcal-calendar-management-dialog.ui
+++ b/src/gui/calendar-management/gcal-calendar-management-dialog.ui
@@ -2,7 +2,7 @@
<!-- Generated with glade 3.18.1 -->
<interface>
<requires lib="gtk+" version="3.15"/>
- <template class="GcalCalendarManagementDialog" parent="GtkDialog">
+ <template class="GcalCalendarManagementDialog" parent="HdyWindow">
<property name="width_request">450</property>
<property name="can_focus">False</property>
<property name="border_width">0</property>
@@ -12,36 +12,40 @@
<property name="modal">True</property>
<property name="destroy_with_parent">True</property>
<property name="modal">True</property>
- <signal name="response" handler="on_dialog_response_signal_cb" object="GcalCalendarManagementDialog"
swapped="no"/>
- <child internal-child="vbox">
- <object class="GtkBox" id="vbox">
- <property name="orientation">vertical</property>
- <property name="border_width">0</property>
+ <child>
+ <object class="HdyDeck">
+ <property name="visible">True</property>
<child>
- <object class="GtkOverlay" id="overlay">
+ <object class="GtkBox" id="vbox">
<property name="visible">True</property>
+ <property name="orientation">vertical</property>
+
+ <child>
+ <object class="HdyHeaderBar" id="headerbar">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Calendar Settings</property>
+ <property name="show_close_button">True</property>
+ </object>
+ </child>
+
<child>
- <object class="GtkStack" id="stack">
+ <object class="GtkOverlay" id="overlay">
<property name="visible">True</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="vhomogeneous">False</property>
- <property name="transition_type">crossfade</property>
+ <child>
+ <object class="GtkStack" id="stack">
+ <property name="visible">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="vhomogeneous">False</property>
+ <property name="transition_type">crossfade</property>
+ </object>
+ </child>
</object>
</child>
+
</object>
- <packing>
- <property name="position">1</property>
- </packing>
</child>
</object>
</child>
- <child type="titlebar">
- <object class="GtkHeaderBar" id="headerbar">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Calendar Settings</property>
- <property name="show_close_button">True</property>
- </object>
- </child>
</template>
</interface>
diff --git a/src/gui/calendar-management/gcal-calendar-management-page.c
b/src/gui/calendar-management/gcal-calendar-management-page.c
index 9e1103cf..76d24f65 100644
--- a/src/gui/calendar-management/gcal-calendar-management-page.c
+++ b/src/gui/calendar-management/gcal-calendar-management-page.c
@@ -20,6 +20,7 @@
#define G_LOG_DOMAIN "GcalCalendarManagementPage"
+#include "gcal-calendar-management-dialog.h"
#include "gcal-calendar-management-page.h"
#include "gcal-context.h"
@@ -107,7 +108,7 @@ gcal_calendar_management_page_switch_page (GcalCalendarManagementPage *self,
g_signal_emit (self, signals[SWITCH_PAGE], 0, page_name, calendar);
}
-GtkHeaderBar*
+HdyHeaderBar*
gcal_calendar_management_page_get_titlebar (GcalCalendarManagementPage *self)
{
GtkWidget *toplevel;
@@ -115,5 +116,5 @@ gcal_calendar_management_page_get_titlebar (GcalCalendarManagementPage *self)
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
g_assert (toplevel != NULL);
- return GTK_HEADER_BAR (gtk_window_get_titlebar (GTK_WINDOW (toplevel)));
+ return gcal_calendar_management_dialog_get_titlebar (GCAL_CALENDAR_MANAGEMENT_DIALOG (toplevel));
}
diff --git a/src/gui/calendar-management/gcal-calendar-management-page.h
b/src/gui/calendar-management/gcal-calendar-management-page.h
index 525c64af..b7f4d2d1 100644
--- a/src/gui/calendar-management/gcal-calendar-management-page.h
+++ b/src/gui/calendar-management/gcal-calendar-management-page.h
@@ -20,7 +20,7 @@
#pragma once
-#include <gtk/gtk.h>
+#include <handy.h>
#include "gcal-calendar.h"
@@ -61,6 +61,6 @@ void gcal_calendar_management_page_switch_page (GcalCalendarMa
const gchar *page_name,
GcalCalendar *calendar);
-GtkHeaderBar* gcal_calendar_management_page_get_titlebar (GcalCalendarManagementPage *self);
+HdyHeaderBar* gcal_calendar_management_page_get_titlebar (GcalCalendarManagementPage *self);
G_END_DECLS
diff --git a/src/gui/calendar-management/gcal-edit-calendar-page.c
b/src/gui/calendar-management/gcal-edit-calendar-page.c
index 97311daa..ab15f485 100644
--- a/src/gui/calendar-management/gcal-edit-calendar-page.c
+++ b/src/gui/calendar-management/gcal-edit-calendar-page.c
@@ -307,11 +307,11 @@ gcal_edit_calendar_page_activate (GcalCalendarManagementPage *page,
GcalCalendar *calendar)
{
GcalEditCalendarPage *self;
- GtkHeaderBar *headerbar;
+ HdyHeaderBar *headerbar;
self = GCAL_EDIT_CALENDAR_PAGE (page);
headerbar = gcal_calendar_management_page_get_titlebar (page);
- gtk_header_bar_pack_start (headerbar, self->back_button);
+ hdy_header_bar_pack_start (headerbar, self->back_button);
setup_calendar (self, calendar);
}
@@ -320,7 +320,7 @@ static void
gcal_edit_calendar_page_deactivate (GcalCalendarManagementPage *page)
{
GcalEditCalendarPage *self;
- GtkHeaderBar *headerbar;
+ HdyHeaderBar *headerbar;
GcalManager *manager;
GCAL_ENTRY;
diff --git a/src/gui/calendar-management/gcal-new-calendar-page.c
b/src/gui/calendar-management/gcal-new-calendar-page.c
index 04bcde42..91d3cf4d 100644
--- a/src/gui/calendar-management/gcal-new-calendar-page.c
+++ b/src/gui/calendar-management/gcal-new-calendar-page.c
@@ -518,16 +518,16 @@ gcal_new_calendar_page_activate (GcalCalendarManagementPage *page,
GcalCalendar *calendar)
{
GcalNewCalendarPage *self;
- GtkHeaderBar *headerbar;
+ HdyHeaderBar *headerbar;
GCAL_ENTRY;
self = GCAL_NEW_CALENDAR_PAGE (page);
headerbar = gcal_calendar_management_page_get_titlebar (page);
- gtk_header_bar_pack_start (headerbar, self->cancel_button);
- gtk_header_bar_pack_end (headerbar, self->add_button);
- gtk_header_bar_set_show_close_button (headerbar, FALSE);
+ hdy_header_bar_pack_start (headerbar, self->cancel_button);
+ hdy_header_bar_pack_end (headerbar, self->add_button);
+ hdy_header_bar_set_show_close_button (headerbar, FALSE);
GCAL_EXIT;
}
@@ -535,7 +535,7 @@ static void
gcal_new_calendar_page_deactivate (GcalCalendarManagementPage *page)
{
GcalNewCalendarPage *self;
- GtkHeaderBar *headerbar;
+ HdyHeaderBar *headerbar;
GCAL_ENTRY;
@@ -544,7 +544,7 @@ gcal_new_calendar_page_deactivate (GcalCalendarManagementPage *page)
gtk_container_remove (GTK_CONTAINER (headerbar), self->cancel_button);
gtk_container_remove (GTK_CONTAINER (headerbar), self->add_button);
- gtk_header_bar_set_show_close_button (headerbar, TRUE);
+ hdy_header_bar_set_show_close_button (headerbar, TRUE);
g_clear_object (&self->local_source);
g_clear_pointer (&self->remote_sources, g_ptr_array_unref);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]