Commit 13c7cdfd authored by Alberts Muktupāvels's avatar Alberts Muktupāvels

menu: add gp_menu_utils_show_error_dialog

parent 8e5a9e5b
......@@ -335,26 +335,19 @@ gp_menu_utils_app_info_launch (GDesktopAppInfo *app_info)
{
GError *error;
const gchar *display_name;
GtkWidget *dialog;
gchar *message;
error = NULL;
if (app_info_launch_uris (app_info, NULL, &error))
return;
display_name = g_app_info_get_display_name (G_APP_INFO (app_info));
dialog = gtk_message_dialog_new (NULL, 0,
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
_("Could not launch '%s'"),
display_name);
message = g_strdup_printf (_("Could not launch '%s'"), display_name);
if (error != NULL)
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
"%s", error->message);
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
gtk_window_present (GTK_WINDOW (dialog));
gp_menu_utils_show_error_dialog (message, error);
g_clear_error (&error);
g_free (message);
}
void
......@@ -362,7 +355,7 @@ gp_menu_utils_launch_uri (const gchar *uri)
{
GError *error;
GAppInfo *app_info;
GtkWidget *dialog;
gchar *message;
error = NULL;
app_info = get_app_info_for_uri (uri, &error);
......@@ -383,19 +376,12 @@ gp_menu_utils_launch_uri (const gchar *uri)
return;
}
dialog = gtk_message_dialog_new (NULL, 0,
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
_("Could not open location '%s'"),
uri);
message = g_strdup_printf (_("Could not open location '%s'"), uri);
if (error != NULL)
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
"%s", error->message);
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
gtk_window_present (GTK_WINDOW (dialog));
gp_menu_utils_show_error_dialog (message, error);
g_clear_error (&error);
g_free (message);
}
GIcon *
......@@ -444,3 +430,21 @@ gp_menu_utils_get_label_for_file (GFile *file)
return get_root_label (file);
}
void
gp_menu_utils_show_error_dialog (const gchar *message,
GError *error)
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new (NULL, 0,
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
"%s", message);
if (error != NULL)
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
"%s", error->message);
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
gtk_window_present (GTK_WINDOW (dialog));
}
......@@ -30,6 +30,9 @@ GIcon *gp_menu_utils_get_icon_for_file (GFile *file);
gchar *gp_menu_utils_get_label_for_file (GFile *file);
void gp_menu_utils_show_error_dialog (const gchar *message,
GError *error);
G_END_DECLS
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment