From 8b8c3f426b96071e3cf92b1236c6507586805647 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 16 Feb 2010 08:20:01 -0600 Subject: Some error handling. --- libindicator/indicator-desktop-shortcuts.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'libindicator') diff --git a/libindicator/indicator-desktop-shortcuts.c b/libindicator/indicator-desktop-shortcuts.c index eceec51..bfd8719 100644 --- a/libindicator/indicator-desktop-shortcuts.c +++ b/libindicator/indicator-desktop-shortcuts.c @@ -304,6 +304,8 @@ indicator_desktop_shortcuts_nick_get_name (IndicatorDesktopShortcuts * ids, cons gboolean indicator_desktop_shortcuts_nick_exec (IndicatorDesktopShortcuts * ids, const gchar * nick) { + GError * error = NULL; + g_return_val_if_fail(INDICATOR_IS_DESKTOP_SHORTCUTS(ids), FALSE); IndicatorDesktopShortcutsPrivate * priv = INDICATOR_DESKTOP_SHORTCUTS_GET_PRIVATE(ids); @@ -354,11 +356,24 @@ indicator_desktop_shortcuts_nick_exec (IndicatorDesktopShortcuts * ids, const gc g_free(name); g_free(exec); GKeyFile * launcher = g_key_file_new(); - g_key_file_load_from_data(launcher, desktopdata, -1, G_KEY_FILE_NONE, NULL); + g_key_file_load_from_data(launcher, desktopdata, -1, G_KEY_FILE_NONE, &error); g_free(desktopdata); + if (error != NULL) { + g_warning("Unable to build desktop keyfile for executing shortcut '%s': %s", nick, error->message); + g_error_free(error); + return FALSE; + } + GDesktopAppInfo * appinfo = g_desktop_app_info_new_from_keyfile(launcher); - gboolean launched = g_app_info_launch(G_APP_INFO(appinfo), NULL, NULL, NULL); + gboolean launched = g_app_info_launch(G_APP_INFO(appinfo), NULL, NULL, &error); + + if (error != NULL) { + g_warning("Unable to launch file from nick '%s': %s", nick, error->message); + g_error_free(error); + g_key_file_free(launcher); + return FALSE; + } g_object_unref(appinfo); g_key_file_free(launcher); -- cgit v1.2.3