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
=== modified file 'src/datetime-service.c'
--- src/datetime-service.c 2012-05-17 20:53:17 +0000
+++ src/datetime-service.c 2012-05-23 18:31:18 +0000
@@ -60,6 +60,8 @@
60 #define SETTINGS_APP_INVOCATION "gnome-control-center datetime"60 #define SETTINGS_APP_INVOCATION "gnome-control-center datetime"
61#endif61#endif
6262
63#define EVOLUTION_SELECTED_CALENDARS "/apps/evolution/calendar/display/selected_calendars"
64
63static void geo_create_client (GeoclueMaster * master, GeoclueMasterClient * client, gchar * path, GError * error, gpointer user_data);65static void geo_create_client (GeoclueMaster * master, GeoclueMasterClient * client, gchar * path, GError * error, gpointer user_data);
64static gboolean update_appointment_menu_items (gpointer user_data);66static gboolean update_appointment_menu_items (gpointer user_data);
65static void update_location_menu_items (void);67static void update_location_menu_items (void);
@@ -500,11 +502,37 @@
500 return FALSE;502 return FALSE;
501}503}
502504
505static gboolean
506calendar_is_active (void)
507{
508 /* confirm that it's got an account set up... */
509 GSList *calendar_list = gconf_client_get_list (gconf, EVOLUTION_SELECTED_CALENDARS, GCONF_VALUE_STRING, NULL);
510 const guint n = g_slist_length (calendar_list);
511 g_debug ("found %u evolution calendars", n);
512 g_slist_free_full (calendar_list, g_free);
513 return n > 0;
514}
515
516static gboolean
517calendar_app_is_usable (void)
518{
519 /* confirm that it's installed... */
520 gchar *evo = g_find_program_in_path("evolution");
521 if (evo == NULL)
522 return FALSE;
523 g_debug ("found calendar app: '%s'", evo);
524 g_free (evo);
525 return TRUE;
526}
527
503static void528static void
504show_events_changed (void)529show_events_changed (void)
505{530{
506 if (g_settings_get_boolean(conf, SETTINGS_SHOW_EVENTS_S)) {531 gboolean has_calendar_app = (!get_greeter_mode () && calendar_app_is_usable());
507 dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);532 gboolean has_active_calendar = calendar_is_active();
533
534 if (has_active_calendar && g_settings_get_boolean(conf, SETTINGS_SHOW_EVENTS_S)) {
535 dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, has_calendar_app);
508 dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);536 dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
509 start_ecal_timer();537 start_ecal_timer();
510 } else {538 } else {
@@ -525,24 +553,6 @@
525 }553 }
526}554}
527555
528static gboolean
529calendar_app_is_usable (void)
530{
531 /* confirm that it's installed... */
532 gchar *evo = g_find_program_in_path("evolution");
533 if (evo == NULL)
534 return FALSE;
535 g_debug ("found calendar app: '%s'", evo);
536 g_free (evo);
537
538 /* confirm that it's got an account set up... */
539 GSList *accounts_list = gconf_client_get_list (gconf, "/apps/evolution/mail/accounts", GCONF_VALUE_STRING, NULL);
540 const guint n = g_slist_length (accounts_list);
541 g_debug ("found %u evolution accounts", n);
542 g_slist_free_full (accounts_list, g_free);
543 return n > 0;
544}
545
546/* Looks for the calendar application and enables the item if556/* Looks for the calendar application and enables the item if
547 we have one, starts ecal timer if events are turned on */557 we have one, starts ecal timer if events are turned on */
548static gboolean558static gboolean
@@ -551,44 +561,38 @@
551 g_return_val_if_fail (calendar != NULL, FALSE);561 g_return_val_if_fail (calendar != NULL, FALSE);
552 562
553 dbusmenu_menuitem_property_set_bool(date, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);563 dbusmenu_menuitem_property_set_bool(date, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
554 564
555 if (!get_greeter_mode () && calendar_app_is_usable()) {565 gboolean has_calendar_app = (!get_greeter_mode () && calendar_app_is_usable());
556 566 gboolean has_active_calendar = calendar_is_active();
557 g_signal_connect (G_OBJECT(date), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,567
558 G_CALLBACK (activate_cb), "evolution -c calendar");568 events_separator = dbusmenu_menuitem_new();
559 569 dbusmenu_menuitem_property_set(events_separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
560 events_separator = dbusmenu_menuitem_new();570 dbusmenu_menuitem_child_add_position(root, events_separator, 2);
561 dbusmenu_menuitem_property_set(events_separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);571
562 dbusmenu_menuitem_child_add_position(root, events_separator, 2);572 if (has_calendar_app) {
563 add_appointment = dbusmenu_menuitem_new();573 add_appointment = dbusmenu_menuitem_new();
564 dbusmenu_menuitem_property_set (add_appointment, DBUSMENU_MENUITEM_PROP_LABEL, _("Add Event…"));574 dbusmenu_menuitem_property_set (add_appointment, DBUSMENU_MENUITEM_PROP_LABEL, _("Add Event…"));
565 dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);575 dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_ENABLED, has_calendar_app);
566 g_signal_connect(G_OBJECT(add_appointment), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), "evolution -c calendar");576 g_signal_connect(G_OBJECT(add_appointment), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), "evolution -c calendar");
567 dbusmenu_menuitem_child_add_position (root, add_appointment, 3);577 dbusmenu_menuitem_child_add_position (root, add_appointment, 3);
568578 g_signal_connect (G_OBJECT(date), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
569579 G_CALLBACK (activate_cb), "evolution -c calendar");
570 if (g_settings_get_boolean(conf, SETTINGS_SHOW_EVENTS_S)) {580 }
581
582 if (has_active_calendar && g_settings_get_boolean(conf, SETTINGS_SHOW_EVENTS_S)) {
583 if (has_calendar_app) {
571 dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);584 dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
572 dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
573 g_idle_add((GSourceFunc)idle_start_ecal_timer, NULL);
574 } else {
575 dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
576 dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
577 stop_ecal_timer();
578 }585 }
579 586 dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
580 // Connect to calendar events587 g_idle_add((GSourceFunc)idle_start_ecal_timer, NULL);
581 g_signal_connect(calendar, "event::month-changed", G_CALLBACK(month_changed_cb), NULL);
582 g_signal_connect(calendar, "event::day-selected", G_CALLBACK(day_selected_cb), NULL);
583 g_signal_connect(calendar, "event::day-selected-double-click", G_CALLBACK(day_selected_double_click_cb), NULL);
584 } else {588 } else {
585 g_debug("Unable to find calendar app.");589 if (has_calendar_app) {
586 if (add_appointment != NULL)
587 dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);590 dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
588 if (events_separator != NULL)591 }
589 dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);592 dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
593 stop_ecal_timer();
590 }594 }
591 595
592 if (g_settings_get_boolean(conf, SETTINGS_SHOW_CALENDAR_S)) {596 if (g_settings_get_boolean(conf, SETTINGS_SHOW_CALENDAR_S)) {
593 dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);597 dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
594 dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);598 dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
@@ -597,6 +601,14 @@
597 dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);601 dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
598 }602 }
599603
604 // Connect to calendar events
605 g_signal_connect(calendar, "event::month-changed", G_CALLBACK(month_changed_cb), NULL);
606 g_signal_connect(calendar, "event::day-selected", G_CALLBACK(day_selected_cb), NULL);
607 g_signal_connect(calendar, "event::day-selected-double-click", G_CALLBACK(day_selected_double_click_cb), NULL);
608
609 // Keep track of active calendars
610 g_signal_connect (conf, "changed::" EVOLUTION_SELECTED_CALENDARS, G_CALLBACK (show_events_changed), NULL);
611
600 return FALSE;612 return FALSE;
601}613}
602614

Subscribers

People subscribed via source and target branches