From 41321ee042e649b3957ffdc2019ade016c49f814 Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Fri, 1 Apr 2011 09:18:43 +0100 Subject: Set a minimum number of days to look for appointments for, allowed it to extend past month end by 1 week. --- src/datetime-service.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/datetime-service.c b/src/datetime-service.c index 1ddaa4d..7f14e74 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -656,6 +656,8 @@ update_appointment_menu_items (gpointer user_data) const int mon = today->tm_mon; const int year = today->tm_year; + int start_month_saved = mon; + struct tm *start_tm = NULL; int this_year = today->tm_year + 1900; int days[12]={31,28,31,30,31,30,31,31,30,31,30,31}; @@ -667,6 +669,7 @@ update_appointment_menu_items (gpointer user_data) if (start_time_appointments > 0) { start_tm = localtime(&start_time_appointments); int start_month = start_tm->tm_mon; + start_month_saved = start_month; int start_year = start_tm->tm_year + 1900; if ((start_month != mon) || (start_year != this_year)) { // Set t1 to the start of that month. @@ -681,6 +684,7 @@ update_appointment_menu_items (gpointer user_data) g_debug("Will highlight %d days from %s", highlightdays, ctime(&t1)); + highlightdays = highlightdays + 7; // Minimum of 7 days ahead t2 = t1 + (time_t) (highlightdays * 24 * 60 * 60); if (!e_cal_get_sources(&sources, E_CAL_SOURCE_TYPE_EVENT, &gerror)) { @@ -781,10 +785,12 @@ update_appointment_menu_items (gpointer user_data) const int dmon = due->tm_mon; const int dyear = due->tm_year; - // Mark day - g_debug("Adding marked date %s, %d", ctime(&ci->start), dmday); - g_variant_builder_add (&markeddays, "i", dmday); - + if (start_month_saved == dmon) { + // Mark day if our query hasn't hit the next month. + g_debug("Adding marked date %s, %d", ctime(&ci->start), dmday); + g_variant_builder_add (&markeddays, "i", dmday); + } + // If the appointment time is less than the selected date, // don't create an appointment item for it. if (vtype == E_CAL_COMPONENT_EVENT) { -- cgit v1.2.3 From 3bcb5d1ba9bf9890dd52d81cd35496d5d97b34a0 Mon Sep 17 00:00:00 2001 From: Dylan McCall Date: Sun, 3 Apr 2011 16:48:20 -0700 Subject: Follow show-calendar setting regardless of whether Evolution is present (LP: #748772) Visibility of upcoming events is no longer tied to show-calendar setting. --- src/datetime-service.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/datetime-service.c b/src/datetime-service.c index 1ddaa4d..4c3bb94 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -439,18 +439,16 @@ static gboolean check_for_calendar (gpointer user_data) { g_return_val_if_fail (calendar != NULL, FALSE); - // Always enable the calendar even if it does nothing - dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); - dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + + dbusmenu_menuitem_property_set_bool(date, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); gchar *evo = g_find_program_in_path("evolution"); if (evo != NULL) { g_debug("Found the calendar application: %s", evo); - - dbusmenu_menuitem_property_set_bool(date, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); + g_signal_connect (G_OBJECT(date), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK (activate_cb), "evolution -c calendar"); - + G_CALLBACK (activate_cb), "evolution -c calendar"); + events_separator = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set(events_separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); dbusmenu_menuitem_child_add_position(root, events_separator, 2); @@ -478,8 +476,16 @@ check_for_calendar (gpointer user_data) g_free(evo); } else { g_debug("Unable to find calendar app."); - dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); + dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); + } + + if (g_settings_get_boolean(conf, SETTINGS_SHOW_CALENDAR_S)) { + dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); + dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + } else { + dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE); + dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); } return FALSE; -- cgit v1.2.3 From 26edf58f8d17fc0cf46de985f59b49a9b0a2999f Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Mon, 4 Apr 2011 13:05:27 +0100 Subject: Added a change which _could_ work if evolution URI's were correct, however local:system is not a valid URI, effectively this will stop showing all calendars right now --- configure.ac | 11 +++++++---- src/datetime-service.c | 17 ++++++++++++++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index ef49e53..2357aa3 100644 --- a/configure.ac +++ b/configure.ac @@ -66,6 +66,7 @@ GDK_REQUIRED_VERSION=2.22 GLIB_REQUIRED_VERSION=2.26 GTK_REQUIRED_VERSION=2.12 GTK3_REQUIRED_VERSION=3.0 +GCONF_REQUIRED_VERSION=2.31 AS_IF([test "x$with_gtk" = x3], [PKG_CHECK_MODULES(INDICATOR, indicator3 >= $INDICATOR_REQUIRED_VERSION @@ -86,7 +87,7 @@ AS_IF([test "x$with_gtk" = x3], AS_IF([test "x$with_gtk" = x3], [PKG_CHECK_MODULES(SERVICE, indicator >= $INDICATOR_REQUIRED_VERSION - glib-2.0 >= $GLIB_REQUIRED_VERSION + glib-2.0 >= $GLIB_REQUIRED_VERSION dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION libido-0.1 >= $INDICATOR_DISPLAY_OBJECTS @@ -97,11 +98,12 @@ AS_IF([test "x$with_gtk" = x3], libedataserver-1.2 >= EDS_REQUIRED_VERSION libedataserverui-1.2 >= EDS_REQUIRED_VERSION cairo >= CAIRO_REQUIRED_VERSION - gdk-2.0 >= GDK_REQUIRED_VERSION) + gdk-2.0 >= GDK_REQUIRED_VERSION + gconf-2.0 >= GCONF_REQUIRED_VERSION) ], [test "x$with_gtk" = x2], [PKG_CHECK_MODULES(SERVICE, indicator >= $INDICATOR_REQUIRED_VERSION - glib-2.0 >= $GLIB_REQUIRED_VERSION + glib-2.0 >= $GLIB_REQUIRED_VERSION dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION libido-0.1 >= $INDICATOR_DISPLAY_OBJECTS @@ -112,7 +114,8 @@ AS_IF([test "x$with_gtk" = x3], libedataserver-1.2 >= EDS_REQUIRED_VERSION libedataserverui-1.2 >= EDS_REQUIRED_VERSION cairo >= CAIRO_REQUIRED_VERSION - gdk-2.0 >= GDK_REQUIRED_VERSION) + gdk-2.0 >= GDK_REQUIRED_VERSION + gconf-2.0 >= GCONF_REQUIRED_VERSION) ], [AC_MSG_FAILURE([Value for --with-gtk was neither 2 nor 3])] ) diff --git a/src/datetime-service.c b/src/datetime-service.c index 1ddaa4d..eb69d42 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -28,6 +28,7 @@ with this program. If not, see . #include #include #include +#include #include #include @@ -82,6 +83,7 @@ static GList * comp_instances = NULL; static gboolean updating_appointments = FALSE; static time_t start_time_appointments = (time_t) 0; GSettings *conf; +GConfClient* gconf; /* Geoclue trackers */ @@ -698,7 +700,13 @@ update_appointment_menu_items (gpointer user_data) comp_instances = NULL; } } - + GSList *cal_list = gconf_client_get_list(gconf, "/apps/evolution/calendar/display/selected_calendars", GCONF_VALUE_STRING, &gerror); + if (gerror) { + g_debug("Failed to get evolution preference for enabled calendars"); + g_error_free(gerror); + gerror = NULL; + cal_list = NULL; + } // Generate instances for all sources for (g = e_source_list_peek_groups (sources); g; g = g->next) { ESourceGroup *group = E_SOURCE_GROUP (g->data); @@ -716,6 +724,11 @@ update_appointment_menu_items (gpointer user_data) gerror = NULL; continue; } + const gchar *ecal_uri = e_cal_get_uri(ecal); + g_debug("Checking ecal_uri is enabled: %s, %s", ecal_uri); + // If source URI is not in source_list continue + if (cal_list != NULL && g_slist_find(cal_list, ecal_uri) == NULL) continue; + g_debug("ecal_uri is enabled, generating instances"); e_cal_generate_instances (ecal, t1, t2, (ECalRecurInstanceFn) populate_appointment_instances, (gpointer) source); } @@ -1300,6 +1313,8 @@ main (int argc, char ** argv) /* Set up GSettings */ conf = g_settings_new(SETTINGS_INTERFACE); + /* Set up gconf for getting evolution enabled calendars */ + gconf = gconf_client_get_default(); // TODO Add a signal handler to catch gsettings changes and respond to them /* Building the base menu */ -- cgit v1.2.3 From f6af2cf76470bfe177503c12699c84ba013feee7 Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Mon, 4 Apr 2011 13:53:19 +0100 Subject: Working patch! YAY --- src/datetime-service.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/datetime-service.c b/src/datetime-service.c index eb69d42..d01f5dc 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -724,11 +724,18 @@ update_appointment_menu_items (gpointer user_data) gerror = NULL; continue; } - const gchar *ecal_uri = e_cal_get_uri(ecal); - g_debug("Checking ecal_uri is enabled: %s, %s", ecal_uri); - // If source URI is not in source_list continue - if (cal_list != NULL && g_slist_find(cal_list, ecal_uri) == NULL) continue; - g_debug("ecal_uri is enabled, generating instances"); + const gchar *ecal_uid = e_source_peek_uid(source); + gboolean match = FALSE; + g_debug("Checking ecal_uid is enabled: %s", ecal_uid); + for (i = 0; i