mirror of https://github.com/GNOME/gimp.git
removed lots of code...
2007-05-24 Michael Natterer <mitch@gimp.org> * app/widgets/gimpsessioninfo.[ch]: removed lots of code... * app/widgets/Makefile.am * app/widgets/gimpsessioninfoaux.[ch] * app/widgets/gimpsessioninfobook.[ch] * app/widgets/gimpsessioninfodockable.[ch]: ...and added it here. Also allocate all structs using GSLice. * app/widgets/gimpcoloreditor.c * app/widgets/gimpcursorview.c * app/widgets/gimpdataeditor.c * app/widgets/gimpdialogfactory.c * app/widgets/gimpdocked.c * app/widgets/gimphistogrameditor.c * app/widgets/gimpmenudock.c * app/widgets/gimppaletteeditor.c: changed accordingly. svn path=/trunk/; revision=22603
This commit is contained in:
parent
dfc676e2f5
commit
616ba659f3
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,22 @@
|
|||
2007-05-24 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/widgets/gimpsessioninfo.[ch]: removed lots of code...
|
||||
|
||||
* app/widgets/Makefile.am
|
||||
* app/widgets/gimpsessioninfoaux.[ch]
|
||||
* app/widgets/gimpsessioninfobook.[ch]
|
||||
* app/widgets/gimpsessioninfodockable.[ch]: ...and added it here.
|
||||
Also allocate all structs using GSLice.
|
||||
|
||||
* app/widgets/gimpcoloreditor.c
|
||||
* app/widgets/gimpcursorview.c
|
||||
* app/widgets/gimpdataeditor.c
|
||||
* app/widgets/gimpdialogfactory.c
|
||||
* app/widgets/gimpdocked.c
|
||||
* app/widgets/gimphistogrameditor.c
|
||||
* app/widgets/gimpmenudock.c
|
||||
* app/widgets/gimppaletteeditor.c: changed accordingly.
|
||||
|
||||
2007-05-24 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/common/bumpmap.c: formatting, added const qualifiers.
|
||||
|
|
|
@ -228,6 +228,12 @@ libappwidgets_a_sources = \
|
|||
gimpselectioneditor.h \
|
||||
gimpsessioninfo.c \
|
||||
gimpsessioninfo.h \
|
||||
gimpsessioninfoaux.c \
|
||||
gimpsessioninfoaux.h \
|
||||
gimpsessioninfobook.c \
|
||||
gimpsessioninfobook.h \
|
||||
gimpsessioninfodockable.c \
|
||||
gimpsessioninfodockable.h \
|
||||
gimpsizebox.c \
|
||||
gimpsizebox.h \
|
||||
gimpstringaction.c \
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include "gimpdocked.h"
|
||||
#include "gimpfgbgeditor.h"
|
||||
#include "gimpfgbgview.h"
|
||||
#include "gimpsessioninfo.h"
|
||||
#include "gimpsessioninfoaux.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "gimpcursorview.h"
|
||||
#include "gimpdocked.h"
|
||||
#include "gimpmenufactory.h"
|
||||
#include "gimpsessioninfo.h"
|
||||
#include "gimpsessioninfoaux.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include "gimpdataeditor.h"
|
||||
#include "gimpdocked.h"
|
||||
#include "gimpmenufactory.h"
|
||||
#include "gimpsessioninfo.h"
|
||||
#include "gimpsessioninfoaux.h"
|
||||
#include "gimpuimanager.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
|
|
@ -799,7 +799,7 @@ gimp_dialog_factory_add_dialog (GimpDialogFactory *factory,
|
|||
|
||||
if (! list) /* didn't find a session info */
|
||||
{
|
||||
info = g_new0 (GimpSessionInfo, 1);
|
||||
info = gimp_session_info_new ();
|
||||
|
||||
info->widget = dialog;
|
||||
|
||||
|
@ -858,7 +858,7 @@ gimp_dialog_factory_add_dialog (GimpDialogFactory *factory,
|
|||
|
||||
if (! list) /* didn't find a session info */
|
||||
{
|
||||
info = g_new0 (GimpSessionInfo, 1);
|
||||
info = gimp_session_info_new ();
|
||||
|
||||
info->widget = dialog;
|
||||
|
||||
|
@ -995,7 +995,7 @@ gimp_dialog_factory_remove_dialog (GimpDialogFactory *factory,
|
|||
factory->session_infos = g_list_remove (factory->session_infos,
|
||||
session_info);
|
||||
|
||||
g_free (session_info);
|
||||
gimp_session_info_free (session_info);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include "core/gimpmarshal.h"
|
||||
|
||||
#include "gimpdocked.h"
|
||||
#include "gimpsessioninfo.h"
|
||||
#include "gimpsessioninfoaux.h"
|
||||
|
||||
|
||||
enum
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include "gimphistogrambox.h"
|
||||
#include "gimphistogrameditor.h"
|
||||
#include "gimphistogramview.h"
|
||||
#include "gimpsessioninfo.h"
|
||||
#include "gimpsessioninfoaux.h"
|
||||
#include "gimpwidgets-utils.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include "gimpdockbook.h"
|
||||
#include "gimphelp-ids.h"
|
||||
#include "gimpmenudock.h"
|
||||
#include "gimpsessioninfo.h"
|
||||
#include "gimpsessioninfoaux.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include "gimphelp-ids.h"
|
||||
#include "gimppaletteeditor.h"
|
||||
#include "gimppaletteview.h"
|
||||
#include "gimpsessioninfo.h"
|
||||
#include "gimpsessioninfoaux.h"
|
||||
#include "gimpuimanager.h"
|
||||
#include "gimpviewrendererpalette.h"
|
||||
#include "gimpwidgets-utils.h"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpsessioninfo.c
|
||||
* Copyright (C) 2001-2003 Michael Natterer <mitch@gimp.org>
|
||||
* Copyright (C) 2001-2007 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* 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
|
||||
|
@ -37,6 +37,9 @@
|
|||
#include "gimpdockbook.h"
|
||||
#include "gimpdocked.h"
|
||||
#include "gimpsessioninfo.h"
|
||||
#include "gimpsessioninfoaux.h"
|
||||
#include "gimpsessioninfobook.h"
|
||||
#include "gimpsessioninfodockable.h"
|
||||
|
||||
|
||||
enum
|
||||
|
@ -48,14 +51,7 @@ enum
|
|||
|
||||
SESSION_INFO_DOCK,
|
||||
|
||||
SESSION_INFO_BOOK,
|
||||
SESSION_INFO_BOOK_POSITION,
|
||||
SESSION_INFO_BOOK_CURRENT_PAGE,
|
||||
SESSION_INFO_DOCKABLE,
|
||||
|
||||
SESSION_INFO_DOCKABLE_TAB_STYLE,
|
||||
SESSION_INFO_DOCKABLE_VIEW_SIZE,
|
||||
SESSION_INFO_DOCKABLE_AUX
|
||||
SESSION_INFO_BOOK
|
||||
};
|
||||
|
||||
#define DEFAULT_SCREEN -1
|
||||
|
@ -63,21 +59,19 @@ enum
|
|||
|
||||
/* local function prototypes */
|
||||
|
||||
static GTokenType session_info_dock_deserialize (GScanner *scanner,
|
||||
GimpSessionInfo *info);
|
||||
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);
|
||||
static GTokenType session_info_dock_deserialize (GScanner *scanner,
|
||||
gint scope,
|
||||
GimpSessionInfo *info);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
GimpSessionInfo *
|
||||
gimp_session_info_new (void)
|
||||
{
|
||||
return g_slice_new0 (GimpSessionInfo);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_session_info_free (GimpSessionInfo *info)
|
||||
{
|
||||
|
@ -97,204 +91,7 @@ gimp_session_info_free (GimpSessionInfo *info)
|
|||
g_list_free (info->books);
|
||||
}
|
||||
|
||||
g_free (info);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_session_info_book_free (GimpSessionInfoBook *book)
|
||||
{
|
||||
g_return_if_fail (book != NULL);
|
||||
|
||||
if (book->dockables)
|
||||
{
|
||||
g_list_foreach (book->dockables, (GFunc) gimp_session_info_dockable_free,
|
||||
NULL);
|
||||
g_list_free (book->dockables);
|
||||
}
|
||||
|
||||
g_free (book);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_session_info_dockable_free (GimpSessionInfoDockable *dockable)
|
||||
{
|
||||
g_return_if_fail (dockable != NULL);
|
||||
|
||||
if (dockable->identifier)
|
||||
g_free (dockable->identifier);
|
||||
|
||||
if (dockable->aux_info)
|
||||
{
|
||||
g_list_foreach (dockable->aux_info, (GFunc) gimp_session_info_aux_free,
|
||||
NULL);
|
||||
g_list_free (dockable->aux_info);
|
||||
}
|
||||
|
||||
g_free (dockable);
|
||||
}
|
||||
|
||||
GimpSessionInfoAux *
|
||||
gimp_session_info_aux_new (const gchar *name,
|
||||
const gchar *value)
|
||||
{
|
||||
GimpSessionInfoAux *aux;
|
||||
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
g_return_val_if_fail (value != NULL, NULL);
|
||||
|
||||
aux = g_slice_new0 (GimpSessionInfoAux);
|
||||
|
||||
aux->name = g_strdup (name);
|
||||
aux->value = g_strdup (value);
|
||||
|
||||
return aux;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_session_info_aux_free (GimpSessionInfoAux *aux)
|
||||
{
|
||||
g_return_if_fail (aux != NULL);
|
||||
|
||||
g_free (aux->name);
|
||||
g_free (aux->value);
|
||||
g_slice_free (GimpSessionInfoAux, aux);
|
||||
}
|
||||
|
||||
GList *
|
||||
gimp_session_info_aux_new_from_props (GObject *object,
|
||||
...)
|
||||
{
|
||||
GList *list = NULL;
|
||||
const gchar *prop_name;
|
||||
va_list args;
|
||||
|
||||
g_return_val_if_fail (G_IS_OBJECT (object), NULL);
|
||||
|
||||
va_start (args, object);
|
||||
|
||||
for (prop_name = va_arg (args, const gchar *);
|
||||
prop_name;
|
||||
prop_name = va_arg (args, const gchar *))
|
||||
{
|
||||
GObjectClass *class = G_OBJECT_GET_CLASS (object);
|
||||
GParamSpec *pspec = g_object_class_find_property (class, prop_name);
|
||||
|
||||
if (pspec)
|
||||
{
|
||||
GString *str = g_string_new (NULL);
|
||||
GValue value = { 0, };
|
||||
|
||||
g_value_init (&value, pspec->value_type);
|
||||
g_object_get_property (object, pspec->name, &value);
|
||||
|
||||
if (! g_param_value_defaults (pspec, &value) &&
|
||||
gimp_config_serialize_value (&value, str, TRUE))
|
||||
{
|
||||
list = g_list_prepend (list,
|
||||
gimp_session_info_aux_new (prop_name,
|
||||
str->str));
|
||||
}
|
||||
|
||||
g_value_unset (&value);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("%s: no property named '%s' for %s",
|
||||
G_STRFUNC,
|
||||
prop_name, G_OBJECT_CLASS_NAME (class));
|
||||
}
|
||||
}
|
||||
|
||||
va_end (args);
|
||||
|
||||
return g_list_reverse (list);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_session_info_aux_set_props (GObject *object,
|
||||
GList *auxs,
|
||||
...)
|
||||
{
|
||||
const gchar *prop_name;
|
||||
va_list args;
|
||||
|
||||
g_return_if_fail (G_IS_OBJECT (object));
|
||||
|
||||
va_start (args, auxs);
|
||||
|
||||
for (prop_name = va_arg (args, const gchar *);
|
||||
prop_name;
|
||||
prop_name = va_arg (args, const gchar *))
|
||||
{
|
||||
GList *list;
|
||||
|
||||
for (list = auxs; list; list = g_list_next (list))
|
||||
{
|
||||
GimpSessionInfoAux *aux = list->data;
|
||||
|
||||
if (strcmp (aux->name, prop_name) == 0)
|
||||
{
|
||||
GObjectClass *class = G_OBJECT_GET_CLASS (object);
|
||||
GParamSpec *pspec = g_object_class_find_property (class,
|
||||
prop_name);
|
||||
|
||||
if (pspec)
|
||||
{
|
||||
GValue value = { 0, };
|
||||
|
||||
g_value_init (&value, pspec->value_type);
|
||||
|
||||
if (G_VALUE_HOLDS_ENUM (&value))
|
||||
{
|
||||
GEnumClass *enum_class;
|
||||
GEnumValue *enum_value;
|
||||
|
||||
enum_class = g_type_class_peek (pspec->value_type);
|
||||
enum_value = g_enum_get_value_by_nick (enum_class,
|
||||
aux->value);
|
||||
|
||||
if (enum_value)
|
||||
{
|
||||
g_value_set_enum (&value, enum_value->value);
|
||||
g_object_set_property (object, pspec->name, &value);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("%s: unknown enum value in '%s' for %s",
|
||||
G_STRFUNC,
|
||||
prop_name, G_OBJECT_CLASS_NAME (class));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GValue str_value = { 0, };
|
||||
|
||||
g_value_init (&str_value, G_TYPE_STRING);
|
||||
g_value_set_static_string (&str_value, aux->value);
|
||||
|
||||
if (g_value_transform (&str_value, &value))
|
||||
g_object_set_property (object, pspec->name, &value);
|
||||
else
|
||||
g_warning ("%s: cannot convert property '%s' for %s",
|
||||
G_STRFUNC,
|
||||
prop_name, G_OBJECT_CLASS_NAME (class));
|
||||
|
||||
g_value_unset (&str_value);
|
||||
}
|
||||
|
||||
g_value_unset (&value);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("%s: no property named '%s' for %s",
|
||||
G_STRFUNC,
|
||||
prop_name, G_OBJECT_CLASS_NAME (class));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
va_end (args);
|
||||
g_slice_free (GimpSessionInfo, info);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -302,15 +99,12 @@ gimp_session_info_save (GimpSessionInfo *info,
|
|||
const gchar *factory_name,
|
||||
GimpConfigWriter *writer)
|
||||
{
|
||||
GEnumClass *enum_class;
|
||||
const gchar *dialog_name;
|
||||
|
||||
g_return_if_fail (info != NULL);
|
||||
g_return_if_fail (factory_name != NULL);
|
||||
g_return_if_fail (writer != NULL);
|
||||
|
||||
enum_class = g_type_class_ref (GIMP_TYPE_TAB_STYLE);
|
||||
|
||||
if (info->widget)
|
||||
gimp_session_info_get_geometry (info);
|
||||
|
||||
|
@ -346,152 +140,23 @@ gimp_session_info_save (GimpSessionInfo *info,
|
|||
|
||||
if (info->widget)
|
||||
{
|
||||
info->aux_info = session_info_get_aux_info (info->widget);
|
||||
gimp_session_info_aux_serialize (writer, info->widget);
|
||||
|
||||
if (info->aux_info)
|
||||
if (! info->toplevel_entry)
|
||||
{
|
||||
GList *list;
|
||||
GimpDock *dock = GIMP_DOCK (info->widget);
|
||||
GList *books;
|
||||
|
||||
gimp_config_writer_open (writer, "aux-info");
|
||||
gimp_config_writer_open (writer, "dock");
|
||||
|
||||
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);
|
||||
}
|
||||
for (books = dock->dockbooks; books; books = g_list_next (books))
|
||||
gimp_session_info_book_serialize (writer, books->data);
|
||||
|
||||
gimp_config_writer_close (writer);
|
||||
|
||||
g_list_foreach (info->aux_info, (GFunc) gimp_session_info_aux_free,
|
||||
NULL);
|
||||
g_list_free (info->aux_info);
|
||||
info->aux_info = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (! info->toplevel_entry && info->widget)
|
||||
{
|
||||
GimpDock *dock;
|
||||
GList *books;
|
||||
|
||||
dock = GIMP_DOCK (info->widget);
|
||||
|
||||
gimp_config_writer_open (writer, "dock");
|
||||
|
||||
for (books = dock->dockbooks; books; books = g_list_next (books))
|
||||
{
|
||||
GimpDockbook *dockbook = books->data;
|
||||
GList *children;
|
||||
GList *pages;
|
||||
gint current_page;
|
||||
|
||||
gimp_config_writer_open (writer, "book");
|
||||
|
||||
if (GTK_IS_VPANED (GTK_WIDGET (dockbook)->parent))
|
||||
{
|
||||
GtkPaned *paned = GTK_PANED (GTK_WIDGET (dockbook)->parent);
|
||||
|
||||
if (GTK_WIDGET (dockbook) == paned->child2)
|
||||
{
|
||||
gimp_config_writer_open (writer, "position");
|
||||
gimp_config_writer_printf (writer, "%d",
|
||||
gtk_paned_get_position (paned));
|
||||
gimp_config_writer_close (writer);
|
||||
}
|
||||
}
|
||||
|
||||
current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
|
||||
|
||||
gimp_config_writer_open (writer, "current-page");
|
||||
gimp_config_writer_printf (writer, "%d", current_page);
|
||||
gimp_config_writer_close (writer);
|
||||
|
||||
children = gtk_container_get_children (GTK_CONTAINER (dockbook));
|
||||
|
||||
for (pages = children; pages; pages = g_list_next (pages))
|
||||
{
|
||||
GimpDockable *dockable = pages->data;
|
||||
GimpDialogFactoryEntry *entry;
|
||||
|
||||
gimp_dialog_factory_from_widget (GTK_WIDGET (dockable), &entry);
|
||||
|
||||
if (entry)
|
||||
{
|
||||
GimpContainerView *view;
|
||||
GEnumValue *enum_value;
|
||||
const gchar *tab_style = "icon";
|
||||
gint view_size = -1;
|
||||
GList *aux_info;
|
||||
|
||||
gimp_config_writer_open (writer, "dockable");
|
||||
gimp_config_writer_string (writer, entry->identifier);
|
||||
|
||||
enum_value = g_enum_get_value (enum_class,
|
||||
dockable->tab_style);
|
||||
|
||||
if (enum_value)
|
||||
tab_style = enum_value->value_nick;
|
||||
|
||||
gimp_config_writer_open (writer, "tab-style");
|
||||
gimp_config_writer_print (writer, tab_style, -1);
|
||||
gimp_config_writer_close (writer);
|
||||
|
||||
view = gimp_container_view_get_by_dockable (dockable);
|
||||
|
||||
if (view)
|
||||
view_size = gimp_container_view_get_view_size (view, NULL);
|
||||
|
||||
if (view_size > 0 &&
|
||||
view_size != entry->view_size)
|
||||
{
|
||||
gimp_config_writer_open (writer, "preview-size");
|
||||
gimp_config_writer_printf (writer, "%d", view_size);
|
||||
gimp_config_writer_close (writer);
|
||||
}
|
||||
|
||||
aux_info = session_info_get_aux_info (GTK_WIDGET (dockable));
|
||||
|
||||
if (aux_info)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
gimp_config_writer_open (writer, "aux-info");
|
||||
|
||||
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) gimp_session_info_aux_free,
|
||||
NULL);
|
||||
g_list_free (aux_info);
|
||||
}
|
||||
|
||||
gimp_config_writer_close (writer); /* dockable */
|
||||
}
|
||||
}
|
||||
|
||||
g_list_free (children);
|
||||
|
||||
gimp_config_writer_close (writer); /* book */
|
||||
}
|
||||
|
||||
gimp_config_writer_close (writer); /* dock */
|
||||
}
|
||||
|
||||
gimp_config_writer_close (writer); /* session-info */
|
||||
|
||||
g_type_class_unref (enum_class);
|
||||
}
|
||||
|
||||
GTokenType
|
||||
|
@ -518,23 +183,6 @@ gimp_session_info_deserialize (GScanner *scanner,
|
|||
g_scanner_scope_add_symbol (scanner, scope, "dock",
|
||||
GINT_TO_POINTER (SESSION_INFO_DOCK));
|
||||
|
||||
g_scanner_scope_add_symbol (scanner, SESSION_INFO_DOCK, "book",
|
||||
GINT_TO_POINTER (SESSION_INFO_BOOK));
|
||||
|
||||
g_scanner_scope_add_symbol (scanner, SESSION_INFO_BOOK, "position",
|
||||
GINT_TO_POINTER (SESSION_INFO_BOOK_POSITION));
|
||||
g_scanner_scope_add_symbol (scanner, SESSION_INFO_BOOK, "current-page",
|
||||
GINT_TO_POINTER (SESSION_INFO_BOOK_CURRENT_PAGE));
|
||||
g_scanner_scope_add_symbol (scanner, SESSION_INFO_BOOK, "dockable",
|
||||
GINT_TO_POINTER (SESSION_INFO_DOCKABLE));
|
||||
|
||||
g_scanner_scope_add_symbol (scanner, SESSION_INFO_DOCKABLE, "tab-style",
|
||||
GINT_TO_POINTER (SESSION_INFO_DOCKABLE_TAB_STYLE));
|
||||
g_scanner_scope_add_symbol (scanner, SESSION_INFO_DOCKABLE, "preview-size",
|
||||
GINT_TO_POINTER (SESSION_INFO_DOCKABLE_VIEW_SIZE));
|
||||
g_scanner_scope_add_symbol (scanner, SESSION_INFO_DOCKABLE, "aux-info",
|
||||
GINT_TO_POINTER (SESSION_INFO_DOCKABLE_AUX));
|
||||
|
||||
token = G_TOKEN_STRING;
|
||||
|
||||
if (! gimp_scanner_parse_string (scanner, &factory_name))
|
||||
|
@ -549,7 +197,7 @@ gimp_session_info_deserialize (GScanner *scanner,
|
|||
if (! gimp_scanner_parse_string (scanner, &entry_name))
|
||||
goto error;
|
||||
|
||||
info = g_new0 (GimpSessionInfo, 1);
|
||||
info = gimp_session_info_new ();
|
||||
|
||||
info->screen = DEFAULT_SCREEN;
|
||||
|
||||
|
@ -606,7 +254,8 @@ gimp_session_info_deserialize (GScanner *scanner,
|
|||
break;
|
||||
|
||||
case SESSION_INFO_AUX:
|
||||
token = session_info_aux_deserialize (scanner, &info->aux_info);
|
||||
token = gimp_session_info_aux_deserialize (scanner,
|
||||
&info->aux_info);
|
||||
if (token != G_TOKEN_LEFT_PAREN)
|
||||
goto error;
|
||||
break;
|
||||
|
@ -615,8 +264,8 @@ gimp_session_info_deserialize (GScanner *scanner,
|
|||
if (info->toplevel_entry)
|
||||
goto error;
|
||||
|
||||
g_scanner_set_scope (scanner, SESSION_INFO_DOCK);
|
||||
token = session_info_dock_deserialize (scanner, info);
|
||||
g_scanner_set_scope (scanner, scope + 1);
|
||||
token = session_info_dock_deserialize (scanner, scope + 1, info);
|
||||
|
||||
if (token == G_TOKEN_LEFT_PAREN)
|
||||
g_scanner_set_scope (scanner, scope);
|
||||
|
@ -662,16 +311,6 @@ gimp_session_info_deserialize (GScanner *scanner,
|
|||
g_scanner_scope_remove_symbol (scanner, scope, "aux-info");
|
||||
g_scanner_scope_remove_symbol (scanner, scope, "dock");
|
||||
|
||||
g_scanner_scope_remove_symbol (scanner, SESSION_INFO_DOCK, "book");
|
||||
|
||||
g_scanner_scope_remove_symbol (scanner, SESSION_INFO_BOOK, "position");
|
||||
g_scanner_scope_remove_symbol (scanner, SESSION_INFO_BOOK, "current-page");
|
||||
g_scanner_scope_remove_symbol (scanner, SESSION_INFO_BOOK, "dockable");
|
||||
|
||||
g_scanner_scope_remove_symbol (scanner, SESSION_INFO_DOCKABLE, "tab-style");
|
||||
g_scanner_scope_remove_symbol (scanner, SESSION_INFO_DOCKABLE, "preview-size");
|
||||
g_scanner_scope_remove_symbol (scanner, SESSION_INFO_DOCKABLE, "aux-info");
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
|
@ -732,7 +371,7 @@ gimp_session_info_restore (GimpSessionInfo *info,
|
|||
TRUE);
|
||||
|
||||
if (dialog && info->aux_info)
|
||||
session_info_set_aux_info (dialog, info->aux_info);
|
||||
gimp_session_info_set_aux_info (dialog, info->aux_info);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -742,63 +381,10 @@ gimp_session_info_restore (GimpSessionInfo *info,
|
|||
dock = GIMP_DOCK (gimp_dialog_factory_dock_new (factory, screen));
|
||||
|
||||
if (dock && info->aux_info)
|
||||
session_info_set_aux_info (GTK_WIDGET (dock), info->aux_info);
|
||||
gimp_session_info_set_aux_info (GTK_WIDGET (dock), info->aux_info);
|
||||
|
||||
for (books = info->books; books; books = g_list_next (books))
|
||||
{
|
||||
GimpSessionInfoBook *book_info = books->data;
|
||||
GtkWidget *dockbook;
|
||||
GList *pages;
|
||||
|
||||
dockbook = gimp_dockbook_new (dock->dialog_factory->menu_factory);
|
||||
|
||||
gimp_dock_add_book (dock, GIMP_DOCKBOOK (dockbook), -1);
|
||||
|
||||
book_info->widget = dockbook;
|
||||
|
||||
for (pages = book_info->dockables; pages; pages = g_list_next (pages))
|
||||
{
|
||||
GimpSessionInfoDockable *dockable_info = pages->data;
|
||||
GtkWidget *dockable;
|
||||
|
||||
if (dockable_info->view_size < GIMP_VIEW_SIZE_TINY ||
|
||||
dockable_info->view_size > GIMP_VIEW_SIZE_GIGANTIC)
|
||||
dockable_info->view_size = -1;
|
||||
|
||||
/* use the new dock's dialog factory to create dockables
|
||||
* because it may be different from the dialog factory
|
||||
* the dock was created from.
|
||||
*/
|
||||
dockable =
|
||||
gimp_dialog_factory_dockable_new (dock->dialog_factory,
|
||||
dock,
|
||||
dockable_info->identifier,
|
||||
dockable_info->view_size);
|
||||
|
||||
if (! dockable)
|
||||
continue;
|
||||
|
||||
gimp_dockable_set_tab_style (GIMP_DOCKABLE (dockable),
|
||||
dockable_info->tab_style);
|
||||
|
||||
if (dockable_info->aux_info)
|
||||
session_info_set_aux_info (dockable, dockable_info->aux_info);
|
||||
|
||||
gimp_dockbook_add (GIMP_DOCKBOOK (dockbook),
|
||||
GIMP_DOCKABLE (dockable), -1);
|
||||
}
|
||||
|
||||
if (book_info->current_page <
|
||||
gtk_notebook_get_n_pages (GTK_NOTEBOOK (dockbook)))
|
||||
{
|
||||
gtk_notebook_set_current_page (GTK_NOTEBOOK (dockbook),
|
||||
book_info->current_page);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_notebook_set_current_page (GTK_NOTEBOOK (dockbook), 0);
|
||||
}
|
||||
}
|
||||
gimp_session_info_book_restore (books->data, dock);
|
||||
|
||||
for (books = info->books; books; books = g_list_next (books))
|
||||
{
|
||||
|
@ -990,9 +576,18 @@ gimp_session_info_get_geometry (GimpSessionInfo *info)
|
|||
|
||||
static GTokenType
|
||||
session_info_dock_deserialize (GScanner *scanner,
|
||||
gint scope,
|
||||
GimpSessionInfo *info)
|
||||
{
|
||||
GTokenType token = G_TOKEN_LEFT_PAREN;
|
||||
GTokenType token;
|
||||
|
||||
g_return_val_if_fail (scanner != NULL, G_TOKEN_LEFT_PAREN);
|
||||
g_return_val_if_fail (info != NULL, G_TOKEN_LEFT_PAREN);
|
||||
|
||||
g_scanner_scope_add_symbol (scanner, scope, "book",
|
||||
GINT_TO_POINTER (SESSION_INFO_BOOK));
|
||||
|
||||
token = G_TOKEN_LEFT_PAREN;
|
||||
|
||||
while (g_scanner_peek_next_token (scanner) == token)
|
||||
{
|
||||
|
@ -1008,11 +603,12 @@ session_info_dock_deserialize (GScanner *scanner,
|
|||
switch (GPOINTER_TO_INT (scanner->value.v_symbol))
|
||||
{
|
||||
case SESSION_INFO_BOOK:
|
||||
g_scanner_set_scope (scanner, SESSION_INFO_BOOK);
|
||||
token = session_info_book_deserialize (scanner, info);
|
||||
g_scanner_set_scope (scanner, scope + 1);
|
||||
token = gimp_session_info_book_deserialize (scanner, scope + 1,
|
||||
info);
|
||||
|
||||
if (token == G_TOKEN_LEFT_PAREN)
|
||||
g_scanner_set_scope (scanner, SESSION_INFO_DOCK);
|
||||
g_scanner_set_scope (scanner, scope);
|
||||
else
|
||||
return token;
|
||||
|
||||
|
@ -1033,246 +629,7 @@ session_info_dock_deserialize (GScanner *scanner,
|
|||
}
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
static GTokenType
|
||||
session_info_book_deserialize (GScanner *scanner,
|
||||
GimpSessionInfo *info)
|
||||
{
|
||||
GimpSessionInfoBook *book;
|
||||
GTokenType token;
|
||||
|
||||
book = g_new0 (GimpSessionInfoBook, 1);
|
||||
|
||||
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_SYMBOL;
|
||||
break;
|
||||
|
||||
case G_TOKEN_SYMBOL:
|
||||
switch (GPOINTER_TO_INT (scanner->value.v_symbol))
|
||||
{
|
||||
case SESSION_INFO_BOOK_POSITION:
|
||||
token = G_TOKEN_INT;
|
||||
if (! gimp_scanner_parse_int (scanner, &book->position))
|
||||
goto error;
|
||||
break;
|
||||
|
||||
case SESSION_INFO_BOOK_CURRENT_PAGE:
|
||||
token = G_TOKEN_INT;
|
||||
if (! gimp_scanner_parse_int (scanner, &book->current_page))
|
||||
goto error;
|
||||
break;
|
||||
|
||||
case SESSION_INFO_DOCKABLE:
|
||||
g_scanner_set_scope (scanner, SESSION_INFO_DOCKABLE);
|
||||
token = session_info_dockable_deserialize (scanner, book);
|
||||
|
||||
if (token == G_TOKEN_LEFT_PAREN)
|
||||
g_scanner_set_scope (scanner, SESSION_INFO_BOOK);
|
||||
else
|
||||
goto error;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
goto error;
|
||||
}
|
||||
token = G_TOKEN_RIGHT_PAREN;
|
||||
break;
|
||||
|
||||
case G_TOKEN_RIGHT_PAREN:
|
||||
token = G_TOKEN_LEFT_PAREN;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
info->books = g_list_append (info->books, book);
|
||||
|
||||
return token;
|
||||
|
||||
error:
|
||||
gimp_session_info_book_free (book);
|
||||
g_scanner_scope_remove_symbol (scanner, scope, "book");
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
static GTokenType
|
||||
session_info_dockable_deserialize (GScanner *scanner,
|
||||
GimpSessionInfoBook *book)
|
||||
{
|
||||
GimpSessionInfoDockable *dockable;
|
||||
GEnumClass *enum_class;
|
||||
GEnumValue *enum_value;
|
||||
GTokenType token;
|
||||
|
||||
dockable = g_new0 (GimpSessionInfoDockable, 1);
|
||||
|
||||
enum_class = g_type_class_ref (GIMP_TYPE_TAB_STYLE);
|
||||
|
||||
token = G_TOKEN_STRING;
|
||||
if (! gimp_scanner_parse_string (scanner, &dockable->identifier))
|
||||
goto error;
|
||||
|
||||
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_SYMBOL;
|
||||
break;
|
||||
|
||||
case G_TOKEN_SYMBOL:
|
||||
switch (GPOINTER_TO_INT (scanner->value.v_symbol))
|
||||
{
|
||||
case SESSION_INFO_DOCKABLE_TAB_STYLE:
|
||||
token = G_TOKEN_IDENTIFIER;
|
||||
if (g_scanner_peek_next_token (scanner) != token)
|
||||
goto error;
|
||||
|
||||
g_scanner_get_next_token (scanner);
|
||||
|
||||
enum_value = g_enum_get_value_by_nick (enum_class,
|
||||
scanner->value.v_identifier);
|
||||
|
||||
if (! enum_value)
|
||||
enum_value = g_enum_get_value_by_name (enum_class,
|
||||
scanner->value.v_identifier);
|
||||
|
||||
if (enum_value)
|
||||
dockable->tab_style = enum_value->value;
|
||||
break;
|
||||
|
||||
case SESSION_INFO_DOCKABLE_VIEW_SIZE:
|
||||
token = G_TOKEN_INT;
|
||||
if (! gimp_scanner_parse_int (scanner, &dockable->view_size))
|
||||
goto error;
|
||||
break;
|
||||
|
||||
case SESSION_INFO_DOCKABLE_AUX:
|
||||
token = session_info_aux_deserialize (scanner,
|
||||
&dockable->aux_info);
|
||||
if (token != G_TOKEN_LEFT_PAREN)
|
||||
goto error;
|
||||
break;
|
||||
|
||||
default:
|
||||
goto error;
|
||||
}
|
||||
token = G_TOKEN_RIGHT_PAREN;
|
||||
break;
|
||||
|
||||
case G_TOKEN_RIGHT_PAREN:
|
||||
token = G_TOKEN_LEFT_PAREN;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
book->dockables = g_list_append (book->dockables, dockable);
|
||||
g_type_class_unref (enum_class);
|
||||
|
||||
return token;
|
||||
|
||||
error:
|
||||
gimp_session_info_dockable_free (dockable);
|
||||
g_type_class_unref (enum_class);
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
static GTokenType
|
||||
session_info_aux_deserialize (GScanner *scanner,
|
||||
GList **aux_list)
|
||||
{
|
||||
GimpSessionInfoAux *aux_info = NULL;
|
||||
GTokenType 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_slice_new0 (GimpSessionInfoAux);
|
||||
|
||||
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)
|
||||
{
|
||||
/* FIXME: make the aux-info stuff generic */
|
||||
|
||||
if (GIMP_IS_DOCK (dialog))
|
||||
gimp_dock_set_aux_info (GIMP_DOCK (dialog), aux_info);
|
||||
else if (GIMP_IS_DOCKABLE (dialog))
|
||||
gimp_dockable_set_aux_info (GIMP_DOCKABLE (dialog), aux_info);
|
||||
}
|
||||
|
||||
static GList *
|
||||
session_info_get_aux_info (GtkWidget *dialog)
|
||||
{
|
||||
/* FIXME: make the aux-info stuff generic */
|
||||
|
||||
if (GIMP_IS_DOCK (dialog))
|
||||
return gimp_dock_get_aux_info (GIMP_DOCK (dialog));
|
||||
else if (GIMP_IS_DOCKABLE (dialog))
|
||||
return gimp_dockable_get_aux_info (GIMP_DOCKABLE (dialog));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpsessioninfo.h
|
||||
* Copyright (C) 2001-2003 Michael Natterer <mitch@gimp.org>
|
||||
* Copyright (C) 2001-2007 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* 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
|
||||
|
@ -45,48 +45,10 @@ struct _GimpSessionInfo
|
|||
GList *books;
|
||||
};
|
||||
|
||||
struct _GimpSessionInfoBook
|
||||
{
|
||||
gint position;
|
||||
gint current_page;
|
||||
|
||||
GtkWidget *widget;
|
||||
|
||||
/* list of GimpSessionInfoDockable */
|
||||
GList *dockables;
|
||||
};
|
||||
|
||||
struct _GimpSessionInfoDockable
|
||||
{
|
||||
gchar *identifier;
|
||||
GimpTabStyle tab_style;
|
||||
gint view_size;
|
||||
|
||||
/* dialog specific list of GimpSessionInfoAux */
|
||||
GList *aux_info;
|
||||
};
|
||||
|
||||
struct _GimpSessionInfoAux
|
||||
{
|
||||
gchar *name;
|
||||
gchar *value;
|
||||
};
|
||||
|
||||
|
||||
GimpSessionInfo *
|
||||
gimp_session_info_new (void);
|
||||
void gimp_session_info_free (GimpSessionInfo *info);
|
||||
void gimp_session_info_book_free (GimpSessionInfoBook *book);
|
||||
void gimp_session_info_dockable_free (GimpSessionInfoDockable *dockable);
|
||||
|
||||
GimpSessionInfoAux *
|
||||
gimp_session_info_aux_new (const gchar *name,
|
||||
const gchar *value);
|
||||
void gimp_session_info_aux_free (GimpSessionInfoAux *aux);
|
||||
|
||||
GList * gimp_session_info_aux_new_from_props (GObject *object,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
void gimp_session_info_aux_set_props (GObject *object,
|
||||
GList *aux,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
|
||||
void gimp_session_info_save (GimpSessionInfo *info,
|
||||
const gchar *factory_name,
|
||||
|
@ -100,4 +62,4 @@ void gimp_session_info_set_geometry (GimpSessionInfo *info);
|
|||
void gimp_session_info_get_geometry (GimpSessionInfo *info);
|
||||
|
||||
|
||||
#endif /* __GIMP_SESSION_INFO_H__ */
|
||||
#endif /* __GIMP_SESSION_INFO_H__ */
|
||||
|
|
|
@ -0,0 +1,317 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpsessioninfoaux.c
|
||||
* Copyright (C) 2001-2007 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* 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"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpconfig/gimpconfig.h"
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "gimpdock.h"
|
||||
#include "gimpdockable.h"
|
||||
#include "gimpsessioninfoaux.h"
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
GimpSessionInfoAux *
|
||||
gimp_session_info_aux_new (const gchar *name,
|
||||
const gchar *value)
|
||||
{
|
||||
GimpSessionInfoAux *aux;
|
||||
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
g_return_val_if_fail (value != NULL, NULL);
|
||||
|
||||
aux = g_slice_new0 (GimpSessionInfoAux);
|
||||
|
||||
aux->name = g_strdup (name);
|
||||
aux->value = g_strdup (value);
|
||||
|
||||
return aux;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_session_info_aux_free (GimpSessionInfoAux *aux)
|
||||
{
|
||||
g_return_if_fail (aux != NULL);
|
||||
|
||||
g_free (aux->name);
|
||||
g_free (aux->value);
|
||||
|
||||
g_slice_free (GimpSessionInfoAux, aux);
|
||||
}
|
||||
|
||||
GList *
|
||||
gimp_session_info_aux_new_from_props (GObject *object,
|
||||
...)
|
||||
{
|
||||
GList *list = NULL;
|
||||
const gchar *prop_name;
|
||||
va_list args;
|
||||
|
||||
g_return_val_if_fail (G_IS_OBJECT (object), NULL);
|
||||
|
||||
va_start (args, object);
|
||||
|
||||
for (prop_name = va_arg (args, const gchar *);
|
||||
prop_name;
|
||||
prop_name = va_arg (args, const gchar *))
|
||||
{
|
||||
GObjectClass *class = G_OBJECT_GET_CLASS (object);
|
||||
GParamSpec *pspec = g_object_class_find_property (class, prop_name);
|
||||
|
||||
if (pspec)
|
||||
{
|
||||
GString *str = g_string_new (NULL);
|
||||
GValue value = { 0, };
|
||||
|
||||
g_value_init (&value, pspec->value_type);
|
||||
g_object_get_property (object, pspec->name, &value);
|
||||
|
||||
if (! g_param_value_defaults (pspec, &value) &&
|
||||
gimp_config_serialize_value (&value, str, TRUE))
|
||||
{
|
||||
list = g_list_prepend (list,
|
||||
gimp_session_info_aux_new (prop_name,
|
||||
str->str));
|
||||
}
|
||||
|
||||
g_value_unset (&value);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("%s: no property named '%s' for %s",
|
||||
G_STRFUNC,
|
||||
prop_name, G_OBJECT_CLASS_NAME (class));
|
||||
}
|
||||
}
|
||||
|
||||
va_end (args);
|
||||
|
||||
return g_list_reverse (list);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_session_info_aux_set_props (GObject *object,
|
||||
GList *auxs,
|
||||
...)
|
||||
{
|
||||
const gchar *prop_name;
|
||||
va_list args;
|
||||
|
||||
g_return_if_fail (G_IS_OBJECT (object));
|
||||
|
||||
va_start (args, auxs);
|
||||
|
||||
for (prop_name = va_arg (args, const gchar *);
|
||||
prop_name;
|
||||
prop_name = va_arg (args, const gchar *))
|
||||
{
|
||||
GList *list;
|
||||
|
||||
for (list = auxs; list; list = g_list_next (list))
|
||||
{
|
||||
GimpSessionInfoAux *aux = list->data;
|
||||
|
||||
if (strcmp (aux->name, prop_name) == 0)
|
||||
{
|
||||
GObjectClass *class = G_OBJECT_GET_CLASS (object);
|
||||
GParamSpec *pspec = g_object_class_find_property (class,
|
||||
prop_name);
|
||||
|
||||
if (pspec)
|
||||
{
|
||||
GValue value = { 0, };
|
||||
|
||||
g_value_init (&value, pspec->value_type);
|
||||
|
||||
if (G_VALUE_HOLDS_ENUM (&value))
|
||||
{
|
||||
GEnumClass *enum_class;
|
||||
GEnumValue *enum_value;
|
||||
|
||||
enum_class = g_type_class_peek (pspec->value_type);
|
||||
enum_value = g_enum_get_value_by_nick (enum_class,
|
||||
aux->value);
|
||||
|
||||
if (enum_value)
|
||||
{
|
||||
g_value_set_enum (&value, enum_value->value);
|
||||
g_object_set_property (object, pspec->name, &value);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("%s: unknown enum value in '%s' for %s",
|
||||
G_STRFUNC,
|
||||
prop_name, G_OBJECT_CLASS_NAME (class));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GValue str_value = { 0, };
|
||||
|
||||
g_value_init (&str_value, G_TYPE_STRING);
|
||||
g_value_set_static_string (&str_value, aux->value);
|
||||
|
||||
if (g_value_transform (&str_value, &value))
|
||||
g_object_set_property (object, pspec->name, &value);
|
||||
else
|
||||
g_warning ("%s: cannot convert property '%s' for %s",
|
||||
G_STRFUNC,
|
||||
prop_name, G_OBJECT_CLASS_NAME (class));
|
||||
|
||||
g_value_unset (&str_value);
|
||||
}
|
||||
|
||||
g_value_unset (&value);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("%s: no property named '%s' for %s",
|
||||
G_STRFUNC,
|
||||
prop_name, G_OBJECT_CLASS_NAME (class));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_session_info_aux_serialize (GimpConfigWriter *writer,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GList *aux_info;
|
||||
|
||||
g_return_if_fail (writer != NULL);
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
aux_info = gimp_session_info_get_aux_info (widget);
|
||||
|
||||
if (aux_info)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
gimp_config_writer_open (writer, "aux-info");
|
||||
|
||||
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) gimp_session_info_aux_free, NULL);
|
||||
g_list_free (aux_info);
|
||||
}
|
||||
}
|
||||
|
||||
GTokenType
|
||||
gimp_session_info_aux_deserialize (GScanner *scanner,
|
||||
GList **aux_list)
|
||||
{
|
||||
GimpSessionInfoAux *aux_info = NULL;
|
||||
GTokenType token = G_TOKEN_LEFT_PAREN;
|
||||
|
||||
g_return_val_if_fail (scanner != NULL, G_TOKEN_LEFT_PAREN);
|
||||
g_return_val_if_fail (aux_list != NULL, 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_slice_new0 (GimpSessionInfoAux);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_session_info_set_aux_info (GtkWidget *dialog,
|
||||
GList *aux_info)
|
||||
{
|
||||
/* FIXME: make the aux-info stuff generic */
|
||||
|
||||
if (GIMP_IS_DOCK (dialog))
|
||||
gimp_dock_set_aux_info (GIMP_DOCK (dialog), aux_info);
|
||||
else if (GIMP_IS_DOCKABLE (dialog))
|
||||
gimp_dockable_set_aux_info (GIMP_DOCKABLE (dialog), aux_info);
|
||||
}
|
||||
|
||||
GList *
|
||||
gimp_session_info_get_aux_info (GtkWidget *dialog)
|
||||
{
|
||||
/* FIXME: make the aux-info stuff generic */
|
||||
|
||||
if (GIMP_IS_DOCK (dialog))
|
||||
return gimp_dock_get_aux_info (GIMP_DOCK (dialog));
|
||||
else if (GIMP_IS_DOCKABLE (dialog))
|
||||
return gimp_dockable_get_aux_info (GIMP_DOCKABLE (dialog));
|
||||
|
||||
return NULL;
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpsessioninfoaux.h
|
||||
* Copyright (C) 2001-2007 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_SESSION_INFO_AUX_H__
|
||||
#define __GIMP_SESSION_INFO_AUX_H__
|
||||
|
||||
|
||||
struct _GimpSessionInfoAux
|
||||
{
|
||||
gchar *name;
|
||||
gchar *value;
|
||||
};
|
||||
|
||||
|
||||
GimpSessionInfoAux *
|
||||
gimp_session_info_aux_new (const gchar *name,
|
||||
const gchar *value);
|
||||
void gimp_session_info_aux_free (GimpSessionInfoAux *aux);
|
||||
|
||||
GList * gimp_session_info_aux_new_from_props (GObject *object,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
void gimp_session_info_aux_set_props (GObject *object,
|
||||
GList *aux,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
|
||||
void gimp_session_info_aux_serialize (GimpConfigWriter *writer,
|
||||
GtkWidget *widget);
|
||||
GTokenType gimp_session_info_aux_deserialize (GScanner *scanner,
|
||||
GList **aux_list);
|
||||
|
||||
void gimp_session_info_set_aux_info (GtkWidget *dialog,
|
||||
GList *aux_info);
|
||||
GList * gimp_session_info_get_aux_info (GtkWidget *dialog);
|
||||
|
||||
|
||||
#endif /* __GIMP_SESSION_INFO_AUX_H__ */
|
|
@ -0,0 +1,237 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpsessioninfobook.c
|
||||
* Copyright (C) 2001-2007 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* 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"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpconfig/gimpconfig.h"
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "gimpdialogfactory.h"
|
||||
#include "gimpdock.h"
|
||||
#include "gimpdockbook.h"
|
||||
#include "gimpsessioninfo.h"
|
||||
#include "gimpsessioninfobook.h"
|
||||
#include "gimpsessioninfodockable.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
SESSION_INFO_BOOK_POSITION,
|
||||
SESSION_INFO_BOOK_CURRENT_PAGE,
|
||||
SESSION_INFO_BOOK_DOCKABLE
|
||||
};
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
GimpSessionInfoBook *
|
||||
gimp_session_info_book_new (void)
|
||||
{
|
||||
return g_slice_new0 (GimpSessionInfoBook);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_session_info_book_free (GimpSessionInfoBook *book)
|
||||
{
|
||||
g_return_if_fail (book != NULL);
|
||||
|
||||
if (book->dockables)
|
||||
{
|
||||
g_list_foreach (book->dockables, (GFunc) gimp_session_info_dockable_free,
|
||||
NULL);
|
||||
g_list_free (book->dockables);
|
||||
}
|
||||
|
||||
g_slice_free (GimpSessionInfoBook, book);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_session_info_book_serialize (GimpConfigWriter *writer,
|
||||
GimpDockbook *dockbook)
|
||||
{
|
||||
GList *children;
|
||||
GList *pages;
|
||||
gint current_page;
|
||||
|
||||
g_return_if_fail (writer != NULL);
|
||||
g_return_if_fail (GIMP_IS_DOCKBOOK (dockbook));
|
||||
|
||||
gimp_config_writer_open (writer, "book");
|
||||
|
||||
if (GTK_IS_VPANED (GTK_WIDGET (dockbook)->parent))
|
||||
{
|
||||
GtkPaned *paned = GTK_PANED (GTK_WIDGET (dockbook)->parent);
|
||||
|
||||
if (GTK_WIDGET (dockbook) == paned->child2)
|
||||
{
|
||||
gimp_config_writer_open (writer, "position");
|
||||
gimp_config_writer_printf (writer, "%d",
|
||||
gtk_paned_get_position (paned));
|
||||
gimp_config_writer_close (writer);
|
||||
}
|
||||
}
|
||||
|
||||
current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
|
||||
|
||||
gimp_config_writer_open (writer, "current-page");
|
||||
gimp_config_writer_printf (writer, "%d", current_page);
|
||||
gimp_config_writer_close (writer);
|
||||
|
||||
children = gtk_container_get_children (GTK_CONTAINER (dockbook));
|
||||
|
||||
for (pages = children; pages; pages = g_list_next (pages))
|
||||
gimp_session_info_dockable_serialize (writer, pages->data);
|
||||
|
||||
g_list_free (children);
|
||||
|
||||
gimp_config_writer_close (writer);
|
||||
}
|
||||
|
||||
GTokenType
|
||||
gimp_session_info_book_deserialize (GScanner *scanner,
|
||||
gint scope,
|
||||
GimpSessionInfo *info)
|
||||
{
|
||||
GimpSessionInfoBook *book;
|
||||
GTokenType token;
|
||||
|
||||
g_return_val_if_fail (scanner != NULL, G_TOKEN_LEFT_PAREN);
|
||||
g_return_val_if_fail (info != NULL, G_TOKEN_LEFT_PAREN);
|
||||
|
||||
g_scanner_scope_add_symbol (scanner, scope, "position",
|
||||
GINT_TO_POINTER (SESSION_INFO_BOOK_POSITION));
|
||||
g_scanner_scope_add_symbol (scanner, scope, "current-page",
|
||||
GINT_TO_POINTER (SESSION_INFO_BOOK_CURRENT_PAGE));
|
||||
g_scanner_scope_add_symbol (scanner, scope, "dockable",
|
||||
GINT_TO_POINTER (SESSION_INFO_BOOK_DOCKABLE));
|
||||
|
||||
book = gimp_session_info_book_new ();
|
||||
|
||||
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_SYMBOL;
|
||||
break;
|
||||
|
||||
case G_TOKEN_SYMBOL:
|
||||
switch (GPOINTER_TO_INT (scanner->value.v_symbol))
|
||||
{
|
||||
case SESSION_INFO_BOOK_POSITION:
|
||||
token = G_TOKEN_INT;
|
||||
if (! gimp_scanner_parse_int (scanner, &book->position))
|
||||
goto error;
|
||||
break;
|
||||
|
||||
case SESSION_INFO_BOOK_CURRENT_PAGE:
|
||||
token = G_TOKEN_INT;
|
||||
if (! gimp_scanner_parse_int (scanner, &book->current_page))
|
||||
goto error;
|
||||
break;
|
||||
|
||||
case SESSION_INFO_BOOK_DOCKABLE:
|
||||
g_scanner_set_scope (scanner, scope + 1);
|
||||
token = gimp_session_info_dockable_deserialize (scanner,
|
||||
scope + 1,
|
||||
book);
|
||||
|
||||
if (token == G_TOKEN_LEFT_PAREN)
|
||||
g_scanner_set_scope (scanner, scope);
|
||||
else
|
||||
goto error;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
goto error;
|
||||
}
|
||||
token = G_TOKEN_RIGHT_PAREN;
|
||||
break;
|
||||
|
||||
case G_TOKEN_RIGHT_PAREN:
|
||||
token = G_TOKEN_LEFT_PAREN;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
info->books = g_list_append (info->books, book);
|
||||
|
||||
g_scanner_scope_remove_symbol (scanner, scope, "position");
|
||||
g_scanner_scope_remove_symbol (scanner, scope, "current-page");
|
||||
g_scanner_scope_remove_symbol (scanner, scope, "dockable");
|
||||
|
||||
return token;
|
||||
|
||||
error:
|
||||
gimp_session_info_book_free (book);
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_session_info_book_restore (GimpSessionInfoBook *info,
|
||||
GimpDock *dock)
|
||||
{
|
||||
GtkWidget *dockbook;
|
||||
GList *pages;
|
||||
|
||||
g_return_if_fail (info != NULL);
|
||||
g_return_if_fail (GIMP_IS_DOCK (dock));
|
||||
|
||||
dockbook = gimp_dockbook_new (dock->dialog_factory->menu_factory);
|
||||
|
||||
gimp_dock_add_book (dock, GIMP_DOCKBOOK (dockbook), -1);
|
||||
|
||||
info->widget = dockbook;
|
||||
|
||||
for (pages = info->dockables; pages; pages = g_list_next (pages))
|
||||
{
|
||||
GimpSessionInfoDockable *dockable_info = pages->data;
|
||||
GimpDockable *dockable;
|
||||
|
||||
dockable = gimp_session_info_dockable_restore (dockable_info, dock);
|
||||
|
||||
if (dockable)
|
||||
gimp_dockbook_add (GIMP_DOCKBOOK (dockbook), dockable, -1);
|
||||
}
|
||||
|
||||
if (info->current_page <
|
||||
gtk_notebook_get_n_pages (GTK_NOTEBOOK (dockbook)))
|
||||
{
|
||||
gtk_notebook_set_current_page (GTK_NOTEBOOK (dockbook),
|
||||
info->current_page);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_notebook_set_current_page (GTK_NOTEBOOK (dockbook), 0);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpsessioninfobook.h
|
||||
* Copyright (C) 2001-2007 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_SESSION_INFO_BOOK_H__
|
||||
#define __GIMP_SESSION_INFO_BOOK_H__
|
||||
|
||||
|
||||
struct _GimpSessionInfoBook
|
||||
{
|
||||
gint position;
|
||||
gint current_page;
|
||||
|
||||
GtkWidget *widget;
|
||||
|
||||
/* list of GimpSessionInfoDockable */
|
||||
GList *dockables;
|
||||
};
|
||||
|
||||
|
||||
GimpSessionInfoBook *
|
||||
gimp_session_info_book_new (void);
|
||||
void gimp_session_info_book_free (GimpSessionInfoBook *book);
|
||||
|
||||
void gimp_session_info_book_serialize (GimpConfigWriter *writer,
|
||||
GimpDockbook *dockbook);
|
||||
GTokenType gimp_session_info_book_deserialize (GScanner *scanner,
|
||||
gint scope,
|
||||
GimpSessionInfo *info);
|
||||
|
||||
void gimp_session_info_book_restore (GimpSessionInfoBook *info,
|
||||
GimpDock *dock);
|
||||
|
||||
|
||||
#endif /* __GIMP_SESSION_INFO_BOOK_H__ */
|
|
@ -0,0 +1,264 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpsessioninfodockable.c
|
||||
* Copyright (C) 2001-2007 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* 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"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpconfig/gimpconfig.h"
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "gimpcontainerview.h"
|
||||
#include "gimpcontainerview-utils.h"
|
||||
#include "gimpdialogfactory.h"
|
||||
#include "gimpdock.h"
|
||||
#include "gimpdockable.h"
|
||||
#include "gimpsessioninfoaux.h"
|
||||
#include "gimpsessioninfobook.h"
|
||||
#include "gimpsessioninfodockable.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
SESSION_INFO_DOCKABLE_TAB_STYLE,
|
||||
SESSION_INFO_DOCKABLE_VIEW_SIZE,
|
||||
SESSION_INFO_DOCKABLE_AUX
|
||||
};
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
GimpSessionInfoDockable *
|
||||
gimp_session_info_dockable_new (void)
|
||||
{
|
||||
return g_slice_new0 (GimpSessionInfoDockable);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_session_info_dockable_free (GimpSessionInfoDockable *dockable)
|
||||
{
|
||||
g_return_if_fail (dockable != NULL);
|
||||
|
||||
if (dockable->identifier)
|
||||
g_free (dockable->identifier);
|
||||
|
||||
if (dockable->aux_info)
|
||||
{
|
||||
g_list_foreach (dockable->aux_info, (GFunc) gimp_session_info_aux_free,
|
||||
NULL);
|
||||
g_list_free (dockable->aux_info);
|
||||
}
|
||||
|
||||
g_slice_free (GimpSessionInfoDockable, dockable);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_session_info_dockable_serialize (GimpConfigWriter *writer,
|
||||
GimpDockable *dockable)
|
||||
{
|
||||
GimpDialogFactoryEntry *entry;
|
||||
|
||||
g_return_if_fail (writer != NULL);
|
||||
g_return_if_fail (GIMP_IS_DOCKABLE (dockable));
|
||||
|
||||
gimp_dialog_factory_from_widget (GTK_WIDGET (dockable), &entry);
|
||||
|
||||
if (entry)
|
||||
{
|
||||
GimpContainerView *view;
|
||||
GEnumClass *enum_class;
|
||||
GEnumValue *enum_value;
|
||||
const gchar *tab_style = "icon";
|
||||
gint view_size = -1;
|
||||
|
||||
enum_class = g_type_class_ref (GIMP_TYPE_TAB_STYLE);
|
||||
|
||||
gimp_config_writer_open (writer, "dockable");
|
||||
gimp_config_writer_string (writer, entry->identifier);
|
||||
|
||||
enum_value = g_enum_get_value (enum_class, dockable->tab_style);
|
||||
|
||||
if (enum_value)
|
||||
tab_style = enum_value->value_nick;
|
||||
|
||||
gimp_config_writer_open (writer, "tab-style");
|
||||
gimp_config_writer_print (writer, tab_style, -1);
|
||||
gimp_config_writer_close (writer);
|
||||
|
||||
view = gimp_container_view_get_by_dockable (dockable);
|
||||
|
||||
if (view)
|
||||
view_size = gimp_container_view_get_view_size (view, NULL);
|
||||
|
||||
if (view_size > 0 &&
|
||||
view_size != entry->view_size)
|
||||
{
|
||||
gimp_config_writer_open (writer, "preview-size");
|
||||
gimp_config_writer_printf (writer, "%d", view_size);
|
||||
gimp_config_writer_close (writer);
|
||||
}
|
||||
|
||||
gimp_session_info_aux_serialize (writer, GTK_WIDGET (dockable));
|
||||
|
||||
gimp_config_writer_close (writer);
|
||||
|
||||
g_type_class_unref (enum_class);
|
||||
}
|
||||
}
|
||||
|
||||
GTokenType
|
||||
gimp_session_info_dockable_deserialize (GScanner *scanner,
|
||||
gint scope,
|
||||
GimpSessionInfoBook *book)
|
||||
{
|
||||
GimpSessionInfoDockable *dockable;
|
||||
GEnumClass *enum_class;
|
||||
GEnumValue *enum_value;
|
||||
GTokenType token;
|
||||
|
||||
g_return_val_if_fail (scanner != NULL, G_TOKEN_LEFT_PAREN);
|
||||
g_return_val_if_fail (book != NULL, G_TOKEN_LEFT_PAREN);
|
||||
|
||||
g_scanner_scope_add_symbol (scanner, scope, "tab-style",
|
||||
GINT_TO_POINTER (SESSION_INFO_DOCKABLE_TAB_STYLE));
|
||||
g_scanner_scope_add_symbol (scanner, scope, "preview-size",
|
||||
GINT_TO_POINTER (SESSION_INFO_DOCKABLE_VIEW_SIZE));
|
||||
g_scanner_scope_add_symbol (scanner, scope, "aux-info",
|
||||
GINT_TO_POINTER (SESSION_INFO_DOCKABLE_AUX));
|
||||
|
||||
dockable = gimp_session_info_dockable_new ();
|
||||
|
||||
enum_class = g_type_class_ref (GIMP_TYPE_TAB_STYLE);
|
||||
|
||||
token = G_TOKEN_STRING;
|
||||
if (! gimp_scanner_parse_string (scanner, &dockable->identifier))
|
||||
goto error;
|
||||
|
||||
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_SYMBOL;
|
||||
break;
|
||||
|
||||
case G_TOKEN_SYMBOL:
|
||||
switch (GPOINTER_TO_INT (scanner->value.v_symbol))
|
||||
{
|
||||
case SESSION_INFO_DOCKABLE_TAB_STYLE:
|
||||
token = G_TOKEN_IDENTIFIER;
|
||||
if (g_scanner_peek_next_token (scanner) != token)
|
||||
goto error;
|
||||
|
||||
g_scanner_get_next_token (scanner);
|
||||
|
||||
enum_value = g_enum_get_value_by_nick (enum_class,
|
||||
scanner->value.v_identifier);
|
||||
|
||||
if (! enum_value)
|
||||
enum_value = g_enum_get_value_by_name (enum_class,
|
||||
scanner->value.v_identifier);
|
||||
|
||||
if (enum_value)
|
||||
dockable->tab_style = enum_value->value;
|
||||
break;
|
||||
|
||||
case SESSION_INFO_DOCKABLE_VIEW_SIZE:
|
||||
token = G_TOKEN_INT;
|
||||
if (! gimp_scanner_parse_int (scanner, &dockable->view_size))
|
||||
goto error;
|
||||
break;
|
||||
|
||||
case SESSION_INFO_DOCKABLE_AUX:
|
||||
token = gimp_session_info_aux_deserialize (scanner,
|
||||
&dockable->aux_info);
|
||||
if (token != G_TOKEN_LEFT_PAREN)
|
||||
goto error;
|
||||
break;
|
||||
|
||||
default:
|
||||
goto error;
|
||||
}
|
||||
token = G_TOKEN_RIGHT_PAREN;
|
||||
break;
|
||||
|
||||
case G_TOKEN_RIGHT_PAREN:
|
||||
token = G_TOKEN_LEFT_PAREN;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
book->dockables = g_list_append (book->dockables, dockable);
|
||||
g_type_class_unref (enum_class);
|
||||
|
||||
g_scanner_scope_remove_symbol (scanner, scope, "tab-style");
|
||||
g_scanner_scope_remove_symbol (scanner, scope, "preview-size");
|
||||
g_scanner_scope_remove_symbol (scanner, scope, "aux-info");
|
||||
|
||||
return token;
|
||||
|
||||
error:
|
||||
gimp_session_info_dockable_free (dockable);
|
||||
g_type_class_unref (enum_class);
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
GimpDockable *
|
||||
gimp_session_info_dockable_restore (GimpSessionInfoDockable *info,
|
||||
GimpDock *dock)
|
||||
{
|
||||
GtkWidget *dockable;
|
||||
|
||||
g_return_val_if_fail (info != NULL, NULL);
|
||||
g_return_val_if_fail (GIMP_IS_DOCK (dock), NULL);
|
||||
|
||||
if (info->view_size < GIMP_VIEW_SIZE_TINY ||
|
||||
info->view_size > GIMP_VIEW_SIZE_GIGANTIC)
|
||||
info->view_size = -1;
|
||||
|
||||
/* use the new dock's dialog factory to create dockables
|
||||
* because it may be different from the dialog factory
|
||||
* the dock was created from.
|
||||
*/
|
||||
dockable = gimp_dialog_factory_dockable_new (dock->dialog_factory,
|
||||
dock,
|
||||
info->identifier,
|
||||
info->view_size);
|
||||
|
||||
if (dockable)
|
||||
{
|
||||
gimp_dockable_set_tab_style (GIMP_DOCKABLE (dockable), info->tab_style);
|
||||
|
||||
if (info->aux_info)
|
||||
gimp_session_info_set_aux_info (dockable, info->aux_info);
|
||||
}
|
||||
|
||||
return GIMP_DOCKABLE (dockable);
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpsessioninfodockable.h
|
||||
* Copyright (C) 2001-2007 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_SESSION_INFO_DOCKABLE_H__
|
||||
#define __GIMP_SESSION_INFO_DOCKABLE_H__
|
||||
|
||||
|
||||
struct _GimpSessionInfoDockable
|
||||
{
|
||||
gchar *identifier;
|
||||
GimpTabStyle tab_style;
|
||||
gint view_size;
|
||||
|
||||
/* dialog specific list of GimpSessionInfoAux */
|
||||
GList *aux_info;
|
||||
};
|
||||
|
||||
|
||||
GimpSessionInfoDockable *
|
||||
gimp_session_info_dockable_new (void);
|
||||
void gimp_session_info_dockable_free (GimpSessionInfoDockable *dockable);
|
||||
|
||||
void gimp_session_info_dockable_serialize (GimpConfigWriter *writer,
|
||||
GimpDockable *dockable);
|
||||
GTokenType gimp_session_info_dockable_deserialize (GScanner *scanner,
|
||||
gint scope,
|
||||
GimpSessionInfoBook *book);
|
||||
|
||||
GimpDockable * gimp_session_info_dockable_restore (GimpSessionInfoDockable *info,
|
||||
GimpDock *dock);
|
||||
|
||||
|
||||
#endif /* __GIMP_SESSION_INFO_DOCKABLE_H__ */
|
Loading…
Reference in New Issue