[gimp] some minor code cleanups
- From: Sven Neumann <neo src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] some minor code cleanups
- Date: Sun, 27 Dec 2009 12:43:03 +0000 (UTC)
commit f0348aff40b27c9fc6da53250e57ea507dd155bb
Author: Sven Neumann <sven gimp org>
Date: Sun Dec 27 11:02:40 2009 +0100
some minor code cleanups
plug-ins/metadata/Makefile.am | 7 +-
plug-ins/metadata/gimpxmpmodelentry.c | 151 ++++++++++++++++++---------------
plug-ins/metadata/gimpxmpmodelentry.h | 29 ++----
plug-ins/metadata/metadata.c | 20 ++--
4 files changed, 106 insertions(+), 101 deletions(-)
---
diff --git a/plug-ins/metadata/Makefile.am b/plug-ins/metadata/Makefile.am
index a60f8b3..9aebcfb 100644
--- a/plug-ins/metadata/Makefile.am
+++ b/plug-ins/metadata/Makefile.am
@@ -37,9 +37,9 @@ metadata_SOURCES = \
gimpxmpmodelentry.c \
exif-decode.h \
exif-decode.c
-# exif-encode.h \
-# exif-encode.c \
-# iptc-decode.h \
+# exif-encode.h \
+# exif-encode.c \
+# iptc-decode.h \
# iptc-decode.c
noinst_PROGRAMS = xmpdump
@@ -63,7 +63,6 @@ INCLUDES = \
-I$(includedir)
LDADD = \
- $(libgimp) \
$(libgimpui) \
$(libgimpwidgets) \
$(libgimp) \
diff --git a/plug-ins/metadata/gimpxmpmodelentry.c b/plug-ins/metadata/gimpxmpmodelentry.c
index 233816e..c935813 100644
--- a/plug-ins/metadata/gimpxmpmodelentry.c
+++ b/plug-ins/metadata/gimpxmpmodelentry.c
@@ -36,55 +36,67 @@ enum
PROP_XMPMODEL
};
+typedef struct
+{
+ const gchar *schema_uri;
+ const gchar *property_name;
+ XMPModel *xmp_model;
+} GimpXmpModelEntryPrivate;
-static void gimp_xmp_model_entry_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_xmp_model_entry_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static void gimp_entry_xmp_model_changed (XMPModel *xmp_model,
- GtkTreeIter *iter,
- gpointer *user_data);
-static void gimp_xmp_model_entry_entry_changed (GimpXmpModelEntry *widget);
+static void gimp_xmp_model_entry_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_xmp_model_entry_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_entry_xmp_model_changed (XMPModel *xmp_model,
+ GtkTreeIter *iter,
+ gpointer *user_data);
-const gchar* find_schema_prefix (const gchar *schema_uri);
+static void gimp_xmp_model_entry_entry_changed (GimpXmpModelEntry *widget);
-static void set_property_edit_icon (GimpXmpModelEntry *entry,
- GtkTreeIter *iter);
+const gchar * find_schema_prefix (const gchar *schema_uri);
+static void set_property_edit_icon (GimpXmpModelEntry *entry,
+ GtkTreeIter *iter);
G_DEFINE_TYPE (GimpXmpModelEntry, gimp_xmp_model_entry, GTK_TYPE_ENTRY)
#define parent_class gimp_xmp_model_entry_parent_class
-#define GIMP_XMP_MODEL_ENTRY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GIMP_TYPE_XMP_MODEL_ENTRY, GimpXmpModelEntryPrivate))
+
+#define GIMP_XMP_MODEL_ENTRY_GET_PRIVATE(obj) \
+ ((GimpXmpModelEntryPrivate *) GIMP_XMP_MODEL_ENTRY (obj)->priv)
+
static GObject *
-gimp_xmp_model_entry_constructor (GType gtype,
- guint n_properties,
- GObjectConstructParam *properties)
+gimp_xmp_model_entry_constructor (GType type,
+ guint n_params,
+ GObjectConstructParam *params)
{
- GObject *obj;
- GimpXmpModelEntry *entry;
- const gchar *signal;
- const gchar *signal_detail;
- const gchar *schema_prefix;
-
- obj = G_OBJECT_CLASS (gimp_xmp_model_entry_parent_class)->constructor (gtype,
- n_properties,
- properties);
+ GObject *obj;
+ GimpXmpModelEntry *entry;
+ GimpXmpModelEntryPrivate *priv;
+ gchar *signal;
+
+ obj = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
+
entry = GIMP_XMP_MODEL_ENTRY (obj);
- schema_prefix = find_schema_prefix (entry->p->schema_uri);
- signal_detail = g_strjoin (":", schema_prefix, entry->p->property_name, NULL);
- signal = g_strjoin ("::", "property-changed", signal_detail, NULL);
- g_signal_connect (entry->p->xmp_model,
- signal,
+ priv = GIMP_XMP_MODEL_ENTRY_GET_PRIVATE (entry);
+
+ signal = g_strdup_printf ("property-changed::%s:%s",
+ find_schema_prefix (priv->schema_uri),
+ priv->property_name);
+
+ g_signal_connect (priv->xmp_model, signal,
G_CALLBACK (gimp_entry_xmp_model_changed),
entry);
+
+ g_free (signal);
+
return obj;
}
@@ -100,21 +112,20 @@ gimp_xmp_model_entry_class_init (GimpXmpModelEntryClass *klass)
g_object_class_install_property (object_class, PROP_SCHEMA_URI,
g_param_spec_string ("schema-uri", NULL, NULL,
NULL,
- G_PARAM_CONSTRUCT |
+ G_PARAM_CONSTRUCT_ONLY |
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_PROPERTY_NAME,
g_param_spec_string ("property-name", NULL, NULL,
NULL,
- G_PARAM_CONSTRUCT |
+ G_PARAM_CONSTRUCT_ONLY |
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_XMPMODEL,
- g_param_spec_object ("xmp-model",
- NULL, NULL,
+ g_param_spec_object ("xmp-model", NULL, NULL,
GIMP_TYPE_XMP_MODEL,
- GIMP_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
+ G_PARAM_CONSTRUCT_ONLY |
+ GIMP_PARAM_READWRITE));
g_type_class_add_private (klass, sizeof (GimpXmpModelEntryPrivate));
}
@@ -122,14 +133,13 @@ gimp_xmp_model_entry_class_init (GimpXmpModelEntryClass *klass)
static void
gimp_xmp_model_entry_init (GimpXmpModelEntry *entry)
{
- entry->p = GIMP_XMP_MODEL_ENTRY_GET_PRIVATE (entry);
-
- entry->p->schema_uri = NULL;
- entry->p->property_name = NULL;
- entry->p->xmp_model = NULL;
+ entry->priv = G_TYPE_INSTANCE_GET_PRIVATE (entry,
+ GIMP_TYPE_XMP_MODEL_ENTRY,
+ GimpXmpModelEntryPrivate);
g_signal_connect (entry, "changed",
- G_CALLBACK (gimp_xmp_model_entry_entry_changed), NULL);
+ G_CALLBACK (gimp_xmp_model_entry_entry_changed),
+ NULL);
}
static void
@@ -138,20 +148,20 @@ gimp_xmp_model_entry_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- GimpXmpModelEntry *entry = GIMP_XMP_MODEL_ENTRY (object);
+ GimpXmpModelEntryPrivate *priv = GIMP_XMP_MODEL_ENTRY_GET_PRIVATE (object);
switch (property_id)
{
case PROP_SCHEMA_URI:
- entry->p->schema_uri = g_value_dup_string (value);
+ priv->schema_uri = g_value_dup_string (value);
break;
case PROP_PROPERTY_NAME:
- entry->p->property_name = g_value_dup_string (value);
+ priv->property_name = g_value_dup_string (value);
break;
case PROP_XMPMODEL:
- entry->p->xmp_model = g_value_dup_object (value);
+ priv->xmp_model = g_value_dup_object (value);
break;
default:
@@ -166,20 +176,20 @@ gimp_xmp_model_entry_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- GimpXmpModelEntry *entry = GIMP_XMP_MODEL_ENTRY (object);
+ GimpXmpModelEntryPrivate *priv = GIMP_XMP_MODEL_ENTRY_GET_PRIVATE (object);
switch (property_id)
{
case PROP_SCHEMA_URI:
- g_value_set_string (value, entry->p->schema_uri);
+ g_value_set_string (value, priv->schema_uri);
break;
case PROP_PROPERTY_NAME:
- g_value_set_string (value, entry->p->property_name);
+ g_value_set_string (value, priv->property_name);
break;
case PROP_XMPMODEL:
- g_value_set_object (value, entry->p->xmp_model);
+ g_value_set_object (value, priv->xmp_model);
break;
default:
@@ -193,17 +203,19 @@ gimp_entry_xmp_model_changed (XMPModel *xmp_model,
GtkTreeIter *iter,
gpointer *user_data)
{
- GimpXmpModelEntry *entry = GIMP_XMP_MODEL_ENTRY (user_data);
- const gchar *tree_value;
- const gchar *property_name;
- GdkPixbuf *icon;
+ GimpXmpModelEntry *entry = GIMP_XMP_MODEL_ENTRY (user_data);
+ GimpXmpModelEntryPrivate *priv = GIMP_XMP_MODEL_ENTRY_GET_PRIVATE (entry);
+ const gchar *tree_value;
+ const gchar *property_name;
+ GdkPixbuf *icon;
gtk_tree_model_get (GTK_TREE_MODEL (xmp_model), iter,
- COL_XMP_NAME, &property_name,
- COL_XMP_VALUE, &tree_value,
+ COL_XMP_NAME, &property_name,
+ COL_XMP_VALUE, &tree_value,
COL_XMP_EDIT_ICON, &icon,
-1);
- if (! strcmp (entry->p->property_name, property_name))
+
+ if (! strcmp (priv->property_name, property_name))
gtk_entry_set_text (GTK_ENTRY (entry), tree_value);
if (icon == NULL)
@@ -216,9 +228,11 @@ gimp_entry_xmp_model_changed (XMPModel *xmp_model,
static void
gimp_xmp_model_entry_entry_changed (GimpXmpModelEntry *entry)
{
- xmp_model_set_scalar_property (entry->p->xmp_model,
- entry->p->schema_uri,
- entry->p->property_name,
+ GimpXmpModelEntryPrivate *priv = GIMP_XMP_MODEL_ENTRY_GET_PRIVATE (entry);
+
+ xmp_model_set_scalar_property (priv->xmp_model,
+ priv->schema_uri,
+ priv->property_name,
gtk_entry_get_text (GTK_ENTRY (entry)));
}
@@ -240,10 +254,11 @@ static void
set_property_edit_icon (GimpXmpModelEntry *entry,
GtkTreeIter *iter)
{
- GdkPixbuf *icon;
- gboolean editable;
+ GimpXmpModelEntryPrivate *priv = GIMP_XMP_MODEL_ENTRY_GET_PRIVATE (entry);
+ GdkPixbuf *icon;
+ gboolean editable;
- gtk_tree_model_get (GTK_TREE_MODEL (entry->p->xmp_model), iter,
+ gtk_tree_model_get (GTK_TREE_MODEL (priv->xmp_model), iter,
COL_XMP_EDITABLE, &editable,
COL_XMP_EDIT_ICON, &icon,
-1);
@@ -252,7 +267,7 @@ set_property_edit_icon (GimpXmpModelEntry *entry,
{
icon = gtk_widget_render_icon (GTK_WIDGET (entry), GIMP_STOCK_WILBER,
GTK_ICON_SIZE_MENU, NULL);
- gtk_tree_store_set (GTK_TREE_STORE (entry->p->xmp_model), iter,
+ gtk_tree_store_set (GTK_TREE_STORE (priv->xmp_model), iter,
COL_XMP_EDIT_ICON, icon,
-1);
}
@@ -260,7 +275,7 @@ set_property_edit_icon (GimpXmpModelEntry *entry,
{
icon = gtk_widget_render_icon (GTK_WIDGET (entry), GTK_STOCK_EDIT,
GTK_ICON_SIZE_MENU, NULL);
- gtk_tree_store_set (GTK_TREE_STORE (entry->p->xmp_model), iter,
+ gtk_tree_store_set (GTK_TREE_STORE (priv->xmp_model), iter,
COL_XMP_EDIT_ICON, icon,
-1);
}
diff --git a/plug-ins/metadata/gimpxmpmodelentry.h b/plug-ins/metadata/gimpxmpmodelentry.h
index 022466f..601634d 100644
--- a/plug-ins/metadata/gimpxmpmodelentry.h
+++ b/plug-ins/metadata/gimpxmpmodelentry.h
@@ -30,37 +30,28 @@ G_BEGIN_DECLS
#define GIMP_XMP_MODEL_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_XMP_MODEL_ENTRY, XMPModelClass))
-typedef struct _GimpXmpModelEntry GimpXmpModelEntry;
-typedef struct _GimpXmpModelEntryClass GimpXmpModelEntryClass;
-typedef struct _GimpXmpModelEntryPrivate GimpXmpModelEntryPrivate;
+typedef struct _GimpXmpModelEntry GimpXmpModelEntry;
+typedef struct _GimpXmpModelEntryClass GimpXmpModelEntryClass;
-struct _GimpXmpModelEntry
-{
- GtkEntry parent_instance;
-
- GimpXmpModelEntryPrivate *p;
-};
-
struct _GimpXmpModelEntryClass
{
GtkEntryClass parent_class;
};
-struct _GimpXmpModelEntryPrivate
+struct _GimpXmpModelEntry
{
- const gchar *schema_uri;
- const gchar *property_name;
- XMPModel *xmp_model;
-
+ GtkEntry parent_instance;
+ gpointer priv;
};
-GType gimp_xmp_model_entry_get_type (void) G_GNUC_CONST;
+GType gimp_xmp_model_entry_get_type (void) G_GNUC_CONST;
+
+GtkWidget * gimp_xmp_model_entry_new (const gchar *schema_uri,
+ const gchar *property,
+ XMPModel *xmp_model);
-GtkWidget* gimp_xmp_model_entry_new (const gchar *schema_uri,
- const gchar *property,
- XMPModel *xmp_model);
G_END_DECLS
diff --git a/plug-ins/metadata/metadata.c b/plug-ins/metadata/metadata.c
index 7898535..17e8448 100644
--- a/plug-ins/metadata/metadata.c
+++ b/plug-ins/metadata/metadata.c
@@ -42,16 +42,16 @@
#define METADATA_PARASITE "gimp-metadata"
#define METADATA_MARKER "GIMP_XMP_1"
-#define METADATA_MARKER_LEN (sizeof (METADATA_MARKER) - 1)
+#define METADATA_MARKER_LEN (strlen (METADATA_MARKER))
/* prototypes of local functions */
-static void query (void);
-static void run (const gchar *name,
- gint nparams,
- const GimpParam *param,
- gint *nreturn_vals,
- GimpParam **return_vals);
+static void query (void);
+static void run (const gchar *name,
+ gint nparams,
+ const GimpParam *param,
+ gint *nreturn_vals,
+ GimpParam **return_vals);
/* local variables */
@@ -71,7 +71,7 @@ query (void)
{
static const GimpParamDef editor_args[] =
{
- { GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
+ { GIMP_PDB_INT32, "run-mode", "Run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
{ GIMP_PDB_IMAGE, "image", "Input image" },
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable (unused)" }
};
@@ -393,13 +393,13 @@ run (const gchar *name,
if (!! strncmp (gimp_parasite_data (parasite),
METADATA_MARKER, METADATA_MARKER_LEN)
|| ! xmp_model_parse_buffer (xmp_model,
- (const gchar *)gimp_parasite_data (parasite)
+ (const gchar *) gimp_parasite_data (parasite)
+ METADATA_MARKER_LEN,
gimp_parasite_data_size (parasite)
- METADATA_MARKER_LEN,
TRUE, &error))
{
- g_printerr ("\nMetadata parasite seems to be corrupt");
+ g_printerr ("\nMetadata parasite seems to be corrupt\n");
/* continue anyway, we will attach a clean parasite later */
}
gimp_parasite_free (parasite);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]