mirror of https://github.com/GNOME/gimp.git
plug-ins: improve error handling and use GError in metadata-editor/viewer.
metadata-editor and metadata-viewer did return GIMP_PDB_SUCCESS when loading the dialog ui failed, we changed this to GIMP_PDB_EXECUTION_ERROR and now use a GError to report it back to GIMP. In metadata-editor also improve the error handling when loading the calendar dialog fails. The error also only showed in the console so change that to show a dialog or the error console.
This commit is contained in:
parent
3d9a9fbbf3
commit
0ffee001bf
|
@ -75,7 +75,8 @@ static GimpValueArray * metadata_run (GimpProcedure *procedu
|
||||||
gpointer run_data);
|
gpointer run_data);
|
||||||
|
|
||||||
static gboolean metadata_editor_dialog (GimpImage *image,
|
static gboolean metadata_editor_dialog (GimpImage *image,
|
||||||
GimpMetadata *metadata);
|
GimpMetadata *metadata,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
static void metadata_dialog_editor_set_metadata (GExiv2Metadata *metadata,
|
static void metadata_dialog_editor_set_metadata (GExiv2Metadata *metadata,
|
||||||
GtkBuilder *builder);
|
GtkBuilder *builder);
|
||||||
|
@ -473,6 +474,7 @@ metadata_run (GimpProcedure *procedure,
|
||||||
{
|
{
|
||||||
GimpImage *image;
|
GimpImage *image;
|
||||||
GimpMetadata *metadata;
|
GimpMetadata *metadata;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
INIT_I18N ();
|
INIT_I18N ();
|
||||||
|
|
||||||
|
@ -493,9 +495,10 @@ metadata_run (GimpProcedure *procedure,
|
||||||
gimp_image_set_metadata (image, metadata);
|
gimp_image_set_metadata (image, metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
metadata_editor_dialog (image, metadata);
|
if (metadata_editor_dialog (image, metadata, &error))
|
||||||
|
return gimp_procedure_new_return_values (procedure, GIMP_PDB_SUCCESS, NULL);
|
||||||
return gimp_procedure_new_return_values (procedure, GIMP_PDB_SUCCESS, NULL);
|
else
|
||||||
|
return gimp_procedure_new_return_values (procedure, GIMP_PDB_EXECUTION_ERROR, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -514,8 +517,9 @@ builder_get_widget (GtkBuilder *builder,
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
metadata_editor_dialog (GimpImage *image,
|
metadata_editor_dialog (GimpImage *image,
|
||||||
GimpMetadata *g_metadata)
|
GimpMetadata *g_metadata,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
GtkBuilder *builder;
|
GtkBuilder *builder;
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
|
@ -526,7 +530,7 @@ metadata_editor_dialog (GimpImage *image,
|
||||||
gchar *ui_file;
|
gchar *ui_file;
|
||||||
gchar *title;
|
gchar *title;
|
||||||
gchar *name;
|
gchar *name;
|
||||||
GError *error = NULL;
|
GError *local_error = NULL;
|
||||||
gboolean run;
|
gboolean run;
|
||||||
|
|
||||||
metadata = GEXIV2_METADATA (g_metadata);
|
metadata = GEXIV2_METADATA (g_metadata);
|
||||||
|
@ -542,13 +546,14 @@ metadata_editor_dialog (GimpImage *image,
|
||||||
ui_file = g_build_filename (gimp_data_directory (),
|
ui_file = g_build_filename (gimp_data_directory (),
|
||||||
"ui", "plug-ins", "plug-in-metadata-editor.ui", NULL);
|
"ui", "plug-ins", "plug-in-metadata-editor.ui", NULL);
|
||||||
|
|
||||||
if (! gtk_builder_add_from_file (builder, ui_file, &error))
|
if (! gtk_builder_add_from_file (builder, ui_file, &local_error))
|
||||||
{
|
{
|
||||||
g_printerr ("Error occurred while loading UI file!\n");
|
if (! local_error)
|
||||||
g_printerr ("Message: %s\n", error->message);
|
local_error = g_error_new_literal (G_FILE_ERROR, 0,
|
||||||
g_clear_error (&error);
|
_("Error loading metadata-editor dialog."));
|
||||||
if (ui_file)
|
g_propagate_error (error, local_error);
|
||||||
g_free (ui_file);
|
|
||||||
|
g_free (ui_file);
|
||||||
g_object_unref (builder);
|
g_object_unref (builder);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -798,12 +803,11 @@ on_date_button_clicked (GtkButton *widget,
|
||||||
|
|
||||||
if (! gtk_builder_add_from_file (builder, ui_file, &error))
|
if (! gtk_builder_add_from_file (builder, ui_file, &error))
|
||||||
{
|
{
|
||||||
g_printerr ("Error occurred while loading UI file!\n");
|
g_log ("", G_LOG_LEVEL_MESSAGE,
|
||||||
if (error != NULL)
|
_("Error loading calendar. %s"),
|
||||||
{
|
error ? error->message : "");
|
||||||
g_printerr ("Message: %s\n", error->message);
|
g_clear_error (&error);
|
||||||
g_clear_error (&error);
|
|
||||||
}
|
|
||||||
if (ui_file)
|
if (ui_file)
|
||||||
g_free (ui_file);
|
g_free (ui_file);
|
||||||
g_object_unref (builder);
|
g_object_unref (builder);
|
||||||
|
|
|
@ -99,7 +99,8 @@ static GimpValueArray * metadata_run (GimpProcedure *procedu
|
||||||
gpointer run_data);
|
gpointer run_data);
|
||||||
|
|
||||||
static gboolean metadata_viewer_dialog (GimpImage *image,
|
static gboolean metadata_viewer_dialog (GimpImage *image,
|
||||||
GimpMetadata *g_metadata);
|
GimpMetadata *g_metadata,
|
||||||
|
GError **error);
|
||||||
static void metadata_dialog_set_metadata (GExiv2Metadata *metadata,
|
static void metadata_dialog_set_metadata (GExiv2Metadata *metadata,
|
||||||
GtkBuilder *builder);
|
GtkBuilder *builder);
|
||||||
static void metadata_dialog_append_tags (GExiv2Metadata *metadata,
|
static void metadata_dialog_append_tags (GExiv2Metadata *metadata,
|
||||||
|
@ -208,6 +209,7 @@ metadata_run (GimpProcedure *procedure,
|
||||||
{
|
{
|
||||||
GimpImage *image;
|
GimpImage *image;
|
||||||
GimpMetadata *metadata;
|
GimpMetadata *metadata;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
INIT_I18N ();
|
INIT_I18N ();
|
||||||
|
|
||||||
|
@ -228,14 +230,16 @@ metadata_run (GimpProcedure *procedure,
|
||||||
gimp_image_set_metadata (image, metadata);
|
gimp_image_set_metadata (image, metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
metadata_viewer_dialog (image, metadata);
|
if (metadata_viewer_dialog (image, metadata, &error))
|
||||||
|
return gimp_procedure_new_return_values (procedure, GIMP_PDB_SUCCESS, NULL);
|
||||||
return gimp_procedure_new_return_values (procedure, GIMP_PDB_SUCCESS, NULL);
|
else
|
||||||
|
return gimp_procedure_new_return_values (procedure, GIMP_PDB_EXECUTION_ERROR, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
metadata_viewer_dialog (GimpImage *image,
|
metadata_viewer_dialog (GimpImage *image,
|
||||||
GimpMetadata *g_metadata)
|
GimpMetadata *g_metadata,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
GtkBuilder *builder;
|
GtkBuilder *builder;
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
|
@ -244,7 +248,7 @@ metadata_viewer_dialog (GimpImage *image,
|
||||||
gchar *ui_file;
|
gchar *ui_file;
|
||||||
gchar *title;
|
gchar *title;
|
||||||
gchar *name;
|
gchar *name;
|
||||||
GError *error = NULL;
|
GError *local_error = NULL;
|
||||||
GExiv2Metadata *metadata;
|
GExiv2Metadata *metadata;
|
||||||
|
|
||||||
metadata = GEXIV2_METADATA(g_metadata);
|
metadata = GEXIV2_METADATA(g_metadata);
|
||||||
|
@ -254,11 +258,13 @@ metadata_viewer_dialog (GimpImage *image,
|
||||||
ui_file = g_build_filename (gimp_data_directory (),
|
ui_file = g_build_filename (gimp_data_directory (),
|
||||||
"ui", "plug-ins", "plug-in-metadata-viewer.ui", NULL);
|
"ui", "plug-ins", "plug-in-metadata-viewer.ui", NULL);
|
||||||
|
|
||||||
if (! gtk_builder_add_from_file (builder, ui_file, &error))
|
if (! gtk_builder_add_from_file (builder, ui_file, &local_error))
|
||||||
{
|
{
|
||||||
g_printerr ("Error occurred while loading UI file!\n");
|
if (! local_error)
|
||||||
g_printerr ("Message: %s\n", error->message);
|
local_error = g_error_new_literal (G_FILE_ERROR, 0,
|
||||||
g_clear_error (&error);
|
_("Error loading metadata-viewer dialog."));
|
||||||
|
g_propagate_error (error, local_error);
|
||||||
|
|
||||||
g_free (ui_file);
|
g_free (ui_file);
|
||||||
g_object_unref (builder);
|
g_object_unref (builder);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
Loading…
Reference in New Issue