removed more code and cleaned up the API.
2007-05-24 Michael Natterer <mitch@gimp.org> * app/widgets/gimpsessioninfo.[ch]: removed more code and cleaned up the API. * app/widgets/Makefile.am * app/widgets/gimpsessioninfodock.[ch]: added the removed code here. * app/widgets/gimpdialogfactory.c: changed accordingly. svn path=/trunk/; revision=22604
This commit is contained in:

committed by
Michael Natterer

parent
616ba659f3
commit
2bf21338a3
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
2007-05-24 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/widgets/gimpsessioninfo.[ch]: removed more code and cleaned
|
||||
up the API.
|
||||
|
||||
* app/widgets/Makefile.am
|
||||
* app/widgets/gimpsessioninfodock.[ch]: added the removed code here.
|
||||
|
||||
* app/widgets/gimpdialogfactory.c: changed accordingly.
|
||||
|
||||
2007-05-24 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/widgets/gimpsessioninfo.[ch]: removed lots of code...
|
||||
|
@ -232,6 +232,8 @@ libappwidgets_a_sources = \
|
||||
gimpsessioninfoaux.h \
|
||||
gimpsessioninfobook.c \
|
||||
gimpsessioninfobook.h \
|
||||
gimpsessioninfodock.c \
|
||||
gimpsessioninfodock.h \
|
||||
gimpsessioninfodockable.c \
|
||||
gimpsessioninfodockable.h \
|
||||
gimpsizebox.c \
|
||||
|
@ -1278,7 +1278,7 @@ gimp_dialog_factories_save_foreach (gconstpointer key,
|
||||
(info->toplevel_entry && ! info->toplevel_entry->session_managed))
|
||||
continue;
|
||||
|
||||
gimp_session_info_save (info, GIMP_OBJECT (factory)->name, writer);
|
||||
gimp_session_info_serialize (writer, info, GIMP_OBJECT (factory)->name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,17 +29,12 @@
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "gimpcontainerview.h"
|
||||
#include "gimpcontainerview-utils.h"
|
||||
#include "gimpdialogfactory.h"
|
||||
#include "gimpdock.h"
|
||||
#include "gimpdockable.h"
|
||||
#include "gimpdockbook.h"
|
||||
#include "gimpdocked.h"
|
||||
#include "gimpsessioninfo.h"
|
||||
#include "gimpsessioninfoaux.h"
|
||||
#include "gimpsessioninfobook.h"
|
||||
#include "gimpsessioninfodockable.h"
|
||||
#include "gimpsessioninfodock.h"
|
||||
|
||||
|
||||
enum
|
||||
@ -48,22 +43,12 @@ enum
|
||||
SESSION_INFO_SIZE,
|
||||
SESSION_INFO_OPEN,
|
||||
SESSION_INFO_AUX,
|
||||
|
||||
SESSION_INFO_DOCK,
|
||||
|
||||
SESSION_INFO_BOOK
|
||||
SESSION_INFO_DOCK
|
||||
};
|
||||
|
||||
#define DEFAULT_SCREEN -1
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static GTokenType session_info_dock_deserialize (GScanner *scanner,
|
||||
gint scope,
|
||||
GimpSessionInfo *info);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
GimpSessionInfo *
|
||||
@ -95,9 +80,9 @@ gimp_session_info_free (GimpSessionInfo *info)
|
||||
}
|
||||
|
||||
void
|
||||
gimp_session_info_save (GimpSessionInfo *info,
|
||||
const gchar *factory_name,
|
||||
GimpConfigWriter *writer)
|
||||
gimp_session_info_serialize (GimpConfigWriter *writer,
|
||||
GimpSessionInfo *info,
|
||||
const gchar *factory_name)
|
||||
{
|
||||
const gchar *dialog_name;
|
||||
|
||||
@ -143,17 +128,7 @@ gimp_session_info_save (GimpSessionInfo *info,
|
||||
gimp_session_info_aux_serialize (writer, info->widget);
|
||||
|
||||
if (! info->toplevel_entry)
|
||||
{
|
||||
GimpDock *dock = GIMP_DOCK (info->widget);
|
||||
GList *books;
|
||||
|
||||
gimp_config_writer_open (writer, "dock");
|
||||
|
||||
for (books = dock->dockbooks; books; books = g_list_next (books))
|
||||
gimp_session_info_book_serialize (writer, books->data);
|
||||
|
||||
gimp_config_writer_close (writer);
|
||||
}
|
||||
gimp_session_info_dock_serialize (writer, GIMP_DOCK (info->widget));
|
||||
}
|
||||
|
||||
gimp_config_writer_close (writer); /* session-info */
|
||||
@ -265,7 +240,8 @@ gimp_session_info_deserialize (GScanner *scanner,
|
||||
goto error;
|
||||
|
||||
g_scanner_set_scope (scanner, scope + 1);
|
||||
token = session_info_dock_deserialize (scanner, scope + 1, info);
|
||||
token = gimp_session_info_dock_deserialize (scanner, scope + 1,
|
||||
info);
|
||||
|
||||
if (token == G_TOKEN_LEFT_PAREN)
|
||||
g_scanner_set_scope (scanner, scope);
|
||||
@ -314,31 +290,6 @@ gimp_session_info_deserialize (GScanner *scanner,
|
||||
return token;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_session_info_paned_size_allocate (GtkWidget *paned,
|
||||
GtkAllocation *allocation,
|
||||
gpointer data)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (paned,
|
||||
gimp_session_info_paned_size_allocate,
|
||||
data);
|
||||
|
||||
gtk_paned_set_position (GTK_PANED (paned), GPOINTER_TO_INT (data));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_session_info_paned_map (GtkWidget *paned,
|
||||
gpointer data)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (paned,
|
||||
gimp_session_info_paned_map,
|
||||
data);
|
||||
|
||||
g_signal_connect_after (paned, "size-allocate",
|
||||
G_CALLBACK (gimp_session_info_paned_size_allocate),
|
||||
data);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_session_info_restore (GimpSessionInfo *info,
|
||||
GimpDialogFactory *factory)
|
||||
@ -375,38 +326,7 @@ gimp_session_info_restore (GimpSessionInfo *info,
|
||||
}
|
||||
else
|
||||
{
|
||||
GimpDock *dock;
|
||||
GList *books;
|
||||
|
||||
dock = GIMP_DOCK (gimp_dialog_factory_dock_new (factory, screen));
|
||||
|
||||
if (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))
|
||||
gimp_session_info_book_restore (books->data, dock);
|
||||
|
||||
for (books = info->books; books; books = g_list_next (books))
|
||||
{
|
||||
GimpSessionInfoBook *book_info = books->data;
|
||||
GtkWidget *dockbook = book_info->widget;
|
||||
|
||||
if (GTK_IS_VPANED (dockbook->parent))
|
||||
{
|
||||
GtkPaned *paned = GTK_PANED (dockbook->parent);
|
||||
|
||||
if (dockbook == paned->child2)
|
||||
g_signal_connect_after (paned, "map",
|
||||
G_CALLBACK (gimp_session_info_paned_map),
|
||||
GINT_TO_POINTER (book_info->position));
|
||||
}
|
||||
}
|
||||
|
||||
g_list_foreach (info->books, (GFunc) gimp_session_info_book_free, NULL);
|
||||
g_list_free (info->books);
|
||||
info->books = NULL;
|
||||
|
||||
gtk_widget_show (GTK_WIDGET (dock));
|
||||
gimp_session_info_dock_restore (info, factory, screen);
|
||||
}
|
||||
|
||||
g_list_foreach (info->aux_info, (GFunc) gimp_session_info_aux_free, NULL);
|
||||
@ -570,66 +490,3 @@ gimp_session_info_get_geometry (GimpSessionInfo *info)
|
||||
info->screen = gdk_screen_get_number (screen);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static GTokenType
|
||||
session_info_dock_deserialize (GScanner *scanner,
|
||||
gint scope,
|
||||
GimpSessionInfo *info)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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:
|
||||
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, scope);
|
||||
else
|
||||
return token;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
return token;
|
||||
}
|
||||
token = G_TOKEN_RIGHT_PAREN;
|
||||
break;
|
||||
|
||||
case G_TOKEN_RIGHT_PAREN:
|
||||
token = G_TOKEN_LEFT_PAREN;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
g_scanner_scope_remove_symbol (scanner, scope, "book");
|
||||
|
||||
return token;
|
||||
}
|
||||
|
@ -46,15 +46,15 @@ struct _GimpSessionInfo
|
||||
};
|
||||
|
||||
|
||||
GimpSessionInfo *
|
||||
gimp_session_info_new (void);
|
||||
GimpSessionInfo * gimp_session_info_new (void);
|
||||
void gimp_session_info_free (GimpSessionInfo *info);
|
||||
|
||||
void gimp_session_info_save (GimpSessionInfo *info,
|
||||
const gchar *factory_name,
|
||||
GimpConfigWriter *writer);
|
||||
void gimp_session_info_serialize (GimpConfigWriter *writer,
|
||||
GimpSessionInfo *info,
|
||||
const gchar *factory_name);
|
||||
GTokenType gimp_session_info_deserialize (GScanner *scanner,
|
||||
gint old_scope);
|
||||
gint scope);
|
||||
|
||||
void gimp_session_info_restore (GimpSessionInfo *info,
|
||||
GimpDialogFactory *factory);
|
||||
|
||||
|
189
app/widgets/gimpsessioninfodock.c
Normal file
189
app/widgets/gimpsessioninfodock.c
Normal file
@ -0,0 +1,189 @@
|
||||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpsessioninfodock.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 "gimpsessioninfo.h"
|
||||
#include "gimpsessioninfoaux.h"
|
||||
#include "gimpsessioninfobook.h"
|
||||
#include "gimpsessioninfodock.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
SESSION_INFO_BOOK
|
||||
};
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
void
|
||||
gimp_session_info_dock_serialize (GimpConfigWriter *writer,
|
||||
GimpDock *dock)
|
||||
{
|
||||
GList *books;
|
||||
|
||||
g_return_if_fail (writer != NULL);
|
||||
g_return_if_fail (GIMP_IS_DOCK (dock));
|
||||
|
||||
gimp_config_writer_open (writer, "dock");
|
||||
|
||||
for (books = dock->dockbooks; books; books = g_list_next (books))
|
||||
gimp_session_info_book_serialize (writer, books->data);
|
||||
|
||||
gimp_config_writer_close (writer);
|
||||
}
|
||||
|
||||
GTokenType
|
||||
gimp_session_info_dock_deserialize (GScanner *scanner,
|
||||
gint scope,
|
||||
GimpSessionInfo *info)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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:
|
||||
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, scope);
|
||||
else
|
||||
return token;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
return token;
|
||||
}
|
||||
token = G_TOKEN_RIGHT_PAREN;
|
||||
break;
|
||||
|
||||
case G_TOKEN_RIGHT_PAREN:
|
||||
token = G_TOKEN_LEFT_PAREN;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
g_scanner_scope_remove_symbol (scanner, scope, "book");
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_session_info_dock_paned_size_allocate (GtkWidget *paned,
|
||||
GtkAllocation *allocation,
|
||||
gpointer data)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (paned,
|
||||
gimp_session_info_dock_paned_size_allocate,
|
||||
data);
|
||||
|
||||
gtk_paned_set_position (GTK_PANED (paned), GPOINTER_TO_INT (data));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_session_info_dock_paned_map (GtkWidget *paned,
|
||||
gpointer data)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (paned,
|
||||
gimp_session_info_dock_paned_map,
|
||||
data);
|
||||
|
||||
g_signal_connect_after (paned, "size-allocate",
|
||||
G_CALLBACK (gimp_session_info_dock_paned_size_allocate),
|
||||
data);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_session_info_dock_restore (GimpSessionInfo *info,
|
||||
GimpDialogFactory *factory,
|
||||
GdkScreen *screen)
|
||||
{
|
||||
GimpDock *dock;
|
||||
GList *books;
|
||||
|
||||
g_return_if_fail (info != NULL);
|
||||
g_return_if_fail (GIMP_IS_DIALOG_FACTORY (factory));
|
||||
g_return_if_fail (GDK_IS_SCREEN (screen));
|
||||
|
||||
dock = GIMP_DOCK (gimp_dialog_factory_dock_new (factory, screen));
|
||||
|
||||
if (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))
|
||||
gimp_session_info_book_restore (books->data, dock);
|
||||
|
||||
for (books = info->books; books; books = g_list_next (books))
|
||||
{
|
||||
GimpSessionInfoBook *book_info = books->data;
|
||||
GtkWidget *dockbook = book_info->widget;
|
||||
|
||||
if (GTK_IS_VPANED (dockbook->parent))
|
||||
{
|
||||
GtkPaned *paned = GTK_PANED (dockbook->parent);
|
||||
|
||||
if (dockbook == paned->child2)
|
||||
g_signal_connect_after (paned, "map",
|
||||
G_CALLBACK (gimp_session_info_dock_paned_map),
|
||||
GINT_TO_POINTER (book_info->position));
|
||||
}
|
||||
}
|
||||
|
||||
g_list_foreach (info->books, (GFunc) gimp_session_info_book_free, NULL);
|
||||
g_list_free (info->books);
|
||||
info->books = NULL;
|
||||
|
||||
gtk_widget_show (GTK_WIDGET (dock));
|
||||
}
|
37
app/widgets/gimpsessioninfodock.h
Normal file
37
app/widgets/gimpsessioninfodock.h
Normal file
@ -0,0 +1,37 @@
|
||||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpsessioninfodock.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_DOCK_H__
|
||||
#define __GIMP_SESSION_INFO_DOCK_H__
|
||||
|
||||
|
||||
void gimp_session_info_dock_serialize (GimpConfigWriter *writer,
|
||||
GimpDock *dock);
|
||||
GTokenType gimp_session_info_dock_deserialize (GScanner *scanner,
|
||||
gint scope,
|
||||
GimpSessionInfo *info);
|
||||
|
||||
void gimp_session_info_dock_restore (GimpSessionInfo *info,
|
||||
GimpDialogFactory *factory,
|
||||
GdkScreen *screen);
|
||||
|
||||
|
||||
#endif /* __GIMP_SESSION_INFO_DOCK_H__ */
|
Reference in New Issue
Block a user