diff options
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | src/datetime-service.c | 36 |
2 files changed, 26 insertions, 14 deletions
diff --git a/configure.ac b/configure.ac index 2357aa3..b932e56 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(indicator-datetime, 0.2.0, ted@canonical.com) +AC_INIT(indicator-datetime, 0.2.1, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-datetime, 0.2.0) +AM_INIT_AUTOMAKE(indicator-datetime, 0.2.1) AM_MAINTAINER_MODE diff --git a/src/datetime-service.c b/src/datetime-service.c index d01f5dc..6458ae9 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -441,18 +441,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); @@ -480,8 +478,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; @@ -658,6 +664,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}; @@ -669,6 +677,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. @@ -683,6 +692,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)) { @@ -801,10 +811,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) { |