Merge lp:~renatofilho/indicator-datetime/calendars into lp:indicator-datetime/12.10

Proposed by Renato Araujo Oliveira Filho
Status: Rejected
Rejected by: Charles Kerr
Proposed branch: lp:~renatofilho/indicator-datetime/calendars
Merge into: lp:indicator-datetime/12.10
Diff against target: 159 lines (+61/-49)
1 file modified
src/datetime-service.c (+61/-49)
To merge this branch: bzr merge lp:~renatofilho/indicator-datetime/calendars
Reviewer Review Type Date Requested Status
Charles Kerr (community) Needs Fixing
PS Jenkins bot (community) continuous-integration Needs Fixing
jenkins (community) continuous-integration Approve
Review via email: mp+107094@code.launchpad.net

Description of the change

Enable support for calendars events without evolution installation.

To post a comment you must log in.
Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

I guess it would help if we hadn't sat on this MP for 8 months, but the datetime codebase has changed so much that this MP can't work as-is.

The idea is fine though and I've opened a new ticket to track it. https://bugs.launchpad.net/indicator-datetime/+bug/1206942

If you want to update this MP for the 13.10 refactoring of i-datetime, please assign yourself to that ticket and I'll review sooner rather than later.

review: Needs Fixing

Unmerged revisions

179. By Renato Araujo Oliveira Filho

