[gimp] app: turn get_label() and get_blurb() into virtual functions of GimpProcedure
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: turn get_label() and get_blurb() into virtual functions of GimpProcedure
- Date: Fri, 1 Jan 2016 19:54:24 +0000 (UTC)
commit 1d3bf65934ceb14f68ba6849b524ef418e63db7e
Author: Michael Natterer <mitch gimp org>
Date: Fri Jan 1 20:52:45 2016 +0100
app: turn get_label() and get_blurb() into virtual functions of GimpProcedure
app/actions/filters-actions.c | 25 +++---
app/actions/plug-in-actions.c | 2 +-
app/file/file-open.c | 4 +-
app/file/file-save.c | 2 +-
app/pdb/gimpprocedure.c | 82 +++++++++++++------
app/pdb/gimpprocedure.h | 6 ++
app/plug-in/gimpplugin-cleanup.c | 8 +--
app/plug-in/gimpplugin.c | 11 +--
app/plug-in/gimppluginmanager-restore.c | 4 +-
app/plug-in/gimppluginprocedure.c | 131 +++++++++++++++----------------
app/plug-in/gimppluginprocedure.h | 4 -
app/widgets/gimpfiledialog.c | 2 +-
app/widgets/gimpfileprocview.c | 2 +-
app/widgets/gimpimagepropview.c | 3 +-
14 files changed, 154 insertions(+), 132 deletions(-)
---
diff --git a/app/actions/filters-actions.c b/app/actions/filters-actions.c
index 3004c26..d21d091 100644
--- a/app/actions/filters-actions.c
+++ b/app/actions/filters-actions.c
@@ -785,8 +785,16 @@ filters_actions_history_changed (Gimp *gimp,
gchar *reshow;
gboolean sensitive = FALSE;
- /* FIXME history */
- label = gimp_plug_in_procedure_get_label (GIMP_PLUG_IN_PROCEDURE (proc));
+ label = gimp_procedure_get_label (proc);
+
+ repeat = g_strdup_printf (_("Re_peat \"%s\""), label);
+ reshow = g_strdup_printf (_("R_e-Show \"%s\""), label);
+
+ gimp_action_group_set_action_label (group, "filters-repeat", repeat);
+ gimp_action_group_set_action_label (group, "filters-reshow", reshow);
+
+ g_free (repeat);
+ g_free (reshow);
/* copy the sensitivity of the plug-in procedure's actual action
* instead of calling filters_actions_update() because doing the
@@ -802,19 +810,10 @@ filters_actions_history_changed (Gimp *gimp,
sensitive = gtk_action_get_sensitive (actual_action);
}
- repeat = g_strdup_printf (_("Re_peat \"%s\""), label);
- reshow = g_strdup_printf (_("R_e-Show \"%s\""), label);
-
- gimp_action_group_set_action_label (group, "filters-repeat", repeat);
- gimp_action_group_set_action_label (group, "filters-reshow", reshow);
-
gimp_action_group_set_action_sensitive (group, "filters-repeat",
sensitive);
gimp_action_group_set_action_sensitive (group, "filters-reshow",
sensitive);
-
- g_free (repeat);
- g_free (reshow);
}
else
{
@@ -848,7 +847,7 @@ filters_actions_history_changed (Gimp *gimp,
}
else
{
- label = gimp_plug_in_procedure_get_label (GIMP_PLUG_IN_PROCEDURE (proc));
+ label = gimp_procedure_get_label (proc);
}
/* see comment above */
@@ -867,7 +866,7 @@ filters_actions_history_changed (Gimp *gimp,
"procedure", proc,
"label", label,
"icon-name", gimp_viewable_get_icon_name (GIMP_VIEWABLE (proc)),
- "tooltip", gimp_plug_in_procedure_get_blurb (GIMP_PLUG_IN_PROCEDURE (proc)),
+ "tooltip", gimp_procedure_get_blurb (proc),
NULL);
}
diff --git a/app/actions/plug-in-actions.c b/app/actions/plug-in-actions.c
index 4f39d4d..665fa96 100644
--- a/app/actions/plug-in-actions.c
+++ b/app/actions/plug-in-actions.c
@@ -336,7 +336,7 @@ plug_in_actions_add_proc (GimpActionGroup *group,
entry.icon_name = gimp_viewable_get_icon_name (GIMP_VIEWABLE (proc));
entry.label = label;
entry.accelerator = NULL;
- entry.tooltip = gimp_plug_in_procedure_get_blurb (proc);
+ entry.tooltip = gimp_procedure_get_blurb (GIMP_PROCEDURE (proc));
entry.procedure = GIMP_PROCEDURE (proc);
entry.help_id = gimp_plug_in_procedure_get_help_id (proc);
diff --git a/app/file/file-open.c b/app/file/file-open.c
index b15acb2..74bbca4 100644
--- a/app/file/file-open.c
+++ b/app/file/file-open.c
@@ -230,7 +230,7 @@ file_open_image (Gimp *gimp,
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("%s plug-in returned SUCCESS but did not "
"return an image"),
- gimp_plug_in_procedure_get_label (file_proc));
+ gimp_procedure_get_label (GIMP_PROCEDURE (file_proc)));
*status = GIMP_PDB_EXECUTION_ERROR;
}
@@ -240,7 +240,7 @@ file_open_image (Gimp *gimp,
if (error && ! *error)
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("%s plug-In could not open image"),
- gimp_plug_in_procedure_get_label (file_proc));
+ gimp_procedure_get_label (GIMP_PROCEDURE (file_proc)));
}
gimp_value_array_unref (return_vals);
diff --git a/app/file/file-save.c b/app/file/file-save.c
index c17b3d4..5768ea9 100644
--- a/app/file/file-save.c
+++ b/app/file/file-save.c
@@ -277,7 +277,7 @@ file_save (Gimp *gimp,
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("%s plug-in could not save image"),
- gimp_plug_in_procedure_get_label (file_proc));
+ gimp_procedure_get_label (GIMP_PROCEDURE (file_proc)));
}
}
diff --git a/app/pdb/gimpprocedure.c b/app/pdb/gimpprocedure.c
index da3b42a..204b510 100644
--- a/app/pdb/gimpprocedure.c
+++ b/app/pdb/gimpprocedure.c
@@ -43,31 +43,33 @@
#include "gimp-intl.h"
-static void gimp_procedure_finalize (GObject *object);
-
-static gint64 gimp_procedure_get_memsize (GimpObject *object,
- gint64 *gui_size);
-
-static GimpValueArray * gimp_procedure_real_execute (GimpProcedure *procedure,
- Gimp *gimp,
- GimpContext *context,
- GimpProgress *progress,
- GimpValueArray *args,
- GError **error);
-static void gimp_procedure_real_execute_async (GimpProcedure *procedure,
- Gimp *gimp,
- GimpContext *context,
- GimpProgress *progress,
- GimpValueArray *args,
- GimpObject *display);
-
-static void gimp_procedure_free_strings (GimpProcedure *procedure);
-static gboolean gimp_procedure_validate_args (GimpProcedure *procedure,
- GParamSpec **param_specs,
- gint n_param_specs,
- GimpValueArray *args,
- gboolean return_vals,
- GError **error);
+static void gimp_procedure_finalize (GObject *object);
+
+static gint64 gimp_procedure_get_memsize (GimpObject *object,
+ gint64 *gui_size);
+
+static const gchar * gimp_procedure_real_get_label (GimpProcedure *procedure);
+static const gchar * gimp_procedure_real_get_blurb (GimpProcedure *procedure);
+static GimpValueArray * gimp_procedure_real_execute (GimpProcedure *procedure,
+ Gimp *gimp,
+ GimpContext *context,
+ GimpProgress *progress,
+ GimpValueArray *args,
+ GError **error);
+static void gimp_procedure_real_execute_async (GimpProcedure *procedure,
+ Gimp *gimp,
+ GimpContext *context,
+ GimpProgress *progress,
+ GimpValueArray *args,
+ GimpObject *display);
+
+static void gimp_procedure_free_strings (GimpProcedure *procedure);
+static gboolean gimp_procedure_validate_args (GimpProcedure *procedure,
+ GParamSpec **param_specs,
+ gint n_param_specs,
+ GimpValueArray *args,
+ gboolean return_vals,
+ GError **error);
G_DEFINE_TYPE (GimpProcedure, gimp_procedure, GIMP_TYPE_VIEWABLE)
@@ -85,6 +87,8 @@ gimp_procedure_class_init (GimpProcedureClass *klass)
gimp_object_class->get_memsize = gimp_procedure_get_memsize;
+ klass->get_label = gimp_procedure_real_get_label;
+ klass->get_blurb = gimp_procedure_real_get_blurb;
klass->execute = gimp_procedure_real_execute;
klass->execute_async = gimp_procedure_real_execute_async;
}
@@ -157,6 +161,18 @@ gimp_procedure_get_memsize (GimpObject *object,
gui_size);
}
+static const gchar *
+gimp_procedure_real_get_label (GimpProcedure *procedure)
+{
+ return gimp_object_get_name (procedure); /* lame fallback */
+}
+
+static const gchar *
+gimp_procedure_real_get_blurb (GimpProcedure *procedure)
+{
+ return procedure->blurb;
+}
+
static GimpValueArray *
gimp_procedure_real_execute (GimpProcedure *procedure,
Gimp *gimp,
@@ -295,6 +311,22 @@ gimp_procedure_take_strings (GimpProcedure *procedure,
procedure->static_strings = FALSE;
}
+const gchar *
+gimp_procedure_get_label (GimpProcedure *procedure)
+{
+ g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
+
+ return GIMP_PROCEDURE_GET_CLASS (procedure)->get_label (procedure);
+}
+
+const gchar *
+gimp_procedure_get_blurb (GimpProcedure *procedure)
+{
+ g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), NULL);
+
+ return GIMP_PROCEDURE_GET_CLASS (procedure)->get_blurb (procedure);
+}
+
GimpValueArray *
gimp_procedure_execute (GimpProcedure *procedure,
Gimp *gimp,
diff --git a/app/pdb/gimpprocedure.h b/app/pdb/gimpprocedure.h
index 4cbae07..d3cc5dc 100644
--- a/app/pdb/gimpprocedure.h
+++ b/app/pdb/gimpprocedure.h
@@ -69,6 +69,9 @@ struct _GimpProcedureClass
{
GimpViewableClass parent_class;
+ const gchar * (* get_label) (GimpProcedure *procedure);
+ const gchar * (* get_blurb) (GimpProcedure *procedure);
+
GimpValueArray * (* execute) (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
@@ -113,6 +116,9 @@ void gimp_procedure_take_strings (GimpProcedure *procedure,
gchar *date,
gchar *deprecated);
+const gchar * gimp_procedure_get_label (GimpProcedure *procedure);
+const gchar * gimp_procedure_get_blurb (GimpProcedure *procedure);
+
void gimp_procedure_add_argument (GimpProcedure *procedure,
GParamSpec *pspec);
void gimp_procedure_add_return_value (GimpProcedure *procedure,
diff --git a/app/plug-in/gimpplugin-cleanup.c b/app/plug-in/gimpplugin-cleanup.c
index 2e99a3d..e4fbe4a 100644
--- a/app/plug-in/gimpplugin-cleanup.c
+++ b/app/plug-in/gimpplugin-cleanup.c
@@ -279,11 +279,9 @@ gimp_plug_in_cleanup_image (GimpPlugInProcFrame *proc_frame,
if (cleanup->undo_group_count != gimp_image_get_undo_group_count (image))
{
- GimpProcedure *proc = proc_frame->procedure;
-
g_message ("Plug-In '%s' left image undo in inconsistent state, "
"closing open undo groups.",
- gimp_plug_in_procedure_get_label (GIMP_PLUG_IN_PROCEDURE (proc)));
+ gimp_procedure_get_label (proc_frame->procedure));
while (cleanup->undo_group_count < gimp_image_get_undo_group_count (image))
{
@@ -335,12 +333,10 @@ gimp_plug_in_cleanup_item (GimpPlugInProcFrame *proc_frame,
if (cleanup->shadow_buffer)
{
- GimpProcedure *proc = proc_frame->procedure;
-
GIMP_LOG (SHADOW_TILES,
"Freeing shadow buffer of drawable '%s' on behalf of '%s'.",
gimp_object_get_name (item),
- gimp_plug_in_procedure_get_label (GIMP_PLUG_IN_PROCEDURE (proc)));
+ gimp_procedure_get_label (proc_frame->procedure));
gimp_drawable_free_shadow_buffer (GIMP_DRAWABLE (item));
}
diff --git a/app/plug-in/gimpplugin.c b/app/plug-in/gimpplugin.c
index 93e4dc0..b2dc2d4 100644
--- a/app/plug-in/gimpplugin.c
+++ b/app/plug-in/gimpplugin.c
@@ -859,15 +859,8 @@ gimp_plug_in_get_undo_desc (GimpPlugIn *plug_in)
proc_frame = gimp_plug_in_get_proc_frame (plug_in);
- if (proc_frame)
- {
- GimpPlugInProcedure *proc;
-
- proc = GIMP_PLUG_IN_PROCEDURE (proc_frame->procedure);
-
- if (proc)
- undo_desc = gimp_plug_in_procedure_get_label (proc);
- }
+ if (proc_frame && proc_frame->procedure)
+ undo_desc = gimp_procedure_get_label (proc_frame->procedure);
return undo_desc ? undo_desc : gimp_object_get_name (plug_in);
}
diff --git a/app/plug-in/gimppluginmanager-restore.c b/app/plug-in/gimppluginmanager-restore.c
index 50e9367..1b1f123 100644
--- a/app/plug-in/gimppluginmanager-restore.c
+++ b/app/plug-in/gimppluginmanager-restore.c
@@ -815,8 +815,8 @@ gimp_plug_in_manager_file_proc_compare (gconstpointer a,
if (g_str_has_prefix (gimp_file_get_utf8_name (proc_b->file), "gimp-xcf"))
return 1;
- label_a = gimp_plug_in_procedure_get_label (proc_a);
- label_b = gimp_plug_in_procedure_get_label (proc_b);
+ label_a = gimp_procedure_get_label (GIMP_PROCEDURE (proc_a));
+ label_b = gimp_procedure_get_label (GIMP_PROCEDURE (proc_b));
if (label_a && label_b)
retval = g_utf8_collate (label_a, label_b);
diff --git a/app/plug-in/gimppluginprocedure.c b/app/plug-in/gimppluginprocedure.c
index 67d26ff..7b9e4fb 100644
--- a/app/plug-in/gimppluginprocedure.c
+++ b/app/plug-in/gimppluginprocedure.c
@@ -61,6 +61,8 @@ static gint64 gimp_plug_in_procedure_get_memsize (GimpObject *object,
static gchar * gimp_plug_in_procedure_get_description (GimpViewable *viewable,
gchar **tooltip);
+static const gchar * gimp_plug_in_procedure_get_label (GimpProcedure *procedure);
+static const gchar * gimp_plug_in_procedure_get_blurb (GimpProcedure *procedure);
static GimpValueArray * gimp_plug_in_procedure_execute (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
@@ -110,6 +112,8 @@ gimp_plug_in_procedure_class_init (GimpPlugInProcedureClass *klass)
viewable_class->default_icon_name = "system-run";
viewable_class->get_description = gimp_plug_in_procedure_get_description;
+ proc_class->get_label = gimp_plug_in_procedure_get_label;
+ proc_class->get_blurb = gimp_plug_in_procedure_get_blurb;
proc_class->execute = gimp_plug_in_procedure_execute;
proc_class->execute_async = gimp_plug_in_procedure_execute_async;
@@ -205,12 +209,68 @@ static gchar *
gimp_plug_in_procedure_get_description (GimpViewable *viewable,
gchar **tooltip)
{
- GimpPlugInProcedure *proc = GIMP_PLUG_IN_PROCEDURE (viewable);
+ GimpProcedure *procedure = GIMP_PROCEDURE (viewable);
if (tooltip)
- *tooltip = g_strdup (gimp_plug_in_procedure_get_blurb (proc));
+ *tooltip = g_strdup (gimp_procedure_get_blurb (procedure));
- return g_strdup (gimp_plug_in_procedure_get_label (proc));
+ return g_strdup (gimp_procedure_get_label (procedure));
+}
+
+static const gchar *
+gimp_plug_in_procedure_get_label (GimpProcedure *procedure)
+{
+ GimpPlugInProcedure *proc = GIMP_PLUG_IN_PROCEDURE (procedure);
+ const gchar *path;
+ gchar *stripped;
+ gchar *ellipsis;
+ gchar *label;
+
+ if (proc->label)
+ return proc->label;
+
+ if (proc->menu_label)
+ path = dgettext (gimp_plug_in_procedure_get_locale_domain (proc),
+ proc->menu_label);
+ else if (proc->menu_paths)
+ path = dgettext (gimp_plug_in_procedure_get_locale_domain (proc),
+ proc->menu_paths->data);
+ else
+ return NULL;
+
+ stripped = gimp_strip_uline (path);
+
+ if (proc->menu_label)
+ label = g_strdup (stripped);
+ else
+ label = g_path_get_basename (stripped);
+
+ g_free (stripped);
+
+ ellipsis = strstr (label, "...");
+
+ if (! ellipsis)
+ ellipsis = strstr (label, "\342\200\246" /* U+2026 HORIZONTAL ELLIPSIS */);
+
+ if (ellipsis && ellipsis == (label + strlen (label) - 3))
+ *ellipsis = '\0';
+
+ proc->label = label;
+
+ return proc->label;
+}
+
+static const gchar *
+gimp_plug_in_procedure_get_blurb (GimpProcedure *procedure)
+{
+ GimpPlugInProcedure *proc = GIMP_PLUG_IN_PROCEDURE (procedure);
+
+ /* do not to pass the empty string to gettext() */
+ if (procedure->blurb && strlen (procedure->blurb))
+ return dgettext (gimp_plug_in_procedure_get_locale_domain (proc),
+ procedure->blurb);
+
+ return NULL;
}
static GimpValueArray *
@@ -541,67 +601,6 @@ gimp_plug_in_procedure_add_menu_path (GimpPlugInProcedure *proc,
return FALSE;
}
-const gchar *
-gimp_plug_in_procedure_get_label (GimpPlugInProcedure *proc)
-{
- const gchar *path;
- gchar *stripped;
- gchar *ellipsis;
- gchar *label;
-
- g_return_val_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (proc), NULL);
-
- if (proc->label)
- return proc->label;
-
- if (proc->menu_label)
- path = dgettext (gimp_plug_in_procedure_get_locale_domain (proc),
- proc->menu_label);
- else if (proc->menu_paths)
- path = dgettext (gimp_plug_in_procedure_get_locale_domain (proc),
- proc->menu_paths->data);
- else
- return NULL;
-
- stripped = gimp_strip_uline (path);
-
- if (proc->menu_label)
- label = g_strdup (stripped);
- else
- label = g_path_get_basename (stripped);
-
- g_free (stripped);
-
- ellipsis = strstr (label, "...");
-
- if (! ellipsis)
- ellipsis = strstr (label, "\342\200\246" /* U+2026 HORIZONTAL ELLIPSIS */);
-
- if (ellipsis && ellipsis == (label + strlen (label) - 3))
- *ellipsis = '\0';
-
- proc->label = label;
-
- return proc->label;
-}
-
-const gchar *
-gimp_plug_in_procedure_get_blurb (const GimpPlugInProcedure *proc)
-{
- GimpProcedure *procedure;
-
- g_return_val_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (proc), NULL);
-
- procedure = GIMP_PROCEDURE (proc);
-
- /* do not to pass the empty string to gettext() */
- if (procedure->blurb && strlen (procedure->blurb))
- return dgettext (gimp_plug_in_procedure_get_locale_domain (proc),
- procedure->blurb);
-
- return NULL;
-}
-
void
gimp_plug_in_procedure_set_icon (GimpPlugInProcedure *proc,
GimpIconType icon_type,
@@ -1022,7 +1021,7 @@ gimp_plug_in_procedure_handle_return_values (GimpPlugInProcedure *proc,
gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR,
_("Calling error for '%s':\n"
"%s"),
- gimp_plug_in_procedure_get_label (proc),
+ gimp_procedure_get_label (GIMP_PROCEDURE (proc)),
g_value_get_string (gimp_value_array_index (return_vals, 1)));
}
break;
@@ -1034,7 +1033,7 @@ gimp_plug_in_procedure_handle_return_values (GimpPlugInProcedure *proc,
gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR,
_("Execution error for '%s':\n"
"%s"),
- gimp_plug_in_procedure_get_label (proc),
+ gimp_procedure_get_label (GIMP_PROCEDURE (proc)),
g_value_get_string (gimp_value_array_index (return_vals, 1)));
}
break;
diff --git a/app/plug-in/gimppluginprocedure.h b/app/plug-in/gimppluginprocedure.h
index 2f1270c..d688236 100644
--- a/app/plug-in/gimppluginprocedure.h
+++ b/app/plug-in/gimppluginprocedure.h
@@ -101,10 +101,6 @@ gboolean gimp_plug_in_procedure_add_menu_path (GimpPlugInProcedure
const gchar *menu_path,
GError **error);
-const gchar * gimp_plug_in_procedure_get_label (GimpPlugInProcedure *proc);
-
-const gchar * gimp_plug_in_procedure_get_blurb (const GimpPlugInProcedure *proc);
-
void gimp_plug_in_procedure_set_icon (GimpPlugInProcedure *proc,
GimpIconType type,
const guint8 *data,
diff --git a/app/widgets/gimpfiledialog.c b/app/widgets/gimpfiledialog.c
index 9304c5f..3b3a7c8 100644
--- a/app/widgets/gimpfiledialog.c
+++ b/app/widgets/gimpfiledialog.c
@@ -797,7 +797,7 @@ gimp_file_dialog_process_procedure (GimpPlugInProcedure *file_proc,
return;
filter = gtk_file_filter_new ();
- str = g_string_new (gimp_plug_in_procedure_get_label (file_proc));
+ str = g_string_new (gimp_procedure_get_label (GIMP_PROCEDURE (file_proc)));
/* Take ownership directly so we don't have to mess with a floating
* ref
diff --git a/app/widgets/gimpfileprocview.c b/app/widgets/gimpfileprocview.c
index cb102d5..f720f8c 100644
--- a/app/widgets/gimpfileprocview.c
+++ b/app/widgets/gimpfileprocview.c
@@ -138,7 +138,7 @@ gimp_file_proc_view_new (Gimp *gimp,
if (! proc->prefixes_list) /* skip URL loaders */
{
- const gchar *label = gimp_plug_in_procedure_get_label (proc);
+ const gchar *label = gimp_procedure_get_label (GIMP_PROCEDURE (proc));
gchar *help_id = gimp_plug_in_procedure_get_help_id (proc);
GSList *list2;
diff --git a/app/widgets/gimpimagepropview.c b/app/widgets/gimpimagepropview.c
index 8fbfe7d..9579a72 100644
--- a/app/widgets/gimpimagepropview.c
+++ b/app/widgets/gimpimagepropview.c
@@ -373,7 +373,8 @@ gimp_image_prop_view_label_set_filetype (GtkWidget *label,
}
gtk_label_set_text (GTK_LABEL (label),
- proc ? gimp_plug_in_procedure_get_label (proc) : NULL);
+ proc ?
+ gimp_procedure_get_label (GIMP_PROCEDURE (proc)) : NULL);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]