[gthumb] browser: show loading errors in the info bar
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] browser: show loading errors in the info bar
- Date: Thu, 2 Aug 2012 12:34:59 +0000 (UTC)
commit 5d96ff557a38f0fe537eaa253484db9ba830081c
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sun May 20 15:11:11 2012 +0200
browser: show loading errors in the info bar
...instead of using a modal dialog that forces the user to click on the
close button.
gthumb/gth-browser.c | 41 +++++++++++++++++++++++++++++++----------
gthumb/gth-info-bar.c | 18 ++++++++++++++++++
2 files changed, 49 insertions(+), 10 deletions(-)
---
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index d5fdff8..eef6350 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -1246,6 +1246,27 @@ file_format (const char *format,
static void
+_gth_browser_show_error (GthBrowser *browser,
+ const char *title,
+ GError *error)
+{
+ /* _gtk_error_dialog_from_gerror_show (GTK_WINDOW (browser), title, error); */
+
+ gth_info_bar_set_primary_text (GTH_INFO_BAR (browser->priv->infobar), title);
+ gth_info_bar_set_secondary_text (GTH_INFO_BAR (browser->priv->infobar), error->message);
+
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (gtk_info_bar_get_action_area (GTK_INFO_BAR (browser->priv->infobar))), GTK_ORIENTATION_HORIZONTAL);
+ gth_info_bar_set_icon (GTH_INFO_BAR (browser->priv->infobar), GTK_STOCK_DIALOG_ERROR);
+ gtk_info_bar_set_message_type (GTK_INFO_BAR (browser->priv->infobar), GTK_MESSAGE_ERROR);
+ _gtk_info_bar_clear_action_area (GTK_INFO_BAR (browser->priv->infobar));
+ gtk_info_bar_add_buttons (GTK_INFO_BAR (browser->priv->infobar),
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
+ NULL);
+ gtk_widget_show (browser->priv->infobar);
+}
+
+
+static void
load_data_done (LoadData *load_data,
GError *error)
{
@@ -1311,10 +1332,10 @@ load_data_done (LoadData *load_data,
gth_browser_update_sensitivity (browser);
title = file_format (_("Could not load the position \"%s\""), load_data->requested_folder->file);
- _gtk_error_dialog_from_gerror_show (GTK_WINDOW (browser), title, error);
- g_error_free (error);
+ _gth_browser_show_error (browser, title, error);
g_free (title);
+ g_error_free (error);
}
@@ -1880,7 +1901,7 @@ mount_volume_ready_cb (GObject *source_object,
char *title;
title = file_format (_("Could not load the position \"%s\""), load_data->requested_folder->file);
- _gtk_error_dialog_from_gerror_show (GTK_WINDOW (load_data->browser), title, error);
+ _gth_browser_show_error (load_data->browser, title, error);
g_clear_error (&error);
g_free (title);
@@ -2074,7 +2095,7 @@ ask_whether_to_save__file_saved_cb (GthViewerPage *viewer_page,
error_occurred = error != NULL;
if (error != NULL)
- _gtk_error_dialog_from_gerror_show (GTK_WINDOW (data->browser), _("Could not save the file"), error);
+ _gth_browser_show_error (data->browser, _("Could not save the file"), error);
ask_whether_to_save__done (data, error_occurred);
}
@@ -2903,7 +2924,7 @@ file_source_rename_ready_cb (GObject *object,
g_object_unref (object);
if (error != NULL)
- _gtk_error_dialog_from_gerror_show (GTK_WINDOW (browser), _("Could not change name"), error);
+ _gth_browser_show_error (browser, _("Could not change name"), error);
}
@@ -5087,7 +5108,7 @@ background_task_completed_cb (GthTask *task,
return;
if (! g_error_matches (error, GTH_TASK_ERROR, GTH_TASK_ERROR_CANCELLED) && ! g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- _gtk_error_dialog_from_gerror_show (GTK_WINDOW (browser), _("Could not perform the operation"), error);
+ _gth_browser_show_error (browser, _("Could not perform the operation"), error);
}
@@ -5121,7 +5142,7 @@ foreground_task_completed_cb (GthTask *task,
gth_statusbar_set_progress (GTH_STATUSBAR (browser->priv->statusbar), NULL, FALSE, 0.0);
gth_browser_update_sensitivity (browser);
if ((error != NULL) && ! g_error_matches (error, GTH_TASK_ERROR, GTH_TASK_ERROR_CANCELLED))
- _gtk_error_dialog_from_gerror_show (GTK_WINDOW (browser), _("Could not perform the operation"), error);
+ _gth_browser_show_error (browser, _("Could not perform the operation"), error);
g_object_unref (browser->priv->task);
browser->priv->task = NULL;
@@ -6052,7 +6073,7 @@ load_file_attributes_ready_cb (GObject *object,
title = file_format (_("Could not load the position \"%s\""), data->location_data->file);
error = g_error_new (GTH_ERROR, 0, _("File type not supported"));
- _gtk_error_dialog_from_gerror_show (GTK_WINDOW (browser), title, error);
+ _gth_browser_show_error (browser, title, error);
g_clear_error (&error);
g_free (title);
@@ -6070,7 +6091,7 @@ load_file_attributes_ready_cb (GObject *object,
char *title;
title = file_format (_("Could not load the position \"%s\""), data->location_data->file);
- _gtk_error_dialog_from_gerror_show (GTK_WINDOW (browser), title, error);
+ _gth_browser_show_error (browser, title, error);
g_free (title);
}
@@ -6095,7 +6116,7 @@ gth_browser_load_location (GthBrowser *browser,
title = file_format (_("Could not load the position \"%s\""), data->location_data->file);
error = g_error_new (GTH_ERROR, 0, _("No suitable module found"));
- _gtk_error_dialog_from_gerror_show (GTK_WINDOW (browser), title, error);
+ _gth_browser_show_error (browser, title, error);
g_clear_error (&error);
g_free (title);
diff --git a/gthumb/gth-info-bar.c b/gthumb/gth-info-bar.c
index 6b2c2f6..a4f412e 100644
--- a/gthumb/gth-info-bar.c
+++ b/gthumb/gth-info-bar.c
@@ -49,6 +49,19 @@ gth_info_bar_init (GthInfoBar *self)
static void
+infobar_response_cb (GtkInfoBar *self,
+ int response_id,
+ gpointer user_data)
+{
+ switch (response_id) {
+ case GTK_RESPONSE_CLOSE:
+ gtk_widget_hide (GTK_WIDGET (self));
+ break;
+ }
+}
+
+
+static void
gth_info_bar_construct (GthInfoBar *self)
{
GtkWidget *hbox_content;
@@ -101,6 +114,11 @@ gth_info_bar_construct (GthInfoBar *self)
gtk_widget_set_name (GTK_WIDGET (self), "GthInfoBar");
gtk_info_bar_set_message_type (GTK_INFO_BAR (self), GTK_MESSAGE_OTHER);
gtk_container_set_border_width (GTK_CONTAINER (self), 0);
+
+ g_signal_connect (self,
+ "response",
+ G_CALLBACK (infobar_response_cb),
+ NULL);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]