← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~karl-qdh/indicator-datetime/onlyenabledcalendars into lp:indicator-datetime

 

Karl Lattimer has proposed merging lp:~karl-qdh/indicator-datetime/onlyenabledcalendars into lp:indicator-datetime.

Requested reviews:
  Ted Gould (ted)
Related bugs:
  Bug #729033 in Indicator Date and Time: "Show only Evolution calendar events if the calendar is active"
  https://bugs.launchpad.net/indicator-datetime/+bug/729033

For more details, see:
https://code.launchpad.net/~karl-qdh/indicator-datetime/onlyenabledcalendars/+merge/56151

working patch to show only enabled calendars
-- 
https://code.launchpad.net/~karl-qdh/indicator-datetime/onlyenabledcalendars/+merge/56151
Your team ayatana-commits is subscribed to branch lp:indicator-datetime.
=== modified file 'configure.ac'
--- configure.ac	2011-03-23 21:03:40 +0000
+++ configure.ac	2011-04-04 12:56:34 +0000
@@ -66,6 +66,7 @@
 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],
 	[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 @@
 	                             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 @@
 	                             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])]
 )

=== modified file 'src/datetime-service.c'
--- src/datetime-service.c	2011-03-30 21:55:14 +0000
+++ src/datetime-service.c	2011-04-04 12:56:34 +0000
@@ -28,6 +28,7 @@
 #include <glib/gi18n.h>
 #include <gio/gio.h>
 #include <math.h>
+#include <gconf/gconf-client.h>
 
 #include <libdbusmenu-gtk/menuitem.h>
 #include <libdbusmenu-glib/server.h>
@@ -82,6 +83,7 @@
 static gboolean           updating_appointments = FALSE;
 static time_t			  start_time_appointments = (time_t) 0;
 GSettings *conf;
+GConfClient* gconf;
 
 
 /* Geoclue trackers */
@@ -698,7 +700,13 @@
 			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,18 @@
 				gerror = NULL;
 				continue;
         	}
+			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<g_slist_length(cal_list);i++) {
+				char *cuid = (char *)g_slist_nth_data(cal_list, i);
+				if (g_strcmp0(cuid, ecal_uid) == 0) {
+					match = TRUE;
+					break;
+				}
+			}
+			if (!match) continue;
+			g_debug("ecal_uid is enabled, generating instances");
 			
 			e_cal_generate_instances (ecal, t1, t2, (ECalRecurInstanceFn) populate_appointment_instances, (gpointer) source);
 		}
@@ -1300,6 +1320,8 @@
 
 	/* 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 */


Follow ups