[gnome-calendar/gbsneto/gtk4: 14/46] calendar-management-dialog: Port to GTK4
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/gbsneto/gtk4: 14/46] calendar-management-dialog: Port to GTK4
- Date: Sat, 12 Feb 2022 16:25:50 +0000 (UTC)
commit 2b834b27ffd5ec700bdf2049fdf8583581ce517a
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Jan 11 16:55:59 2022 -0300
calendar-management-dialog: Port to GTK4
Subclass AdwWindow. Adjust the API to return GtkHeaderBar
instead of HdyHeaderBar.
.../gcal-calendar-management-dialog.c | 16 +++++++------
.../gcal-calendar-management-dialog.h | 6 ++---
.../gcal-calendar-management-dialog.ui | 26 +++++++++-------------
.../gcal-calendar-management-page.c | 10 ++++-----
.../gcal-calendar-management-page.h | 2 +-
.../calendar-management/gcal-edit-calendar-page.c | 8 +++----
.../calendar-management/gcal-new-calendar-page.c | 16 ++++++-------
src/gui/gcal-window.ui | 1 -
8 files changed, 40 insertions(+), 45 deletions(-)
---
diff --git a/src/gui/calendar-management/gcal-calendar-management-dialog.c
b/src/gui/calendar-management/gcal-calendar-management-dialog.c
index e019b402..b480b926 100644
--- a/src/gui/calendar-management/gcal-calendar-management-dialog.c
+++ b/src/gui/calendar-management/gcal-calendar-management-dialog.c
@@ -54,11 +54,12 @@ typedef enum
struct _GcalCalendarManagementDialog
{
- HdyWindow parent;
+ AdwWindow parent;
- HdyHeaderBar *headerbar;
+ GtkHeaderBar *headerbar;
GtkWidget *notebook;
GtkWidget *stack;
+ AdwWindowTitle *window_title;
/* flags */
ESource *source;
@@ -76,7 +77,7 @@ static void on_page_switched_cb (GcalCalendarMa
GcalCalendar *calendar,
GcalCalendarManagementDialog *self);
-G_DEFINE_TYPE (GcalCalendarManagementDialog, gcal_calendar_management_dialog, HDY_TYPE_WINDOW)
+G_DEFINE_TYPE (GcalCalendarManagementDialog, gcal_calendar_management_dialog, ADW_TYPE_WINDOW)
enum
{
@@ -114,8 +115,8 @@ set_page (GcalCalendarManagementDialog *self,
gtk_stack_set_visible_child (GTK_STACK (self->stack), GTK_WIDGET (page));
gcal_calendar_management_page_activate (page, calendar);
- hdy_header_bar_set_title (self->headerbar,
- gcal_calendar_management_page_get_title (page));
+ adw_window_title_set_title (self->window_title,
+ gcal_calendar_management_page_get_title (page));
break;
}
@@ -268,6 +269,7 @@ 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_child (widget_class, GcalCalendarManagementDialog, window_title);
}
static void
@@ -276,10 +278,10 @@ gcal_calendar_management_dialog_init (GcalCalendarManagementDialog *self)
gtk_widget_init_template (GTK_WIDGET (self));
}
-HdyHeaderBar*
+GtkHeaderBar*
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);
+ return 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 8bae5a54..bcbde11f 100644
--- a/src/gui/calendar-management/gcal-calendar-management-dialog.h
+++ b/src/gui/calendar-management/gcal-calendar-management-dialog.h
@@ -23,7 +23,7 @@
#include "gcal-manager.h"
#include <libecal/libecal.h>
-#include <handy.h>
+#include <adwaita.h>
G_BEGIN_DECLS
@@ -34,8 +34,8 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GcalCalendarManagementDialog,
gcal_calendar_management_dialog,
GCAL, CALENDAR_MANAGEMENT_DIALOG,
- HdyWindow)
+ AdwWindow)
-HdyHeaderBar* gcal_calendar_management_dialog_get_titlebar (GcalCalendarManagementDialog *self);
+GtkHeaderBar* 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 cb277102..7ef29448 100644
--- a/src/gui/calendar-management/gcal-calendar-management-dialog.ui
+++ b/src/gui/calendar-management/gcal-calendar-management-dialog.ui
@@ -1,39 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.1 -->
<interface>
- <requires lib="gtk+" version="3.15"/>
- <template class="GcalCalendarManagementDialog" parent="HdyWindow">
+ <template class="GcalCalendarManagementDialog" parent="AdwWindow">
+ <property name="title" translatable="yes">Calendar Settings</property>
<property name="width_request">450</property>
- <property name="can_focus">False</property>
- <property name="border_width">0</property>
<property name="default_width">550</property>
<property name="default_height">500</property>
- <property name="type_hint">dialog</property>
<property name="modal">True</property>
<property name="destroy_with_parent">True</property>
- <property name="modal">True</property>
+ <property name="hide-on-close">True</property>
<child>
- <object class="HdyDeck">
- <property name="visible">True</property>
+ <object class="AdwLeaflet">
+ <property name="can-unfold">False</property>
<child>
<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 class="GtkHeaderBar" id="headerbar">
+ <property name="show-title-buttons">True</property>
+ <property name="title-widget">
+ <object class="AdwWindowTitle" id="window_title" />
+ </property>
</object>
</child>
<child>
<object class="GtkOverlay" id="overlay">
- <property name="visible">True</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>
diff --git a/src/gui/calendar-management/gcal-calendar-management-page.c
b/src/gui/calendar-management/gcal-calendar-management-page.c
index 76d24f65..4575ddb2 100644
--- a/src/gui/calendar-management/gcal-calendar-management-page.c
+++ b/src/gui/calendar-management/gcal-calendar-management-page.c
@@ -108,13 +108,13 @@ gcal_calendar_management_page_switch_page (GcalCalendarManagementPage *self,
g_signal_emit (self, signals[SWITCH_PAGE], 0, page_name, calendar);
}
-HdyHeaderBar*
+GtkHeaderBar*
gcal_calendar_management_page_get_titlebar (GcalCalendarManagementPage *self)
{
- GtkWidget *toplevel;
+ GtkNative *native;
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
- g_assert (toplevel != NULL);
+ native = gtk_widget_get_native (GTK_WIDGET (self));
+ g_assert (native != NULL);
- return gcal_calendar_management_dialog_get_titlebar (GCAL_CALENDAR_MANAGEMENT_DIALOG (toplevel));
+ return gcal_calendar_management_dialog_get_titlebar (GCAL_CALENDAR_MANAGEMENT_DIALOG (native));
}
diff --git a/src/gui/calendar-management/gcal-calendar-management-page.h
b/src/gui/calendar-management/gcal-calendar-management-page.h
index b7f4d2d1..9031f7df 100644
--- a/src/gui/calendar-management/gcal-calendar-management-page.h
+++ b/src/gui/calendar-management/gcal-calendar-management-page.h
@@ -61,6 +61,6 @@ void gcal_calendar_management_page_switch_page (GcalCalendarMa
const gchar *page_name,
GcalCalendar *calendar);
-HdyHeaderBar* gcal_calendar_management_page_get_titlebar (GcalCalendarManagementPage *self);
+GtkHeaderBar* 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 ab15f485..8b60aea4 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;
- HdyHeaderBar *headerbar;
+ GtkHeaderBar *headerbar;
self = GCAL_EDIT_CALENDAR_PAGE (page);
headerbar = gcal_calendar_management_page_get_titlebar (page);
- hdy_header_bar_pack_start (headerbar, self->back_button);
+ gtk_header_bar_pack_start (headerbar, self->back_button);
setup_calendar (self, calendar);
}
@@ -320,14 +320,14 @@ static void
gcal_edit_calendar_page_deactivate (GcalCalendarManagementPage *page)
{
GcalEditCalendarPage *self;
- HdyHeaderBar *headerbar;
+ GtkHeaderBar *headerbar;
GcalManager *manager;
GCAL_ENTRY;
self = GCAL_EDIT_CALENDAR_PAGE (page);
headerbar = gcal_calendar_management_page_get_titlebar (page);
- gtk_container_remove (GTK_CONTAINER (headerbar), self->back_button);
+ gtk_header_bar_remove (headerbar, self->back_button);
update_calendar (self);
diff --git a/src/gui/calendar-management/gcal-new-calendar-page.c
b/src/gui/calendar-management/gcal-new-calendar-page.c
index 91d3cf4d..e8fa9895 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;
- HdyHeaderBar *headerbar;
+ GtkHeaderBar *headerbar;
GCAL_ENTRY;
self = GCAL_NEW_CALENDAR_PAGE (page);
headerbar = gcal_calendar_management_page_get_titlebar (page);
- 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);
+ gtk_header_bar_pack_start (headerbar, self->cancel_button);
+ gtk_header_bar_pack_end (headerbar, self->add_button);
+ gtk_header_bar_set_show_title_buttons (headerbar, FALSE);
GCAL_EXIT;
}
@@ -535,16 +535,16 @@ static void
gcal_new_calendar_page_deactivate (GcalCalendarManagementPage *page)
{
GcalNewCalendarPage *self;
- HdyHeaderBar *headerbar;
+ GtkHeaderBar *headerbar;
GCAL_ENTRY;
self = GCAL_NEW_CALENDAR_PAGE (page);
headerbar = gcal_calendar_management_page_get_titlebar (page);
- gtk_container_remove (GTK_CONTAINER (headerbar), self->cancel_button);
- gtk_container_remove (GTK_CONTAINER (headerbar), self->add_button);
- hdy_header_bar_set_show_close_button (headerbar, TRUE);
+ gtk_header_bar_remove (headerbar, self->cancel_button);
+ gtk_header_bar_remove (headerbar, self->add_button);
+ gtk_header_bar_set_show_title_buttons (headerbar, TRUE);
g_clear_object (&self->local_source);
g_clear_pointer (&self->remote_sources, g_ptr_array_unref);
diff --git a/src/gui/gcal-window.ui b/src/gui/gcal-window.ui
index 814bead7..6f86408f 100644
--- a/src/gui/gcal-window.ui
+++ b/src/gui/gcal-window.ui
@@ -235,7 +235,6 @@
<object class="GcalCalendarManagementDialog" id="calendar_management_dialog">
<property name="visible">False</property>
<property name="transient_for">GcalWindow</property>
- <signal name="delete-event" handler="gtk_widget_hide_on_delete" object="GcalWindow" swapped="no" />
</object>
<object class="GcalEventEditorDialog" id="event_editor">
<property name="visible">False</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]