mirror of https://github.com/GNOME/gimp.git
Registered new GimpXMPModelEntry, connected it with the XMPModel.
The new entry widget now makes use of the detailed signal from the XMPModel.
This commit is contained in:
parent
54844e8ab8
commit
a13e4692fb
|
@ -1,5 +1,6 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
libgimpxmpmodelentry = libgimpxmpmodelentry.a
|
||||
libgimpui = $(top_builddir)/libgimp/libgimpui-$(GIMP_API_VERSION).la
|
||||
libgimpwidgets = $(top_builddir)/libgimpwidgets/libgimpwidgets-$(GIMP_API_VERSION).la
|
||||
libgimp = $(top_builddir)/libgimp/libgimp-$(GIMP_API_VERSION).la
|
||||
|
@ -14,6 +15,14 @@ endif
|
|||
|
||||
AM_LDFLAGS = $(mwindows)
|
||||
|
||||
noinst_LIBRARIES = libgimpxmpmodelentry.a
|
||||
|
||||
libgimpxmpmodelentry_a_SOURCES = \
|
||||
gimpxmpmodelentry.h \
|
||||
gimpxmpmodelentry.c \
|
||||
xmp-model.c \
|
||||
xmp-model.h
|
||||
|
||||
libexecdir = $(gimpplugindir)/plug-ins
|
||||
|
||||
libexec_PROGRAMS = metadata
|
||||
|
@ -61,6 +70,8 @@ INCLUDES = \
|
|||
-I$(includedir)
|
||||
|
||||
LDADD = \
|
||||
$(libgimpxmpmodelentry) \
|
||||
$(libgimp) \
|
||||
$(libgimpui) \
|
||||
$(libgimpwidgets) \
|
||||
$(libgimp) \
|
||||
|
|
|
@ -0,0 +1,146 @@
|
|||
/* gimpxmpmodelentry.c - custom entry widget linked to the xmp model
|
||||
*
|
||||
* Copyright (C) 2009, Róman Joost <romanofski@gimp.org>
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "xmp-schemas.h"
|
||||
#include "xmp-model.h"
|
||||
|
||||
#include "gimpxmpmodelentry.h"
|
||||
|
||||
|
||||
static void gimp_xmp_model_entry_init (GimpXMPModelEntry *entry);
|
||||
|
||||
static void gimp_entry_xmp_model_changed (XMPModel *xmp_model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer *user_data);
|
||||
|
||||
static void entry_changed (GimpXMPModelEntry *widget);
|
||||
|
||||
const gchar* find_schema_prefix (const gchar *schema_uri);
|
||||
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpXMPModelEntry, gimp_xmp_model_entry, GTK_TYPE_ENTRY)
|
||||
|
||||
#define parent_class gimp_xmp_model_entry_parent_class
|
||||
|
||||
|
||||
static void
|
||||
gimp_xmp_model_entry_class_init (GimpXMPModelEntryClass *klass)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_xmp_model_entry_init (GimpXMPModelEntry *entry)
|
||||
{
|
||||
entry->schema_uri = NULL;
|
||||
entry->property_name = NULL;
|
||||
entry->xmp_model = NULL;
|
||||
|
||||
g_signal_connect (entry, "changed",
|
||||
G_CALLBACK (entry_changed), NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_xmp_model_entry_new:
|
||||
* @schema_uri: the XMP schema_uri this entry belongs to
|
||||
* @property_name: the property name this entry changes in the XMP model
|
||||
* @xmp_model: the xmp_model for itself
|
||||
*
|
||||
* Returns: a new #GimpXMPModelEntry widget
|
||||
*
|
||||
**/
|
||||
GtkWidget*
|
||||
gimp_xmp_model_entry_new (const gchar *schema_uri,
|
||||
const gchar *property_name,
|
||||
XMPModel *xmp_model)
|
||||
{
|
||||
GimpXMPModelEntry *entry;
|
||||
const gchar *value;
|
||||
const gchar *signal;
|
||||
const gchar *signal_detail;
|
||||
const gchar *schema_prefix;
|
||||
|
||||
entry = g_object_new (GIMP_TYPE_XMP_MODEL_ENTRY, NULL);
|
||||
entry->schema_uri = schema_uri;
|
||||
entry->property_name = property_name;
|
||||
entry->xmp_model = xmp_model;
|
||||
|
||||
value = xmp_model_get_scalar_property (xmp_model, schema_uri, property_name);
|
||||
if (value != NULL)
|
||||
gtk_entry_set_text (GTK_ENTRY (entry), value);
|
||||
else
|
||||
gtk_entry_set_text (GTK_ENTRY (entry), "");
|
||||
|
||||
schema_prefix = find_schema_prefix (schema_uri);
|
||||
signal_detail = g_strjoin (":", schema_prefix, property_name, NULL);
|
||||
signal = g_strjoin ("::", "property-changed", signal_detail, NULL);
|
||||
|
||||
g_signal_connect (xmp_model, signal,
|
||||
G_CALLBACK (gimp_entry_xmp_model_changed),
|
||||
entry);
|
||||
return GTK_WIDGET (entry);
|
||||
}
|
||||
|
||||
static void
|
||||
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;
|
||||
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (xmp_model), iter,
|
||||
COL_XMP_NAME, &property_name,
|
||||
COL_XMP_VALUE, &tree_value,
|
||||
-1);
|
||||
if (! strcmp (entry->property_name, property_name))
|
||||
gtk_entry_set_text (GTK_ENTRY (entry), tree_value);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
entry_changed (GimpXMPModelEntry *entry)
|
||||
{
|
||||
xmp_model_set_scalar_property (entry->xmp_model,
|
||||
entry->schema_uri,
|
||||
entry->property_name,
|
||||
gtk_entry_get_text (GTK_ENTRY (entry)));
|
||||
|
||||
}
|
||||
|
||||
/* find the schema prefix for the given URI */
|
||||
const gchar*
|
||||
find_schema_prefix (const gchar *schema_uri)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; xmp_schemas[i].uri != NULL; ++i)
|
||||
{
|
||||
if (! strcmp (xmp_schemas[i].uri, schema_uri))
|
||||
return xmp_schemas[i].prefix;
|
||||
}
|
||||
return NULL;
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/* gimpxmpmodelentry.h - custom entry widget linked to the xmp model
|
||||
*
|
||||
* Copyright (C) 2009, Róman Joost <romanofski@gimp.org>
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_XMP_MODEL_ENTRY_H__
|
||||
#define __GIMP_XMP_MODEL_ENTRY_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GIMP_TYPE_XMP_MODEL_ENTRY (gimp_xmp_model_entry_get_type ())
|
||||
#define GIMP_XMP_MODEL_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_XMP_MODEL_ENTRY, GimpXMPModelEntry))
|
||||
|
||||
|
||||
typedef struct _GimpXMPModelEntry GimpXMPModelEntry;
|
||||
typedef struct _GimpXMPModelEntryClass GimpXMPModelEntryClass;
|
||||
|
||||
struct _GimpXMPModelEntry
|
||||
{
|
||||
GtkEntry parent_instance;
|
||||
|
||||
const gchar *schema_uri;
|
||||
const gchar *property_name;
|
||||
XMPModel *xmp_model;
|
||||
};
|
||||
|
||||
struct _GimpXMPModelEntryClass
|
||||
{
|
||||
GtkEntryClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
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);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GIMP_XMP_MODEL_ENTRY_H__ */
|
|
@ -53,6 +53,7 @@
|
|||
#include "interface.h"
|
||||
#include "metadata.h"
|
||||
#include "xmp-encode.h"
|
||||
#include "gimpxmpmodelentry.h"
|
||||
|
||||
|
||||
#define RESPONSE_IMPORT 1
|
||||
|
@ -69,10 +70,10 @@ typedef struct
|
|||
} MetadataGui;
|
||||
|
||||
static void
|
||||
value_edited (GtkCellRendererText *cell,
|
||||
const gchar *path_string,
|
||||
const gchar *new_text,
|
||||
gpointer data)
|
||||
tree_value_edited (GtkCellRendererText *cell,
|
||||
const gchar *path_string,
|
||||
const gchar *new_text,
|
||||
gpointer data)
|
||||
{
|
||||
GtkTreeModel *model = data;
|
||||
GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
|
||||
|
@ -86,8 +87,8 @@ value_edited (GtkCellRendererText *cell,
|
|||
/* FIXME: update value[] array */
|
||||
/* FIXME: check widget xref and update other widget if not NULL */
|
||||
gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
|
||||
COL_XMP_VALUE, new_text,
|
||||
-1);
|
||||
COL_XMP_VALUE, new_text,
|
||||
-1);
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
@ -136,7 +137,7 @@ add_view_columns (GtkTreeView *treeview)
|
|||
g_object_set (renderer, "xalign", 0.0, NULL);
|
||||
|
||||
g_signal_connect (renderer, "edited",
|
||||
G_CALLBACK (value_edited), model);
|
||||
G_CALLBACK (tree_value_edited), model);
|
||||
col_offset =
|
||||
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
|
||||
-1, _("Value"),
|
||||
|
@ -195,6 +196,7 @@ typedef struct
|
|||
const gchar *schema;
|
||||
const gchar *property_name;
|
||||
GSList *widget_list;
|
||||
MetadataGui *mgui;
|
||||
} WidgetXRef;
|
||||
|
||||
static void
|
||||
|
@ -203,13 +205,18 @@ entry_changed (GtkEntry *entry,
|
|||
{
|
||||
WidgetXRef *xref = user_data;
|
||||
|
||||
g_print ("XMP: %s %p %p %s\n", xref->property_name, entry, user_data, gtk_entry_get_text (entry)); /* FIXME */
|
||||
xmp_model_set_scalar_property (xref->mgui->xmp_model,
|
||||
xref->schema,
|
||||
xref->property_name,
|
||||
gtk_entry_get_text (entry));
|
||||
update_icons (xref->mgui);
|
||||
}
|
||||
|
||||
static void
|
||||
register_entry_xref (GtkWidget *entry,
|
||||
const gchar *schema,
|
||||
const gchar *property_name)
|
||||
const gchar *property_name,
|
||||
MetadataGui *mgui)
|
||||
{
|
||||
WidgetXRef *xref;
|
||||
|
||||
|
@ -217,13 +224,14 @@ register_entry_xref (GtkWidget *entry,
|
|||
xref->schema = schema;
|
||||
xref->property_name = property_name;
|
||||
xref->widget_list = g_slist_prepend (NULL, entry);
|
||||
xref->mgui = mgui;
|
||||
g_signal_connect (GTK_ENTRY (entry), "changed",
|
||||
G_CALLBACK (entry_changed), xref);
|
||||
G_CALLBACK (entry_changed), xref);
|
||||
}
|
||||
|
||||
static void
|
||||
text_changed (GtkTextBuffer *text_buffer,
|
||||
gpointer user_data)
|
||||
gpointer user_data)
|
||||
{
|
||||
WidgetXRef *xref = user_data;
|
||||
GtkTextIter start;
|
||||
|
@ -245,11 +253,12 @@ register_text_xref (GtkTextBuffer *text_buffer,
|
|||
xref->property_name = property_name;
|
||||
xref->widget_list = g_slist_prepend (NULL, text_buffer);
|
||||
g_signal_connect (GTK_TEXT_BUFFER (text_buffer), "changed",
|
||||
G_CALLBACK (text_changed), xref);
|
||||
G_CALLBACK (text_changed), xref);
|
||||
}
|
||||
|
||||
static void
|
||||
add_description_tab (GtkWidget *notebook)
|
||||
add_description_tab (GtkWidget *notebook,
|
||||
MetadataGui *mgui)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
GtkWidget *table;
|
||||
|
@ -262,7 +271,7 @@ add_description_tab (GtkWidget *notebook)
|
|||
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), frame,
|
||||
gtk_label_new (_("Description")));
|
||||
gtk_container_set_border_width (GTK_CONTAINER (frame), 10);
|
||||
/* gtk_widget_show (frame); */
|
||||
gtk_widget_show (frame);
|
||||
|
||||
table = gtk_table_new (5, 2, FALSE);
|
||||
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
|
||||
|
@ -270,17 +279,16 @@ add_description_tab (GtkWidget *notebook)
|
|||
gtk_container_add (GTK_CONTAINER (frame), table);
|
||||
/* gtk_widget_show (table); */
|
||||
|
||||
entry = gtk_entry_new ();
|
||||
register_entry_xref (entry, XMP_SCHEMA_DUBLIN_CORE, "title");
|
||||
entry = gimp_xmp_model_entry_new (XMP_SCHEMA_DUBLIN_CORE, "title", mgui->xmp_model);
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
||||
_("Image _title:"), 0.0, 0.5,
|
||||
entry, 1, FALSE);
|
||||
_("Image _title:"), 0.0, 0.5,
|
||||
entry, 1, FALSE);
|
||||
|
||||
entry = gtk_entry_new ();
|
||||
register_entry_xref (entry, XMP_SCHEMA_DUBLIN_CORE, "creator");
|
||||
entry = gimp_xmp_model_entry_new (XMP_SCHEMA_DUBLIN_CORE, "creator", mgui->xmp_model);
|
||||
//register_entry_xref (entry, XMP_SCHEMA_DUBLIN_CORE, "creator", mgui);
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
||||
_("_Author:"), 0.0, 0.5,
|
||||
entry, 1, FALSE);
|
||||
_("_Author:"), 0.0, 0.5,
|
||||
entry, 1, FALSE);
|
||||
|
||||
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
|
||||
|
@ -302,7 +310,7 @@ add_description_tab (GtkWidget *notebook)
|
|||
scrolled_window, 1, FALSE);
|
||||
|
||||
entry = gtk_entry_new ();
|
||||
register_entry_xref (entry, XMP_SCHEMA_PHOTOSHOP, "CaptionWriter");
|
||||
register_entry_xref (entry, XMP_SCHEMA_PHOTOSHOP, "CaptionWriter", mgui);
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 3,
|
||||
_("Description _writer:"), 0.0, 0.5,
|
||||
entry, 1, FALSE);
|
||||
|
@ -697,7 +705,7 @@ metadata_dialog (gint32 image_ID,
|
|||
mgui.run_ok = FALSE;
|
||||
|
||||
/* add the tabs to the notebook */
|
||||
add_description_tab (notebook);
|
||||
add_description_tab (notebook, &mgui);
|
||||
add_copyright_tab (notebook);
|
||||
add_origin_tab (notebook);
|
||||
add_camera1_tab (notebook);
|
||||
|
|
Loading…
Reference in New Issue