From aca797d19293dfd5aa167bbfa89df9e3483f517b Mon Sep 17 00:00:00 2001 From: Titouan Real Date: Fri, 8 Nov 2024 18:59:24 +0100 Subject: [PATCH] Remove GcalCalendarRow --- .../event-editor/event-editor.gresource.xml | 1 - src/gui/event-editor/gcal-calendar-row.c | 192 ------------------ src/gui/event-editor/gcal-calendar-row.h | 33 --- src/gui/event-editor/gcal-calendar-row.ui | 32 --- src/gui/event-editor/meson.build | 1 - 5 files changed, 259 deletions(-) delete mode 100644 src/gui/event-editor/gcal-calendar-row.c delete mode 100644 src/gui/event-editor/gcal-calendar-row.h delete mode 100644 src/gui/event-editor/gcal-calendar-row.ui diff --git a/src/gui/event-editor/event-editor.gresource.xml b/src/gui/event-editor/event-editor.gresource.xml index c875c9e2..38165c51 100644 --- a/src/gui/event-editor/event-editor.gresource.xml +++ b/src/gui/event-editor/event-editor.gresource.xml @@ -2,7 +2,6 @@ gcal-alarm-row.ui - gcal-calendar-row.ui gcal-date-chooser.ui gcal-date-chooser-day.ui gcal-date-selector.ui diff --git a/src/gui/event-editor/gcal-calendar-row.c b/src/gui/event-editor/gcal-calendar-row.c deleted file mode 100644 index 2dcb57bc..00000000 --- a/src/gui/event-editor/gcal-calendar-row.c +++ /dev/null @@ -1,192 +0,0 @@ -/* gcal-calendar-row.c - * - * Copyright 2024 Diego Iván M.E - * - * 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 . - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -#define G_LOG_DOMAIN "GcalCalendarRow" - -#include "config.h" -#include "gcal-calendar-row.h" -#include "gcal-debug.h" -#include "gcal-utils.h" - -#include - -struct _GcalCalendarRow -{ - AdwActionRow parent; - - GtkImage *color_image; - GtkImage *visibility_image; - GcalCalendar *calendar; -}; - -G_DEFINE_TYPE (GcalCalendarRow, gcal_calendar_row, ADW_TYPE_PREFERENCES_ROW) - -enum -{ - PROP_0, - PROP_CALENDAR, - N_PROPS, -}; - -static GParamSpec *properties [N_PROPS] = { NULL, }; - -static gboolean -paintable_from_gdk_rgb (GBinding *binding, - const GValue *from_value, - GValue *to_value, - gpointer user_data) -{ - GdkRGBA *rgba = g_value_get_boxed (from_value); - g_value_take_object (to_value, get_circle_paintable_from_color (rgba, 16)); - return TRUE; -} - -static void -updated_visibility_cb (GcalCalendarRow *self) -{ - g_autofree gchar *accessible_description = NULL; - - GCAL_ENTRY; - gtk_widget_set_visible (GTK_WIDGET (self->visibility_image), !gcal_calendar_get_visible (self->calendar)); - - if (!gcal_calendar_get_visible (self->calendar)) - accessible_description = g_strdup (_("This calendar is hidden")); - - gtk_accessible_update_property (GTK_ACCESSIBLE (self), - GTK_ACCESSIBLE_PROPERTY_DESCRIPTION, accessible_description, -1); - GCAL_EXIT; -} - -static void -set_calendar (GcalCalendarRow *self, - GcalCalendar *calendar) -{ - g_return_if_fail (GCAL_IS_CALENDAR (calendar)); - g_set_object (&self->calendar, calendar); - - g_object_bind_property_full (self->calendar, "color", - self->color_image, "paintable", - G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE, - paintable_from_gdk_rgb, - NULL, - NULL, - NULL); - g_signal_connect_object (self->calendar, - "notify::visible", (GCallback) updated_visibility_cb, - self, G_CONNECT_SWAPPED); - - g_object_bind_property (calendar, "name", self, "title", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); - - gtk_actionable_set_action_name (GTK_ACTIONABLE (self), "event-editor-dialog.select-calendar"); - gtk_actionable_set_action_target (GTK_ACTIONABLE (self), "s", gcal_calendar_get_id (calendar)); - - updated_visibility_cb (self); -} - -/* - * GObject overrides - */ - -static void -gcal_calendar_row_finalize (GObject *object) -{ - GcalCalendarRow *self = (GcalCalendarRow *)object; - - g_clear_object (&self->calendar); - - G_OBJECT_CLASS (gcal_calendar_row_parent_class)->finalize (object); -} - -static void -gcal_calendar_row_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GcalCalendarRow *self = GCAL_CALENDAR_ROW (object); - - switch (prop_id) - { - case PROP_CALENDAR: - g_value_set_object (value, self->calendar); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - } -} - -static void -gcal_calendar_row_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GcalCalendarRow *self = GCAL_CALENDAR_ROW (object); - - switch (prop_id) - { - case PROP_CALENDAR: - g_assert (self->calendar == NULL); - set_calendar (self, g_value_get_object (value)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - } -} - -static void -gcal_calendar_row_class_init (GcalCalendarRowClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - object_class->finalize = gcal_calendar_row_finalize; - object_class->get_property = gcal_calendar_row_get_property; - object_class->set_property = gcal_calendar_row_set_property; - - properties[PROP_CALENDAR] = g_param_spec_object ("calendar", - "Calendar", - "Calendar", - GCAL_TYPE_CALENDAR, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | 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/event-editor/gcal-calendar-row.ui"); - - gtk_widget_class_bind_template_child (widget_class, GcalCalendarRow, color_image); - gtk_widget_class_bind_template_child (widget_class, GcalCalendarRow, visibility_image); -} - -static void -gcal_calendar_row_init (GcalCalendarRow *self) -{ - gtk_widget_init_template (GTK_WIDGET (self)); -} - -GtkWidget* -gcal_calendar_row_new(GcalCalendar *calendar) -{ - return g_object_new (GCAL_TYPE_CALENDAR_ROW, - "calendar", calendar, - NULL); -} diff --git a/src/gui/event-editor/gcal-calendar-row.h b/src/gui/event-editor/gcal-calendar-row.h deleted file mode 100644 index cbbc1c88..00000000 --- a/src/gui/event-editor/gcal-calendar-row.h +++ /dev/null @@ -1,33 +0,0 @@ -/* gcal-calendar-row.h - * - * Copyright 2024 Diego Iván M.E - * - * 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 . - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -#pragma once - -#include -#include "gcal-calendar.h" -G_BEGIN_DECLS - -#define GCAL_TYPE_CALENDAR_ROW (gcal_calendar_row_get_type()) - -G_DECLARE_FINAL_TYPE (GcalCalendarRow, gcal_calendar_row, GCAL, CALENDAR_ROW, AdwPreferencesRow) - -GtkWidget* gcal_calendar_row_new (GcalCalendar *calendar); - -G_END_DECLS diff --git a/src/gui/event-editor/gcal-calendar-row.ui b/src/gui/event-editor/gcal-calendar-row.ui deleted file mode 100644 index 97d3e347..00000000 --- a/src/gui/event-editor/gcal-calendar-row.ui +++ /dev/null @@ -1,32 +0,0 @@ - - - - diff --git a/src/gui/event-editor/meson.build b/src/gui/event-editor/meson.build index 857b9ef1..1c9707ff 100644 --- a/src/gui/event-editor/meson.build +++ b/src/gui/event-editor/meson.build @@ -8,7 +8,6 @@ built_sources += gnome.compile_resources( sources += files( 'gcal-alarm-row.c', - 'gcal-calendar-row.c', 'gcal-date-chooser.c', 'gcal-date-chooser-day.c', 'gcal-date-selector.c',