mirror of
https://github.com/edu4rdshl/gnome-shell.git
synced 2026-07-17 23:24:51 +00:00
calendar-server: Launch default calendar app when clicked on notification
Rather than just disappearing the notification when the user clicks on it, open the default calendar app.
This commit is contained in:
parent
024a4f8559
commit
e35fe2c614
3 changed files with 56 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue