Commit 059e7773 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

First attempt to get the docks session managed:

2001-04-16  Michael Natterer  <mitch@gimp.org>

	First attempt to get the docks session managed:

	* app/gimprc.c: new gimprc type "new-session-info" which will soon
	replace the original one.

	* app/menus.c
	* app/gui/dialogs.c: s/_/-/g in all dialog identifier strings.

	* app/session.[ch]: call the dialog factory's session functions.

	* app/test_commands.c: use the dialog factory to create the tabs.

	* app/gui/dialogs-commands.c
	* app/gui/dialogs-constructors.[ch]: the constructors return widgets,
	not dockables now.

	* app/widgets/gimpdialogfactory.[ch]: maintain a list of dialog
	factories in the class struct. Added ugly code to do the GimpDock
	session management.

	* app/gui/gui.c
	* app/widgets/gimpdock.c: changed accordingly.
parent f0d16f69
2001-04-16 Michael Natterer <mitch@gimp.org>
First attempt to get the docks session managed:
* app/gimprc.c: new gimprc type "new-session-info" which will soon
replace the original one.
* app/menus.c
* app/gui/dialogs.c: s/_/-/g in all dialog identifier strings.
* app/session.[ch]: call the dialog factory's session functions.
* app/test_commands.c: use the dialog factory to create the tabs.
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.[ch]: the constructors return widgets,
not dockables now.
* app/widgets/gimpdialogfactory.[ch]: maintain a list of dialog
factories in the class struct. Added ugly code to do the GimpDock
session management.
* app/gui/gui.c
* app/widgets/gimpdock.c: changed accordingly.
2001-04-15 Michael Natterer <mitch@gimp.org>
* app/gui/Makefile.am: new files:
......
......@@ -24,6 +24,7 @@
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpdock.h"
#include "widgets/gimpdockable.h"
#include "widgets/gimpdockbook.h"
#include "dialogs-commands.h"
......@@ -40,13 +41,13 @@ dialogs_add_tab_cmd_callback (GtkWidget *widget,
if (dockbook && action)
{
GimpDockable *dockable;
GtkWidget *dockable;
dockable = gimp_dialog_factory_dialog_new (dockbook->dock->factory,
GUINT_TO_POINTER (action));
if (dockable)
gimp_dockbook_add (dockbook, dockable, -1);
gimp_dockbook_add (dockbook, GIMP_DOCKABLE (dockable), -1);
}
}
......
......@@ -46,28 +46,28 @@
#include "libgimp/gimpintl.h"
static GtkWidget * dialogs_brush_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
static GtkWidget * dialogs_pattern_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
static GtkWidget * dialogs_gradient_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
static GtkWidget * dialogs_palette_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
static GimpDockable * dialogs_dockable_new (GtkWidget *widget,
const gchar *name,
const gchar *short_name,
GimpDockableGetTabFunc get_tab_func);
static GtkWidget * dialogs_brush_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
static GtkWidget * dialogs_pattern_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
static GtkWidget * dialogs_gradient_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
static GtkWidget * dialogs_palette_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
static GtkWidget * dialogs_dockable_new (GtkWidget *widget,
const gchar *name,
const gchar *short_name,
GimpDockableGetTabFunc get_tab_func);
/* public functions */
GimpDockable *
GtkWidget *
dialogs_image_list_view_new (GimpDialogFactory *factory)
{
GtkWidget *view;
......@@ -82,7 +82,7 @@ dialogs_image_list_view_new (GimpDialogFactory *factory)
NULL);
}
GimpDockable *
GtkWidget *
dialogs_brush_list_view_new (GimpDialogFactory *factory)
{
GtkWidget *view;
......@@ -99,7 +99,7 @@ dialogs_brush_list_view_new (GimpDialogFactory *factory)
dialogs_brush_tab_func);
}
GimpDockable *
GtkWidget *
dialogs_pattern_list_view_new (GimpDialogFactory *factory)
{
GtkWidget *view;
......@@ -116,7 +116,7 @@ dialogs_pattern_list_view_new (GimpDialogFactory *factory)
dialogs_pattern_tab_func);
}
GimpDockable *
GtkWidget *
dialogs_gradient_list_view_new (GimpDialogFactory *factory)
{
GtkWidget *view;
......@@ -133,7 +133,7 @@ dialogs_gradient_list_view_new (GimpDialogFactory *factory)
dialogs_gradient_tab_func);
}
GimpDockable *
GtkWidget *
dialogs_palette_list_view_new (GimpDialogFactory *factory)
{
GtkWidget *view;
......@@ -150,7 +150,7 @@ dialogs_palette_list_view_new (GimpDialogFactory *factory)
dialogs_palette_tab_func);
}
GimpDockable *
GtkWidget *
dialogs_tool_list_view_new (GimpDialogFactory *factory)
{
GtkWidget *view;
......@@ -168,7 +168,7 @@ dialogs_tool_list_view_new (GimpDialogFactory *factory)
/* grid views */
GimpDockable *
GtkWidget *
dialogs_image_grid_view_new (GimpDialogFactory *factory)
{
GtkWidget *view;
......@@ -183,7 +183,7 @@ dialogs_image_grid_view_new (GimpDialogFactory *factory)
NULL);
}
GimpDockable *
GtkWidget *
dialogs_brush_grid_view_new (GimpDialogFactory *factory)
{
GtkWidget *view;
......@@ -200,7 +200,7 @@ dialogs_brush_grid_view_new (GimpDialogFactory *factory)
dialogs_brush_tab_func);
}
GimpDockable *
GtkWidget *
dialogs_pattern_grid_view_new (GimpDialogFactory *factory)
{
GtkWidget *view;
......@@ -217,7 +217,7 @@ dialogs_pattern_grid_view_new (GimpDialogFactory *factory)
dialogs_pattern_tab_func);
}
GimpDockable *
GtkWidget *
dialogs_gradient_grid_view_new (GimpDialogFactory *factory)
{
GtkWidget *view;
......@@ -234,7 +234,7 @@ dialogs_gradient_grid_view_new (GimpDialogFactory *factory)
dialogs_gradient_tab_func);
}
GimpDockable *
GtkWidget *
dialogs_palette_grid_view_new (GimpDialogFactory *factory)
{
GtkWidget *view;
......@@ -251,7 +251,7 @@ dialogs_palette_grid_view_new (GimpDialogFactory *factory)
dialogs_palette_tab_func);
}
GimpDockable *
GtkWidget *
dialogs_tool_grid_view_new (GimpDialogFactory *factory)
{
GtkWidget *view;
......@@ -365,7 +365,7 @@ dialogs_palette_tab_func (GimpDockable *dockable,
return preview;
}
GimpDockable *
GtkWidget *
dialogs_dockable_new (GtkWidget *widget,
const gchar *name,
const gchar *short_name,
......@@ -380,5 +380,5 @@ dialogs_dockable_new (GtkWidget *widget,
gtk_container_add (GTK_CONTAINER (dockable), widget);
gtk_widget_show (widget);
return GIMP_DOCKABLE (dockable);
return dockable;
}
......@@ -20,19 +20,19 @@
#define __DIALOGS_CONSTRUCTORS_H__
GimpDockable * dialogs_image_list_view_new (GimpDialogFactory *factory);
GimpDockable * dialogs_brush_list_view_new (GimpDialogFactory *factory);
GimpDockable * dialogs_pattern_list_view_new (GimpDialogFactory *factory);
GimpDockable * dialogs_gradient_list_view_new (GimpDialogFactory *factory);
GimpDockable * dialogs_palette_list_view_new (GimpDialogFactory *factory);
GimpDockable * dialogs_tool_list_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_image_list_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_brush_list_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_pattern_list_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_gradient_list_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_palette_list_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_tool_list_view_new (GimpDialogFactory *factory);
GimpDockable * dialogs_image_grid_view_new (GimpDialogFactory *factory);
GimpDockable * dialogs_brush_grid_view_new (GimpDialogFactory *factory);
GimpDockable * dialogs_pattern_grid_view_new (GimpDialogFactory *factory);
GimpDockable * dialogs_gradient_grid_view_new (GimpDialogFactory *factory);
GimpDockable * dialogs_palette_grid_view_new (GimpDialogFactory *factory);
GimpDockable * dialogs_tool_grid_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_image_grid_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_brush_grid_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_pattern_grid_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_gradient_grid_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_palette_grid_view_new (GimpDialogFactory *factory);
GtkWidget * dialogs_tool_grid_view_new (GimpDialogFactory *factory);
#endif /* __DIALOGS_CONSTRUCTORS_H__ */
......@@ -31,54 +31,76 @@
#include "gimpcontext.h"
GimpDialogFactory *global_dialog_factory = NULL;
GimpDialogFactory *global_dialog_factory = NULL;
GimpDialogFactory *global_dock_factory = NULL;
GimpDialogFactory *global_image_dock_factory = NULL;
void
dialogs_register (void)
dialogs_init (void)
{
GtkItemFactory *item_factory;
global_dialog_factory =
gimp_dialog_factory_new ("toplevel",
gimp_context_get_user (),
NULL);
item_factory = menus_get_dialogs_factory ();
global_dock_factory =
gimp_dialog_factory_new ("dock",
gimp_context_get_user (),
menus_get_dialogs_factory ());
global_dialog_factory = gimp_dialog_factory_new (gimp_context_get_user (),
item_factory);
global_image_dock_factory =
gimp_dialog_factory_new ("image-dock",
gimp_context_get_user (),
NULL);
gimp_dialog_factory_register (global_dialog_factory,
"gimp:image_list",
gimp_dialog_factory_register (global_dock_factory,
"gimp:image-list",
dialogs_image_list_view_new);
gimp_dialog_factory_register (global_dialog_factory,
"gimp:brush_list",
gimp_dialog_factory_register (global_dock_factory,
"gimp:brush-list",
dialogs_brush_list_view_new);
gimp_dialog_factory_register (global_dialog_factory,
"gimp:pattern_list",
gimp_dialog_factory_register (global_dock_factory,
"gimp:pattern-list",
dialogs_pattern_list_view_new);
gimp_dialog_factory_register (global_dialog_factory,
"gimp:gradient_list",
gimp_dialog_factory_register (global_dock_factory,
"gimp:gradient-list",
dialogs_gradient_list_view_new);
gimp_dialog_factory_register (global_dialog_factory,
"gimp:palette_list",
gimp_dialog_factory_register (global_dock_factory,
"gimp:palette-list",
dialogs_palette_list_view_new);
gimp_dialog_factory_register (global_dialog_factory,
"gimp:tool_list",
gimp_dialog_factory_register (global_dock_factory,
"gimp:tool-list",
dialogs_tool_list_view_new);
gimp_dialog_factory_register (global_dialog_factory,
"gimp:image_grid",
gimp_dialog_factory_register (global_dock_factory,
"gimp:image-grid",
dialogs_image_grid_view_new);
gimp_dialog_factory_register (global_dialog_factory,
"gimp:brush_grid",
gimp_dialog_factory_register (global_dock_factory,
"gimp:brush-grid",
dialogs_brush_grid_view_new);
gimp_dialog_factory_register (global_dialog_factory,
"gimp:pattern_grid",
gimp_dialog_factory_register (global_dock_factory,
"gimp:pattern-grid",
dialogs_pattern_grid_view_new);
gimp_dialog_factory_register (global_dialog_factory,
"gimp:gradient_grid",
gimp_dialog_factory_register (global_dock_factory,
"gimp:gradient-grid",
dialogs_gradient_grid_view_new);
gimp_dialog_factory_register (global_dialog_factory,
"gimp:palette_grid",
gimp_dialog_factory_register (global_dock_factory,
"gimp:palette-grid",
dialogs_palette_grid_view_new);
gimp_dialog_factory_register (global_dialog_factory,
"gimp:tool_grid",
gimp_dialog_factory_register (global_dock_factory,
"gimp:tool-grid",
dialogs_tool_grid_view_new);
}
void
dialogs_exit (void)
{
gtk_object_unref (GTK_OBJECT (global_dialog_factory));
gtk_object_unref (GTK_OBJECT (global_dock_factory));
gtk_object_unref (GTK_OBJECT (global_image_dock_factory));
global_dialog_factory = NULL;
global_dock_factory = NULL;
global_image_dock_factory = NULL;
}
......@@ -21,9 +21,12 @@
extern GimpDialogFactory *global_dialog_factory;
extern GimpDialogFactory *global_dock_factory;
extern GimpDialogFactory *global_image_dock_factory;
void dialogs_register (void);
void dialogs_init (void);
void dialogs_exit (void);
#endif /* __DIALOGS_H__ */
......@@ -40,6 +40,8 @@
#include "tools/gimptool.h"
#include "tools/gimptoolinfo.h"
#include "widgets/gimpdialogfactory.h"
#include "app_procs.h"
#include "appenv.h"
#include "color_notebook.h"
......@@ -92,6 +94,7 @@ typedef enum
TT_XMENUPATH,
TT_XDEVICE,
TT_XSESSIONINFO,
TT_XNEWSESSIONINFO,
TT_XCOLORHISTORY,
TT_XUNITINFO,
TT_XPARASITE,
......@@ -143,6 +146,7 @@ static gint parse_plug_in_def (gpointer val1p, gpointer val2p)
static gint parse_device (gpointer val1p, gpointer val2p);
static gint parse_menu_path (gpointer val1p, gpointer val2p);
static gint parse_session_info (gpointer val1p, gpointer val2p);
static gint parse_new_session_info (gpointer val1p, gpointer val2p);
static gint parse_unit_info (gpointer val1p, gpointer val2p);
static gint parse_parasite (gpointer val1p, gpointer val2p);
static gint parse_help_browser (gpointer val1p, gpointer val2p);
......@@ -327,6 +331,7 @@ static ParseFunc funcs[] =
{ "menu-path", TT_XMENUPATH, NULL, NULL },
{ "device", TT_XDEVICE, NULL, NULL },
{ "session-info", TT_XSESSIONINFO, NULL, NULL },
{ "new-session-info", TT_XNEWSESSIONINFO, NULL, NULL },
{ "color-history", TT_XCOLORHISTORY, NULL, NULL },
{ "unit-info", TT_XUNITINFO, NULL, NULL },
{ "monitor-xresolution", TT_DOUBLE, &monitor_xres, NULL },
......@@ -357,24 +362,6 @@ static gint n_funcs = (sizeof (funcs) /
sizeof (funcs[0]));
static SessionInfo *session_infos[] =
{
&toolbox_session_info,
&lc_dialog_session_info,
&info_dialog_session_info,
&tool_options_session_info,
&palette_session_info,
&brush_select_session_info,
&pattern_select_session_info,
&gradient_select_session_info,
&device_status_session_info,
&error_console_session_info,
&document_index_session_info
};
static gint n_session_infos = (sizeof (session_infos) /
sizeof (session_infos[0]));
static ParseInfo parse_info = { NULL };
static GList *unknown_tokens = NULL;
......@@ -907,6 +894,8 @@ parse_statement (void)
return parse_device (funcs[i].val1p, funcs[i].val2p);
case TT_XSESSIONINFO:
return parse_session_info (funcs[i].val1p, funcs[i].val2p);
case TT_XNEWSESSIONINFO:
return parse_new_session_info (funcs[i].val1p, funcs[i].val2p);
case TT_XCOLORHISTORY:
return parse_color_history (funcs[i].val1p, funcs[i].val2p);
case TT_XUNITINFO:
......@@ -2336,6 +2325,24 @@ parse_session_info (gpointer val1p,
gint token;
SessionInfo *info = NULL;
static SessionInfo *session_infos[] =
{
&toolbox_session_info,
&lc_dialog_session_info,
&info_dialog_session_info,
&tool_options_session_info,
&palette_session_info,
&brush_select_session_info,
&pattern_select_session_info,
&gradient_select_session_info,
&device_status_session_info,
&error_console_session_info,
&document_index_session_info
};
static gint n_session_infos = (sizeof (session_infos) /
sizeof (session_infos[0]));
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
return ERROR;
......@@ -2409,6 +2416,124 @@ parse_session_info (gpointer val1p,
return OK;
}
static gint
parse_new_session_info (gpointer val1p,
gpointer val2p)
{
gint token;
GimpDialogFactory *factory;
GimpSessionInfo *info = NULL;
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
factory = gimp_dialog_factory_from_name (token_str);
if (! factory)
goto error;
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
goto error;
token = get_next_token ();
info = g_new0 (GimpSessionInfo, 1);
/* Parse options for session info */
while (peek_next_token () == TOKEN_LEFT_PAREN)
{
token = get_next_token ();
token = peek_next_token ();
if (!token || (token != TOKEN_SYMBOL))
goto error;
token = get_next_token ();
if (!strcmp ("position", token_sym))
{
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
goto error;
token = get_next_token ();
info->x = token_int;
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
goto error;
token = get_next_token ();
info->y = token_int;
}
else if (!strcmp ("size", token_sym))
{
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
goto error;
token = get_next_token ();
info->width = token_int;
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
goto error;
token = get_next_token ();
info->height = token_int;
}
else if (!strcmp ("open-on-exit", token_sym))
{
info->open = TRUE;
}
else if (!strcmp ("dock", token_sym))
{
while (peek_next_token () == TOKEN_LEFT_PAREN)
{
token = get_next_token ();
info->sub_dialogs = g_list_prepend (info->sub_dialogs, NULL);
while (peek_next_token () == TOKEN_STRING)
{
token = get_next_token ();
info->sub_dialogs->data =
g_list_append (info->sub_dialogs->data,
g_strdup (token_str));
}
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
goto error;
token = get_next_token ();
}
info->sub_dialogs = g_list_reverse (info->sub_dialogs);
}
else
{
goto error;
}
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
goto error;
token = get_next_token ();
}
if (!token || (token != TOKEN_RIGHT_PAREN))
goto error;
token = get_next_token ();
factory->session_infos = g_list_append (factory->session_infos, info);
return OK;
error:
g_free (info);
return ERROR;
}
static gint
parse_color_history (gpointer val1p,
gpointer val2p)
......@@ -2750,6 +2875,7 @@ value_to_str (gchar *name)
case TT_XMENUPATH:
case TT_XDEVICE:
case TT_XSESSIONINFO:
case TT_XNEWSESSIONINFO:
case TT_XCOLORHISTORY:
case TT_XUNITINFO:
case TT_XPARASITE:
......
......@@ -24,6 +24,7 @@
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpdock.h"
#include "widgets/gimpdockable.h"
#include "widgets/gimpdockbook.h"
#include "dialogs-commands.h"
......@@ -40,13 +41,13 @@ dialogs_add_tab_cmd_callback (GtkWidget *widget,
if (dockbook && action)
{
GimpDockable *dockable;
GtkWidget *dockable;
dockable = gimp_dialog_factory_dialog_new (dockbook->dock->factory,
GUINT_TO_POINTER (action));
if (dockable)
gimp_dockbook_add (dockbook, dockable, -1);
gimp_dockbook_add (dockbook, GIMP_DOCKABLE (dockable), -1);
}
}
......
......@@ -46,28 +46,28 @@
#include "libgimp/gimpintl.h"
static GtkWidget * dialogs_brush_tab_func (GimpDockable *dockable,
GimpDockbook *dockbook,
gint size);
static GtkWidget * dialogs_pattern_tab_func (GimpDockable *dockable,