2002-03-08 08:27:45 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* gimpdataeditor.c
|
2004-09-27 03:26:37 +08:00
|
|
|
* Copyright (C) 2002-2004 Michael Natterer <mitch@gimp.org>
|
2002-03-08 08:27:45 +08:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2003-10-12 00:50:35 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2002-03-08 08:27:45 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "widgets-types.h"
|
|
|
|
|
|
|
|
#include "core/gimp.h"
|
2003-10-12 00:50:35 +08:00
|
|
|
#include "core/gimpcontainer.h"
|
2002-03-08 08:27:45 +08:00
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
#include "core/gimpdata.h"
|
2003-10-12 00:50:35 +08:00
|
|
|
#include "core/gimpdatafactory.h"
|
2002-03-08 08:27:45 +08:00
|
|
|
|
|
|
|
#include "gimpdataeditor.h"
|
2003-10-12 00:50:35 +08:00
|
|
|
#include "gimpdocked.h"
|
2003-01-11 01:55:53 +08:00
|
|
|
#include "gimpmenufactory.h"
|
2003-10-12 00:50:35 +08:00
|
|
|
#include "gimpsessioninfo.h"
|
2004-10-25 04:38:35 +08:00
|
|
|
#include "gimpuimanager.h"
|
2002-03-08 08:27:45 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2002-03-08 08:27:45 +08:00
|
|
|
|
|
|
|
|
2004-09-27 03:26:37 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2004-09-27 03:41:56 +08:00
|
|
|
PROP_DATA_FACTORY,
|
|
|
|
PROP_DATA
|
2004-09-27 03:26:37 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-03-08 08:27:45 +08:00
|
|
|
static void gimp_data_editor_class_init (GimpDataEditorClass *klass);
|
|
|
|
static void gimp_data_editor_init (GimpDataEditor *view);
|
|
|
|
|
2003-10-12 00:50:35 +08:00
|
|
|
static void gimp_data_editor_docked_iface_init (GimpDockedInterface *docked_iface);
|
2004-09-27 02:41:29 +08:00
|
|
|
|
2004-10-25 04:38:35 +08:00
|
|
|
static GObject * gimp_data_editor_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params);
|
2004-09-27 03:26:37 +08:00
|
|
|
static void gimp_data_editor_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2004-09-27 03:41:56 +08:00
|
|
|
static void gimp_data_editor_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2004-09-27 02:41:29 +08:00
|
|
|
static void gimp_data_editor_dispose (GObject *object);
|
|
|
|
|
2003-10-12 00:50:35 +08:00
|
|
|
static void gimp_data_editor_set_aux_info (GimpDocked *docked,
|
|
|
|
GList *aux_info);
|
|
|
|
static GList * gimp_data_editor_get_aux_info (GimpDocked *docked);
|
2005-04-17 04:48:33 +08:00
|
|
|
static gchar * gimp_data_editor_get_title (GimpDocked *docked);
|
2003-10-12 00:50:35 +08:00
|
|
|
|
2002-03-08 08:27:45 +08:00
|
|
|
static void gimp_data_editor_real_set_data (GimpDataEditor *editor,
|
|
|
|
GimpData *data);
|
|
|
|
|
|
|
|
static void gimp_data_editor_name_activate (GtkWidget *widget,
|
|
|
|
GimpDataEditor *editor);
|
|
|
|
static gboolean gimp_data_editor_name_focus_out (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
GimpDataEditor *editor);
|
|
|
|
|
|
|
|
static void gimp_data_editor_data_name_changed (GimpObject *object,
|
|
|
|
GimpDataEditor *editor);
|
|
|
|
|
|
|
|
static void gimp_data_editor_save_clicked (GtkWidget *widget,
|
|
|
|
GimpDataEditor *editor);
|
|
|
|
static void gimp_data_editor_revert_clicked (GtkWidget *widget,
|
|
|
|
GimpDataEditor *editor);
|
2003-11-12 03:00:42 +08:00
|
|
|
static void gimp_data_editor_save_dirty (GimpDataEditor *editor);
|
2002-03-08 08:27:45 +08:00
|
|
|
|
|
|
|
|
|
|
|
static GimpEditorClass *parent_class = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
GType
|
|
|
|
gimp_data_editor_get_type (void)
|
|
|
|
{
|
2003-10-12 00:50:35 +08:00
|
|
|
static GType type = 0;
|
2002-03-08 08:27:45 +08:00
|
|
|
|
2003-10-12 00:50:35 +08:00
|
|
|
if (! type)
|
2002-03-08 08:27:45 +08:00
|
|
|
{
|
|
|
|
static const GTypeInfo view_info =
|
|
|
|
{
|
|
|
|
sizeof (GimpDataEditorClass),
|
|
|
|
NULL, /* base_init */
|
|
|
|
NULL, /* base_finalize */
|
|
|
|
(GClassInitFunc) gimp_data_editor_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpDataEditor),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_data_editor_init,
|
|
|
|
};
|
2003-10-12 00:50:35 +08:00
|
|
|
static const GInterfaceInfo docked_iface_info =
|
|
|
|
{
|
|
|
|
(GInterfaceInitFunc) gimp_data_editor_docked_iface_init,
|
|
|
|
NULL, /* iface_finalize */
|
|
|
|
NULL /* iface_data */
|
|
|
|
};
|
2002-03-08 08:27:45 +08:00
|
|
|
|
2003-10-12 00:50:35 +08:00
|
|
|
type = g_type_register_static (GIMP_TYPE_EDITOR,
|
|
|
|
"GimpDataEditor",
|
|
|
|
&view_info, 0);
|
|
|
|
|
|
|
|
g_type_add_interface_static (type, GIMP_TYPE_DOCKED,
|
|
|
|
&docked_iface_info);
|
2002-03-08 08:27:45 +08:00
|
|
|
}
|
|
|
|
|
2003-10-12 00:50:35 +08:00
|
|
|
return type;
|
2002-03-08 08:27:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_data_editor_class_init (GimpDataEditorClass *klass)
|
|
|
|
{
|
2004-09-27 02:41:29 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2002-03-08 08:27:45 +08:00
|
|
|
|
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
|
|
|
|
2004-10-25 04:38:35 +08:00
|
|
|
object_class->constructor = gimp_data_editor_constructor;
|
2004-09-27 03:26:37 +08:00
|
|
|
object_class->set_property = gimp_data_editor_set_property;
|
2004-09-27 03:41:56 +08:00
|
|
|
object_class->get_property = gimp_data_editor_get_property;
|
2004-09-27 03:26:37 +08:00
|
|
|
object_class->dispose = gimp_data_editor_dispose;
|
2002-03-08 08:27:45 +08:00
|
|
|
|
2004-09-27 03:26:37 +08:00
|
|
|
klass->set_data = gimp_data_editor_real_set_data;
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_DATA_FACTORY,
|
|
|
|
g_param_spec_object ("data-factory",
|
|
|
|
NULL, NULL,
|
|
|
|
GIMP_TYPE_DATA_FACTORY,
|
2004-09-27 03:41:56 +08:00
|
|
|
G_PARAM_READWRITE |
|
2004-09-27 03:26:37 +08:00
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
2004-09-27 03:41:56 +08:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_DATA,
|
|
|
|
g_param_spec_object ("data",
|
|
|
|
NULL, NULL,
|
|
|
|
GIMP_TYPE_DATA,
|
|
|
|
G_PARAM_READWRITE));
|
2002-03-08 08:27:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_data_editor_init (GimpDataEditor *editor)
|
|
|
|
{
|
2003-10-12 00:50:35 +08:00
|
|
|
editor->data_factory = NULL;
|
2003-03-10 22:07:22 +08:00
|
|
|
editor->data = NULL;
|
|
|
|
editor->data_editable = FALSE;
|
2002-03-08 08:27:45 +08:00
|
|
|
|
|
|
|
editor->name_entry = gtk_entry_new ();
|
2004-09-27 03:26:37 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (editor), editor->name_entry, FALSE, FALSE, 0);
|
2002-03-08 08:27:45 +08:00
|
|
|
gtk_widget_show (editor->name_entry);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (editor->name_entry, "activate",
|
2002-03-08 08:27:45 +08:00
|
|
|
G_CALLBACK (gimp_data_editor_name_activate),
|
|
|
|
editor);
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (editor->name_entry, "focus_out_event",
|
2002-03-08 08:27:45 +08:00
|
|
|
G_CALLBACK (gimp_data_editor_name_focus_out),
|
|
|
|
editor);
|
2004-10-25 04:38:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_data_editor_docked_iface_init (GimpDockedInterface *docked_iface)
|
|
|
|
{
|
|
|
|
docked_iface->set_aux_info = gimp_data_editor_set_aux_info;
|
|
|
|
docked_iface->get_aux_info = gimp_data_editor_get_aux_info;
|
2005-04-17 04:48:33 +08:00
|
|
|
docked_iface->get_title = gimp_data_editor_get_title;
|
2004-10-25 04:38:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static GObject *
|
|
|
|
gimp_data_editor_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params)
|
|
|
|
{
|
|
|
|
GObject *object;
|
|
|
|
GimpDataEditor *editor;
|
|
|
|
|
|
|
|
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
|
|
|
|
|
|
|
editor = GIMP_DATA_EDITOR (object);
|
2002-03-08 08:27:45 +08:00
|
|
|
|
2003-10-12 00:50:35 +08:00
|
|
|
editor->save_button =
|
2002-03-08 08:27:45 +08:00
|
|
|
gimp_editor_add_button (GIMP_EDITOR (editor),
|
|
|
|
GTK_STOCK_SAVE,
|
|
|
|
_("Save"), NULL,
|
|
|
|
G_CALLBACK (gimp_data_editor_save_clicked),
|
|
|
|
NULL,
|
|
|
|
editor);
|
|
|
|
|
2003-10-12 00:50:35 +08:00
|
|
|
editor->revert_button =
|
2002-03-08 08:27:45 +08:00
|
|
|
gimp_editor_add_button (GIMP_EDITOR (editor),
|
|
|
|
GTK_STOCK_REVERT_TO_SAVED,
|
|
|
|
_("Revert"), NULL,
|
|
|
|
G_CALLBACK (gimp_data_editor_revert_clicked),
|
|
|
|
NULL,
|
|
|
|
editor);
|
2004-12-13 02:26:16 +08:00
|
|
|
/*
|
|
|
|
* Set insensitive because revert buttons are not yet implemented.
|
|
|
|
*/
|
|
|
|
gtk_widget_set_sensitive (editor->revert_button, FALSE);
|
2002-03-08 08:27:45 +08:00
|
|
|
|
2004-10-25 04:38:35 +08:00
|
|
|
return object;
|
2003-10-12 00:50:35 +08:00
|
|
|
}
|
|
|
|
|
2004-09-27 03:26:37 +08:00
|
|
|
static void
|
|
|
|
gimp_data_editor_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpDataEditor *editor = GIMP_DATA_EDITOR (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_DATA_FACTORY:
|
|
|
|
editor->data_factory = g_value_get_object (value);
|
|
|
|
break;
|
2004-09-27 03:41:56 +08:00
|
|
|
case PROP_DATA:
|
|
|
|
gimp_data_editor_set_data (editor,
|
|
|
|
(GimpData *) g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_data_editor_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpDataEditor *editor = GIMP_DATA_EDITOR (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_DATA_FACTORY:
|
|
|
|
g_value_set_object (value, editor->data_factory);
|
|
|
|
break;
|
|
|
|
case PROP_DATA:
|
|
|
|
g_value_set_object (value, editor->data);
|
|
|
|
break;
|
2004-09-27 03:26:37 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-27 02:41:29 +08:00
|
|
|
static void
|
|
|
|
gimp_data_editor_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
GimpDataEditor *editor = GIMP_DATA_EDITOR (object);
|
|
|
|
|
|
|
|
if (editor->data)
|
|
|
|
{
|
|
|
|
/* Save dirty data before we clear out */
|
|
|
|
gimp_data_editor_save_dirty (editor);
|
|
|
|
gimp_data_editor_set_data (editor, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2003-10-19 01:10:36 +08:00
|
|
|
#define AUX_INFO_CURRENT_DATA "current-data"
|
|
|
|
|
2003-10-12 00:50:35 +08:00
|
|
|
static void
|
|
|
|
gimp_data_editor_set_aux_info (GimpDocked *docked,
|
|
|
|
GList *aux_info)
|
|
|
|
{
|
|
|
|
GimpDataEditor *editor = GIMP_DATA_EDITOR (docked);
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
for (list = aux_info; list; list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GimpSessionInfoAux *aux = list->data;
|
|
|
|
|
2003-10-19 01:10:36 +08:00
|
|
|
if (! strcmp (aux->name, AUX_INFO_CURRENT_DATA))
|
2003-10-12 00:50:35 +08:00
|
|
|
{
|
|
|
|
GimpData *data;
|
|
|
|
|
|
|
|
data = (GimpData *)
|
|
|
|
gimp_container_get_child_by_name (editor->data_factory->container,
|
|
|
|
aux->value);
|
|
|
|
|
|
|
|
if (data)
|
|
|
|
gimp_data_editor_set_data (editor, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static GList *
|
|
|
|
gimp_data_editor_get_aux_info (GimpDocked *docked)
|
|
|
|
{
|
|
|
|
GimpDataEditor *editor = GIMP_DATA_EDITOR (docked);
|
|
|
|
GList *aux_info = NULL;
|
|
|
|
|
|
|
|
if (editor->data)
|
|
|
|
{
|
|
|
|
GimpSessionInfoAux *aux;
|
2003-10-12 01:05:48 +08:00
|
|
|
const gchar *value;
|
2003-10-12 00:50:35 +08:00
|
|
|
|
2003-10-12 01:05:48 +08:00
|
|
|
value = gimp_object_get_name (GIMP_OBJECT (editor->data));
|
2003-10-12 00:50:35 +08:00
|
|
|
|
2003-10-19 01:10:36 +08:00
|
|
|
aux = gimp_session_info_aux_new (AUX_INFO_CURRENT_DATA, value);
|
2003-10-12 00:50:35 +08:00
|
|
|
aux_info = g_list_append (aux_info, aux);
|
|
|
|
}
|
|
|
|
|
|
|
|
return aux_info;
|
|
|
|
}
|
|
|
|
|
2005-04-17 04:48:33 +08:00
|
|
|
static gchar *
|
|
|
|
gimp_data_editor_get_title (GimpDocked *docked)
|
|
|
|
{
|
|
|
|
GimpDataEditor *editor = GIMP_DATA_EDITOR (docked);
|
|
|
|
GimpDataEditorClass *editor_class = GIMP_DATA_EDITOR_GET_CLASS (editor);
|
|
|
|
|
|
|
|
if (editor->data_editable)
|
|
|
|
return g_strdup (editor_class->title);
|
|
|
|
else
|
|
|
|
return g_strdup_printf (_("%s (read only)"), editor_class->title);
|
|
|
|
}
|
|
|
|
|
2002-03-08 08:27:45 +08:00
|
|
|
static void
|
|
|
|
gimp_data_editor_real_set_data (GimpDataEditor *editor,
|
|
|
|
GimpData *data)
|
|
|
|
{
|
2005-04-17 04:48:33 +08:00
|
|
|
gboolean editable;
|
|
|
|
|
2002-03-08 08:27:45 +08:00
|
|
|
if (editor->data)
|
|
|
|
{
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (editor->data,
|
2002-03-08 08:27:45 +08:00
|
|
|
gimp_data_editor_data_name_changed,
|
|
|
|
editor);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_object_unref (editor->data);
|
2002-03-08 08:27:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
editor->data = data;
|
|
|
|
|
|
|
|
if (editor->data)
|
|
|
|
{
|
2003-01-06 06:07:10 +08:00
|
|
|
g_object_ref (editor->data);
|
2002-03-08 08:27:45 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (editor->data, "name_changed",
|
2002-03-08 08:27:45 +08:00
|
|
|
G_CALLBACK (gimp_data_editor_data_name_changed),
|
|
|
|
editor);
|
|
|
|
|
2002-03-10 23:05:58 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (editor->name_entry),
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (editor->data)));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (editor->name_entry), "");
|
2002-03-08 08:27:45 +08:00
|
|
|
}
|
|
|
|
|
2005-04-17 04:48:33 +08:00
|
|
|
editable = (editor->data && editor->data->writable);
|
|
|
|
|
|
|
|
if (editor->data_editable != editable)
|
|
|
|
{
|
|
|
|
editor->data_editable = editable;
|
2003-03-10 22:07:22 +08:00
|
|
|
|
2005-04-17 04:48:33 +08:00
|
|
|
gtk_widget_set_sensitive (editor->name_entry, editable);
|
|
|
|
gimp_docked_title_changed (GIMP_DOCKED (editor));
|
|
|
|
}
|
2002-03-08 08:27:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_data_editor_set_data (GimpDataEditor *editor,
|
|
|
|
GimpData *data)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DATA_EDITOR (editor));
|
2003-03-21 19:47:37 +08:00
|
|
|
g_return_if_fail (data == NULL || GIMP_IS_DATA (data));
|
2003-10-12 00:50:35 +08:00
|
|
|
g_return_if_fail (data == NULL ||
|
|
|
|
g_type_is_a (G_TYPE_FROM_INSTANCE (data),
|
|
|
|
editor->data_factory->container->children_type));
|
2002-03-08 08:27:45 +08:00
|
|
|
|
|
|
|
if (editor->data != data)
|
2004-09-27 03:41:56 +08:00
|
|
|
{
|
|
|
|
GIMP_DATA_EDITOR_GET_CLASS (editor)->set_data (editor, data);
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (editor), "data");
|
2004-10-25 04:38:35 +08:00
|
|
|
|
|
|
|
if (GIMP_EDITOR (editor)->ui_manager)
|
|
|
|
gimp_ui_manager_update (GIMP_EDITOR (editor)->ui_manager,
|
|
|
|
GIMP_EDITOR (editor)->popup_data);
|
2004-09-27 03:41:56 +08:00
|
|
|
}
|
2002-03-08 08:27:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GimpData *
|
|
|
|
gimp_data_editor_get_data (GimpDataEditor *editor)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DATA_EDITOR (editor), NULL);
|
|
|
|
|
|
|
|
return editor->data;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_data_editor_name_activate (GtkWidget *widget,
|
|
|
|
GimpDataEditor *editor)
|
|
|
|
{
|
|
|
|
if (editor->data)
|
|
|
|
{
|
|
|
|
const gchar *entry_text;
|
|
|
|
|
|
|
|
entry_text = gtk_entry_get_text (GTK_ENTRY (widget));
|
|
|
|
|
|
|
|
gimp_object_set_name (GIMP_OBJECT (editor->data), entry_text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_data_editor_name_focus_out (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
GimpDataEditor *editor)
|
|
|
|
{
|
|
|
|
gimp_data_editor_name_activate (widget, editor);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_data_editor_data_name_changed (GimpObject *object,
|
|
|
|
GimpDataEditor *editor)
|
|
|
|
{
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (editor->name_entry),
|
|
|
|
gimp_object_get_name (object));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_data_editor_save_clicked (GtkWidget *widget,
|
|
|
|
GimpDataEditor *editor)
|
2003-11-12 03:00:42 +08:00
|
|
|
{
|
|
|
|
gimp_data_editor_save_dirty (editor);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_data_editor_revert_clicked (GtkWidget *widget,
|
|
|
|
GimpDataEditor *editor)
|
|
|
|
{
|
|
|
|
g_print ("TODO: implement revert\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_data_editor_save_dirty (GimpDataEditor *editor)
|
2002-03-08 08:27:45 +08:00
|
|
|
{
|
2004-01-29 05:53:50 +08:00
|
|
|
GimpData *data = editor->data;
|
2003-11-12 07:50:03 +08:00
|
|
|
|
2004-02-13 19:53:22 +08:00
|
|
|
if (data && data->dirty && data->writable)
|
2004-01-29 05:53:50 +08:00
|
|
|
gimp_data_factory_data_save_single (editor->data_factory, data);
|
2002-03-08 08:27:45 +08:00
|
|
|
}
|