aboutsummaryrefslogtreecommitdiff
path: root/src/datetime-service.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/datetime-service.c')
-rw-r--r--src/datetime-service.c78
1 files changed, 47 insertions, 31 deletions
diff --git a/src/datetime-service.c b/src/datetime-service.c
index b81ac1a..dfce637 100644
--- a/src/datetime-service.c
+++ b/src/datetime-service.c
@@ -31,7 +31,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <math.h>
#include <gconf/gconf-client.h>
-#include <libdbusmenu-gtk3/menuitem.h>
+#include <libdbusmenu-gtk/menuitem.h>
#include <libdbusmenu-glib/server.h>
#include <libdbusmenu-glib/client.h>
#include <libdbusmenu-glib/menuitem.h>
@@ -479,41 +479,47 @@ show_events_changed (void)
}
}
+static gboolean
+calendar_app_is_usable (void)
+{
+ /* confirm that it's installed... */
+ gchar *evo = g_find_program_in_path("evolution");
+ if (evo == NULL)
+ return FALSE;
+ g_debug ("found calendar app: '%s'", evo);
+ g_free (evo);
+
+ /* confirm that it's got an account set up... */
+ GSList *accounts_list = gconf_client_get_list (gconf, "/apps/evolution/mail/accounts", GCONF_VALUE_STRING, NULL);
+ const guint n = g_slist_length (accounts_list);
+ g_debug ("found %u evolution accounts", n);
+ g_slist_free (accounts_list);
+ return n > 0;
+}
+
/* Looks for the calendar application and enables the item if
we have one, starts ecal timer if events are turned on */
static gboolean
check_for_calendar (gpointer user_data)
{
- GError *error = NULL;
-
g_return_val_if_fail (calendar != NULL, FALSE);
dbusmenu_menuitem_property_set_bool(date, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
- gchar *evo = g_find_program_in_path("evolution");
- if (!get_greeter_mode () && evo != NULL) {
- g_debug("Found the calendar application: %s", evo);
+ if (!get_greeter_mode () && calendar_app_is_usable()) {
g_signal_connect (G_OBJECT(date), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
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);
+ add_appointment = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set (add_appointment, DBUSMENU_MENUITEM_PROP_LABEL, _("Add Event…"));
+ dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
+ g_signal_connect(G_OBJECT(add_appointment), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), "evolution -c calendar");
+ dbusmenu_menuitem_child_add_position (root, add_appointment, 3);
- GSList *accounts_list = gconf_client_get_list (gconf, "/apps/evolution/mail/accounts", GCONF_VALUE_STRING, &error);
- if (error != NULL) {
- g_debug("%s: Failed to get evolution mail accounts", G_STRFUNC);
- g_clear_error (&error);
- if (accounts_list)
- g_slist_free (accounts_list);
- } else if (accounts_list != NULL) {
- g_slist_free (accounts_list);
- 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);
- add_appointment = dbusmenu_menuitem_new();
- dbusmenu_menuitem_property_set (add_appointment, DBUSMENU_MENUITEM_PROP_LABEL, _("Add Event…"));
- dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
- g_signal_connect(G_OBJECT(add_appointment), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), "evolution -c calendar");
- dbusmenu_menuitem_child_add_position (root, add_appointment, 3);
- }
if (g_settings_get_boolean(conf, SETTINGS_SHOW_EVENTS_S)) {
dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
@@ -529,7 +535,6 @@ check_for_calendar (gpointer user_data)
g_signal_connect(calendar, "event::month-changed", G_CALLBACK(month_changed_cb), NULL);
g_signal_connect(calendar, "event::day-selected", G_CALLBACK(day_selected_cb), NULL);
g_signal_connect(calendar, "event::day-selected-double-click", G_CALLBACK(day_selected_double_click_cb), NULL);
- g_free(evo);
} else {
g_debug("Unable to find calendar app.");
dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
@@ -591,8 +596,8 @@ update_timezone_menu_items(gpointer user_data) {
offset = dbusmenu_menuitem_get_position (current_location, root)+1;
for (i = 0; i < len; i++) {
// Iterate over configured places and add any which aren't already listed
- if (g_strcmp0(locations[i], current_timezone) != 0 &&
- g_strcmp0(locations[i], geo_timezone) != 0) {
+ if ((current_timezone == NULL || !g_str_has_prefix(locations[i], current_timezone)) &&
+ (geo_timezone == NULL || !g_str_has_prefix(locations[i], geo_timezone))) {
g_debug("Adding timezone in update_timezones %s", locations[i]);
item = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set (item, DBUSMENU_MENUITEM_PROP_TYPE, TIMEZONE_MENUITEM_TYPE);
@@ -989,13 +994,19 @@ update_appointment_menu_items (gpointer user_data)
// Draw the correct icon for the appointment type and then tint it using mask fill.
// For now we'll create a circle
if (color_spec != NULL) {
- GdkColor color;
- gdk_color_parse (color_spec, &color);
g_debug("Creating a cairo surface: size, %d by %d", width, height);
cairo_surface_t *surface = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, width, height );
- cairo_t *cr = cairo_create(surface);
- gdk_cairo_set_source_color(cr, &color);
+ cairo_t *cr = cairo_create(surface);
+#if GTK_CHECK_VERSION(3,0,0)
+ GdkRGBA rgba;
+ if (gdk_rgba_parse (&rgba, color_spec))
+ gdk_cairo_set_source_rgba (cr, &rgba);
+#else
+ GdkColor color;
+ if (gdk_color_parse (color_spec, &color))
+ gdk_cairo_set_source_color (cr, &color);
+#endif
cairo_paint(cr);
cairo_set_source_rgba(cr, 0,0,0,0.5);
cairo_set_line_width(cr, 1);
@@ -1414,7 +1425,12 @@ geo_create_client (GeoclueMaster * master, GeoclueMasterClient * client, gchar *
geo_master = client;
- if (geo_master != NULL) {
+ if (error != NULL) {
+ g_warning("Unable to get a GeoClue client! '%s' Geolocation based timezone support will not be available.", error->message);
+ return;
+ }
+
+ if (geo_master == NULL) {
g_warning(_("Unable to get a GeoClue client! Geolocation based timezone support will not be available."));
return;
}