[gnome-calendar/gbsneto/gtk4: 1/29] window: Port to GTK4
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/gbsneto/gtk4: 1/29] window: Port to GTK4
- Date: Thu, 27 Jan 2022 19:51:00 +0000 (UTC)
commit f107a8d7992208fa4da7bda0842176668ec45265
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Mon Jan 10 18:44:17 2022 -0300
window: Port to GTK4
Subclass AdwApplicationWindow.
src/gui/gcal-window.c | 217 ++++++++++--------------
src/gui/gcal-window.h | 9 +-
src/gui/gcal-window.ui | 440 ++++++++++++++++++++-----------------------------
3 files changed, 266 insertions(+), 400 deletions(-)
---
diff --git a/src/gui/gcal-window.c b/src/gui/gcal-window.c
index 75e937ab..f39c37cd 100644
--- a/src/gui/gcal-window.c
+++ b/src/gui/gcal-window.c
@@ -91,7 +91,7 @@ typedef struct
struct _GcalWindow
{
- HdyApplicationWindow parent;
+ AdwApplicationWindow parent;
/* timeout ids */
guint notification_timeout;
@@ -101,7 +101,7 @@ struct _GcalWindow
GtkWidget *header_bar;
GtkWidget *views_overlay;
- GtkWidget *views_stack;
+ AdwViewStack *views_stack;
GtkWidget *week_view;
GtkWidget *month_view;
GtkWidget *year_view;
@@ -119,9 +119,9 @@ struct _GcalWindow
GtkWidget *views_switcher;
GcalEventEditorDialog *event_editor;
- GtkWidget *import_dialog;
+ GtkWindow *import_dialog;
- DzlSuggestionButton *search_button;
+ GcalSearchButton *search_button;
/* new event popover widgets */
GtkWidget *quick_add_popover;
@@ -165,11 +165,6 @@ struct _GcalWindow
GtkCssProvider *colors_provider;
/* Window states */
- gint width;
- gint height;
- gint pos_x;
- gint pos_y;
- gboolean is_maximized;
gboolean in_key_press;
};
@@ -188,7 +183,7 @@ enum
gtk_application_set_accels_for_action (GTK_APPLICATION (app), action, tmp);\
}
-G_DEFINE_TYPE (GcalWindow, gcal_window, HDY_TYPE_APPLICATION_WINDOW)
+G_DEFINE_TYPE (GcalWindow, gcal_window, ADW_TYPE_APPLICATION_WINDOW)
static GParamSpec* properties[N_PROPS] = { NULL, };
@@ -278,49 +273,6 @@ update_active_date (GcalWindow *window,
GCAL_EXIT;
}
-static void
-load_geometry (GcalWindow *self)
-{
- GSettings *settings;
-
- GCAL_ENTRY;
-
- settings = gcal_context_get_settings (self->context);
-
- self->is_maximized = g_settings_get_boolean (settings, "window-maximized");
- g_settings_get (settings, "window-size", "(ii)", &self->width, &self->height);
- g_settings_get (settings, "window-position", "(ii)", &self->pos_x, &self->pos_y);
-
- if (self->is_maximized)
- {
- gtk_window_maximize (GTK_WINDOW (self));
- }
- else
- {
- gtk_window_set_default_size (GTK_WINDOW (self), self->width, self->height);
- if (self->pos_x >= 0)
- gtk_window_move (GTK_WINDOW (self), self->pos_x, self->pos_y);
- }
-
- GCAL_EXIT;
-}
-
-static void
-save_geometry (GcalWindow *self)
-{
- GSettings *settings;
-
- GCAL_ENTRY;
-
- settings = gcal_context_get_settings (self->context);
-
- g_settings_set_boolean (settings, "window-maximized", self->is_maximized);
- g_settings_set (settings, "window-size", "(ii)", self->width, self->height);
- g_settings_set (settings, "window-position", "(ii)", self->pos_x, self->pos_y);
-
- GCAL_EXIT;
-}
-
static void
recalculate_calendar_colors_css (GcalWindow *self)
{
@@ -354,7 +306,7 @@ recalculate_calendar_colors_css (GcalWindow *self)
}
new_css_data = g_strjoinv ("\n", new_css_snippets);
- gtk_css_provider_load_from_data (self->colors_provider, new_css_data, -1, &error);
+ gtk_css_provider_load_from_data (self->colors_provider, new_css_data, -1);
if (error)
g_warning ("Error creating custom stylesheet. %s", error->message);
@@ -366,15 +318,15 @@ load_css_providers (GcalWindow *self)
g_autoptr (GFile) css_file = NULL;
g_autofree gchar *theme_name = NULL;
g_autofree gchar *theme_uri = NULL;
- GdkScreen *screen;
+ GdkDisplay *display;
- screen = gtk_widget_get_screen (GTK_WIDGET (self));
+ display = gtk_widget_get_display (GTK_WIDGET (self));
/* Theme */
self->provider = gtk_css_provider_new ();
- gtk_style_context_add_provider_for_screen (screen,
- GTK_STYLE_PROVIDER (self->provider),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION + 1);
+ gtk_style_context_add_provider_for_display (display,
+ GTK_STYLE_PROVIDER (self->provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION + 1);
/* Retrieve the theme name */
g_object_get (gtk_settings_get_default (), "gtk-theme-name", &theme_name, NULL);
@@ -384,15 +336,15 @@ load_css_providers (GcalWindow *self)
css_file = g_file_new_for_uri (theme_uri);
if (g_file_query_exists (css_file, NULL))
- gtk_css_provider_load_from_file (self->provider, css_file, NULL);
+ gtk_css_provider_load_from_file (self->provider, css_file);
else
gtk_css_provider_load_from_resource (self->provider, "/org/gnome/calendar/theme/Adwaita.css");
/* Calendar olors */
self->colors_provider = gtk_css_provider_new ();
- gtk_style_context_add_provider_for_screen (screen,
- GTK_STYLE_PROVIDER (self->colors_provider),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION + 2);
+ gtk_style_context_add_provider_for_display (display,
+ GTK_STYLE_PROVIDER (self->colors_provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION + 2);
}
@@ -428,7 +380,7 @@ on_view_action_activated (GSimpleAction *action,
view = --(window->active_view);
window->active_view = CLAMP (view, GCAL_WINDOW_VIEW_WEEK, GCAL_WINDOW_VIEW_YEAR);
- gtk_stack_set_visible_child (GTK_STACK (window->views_stack), window->views[window->active_view]);
+ adw_view_stack_set_visible_child (window->views_stack, window->views[window->active_view]);
g_object_notify_by_pspec (G_OBJECT (user_data), properties[PROP_ACTIVE_VIEW]);
}
@@ -532,11 +484,11 @@ view_changed (GObject *object,
window = GCAL_WINDOW (user_data);
/* XXX: this is the destruction process */
- if (!gtk_widget_get_visible (window->views_stack))
+ if (!gtk_widget_get_visible (GTK_WIDGET (window->views_stack)))
return;
eklass = g_type_class_ref (GCAL_TYPE_WINDOW_VIEW);
- eval = g_enum_get_value_by_nick (eklass, gtk_stack_get_visible_child_name (GTK_STACK
(window->views_stack)));
+ eval = g_enum_get_value_by_nick (eklass, adw_view_stack_get_visible_child_name (window->views_stack));
view_type = eval->value;
@@ -579,7 +531,8 @@ show_new_event_widget (GcalView *view,
GcalWindow *window)
{
GdkRectangle rect;
- gint out_x, out_y;
+ gdouble out_x;
+ gdouble out_y;
GCAL_ENTRY;
@@ -606,7 +559,11 @@ show_new_event_widget (GcalView *view,
gcal_quick_add_popover_set_date_end (GCAL_QUICK_ADD_POPOVER (window->quick_add_popover), end_span);
/* Position and place the quick add popover */
- gtk_widget_translate_coordinates (window->views[window->active_view], window->views_stack, x, y, &out_x,
&out_y);
+ gtk_widget_translate_coordinates (window->views[window->active_view],
+ GTK_WIDGET (window),
+ x, y,
+ &out_x,
+ &out_y);
/* Place popover over the given (x,y) position */
rect.x = out_x;
@@ -641,7 +598,7 @@ create_notification (GcalWindow *window,
{
/* notification content */
gtk_label_set_markup (GTK_LABEL (window->notification_label), message);
- gtk_widget_show_all (window->notification);
+ gtk_widget_show (window->notification);
if (button_label != NULL)
{
@@ -670,22 +627,6 @@ hide_notification_scheduled (gpointer window)
return FALSE;
}
-static gboolean
-window_state_changed (GtkWidget *widget,
- GdkEvent *event,
- gpointer user_data)
-{
- GcalWindow *window;
- GdkEventWindowState *state;
-
- window = GCAL_WINDOW (widget);
- state = (GdkEventWindowState*) event;
-
- window->is_maximized = state->new_window_state & GDK_WINDOW_STATE_MAXIMIZED;
-
- return FALSE;
-}
-
static void
edit_event (GcalQuickAddPopover *popover,
GcalEvent *event,
@@ -871,8 +812,6 @@ gcal_window_finalize (GObject *object)
GCAL_ENTRY;
- save_geometry (window);
-
gcal_clear_timeout (&window->open_edit_dialog_timeout_id);
/* If we have a queued event to delete, remove it now */
@@ -904,10 +843,32 @@ gcal_window_finalize (GObject *object)
GCAL_EXIT;
}
+static void
+gcal_window_dispose (GObject *object)
+{
+ GcalTimeline *timeline;
+ GcalWindow *self;
+
+ self = GCAL_WINDOW (object);
+
+ timeline = gcal_manager_get_timeline (gcal_context_get_manager (self->context));
+ gcal_timeline_remove_subscriber (timeline, GCAL_TIMELINE_SUBSCRIBER (self->week_view));
+ gcal_timeline_remove_subscriber (timeline, GCAL_TIMELINE_SUBSCRIBER (self->month_view));
+ //gcal_timeline_remove_subscriber (timeline, GCAL_TIMELINE_SUBSCRIBER (self->year_view));
+
+ g_clear_pointer (&self->quick_add_popover, gtk_widget_unparent);
+
+ G_OBJECT_CLASS (gcal_window_parent_class)->dispose (object);
+}
+
static void
gcal_window_constructed (GObject *object)
{
GcalWindow *self;
+ GSettings *settings;
+ gboolean maximized;
+ gint height;
+ gint width;
GCAL_ENTRY;
@@ -916,7 +877,15 @@ gcal_window_constructed (GObject *object)
G_OBJECT_CLASS (gcal_window_parent_class)->constructed (object);
/* Load saved geometry *after* the construct-time properties are set */
- load_geometry (self);
+ settings = gcal_context_get_settings (self->context);
+
+ maximized = g_settings_get_boolean (settings, "window-maximized");
+ g_settings_get (settings, "window-size", "(ii)", &width, &height);
+
+ gtk_window_set_default_size (GTK_WINDOW (self), width, height);
+
+ if (maximized)
+ gtk_window_maximize (GTK_WINDOW (self));
/*
* FIXME: this is a hack around the issue that happens when trying to bind
@@ -960,7 +929,7 @@ gcal_window_set_property (GObject *object,
case PROP_ACTIVE_VIEW:
self->active_view = g_value_get_enum (value);
gtk_widget_show (self->views[self->active_view]);
- gtk_stack_set_visible_child (GTK_STACK (self->views_stack), self->views[self->active_view]);
+ adw_view_stack_set_visible_child (self->views_stack, self->views[self->active_view]);
break;
case PROP_ACTIVE_DATE:
@@ -1027,36 +996,26 @@ gcal_window_get_property (GObject *object,
*/
static void
-gcal_window_destroy (GtkWidget *widget)
+gcal_window_unmap (GtkWidget *widget)
{
- GcalTimeline *timeline;
GcalWindow *self;
+ GSettings *settings;
+ gint height;
+ gint width;
- self = GCAL_WINDOW (widget);
-
- timeline = gcal_manager_get_timeline (gcal_context_get_manager (self->context));
- gcal_timeline_remove_subscriber (timeline, GCAL_TIMELINE_SUBSCRIBER (self->week_view));
- gcal_timeline_remove_subscriber (timeline, GCAL_TIMELINE_SUBSCRIBER (self->month_view));
- gcal_timeline_remove_subscriber (timeline, GCAL_TIMELINE_SUBSCRIBER (self->year_view));
-
- GTK_WIDGET_CLASS (gcal_window_parent_class)->destroy (widget);
-}
+ GCAL_ENTRY;
-static gboolean
-gcal_window_configure_event (GtkWidget *widget,
- GdkEventConfigure *event)
-{
- GcalWindow *window;
- gboolean retval;
+ self = GCAL_WINDOW (widget);
+ settings = gcal_context_get_settings (self->context);
- window = GCAL_WINDOW (widget);
+ gtk_window_get_default_size (GTK_WINDOW (self), &width, &height);
- gtk_window_get_size (GTK_WINDOW (window), &window->width, &window->height);
- gtk_window_get_position (GTK_WINDOW (window), &window->pos_x, &window->pos_y);
+ g_settings_set_boolean (settings, "window-maximized", gtk_window_is_maximized (GTK_WINDOW (self)));
+ g_settings_set (settings, "window-size", "(ii)", width, height);
- retval = GTK_WIDGET_CLASS (gcal_window_parent_class)->configure_event (widget, event);
+ GTK_WIDGET_CLASS (gcal_window_parent_class)->unmap (widget);
- return retval;
+ GCAL_EXIT;
}
static void
@@ -1079,12 +1038,12 @@ gcal_window_class_init (GcalWindowClass *klass)
object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gcal_window_finalize;
object_class->constructed = gcal_window_constructed;
+ object_class->dispose = gcal_window_dispose;
object_class->set_property = gcal_window_set_property;
object_class->get_property = gcal_window_get_property;
widget_class = GTK_WIDGET_CLASS (klass);
- widget_class->configure_event = gcal_window_configure_event;
- widget_class->destroy = gcal_window_destroy;
+ widget_class->unmap = gcal_window_unmap;
properties[PROP_ACTIVE_DATE] = g_param_spec_boxed ("active-date",
@@ -1156,9 +1115,6 @@ gcal_window_class_init (GcalWindowClass *klass)
gtk_widget_class_bind_template_callback (widget_class, close_new_event_widget);
gtk_widget_class_bind_template_callback (widget_class, event_activated);
- /* Syncronization related */
- gtk_widget_class_bind_template_callback (widget_class, window_state_changed);
-
/* Edit dialog related */
gtk_widget_class_bind_template_callback (widget_class, on_event_editor_dialog_remove_event_cb);
}
@@ -1187,8 +1143,8 @@ gcal_window_init (GcalWindow *self)
gtk_widget_init_template (GTK_WIDGET (self));
/* Calendar icon */
- gtk_container_add (GTK_CONTAINER (self->calendars_button),
- gcal_calendar_popover_get_icon (GCAL_CALENDAR_POPOVER (self->calendar_popover)));
+ gtk_menu_button_set_child (GTK_MENU_BUTTON (self->calendars_button),
+ gcal_calendar_popover_get_icon (GCAL_CALENDAR_POPOVER
(self->calendar_popover)));
self->views[GCAL_WINDOW_VIEW_WEEK] = self->week_view;
self->views[GCAL_WINDOW_VIEW_MONTH] = self->month_view;
@@ -1197,12 +1153,6 @@ gcal_window_init (GcalWindow *self)
self->active_date = g_date_time_new_from_unix_local (0);
self->rtl = gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_RTL;
- /* Dzl shortcut support */
- g_signal_connect_object (self,
- "key-press-event",
- G_CALLBACK (dzl_shortcut_manager_handle_event),
- NULL,
- G_CONNECT_SWAPPED);
/* devel styling */
if (g_strcmp0 (PROFILE, "Devel") == 0)
{
@@ -1221,6 +1171,8 @@ gcal_window_init (GcalWindow *self)
gcal_window_add_accelerator (app, "win.change-view(2)", "<Ctrl>3");
gcal_window_add_accelerator (app, "app.quit", "<Ctrl>q");
gcal_window_add_accelerator (app, "win.new-event", "<Ctrl>n");
+
+ gtk_widget_set_parent (self->quick_add_popover, GTK_WIDGET (self));
}
/**
@@ -1256,12 +1208,13 @@ void
gcal_window_set_search_query (GcalWindow *self,
const gchar *query)
{
- DzlSuggestionEntry *entry;
+ //GtkEntry *entry;
g_return_if_fail (GCAL_IS_WINDOW (self));
- entry = dzl_suggestion_button_get_entry (self->search_button);
- gtk_entry_set_text (GTK_ENTRY (entry), query);
+ // TODO
+ //entry = gcal_search_button_get_entry (self->search_button);
+ //gtk_entry_set_text (GTK_ENTRY (entry), query);
}
/**
@@ -1279,7 +1232,7 @@ gcal_window_open_event_by_uuid (GcalWindow *self,
GList *widgets;
/* XXX: show events on month view */
- gtk_stack_set_visible_child (GTK_STACK (self->views_stack), self->month_view);
+ adw_view_stack_set_visible_child (self->views_stack, self->month_view);
widgets = gcal_view_get_children_by_uuid (GCAL_VIEW (self->month_view),
GCAL_RECURRENCE_MOD_THIS_ONLY,
@@ -1308,11 +1261,11 @@ gcal_window_import_files (GcalWindow *self,
{
g_return_if_fail (GCAL_IS_WINDOW (self));
- g_clear_pointer (&self->import_dialog, gtk_widget_destroy);
+ g_clear_pointer (&self->import_dialog, gtk_window_destroy);
- self->import_dialog = gcal_import_dialog_new_for_files (self->context, files, n_files);
- gtk_window_set_transient_for (GTK_WINDOW (self->import_dialog), GTK_WINDOW (self));
- gtk_window_present (GTK_WINDOW (self->import_dialog));
+ self->import_dialog = GTK_WINDOW (gcal_import_dialog_new_for_files (self->context, files, n_files));
+ gtk_window_set_transient_for (self->import_dialog, GTK_WINDOW (self));
+ gtk_window_present (self->import_dialog);
g_object_add_weak_pointer (G_OBJECT (self->import_dialog), (gpointer *)&self->import_dialog);
}
diff --git a/src/gui/gcal-window.h b/src/gui/gcal-window.h
index efde2434..f3777d83 100644
--- a/src/gui/gcal-window.h
+++ b/src/gui/gcal-window.h
@@ -16,21 +16,18 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef __GCAL_WINDOW_H__
-#define __GCAL_WINDOW_H__
+#pragma once
#include "gcal-application.h"
#include "gcal-enums.h"
#include "gcal-utils.h"
-#include <handy.h>
-
G_BEGIN_DECLS
#define GCAL_TYPE_WINDOW (gcal_window_get_type ())
-G_DECLARE_FINAL_TYPE (GcalWindow, gcal_window, GCAL, WINDOW, HdyApplicationWindow)
+G_DECLARE_FINAL_TYPE (GcalWindow, gcal_window, GCAL, WINDOW, AdwApplicationWindow)
GtkWidget* gcal_window_new_with_date (GcalApplication *app,
GDateTime *date);
@@ -46,5 +43,3 @@ void gcal_window_import_files (GcalWindow
gint n_files);
G_END_DECLS
-
-#endif /* __GCAL_WINDOW_H__ */
diff --git a/src/gui/gcal-window.ui b/src/gui/gcal-window.ui
index 46ea361a..07e0806a 100644
--- a/src/gui/gcal-window.ui
+++ b/src/gui/gcal-window.ui
@@ -1,83 +1,185 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <requires lib="gtk+" version="3.14"/>
- <template class="GcalWindow" parent="HdyApplicationWindow">
- <property name="window_position">center</property>
+ <template class="GcalWindow" parent="AdwApplicationWindow">
+ <property name="title" translatable="yes">Calendar</property>
<property name="default_width">800</property>
<property name="default_height">600</property>
<property name="height_request">600</property>
- <property name="show_menubar">False</property>
- <signal name="window-state-event" handler="window_state_changed" object="GcalWindow" swapped="no"/>
- <style>
- <class name="org-gnome-Calendar"/>
- </style>
+
+ <!-- Shortcuts -->
+ <child>
+ <object class='GtkShortcutController'>
+ <child>
+ <object class='GtkShortcut'>
+ <property name='trigger'><Control>t</property>
+ <property name='action'>win.today</property>
+ </object>
+ </child>
+ <child>
+ <object class='GtkShortcut'>
+ <property name='trigger'><Alt>Down</property>
+ <property name='action'>win.today</property>
+ </object>
+ </child>
+ <child>
+ <object class='GtkShortcut'>
+ <property name='trigger'>Home</property>
+ <property name='action'>win.today</property>
+ </object>
+ </child>
+ <child>
+ <object class='GtkShortcut'>
+ <property name='trigger'><Alt>Left</property>
+ <property name='action'>win.previous-date</property>
+ </object>
+ </child>
+ <child>
+ <object class='GtkShortcut'>
+ <property name='trigger'>Page_Up</property>
+ <property name='action'>win.previous-date</property>
+ </object>
+ </child>
+ <child>
+ <object class='GtkShortcut'>
+ <property name='trigger'><Alt>Right</property>
+ <property name='action'>win.next-date</property>
+ </object>
+ </child>
+ <child>
+ <object class='GtkShortcut'>
+ <property name='trigger'>Page_Down</property>
+ <property name='action'>win.next-date</property>
+ </object>
+ </child>
+ </object>
+ </child>
+
<child>
<object class="GtkBox">
- <property name="visible">True</property>
<property name="orientation">vertical</property>
+ <child>
+ <object class="GtkHeaderBar" id="header_bar">
+ <property name="show-title-buttons">True</property>
+ <child>
+ <object class="GtkButton" id="new_event_button">
+ <property name="icon-name">list-add-symbolic</property>
+ <property name="action-name">win.new-event</property>
+ <property name="tooltip_text" translatable="yes" context="tooltip">Add a new event</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="today_button">
+ <property name="label" translatable="yes">Today</property>
+ <property name="action-name">win.today</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox" id="button_box">
+ <child>
+ <object class="GtkButton" id="back_button">
+ <property name="icon_name">go-previous-symbolic</property>
+ <property name="action-name">win.previous-date</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="forward_button">
+ <property name="icon_name">go-next-symbolic</property>
+ <property name="action-name">win.next-date</property>
+ </object>
+ </child>
+ <style>
+ <class name="linked"/>
+ </style>
+ </object>
+ </child>
+ <child type="title">
+ <object class="AdwViewSwitcher" id="views_switcher">
+ <property name="stack">views_stack</property>
+ <property name="policy">wide</property>
+ </object>
+ </child>
+ <child type="end">
+ <object class="GtkMenuButton" id="menu_button">
+ <property name="icon-name">open-menu-symbolic</property>
+ <property name="popover">win_menu</property>
+ </object>
+ </child>
+ <child type="end">
+ <object class="GtkMenuButton" id="calendars_button">
+ <property name="popover">calendar_popover</property>
+ <property name="tooltip_text" translatable="yes">Manage your calendars</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ </object>
+ </child>
+ <child type="end">
+ <object class="GcalSearchButton" id="search_button">
+ <property name="tooltip_text" translatable="yes" context="tooltip">Search for
events</property>
+ </object>
+ </child>
+ </object>
+ </child>
+
+ <!-- Main Overlay -->
<child>
<object class="GtkOverlay" id="views_overlay">
- <property name="visible">True</property>
<child>
<object class="GtkBox" id="main_box">
- <property name="visible">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<child>
- <object class="GtkStack" id="views_stack">
- <property name="visible">True</property>
+ <object class="AdwViewStack" id="views_stack">
<property name="hexpand">True</property>
<property name="vexpand">True</property>
- <property name="transition_duration">250</property>
- <property name="transition_type">crossfade</property>
<signal name="notify::visible-child" handler="view_changed" object="GcalWindow"
swapped="no"/>
<style>
<class name="view"/>
</style>
<child>
- <object class="GcalWeekView" id="week_view">
- <property name="visible">True</property>
- <property name="active-date" bind-source="GcalWindow" bind-property="active-date"
bind-flags="bidirectional"/>
- <signal name="create-event" handler="show_new_event_widget" object="GcalWindow"
swapped="no"/>
- <signal name="event-activated" handler="event_activated" object="GcalWindow"
swapped="no"/>
- </object>
- <packing>
+ <object class="AdwViewStackPage">
<property name="name">week</property>
<property name="title" translatable="yes">Week</property>
<property name="icon_name">calendar-week-symbolic</property>
- </packing>
+ <property name="child">
+ <object class="GcalWeekView" id="week_view">
+ <property name="active-date" bind-source="GcalWindow"
bind-property="active-date" bind-flags="bidirectional"/>
+ <signal name="create-event" handler="show_new_event_widget" object="GcalWindow"
swapped="no"/>
+ <signal name="event-activated" handler="event_activated" object="GcalWindow"
swapped="no"/>
+ </object>
+ </property>
+ </object>
</child>
<child>
- <object class="GcalMonthView" id="month_view">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="active-date" bind-source="GcalWindow" bind-property="active-date"
bind-flags="bidirectional"/>
- <signal name="create-event" handler="show_new_event_widget" object="GcalWindow"
swapped="no"/>
- <signal name="create-event-detailed" handler="create_event_detailed_cb"
object="GcalWindow" swapped="no"/>
- <signal name="event-activated" handler="event_activated" object="GcalWindow"
swapped="no"/>
- </object>
- <packing>
- <property name="position">1</property>
+ <object class="AdwViewStackPage">
<property name="name">month</property>
<property name="title" translatable="yes">Month</property>
<property name="icon_name">calendar-month-symbolic</property>
- </packing>
+ <property name="child">
+ <object class="GcalMonthView" id="month_view">
+ <property name="active-date" bind-source="GcalWindow"
bind-property="active-date" bind-flags="bidirectional"/>
+ <signal name="create-event" handler="show_new_event_widget" object="GcalWindow"
swapped="no"/>
+ <signal name="create-event-detailed" handler="create_event_detailed_cb"
object="GcalWindow" swapped="no"/>
+ <signal name="event-activated" handler="event_activated" object="GcalWindow"
swapped="no"/>
+ </object>
+ </property>
+ </object>
</child>
<child>
- <object class="GcalYearView" id="year_view">
- <property name="visible">True</property>
- <property name="active-date" bind-source="GcalWindow" bind-property="active-date"
bind-flags="bidirectional"/>
- <signal name="create-event" handler="show_new_event_widget" object="GcalWindow"
swapped="no"/>
- <signal name="create-event-detailed" handler="create_event_detailed_cb"
object="GcalWindow" swapped="no"/>
- <signal name="event-activated" handler="event_activated" object="GcalWindow"
swapped="no"/>
- </object>
- <packing>
- <property name="position">2</property>
+ <object class="AdwViewStackPage">
<property name="name">year</property>
<property name="title" translatable="yes">Year</property>
<property name="icon_name">calendar-year-symbolic</property>
- </packing>
+ <property name="child">
+ <object class="GcalYearView" id="year_view">
+ <property name="active-date" bind-source="GcalWindow"
bind-property="active-date" bind-flags="bidirectional"/>
+ <signal name="create-event" handler="show_new_event_widget" object="GcalWindow"
swapped="no"/>
+ <signal name="create-event-detailed" handler="create_event_detailed_cb"
object="GcalWindow" swapped="no"/>
+ <signal name="event-activated" handler="event_activated" object="GcalWindow"
swapped="no"/>
+ </object>
+ </property>
+ </object>
</child>
</object>
</child>
@@ -85,72 +187,41 @@
</child>
<child type="overlay">
<object class="GtkRevealer" id="notification">
- <property name="visible">True</property>
<property name="halign">center</property>
<property name="valign">start</property>
<property name="transition_duration">100</property>
<signal name="notify::child-revealed" handler="remove_event" object="GcalWindow"
swapped="no"/>
<child>
<object class="GtkFrame">
- <property name="visible">True</property>
<child>
- <object class="GtkGrid">
- <property name="visible">True</property>
+ <object class="GtkBox">
<property name="margin_start">12</property>
<property name="margin_end">12</property>
<property name="margin_top">2</property>
<property name="margin_bottom">2</property>
- <property name="column_spacing">12</property>
+ <property name="spacing">12</property>
<child>
<object class="GtkLabel" id="notification_label">
- <property name="visible">True</property>
<property name="use_markup">True</property>
</object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
</child>
<child>
<object class="GtkButton" id="notification_action_button">
<property name="label">button</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="no_show_all">True</property>
<signal name="clicked" handler="undo_remove_action" object="GcalWindow"
swapped="no"/>
<style>
<class name="text-button"/>
</style>
</object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
</child>
<child>
<object class="GtkButton" id="notification_close_button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="relief">none</property>
- <property name="focus_on_click">False</property>
+ <property name="icon_name">window-close-symbolic</property>
<signal name="clicked" handler="hide_notification" object="GcalWindow"
swapped="yes"/>
- <child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="icon_name">window-close-symbolic</property>
- <property name="icon_size">2</property>
- </object>
- </child>
<style>
- <class name="image-button"/>
+ <class name="flat" />
</style>
</object>
- <packing>
- <property name="left_attach">2</property>
- <property name="top_attach">0</property>
- </packing>
</child>
</object>
</child>
@@ -162,136 +233,13 @@
</object>
</child>
</object>
- <packing>
- <property name="pack_type">end</property>
- </packing>
- </child>
- <child>
- <object class="HdyHeaderBar" id="header_bar">
- <property name="visible">True</property>
- <property name="show_close_button">True</property>
- <property name="title" translatable="yes">Calendar</property>
- <child>
- <object class="GtkButton" id="new_event_button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="action-name">win.new-event</property>
- <property name="tooltip_text" translatable="yes" context="tooltip">Add a new event</property>
- <child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="icon-name">list-add-symbolic</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkButton" id="today_button">
- <property name="label" translatable="yes">Today</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="action-name">win.today</property>
- <accelerator key="t" modifiers="GDK_CONTROL_MASK" signal="clicked"/>
- <accelerator key="Down" modifiers="GDK_MOD1_MASK" signal="clicked"/>
- <accelerator key="Home" signal="clicked"/>
- </object>
- </child>
- <child>
- <object class="GtkBox" id="button_box">
- <property name="visible">True</property>
- <child>
- <object class="GtkButton" id="back_button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="action-name">win.previous-date</property>
- <accelerator key="Left" modifiers="GDK_MOD1_MASK" signal="clicked"/>
- <accelerator key="Page_Up" signal="clicked"/>
- <child>
- <object class="GtkImage" id="go_back_image">
- <property name="visible">True</property>
- <property name="icon_name">go-previous-symbolic</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkButton" id="forward_button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="action-name">win.next-date</property>
- <accelerator key="Right" modifiers="GDK_MOD1_MASK" signal="clicked"/>
- <accelerator key="Page_Down" signal="clicked"/>
- <child>
- <object class="GtkImage" id="go_next_image">
- <property name="visible">True</property>
- <property name="icon_name">go-next-symbolic</property>
- </object>
- </child>
- </object>
- </child>
- <style>
- <class name="linked"/>
- </style>
- </object>
- </child>
- <child type="title">
- <object class="HdyViewSwitcher" id="views_switcher">
- <property name="visible">True</property>
- <property name="stack">views_stack</property>
- </object>
- </child>
- <child>
- <object class="GtkMenuButton" id="menu_button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="popover">win_menu</property>
- <property name="receives_default">True</property>
- <child>
- <object class="GtkImage" id="menu_image">
- <property name="visible">True</property>
- <property name="icon_name">open-menu-symbolic</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="pack_type">end</property>
- </packing>
- </child>
- <child>
- <object class="GtkMenuButton" id="calendars_button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="popover">calendar_popover</property>
- <property name="tooltip_text" translatable="yes">Manage your calendars</property>
- </object>
- <packing>
- <property name="pack_type">end</property>
- </packing>
- </child>
- <child>
- <object class="GcalSearchButton" id="search_button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes" context="tooltip">Search for
events</property>
- </object>
- <packing>
- <property name="pack_type">end</property>
- </packing>
- </child>
- </object>
</child>
+
</object>
</child>
</template>
<object class="GcalCalendarPopover" id="calendar_popover" />
<object class="GcalQuickAddPopover" id="quick_add_popover">
- <property name="visible">False</property>
- <property name="relative_to">views_stack</property>
<signal name="edit-event" handler="edit_event" object="GcalWindow" swapped="no"/>
<signal name="closed" handler="close_new_event_widget" object="GcalWindow" swapped="no"/>
</object>
@@ -304,69 +252,39 @@
<property name="visible">False</property>
<property name="transient_for">GcalWindow</property>
<signal name="remove-event" handler="on_event_editor_dialog_remove_event_cb" object="GcalWindow"
swapped="no"/>
- <signal name="delete-event" handler="gtk_widget_hide_on_delete" object="GcalWindow" swapped="no"/>
</object>
+ <menu id='menu'>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_Online Accounts…</attribute>
+ <attribute name="action-name">window.open-online-accounts</attribute>
+ </item>
+ <submenu>
+ <attribute name="label" translatable="yes">Weather</attribute>
+ <item>
+ <attribute name="custom">weather</attribute>
+ </item>
+ </submenu>
+ </section>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
+ <attribute name="action-name">window.show-help-overlay</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_About Calendar</attribute>
+ <attribute name="action-name">app.about</attribute>
+ </item>
+ </section>
+ </menu>
+
<object class="GtkPopoverMenu" id="win_menu">
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="margin">12</property>
- <property name="orientation">vertical</property>
-
- <!-- About -->
- <child>
- <object class="GtkModelButton">
- <property name="visible">True</property>
- <property name="action-name">win.open-online-accounts</property>
- <property name="text" translatable="yes">_Online Accounts…</property>
- </object>
- </child>
-
- <!-- Weather -->
- <child>
- <object class="GtkModelButton">
- <property name="visible">True</property>
- <property name="menu-name">weather</property>
- <property name="text" translatable="yes">_Weather</property>
- </object>
- </child>
-
- <child>
- <object class="GtkSeparator">
- <property name="visible">True</property>
- </object>
- </child>
-
- <!-- Shortcuts -->
- <child>
- <object class="GtkModelButton">
- <property name="visible">True</property>
- <property name="action-name">win.show-help-overlay</property>
- <property name="text" translatable="yes">_Keyboard Shortcuts</property>
- </object>
- </child>
-
- <!-- About -->
- <child>
- <object class="GtkModelButton">
- <property name="visible">True</property>
- <property name="action-name">app.about</property>
- <property name="text" translatable="yes">_About Calendar</property>
- </object>
- </child>
- </object>
- </child>
+ <property name="menu-model">menu</property>
<!-- Weather submenu -->
- <child>
- <object class="GcalWeatherSettings" id="weather_settings">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- </object>
- <packing>
- <property name="submenu">weather</property>
- </packing>
+ <child type="weather">
+ <object class="GcalWeatherSettings" id="weather_settings" />
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]