app/widgets/widgets-types.h added new struct GimpSessionInfoAux which
2003-10-11 Michael Natterer <mitch@gimp.org> * app/widgets/widgets-types.h * app/widgets/gimpsessioninfo.[ch]: added new struct GimpSessionInfoAux which contains "gchar *name" and "gchar *value". Changed sessionrc "aux-info" format again to be really extendable this time. Also breaks everybody's sessionrc again. * app/widgets/gimpimagedock.c * etc/sessionrc: changed accordingly. Implemented the stuff suggested in bug #122964. Fixes bug #122964 and bug #52206: * app/widgets/gimpdataeditor.[ch]: replaced the "Gimp" member by a "GimpDataFactory" and changed gimp_data_editor_construct() accordingly. Implement GimpDockedInterface::set_aux_info() and get_aux_info() and remember the currently edited data across sessions. * app/gui/gradient-editor-commands.c * app/gui/gradient-editor-menu.c * app/widgets/gimpbrusheditor.c * app/widgets/gimpgradienteditor.c * app/widgets/gimppaletteeditor.c: changed accordingly. * app/widgets/gimpcoloreditor.c: remember the active color selector across sessions.
This commit is contained in:

committed by
Michael Natterer

parent
3aa0b64e15
commit
b136228de9
29
ChangeLog
29
ChangeLog
@ -1,3 +1,32 @@
|
||||
2003-10-11 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/widgets/widgets-types.h
|
||||
* app/widgets/gimpsessioninfo.[ch]: added new struct
|
||||
GimpSessionInfoAux which contains "gchar *name" and "gchar *value".
|
||||
Changed sessionrc "aux-info" format again to be really extendable
|
||||
this time. Also breaks everybody's sessionrc again.
|
||||
|
||||
* app/widgets/gimpimagedock.c
|
||||
* etc/sessionrc: changed accordingly.
|
||||
|
||||
Implemented the stuff suggested in bug #122964. Fixes bug #122964
|
||||
and bug #52206:
|
||||
|
||||
* app/widgets/gimpdataeditor.[ch]: replaced the "Gimp" member by a
|
||||
"GimpDataFactory" and changed gimp_data_editor_construct()
|
||||
accordingly. Implement GimpDockedInterface::set_aux_info() and
|
||||
get_aux_info() and remember the currently edited data across
|
||||
sessions.
|
||||
|
||||
* app/gui/gradient-editor-commands.c
|
||||
* app/gui/gradient-editor-menu.c
|
||||
* app/widgets/gimpbrusheditor.c
|
||||
* app/widgets/gimpgradienteditor.c
|
||||
* app/widgets/gimppaletteeditor.c: changed accordingly.
|
||||
|
||||
* app/widgets/gimpcoloreditor.c: remember the active color
|
||||
selector across sessions.
|
||||
|
||||
2003-10-11 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/core/gimpcontainer.c (gimp_container_deserialize): when
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpdatafactory.h"
|
||||
#include "core/gimpgradient.h"
|
||||
|
||||
#include "widgets/gimpgradienteditor.h"
|
||||
@ -112,7 +113,7 @@ gradient_editor_load_left_cmd_callback (GtkWidget *widget,
|
||||
|
||||
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
||||
|
||||
user_context = gimp_get_user_context (GIMP_DATA_EDITOR (editor)->gimp);
|
||||
user_context = gimp_get_user_context (GIMP_DATA_EDITOR (editor)->data_factory->gimp);
|
||||
|
||||
i = (gint) action;
|
||||
|
||||
@ -230,7 +231,7 @@ gradient_editor_load_right_cmd_callback (GtkWidget *widget,
|
||||
|
||||
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
||||
|
||||
user_context = gimp_get_user_context (GIMP_DATA_EDITOR (editor)->gimp);
|
||||
user_context = gimp_get_user_context (GIMP_DATA_EDITOR (editor)->data_factory->gimp);
|
||||
|
||||
i = (gint) action;
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpdatafactory.h"
|
||||
#include "core/gimpgradient.h"
|
||||
|
||||
#include "widgets/gimpgradienteditor.h"
|
||||
@ -112,7 +113,7 @@ gradient_editor_load_left_cmd_callback (GtkWidget *widget,
|
||||
|
||||
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
||||
|
||||
user_context = gimp_get_user_context (GIMP_DATA_EDITOR (editor)->gimp);
|
||||
user_context = gimp_get_user_context (GIMP_DATA_EDITOR (editor)->data_factory->gimp);
|
||||
|
||||
i = (gint) action;
|
||||
|
||||
@ -230,7 +231,7 @@ gradient_editor_load_right_cmd_callback (GtkWidget *widget,
|
||||
|
||||
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
||||
|
||||
user_context = gimp_get_user_context (GIMP_DATA_EDITOR (editor)->gimp);
|
||||
user_context = gimp_get_user_context (GIMP_DATA_EDITOR (editor)->data_factory->gimp);
|
||||
|
||||
i = (gint) action;
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpdatafactory.h"
|
||||
#include "core/gimpgradient.h"
|
||||
|
||||
#include "widgets/gimpdataeditor.h"
|
||||
@ -282,7 +283,7 @@ gradient_editor_menu_update (GtkItemFactory *factory,
|
||||
|
||||
editor = GIMP_GRADIENT_EDITOR (data);
|
||||
|
||||
user_context = gimp_get_user_context (GIMP_DATA_EDITOR (editor)->gimp);
|
||||
user_context = gimp_get_user_context (GIMP_DATA_EDITOR (editor)->data_factory->gimp);
|
||||
|
||||
if (editor->control_sel_l->prev)
|
||||
left_seg = editor->control_sel_l->prev;
|
||||
|
@ -229,8 +229,7 @@ gimp_brush_editor_new (Gimp *gimp)
|
||||
brush_editor = g_object_new (GIMP_TYPE_BRUSH_EDITOR, NULL);
|
||||
|
||||
if (! gimp_data_editor_construct (GIMP_DATA_EDITOR (brush_editor),
|
||||
gimp,
|
||||
GIMP_TYPE_BRUSH,
|
||||
gimp->brush_factory,
|
||||
NULL, NULL))
|
||||
{
|
||||
g_object_unref (brush_editor);
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@ -33,6 +35,7 @@
|
||||
|
||||
#include "gimpcoloreditor.h"
|
||||
#include "gimpdocked.h"
|
||||
#include "gimpsessioninfo.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
@ -43,10 +46,15 @@ static void gimp_color_editor_docked_iface_init (GimpDockedInterface *docked_
|
||||
|
||||
static void gimp_color_editor_destroy (GtkObject *object);
|
||||
|
||||
static void gimp_color_editor_set_aux_info (GimpDocked *docked,
|
||||
GList *aux_info);
|
||||
static GList *gimp_color_editor_get_aux_info (GimpDocked *docked);
|
||||
static void gimp_color_editor_set_docked_context (GimpDocked *docked,
|
||||
GimpContext *context,
|
||||
GimpContext *prev_context);
|
||||
|
||||
static void gimp_color_editor_destroy (GtkObject *object);
|
||||
|
||||
static void gimp_color_editor_fg_changed (GimpContext *context,
|
||||
const GimpRGB *rgb,
|
||||
GimpColorEditor *editor);
|
||||
@ -198,7 +206,8 @@ gimp_color_editor_init (GimpColorEditor *editor)
|
||||
selector_class->name,
|
||||
selector_class->help_page);
|
||||
|
||||
g_object_set_data (G_OBJECT (button), "selector", selector);
|
||||
g_object_set_data (G_OBJECT (button), "selector", selector);
|
||||
g_object_set_data (G_OBJECT (selector), "button", button);
|
||||
|
||||
g_signal_connect (button, "toggled",
|
||||
G_CALLBACK (gimp_color_editor_tab_toggled),
|
||||
@ -288,7 +297,78 @@ gimp_color_editor_init (GimpColorEditor *editor)
|
||||
static void
|
||||
gimp_color_editor_docked_iface_init (GimpDockedInterface *docked_iface)
|
||||
{
|
||||
docked_iface->set_context = gimp_color_editor_set_docked_context;
|
||||
docked_iface->set_aux_info = gimp_color_editor_set_aux_info;
|
||||
docked_iface->get_aux_info = gimp_color_editor_get_aux_info;
|
||||
docked_iface->set_context = gimp_color_editor_set_docked_context;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_editor_set_aux_info (GimpDocked *docked,
|
||||
GList *aux_info)
|
||||
{
|
||||
GimpColorEditor *editor = GIMP_COLOR_EDITOR (docked);
|
||||
GtkWidget *notebook = GIMP_COLOR_NOTEBOOK (editor->notebook)->notebook;
|
||||
GList *list;
|
||||
|
||||
for (list = aux_info; list; list = g_list_next (list))
|
||||
{
|
||||
GimpSessionInfoAux *aux = list->data;
|
||||
|
||||
if (! strcmp (aux->name, "current-page"))
|
||||
{
|
||||
GList *children;
|
||||
GList *child;
|
||||
|
||||
children = gtk_container_get_children (GTK_CONTAINER (notebook));
|
||||
|
||||
for (child = children; child; child = g_list_next (child))
|
||||
{
|
||||
if (! strcmp (G_OBJECT_TYPE_NAME (child->data), aux->value))
|
||||
{
|
||||
GtkWidget *button;
|
||||
|
||||
button = g_object_get_data (G_OBJECT (child->data), "button");
|
||||
|
||||
if (button)
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
|
||||
TRUE);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
g_list_free (children);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static GList *
|
||||
gimp_color_editor_get_aux_info (GimpDocked *docked)
|
||||
{
|
||||
GimpColorEditor *editor = GIMP_COLOR_EDITOR (docked);
|
||||
GimpColorNotebook *notebook = GIMP_COLOR_NOTEBOOK (editor->notebook);
|
||||
GList *aux_info = NULL;
|
||||
|
||||
if (notebook->cur_page)
|
||||
{
|
||||
GimpSessionInfoAux *aux;
|
||||
|
||||
aux = g_new0 (GimpSessionInfoAux, 1);
|
||||
aux->name = g_strdup ("current-page");
|
||||
aux->value = g_strdup (G_OBJECT_TYPE_NAME (notebook->cur_page));
|
||||
|
||||
aux_info = g_list_append (aux_info, aux);
|
||||
}
|
||||
|
||||
return aux_info;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_editor_set_docked_context (GimpDocked *docked,
|
||||
GimpContext *context,
|
||||
GimpContext *prev_context)
|
||||
{
|
||||
gimp_color_editor_set_context (GIMP_COLOR_EDITOR (docked), context);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -304,14 +384,6 @@ gimp_color_editor_destroy (GtkObject *object)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_editor_set_docked_context (GimpDocked *docked,
|
||||
GimpContext *context,
|
||||
GimpContext *prev_context)
|
||||
{
|
||||
gimp_color_editor_set_context (GIMP_COLOR_EDITOR (docked), context);
|
||||
}
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
@ -28,12 +30,16 @@
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontainer.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpdata.h"
|
||||
#include "core/gimpdatafactory.h"
|
||||
|
||||
#include "gimpdataeditor.h"
|
||||
#include "gimpdocked.h"
|
||||
#include "gimpitemfactory.h"
|
||||
#include "gimpmenufactory.h"
|
||||
#include "gimpsessioninfo.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
@ -41,6 +47,11 @@
|
||||
static void gimp_data_editor_class_init (GimpDataEditorClass *klass);
|
||||
static void gimp_data_editor_init (GimpDataEditor *view);
|
||||
|
||||
static void gimp_data_editor_docked_iface_init (GimpDockedInterface *docked_iface);
|
||||
static void gimp_data_editor_set_aux_info (GimpDocked *docked,
|
||||
GList *aux_info);
|
||||
static GList * gimp_data_editor_get_aux_info (GimpDocked *docked);
|
||||
|
||||
static void gimp_data_editor_dispose (GObject *object);
|
||||
|
||||
static void gimp_data_editor_real_set_data (GimpDataEditor *editor,
|
||||
@ -67,9 +78,9 @@ static GimpEditorClass *parent_class = NULL;
|
||||
GType
|
||||
gimp_data_editor_get_type (void)
|
||||
{
|
||||
static GType view_type = 0;
|
||||
static GType type = 0;
|
||||
|
||||
if (! view_type)
|
||||
if (! type)
|
||||
{
|
||||
static const GTypeInfo view_info =
|
||||
{
|
||||
@ -83,13 +94,22 @@ gimp_data_editor_get_type (void)
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gimp_data_editor_init,
|
||||
};
|
||||
static const GInterfaceInfo docked_iface_info =
|
||||
{
|
||||
(GInterfaceInitFunc) gimp_data_editor_docked_iface_init,
|
||||
NULL, /* iface_finalize */
|
||||
NULL /* iface_data */
|
||||
};
|
||||
|
||||
view_type = g_type_register_static (GIMP_TYPE_EDITOR,
|
||||
"GimpDataEditor",
|
||||
&view_info, 0);
|
||||
type = g_type_register_static (GIMP_TYPE_EDITOR,
|
||||
"GimpDataEditor",
|
||||
&view_info, 0);
|
||||
|
||||
g_type_add_interface_static (type, GIMP_TYPE_DOCKED,
|
||||
&docked_iface_info);
|
||||
}
|
||||
|
||||
return view_type;
|
||||
return type;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -109,7 +129,7 @@ gimp_data_editor_class_init (GimpDataEditorClass *klass)
|
||||
static void
|
||||
gimp_data_editor_init (GimpDataEditor *editor)
|
||||
{
|
||||
editor->data_type = G_TYPE_NONE;
|
||||
editor->data_factory = NULL;
|
||||
editor->data = NULL;
|
||||
editor->data_editable = FALSE;
|
||||
|
||||
@ -142,6 +162,58 @@ gimp_data_editor_init (GimpDataEditor *editor)
|
||||
editor);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if (! strcmp (aux->name, "current-data"))
|
||||
{
|
||||
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;
|
||||
|
||||
aux = g_new0 (GimpSessionInfoAux, 1);
|
||||
aux->name = g_strdup ("current-data");
|
||||
aux->value = g_strdup (gimp_object_get_name (GIMP_OBJECT (editor->data)));
|
||||
|
||||
aux_info = g_list_append (aux_info, aux);
|
||||
}
|
||||
|
||||
return aux_info;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_data_editor_dispose (GObject *object)
|
||||
{
|
||||
@ -195,30 +267,28 @@ gimp_data_editor_real_set_data (GimpDataEditor *editor,
|
||||
|
||||
gboolean
|
||||
gimp_data_editor_construct (GimpDataEditor *editor,
|
||||
Gimp *gimp,
|
||||
GType data_type,
|
||||
GimpDataFactory *data_factory,
|
||||
GimpMenuFactory *menu_factory,
|
||||
const gchar *menu_identifier)
|
||||
{
|
||||
GimpData *data;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_DATA_EDITOR (editor), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
|
||||
g_return_val_if_fail (g_type_is_a (data_type, GIMP_TYPE_DATA), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_DATA_FACTORY (data_factory), FALSE);
|
||||
g_return_val_if_fail (menu_factory == NULL ||
|
||||
GIMP_IS_MENU_FACTORY (menu_factory), FALSE);
|
||||
g_return_val_if_fail (menu_factory == NULL ||
|
||||
menu_identifier != NULL, FALSE);
|
||||
|
||||
editor->gimp = gimp;
|
||||
editor->data_type = data_type;
|
||||
editor->data_factory = data_factory;
|
||||
|
||||
if (menu_factory && menu_identifier)
|
||||
gimp_editor_create_menu (GIMP_EDITOR (editor),
|
||||
menu_factory, menu_identifier, editor);
|
||||
|
||||
data = (GimpData *)
|
||||
gimp_context_get_by_type (gimp_get_user_context (gimp), data_type);
|
||||
gimp_context_get_by_type (gimp_get_user_context (data_factory->gimp),
|
||||
data_factory->container->children_type);
|
||||
|
||||
gimp_data_editor_set_data (editor, data);
|
||||
|
||||
@ -231,8 +301,9 @@ gimp_data_editor_set_data (GimpDataEditor *editor,
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_DATA_EDITOR (editor));
|
||||
g_return_if_fail (data == NULL || GIMP_IS_DATA (data));
|
||||
g_return_if_fail (data == NULL || g_type_is_a (G_TYPE_FROM_INSTANCE (data),
|
||||
editor->data_type));
|
||||
g_return_if_fail (data == NULL ||
|
||||
g_type_is_a (G_TYPE_FROM_INSTANCE (data),
|
||||
editor->data_factory->container->children_type));
|
||||
|
||||
if (editor->data != data)
|
||||
GIMP_DATA_EDITOR_GET_CLASS (editor)->set_data (editor, data);
|
||||
|
@ -40,9 +40,7 @@ struct _GimpDataEditor
|
||||
{
|
||||
GimpEditor parent_instance;
|
||||
|
||||
Gimp *gimp;
|
||||
|
||||
GType data_type;
|
||||
GimpDataFactory *data_factory;
|
||||
GimpData *data;
|
||||
gboolean data_editable;
|
||||
|
||||
@ -66,8 +64,7 @@ struct _GimpDataEditorClass
|
||||
GType gimp_data_editor_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_data_editor_construct (GimpDataEditor *editor,
|
||||
Gimp *gimp,
|
||||
GType data_type,
|
||||
GimpDataFactory *data_factory,
|
||||
GimpMenuFactory *menu_factory,
|
||||
const gchar *menu_identifier);
|
||||
|
||||
|
@ -472,8 +472,7 @@ gimp_gradient_editor_new (Gimp *gimp,
|
||||
editor = g_object_new (GIMP_TYPE_GRADIENT_EDITOR, NULL);
|
||||
|
||||
if (! gimp_data_editor_construct (GIMP_DATA_EDITOR (editor),
|
||||
gimp,
|
||||
GIMP_TYPE_GRADIENT,
|
||||
gimp->gradient_factory,
|
||||
menu_factory, "<GradientEditor>"))
|
||||
{
|
||||
g_object_unref (editor);
|
||||
@ -820,7 +819,7 @@ preview_set_foreground (GimpGradientEditor *editor,
|
||||
|
||||
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
||||
|
||||
user_context = gimp_get_user_context (GIMP_DATA_EDITOR (editor)->gimp);
|
||||
user_context = gimp_get_user_context (GIMP_DATA_EDITOR (editor)->data_factory->gimp);
|
||||
|
||||
xpos = control_calc_g_pos (editor, x);
|
||||
|
||||
@ -854,7 +853,7 @@ preview_set_background (GimpGradientEditor *editor,
|
||||
|
||||
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
|
||||
|
||||
user_context = gimp_get_user_context (GIMP_DATA_EDITOR (editor)->gimp);
|
||||
user_context = gimp_get_user_context (GIMP_DATA_EDITOR (editor)->data_factory->gimp);
|
||||
|
||||
xpos = control_calc_g_pos (editor, x);
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "gimpdockable.h"
|
||||
#include "gimpdockbook.h"
|
||||
#include "gimphelp-ids.h"
|
||||
#include "gimpsessioninfo.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
@ -295,23 +296,22 @@ gimp_image_dock_set_aux_info (GimpDock *dock,
|
||||
GList *aux_info)
|
||||
{
|
||||
GimpImageDock *image_dock = GIMP_IMAGE_DOCK (dock);
|
||||
GList *aux;
|
||||
GList *list;
|
||||
gboolean menu_shown = image_dock->show_image_menu;
|
||||
gboolean auto_follow = image_dock->auto_follow_active;
|
||||
|
||||
for (aux = aux_info; aux; aux = g_list_next (aux))
|
||||
for (list = aux_info; list; list = g_list_next (list))
|
||||
{
|
||||
gchar *str = (gchar *) aux->data;
|
||||
GimpSessionInfoAux *aux = list->data;
|
||||
|
||||
if (! strcmp (str, "menu-shown"))
|
||||
menu_shown = TRUE;
|
||||
else if (! strcmp (str, "menu-hidden"))
|
||||
menu_shown = FALSE;
|
||||
|
||||
else if (! strcmp (str, "follow-active-image"))
|
||||
auto_follow = TRUE;
|
||||
else if (! strcmp (str, "dont-follow-active-image"))
|
||||
auto_follow = FALSE;
|
||||
if (! strcmp (aux->name, "show-image-menu"))
|
||||
{
|
||||
menu_shown = ! g_ascii_strcasecmp (aux->value, "true");
|
||||
}
|
||||
else if (! strcmp (aux->name, "follow-active-image"))
|
||||
{
|
||||
auto_follow = ! g_ascii_strcasecmp (aux->value, "true");
|
||||
}
|
||||
}
|
||||
|
||||
if (menu_shown != image_dock->show_image_menu)
|
||||
@ -324,20 +324,23 @@ gimp_image_dock_set_aux_info (GimpDock *dock,
|
||||
static GList *
|
||||
gimp_image_dock_get_aux_info (GimpDock *dock)
|
||||
{
|
||||
GimpImageDock *image_dock = GIMP_IMAGE_DOCK (dock);
|
||||
GList *aux = NULL;
|
||||
GimpImageDock *image_dock = GIMP_IMAGE_DOCK (dock);
|
||||
GList *aux_info = NULL;
|
||||
GimpSessionInfoAux *aux;
|
||||
|
||||
aux = g_list_append (aux,
|
||||
image_dock->show_image_menu ?
|
||||
g_strdup ("menu-shown") :
|
||||
g_strdup ("menu-hidden"));
|
||||
aux = g_new0 (GimpSessionInfoAux, 1);
|
||||
aux->name = g_strdup ("show-image-menu");
|
||||
aux->value = g_strdup (image_dock->show_image_menu ? "true" : "false");
|
||||
|
||||
aux = g_list_append (aux,
|
||||
image_dock->auto_follow_active ?
|
||||
g_strdup ("follow-active-image") :
|
||||
g_strdup ("dont-follow-active-image"));
|
||||
aux_info = g_list_append (aux_info, aux);
|
||||
|
||||
return aux;
|
||||
aux = g_new0 (GimpSessionInfoAux, 1);
|
||||
aux->name = g_strdup ("follow-auctive-image");
|
||||
aux->value = g_strdup (image_dock->auto_follow_active ? "true" : "false");
|
||||
|
||||
aux_info = g_list_append (aux_info, aux);
|
||||
|
||||
return aux_info;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "gimpdockable.h"
|
||||
#include "gimpdockbook.h"
|
||||
#include "gimphelp-ids.h"
|
||||
#include "gimpsessioninfo.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
@ -295,23 +296,22 @@ gimp_image_dock_set_aux_info (GimpDock *dock,
|
||||
GList *aux_info)
|
||||
{
|
||||
GimpImageDock *image_dock = GIMP_IMAGE_DOCK (dock);
|
||||
GList *aux;
|
||||
GList *list;
|
||||
gboolean menu_shown = image_dock->show_image_menu;
|
||||
gboolean auto_follow = image_dock->auto_follow_active;
|
||||
|
||||
for (aux = aux_info; aux; aux = g_list_next (aux))
|
||||
for (list = aux_info; list; list = g_list_next (list))
|
||||
{
|
||||
gchar *str = (gchar *) aux->data;
|
||||
GimpSessionInfoAux *aux = list->data;
|
||||
|
||||
if (! strcmp (str, "menu-shown"))
|
||||
menu_shown = TRUE;
|
||||
else if (! strcmp (str, "menu-hidden"))
|
||||
menu_shown = FALSE;
|
||||
|
||||
else if (! strcmp (str, "follow-active-image"))
|
||||
auto_follow = TRUE;
|
||||
else if (! strcmp (str, "dont-follow-active-image"))
|
||||
auto_follow = FALSE;
|
||||
if (! strcmp (aux->name, "show-image-menu"))
|
||||
{
|
||||
menu_shown = ! g_ascii_strcasecmp (aux->value, "true");
|
||||
}
|
||||
else if (! strcmp (aux->name, "follow-active-image"))
|
||||
{
|
||||
auto_follow = ! g_ascii_strcasecmp (aux->value, "true");
|
||||
}
|
||||
}
|
||||
|
||||
if (menu_shown != image_dock->show_image_menu)
|
||||
@ -324,20 +324,23 @@ gimp_image_dock_set_aux_info (GimpDock *dock,
|
||||
static GList *
|
||||
gimp_image_dock_get_aux_info (GimpDock *dock)
|
||||
{
|
||||
GimpImageDock *image_dock = GIMP_IMAGE_DOCK (dock);
|
||||
GList *aux = NULL;
|
||||
GimpImageDock *image_dock = GIMP_IMAGE_DOCK (dock);
|
||||
GList *aux_info = NULL;
|
||||
GimpSessionInfoAux *aux;
|
||||
|
||||
aux = g_list_append (aux,
|
||||
image_dock->show_image_menu ?
|
||||
g_strdup ("menu-shown") :
|
||||
g_strdup ("menu-hidden"));
|
||||
aux = g_new0 (GimpSessionInfoAux, 1);
|
||||
aux->name = g_strdup ("show-image-menu");
|
||||
aux->value = g_strdup (image_dock->show_image_menu ? "true" : "false");
|
||||
|
||||
aux = g_list_append (aux,
|
||||
image_dock->auto_follow_active ?
|
||||
g_strdup ("follow-active-image") :
|
||||
g_strdup ("dont-follow-active-image"));
|
||||
aux_info = g_list_append (aux_info, aux);
|
||||
|
||||
return aux;
|
||||
aux = g_new0 (GimpSessionInfoAux, 1);
|
||||
aux->name = g_strdup ("follow-auctive-image");
|
||||
aux->value = g_strdup (image_dock->auto_follow_active ? "true" : "false");
|
||||
|
||||
aux_info = g_list_append (aux_info, aux);
|
||||
|
||||
return aux_info;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -440,8 +440,7 @@ gimp_palette_editor_new (Gimp *gimp,
|
||||
palette_editor = g_object_new (GIMP_TYPE_PALETTE_EDITOR, NULL);
|
||||
|
||||
if (! gimp_data_editor_construct (GIMP_DATA_EDITOR (palette_editor),
|
||||
gimp,
|
||||
GIMP_TYPE_PALETTE,
|
||||
gimp->palette_factory,
|
||||
menu_factory, "<PaletteEditor>"))
|
||||
{
|
||||
g_object_unref (palette_editor);
|
||||
@ -530,7 +529,7 @@ palette_editor_color_area_button_press (GtkWidget *widget,
|
||||
|
||||
palette = GIMP_PALETTE (data_editor->data);
|
||||
|
||||
user_context = gimp_get_user_context (data_editor->gimp);
|
||||
user_context = gimp_get_user_context (data_editor->data_factory->gimp);
|
||||
|
||||
entry_width = editor->col_width + SPACING;
|
||||
entry_height = (ENTRY_HEIGHT * editor->zoom_factor) + SPACING;
|
||||
@ -1042,7 +1041,7 @@ palette_editor_new_ext_clicked (GtkWidget *widget,
|
||||
|
||||
palette = GIMP_PALETTE (data_editor->data);
|
||||
|
||||
user_context = gimp_get_user_context (data_editor->gimp);
|
||||
user_context = gimp_get_user_context (data_editor->data_factory->gimp);
|
||||
|
||||
if (state & GDK_CONTROL_MASK)
|
||||
gimp_context_get_background (user_context, &color);
|
||||
@ -1221,7 +1220,7 @@ palette_editor_color_notebook_callback (ColorNotebook *color_notebook,
|
||||
|
||||
palette = GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data);
|
||||
|
||||
user_context = gimp_get_user_context (GIMP_DATA_EDITOR (editor)->gimp);
|
||||
user_context = gimp_get_user_context (GIMP_DATA_EDITOR (editor)->data_factory->gimp);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
|
@ -55,7 +55,7 @@ enum
|
||||
|
||||
SESSION_INFO_DOCKABLE_TAB_STYLE,
|
||||
SESSION_INFO_DOCKABLE_PREVIEW_SIZE,
|
||||
SESSION_INFO_DOCKABLE_AUX_INFO
|
||||
SESSION_INFO_DOCKABLE_AUX
|
||||
};
|
||||
|
||||
|
||||
@ -67,6 +67,8 @@ static GTokenType session_info_book_deserialize (GScanner *scanner,
|
||||
GimpSessionInfo *info);
|
||||
static GTokenType session_info_dockable_deserialize (GScanner *scanner,
|
||||
GimpSessionInfoBook *book);
|
||||
static GTokenType session_info_aux_deserialize (GScanner *scanner,
|
||||
GList **aux_list);
|
||||
static void session_info_set_aux_info (GtkWidget *dialog,
|
||||
GList *aux_info);
|
||||
static GList * session_info_get_aux_info (GtkWidget *dialog);
|
||||
@ -126,6 +128,20 @@ gimp_session_info_dockable_free (GimpSessionInfoDockable *dockable)
|
||||
g_free (dockable);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_session_info_aux_free (GimpSessionInfoAux *aux)
|
||||
{
|
||||
g_return_if_fail (aux != NULL);
|
||||
|
||||
if (aux->name)
|
||||
g_free (aux->name);
|
||||
|
||||
if (aux->value)
|
||||
g_free (aux->value);
|
||||
|
||||
g_free (aux);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_session_info_save (GimpSessionInfo *info,
|
||||
const gchar *factory_name,
|
||||
@ -175,16 +191,23 @@ gimp_session_info_save (GimpSessionInfo *info,
|
||||
|
||||
if (info->aux_info)
|
||||
{
|
||||
GList *aux;
|
||||
GList *list;
|
||||
|
||||
gimp_config_writer_open (writer, "aux-info");
|
||||
|
||||
for (aux = info->aux_info; aux; aux = g_list_next (aux))
|
||||
gimp_config_writer_string (writer, (gchar *) aux->data);
|
||||
for (list = info->aux_info; list; list = g_list_next (list))
|
||||
{
|
||||
GimpSessionInfoAux *aux = list->data;
|
||||
|
||||
gimp_config_writer_open (writer, aux->name);
|
||||
gimp_config_writer_string (writer, aux->value);
|
||||
gimp_config_writer_close (writer);
|
||||
}
|
||||
|
||||
gimp_config_writer_close (writer);
|
||||
|
||||
g_list_foreach (info->aux_info, (GFunc) g_free, NULL);
|
||||
g_list_foreach (info->aux_info, (GFunc) gimp_session_info_aux_free,
|
||||
NULL);
|
||||
g_list_free (info->aux_info);
|
||||
info->aux_info = NULL;
|
||||
}
|
||||
@ -268,16 +291,24 @@ gimp_session_info_save (GimpSessionInfo *info,
|
||||
|
||||
if (aux_info)
|
||||
{
|
||||
GList *aux;
|
||||
GList *list;
|
||||
|
||||
gimp_config_writer_open (writer, "aux-info");
|
||||
|
||||
for (aux = aux_info; aux; aux = g_list_next (aux))
|
||||
gimp_config_writer_string (writer, (gchar *) aux->data);
|
||||
for (list = aux_info; list; list = g_list_next (list))
|
||||
{
|
||||
GimpSessionInfoAux *aux = list->data;
|
||||
|
||||
gimp_config_writer_open (writer, aux->name);
|
||||
gimp_config_writer_string (writer, aux->value);
|
||||
gimp_config_writer_close (writer);
|
||||
}
|
||||
|
||||
gimp_config_writer_close (writer);
|
||||
|
||||
g_list_foreach (aux_info, (GFunc) g_free, NULL);
|
||||
g_list_foreach (aux_info,
|
||||
(GFunc) gimp_session_info_aux_free,
|
||||
NULL);
|
||||
g_list_free (aux_info);
|
||||
}
|
||||
|
||||
@ -307,7 +338,6 @@ gimp_session_info_deserialize (GScanner *scanner,
|
||||
GTokenType token;
|
||||
gchar *factory_name;
|
||||
gchar *entry_name;
|
||||
gchar *string;
|
||||
|
||||
g_return_val_if_fail (scanner != NULL, G_TOKEN_LEFT_PAREN);
|
||||
|
||||
@ -335,7 +365,7 @@ gimp_session_info_deserialize (GScanner *scanner,
|
||||
g_scanner_scope_add_symbol (scanner, SESSION_INFO_DOCKABLE, "preview-size",
|
||||
GINT_TO_POINTER (SESSION_INFO_DOCKABLE_PREVIEW_SIZE));
|
||||
g_scanner_scope_add_symbol (scanner, SESSION_INFO_DOCKABLE, "aux-info",
|
||||
GINT_TO_POINTER (SESSION_INFO_DOCKABLE_AUX_INFO));
|
||||
GINT_TO_POINTER (SESSION_INFO_DOCKABLE_AUX));
|
||||
|
||||
token = G_TOKEN_STRING;
|
||||
|
||||
@ -403,18 +433,9 @@ gimp_session_info_deserialize (GScanner *scanner,
|
||||
break;
|
||||
|
||||
case SESSION_INFO_AUX:
|
||||
while ((token =
|
||||
g_scanner_peek_next_token (scanner)) == G_TOKEN_STRING)
|
||||
{
|
||||
if (gimp_scanner_parse_string (scanner, &string))
|
||||
info->aux_info = g_list_append (info->aux_info, string);
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (token != G_TOKEN_RIGHT_PAREN)
|
||||
token = G_TOKEN_STRING;
|
||||
|
||||
token = session_info_aux_deserialize (scanner, &info->aux_info);
|
||||
if (token != G_TOKEN_LEFT_PAREN)
|
||||
goto error;
|
||||
break;
|
||||
|
||||
case SESSION_INFO_DOCK:
|
||||
@ -779,7 +800,6 @@ session_info_dockable_deserialize (GScanner *scanner,
|
||||
GimpSessionInfoBook *book)
|
||||
{
|
||||
GimpSessionInfoDockable *dockable;
|
||||
gchar *string;
|
||||
GEnumClass *enum_class;
|
||||
GEnumValue *enum_value;
|
||||
GTokenType token;
|
||||
@ -831,20 +851,11 @@ session_info_dockable_deserialize (GScanner *scanner,
|
||||
goto error;
|
||||
break;
|
||||
|
||||
case SESSION_INFO_DOCKABLE_AUX_INFO:
|
||||
while ((token =
|
||||
g_scanner_peek_next_token (scanner)) == G_TOKEN_STRING)
|
||||
{
|
||||
if (gimp_scanner_parse_string (scanner, &string))
|
||||
dockable->aux_info = g_list_append (dockable->aux_info,
|
||||
string);
|
||||
else
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (token != G_TOKEN_RIGHT_PAREN)
|
||||
token = G_TOKEN_STRING;
|
||||
|
||||
case SESSION_INFO_DOCKABLE_AUX:
|
||||
token = session_info_aux_deserialize (scanner,
|
||||
&dockable->aux_info);
|
||||
if (token != G_TOKEN_LEFT_PAREN)
|
||||
goto error;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -874,6 +885,62 @@ session_info_dockable_deserialize (GScanner *scanner,
|
||||
return token;
|
||||
}
|
||||
|
||||
static GTokenType
|
||||
session_info_aux_deserialize (GScanner *scanner,
|
||||
GList **aux_list)
|
||||
{
|
||||
GimpSessionInfoAux *aux_info = NULL;
|
||||
GTokenType token;
|
||||
|
||||
token = G_TOKEN_LEFT_PAREN;
|
||||
|
||||
while (g_scanner_peek_next_token (scanner) == token)
|
||||
{
|
||||
token = g_scanner_get_next_token (scanner);
|
||||
|
||||
switch (token)
|
||||
{
|
||||
case G_TOKEN_LEFT_PAREN:
|
||||
token = G_TOKEN_IDENTIFIER;
|
||||
break;
|
||||
|
||||
case G_TOKEN_IDENTIFIER:
|
||||
{
|
||||
aux_info = g_new0 (GimpSessionInfoAux, 1);
|
||||
|
||||
aux_info->name = g_strdup (scanner->value.v_identifier);
|
||||
|
||||
token = G_TOKEN_STRING;
|
||||
if (g_scanner_peek_next_token (scanner) != token)
|
||||
goto error;
|
||||
|
||||
if (! gimp_scanner_parse_string (scanner, &aux_info->value))
|
||||
goto error;
|
||||
|
||||
*aux_list = g_list_append (*aux_list, aux_info);
|
||||
aux_info = NULL;
|
||||
}
|
||||
token = G_TOKEN_RIGHT_PAREN;
|
||||
break;
|
||||
|
||||
case G_TOKEN_RIGHT_PAREN:
|
||||
token = G_TOKEN_LEFT_PAREN;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return token;
|
||||
|
||||
error:
|
||||
if (aux_info)
|
||||
gimp_session_info_aux_free (aux_info);
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
static void
|
||||
session_info_set_aux_info (GtkWidget *dialog,
|
||||
GList *aux_info)
|
||||
|
@ -35,8 +35,8 @@ struct _GimpSessionInfo
|
||||
/* only valid while restoring and saving the session */
|
||||
gboolean open;
|
||||
|
||||
/* GList of gchar* of optional additional dialog specific info */
|
||||
GList *aux_info;
|
||||
/* dialog specific list of GimpSessionInfoAux */
|
||||
GList *aux_info; /* dialog specific list of GimpSessionInfoAux */
|
||||
|
||||
/* only one of these is valid */
|
||||
GimpDialogFactoryEntry *toplevel_entry;
|
||||
@ -58,14 +58,22 @@ struct _GimpSessionInfoDockable
|
||||
GimpTabStyle tab_style;
|
||||
gint preview_size;
|
||||
|
||||
/* GList of gchar* of optional additional dockable specific info */
|
||||
|
||||
/* dialog specific list of GimpSessionInfoAux */
|
||||
GList *aux_info;
|
||||
};
|
||||
|
||||
struct _GimpSessionInfoAux
|
||||
{
|
||||
gchar *name;
|
||||
gchar *value;
|
||||
};
|
||||
|
||||
|
||||
void gimp_session_info_free (GimpSessionInfo *info);
|
||||
void gimp_session_info_book_free (GimpSessionInfoBook *book);
|
||||
void gimp_session_info_dockable_free (GimpSessionInfoDockable *dockable);
|
||||
void gimp_session_info_aux_free (GimpSessionInfoAux *aux);
|
||||
|
||||
void gimp_session_info_save (GimpSessionInfo *info,
|
||||
const gchar *factory_name,
|
||||
|
@ -121,6 +121,7 @@ typedef struct _GimpDialogFactoryEntry GimpDialogFactoryEntry;
|
||||
typedef struct _GimpSessionInfo GimpSessionInfo;
|
||||
typedef struct _GimpSessionInfoBook GimpSessionInfoBook;
|
||||
typedef struct _GimpSessionInfoDockable GimpSessionInfoDockable;
|
||||
typedef struct _GimpSessionInfoAux GimpSessionInfoAux;
|
||||
|
||||
|
||||
/* function types */
|
||||
|
@ -17,7 +17,9 @@
|
||||
(position 300 48)
|
||||
(size 240 660)
|
||||
(open-on-exit)
|
||||
(aux-info "menu-shown" "follow-active-image")
|
||||
(aux-info
|
||||
(show-image-menu "true")
|
||||
(follow-active-image "true"))
|
||||
(dock
|
||||
(book
|
||||
(dockable "gimp-layer-list"
|
||||
|
Reference in New Issue
Block a user