views: move agenda view to main area
This prepares for multiple views to be there for mobile users, and is the location at which a dedicated agenda view for desktop will be, once the current agenda view is refactored to suit desktop use-cases better. Signed-off-by: Markus Göllnitz <camelcasenick@bewares.it> Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/542>
This commit is contained in:
committed by
Marge Bot
parent
07a6a077cb
commit
dec31cadd4
@@ -35,6 +35,7 @@ typedef enum
|
||||
* GcalWindowViewType:
|
||||
* @GCAL_WINDOW_VIEW_WEEK: Week view
|
||||
* @GCAL_WINDOW_VIEW_MONTH: Month view
|
||||
* GCAL_WINDOW_VIEW_AGENDA: Agenda/list view
|
||||
*
|
||||
* Enum with the available views.
|
||||
*/
|
||||
@@ -42,6 +43,7 @@ typedef enum
|
||||
{
|
||||
GCAL_WINDOW_VIEW_WEEK,
|
||||
GCAL_WINDOW_VIEW_MONTH,
|
||||
GCAL_WINDOW_VIEW_AGENDA,
|
||||
|
||||
GCAL_WINDOW_VIEW_N_VIEWS,
|
||||
} GcalWindowView;
|
||||
|
||||
+48
-7
@@ -109,7 +109,6 @@ struct _GcalWindow
|
||||
GtkWidget *month_view;
|
||||
GtkWidget *agenda_view;
|
||||
GtkWidget *date_chooser;
|
||||
GtkWidget *action_bar;
|
||||
GcalSyncIndicator *sync_indicator;
|
||||
GcalToolbarEnd *toolbar_end;
|
||||
GcalToolbarEnd *sidebar_toolbar_end;
|
||||
@@ -203,6 +202,7 @@ update_today_action_enabled (GcalWindow *window)
|
||||
{
|
||||
case GCAL_WINDOW_VIEW_WEEK:
|
||||
case GCAL_WINDOW_VIEW_MONTH:
|
||||
case GCAL_WINDOW_VIEW_AGENDA:
|
||||
enabled = g_date_time_get_year (window->active_date) != g_date_time_get_year (now) ||
|
||||
g_date_time_get_week_of_year (window->active_date) != g_date_time_get_week_of_year (now);
|
||||
|
||||
@@ -263,7 +263,6 @@ update_active_date (GcalWindow *window,
|
||||
|
||||
for (i = 0; i < GCAL_WINDOW_VIEW_N_VIEWS; i++)
|
||||
gcal_view_set_date (GCAL_VIEW (window->views[i]), new_date);
|
||||
gcal_view_set_date (GCAL_VIEW (window->agenda_view), new_date);
|
||||
gcal_view_set_date (GCAL_VIEW (window->date_chooser), new_date);
|
||||
|
||||
update_today_action_enabled (window);
|
||||
@@ -333,10 +332,17 @@ content_title (GcalWindow *self,
|
||||
GcalWindowView active_view)
|
||||
{
|
||||
/* We check for NULL so we get the right page name during initialization */
|
||||
if (active_view == GCAL_WINDOW_VIEW_WEEK)
|
||||
return g_strdup (_("Week"));
|
||||
else
|
||||
return g_strdup (_("Month"));
|
||||
switch (active_view)
|
||||
{
|
||||
case GCAL_WINDOW_VIEW_WEEK:
|
||||
return g_strdup (_("Week"));
|
||||
case GCAL_WINDOW_VIEW_MONTH:
|
||||
return g_strdup (_("Month"));
|
||||
case GCAL_WINDOW_VIEW_AGENDA:
|
||||
return g_strdup (_("Agenda"));
|
||||
default:
|
||||
return g_strdup (_("Calendar"));
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
@@ -594,6 +600,32 @@ on_window_undo_delete_event_cb (GSimpleAction *action,
|
||||
GCAL_EXIT;
|
||||
}
|
||||
|
||||
static void
|
||||
on_breakpoint_changed (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
GcalWindow *window)
|
||||
{
|
||||
gint32 view = window->active_view;
|
||||
|
||||
while (!adw_view_stack_page_get_visible (adw_view_stack_get_page (window->views_stack, window->views[view])))
|
||||
{
|
||||
view--;
|
||||
|
||||
if (view < 0)
|
||||
view += GCAL_WINDOW_VIEW_N_VIEWS;
|
||||
|
||||
if (view == window->active_view)
|
||||
return;
|
||||
}
|
||||
|
||||
if (window->active_view != view)
|
||||
{
|
||||
window->active_view = view;
|
||||
adw_view_stack_set_visible_child (window->views_stack, window->views[window->active_view]);
|
||||
g_object_notify_by_pspec (G_OBJECT (window), properties[PROP_ACTIVE_VIEW]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
view_changed (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
@@ -610,6 +642,14 @@ view_changed (GObject *object,
|
||||
if (!gtk_widget_get_visible (GTK_WIDGET (window->views_stack)))
|
||||
return;
|
||||
|
||||
/*
|
||||
* As there are no guarantees for the order of AdwBreakpoint setters,
|
||||
* it is possible that the agenda view disappears before the month and
|
||||
* week views reappears, and vice versa.
|
||||
*/
|
||||
if (!adw_view_stack_get_visible_child_name (window->views_stack))
|
||||
return;
|
||||
|
||||
eklass = g_type_class_ref (GCAL_TYPE_WINDOW_VIEW);
|
||||
eval = g_enum_get_value_by_nick (eklass, adw_view_stack_get_visible_child_name (window->views_stack));
|
||||
|
||||
@@ -1271,7 +1311,6 @@ gcal_window_class_init (GcalWindowClass *klass)
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, header_bar);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, menu_button);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, month_view);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, action_bar);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, quick_add_popover);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, overlay);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, sidebar_toolbar_end);
|
||||
@@ -1285,6 +1324,7 @@ gcal_window_class_init (GcalWindowClass *klass)
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, drop_overlay);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, drop_target);
|
||||
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_breakpoint_changed);
|
||||
gtk_widget_class_bind_template_callback (widget_class, view_changed);
|
||||
|
||||
/* Event creation related */
|
||||
@@ -1329,6 +1369,7 @@ gcal_window_init (GcalWindow *self)
|
||||
|
||||
self->views[GCAL_WINDOW_VIEW_WEEK] = self->week_view;
|
||||
self->views[GCAL_WINDOW_VIEW_MONTH] = self->month_view;
|
||||
self->views[GCAL_WINDOW_VIEW_AGENDA] = self->agenda_view;
|
||||
|
||||
self->active_date = g_date_time_new_from_unix_local (0);
|
||||
self->rtl = gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_RTL;
|
||||
|
||||
+82
-61
@@ -80,6 +80,13 @@
|
||||
<property name="arguments">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcut">
|
||||
<property name="trigger"><Alt>3</property>
|
||||
<property name="action">action(win.change-view)</property>
|
||||
<property name="arguments">3</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcut">
|
||||
<property name="trigger"><Ctrl>n</property>
|
||||
@@ -147,82 +154,52 @@
|
||||
<property name="sidebar">
|
||||
<object class="AdwToolbarView">
|
||||
<child type="top">
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
|
||||
<child>
|
||||
<object class="AdwHeaderBar">
|
||||
<child type="start">
|
||||
<object class="GcalSyncIndicator" id="sync_indicator" />
|
||||
</child>
|
||||
<property name="title-widget">
|
||||
<object class="GcalCalendarButton" id="calendars_button" />
|
||||
</property>
|
||||
<child type="end">
|
||||
<object class="GtkMenuButton" id="menu_button">
|
||||
<property name="icon-name">open-menu-symbolic</property>
|
||||
<property name="popover">win_menu</property>
|
||||
<property name="tooltip-text" translatable="yes">Main Menu</property>
|
||||
<property name="primary">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<object class="AdwHeaderBar">
|
||||
<child type="start">
|
||||
<object class="GcalSyncIndicator" id="sync_indicator" />
|
||||
</child>
|
||||
<property name="title-widget">
|
||||
<object class="GcalCalendarButton" id="calendars_button" />
|
||||
</property>
|
||||
<child type="end">
|
||||
<object class="GtkMenuButton" id="menu_button">
|
||||
<property name="icon-name">open-menu-symbolic</property>
|
||||
<property name="popover">win_menu</property>
|
||||
<property name="tooltip-text" translatable="yes">Main Menu</property>
|
||||
<property name="primary">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<property name="content">
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GcalDateChooser" id="date_chooser">
|
||||
<property name="split-month-year">False</property>
|
||||
<property name="split-month-year">True</property>
|
||||
<property name="vexpand">False</property>
|
||||
<property name="active-date" bind-source="GcalWindow" bind-property="active-date" bind-flags="bidirectional" />
|
||||
<signal name="day-selected" handler="day_selected" object="GcalWindow" swapped="yes" />
|
||||
</object>
|
||||
</child>
|
||||
|
||||
</object>
|
||||
|
||||
</child>
|
||||
|
||||
<property name="content">
|
||||
<object class="GcalAgendaView" id="agenda_view">
|
||||
<property name="vexpand">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" />
|
||||
<child>
|
||||
<object class="GcalCalendarList" id="calendars_list" />
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
|
||||
<child type="bottom">
|
||||
<object class="GtkActionBar" id="action_bar">
|
||||
<property name="revealed">False</property>
|
||||
<child type="start">
|
||||
<object class="GtkButton">
|
||||
<property name="action-name">win.today</property>
|
||||
<property name="child">
|
||||
<object class="AdwButtonContent">
|
||||
<property name="label" translatable="yes">_Today</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="icon-name">calendar-today-symbolic</property>
|
||||
<property name="can-shrink">True</property>
|
||||
<property name="tooltip-text" translatable="yes">Go to Today</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="end">
|
||||
<object class="GcalToolbarEnd" id="sidebar_toolbar_end" />
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
|
||||
<!-- Main content -->
|
||||
<property name="content">
|
||||
<object class="AdwToolbarView">
|
||||
<object class="AdwToolbarView" id="main_toolbar">
|
||||
<style>
|
||||
<class name="view" />
|
||||
</style>
|
||||
|
||||
<property name="reveal-bottom-bars">False</property>
|
||||
|
||||
<child type="top">
|
||||
<object class="AdwHeaderBar" id="header_bar">
|
||||
<child type="start">
|
||||
@@ -279,7 +256,7 @@
|
||||
<class name="view" />
|
||||
</style>
|
||||
<child>
|
||||
<object class="AdwViewStackPage">
|
||||
<object class="AdwViewStackPage" id="week_page">
|
||||
<property name="name">week</property>
|
||||
<property name="title" translatable="yes">_Week</property>
|
||||
<property name="use-underline">True</property>
|
||||
@@ -294,7 +271,7 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="AdwViewStackPage">
|
||||
<object class="AdwViewStackPage" id="month_page">
|
||||
<property name="name">month</property>
|
||||
<property name="title" translatable="yes">_Month</property>
|
||||
<property name="use-underline">True</property>
|
||||
@@ -309,9 +286,48 @@
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="AdwViewStackPage" id="agenda_page">
|
||||
<property name="name">agenda</property>
|
||||
<property name="title" translatable="yes">_Agenda</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="icon-name">calendar-agenda-symbolic</property>
|
||||
<property name="visible">False</property>
|
||||
<property name="child">
|
||||
<object class="GcalAgendaView" id="agenda_view">
|
||||
<property name="vexpand">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>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
|
||||
<child type="bottom">
|
||||
<object class="GtkActionBar">
|
||||
<child type="start">
|
||||
<object class="GtkButton">
|
||||
<property name="action-name">win.today</property>
|
||||
<property name="child">
|
||||
<object class="AdwButtonContent">
|
||||
<property name="label" translatable="yes">_Today</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="icon-name">calendar-today-symbolic</property>
|
||||
<property name="can-shrink">True</property>
|
||||
<property name="tooltip-text" translatable="yes">Go to Today</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="end">
|
||||
<object class="GcalToolbarEnd" id="sidebar_toolbar_end" />
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
@@ -321,14 +337,19 @@
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<signal name="notify::current-breakpoint" handler="on_breakpoint_changed" object="GcalWindow" swapped="no" />
|
||||
|
||||
<child>
|
||||
<object class="AdwBreakpoint">
|
||||
<condition>max-width: 700sp</condition>
|
||||
<setter object="split_view" property="collapsed">True</setter>
|
||||
<setter object="split_view" property="show-sidebar">True</setter>
|
||||
<setter object="action_bar" property="revealed">True</setter>
|
||||
<!-- This needs to be set so that focus does not stay in the content pane when folding. -->
|
||||
<setter object="content_page" property="sensitive">False</setter>
|
||||
<setter object="split_view" property="show-sidebar">False</setter>
|
||||
<setter object="main_toolbar" property="reveal-bottom-bars">True</setter>
|
||||
|
||||
<!-- only make views optimised for certain width visible here -->
|
||||
<setter object="week_page" property="visible">False</setter>
|
||||
<setter object="month_page" property="visible">False</setter>
|
||||
<setter object="agenda_page" property="visible">True</setter>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m 1 1 v 2 h 14 v -2 z m 0 4 v 2 h 10 v -2 z m 0 4 v 2 h 14 v -2 z m 0 4 v 2 h 10 v -2 z m 0 0" fill="#2e3436"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 259 B |
@@ -2,6 +2,7 @@
|
||||
<gresources>
|
||||
<gresource prefix="/org/gnome/calendar/icons/scalable/emblems/">
|
||||
<file compressed="true">add-reminder-symbolic.svg</file>
|
||||
<file compressed="true">calendar-agenda-symbolic.svg</file>
|
||||
<file compressed="true">calendar-month-symbolic.svg</file>
|
||||
<file compressed="true">calendar-week-symbolic.svg</file>
|
||||
<file compressed="true">calendar-today-symbolic.svg</file>
|
||||
|
||||
@@ -2,6 +2,14 @@
|
||||
<interface>
|
||||
<template class="GcalAgendaView" parent="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GcalDateChooser" id="date_chooser">
|
||||
<property name="split-month-year">False</property>
|
||||
<property name="vexpand">False</property>
|
||||
<property name="valign">end</property>
|
||||
<property name="active-date" bind-source="GcalAgendaView" bind-property="active-date" bind-flags="bidirectional" />
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="scrolled_window">
|
||||
<property name="hexpand">True</property>
|
||||
@@ -12,9 +20,6 @@
|
||||
<property name="selection-mode">none</property>
|
||||
<property name="vexpand">True</property>
|
||||
<signal name="row-activated" handler="on_list_box_row_activated_cb" object="GcalAgendaView" swapped="no" />
|
||||
<style>
|
||||
<class name="background" />
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkListBoxRow" id="no_events_row">
|
||||
<property name="activatable">False</property>
|
||||
|
||||
Reference in New Issue
Block a user