calendar-management: Switch to HdyWindow
Make GcalCalendarManagementDialog an HdyWindow subclass, and adapt the widgetry to work with the new parent class. Use HdyHeaderBar everywhere.
This commit is contained in:
@@ -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,13 +184,19 @@ on_page_switched_cb (GcalCalendarManagementPage *page,
|
||||
GCAL_EXIT;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* GtkWidget overrides
|
||||
*/
|
||||
|
||||
static void
|
||||
on_dialog_response_signal_cb (GtkDialog *dialog,
|
||||
gint response_id,
|
||||
GcalCalendarManagementDialog *self)
|
||||
gcal_calendar_management_dialog_hide (GtkWidget *widget)
|
||||
{
|
||||
GcalCalendarManagementDialog *self = (GcalCalendarManagementDialog *) widget;
|
||||
|
||||
set_page (self, "calendars", NULL);
|
||||
gtk_widget_hide (GTK_WIDGET (dialog));
|
||||
|
||||
GTK_WIDGET_CLASS (gcal_calendar_management_dialog_parent_class)->hide (widget);
|
||||
}
|
||||
|
||||
|
||||
@@ -198,22 +204,6 @@ on_dialog_response_signal_cb (GtkDialog *dialog,
|
||||
* GObject overrides
|
||||
*/
|
||||
|
||||
static void
|
||||
gcal_calendar_management_dialog_constructed (GObject *object)
|
||||
{
|
||||
GcalCalendarManagementDialog *self;
|
||||
|
||||
self = GCAL_CALENDAR_MANAGEMENT_DIALOG (object);
|
||||
|
||||
G_OBJECT_CLASS (gcal_calendar_management_dialog_parent_class)->constructed (object);
|
||||
|
||||
/* widget responses */
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (object), GTK_RESPONSE_CANCEL);
|
||||
|
||||
/* setup titlebar */
|
||||
gtk_window_set_titlebar (GTK_WINDOW (object), self->headerbar);
|
||||
}
|
||||
|
||||
static void
|
||||
gcal_calendar_management_dialog_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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="GtkStack" id="stack">
|
||||
<object class="HdyHeaderBar" id="headerbar">
|
||||
<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>
|
||||
<property name="title" translatable="yes">Calendar Settings</property>
|
||||
<property name="show_close_button">True</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>
|
||||
<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>
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user