plug-ins: Remove dependency on GtkBuilder from metadata-editor

Instead of loading the GtkBuilder .ui file we now create all widgets in
code.
Added several support functions to reduce code copy/pasting and making
additional widgets and supporting more metadata easier.
The overall layout should still look the same, with a few exceptions:
- Each notebook page only uses one grid. This makes it possible to align
all data entry widgets.
- Featured Organization and it's code were two treeviews next to each
other. These are now organized below each other to make automatic code
generation easier.
- Since we needed to touch this code anyway, I also fixed Xmp.dc.creator
and Xmp.iptcExt.ModelAge to be multiline. This closes #7286.
- The old icons used for the date button, add, and remove row buttons
were replaced by gimp-grid, list-add and list-remove.

Since this was the last .ui file used in GIMP plug-ins, we remove all
files from the .ui subdirectory and references to that.

Note that there are several more places where GtkBuilder is used, but
those cases uses strings defined in code instead of .ui files.
This commit is contained in:
Jacob Boerema 2023-05-10 13:04:18 -04:00
parent 415b32e763
commit 8969bbcee8
13 changed files with 948 additions and 5131 deletions

View File

@ -59,5 +59,4 @@ SUBDIRS = \
screenshot \
selection-to-path \
$(twain) \
ui \
common

View File

@ -32,4 +32,3 @@ subdir('screenshot')
subdir('script-fu')
subdir('selection-to-path')
subdir('twain')
subdir('ui')

File diff suppressed because it is too large Load Diff

View File

@ -20,8 +20,11 @@
#ifndef __METADATA_EDITOR_H__
#define __METADATA_EDITOR_H__
extern void metadata_editor_write_callback (GtkWidget *dialog,
GtkBuilder *builder,
GimpImage *image);
void metadata_editor_write_callback (GtkWidget *dialog,
metadata_editor *meta_info,
GimpImage *image);
GtkWidget * metadata_editor_get_widget (metadata_editor *meta_info,
const gchar *name);
#endif /* __METADATA_EDITOR_H__ */

View File

@ -101,7 +101,7 @@ export_file_metadata (metadata_editor *args)
if (force_write == TRUE)
{
/* Save fields in case of updates */
metadata_editor_write_callback (args->dialog, args->builder, args->image);
metadata_editor_write_callback (args->dialog, args, args->image);
/* Fetch a fresh copy of the metadata */
args->metadata = GEXIV2_METADATA (gimp_image_get_metadata (args->image));
}

View File