Enable support for calendars events without evolution installation.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/datetime-service.c'
2--- src/datetime-service.c 2012-05-17 20:53:17 +0000
3+++ src/datetime-service.c 2012-05-23 18:31:18 +0000
4@@ -60,6 +60,8 @@
5 #define SETTINGS_APP_INVOCATION "gnome-control-center datetime"
6 #endif
7
8+#define EVOLUTION_SELECTED_CALENDARS "/apps/evolution/calendar/display/selected_calendars"
9+
10 static void geo_create_client (GeoclueMaster * master, GeoclueMasterClient * client, gchar * path, GError * error, gpointer user_data);
11 static gboolean update_appointment_menu_items (gpointer user_data);
12 static void update_location_menu_items (void);
13@@ -500,11 +502,37 @@
14 return FALSE;
15 }
16
17+static gboolean
18+calendar_is_active (void)
19+{
20+ /* confirm that it's got an account set up... */
21+ GSList *calendar_list = gconf_client_get_list (gconf, EVOLUTION_SELECTED_CALENDARS, GCONF_VALUE_STRING, NULL);
22+ const guint n = g_slist_length (calendar_list);
23+ g_debug ("found %u evolution calendars", n);
24+ g_slist_free_full (calendar_list, g_free);
25+ return n > 0;
26+}
27+
28+static gboolean
29+calendar_app_is_usable (void)
30+{
31+ /* confirm that it's installed... */
32+ gchar *evo = g_find_program_in_path("evolution");
33+ if (evo == NULL)
34+ return FALSE;
35+ g_debug ("found calendar app: '%s'", evo);
36+ g_free (evo);
37+ return TRUE;
38+}
39+
40 static void
41 show_events_changed (void)
42 {
43- if (g_settings_get_boolean(conf, SETTINGS_SHOW_EVENTS_S)) {
44- dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
45+ gboolean has_calendar_app = (!get_greeter_mode () && calendar_app_is_usable());
46+ gboolean has_active_calendar = calendar_is_active();
47+
48+ if (has_active_calendar && g_settings_get_boolean(conf, SETTINGS_SHOW_EVENTS_S)) {
49+ dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, has_calendar_app);
50 dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
51 start_ecal_timer();
52 } else {
53@@ -525,24 +553,6 @@
54 }
55 }
56
57-static gboolean
58-calendar_app_is_usable (void)
59-{
60- /* confirm that it's installed... */
61- gchar *evo = g_find_program_in_path("evolution");
62- if (evo == NULL)
63- return FALSE;
64- g_debug ("found calendar app: '%s'", evo);
65- g_free (evo);
66-
67- /* confirm that it's got an account set up... */
68- GSList *accounts_list = gconf_client_get_list (gconf, "/apps/evolution/mail/accounts", GCONF_VALUE_STRING, NULL);
69- const guint n = g_slist_length (accounts_list);
70- g_debug ("found %u evolution accounts", n);
71- g_slist_free_full (accounts_list, g_free);
72- return n > 0;
73-}
74-
75 /* Looks for the calendar application and enables the item if
76 we have one, starts ecal timer if events are turned on */
77 static gboolean
78@@ -551,44 +561,38 @@
79 g_return_val_if_fail (calendar != NULL, FALSE);
80
81 dbusmenu_menuitem_property_set_bool(date, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
82-
83- if (!get_greeter_mode () && calendar_app_is_usable()) {
84-
85- g_signal_connect (G_OBJECT(date), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
86- G_CALLBACK (activate_cb), "evolution -c calendar");
87-
88- events_separator = dbusmenu_menuitem_new();
89- dbusmenu_menuitem_property_set(events_separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
90- dbusmenu_menuitem_child_add_position(root, events_separator, 2);
91+
92+ gboolean has_calendar_app = (!get_greeter_mode () && calendar_app_is_usable());
93+ gboolean has_active_calendar = calendar_is_active();
94+
95+ events_separator = dbusmenu_menuitem_new();
96+ dbusmenu_menuitem_property_set(events_separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
97+ dbusmenu_menuitem_child_add_position(root, events_separator, 2);
98+
99+ if (has_calendar_app) {
100 add_appointment = dbusmenu_menuitem_new();
101 dbusmenu_menuitem_property_set (add_appointment, DBUSMENU_MENUITEM_PROP_LABEL, _("Add Event…"));
102- dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
103+ dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_ENABLED, has_calendar_app);
104 g_signal_connect(G_OBJECT(add_appointment), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), "evolution -c calendar");
105 dbusmenu_menuitem_child_add_position (root, add_appointment, 3);
106-
107-
108- if (g_settings_get_boolean(conf, SETTINGS_SHOW_EVENTS_S)) {
109+ g_signal_connect (G_OBJECT(date), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
110+ G_CALLBACK (activate_cb), "evolution -c calendar");
111+ }
112+
113+ if (has_active_calendar && g_settings_get_boolean(conf, SETTINGS_SHOW_EVENTS_S)) {
114+ if (has_calendar_app) {
115 dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
116- dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
117- g_idle_add((GSourceFunc)idle_start_ecal_timer, NULL);
118- } else {
119- dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
120- dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
121- stop_ecal_timer();
122 }
123-
124- // Connect to calendar events
125- g_signal_connect(calendar, "event::month-changed", G_CALLBACK(month_changed_cb), NULL);
126- g_signal_connect(calendar, "event::day-selected", G_CALLBACK(day_selected_cb), NULL);
127- g_signal_connect(calendar, "event::day-selected-double-click", G_CALLBACK(day_selected_double_click_cb), NULL);
128+ dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
129+ g_idle_add((GSourceFunc)idle_start_ecal_timer, NULL);
130 } else {
131- g_debug("Unable to find calendar app.");
132- if (add_appointment != NULL)
133+ if (has_calendar_app) {
134 dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
135- if (events_separator != NULL)
136- dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
137+ }
138+ dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
139+ stop_ecal_timer();
140 }
141-
142+
143 if (g_settings_get_boolean(conf, SETTINGS_SHOW_CALENDAR_S)) {
144 dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
145 dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
146@@ -597,6 +601,14 @@
147 dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
148 }
149
150+ // Connect to calendar events
151+ g_signal_connect(calendar, "event::month-changed", G_CALLBACK(month_changed_cb), NULL);
152+ g_signal_connect(calendar, "event::day-selected", G_CALLBACK(day_selected_cb), NULL);
153+ g_signal_connect(calendar, "event::day-selected-double-click", G_CALLBACK(day_selected_double_click_cb), NULL);
154+
155+ // Keep track of active calendars
156+ g_signal_connect (conf, "changed::" EVOLUTION_SELECTED_CALENDARS, G_CALLBACK (show_events_changed), NULL);
157+
158 return FALSE;
159 }
160

Subscribers

People subscribed via source and target branches