calendar-management: Replace bottom button with menu

The new menu allows opening either the new-local-calendar or the
new-online-calendar page. As of this commit both pages still show
the same content, this will be fixed in the following commits.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/850>
This commit is contained in:
Titouan Real
2026-09-26 00:04:12 +00:00
committed by Marge Bot
parent 736b724d24
commit 8a21b82e42
5 changed files with 41 additions and 44 deletions
@@ -25,6 +25,7 @@
#include "gcal-calendars-page.h"
#include "gcal-edit-calendar-page.h"
#include "gcal-new-local-calendar-page.h"
#include "gcal-new-online-calendar-page.h"
#include "gcal-utils.h"
#include <glib/gi18n.h>
@@ -46,7 +47,8 @@
typedef enum
{
GCAL_PAGE_CALENDARS,
GCAL_PAGE_NEW_CALENDAR,
GCAL_PAGE_NEW_LOCAL_CALENDAR,
GCAL_PAGE_NEW_ONLINE_CALENDAR,
GCAL_PAGE_EDIT_CALENDAR,
N_PAGES,
} GcalPageType;
@@ -170,7 +172,8 @@ gcal_calendar_management_dialog_init (GcalCalendarManagementDialog *self)
GType gtype;
} pages[] = {
{ GCAL_PAGE_CALENDARS, GCAL_TYPE_CALENDARS_PAGE },
{ GCAL_PAGE_NEW_CALENDAR, GCAL_TYPE_NEW_LOCAL_CALENDAR_PAGE },
{ GCAL_PAGE_NEW_LOCAL_CALENDAR, GCAL_TYPE_NEW_LOCAL_CALENDAR_PAGE },
{ GCAL_PAGE_NEW_ONLINE_CALENDAR, GCAL_TYPE_NEW_ONLINE_CALENDAR_PAGE },
{ GCAL_PAGE_EDIT_CALENDAR, GCAL_TYPE_EDIT_CALENDAR_PAGE },
};
@@ -8,7 +8,18 @@ template $GcalCalendarsPage: Adw.NavigationPage {
child: Adw.ToastOverlay toast_overlay {
Adw.ToolbarView {
[top]
Adw.HeaderBar {}
Adw.HeaderBar {
[start]
MenuButton {
tooltip-text: _("Add Calendar");
icon-name: "plus-large-symbolic";
menu-model: menu {
item (_("New Local Calendar…"), "calendar-management.new-local-calendar")
item (_("Add Remote Calendar…"), "calendar-management.new-online-calendar")
};
}
}
content: Adw.PreferencesPage {
Adw.PreferencesGroup {
@@ -23,37 +34,6 @@ template $GcalCalendarsPage: Adw.NavigationPage {
}
}
};
[bottom]
Adw.Clamp {
ListBox {
selection-mode: none;
margin-top: 15;
margin-bottom: 15;
margin-start: 12;
margin-end: 12;
Adw.ButtonRow {
title: _("_Add Calendar");
use-underline: true;
end-icon-name: "go-next-symbolic";
activated => $on_new_calendar_row_activated_cb(template) not-swapped;
ShortcutController {
scope: managed;
Shortcut {
trigger: "<Ctrl>n";
action: "activate";
}
}
}
styles [
"boxed-list",
]
}
}
}
};
}
@@ -213,6 +213,22 @@ clear_toast_and_delete_calendar (GcalCalendarsPage *self,
* Callbacks
*/
static void
on_new_local_calendar_action_activated (GtkWidget *widget)
{
GcalCalendarManagementPage *page = GCAL_CALENDAR_MANAGEMENT_PAGE (widget);
gcal_calendar_management_page_switch_page (page, "new-local-calendar", NULL);
}
static void
on_new_online_calendar_action_activated (GtkWidget *widget)
{
GcalCalendarManagementPage *page = GCAL_CALENDAR_MANAGEMENT_PAGE (widget);
gcal_calendar_management_page_switch_page (page, "new-online-calendar", NULL);
}
static gint
listbox_sort_func (GtkListBoxRow *row1,
GtkListBoxRow *row2,
@@ -264,15 +280,6 @@ on_listbox_row_activated_cb (GtkListBox *listbox,
gcal_calendar_management_page_switch_page (page, "edit-calendar", calendar);
}
static void
on_new_calendar_row_activated_cb (AdwButtonRow *button,
GcalCalendarsPage *self)
{
GcalCalendarManagementPage *page = GCAL_CALENDAR_MANAGEMENT_PAGE (self);
gcal_calendar_management_page_switch_page (page, "new-local-calendar", NULL);
}
static void
on_manager_calendar_added_cb (GcalManager *manager,
GcalCalendar *calendar,
@@ -417,7 +424,11 @@ gcal_calendars_page_class_init (GcalCalendarsPageClass *klass)
gtk_widget_class_bind_template_child (widget_class, GcalCalendarsPage, toast_overlay);
gtk_widget_class_bind_template_callback (widget_class, on_listbox_row_activated_cb);
gtk_widget_class_bind_template_callback (widget_class, on_new_calendar_row_activated_cb);
gtk_widget_class_install_action (widget_class, "calendar-management.new-local-calendar", NULL,
(GtkWidgetActionActivateFunc) on_new_local_calendar_action_activated);
gtk_widget_class_install_action (widget_class, "calendar-management.new-online-calendar", NULL,
(GtkWidgetActionActivateFunc) on_new_online_calendar_action_activated);
}
static void
+1
View File
@@ -15,6 +15,7 @@
<file compressed="true">globe-symbolic.svg</file>
<file compressed="true">info-outline-symbolic.svg</file>
<file compressed="true">loupe-large-symbolic.svg</file>
<file compressed="true">plus-large-symbolic.svg</file>
<file compressed="true">share-symbolic.svg</file>
<file compressed="true">map-symbolic.svg</file>
</gresource>
+2
View File
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" height="16px" viewBox="0 0 16 16" width="16px"><path d="m 7 1 v 6 h -6 v 2 h 6 v 6 h 2 v -6 h 6 v -2 h -6 v -6 z m 0 0" fill="#222222"/></svg>

After

Width:  |  Height:  |  Size: 222 B