Commit d16b3aba authored by Sven Neumann's avatar Sven Neumann
Browse files

Rough outline of session-managment. A new config

file 'sessionrc' is written and the position of some windows is
remembered. Still has some problems (offset by wm decorations).
Can be switched off in the preferences.
parent db79dc64
Mon Jun 22 18:43:22 MEST 1998 Sven Neumann <sven@gimp.org>
* app/Makefile.am
* app/app_procs.c
* app/brush_select.c
* app/gimprc.[ch]
* app/gradient.c
* app/info_dialog.c
* app/interface.c
* app/layers_dialog.c
* app/palette.c
* app/pattern_select.c
* app/preferences_dialog.c
* app/session.[ch] (new files)
* app/tools.c: Rough outline of session-managment. A new config
file 'sessionrc' is written and the position of some windows is
remembered. Still has some problems (offset by wm decorations).
Can be switched off in the preferences.
Sun Jun 21 15:16:46 CDT 1998 Larry Ewing <lewing@gimp.org>
* app/bezier_select.c
......
......@@ -242,6 +242,8 @@ gimp_SOURCES = \
scroll.h \
selection.c \
selection.h \
session.h \
session.c \
shear_tool.c \
shear_tool.h \
temp_buf.c \
......
......@@ -50,6 +50,7 @@
#include "patterns.h"
#include "plug_in.h"
#include "procedural_db.h"
#include "session.h"
#include "temp_buf.h"
#include "tile_swap.h"
#include "tips_dialog.h"
......@@ -513,6 +514,7 @@ app_init (void)
{
get_standard_colormaps ();
devices_init ();
session_init ();
create_toolbox ();
gximage_init ();
render_setup (transparency_type, transparency_size);
......@@ -528,20 +530,6 @@ app_init (void)
}
void
app_save_window_positions (void)
{
GList *update = NULL; /* options that should be updated in .gimprc */
GList *remove = NULL; /* options that should be commented out */
update = g_list_append (update, "toolbox-position");
update = g_list_append (update, "lc-dialog-position");
save_gimprc (&update, &remove);
g_list_free (update);
g_list_free (remove);
}
int
app_exit_finish_done (void)
{
......@@ -566,6 +554,7 @@ app_exit_finish (void)
patterns_free ();
palettes_free ();
gradients_free ();
grad_free_gradient_editor ();
hue_saturation_free ();
curves_free ();
levels_free ();
......@@ -584,11 +573,9 @@ app_exit_finish (void)
gximage_free ();
render_free ();
tools_options_dialog_free ();
if (save_window_positions_on_exit)
{
app_save_window_positions();
}
save_sessionrc ();
}
/* gtk_exit (0); */
gtk_main_quit();
}
......
......@@ -27,6 +27,7 @@
#include "disp_callbacks.h"
#include "errors.h"
#include "paint_funcs.h"
#include "session.h"
#define STD_CELL_WIDTH 24
......@@ -141,6 +142,7 @@ brush_select_new ()
bsp->shell = gtk_dialog_new ();
gtk_window_set_wmclass (GTK_WINDOW (bsp->shell), "brushselection", "Gimp");
gtk_window_set_title (GTK_WINDOW (bsp->shell), "Brush Selection");
session_set_window_geometry (bsp->shell, &brush_select_geometry, TRUE);
gtk_window_set_policy(GTK_WINDOW(bsp->shell), FALSE, TRUE, FALSE);
vbox = gtk_vbox_new (FALSE, 1);
gtk_container_border_width (GTK_CONTAINER (vbox), 2);
......@@ -313,6 +315,7 @@ brush_select_free (BrushSelectP bsp)
{
if (bsp)
{
session_get_window_geometry (bsp->shell, &brush_select_geometry);
if (bsp->brush_popup != NULL)
gtk_widget_destroy (bsp->brush_popup);
g_free (bsp);
......
......@@ -21,6 +21,7 @@
#include "gimprc.h"
#include "info_dialog.h"
#include "interface.h"
#include "session.h"
/* static functions */
static InfoField * info_field_new (InfoDialog *, char *, char *);
......@@ -85,7 +86,7 @@ info_dialog_new (char *title)
shell = gtk_dialog_new ();
gtk_window_set_wmclass (GTK_WINDOW (shell), "info_dialog", "Gimp");
gtk_window_set_title (GTK_WINDOW (shell), title);
gtk_widget_set_uposition (shell, info_x, info_y);
session_set_window_geometry (shell, &info_dialog_geometry, FALSE );
gtk_signal_connect (GTK_OBJECT (shell), "delete_event",
GTK_SIGNAL_FUNC (info_dialog_delete_callback),
......@@ -139,6 +140,8 @@ info_dialog_free (InfoDialog *idialog)
/* Free the actual field linked list */
g_slist_free (idialog->field_list);
session_get_window_geometry (idialog->shell, &info_dialog_geometry);
/* Destroy the associated widgets */
gtk_widget_destroy (idialog->shell);
......
......@@ -43,6 +43,7 @@
#include "posterize.h"
#include "resize.h"
#include "scale.h"
#include "session.h"
#include "threshold.h"
#include "tips_dialog.h"
#include "tools.h"
......@@ -66,6 +67,7 @@ static void file_prefs_text_callback (GtkWidget *, gpointer);
static void file_prefs_spinbutton_callback (GtkWidget *, gpointer);
static void file_prefs_preview_size_callback (GtkWidget *, gpointer);
static void file_prefs_mem_size_unit_callback (GtkWidget *, gpointer);
static void file_prefs_clear_window_positions_callback (GtkWidget *, gpointer);
/* static variables */
static int last_type = RGB;
......@@ -287,8 +289,8 @@ file_prefs_save_callback (GtkWidget *widget,
update = g_list_append (update, "cubic-interpolation");
if (confirm_on_close != old_confirm_on_close)
update = g_list_append (update, "confirm-on-close");
if (confirm_on_close != old_confirm_on_close)
update = g_list_append (update, "save_window_positions_on_exit");
if (save_window_positions_on_exit != old_save_window_positions_on_exit)
update = g_list_append (update, "save-window-positions-on-exit");
if (default_width != old_default_width ||
default_height != old_default_height)
update = g_list_append (update, "default-image-size");
......@@ -456,25 +458,27 @@ file_prefs_toggle_callback (GtkWidget *widget,
{
int *val;
if (data==&allow_resize_windows)
if (data == &allow_resize_windows)
allow_resize_windows = GTK_TOGGLE_BUTTON (widget)->active;
else if (data==&auto_save)
else if (data == &auto_save)
auto_save = GTK_TOGGLE_BUTTON (widget)->active;
else if (data==&no_cursor_updating)
else if (data == &no_cursor_updating)
no_cursor_updating = GTK_TOGGLE_BUTTON (widget)->active;
else if (data==&show_tool_tips)
else if (data == &show_tool_tips)
show_tool_tips = GTK_TOGGLE_BUTTON (widget)->active;
else if (data==&cubic_interpolation)
else if (data == &cubic_interpolation)
cubic_interpolation = GTK_TOGGLE_BUTTON (widget)->active;
else if (data==&confirm_on_close)
else if (data == &confirm_on_close)
confirm_on_close = GTK_TOGGLE_BUTTON (widget)->active;
else if (data==&edit_stingy_memory_use)
else if (data == &save_window_positions_on_exit)
save_window_positions_on_exit = GTK_TOGGLE_BUTTON (widget)->active;
else if (data == &edit_stingy_memory_use)
edit_stingy_memory_use = GTK_TOGGLE_BUTTON (widget)->active;
else if (data==&edit_install_cmap)
else if (data == &edit_install_cmap)
edit_install_cmap = GTK_TOGGLE_BUTTON (widget)->active;
else if (data==&edit_cycled_marching_ants)
else if (data == &edit_cycled_marching_ants)
edit_cycled_marching_ants = GTK_TOGGLE_BUTTON (widget)->active;
else if (data==&default_type)
else if (data == &default_type)
{
default_type = (long) gtk_object_get_user_data (GTK_OBJECT (widget));
}
......@@ -545,6 +549,13 @@ file_prefs_string_callback (GtkWidget *widget,
file_prefs_strset (val, gtk_entry_get_text (GTK_ENTRY (widget)));
}
static void
file_prefs_clear_window_positions_callback (GtkWidget *widget,
gpointer data)
{
session_geometry_updates = NULL;
}
void
file_pref_cmd_callback (GtkWidget *widget,
gpointer client_data)
......@@ -988,15 +999,6 @@ file_pref_cmd_callback (GtkWidget *widget,
&show_tool_tips);
gtk_widget_show (button);
button = gtk_check_button_new_with_label("Save window positions on exit");
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button),
save_window_positions_on_exit);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "toggled",
(GtkSignalFunc) file_prefs_toggle_callback,
&save_window_positions_on_exit);
gtk_widget_show (button);
hbox = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
......@@ -1105,6 +1107,43 @@ file_pref_cmd_callback (GtkWidget *widget,
label = gtk_label_new ("Environment");
gtk_notebook_append_page (GTK_NOTEBOOK(notebook), out_frame, label);
/* Session Management */
out_frame = gtk_frame_new ("Session managment");
gtk_container_border_width (GTK_CONTAINER (out_frame), 10);
gtk_widget_set_usize (out_frame, 320, 200);
gtk_widget_show (out_frame);
vbox = gtk_vbox_new (FALSE, 2);
gtk_container_border_width (GTK_CONTAINER (vbox), 1);
gtk_container_add (GTK_CONTAINER (out_frame), vbox);
gtk_widget_show (vbox);
button = gtk_check_button_new_with_label ("Save window positions on exit");
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button),
save_window_positions_on_exit);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "toggled",
(GtkSignalFunc) file_prefs_toggle_callback,
&save_window_positions_on_exit);
gtk_widget_show (button);
hbox = gtk_hbox_new (FALSE, 2);
gtk_container_border_width (GTK_CONTAINER (hbox), 4);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
button = gtk_button_new_with_label ("Clear saved window positions");
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) file_prefs_clear_window_positions_callback,
NULL);
gtk_widget_show (button);
label = gtk_label_new ("Session");
gtk_notebook_append_page (GTK_NOTEBOOK(notebook), out_frame, label);
gtk_widget_show (notebook);
/* Directories */
out_frame = gtk_frame_new ("Directories settings");
gtk_container_border_width (GTK_CONTAINER (out_frame), 10);
......
......@@ -33,6 +33,7 @@
#include "general.h"
#include "interface.h"
#include "menus.h"
#include "session.h"
#include "tools.h"
#include "pixmaps.h"
......@@ -444,7 +445,7 @@ create_toolbox ()
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_wmclass (GTK_WINDOW (window), "toolbox", "Gimp");
gtk_window_set_title (GTK_WINDOW (window), "The GIMP");
gtk_widget_set_uposition (window, toolbox_x, toolbox_y);
session_set_window_geometry (window, &toolbox_geometry, TRUE);
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
GTK_SIGNAL_FUNC (toolbox_delete),
NULL);
......@@ -522,7 +523,8 @@ toolbox_free ()
{
int i;
gdk_window_get_position (toolbox_shell->window, &toolbox_x, &toolbox_y);
session_get_window_geometry (toolbox_shell, &toolbox_geometry);
gtk_widget_destroy (toolbox_shell);
for (i = 0; i < num_tools; i++)
{
......
......@@ -33,6 +33,7 @@
#include "general.h"
#include "interface.h"
#include "menus.h"
#include "session.h"
#include "tools.h"
#include "pixmaps.h"
......@@ -444,7 +445,7 @@ create_toolbox ()
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_wmclass (GTK_WINDOW (window), "toolbox", "Gimp");
gtk_window_set_title (GTK_WINDOW (window), "The GIMP");
gtk_widget_set_uposition (window, toolbox_x, toolbox_y);
session_set_window_geometry (window, &toolbox_geometry, TRUE);
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
GTK_SIGNAL_FUNC (toolbox_delete),
NULL);
......@@ -522,7 +523,8 @@ toolbox_free ()
{
int i;
gdk_window_get_position (toolbox_shell->window, &toolbox_x, &toolbox_y);
session_get_window_geometry (toolbox_shell, &toolbox_geometry);
gtk_widget_destroy (toolbox_shell);
for (i = 0; i < num_tools; i++)
{
......
......@@ -33,6 +33,7 @@
#include "menus.h"
#include "plug_in.h"
#include "gimage.h"
#include "session.h"
#include "tools.h"
#define ERROR 0
......@@ -54,7 +55,8 @@ typedef enum {
TT_XPLUGIN,
TT_XPLUGINDEF,
TT_XMENUPATH,
TT_XDEVICE
TT_XDEVICE,
TT_XSESSIONGEOM
} TokenType;
typedef struct _ParseFunc ParseFunc;
......@@ -106,14 +108,8 @@ int show_rulers = TRUE;
int ruler_units = GTK_PIXELS;
int auto_save = TRUE;
int cubic_interpolation = FALSE;
int toolbox_x = 0, toolbox_y = 0;
int lc_x = 0, lc_y = 400;
int progress_x = 170, progress_y = 5;
int info_x = 165, info_y = 0;
int color_select_x = 140, color_select_y = 120;
int tool_options_x = 0, tool_options_y = 345;
int confirm_on_close = TRUE;
int save_window_positions_on_exit = FALSE;
int save_window_positions_on_exit = TRUE;
int default_width = 256;
int default_height = 256;
int default_type = RGB;
......@@ -144,6 +140,7 @@ static int parse_plug_in (gpointer val1p, gpointer val2p);
static int parse_plug_in_def (gpointer val1p, gpointer val2p);
static int parse_device (gpointer val1p, gpointer val2p);
static int parse_menu_path (gpointer val1p, gpointer val2p);
static int parse_session_geometry (gpointer val1p, gpointer val2p);
static int parse_proc_def (PlugInProcDef **proc_def);
static int parse_proc_arg (ProcArg *arg);
......@@ -213,21 +210,17 @@ static ParseFunc funcs[] =
{ "auto-save", TT_BOOLEAN, &auto_save, NULL },
{ "dont-auto-save", TT_BOOLEAN, NULL, &auto_save },
{ "cubic-interpolation", TT_BOOLEAN, &cubic_interpolation, NULL },
{ "toolbox-position", TT_POSITION, &toolbox_x, &toolbox_y },
{ "lc-dialog-position", TT_POSITION, &lc_x, &lc_y },
{ "progress-position", TT_POSITION, &progress_x, &progress_y },
{ "info-position", TT_POSITION, &info_x, &info_y },
{ "color-select-position", TT_POSITION, &color_select_x, &color_select_y },
{ "tool-options-position", TT_POSITION, &tool_options_x, &tool_options_y },
{ "confirm-on-close", TT_BOOLEAN, &confirm_on_close, NULL },
{ "dont-confirm-on-close", TT_BOOLEAN, NULL, &confirm_on_close },
{ "save-window-positions-on-exit",
TT_BOOLEAN, &save_window_positions_on_exit, NULL },
{ "dont-save-window-positions-on-exit",
TT_BOOLEAN, NULL, &save_window_positions_on_exit},
{ "dont-confirm-on-close", TT_BOOLEAN, NULL, &confirm_on_close },
{ "show-tips", TT_BOOLEAN, &show_tips, NULL },
{ "dont-show-tips", TT_BOOLEAN, NULL, &show_tips },
{ "last-tip-shown", TT_INT, &last_tip, NULL },
{ "show-tool-tips", TT_BOOLEAN, &show_tool_tips, NULL },
{ "dont-show-tool-tips", TT_BOOLEAN, NULL, &show_tool_tips },
{ "default-image-size", TT_POSITION, &default_width, &default_height },
{ "default-image-type", TT_IMAGETYPE, &default_type, NULL },
{ "default-resolution", TT_INT, &default_resolution, NULL },
......@@ -236,11 +229,24 @@ static ParseFunc funcs[] =
{ "plug-in-def", TT_XPLUGINDEF, NULL, NULL },
{ "menu-path", TT_XMENUPATH, NULL, NULL },
{ "device", TT_XDEVICE, NULL, NULL },
{ "show-tool-tips", TT_BOOLEAN, &show_tool_tips, NULL },
{ "dont-show-tool-tips", TT_BOOLEAN, NULL, &show_tool_tips },
{ "session-geometry", TT_XSESSIONGEOM, NULL, NULL}
};
static int nfuncs = sizeof (funcs) / sizeof (funcs[0]);
static SessionGeometry *session_geometries[] =
{
&toolbox_geometry,
&lc_dialog_geometry,
&info_dialog_geometry,
&tool_options_geometry,
&palette_geometry,
&brush_select_geometry,
&pattern_select_geometry,
&gradient_editor_geometry
};
static int nsession_geometries = sizeof (session_geometries) / sizeof (session_geometries[0]);
#define MAX_GIMPDIR_LEN 500
char *
......@@ -590,6 +596,8 @@ parse_statement ()
return parse_menu_path (funcs[i].val1p, funcs[i].val2p);
case TT_XDEVICE:
return parse_device (funcs[i].val1p, funcs[i].val2p);
case TT_XSESSIONGEOM:
return parse_session_geometry (funcs[i].val1p, funcs[i].val2p);
}
return parse_unknown (token_sym);
......@@ -1738,6 +1746,85 @@ error:
return ERROR;
}
static int
parse_session_geometry (gpointer val1p,
gpointer val2p)
{
int i;
int token;
SessionGeometry *geometry = NULL;
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
return ERROR;
token = get_next_token ();
for (i = 0; i < nsession_geometries; i++)
{
if (strcmp (session_geometries[i]->name, token_str) == 0)
geometry = session_geometries[i];
}
if (geometry == NULL)
return ERROR;
/* Parse options for session geometry */
while ( peek_next_token () == TOKEN_LEFT_PAREN )
{
token = get_next_token ();
token = peek_next_token ();
if (!token || (token != TOKEN_SYMBOL))
return ERROR;
token = get_next_token ();
if (!strcmp ("position", token_sym))
{
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
return ERROR;
token = get_next_token ();
geometry->x = token_int;
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
return ERROR;
token = get_next_token ();
geometry->y = token_int;
}
else if (!strcmp ("size", token_sym))
{
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
return ERROR;
token = get_next_token ();
geometry->width = token_int;
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
return ERROR;
token = get_next_token ();
geometry->height = token_int;
}
else
return ERROR;
token = peek_next_token ();
if (!token || (token != TOKEN_RIGHT_PAREN))
return ERROR;
token = get_next_token ();
}
if (!token || (token != TOKEN_RIGHT_PAREN))
return ERROR;
token = get_next_token ();
session_geometry_updates = g_list_append (session_geometry_updates, geometry);
return OK;
}
static int
parse_unknown (char *token_sym)
{
......@@ -1826,6 +1913,7 @@ value_to_str (char *name)
case TT_XPLUGINDEF:
case TT_XMENUPATH:
case TT_XDEVICE:
case TT_XSESSIONGEOM:
return NULL;
}
return NULL;
......
......@@ -52,12 +52,6 @@ extern int show_rulers;
extern int ruler_units;
extern int auto_save;
extern int cubic_interpolation;
extern int toolbox_x, toolbox_y;
extern int lc_x, lc_y;
extern int progress_x, progress_y;
extern int info_x, info_y;
extern int color_select_x, color_select_y;
extern int tool_options_x, tool_options_y;
extern int confirm_on_close;
extern int save_window_positions_on_exit;
extern int default_width, default_height;
......
......@@ -163,6 +163,7 @@
#include "gradient.h"
#include "interface.h"
#include "palette.h"
#include "session.h"
/***** Magic numbers *****/
......@@ -789,8 +790,8 @@ grad_create_gradient_editor(void)
gtk_window_set_wmclass (GTK_WINDOW(g_editor->shell), "gradient_editor", "Gimp");
gtk_container_border_width(GTK_CONTAINER(g_editor->shell), 0);
gtk_window_set_title(GTK_WINDOW(g_editor->shell), "Gradient Editor");
gtk_window_position(GTK_WINDOW(g_editor->shell), GTK_WIN_POS_CENTER);
session_set_window_geometry (g_editor->shell, &gradient_editor_geometry, TRUE);
/* handle window manager close signals */
gtk_signal_connect (GTK_OBJECT (g_editor->shell), "delete_event",
GTK_SIGNAL_FUNC (ed_close_callback),
......@@ -1064,6 +1065,9 @@ void
grad_free_gradient_editor(void)
{
/* FIXME */
if (g_editor)
session_get_window_geometry (g_editor->shell, &gradient_editor_geometry);
} /* grad_free_gradient_editor */
......
......@@ -163,6 +163,7 @@
#include "gradient.h"
#include "interface.h"
#include "palette.h"
#include "session.h"
/***** Magic numbers *****/
......@@ -789,8 +790,8 @@ grad_create_gradient_editor(void)
gtk_window_set_wmclass (GTK_WINDOW(g_editor->shell), "gradient_editor", "Gimp");
gtk_container_border_width(GTK_CONTAINER(g_editor->shell), 0);
gtk_window_set_title(GTK_WINDOW(g_editor->shell), "Gradient Editor");
gtk_window_position(GTK_WINDOW(g_editor->shell), GTK_WIN_POS_CENTER);
session_set_window_geometry (g_editor->shell, &gradient_editor_geometry, TRUE);
/* handle window manager close signals */
gtk_signal_connect (GTK_OBJECT (g_editor->shell), "delete_event",
GTK_SIGNAL_FUNC (ed_close_callback),
......@@ -1064,6 +1065,9 @@ void
grad_free_gradient_editor(void)
{
/* FIXME */
if (g_editor)
session_get_window_geometry (g_editor->shell, &gradient_editor_geometry);
} /* grad_free_gradient_editor */
......
......@@ -27,6 +27,7 @@
#include "disp_callbacks.h"
#include "errors.h"
#include "paint_funcs.h"
#include "session.h"
#define STD_CELL_WIDTH 24
......@@ -141,6 +142,7 @@ brush_select_new ()
bsp->shell = gtk_dialog_new ();
gtk_window_set_wmclass (GTK_WINDOW (bsp->shell), "brushselection", "Gimp");
gtk_window_set_title (GTK_WINDOW (bsp->shell), "Brush Selection");
session_set_window_geometry (bsp->shell, &brush_select_geometry, TRUE);
gtk_window_set_policy(GTK_WINDOW(bsp->shell), FALSE, TRUE, FALSE);
vbox = gtk_vbox_new (FALSE, 1);
gtk_container_border_width (GTK_CONTAINER (vbox), 2);
......@@ -313,6 +315,7 @@ brush_select_free (BrushSelectP bsp)
{
if (bsp)
{
session_get_window_geometry (bsp->shell, &brush_select_geometry);
if (bsp->brush_popup != NULL)
gtk_widget_destroy (bsp->brush_popup);
g_free (bsp);
......
......@@ -163,6 +163,7 @@
#include "gradient.h"
#include "interface.h"
#include "palette.h"
#include "session.h"