window: reorganise top and bottom toolbars

This lets users directly launch the calendar dialogue
instead of sidebar in narrow mode.

It moves the view switcher to bottom when narrow.

This also makes the sidebar overlaid for an intermediate
step between narrow and always optionally visible sidebar.

Further, it moves the today button to bottom with the new
navigation button at its old location.

Closes: https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/1007

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:
Markus Göllnitz
2025-06-08 09:59:00 +00:00
committed by Marge Bot
parent 7904aba23c
commit b728e5beae
8 changed files with 69 additions and 259 deletions
-1
View File
@@ -42,7 +42,6 @@ src/gui/gcal-quick-add-popover.c
src/gui/gcal-quick-add-popover.ui
src/gui/gcal-search-button.ui
src/gui/gcal-sync-indicator.ui
src/gui/gcal-toolbar-end.ui
src/gui/gcal-weather-settings.ui
src/gui/gcal-window.c
src/gui/gcal-window.ui
-142
View File
@@ -1,142 +0,0 @@
/* gcal-toolbar-end.c
*
* Copyright 2022 Christopher Davis <christopherdavis@gnome.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include "gcal-context.h"
#include "gcal-search-button.h"
#include "gcal-toolbar-end.h"
struct _GcalToolbarEnd
{
AdwBin parent_instance;
GcalSearchButton *search_button;
GcalContext *context;
};
G_DEFINE_FINAL_TYPE (GcalToolbarEnd, gcal_toolbar_end, ADW_TYPE_BIN)
enum
{
PROP_0,
PROP_CONTEXT,
N_PROPS
};
static GParamSpec *properties [N_PROPS];
/*
* GObject overrides
*/
static void
gcal_toolbar_end_finalize (GObject *object)
{
GcalToolbarEnd *self = (GcalToolbarEnd *)object;
g_clear_object (&self->context);
G_OBJECT_CLASS (gcal_toolbar_end_parent_class)->finalize (object);
}
static void
gcal_toolbar_end_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GcalToolbarEnd *self = GCAL_TOOLBAR_END (object);
switch (prop_id)
{
case PROP_CONTEXT:
g_value_set_object (value, self->context);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
gcal_toolbar_end_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GcalToolbarEnd *self = GCAL_TOOLBAR_END (object);
switch (prop_id)
{
case PROP_CONTEXT:
g_assert (self->context == NULL);
self->context = g_value_dup_object (value);
g_object_bind_property (self, "context", self->search_button, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
gcal_toolbar_end_class_init (GcalToolbarEndClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = gcal_toolbar_end_finalize;
object_class->get_property = gcal_toolbar_end_get_property;
object_class->set_property = gcal_toolbar_end_set_property;
/**
* GcalToolbarEnd::context:
*
* The #GcalContext of the application.
*/
properties[PROP_CONTEXT] = g_param_spec_object ("context",
"Context of the application",
"The context of the application",
GCAL_TYPE_CONTEXT,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, N_PROPS, properties);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/ui/gui/gcal-toolbar-end.ui");
gtk_widget_class_bind_template_child (widget_class, GcalToolbarEnd, search_button);
}
static void
gcal_toolbar_end_init (GcalToolbarEnd *self)
{
g_type_ensure (GCAL_TYPE_SEARCH_BUTTON);
gtk_widget_init_template (GTK_WIDGET (self));
}
GtkWidget *
gcal_toolbar_end_get_search_button (GcalToolbarEnd *self)
{
g_return_val_if_fail (GCAL_IS_TOOLBAR_END (self), NULL);
return GTK_WIDGET (self->search_button);
}
-33
View File
@@ -1,33 +0,0 @@
/* gcal-toolbar-end.h
*
* Copyright 2022 Christopher Davis <christopherdavis@gnome.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#pragma once
#include <adwaita.h>
G_BEGIN_DECLS
#define GCAL_TYPE_TOOLBAR_END (gcal_toolbar_end_get_type())
G_DECLARE_FINAL_TYPE (GcalToolbarEnd, gcal_toolbar_end, GCAL, TOOLBAR_END, AdwBin)
GtkWidget * gcal_toolbar_end_get_search_button (GcalToolbarEnd *self);
G_END_DECLS
-22
View File
@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GcalToolbarEnd" parent="AdwBin">
<property name="child">
<object class="GtkBox">
<property name="spacing">6</property>
<child>
<object class="GcalSearchButton" id="search_button">
<property name="tooltip-text" translatable="yes" context="tooltip">Search</property>
</object>
</child>
<child>
<object class="GtkButton">
<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 Event</property>
</object>
</child>
</object>
</property>
</template>
</interface>
+7 -21
View File
@@ -22,6 +22,7 @@
#include "gcal-agenda-view.h"
#include "gcal-calendar-list.h"
#include "gcal-calendar-management-dialog.h"
#include "gcal-calendar-navigation-button.h"
#include "config.h"
#include "gcal-date-chooser.h"
#include "gcal-debug.h"
@@ -36,7 +37,6 @@
#include "gcal-sync-indicator.h"
#include "gcal-timeline.h"
#include "gcal-timeline-subscriber.h"
#include "gcal-toolbar-end.h"
#include "gcal-view.h"
#include "gcal-weather-settings.h"
#include "gcal-week-view.h"
@@ -110,14 +110,12 @@ struct _GcalWindow
GtkWidget *agenda_view;
GtkWidget *date_chooser;
GcalSyncIndicator *sync_indicator;
GcalToolbarEnd *toolbar_end;
GcalToolbarEnd *sidebar_toolbar_end;
GtkWidget *search_button;
AdwNavigationSplitView *split_view;
/* header_bar widgets */
GtkWidget *calendars_list;
GtkWidget *menu_button;
GtkWidget *views_switcher;
GcalEventEditorDialog *event_editor;
GtkWidget *import_dialog;
@@ -1050,7 +1048,6 @@ gcal_window_finalize (GObject *object)
}
g_clear_object (&window->context);
g_clear_object (&window->views_switcher);
gcal_clear_date_time (&window->active_date);
@@ -1125,8 +1122,7 @@ gcal_window_constructed (GObject *object)
g_object_bind_property (self, "context", self->event_editor, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
g_object_bind_property (self, "context", self->quick_add_popover, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
g_object_bind_property (self, "context", self->sync_indicator, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
g_object_bind_property (self, "context", self->toolbar_end, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
g_object_bind_property (self, "context", self->sidebar_toolbar_end, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
g_object_bind_property (self, "context", self->search_button, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
/* CSS */
load_css_providers (self);
@@ -1252,13 +1248,14 @@ gcal_window_class_init (GcalWindowClass *klass)
g_type_ensure (GCAL_TYPE_AGENDA_VIEW);
g_type_ensure (GCAL_TYPE_CALENDAR_LIST);
g_type_ensure (GCAL_TYPE_CALENDAR_NAVIGATION_BUTTON);
g_type_ensure (GCAL_TYPE_DATE_CHOOSER);
g_type_ensure (GCAL_TYPE_EVENT_EDITOR_DIALOG);
g_type_ensure (GCAL_TYPE_MANAGER);
g_type_ensure (GCAL_TYPE_MONTH_VIEW);
g_type_ensure (GCAL_TYPE_QUICK_ADD_POPOVER);
g_type_ensure (GCAL_TYPE_SYNC_INDICATOR);
g_type_ensure (GCAL_TYPE_TOOLBAR_END);
g_type_ensure (GCAL_TYPE_SEARCH_BUTTON);
g_type_ensure (GCAL_TYPE_WEATHER_SETTINGS);
g_type_ensure (GCAL_TYPE_WEEK_VIEW);
g_type_ensure (GCAL_TYPE_DROP_OVERLAY);
@@ -1313,12 +1310,10 @@ gcal_window_class_init (GcalWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, GcalWindow, month_view);
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);
gtk_widget_class_bind_template_child (widget_class, GcalWindow, split_view);
gtk_widget_class_bind_template_child (widget_class, GcalWindow, sync_indicator);
gtk_widget_class_bind_template_child (widget_class, GcalWindow, toolbar_end);
gtk_widget_class_bind_template_child (widget_class, GcalWindow, search_button);
gtk_widget_class_bind_template_child (widget_class, GcalWindow, views_stack);
gtk_widget_class_bind_template_child (widget_class, GcalWindow, views_switcher);
gtk_widget_class_bind_template_child (widget_class, GcalWindow, weather_settings);
gtk_widget_class_bind_template_child (widget_class, GcalWindow, week_view);
gtk_widget_class_bind_template_child (widget_class, GcalWindow, drop_overlay);
@@ -1420,18 +1415,9 @@ void
gcal_window_set_search_query (GcalWindow *self,
const gchar *query)
{
GtkWidget *search_button;
GcalToolbarEnd *toolbar_end;
g_return_if_fail (GCAL_IS_WINDOW (self));
if (adw_navigation_split_view_get_collapsed (self->split_view))
toolbar_end = self->sidebar_toolbar_end;
else
toolbar_end = self->toolbar_end;
search_button = gcal_toolbar_end_get_search_button (toolbar_end);
gcal_search_button_search (GCAL_SEARCH_BUTTON (search_button), query);
gcal_search_button_search (GCAL_SEARCH_BUTTON (self->search_button), query);
}
/**
+62 -38
View File
@@ -160,19 +160,7 @@
<property name="sidebar">
<object class="AdwToolbarView">
<child type="top">
<object class="AdwHeaderBar">
<child type="start">
<object class="GcalSyncIndicator" id="sync_indicator" />
</child>
<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>
<object class="AdwHeaderBar" />
</child>
<property name="content">
@@ -201,8 +189,6 @@
<class name="view" />
</style>
<property name="reveal-bottom-bars">False</property>
<child type="top">
<object class="AdwHeaderBar" id="header_bar">
<child type="start">
@@ -224,27 +210,26 @@
</object>
</child>
<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>
<object class="GcalSyncIndicator" id="sync_indicator" />
</child>
<property name="title-widget">
<object class="AdwViewSwitcher" id="views_switcher">
<property name="stack">views_stack</property>
<property name="policy">wide</property>
<object class="GcalCalendarNavigationButton" id="navigation_button_title">
<property name="active-date" bind-source="GcalWindow" bind-property="active-date" bind-flags="bidirectional" />
<property name="active" bind-source="split_view" bind-property="show-sidebar" bind-flags="sync-create | invert-boolean" />
</object>
</property>
<child type="end">
<object class="GcalToolbarEnd" id="toolbar_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>
<child type="end">
<object class="GcalSearchButton" id="search_button">
<property name="tooltip-text" translatable="yes" context="tooltip">Search</property>
</object>
</child>
</object>
</child>
@@ -325,8 +310,29 @@
</property>
</object>
</child>
<child type="center">
<object class="AdwBin" id="view_switcher_bin">
<property name="child">
<object class="AdwViewSwitcher" id="view_switcher_wide">
<property name="stack">views_stack</property>
<property name="policy">wide</property>
</object>
</property>
</object>
</child>
<child type="end">
<object class="GcalToolbarEnd" id="sidebar_toolbar_end" />
<object class="GtkButton">
<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 Event</property>
</object>
</child>
<child type="end">
<object class="GtkButton">
<property name="icon-name">x-office-calendar-symbolic</property>
<property name="tooltip-text" translatable="yes">Manage Calendars</property>
<property name="action-name">win.show-calendars</property>
</object>
</child>
</object>
</child>
@@ -342,13 +348,26 @@
<signal name="notify::current-breakpoint" handler="on_breakpoint_changed" object="GcalWindow" swapped="no" />
<child>
<object class="AdwBreakpoint">
<condition>max-width: 1000sp</condition>
<setter object="split_view" property="collapsed">True</setter>
<setter object="view_switcher_bin" property="child">view_switcher_narrow</setter>
</object>
</child>
<child>
<object class="AdwBreakpoint">
<condition>max-width: 700sp</condition>
<setter object="split_view" property="collapsed">True</setter>
<setter object="split_view" property="show-sidebar">False</setter>
<setter object="main_toolbar" property="reveal-bottom-bars">True</setter>
<setter object="view_switcher_bin" property="visible">False</setter> <!-- set child to view_switcher_narrow here once there are multiple mobile-friendly views -->
<setter object="split_view" property="show-sidebar">False</setter>
<setter object="sidebar_button" property="visible">False</setter>
<!-- remove once agenda view no longer needs always visible date chooser -->
<setter object="header_bar" property="title-widget"></setter>
<setter object="navigation_button_title" property="active">False</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>
@@ -356,6 +375,15 @@
</object>
</child>
</template>
<object class="AdwInlineViewSwitcher" id="view_switcher_narrow">
<style>
<class name="flat" />
</style>
<property name="stack">views_stack</property>
<property name="display-mode">icons</property>
</object>
<object class="GcalQuickAddPopover" id="quick_add_popover">
<signal name="edit-event" handler="edit_event" object="GcalWindow" swapped="no"/>
<signal name="closed" handler="close_new_event_widget" object="GcalWindow" swapped="no"/>
@@ -371,10 +399,6 @@
<attribute name="label" translatable="yes">_Synchronize Calendars</attribute>
<attribute name="action">app.sync</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Manage Calendars</attribute>
<attribute name="action">win.show-calendars</attribute>
</item>
</section>
<section>
<item>
-1
View File
@@ -9,7 +9,6 @@
<file compressed="true">gcal-quick-add-popover.ui</file>
<file compressed="true">gcal-search-button.ui</file>
<file compressed="true">gcal-sync-indicator.ui</file>
<file compressed="true">gcal-toolbar-end.ui</file>
<file compressed="true">gcal-weather-settings.ui</file>
<file compressed="true">gcal-window.ui</file>
</gresource>
-1
View File
@@ -27,7 +27,6 @@ sources += files(
'gcal-quick-add-popover.c',
'gcal-search-button.c',
'gcal-sync-indicator.c',
'gcal-toolbar-end.c',
'gcal-weather-settings.c',
'gcal-window.c',
)