[gimp] Minor plug-in sensitivity refactoring
- From: Michael Natterer <mitch src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] Minor plug-in sensitivity refactoring
- Date: Sun, 23 Aug 2009 10:49:31 +0000 (UTC)
commit b141bcdb600deb41683ccb64be444523e53614bf
Author: Michael Natterer <mitch gimp org>
Date: Sat Aug 22 01:22:41 2009 +0200
Minor plug-in sensitivity refactoring
* app/plug-in/gimppluginprocedure.[ch]
(gimp_plug_in_procedure_get_sensitive): change GimpImageType
parameter to GimpDrawable and do the type check internally.
* app/actions/plug-in-actions.c (plug_in_actions_update): pass the
active drawable instead of its type.
app/actions/plug-in-actions.c | 19 +++++++------------
app/plug-in/gimppluginprocedure.c | 13 +++++++++----
app/plug-in/gimppluginprocedure.h | 2 +-
3 files changed, 17 insertions(+), 17 deletions(-)
---
diff --git a/app/actions/plug-in-actions.c b/app/actions/plug-in-actions.c
index 25bd667..0a0149b 100644
--- a/app/actions/plug-in-actions.c
+++ b/app/actions/plug-in-actions.c
@@ -237,19 +237,14 @@ void
plug_in_actions_update (GimpActionGroup *group,
gpointer data)
{
- GimpImage *image = action_data_get_image (data);
- GimpPlugInManager *manager = group->gimp->plug_in_manager;
- GimpImageType type = -1;
+ GimpImage *image = action_data_get_image (data);
+ GimpPlugInManager *manager = group->gimp->plug_in_manager;
+ GimpDrawable *drawable = NULL;
GSList *list;
gint i;
if (image)
- {
- GimpDrawable *drawable = gimp_image_get_active_drawable (image);
-
- if (drawable)
- type = gimp_drawable_type (drawable);
- }
+ drawable = gimp_image_get_active_drawable (image);
for (list = manager->plug_in_procedures; list; list = g_slist_next (list))
{
@@ -260,7 +255,7 @@ plug_in_actions_update (GimpActionGroup *group,
proc->image_types_val)
{
gboolean sensitive = gimp_plug_in_procedure_get_sensitive (proc,
- type);
+ drawable);
gimp_action_group_set_action_sensitive (group,
GIMP_OBJECT (proc)->name,
@@ -269,7 +264,7 @@ plug_in_actions_update (GimpActionGroup *group,
}
if (manager->history &&
- gimp_plug_in_procedure_get_sensitive (manager->history->data, type))
+ gimp_plug_in_procedure_get_sensitive (manager->history->data, drawable))
{
gimp_action_group_set_action_sensitive (group, "plug-in-repeat", TRUE);
gimp_action_group_set_action_sensitive (group, "plug-in-reshow", TRUE);
@@ -287,7 +282,7 @@ plug_in_actions_update (GimpActionGroup *group,
i + 1);
gboolean sensitive;
- sensitive = gimp_plug_in_procedure_get_sensitive (proc, type);
+ sensitive = gimp_plug_in_procedure_get_sensitive (proc, drawable);
gimp_action_group_set_action_sensitive (group, name, sensitive);
diff --git a/app/plug-in/gimppluginprocedure.c b/app/plug-in/gimppluginprocedure.c
index 7adab03..694dd81 100644
--- a/app/plug-in/gimppluginprocedure.c
+++ b/app/plug-in/gimppluginprocedure.c
@@ -21,7 +21,7 @@
#include <string.h>
-#include <glib-object.h>
+#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libgimpbase/gimpbase.h"
@@ -30,6 +30,7 @@
#include "core/gimp.h"
#include "core/gimp-utils.h"
+#include "core/gimpdrawable.h"
#include "core/gimpmarshal.h"
#include "core/gimpparamspecs.h"
@@ -683,11 +684,16 @@ gimp_plug_in_procedure_get_help_id (const GimpPlugInProcedure *proc)
gboolean
gimp_plug_in_procedure_get_sensitive (const GimpPlugInProcedure *proc,
- GimpImageType image_type)
+ GimpDrawable *drawable)
{
- gboolean sensitive;
+ GimpImageType image_type = -1;
+ gboolean sensitive = FALSE;
g_return_val_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (proc), FALSE);
+ g_return_val_if_fail (drawable == NULL || GIMP_IS_DRAWABLE (drawable), FALSE);
+
+ if (drawable)
+ image_type = gimp_drawable_type (drawable);
switch (image_type)
{
@@ -710,7 +716,6 @@ gimp_plug_in_procedure_get_sensitive (const GimpPlugInProcedure *proc,
sensitive = proc->image_types_val & GIMP_PLUG_IN_INDEXEDA_IMAGE;
break;
default:
- sensitive = FALSE;
break;
}
diff --git a/app/plug-in/gimppluginprocedure.h b/app/plug-in/gimppluginprocedure.h
index 1476927..195a98f 100644
--- a/app/plug-in/gimppluginprocedure.h
+++ b/app/plug-in/gimppluginprocedure.h
@@ -116,7 +116,7 @@ GdkPixbuf * gimp_plug_in_procedure_get_pixbuf (const GimpPlugInProcedure
gchar * gimp_plug_in_procedure_get_help_id (const GimpPlugInProcedure *proc);
gboolean gimp_plug_in_procedure_get_sensitive (const GimpPlugInProcedure *proc,
- GimpImageType image_type);
+ GimpDrawable *drawable);
void gimp_plug_in_procedure_set_image_types (GimpPlugInProcedure *proc,
const gchar *image_types);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]