@ -23,7 +23,7 @@
typedef struct
{
GtkWidget *dialog;
GtkBuilder *builder;
GHashTable *widgets;
GExiv2Metadata *metadata;
GimpImage *image;
gchar *filename;

View File

@ -38,7 +38,7 @@ const metadata_tag default_metadata_tags[] =
{
/* Description */
{ "Xmp.dc.title", "single", 16, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 0
{ "Xmp.dc.creator", "single", 13, TAG_TYPE_XMP, GIMP_XMP_SEQ }, // 1
{ "Xmp.dc.creator", "multi", 13, TAG_TYPE_XMP, GIMP_XMP_SEQ }, // 1
{ "Xmp.dc.description", "multi", 14, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 2
{ "Xmp.dc.subject", "multi", 15, TAG_TYPE_XMP, GIMP_XMP_BAG }, // 3
{ "Xmp.dc.rights", "single", 17, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 4
@ -84,7 +84,7 @@ const metadata_tag default_metadata_tags[] =
{ "Xmp.iptcExt.RegistryId", "list", -1, TAG_TYPE_XMP, GIMP_XMP_NONE }, // 38
{ "Xmp.iptcExt.ArtworkOrObject", "list", -1, TAG_TYPE_XMP, GIMP_XMP_NONE }, // 39
{ "Xmp.iptcExt.AddlModelInfo", "multi", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 40
{ "Xmp.iptcExt.ModelAge", "single", -1, TAG_TYPE_XMP, GIMP_XMP_BAG }, // 41
{ "Xmp.iptcExt.ModelAge", "multi", -1, TAG_TYPE_XMP, GIMP_XMP_BAG }, // 41
{ "Xmp.iptcExt.MaxAvailWidth", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 42
{ "Xmp.iptcExt.MaxAvailHeight", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 43
{ "Xmp.iptcExt.DigitalSourceType", "combo", -1, TAG_TYPE_XMP, GIMP_XMP_NONE }, // 44

View File

@ -30,6 +30,7 @@
#include "metadata-misc.h"
#include "metadata-xml.h"
#include "metadata-tags.h"
#include "metadata-editor.h"
extern gboolean gimpmetadata;
extern gboolean force_write;
@ -164,9 +165,9 @@ set_tag_ui (metadata_editor *args,
gchar *value,
gchar* mode)
{
GtkWidget *widget;
GtkWidget *widget = NULL;
widget = GTK_WIDGET (gtk_builder_get_object (args->builder, str_tag_name));
widget = GTK_WIDGET (metadata_editor_get_widget (args, str_tag_name));
if (!strcmp ("single", mode))
{
@ -552,18 +553,18 @@ get_tag_ui_text (metadata_editor *args,
gchar *name,
gchar *mode)
{
GObject *object;
GtkWidget *widget = NULL;
object = gtk_builder_get_object (args->builder, name);
widget = metadata_editor_get_widget (args, name);
if (! strcmp ("single", mode))
{
GtkEntry *entry = GTK_ENTRY (object);
GtkEntry *entry = GTK_ENTRY (widget);
return gtk_entry_get_text (entry);
}
else if (!strcmp ("multi", mode))
{
GtkTextView *text_view = GTK_TEXT_VIEW (object);
GtkTextView *text_view = GTK_TEXT_VIEW (widget);
GtkTextBuffer *buffer;
GtkTextIter start;
GtkTextIter end;
@ -602,8 +603,7 @@ get_list_elements (GString *xmldata, int element_count, gchar **rowtagdata)
gchar *
get_tag_ui_list (metadata_editor *args, gchar *name, gchar *mode)
{
GObject *object;
GtkWidget *widget;
GtkWidget *widget = NULL;
GtkTreeModel *treemodel;
GtkListStore *liststore;
GtkTreeIter iter;
@ -616,8 +616,7 @@ get_tag_ui_list (metadata_editor *args, gchar *name, gchar *mode)
has_data = FALSE;
xmldata = g_string_new ("");
object = gtk_builder_get_object (args->builder, name);
widget = GTK_WIDGET(object);
widget = metadata_editor_get_widget (args, name);
liststore = GTK_LIST_STORE(gtk_tree_view_get_model((GtkTreeView *)widget));
treemodel = GTK_TREE_MODEL (liststore);
@ -826,16 +825,7 @@ get_tag_ui_list (metadata_editor *args, gchar *name, gchar *mode)
gint
get_tag_ui_combo (metadata_editor *args, gchar *name, gchar *mode)
{
GObject *object;
GtkComboBoxText *combo;
gint value;
object = gtk_builder_get_object (args->builder, name);
combo = GTK_COMBO_BOX_TEXT (object);
value = gtk_combo_box_get_active (GTK_COMBO_BOX(combo));
return value;
return gtk_combo_box_get_active (GTK_COMBO_BOX(metadata_editor_get_widget (args, name)));
}
void

View File

@ -1,2 +0,0 @@
/Makefile
/Makefile.in

View File

@ -1,6 +0,0 @@
uidatadir = $(gimpdatadir)/ui/plug-ins
uidata_DATA = \
plug-in-metadata-editor.ui
EXTRA_DIST = $(uidata_DATA)

View File

@ -1,7 +0,0 @@
plugin_ui = [
'plug-in-metadata-editor.ui',
]
install_data(plugin_ui,
install_dir: gimpdatadir / 'ui' / 'plug-ins',
)

File diff suppressed because it is too large Load Diff

View File

@ -154,7 +154,6 @@ plug-ins/gimpressionist/repaint.c
plug-ins/gimpressionist/size.c
plug-ins/gimpressionist/sizemap.c
plug-ins/gimpressionist/utils.c
plug-ins/ui/plug-in-metadata-editor.ui
plug-ins/gradient-flare/gradient-flare.c
plug-ins/help-browser/dialog.c
plug-ins/help-browser/help-browser.c