calendar-row: Rename calendar-combo-row-item to calendar-row

Currently, the quick add popover implements its own row
widget for each calendar, which duplicates tons of unnecessary
code. This commit streamlines the calendar-combo-row-item row
widget to make it reusable elsewhere.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/362>
This commit is contained in:
Hari Rana
2025-11-18 11:37:07 -03:00
committed by Georges Basile Stavracas Neto
parent 324bde2c72
commit f8c5751174
8 changed files with 46 additions and 46 deletions
+1 -1
View File
@@ -12,8 +12,8 @@ src/gui/calendar-management/gcal-edit-calendar-page.blp
src/gui/calendar-management/gcal-edit-calendar-page.c src/gui/calendar-management/gcal-edit-calendar-page.c
src/gui/calendar-management/gcal-new-calendar-page.blp src/gui/calendar-management/gcal-new-calendar-page.blp
src/gui/calendar-management/gcal-new-calendar-page.c src/gui/calendar-management/gcal-new-calendar-page.c
src/gui/common/gcal-calendar-combo-row-item.c
src/gui/common/gcal-calendar-combo-row.blp src/gui/common/gcal-calendar-combo-row.blp
src/gui/common/gcal-calendar-row.c
src/gui/common/gcal-date-chooser.c src/gui/common/gcal-date-chooser.c
src/gui/event-editor/gcal-alarm-row.blp src/gui/event-editor/gcal-alarm-row.blp
src/gui/event-editor/gcal-alarm-row.c src/gui/event-editor/gcal-alarm-row.c
+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/common"> <gresource prefix="/org/gnome/calendar/ui/common">
<file compressed="true">gcal-calendar-combo-row-item.ui</file> <file compressed="true">gcal-calendar-row.ui</file>
<file compressed="true">gcal-calendar-combo-row.ui</file> <file compressed="true">gcal-calendar-combo-row.ui</file>
<file compressed="true">gcal-date-chooser.ui</file> <file compressed="true">gcal-date-chooser.ui</file>
<file compressed="true">gcal-date-chooser-day.ui</file> <file compressed="true">gcal-date-chooser-day.ui</file>
+2 -2
View File
@@ -19,7 +19,7 @@
#define G_LOG_DOMAIN "GcalCalendarComboRow" #define G_LOG_DOMAIN "GcalCalendarComboRow"
#include "gcal-calendar-combo-row.h" #include "gcal-calendar-combo-row.h"
#include "gcal-calendar-combo-row-item.h" #include "gcal-calendar-row.h"
#include <locale.h> #include <locale.h>
#include <langinfo.h> #include <langinfo.h>
@@ -95,7 +95,7 @@ calendar_item_bind_cb (GtkSignalListItemFactory *factory,
box = g_object_get_data (G_OBJECT (item), "box"); box = g_object_get_data (G_OBJECT (item), "box");
checkmark = g_object_get_data (G_OBJECT (item), "checkmark"); checkmark = g_object_get_data (G_OBJECT (item), "checkmark");
calendar_row = gcal_calendar_combo_row_item_new (data); calendar_row = gcal_calendar_row_new (data);
gtk_box_insert_child_after (GTK_BOX (box), calendar_row, NULL); gtk_box_insert_child_after (GTK_BOX (box), calendar_row, NULL);
@@ -1,8 +1,8 @@
using Gtk 4.0; using Gtk 4.0;
using Adw 1; using Adw 1;
template $GcalCalendarComboRowItem: Adw.PreferencesRow { template $GcalCalendarRow: Adw.PreferencesRow {
Box { child: Box {
orientation: horizontal; orientation: horizontal;
spacing: 6; spacing: 6;
@@ -23,5 +23,5 @@ template $GcalCalendarComboRowItem: Adw.PreferencesRow {
hexpand: true; hexpand: true;
icon-name: "eye-not-looking-symbolic"; icon-name: "eye-not-looking-symbolic";
} }
} };
} }
@@ -1,4 +1,4 @@
/* gcal-calendar-combo-row-item.c /* gcal-calendar-row.c
* *
* Copyright 2024 Diego Iván M.E <diegoivan.mae@gmail.com> * Copyright 2024 Diego Iván M.E <diegoivan.mae@gmail.com>
* *
@@ -18,25 +18,25 @@
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
*/ */
#define G_LOG_DOMAIN "GcalCalendarComboRowItem" #define G_LOG_DOMAIN "GcalCalendarRow"
#include "config.h" #include "config.h"
#include "gcal-calendar-combo-row-item.h" #include "gcal-calendar-row.h"
#include "gcal-debug.h" #include "gcal-debug.h"
#include "gcal-utils.h" #include "gcal-utils.h"
#include <glib/gi18n.h> #include <glib/gi18n.h>
struct _GcalCalendarComboRowItem struct _GcalCalendarRow
{ {
AdwActionRow parent; AdwPreferencesRow parent;
GtkImage *color_image; GtkImage *color_image;
GtkImage *visibility_image; GtkImage *visibility_image;
GcalCalendar *calendar; GcalCalendar *calendar;
}; };
G_DEFINE_TYPE (GcalCalendarComboRowItem, gcal_calendar_combo_row_item, ADW_TYPE_PREFERENCES_ROW) G_DEFINE_TYPE (GcalCalendarRow, gcal_calendar_row, ADW_TYPE_PREFERENCES_ROW)
enum enum
{ {
@@ -59,7 +59,7 @@ paintable_from_gdk_rgb (GBinding *binding,
} }
static void static void
updated_visibility_cb (GcalCalendarComboRowItem *self) updated_visibility_cb (GcalCalendarRow *self)
{ {
g_autofree gchar *accessible_description = NULL; g_autofree gchar *accessible_description = NULL;
@@ -75,8 +75,8 @@ updated_visibility_cb (GcalCalendarComboRowItem *self)
} }
static void static void
set_calendar (GcalCalendarComboRowItem *self, set_calendar (GcalCalendarRow *self,
GcalCalendar *calendar) GcalCalendar *calendar)
{ {
g_return_if_fail (GCAL_IS_CALENDAR (calendar)); g_return_if_fail (GCAL_IS_CALENDAR (calendar));
g_set_object (&self->calendar, calendar); g_set_object (&self->calendar, calendar);
@@ -102,22 +102,22 @@ set_calendar (GcalCalendarComboRowItem *self,
*/ */
static void static void
gcal_calendar_combo_row_item_finalize (GObject *object) gcal_calendar_row_finalize (GObject *object)
{ {
GcalCalendarComboRowItem *self = (GcalCalendarComboRowItem *)object; GcalCalendarRow *self = (GcalCalendarRow *)object;
g_clear_object (&self->calendar); g_clear_object (&self->calendar);
G_OBJECT_CLASS (gcal_calendar_combo_row_item_parent_class)->finalize (object); G_OBJECT_CLASS (gcal_calendar_row_parent_class)->finalize (object);
} }
static void static void
gcal_calendar_combo_row_item_get_property (GObject *object, gcal_calendar_row_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GcalCalendarComboRowItem *self = GCAL_CALENDAR_COMBO_ROW_ITEM (object); GcalCalendarRow *self = GCAL_CALENDAR_ROW (object);
switch (prop_id) switch (prop_id)
{ {
@@ -131,12 +131,12 @@ gcal_calendar_combo_row_item_get_property (GObject *object,
} }
static void static void
gcal_calendar_combo_row_item_set_property (GObject *object, gcal_calendar_row_set_property (GObject *object,
guint prop_id, guint prop_id,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GcalCalendarComboRowItem *self = GCAL_CALENDAR_COMBO_ROW_ITEM (object); GcalCalendarRow *self = GCAL_CALENDAR_ROW (object);
switch (prop_id) switch (prop_id)
{ {
@@ -151,14 +151,14 @@ gcal_calendar_combo_row_item_set_property (GObject *object,
} }
static void static void
gcal_calendar_combo_row_item_class_init (GcalCalendarComboRowItemClass *klass) gcal_calendar_row_class_init (GcalCalendarRowClass *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_combo_row_item_finalize; object_class->finalize = gcal_calendar_row_finalize;
object_class->get_property = gcal_calendar_combo_row_item_get_property; object_class->get_property = gcal_calendar_row_get_property;
object_class->set_property = gcal_calendar_combo_row_item_set_property; object_class->set_property = gcal_calendar_row_set_property;
properties[PROP_CALENDAR] = g_param_spec_object ("calendar", properties[PROP_CALENDAR] = g_param_spec_object ("calendar",
"Calendar", "Calendar",
@@ -168,22 +168,22 @@ gcal_calendar_combo_row_item_class_init (GcalCalendarComboRowItemClass *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/common/gcal-calendar-combo-row-item.ui"); gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/ui/common/gcal-calendar-row.ui");
gtk_widget_class_bind_template_child (widget_class, GcalCalendarComboRowItem, color_image); gtk_widget_class_bind_template_child (widget_class, GcalCalendarRow, color_image);
gtk_widget_class_bind_template_child (widget_class, GcalCalendarComboRowItem, visibility_image); gtk_widget_class_bind_template_child (widget_class, GcalCalendarRow, visibility_image);
} }
static void static void
gcal_calendar_combo_row_item_init (GcalCalendarComboRowItem *self) gcal_calendar_row_init (GcalCalendarRow *self)
{ {
gtk_widget_init_template (GTK_WIDGET (self)); gtk_widget_init_template (GTK_WIDGET (self));
} }
GtkWidget* GtkWidget*
gcal_calendar_combo_row_item_new (GcalCalendar *calendar) gcal_calendar_row_new (GcalCalendar *calendar)
{ {
return g_object_new (GCAL_TYPE_CALENDAR_COMBO_ROW_ITEM, return g_object_new (GCAL_TYPE_CALENDAR_ROW,
"calendar", calendar, "calendar", calendar,
NULL); NULL);
} }
@@ -24,10 +24,10 @@
#include "gcal-calendar.h" #include "gcal-calendar.h"
G_BEGIN_DECLS G_BEGIN_DECLS
#define GCAL_TYPE_CALENDAR_COMBO_ROW_ITEM (gcal_calendar_combo_row_item_get_type()) #define GCAL_TYPE_CALENDAR_ROW (gcal_calendar_row_get_type())
G_DECLARE_FINAL_TYPE (GcalCalendarComboRowItem, gcal_calendar_combo_row_item, GCAL, CALENDAR_COMBO_ROW_ITEM, AdwPreferencesRow) G_DECLARE_FINAL_TYPE (GcalCalendarRow, gcal_calendar_row, GCAL, CALENDAR_ROW, AdwPreferencesRow)
GtkWidget* gcal_calendar_combo_row_item_new (GcalCalendar *calendar); GtkWidget* gcal_calendar_row_new (GcalCalendar *calendar);
G_END_DECLS G_END_DECLS
+2 -2
View File
@@ -3,8 +3,8 @@ calendar_incs += include_directories('.')
blueprints = custom_target( blueprints = custom_target(
'blueprints', 'blueprints',
input: files( input: files(
'gcal-calendar-combo-row-item.blp',
'gcal-calendar-combo-row.blp', 'gcal-calendar-combo-row.blp',
'gcal-calendar-row.blp',
'gcal-date-chooser-day.blp', 'gcal-date-chooser-day.blp',
'gcal-date-chooser.blp', 'gcal-date-chooser.blp',
), ),
@@ -26,7 +26,7 @@ built_sources += gnome.compile_resources(
) )
sources += files( sources += files(
'gcal-calendar-combo-row-item.c', 'gcal-calendar-row.c',
'gcal-calendar-combo-row.c', 'gcal-calendar-combo-row.c',
'gcal-date-chooser.c', 'gcal-date-chooser.c',
'gcal-date-chooser-day.c', 'gcal-date-chooser-day.c',
+2 -2
View File
@@ -9,7 +9,7 @@ template $GcalQuickAddPopover: Popover {
"quick-add-popover", "quick-add-popover",
] ]
Box { child: Box {
orientation: vertical; orientation: vertical;
margin-top: 12; margin-top: 12;
margin-bottom: 12; margin-bottom: 12;
@@ -103,5 +103,5 @@ template $GcalQuickAddPopover: Popover {
] ]
} }
} }
} };
} }