aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-03-09 22:32:19 -0500
committerCharles Kerr <charles.kerr@canonical.com>2014-03-09 22:32:19 -0500
commit379aeeed3dc02c1088f2a50f1ec3ec880d7d4b76 (patch)
tree39dd136cd3f54ee903ba757c461d9f0f502315ce /src
parent462e8e6d8e46475ea3222056f65ff40823e9e0bf (diff)
parentdf650bec0f1c634ee773c150b451c3bdd8ed4e65 (diff)
downloadayatana-indicator-datetime-379aeeed3dc02c1088f2a50f1ec3ec880d7d4b76.tar.gz
ayatana-indicator-datetime-379aeeed3dc02c1088f2a50f1ec3ec880d7d4b76.tar.bz2
ayatana-indicator-datetime-379aeeed3dc02c1088f2a50f1ec3ec880d7d4b76.zip
Don't list an 'Add Event…' button if there's not a calendar app available
Diffstat (limited to 'src')
-rw-r--r--src/actions-live.cpp24
-rw-r--r--src/menu.cpp19
2 files changed, 35 insertions, 8 deletions
diff --git a/src/actions-live.cpp b/src/actions-live.cpp
index ca9ca9b..f8ef4e8 100644
--- a/src/actions-live.cpp
+++ b/src/actions-live.cpp
@@ -74,6 +74,30 @@ void LiveActions::open_desktop_settings()
g_free (path);
}
+bool LiveActions::can_open_planner() const
+{
+ bool inited = false;
+ bool have_evolution = false;
+
+ if (G_UNLIKELY(!inited))
+ {
+ inited = true;
+
+ auto all = g_app_info_get_all_for_type ("text/calendar");
+ for(auto l=all; !have_evolution && l!=nullptr; l=l->next)
+ {
+ auto app_info = static_cast<GAppInfo*>(l->data);
+
+ if (!g_strcmp0("evolution", g_app_info_get_executable(app_info)))
+ have_evolution = true;
+ }
+
+ g_list_free_full(all, (GDestroyNotify)g_object_unref);
+ }
+
+ return have_evolution;
+}
+
void LiveActions::open_planner()
{
execute_command("evolution -c calendar");
diff --git a/src/menu.cpp b/src/menu.cpp
index d6abd27..90ef41f 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -308,7 +308,7 @@ private:
g_menu_item_set_action_and_target_value (menu_item,
"indicator.activate-appointment",
g_variant_new_string (appt.uid.c_str()));
- else
+ else if (m_actions->can_open_planner())
g_menu_item_set_action_and_target_value (menu_item,
"indicator.activate-planner",
g_variant_new_int64 (unix_time));
@@ -325,13 +325,16 @@ private:
{
add_appointments (menu, profile);
- // add the 'Add Event…' menuitem
- auto menu_item = g_menu_item_new(_("Add Event…"), nullptr);
- const gchar* action_name = "indicator.activate-planner";
- auto v = g_variant_new_int64(0);
- g_menu_item_set_action_and_target_value(menu_item, action_name, v);
- g_menu_append_item(menu, menu_item);
- g_object_unref(menu_item);
+ if (m_actions->can_open_planner())
+ {
+ // add the 'Add Event…' menuitem
+ auto menu_item = g_menu_item_new(_("Add Event…"), nullptr);
+ const gchar* action_name = "indicator.activate-planner";
+ auto v = g_variant_new_int64(0);
+ g_menu_item_set_action_and_target_value(menu_item, action_name, v);
+ g_menu_append_item(menu, menu_item);
+ g_object_unref(menu_item);
+ }
}
else if (profile==Phone)
{