calendar-button: change widget to standalone list for sidebar

The sync entry is dropped here in favour of one in the
main menu.

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 dec31cadd4
commit df182ed942
9 changed files with 102 additions and 128 deletions
-83
View File
@@ -1,83 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GcalCalendarButton" parent="AdwBin">
<child>
<object class="GtkMenuButton">
<property name="tooltip-text" translatable="yes">Manage Calendars</property>
<property name="use-underline">True</property>
<property name="label" translatable="yes">_Calendars</property>
<property name="popover">popover</property>
<property name="can-shrink">True</property>
<style>
<class name="image-button" />
</style>
<child>
<object class="GtkShortcutController">
<property name="scope">managed</property>
<child>
<object class="GtkShortcut">
<property name="trigger">F8</property>
<property name="action">activate</property>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
<menu id='menu'>
<section>
<item>
<attribute name="custom">list</attribute>
</item>
</section>
<section>
<item>
<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>
</menu>
<object class="GtkPopoverMenu" id="popover">
<property name="position">bottom</property>
<property name="menu-model">menu</property>
<child type="list">
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow">
<property name="hscrollbar_policy">never</property>
<property name="max_content_height">450</property>
<property name="max_content_width">800</property>
<property name="propagate-natural-height">True</property>
<property name="propagate-natural-width">True</property>
<child>
<object class="AdwClamp">
<property name="maximum-size">800</property>
<property name="tightening-threshold">800</property>
<child>
<object class="GtkListBox" id="calendar_listbox">
<property name="hexpand">True</property>
<property name="selection_mode">none</property>
<signal name="row-activated" handler="on_listbox_row_activated_cb" object="GcalCalendarButton" swapped="no"/>
<style>
<class name="calendar-list"/>
</style>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>
@@ -1,4 +1,4 @@
/* gcal-calendar-button.c /* gcal-calendar-list.c
* *
* Copyright 2019 Georges Basile Stavracas Neto <georges.stavracas@gmail.com> * Copyright 2019 Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
* *
@@ -18,14 +18,14 @@
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
*/ */
#define G_LOG_DOMAIN "GcalCalendarButton" #define G_LOG_DOMAIN "GcalCalendarList"
#include "gcal-calendar-list.h"
#include "gcal-calendar.h" #include "gcal-calendar.h"
#include "gcal-calendar-button.h"
#include "gcal-context.h" #include "gcal-context.h"
#include "gcal-utils.h" #include "gcal-utils.h"
struct _GcalCalendarButton struct _GcalCalendarList
{ {
AdwBin parent; AdwBin parent;
@@ -34,7 +34,7 @@ struct _GcalCalendarButton
GcalContext *context; GcalContext *context;
}; };
G_DEFINE_TYPE (GcalCalendarButton, gcal_calendar_button, ADW_TYPE_BIN) G_DEFINE_TYPE (GcalCalendarList, gcal_calendar_list, ADW_TYPE_BIN)
enum enum
{ {
@@ -71,9 +71,7 @@ create_row_func (gpointer data,
calendar = GCAL_CALENDAR (data); calendar = GCAL_CALENDAR (data);
row = g_object_new (GTK_TYPE_LIST_BOX_ROW, row = g_object_new (GTK_TYPE_LIST_BOX_ROW, NULL);
"css-name", "modelbutton",
NULL);
/* main box */ /* main box */
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
@@ -123,9 +121,9 @@ create_row_func (gpointer data,
*/ */
static void static void
on_listbox_row_activated_cb (GtkListBox *listbox, on_listbox_row_activated_cb (GtkListBox *listbox,
GtkListBoxRow *row, GtkListBoxRow *row,
GcalCalendarButton *self) GcalCalendarList *self)
{ {
GtkCheckButton *check = g_object_get_data (G_OBJECT (row), "check"); GtkCheckButton *check = g_object_get_data (G_OBJECT (row), "check");
@@ -138,22 +136,22 @@ on_listbox_row_activated_cb (GtkListBox *listbox,
*/ */
static void static void
gcal_calendar_button_finalize (GObject *object) gcal_calendar_list_finalize (GObject *object)
{ {
GcalCalendarButton *self = (GcalCalendarButton *)object; GcalCalendarList *self = (GcalCalendarList *) object;
g_clear_object (&self->context); g_clear_object (&self->context);
G_OBJECT_CLASS (gcal_calendar_button_parent_class)->finalize (object); G_OBJECT_CLASS (gcal_calendar_list_parent_class)->finalize (object);
} }
static void static void
gcal_calendar_button_get_property (GObject *object, gcal_calendar_list_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GcalCalendarButton *self = GCAL_CALENDAR_BUTTON (object); GcalCalendarList *self = GCAL_CALENDAR_LIST (object);
switch (prop_id) switch (prop_id)
{ {
@@ -167,12 +165,12 @@ gcal_calendar_button_get_property (GObject *object,
} }
static void static void
gcal_calendar_button_set_property (GObject *object, gcal_calendar_list_set_property (GObject *object,
guint prop_id, guint prop_id,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GcalCalendarButton *self = GCAL_CALENDAR_BUTTON (object); GcalCalendarList *self = GCAL_CALENDAR_LIST (object);
switch (prop_id) switch (prop_id)
{ {
@@ -198,17 +196,17 @@ gcal_calendar_button_set_property (GObject *object,
} }
static void static void
gcal_calendar_button_class_init (GcalCalendarButtonClass *klass) gcal_calendar_list_class_init (GcalCalendarListClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = gcal_calendar_button_finalize; object_class->finalize = gcal_calendar_list_finalize;
object_class->get_property = gcal_calendar_button_get_property; object_class->get_property = gcal_calendar_list_get_property;
object_class->set_property = gcal_calendar_button_set_property; object_class->set_property = gcal_calendar_list_set_property;
/** /**
* GcalCalendarButton::context: * GcalCalendarList::context:
* *
* The #GcalContext of the application. * The #GcalContext of the application.
*/ */
@@ -220,15 +218,15 @@ gcal_calendar_button_class_init (GcalCalendarButtonClass *klass)
g_object_class_install_properties (object_class, N_PROPS, properties); 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-calendar-button.ui"); gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/ui/gui/gcal-calendar-list.ui");
gtk_widget_class_bind_template_child (widget_class, GcalCalendarButton, calendar_listbox); gtk_widget_class_bind_template_child (widget_class, GcalCalendarList, calendar_listbox);
gtk_widget_class_bind_template_callback (widget_class, on_listbox_row_activated_cb); gtk_widget_class_bind_template_callback (widget_class, on_listbox_row_activated_cb);
} }
static void static void
gcal_calendar_button_init (GcalCalendarButton *self) gcal_calendar_list_init (GcalCalendarList *self)
{ {
gtk_widget_init_template (GTK_WIDGET (self)); gtk_widget_init_template (GTK_WIDGET (self));
} }
@@ -1,4 +1,4 @@
/* gcal-calendar-button.h /* gcal-calendar-list.h
* *
* Copyright 2019 Georges Basile Stavracas Neto <georges.stavracas@gmail.com> * Copyright 2019 Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
* *
@@ -24,7 +24,7 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define GCAL_TYPE_CALENDAR_BUTTON (gcal_calendar_button_get_type()) #define GCAL_TYPE_CALENDAR_LIST (gcal_calendar_list_get_type ())
G_DECLARE_FINAL_TYPE (GcalCalendarButton, gcal_calendar_button, GCAL, CALENDAR_BUTTON, AdwBin) G_DECLARE_FINAL_TYPE (GcalCalendarList, gcal_calendar_list, GCAL, CALENDAR_LIST, AdwBin)
G_END_DECLS G_END_DECLS
+31
View File
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GcalCalendarList" parent="AdwBin">
<property name="child">
<object class="GtkScrolledWindow">
<property name="hscrollbar_policy">never</property>
<property name="propagate-natural-height">True</property>
<property name="propagate-natural-width">True</property>
<property name="child">
<object class="AdwClamp">
<property name="maximum-size">800</property>
<property name="tightening-threshold">800</property>
<property name="child">
<object class="GtkListBox" id="calendar_listbox">
<style>
<class name="navigation-sidebar" />
</style>
<property name="hexpand">True</property>
<property name="selection_mode">none</property>
<signal name="row-activated" handler="on_listbox_row_activated_cb" object="GcalCalendarList" swapped="no" />
<style>
<class name="calendar-list" />
</style>
</object>
</property>
</object>
</property>
</object>
</property>
</template>
</interface>
+5 -5
View File
@@ -20,8 +20,8 @@
#define G_LOG_DOMAIN "GcalWindow" #define G_LOG_DOMAIN "GcalWindow"
#include "gcal-agenda-view.h" #include "gcal-agenda-view.h"
#include "gcal-calendar-list.h"
#include "gcal-calendar-management-dialog.h" #include "gcal-calendar-management-dialog.h"
#include "gcal-calendar-button.h"
#include "config.h" #include "config.h"
#include "gcal-date-chooser.h" #include "gcal-date-chooser.h"
#include "gcal-debug.h" #include "gcal-debug.h"
@@ -115,7 +115,7 @@ struct _GcalWindow
AdwNavigationSplitView *split_view; AdwNavigationSplitView *split_view;
/* header_bar widgets */ /* header_bar widgets */
GtkWidget *calendars_button; GtkWidget *calendars_list;
GtkWidget *menu_button; GtkWidget *menu_button;
GtkWidget *views_switcher; GtkWidget *views_switcher;
@@ -1116,7 +1116,7 @@ gcal_window_constructed (GObject *object)
* FIXME: this is a hack around the issue that happens when trying to bind * FIXME: this is a hack around the issue that happens when trying to bind
* these properties using the GtkBuilder .ui file. * these properties using the GtkBuilder .ui file.
*/ */
g_object_bind_property (self, "context", self->calendars_button, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); g_object_bind_property (self, "context", self->calendars_list, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
g_object_bind_property (self, "context", self->weather_settings, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); g_object_bind_property (self, "context", self->weather_settings, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
g_object_bind_property (self, "context", self->week_view, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); g_object_bind_property (self, "context", self->week_view, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
g_object_bind_property (self, "context", self->month_view, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); g_object_bind_property (self, "context", self->month_view, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
@@ -1251,7 +1251,7 @@ gcal_window_class_init (GcalWindowClass *klass)
GtkWidgetClass *widget_class; GtkWidgetClass *widget_class;
g_type_ensure (GCAL_TYPE_AGENDA_VIEW); g_type_ensure (GCAL_TYPE_AGENDA_VIEW);
g_type_ensure (GCAL_TYPE_CALENDAR_BUTTON); g_type_ensure (GCAL_TYPE_CALENDAR_LIST);
g_type_ensure (GCAL_TYPE_DATE_CHOOSER); g_type_ensure (GCAL_TYPE_DATE_CHOOSER);
g_type_ensure (GCAL_TYPE_EVENT_EDITOR_DIALOG); g_type_ensure (GCAL_TYPE_EVENT_EDITOR_DIALOG);
g_type_ensure (GCAL_TYPE_MANAGER); g_type_ensure (GCAL_TYPE_MANAGER);
@@ -1305,7 +1305,7 @@ gcal_window_class_init (GcalWindowClass *klass)
/* widgets */ /* widgets */
gtk_widget_class_bind_template_child (widget_class, GcalWindow, agenda_view); gtk_widget_class_bind_template_child (widget_class, GcalWindow, agenda_view);
gtk_widget_class_bind_template_child (widget_class, GcalWindow, calendars_button); gtk_widget_class_bind_template_child (widget_class, GcalWindow, calendars_list);
gtk_widget_class_bind_template_child (widget_class, GcalWindow, date_chooser); gtk_widget_class_bind_template_child (widget_class, GcalWindow, date_chooser);
gtk_widget_class_bind_template_child (widget_class, GcalWindow, event_editor); gtk_widget_class_bind_template_child (widget_class, GcalWindow, event_editor);
gtk_widget_class_bind_template_child (widget_class, GcalWindow, header_bar); gtk_widget_class_bind_template_child (widget_class, GcalWindow, header_bar);
+16 -3
View File
@@ -117,6 +117,12 @@
<property name="action">action(app.sync)</property> <property name="action">action(app.sync)</property>
</object> </object>
</child> </child>
<child>
<object class="GtkShortcut">
<property name="trigger">F8</property>
<property name="action">action(win.show-calendars)</property>
</object>
</child>
</object> </object>
</child> </child>
@@ -158,9 +164,6 @@
<child type="start"> <child type="start">
<object class="GcalSyncIndicator" id="sync_indicator" /> <object class="GcalSyncIndicator" id="sync_indicator" />
</child> </child>
<property name="title-widget">
<object class="GcalCalendarButton" id="calendars_button" />
</property>
<child type="end"> <child type="end">
<object class="GtkMenuButton" id="menu_button"> <object class="GtkMenuButton" id="menu_button">
<property name="icon-name">open-menu-symbolic</property> <property name="icon-name">open-menu-symbolic</property>
@@ -363,6 +366,16 @@
</object> </object>
<menu id='menu'> <menu id='menu'>
<section>
<item>
<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> <section>
<item> <item>
<attribute name="label" translatable="yes">_Date &amp; Time Settings…</attribute> <attribute name="label" translatable="yes">_Date &amp; Time Settings…</attribute>
+1 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<gresources> <gresources>
<gresource prefix="/org/gnome/calendar/ui/gui"> <gresource prefix="/org/gnome/calendar/ui/gui">
<file compressed="true">gcal-calendar-button.ui</file> <file compressed="true">gcal-calendar-list.ui</file>
<file compressed="true">gcal-event-popover.ui</file> <file compressed="true">gcal-event-popover.ui</file>
<file compressed="true">gcal-event-widget.ui</file> <file compressed="true">gcal-event-widget.ui</file>
<file compressed="true">gcal-meeting-row.ui</file> <file compressed="true">gcal-meeting-row.ui</file>
+1 -1
View File
@@ -16,7 +16,7 @@ built_sources += gnome.compile_resources(
sources += files( sources += files(
'gcal-application.c', 'gcal-application.c',
'gcal-calendar-button.c', 'gcal-calendar-list.c',
'gcal-drop-overlay.c', 'gcal-drop-overlay.c',
'gcal-event-popover.c', 'gcal-event-popover.c',
'gcal-event-widget.c', 'gcal-event-widget.c',
+15
View File
@@ -386,6 +386,21 @@ syncindicator {
padding: 6px; padding: 6px;
} }
/*
* Calendar list-style
*/
/* per https://gitlab.gnome.org/GNOME/libadwaita/-/blob/1ff329681652fa99ecac89092d7639063a5972cc/src/stylesheet/widgets/_menus.scss */
.calendar-list check {
min-width: 14px;
min-height: 14px;
-gtk-icon-size: 14px;
padding: 2px;
background: none;
box-shadow: none;
color: inherit;
}
/* /*
* Styles for the drop overlay. * Styles for the drop overlay.
* From Amberol https://gitlab.gnome.org/World/amberol/-/blob/0dd6250ffd294b14532c428dcb76ae42086a5923/src/gtk/style.css * From Amberol https://gitlab.gnome.org/World/amberol/-/blob/0dd6250ffd294b14532c428dcb76ae42086a5923/src/gtk/style.css