summaryrefslogtreecommitdiff
path: root/applets/clock/clock.c
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2025-07-25 07:22:50 -0400
committerVictor Kareh <[email protected]>2025-07-25 16:52:45 -0400
commitdafe6ccfd17ede3af0c8a92cc06a545c4d1723ef (patch)
tree7777098fb6a2b225aa0878012f475a9ce13befd2 /applets/clock/clock.c
parentd62e45c2b0aaf4b15eecc2e8f1529f42fb4c8e6d (diff)
downloadmate-panel-evolution-calendar-integration.tar.bz2
mate-panel-evolution-calendar-integration.tar.xz
clock: Backport Evolution calendar integration from gnome-panelevolution-calendar-integration
Add Evolution Data Server (EDS) calendar integration to the MATE panel clock applet, most of it ported from gnome-panel's clock applet. This allows users to view calendar events and tasks directly from the clock popup calendar. The calendar integration is disabled by default and can be enabled with --enable-eds during configuration. When disabled, the clock applet functions normally without any EDS dependencies.
Diffstat (limited to 'applets/clock/clock.c')
-rw-r--r--applets/clock/clock.c46
1 files changed, 42 insertions, 4 deletions
diff --git a/applets/clock/clock.c b/applets/clock/clock.c
index 0eee5766..41bb49b0 100644
--- a/applets/clock/clock.c
+++ b/applets/clock/clock.c
@@ -89,6 +89,8 @@
#define KEY_CITIES "cities"
#define KEY_TEMPERATURE_UNIT "temperature-unit"
#define KEY_SPEED_UNIT "speed-unit"
+#define KEY_SHOW_CALENDAR_EVENTS "show-calendar-events"
+#define KEY_SHOW_TASKS "show-tasks"
/* For watching for when the system resumes from sleep mode (e.g. suspend)
* and updating the clock as soon as that happens. */
@@ -127,6 +129,7 @@ struct _ClockData {
GtkWidget *props;
GtkWidget *calendar_popup;
+ gboolean calendar_popup_destroying;
GtkWidget *clock_vbox;
GtkSizeGroup *clock_group;
@@ -788,9 +791,12 @@ destroy_clock (GtkWidget * widget, ClockData *cd)
gtk_widget_destroy (cd->props);
cd->props = NULL;
- if (cd->calendar_popup)
+ if (cd->calendar_popup && !cd->calendar_popup_destroying) {
+ cd->calendar_popup_destroying = TRUE;
gtk_widget_destroy (cd->calendar_popup);
+ }
cd->calendar_popup = NULL;
+ cd->calendar_popup_destroying = FALSE;
g_free (cd->timeformat);
@@ -861,7 +867,8 @@ create_calendar (ClockData *cd)
prefs_path = mate_panel_applet_get_preferences_path (MATE_PANEL_APPLET (cd->applet));
window = calendar_window_new (&cd->current_time,
prefs_path,
- cd->orient == MATE_PANEL_APPLET_ORIENT_UP);
+ cd->orient == MATE_PANEL_APPLET_ORIENT_UP,
+ cd->settings);
g_free (prefs_path);
calendar_window_set_show_weeks (CALENDAR_WINDOW (window),
@@ -1348,9 +1355,11 @@ static void
update_calendar_popup (ClockData *cd)
{
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cd->panel_button))) {
- if (cd->calendar_popup) {
+ if (cd->calendar_popup && !cd->calendar_popup_destroying) {
+ cd->calendar_popup_destroying = TRUE;
gtk_widget_destroy (cd->calendar_popup);
cd->calendar_popup = NULL;
+ cd->calendar_popup_destroying = FALSE;
cd->cities_section = NULL;
cd->map_widget = NULL;
cd->clock_vbox = NULL;
@@ -1363,7 +1372,7 @@ update_calendar_popup (ClockData *cd)
return;
}
- if (!cd->calendar_popup) {
+ if (!cd->calendar_popup && !cd->calendar_popup_destroying) {
cd->calendar_popup = create_calendar (cd);
g_object_add_weak_pointer (G_OBJECT (cd->calendar_popup),
(gpointer *) &cd->calendar_popup);
@@ -3286,6 +3295,35 @@ fill_prefs_window (ClockData *cd)
g_settings_bind (cd->settings, KEY_SHOW_TEMPERATURE, widget, "active",
G_SETTINGS_BIND_DEFAULT);
+#ifdef HAVE_EDS
+ /* Set the EDS calendar event checkboxes */
+ widget = _clock_get_widget (cd, "show_calendar_events_check");
+ if (widget) {
+ /* Bind to gsettings - this should sync with calendar window automatically */
+ g_settings_bind (cd->settings, KEY_SHOW_CALENDAR_EVENTS, widget, "active",
+ G_SETTINGS_BIND_DEFAULT);
+ } else {
+ g_warning ("Could not find show_calendar_events_check widget in preferences");
+ }
+
+ /* Set the EDS tasks checkboxes */
+ widget = _clock_get_widget (cd, "show_tasks_check");
+ if (widget) {
+ /* Bind to gsettings - this should sync with calendar window automatically */
+ g_settings_bind (cd->settings, KEY_SHOW_TASKS, widget, "active",
+ G_SETTINGS_BIND_DEFAULT);
+ } else {
+ g_warning ("Could not find show_tasks_check widget in preferences");
+ }
+
+#else
+ /* Hide the Calendar tab if EDS is not available */
+ widget = _clock_get_widget (cd, "vbox-calendar");
+ gtk_widget_hide (widget);
+ widget = _clock_get_widget (cd, "label-calendar-tab");
+ gtk_widget_hide (widget);
+#endif
+
/* Fill the Cities list */
widget = _clock_get_widget (cd, "cities_list");