diff --git a/src/calendar-server/gnome-shell-calendar-server.c b/src/calendar-server/gnome-shell-calendar-server.c index 91c484da9..c12c7c277 100644 --- a/src/calendar-server/gnome-shell-calendar-server.c +++ b/src/calendar-server/gnome-shell-calendar-server.c @@ -1090,6 +1090,18 @@ app_dismiss_reminder_cb (GSimpleAction *action, reminder_watcher_dismiss_by_id (app->reminder_watcher, g_variant_get_string (parameter, NULL)); } +static void +app_open_in_app_cb (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) +{ + App *app = _global_app; + + g_return_if_fail (app != NULL); + + reminder_watcher_open_in_app_by_id (app->reminder_watcher, g_variant_get_string (parameter, NULL)); +} + int main (int argc, char **argv) @@ -1101,7 +1113,8 @@ main (int argc, }; const GActionEntry action_entries[] = { { "snooze-reminder", app_snooze_reminder_cb, "s" }, - { "dismiss-reminder", app_dismiss_reminder_cb, "s" } + { "dismiss-reminder", app_dismiss_reminder_cb, "s" }, + { "open-in-app", app_open_in_app_cb, "s" } }; g_autoptr (GApplication) application = NULL; g_autoptr (GError) error = NULL; diff --git a/src/calendar-server/reminder-watcher.c b/src/calendar-server/reminder-watcher.c index e2ae079a8..51c8868ac 100644 --- a/src/calendar-server/reminder-watcher.c +++ b/src/calendar-server/reminder-watcher.c @@ -234,6 +234,7 @@ reminder_watcher_notify_display (ReminderWatcher *rw, } #endif + g_notification_set_default_action_and_target (notification, "app.open-in-app", "s", notif_id); g_notification_add_button_with_target (notification, _("Snooze"), "app.snooze-reminder", "s", notif_id); g_notification_add_button_with_target (notification, _("Dismiss"), "app.dismiss-reminder", "s", notif_id); @@ -813,3 +814,41 @@ reminder_watcher_snooze_by_id (EReminderWatcher *reminder_watcher, print_debug ("Snooze: Cannot find reminder '%s'", id); } } + +void +reminder_watcher_open_in_app_by_id (EReminderWatcher *reminder_watcher, + const gchar *id) +{ + GAppInfo *app_info; + GError *local_error = NULL; + + app_info = g_app_info_get_default_for_type ("text/calendar", FALSE); + if (app_info == NULL) + { + GList *recommended; + + print_debug ("OpenInApp: No default application for 'text/calendar' found"); + + recommended = g_app_info_get_recommended_for_type ("text/calendar"); + if (recommended) + { + /* pick the last used, when there's no default app */ + app_info = g_object_ref (recommended->data); + + g_list_free_full (recommended, g_object_unref); + } + else + { + print_debug ("OpenInApp: No recommended application for 'text/calendar' found"); + return; + } + } + + if (g_app_info_launch_uris (app_info, NULL, NULL, &local_error)) + print_debug ("OpenInApp: Launched '%s'", g_app_info_get_executable (app_info)); + else + print_debug ("OpenInApp: Failed to launch '%s': %s", g_app_info_get_executable (app_info), local_error ? local_error->message : "Unknown error"); + + g_object_unref (app_info); + g_clear_error (&local_error); +} diff --git a/src/calendar-server/reminder-watcher.h b/src/calendar-server/reminder-watcher.h index f526b916a..27e1a299d 100644 --- a/src/calendar-server/reminder-watcher.h +++ b/src/calendar-server/reminder-watcher.h @@ -63,7 +63,9 @@ void reminder_watcher_dismiss_by_id(EReminderWatcher *reminder_watc const gchar *id); void reminder_watcher_snooze_by_id (EReminderWatcher *reminder_watcher, const gchar *id); - +void reminder_watcher_open_in_app_by_id + (EReminderWatcher *reminder_watcher, + const gchar *id); G_END_DECLS #endif /* REMINDER_WATCHER_H */