More session-managment functionality. Opened dialogs are saved and eventually

reopened. Try to use the --restore-session command-line option.


--Sven
This commit is contained in:
Sven Neumann 1998-07-11 22:23:23 +00:00
parent 32058a457f
commit 329e2072d8
40 changed files with 458 additions and 250 deletions

View File

@ -1,3 +1,28 @@
Sun Jul 12 00:13:02 MEST 1998 Sven Neumann <sven@gimp.org>
* gimprc.in
* app/app_procs.c
* app/appenv.h
* app/brush_select.c
* app/gimprc.c
* app/gimprc.h
* app/gradient.c
* app/info_dialog.c
* app/interface.c
* app/layers_dialog.c
* app/main.c
* app/palette.c
* app/pattern_select.c
* app/preferences_dialog.c
* app/session.c
* app/session.h
* app/tools.c: More session-managment functionality. Opened dialogs
are saved and eventually reopened. Try to use the --restore-session
command-line option. The format of gimprc and sessionrc have
slightly changed. You should remove your sessionrc and delete the
line (save-window-positions-on-exit) from your gimprc to avoid
warnings.
Sat Jul 11 12:20:50 1998 Scott Goehring <scott@poverty.bloomington.in.us>
* app/paint_funcs.c (copy_region): Added missing tile_release

View File

@ -968,8 +968,8 @@ dialogs_palette_cmd_callback (GtkWidget *widget,
}
void
dialogs_gradient_editor_cmd_callback(GtkWidget *widget,
gpointer client_data)
dialogs_gradient_editor_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
grad_create_gradient_editor ();
} /* dialogs_gradient_editor_cmd_callback */

View File

@ -86,6 +86,7 @@ static void splash_logo_expose (GtkWidget *widget);
static gint is_app_exit_finish_done = FALSE;
int we_are_exiting = FALSE;
static ProcArg quit_args[] =
{
@ -476,6 +477,8 @@ app_init (void)
RESET_BAR();
parse_gimprc (); /* parse the local GIMP configuration file */
if (always_restore_session)
restore_session = TRUE;
/* Now we are ready to draw the splash-screen-image to the start-up window */
if (no_interface == FALSE)
@ -534,6 +537,8 @@ app_init (void)
get_active_pattern ();
paint_funcs_setup ();
if (no_interface == FALSE)
session_restore();
}
int
@ -550,6 +555,7 @@ app_exit_finish (void)
is_app_exit_finish_done = TRUE;
message_handler = CONSOLE;
we_are_exiting = TRUE;
lc_dialog_free ();
gdisplays_delete ();

View File

@ -41,6 +41,8 @@ extern int no_data;
extern int be_verbose;
extern int use_debug_handler;
extern int console_messages;
extern int restore_session;
extern int we_are_exiting; /* this is used in session_get_window_info() */
extern GimpSet* image_context;
extern MessageHandlerType message_handler;

View File

@ -165,7 +165,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);
session_set_window_geometry (bsp->shell, &brush_select_session_info, 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);
@ -365,7 +365,7 @@ brush_select_free (BrushSelectP bsp)
{
if (bsp)
{
session_get_window_geometry (bsp->shell, &brush_select_geometry);
session_get_window_info (bsp->shell, &brush_select_session_info);
if (bsp->brush_popup != NULL)
gtk_widget_destroy (bsp->brush_popup);
g_free (bsp);

View File

@ -968,8 +968,8 @@ dialogs_palette_cmd_callback (GtkWidget *widget,
}
void
dialogs_gradient_editor_cmd_callback(GtkWidget *widget,
gpointer client_data)
dialogs_gradient_editor_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
grad_create_gradient_editor ();
} /* dialogs_gradient_editor_cmd_callback */

View File

@ -86,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);
session_set_window_geometry (shell, &info_dialog_geometry, FALSE );
session_set_window_geometry (shell, &info_dialog_session_info, FALSE );
gtk_signal_connect (GTK_OBJECT (shell), "delete_event",
GTK_SIGNAL_FUNC (info_dialog_delete_callback),
@ -140,7 +140,7 @@ 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);
session_get_window_info (idialog->shell, &info_dialog_session_info);
/* Destroy the associated widgets */
gtk_widget_destroy (idialog->shell);

View File

@ -66,7 +66,7 @@ static void file_prefs_toggle_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 void file_prefs_clear_session_info_callback (GtkWidget *, gpointer);
/* static variables */
static int last_type = RGB;
@ -83,7 +83,8 @@ static int old_no_cursor_updating;
static int old_show_tool_tips;
static int old_cubic_interpolation;
static int old_confirm_on_close;
static int old_save_window_positions_on_exit;
static int old_save_session_info;
static int old_always_restore_session;
static int old_default_width;
static int old_default_height;
static int old_default_type;
@ -294,11 +295,13 @@ file_prefs_save_callback (GtkWidget *widget,
update = g_list_append (update, "confirm-on-close");
remove = g_list_append (remove, "dont-confirm-on-close");
}
if (save_window_positions_on_exit != old_save_window_positions_on_exit)
if (save_session_info != old_save_session_info)
{
update = g_list_append (update, "save-window-positions-on-exit");
remove = g_list_append (remove, "dont-save-window-positions-on-exit");
update = g_list_append (update, "save-session-info");
remove = g_list_append (remove, "dont-save-session-info");
}
if (always_restore_session != old_always_restore_session)
update = g_list_append (update, "always-restore-session");
if (default_width != old_default_width ||
default_height != old_default_height)
update = g_list_append (update, "default-image-size");
@ -424,7 +427,7 @@ file_prefs_cancel_callback (GtkWidget *widget,
show_tool_tips = old_show_tool_tips;
cubic_interpolation = old_cubic_interpolation;
confirm_on_close = old_confirm_on_close;
save_window_positions_on_exit = old_save_window_positions_on_exit;
save_session_info = old_save_session_info;
default_width = old_default_width;
default_height = old_default_height;
default_type = old_default_type;
@ -478,8 +481,10 @@ file_prefs_toggle_callback (GtkWidget *widget,
cubic_interpolation = GTK_TOGGLE_BUTTON (widget)->active;
else if (data == &confirm_on_close)
confirm_on_close = GTK_TOGGLE_BUTTON (widget)->active;
else if (data == &save_window_positions_on_exit)
save_window_positions_on_exit = GTK_TOGGLE_BUTTON (widget)->active;
else if (data == &save_session_info)
save_session_info = GTK_TOGGLE_BUTTON (widget)->active;
else if (data == &always_restore_session)
always_restore_session = 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)
@ -560,11 +565,11 @@ file_prefs_string_callback (GtkWidget *widget,
}
static void
file_prefs_clear_window_positions_callback (GtkWidget *widget,
gpointer data)
file_prefs_clear_session_info_callback (GtkWidget *widget,
gpointer data)
{
g_list_free (session_geometry_updates);
session_geometry_updates = NULL;
g_list_free (session_info_updates);
session_info_updates = NULL;
}
void
@ -686,7 +691,8 @@ file_pref_cmd_callback (GtkWidget *widget,
old_show_tool_tips = show_tool_tips;
old_cubic_interpolation = cubic_interpolation;
old_confirm_on_close = confirm_on_close;
old_save_window_positions_on_exit = save_window_positions_on_exit;
old_save_session_info = save_session_info;
old_always_restore_session = always_restore_session;
old_default_width = default_width;
old_default_height = default_height;
old_default_type = default_type;
@ -1131,11 +1137,11 @@ file_pref_cmd_callback (GtkWidget *widget,
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);
save_session_info);
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);
&save_session_info);
gtk_widget_show (button);
hbox = gtk_hbox_new (FALSE, 2);
@ -1146,10 +1152,19 @@ file_pref_cmd_callback (GtkWidget *widget,
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,
(GtkSignalFunc) file_prefs_clear_session_info_callback,
NULL);
gtk_widget_show (button);
button = gtk_check_button_new_with_label ("Always try to restore session");
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button),
always_restore_session);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "toggled",
(GtkSignalFunc) file_prefs_toggle_callback,
&always_restore_session);
gtk_widget_show (button);
label = gtk_label_new ("Session");
gtk_notebook_append_page (GTK_NOTEBOOK(notebook), out_frame, label);

View File

@ -443,7 +443,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");
session_set_window_geometry (window, &toolbox_geometry, TRUE);
session_set_window_geometry (window, &toolbox_session_info, TRUE);
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
GTK_SIGNAL_FUNC (toolbox_delete),
NULL);
@ -521,7 +521,7 @@ toolbox_free ()
{
int i;
session_get_window_geometry (toolbox_shell, &toolbox_geometry);
session_get_window_info (toolbox_shell, &toolbox_session_info);
gtk_widget_destroy (toolbox_shell);
for (i = 0; i < num_tools; i++)

View File

@ -443,7 +443,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");
session_set_window_geometry (window, &toolbox_geometry, TRUE);
session_set_window_geometry (window, &toolbox_session_info, TRUE);
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
GTK_SIGNAL_FUNC (toolbox_delete),
NULL);
@ -521,7 +521,7 @@ toolbox_free ()
{
int i;
session_get_window_geometry (toolbox_shell, &toolbox_geometry);
session_get_window_info (toolbox_shell, &toolbox_session_info);
gtk_widget_destroy (toolbox_shell);
for (i = 0; i < num_tools; i++)

View File

@ -56,7 +56,7 @@ typedef enum {
TT_XPLUGINDEF,
TT_XMENUPATH,
TT_XDEVICE,
TT_XSESSIONGEOM
TT_XSESSIONINFO
} TokenType;
typedef struct _ParseFunc ParseFunc;
@ -109,7 +109,8 @@ int ruler_units = GTK_PIXELS;
int auto_save = TRUE;
int cubic_interpolation = FALSE;
int confirm_on_close = TRUE;
int save_window_positions_on_exit = TRUE;
int save_session_info = TRUE;
int always_restore_session = FALSE;
int default_width = 256;
int default_height = 256;
int default_type = RGB;
@ -140,7 +141,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_session_info (gpointer val1p, gpointer val2p);
static int parse_proc_def (PlugInProcDef **proc_def);
static int parse_proc_arg (ProcArg *arg);
@ -214,10 +215,9 @@ static ParseFunc funcs[] =
{ "cubic-interpolation", TT_BOOLEAN, &cubic_interpolation, NULL },
{ "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},
{ "save-session-info", TT_BOOLEAN, &save_session_info, NULL },
{ "dont-save-session-info", TT_BOOLEAN, NULL, &save_session_info},
{ "always-restore-session", TT_BOOLEAN, &always_restore_session, NULL },
{ "show-tips", TT_BOOLEAN, &show_tips, NULL },
{ "dont-show-tips", TT_BOOLEAN, NULL, &show_tips },
{ "last-tip-shown", TT_INT, &last_tip, NULL },
@ -231,22 +231,22 @@ static ParseFunc funcs[] =
{ "plug-in-def", TT_XPLUGINDEF, NULL, NULL },
{ "menu-path", TT_XMENUPATH, NULL, NULL },
{ "device", TT_XDEVICE, NULL, NULL },
{ "session-geometry", TT_XSESSIONGEOM, NULL, NULL}
{ "session-info", TT_XSESSIONINFO, NULL, NULL}
};
static int nfuncs = sizeof (funcs) / sizeof (funcs[0]);
static SessionGeometry *session_geometries[] =
static SessionInfo *session_infos[] =
{
&toolbox_geometry,
&lc_dialog_geometry,
&info_dialog_geometry,
&tool_options_geometry,
&palette_geometry,
&brush_select_geometry,
&pattern_select_geometry,
&gradient_editor_geometry
&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_editor_session_info
};
static int nsession_geometries = sizeof (session_geometries) / sizeof (session_geometries[0]);
static int nsession_infos = sizeof (session_infos) / sizeof (session_infos[0]);
extern char* alternate_gimprc;
extern char* alternate_system_gimprc;
@ -609,8 +609,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);
case TT_XSESSIONINFO:
return parse_session_info (funcs[i].val1p, funcs[i].val2p);
}
return parse_unknown (token_sym);
@ -1758,28 +1758,28 @@ error:
}
static int
parse_session_geometry (gpointer val1p,
gpointer val2p)
parse_session_info (gpointer val1p,
gpointer val2p)
{
int i;
int token;
SessionGeometry *geometry = NULL;
SessionInfo *info = NULL;
token = peek_next_token ();
if (!token || (token != TOKEN_STRING))
return ERROR;
token = get_next_token ();
for (i = 0; i < nsession_geometries; i++)
for (i = 0; i < nsession_infos; i++)
{
if (strcmp (session_geometries[i]->name, token_str) == 0)
geometry = session_geometries[i];
if (strcmp (session_infos[i]->name, token_str) == 0)
info = session_infos[i];
}
if (geometry == NULL)
if (info == NULL)
return ERROR;
/* Parse options for session geometry */
/* Parse options for session info */
while ( peek_next_token () == TOKEN_LEFT_PAREN )
{
@ -1796,13 +1796,13 @@ parse_session_geometry (gpointer val1p,
if (!token || (token != TOKEN_NUMBER))
return ERROR;
token = get_next_token ();
geometry->x = token_int;
info->x = token_int;
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
return ERROR;
token = get_next_token ();
geometry->y = token_int;
info->y = token_int;
}
else if (!strcmp ("size", token_sym))
{
@ -1810,14 +1810,16 @@ parse_session_geometry (gpointer val1p,
if (!token || (token != TOKEN_NUMBER))
return ERROR;
token = get_next_token ();
geometry->width = token_int;
info->width = token_int;
token = peek_next_token ();
if (!token || (token != TOKEN_NUMBER))
return ERROR;
token = get_next_token ();
geometry->height = token_int;
info->height = token_int;
}
else if (!strcmp ("open-on-exit", token_sym))
info->open = TRUE;
else
return ERROR;
@ -1831,7 +1833,7 @@ parse_session_geometry (gpointer val1p,
return ERROR;
token = get_next_token ();
session_geometry_updates = g_list_append (session_geometry_updates, geometry);
session_info_updates = g_list_append (session_info_updates, info);
return OK;
}
@ -1924,7 +1926,7 @@ value_to_str (char *name)
case TT_XPLUGINDEF:
case TT_XMENUPATH:
case TT_XDEVICE:
case TT_XSESSIONGEOM:
case TT_XSESSIONINFO:
return NULL;
}
return NULL;

View File

@ -53,11 +53,12 @@ extern int ruler_units;
extern int auto_save;
extern int cubic_interpolation;
extern int confirm_on_close;
extern int save_window_positions_on_exit;
extern int default_width, default_height;
extern int default_type;
extern int default_resolution;
extern int default_resolution_units;
extern int save_session_info;
extern int always_restore_session;
extern int show_tips;
extern int last_tip;
extern int show_tool_tips;

View File

@ -790,7 +790,7 @@ 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");
session_set_window_geometry (g_editor->shell, &gradient_editor_geometry, TRUE);
session_set_window_geometry (g_editor->shell, &gradient_editor_session_info, TRUE);
/* handle window manager close signals */
gtk_signal_connect (GTK_OBJECT (g_editor->shell), "delete_event",
@ -1067,7 +1067,7 @@ grad_free_gradient_editor(void)
/* FIXME */
if (g_editor)
session_get_window_geometry (g_editor->shell, &gradient_editor_geometry);
session_get_window_info (g_editor->shell, &gradient_editor_session_info);
} /* grad_free_gradient_editor */

View File

@ -790,7 +790,7 @@ 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");
session_set_window_geometry (g_editor->shell, &gradient_editor_geometry, TRUE);
session_set_window_geometry (g_editor->shell, &gradient_editor_session_info, TRUE);
/* handle window manager close signals */
gtk_signal_connect (GTK_OBJECT (g_editor->shell), "delete_event",
@ -1067,7 +1067,7 @@ grad_free_gradient_editor(void)
/* FIXME */
if (g_editor)
session_get_window_geometry (g_editor->shell, &gradient_editor_geometry);
session_get_window_info (g_editor->shell, &gradient_editor_session_info);
} /* grad_free_gradient_editor */

View File

@ -165,7 +165,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);
session_set_window_geometry (bsp->shell, &brush_select_session_info, 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);
@ -365,7 +365,7 @@ brush_select_free (BrushSelectP bsp)
{
if (bsp)
{
session_get_window_geometry (bsp->shell, &brush_select_geometry);
session_get_window_info (bsp->shell, &brush_select_session_info);
if (bsp->brush_popup != NULL)
gtk_widget_destroy (bsp->brush_popup);
g_free (bsp);

View File

@ -968,8 +968,8 @@ dialogs_palette_cmd_callback (GtkWidget *widget,
}
void
dialogs_gradient_editor_cmd_callback(GtkWidget *widget,
gpointer client_data)
dialogs_gradient_editor_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
grad_create_gradient_editor ();
} /* dialogs_gradient_editor_cmd_callback */

View File

@ -790,7 +790,7 @@ 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");
session_set_window_geometry (g_editor->shell, &gradient_editor_geometry, TRUE);
session_set_window_geometry (g_editor->shell, &gradient_editor_session_info, TRUE);
/* handle window manager close signals */
gtk_signal_connect (GTK_OBJECT (g_editor->shell), "delete_event",
@ -1067,7 +1067,7 @@ grad_free_gradient_editor(void)
/* FIXME */
if (g_editor)
session_get_window_geometry (g_editor->shell, &gradient_editor_geometry);
session_get_window_info (g_editor->shell, &gradient_editor_session_info);
} /* grad_free_gradient_editor */

View File

@ -968,8 +968,8 @@ dialogs_palette_cmd_callback (GtkWidget *widget,
}
void
dialogs_gradient_editor_cmd_callback(GtkWidget *widget,
gpointer client_data)
dialogs_gradient_editor_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
grad_create_gradient_editor ();
} /* dialogs_gradient_editor_cmd_callback */

View File

@ -86,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);
session_set_window_geometry (shell, &info_dialog_geometry, FALSE );
session_set_window_geometry (shell, &info_dialog_session_info, FALSE );
gtk_signal_connect (GTK_OBJECT (shell), "delete_event",
GTK_SIGNAL_FUNC (info_dialog_delete_callback),
@ -140,7 +140,7 @@ 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);
session_get_window_info (idialog->shell, &info_dialog_session_info);
/* Destroy the associated widgets */
gtk_widget_destroy (idialog->shell);

View File

@ -306,7 +306,7 @@ lc_dialog_create (GimpImage* gimage)
gtk_window_set_title (GTK_WINDOW (lc_shell), "Layers & Channels");
gtk_window_set_wmclass (GTK_WINDOW (lc_shell), "layers_and_channels", "Gimp");
session_set_window_geometry (lc_shell, &lc_dialog_geometry, TRUE);
session_set_window_geometry (lc_shell, &lc_dialog_session_info, TRUE);
gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (lc_shell)->vbox), 2);
gtk_signal_connect (GTK_OBJECT (lc_shell),
"delete_event",
@ -457,7 +457,7 @@ lc_dialog_free ()
if (lc_shell == NULL)
return;
session_get_window_geometry (lc_shell, &lc_dialog_geometry);
session_get_window_info (lc_shell, &lc_dialog_session_info);
layers_dialog_free ();
channels_dialog_free ();

View File

@ -173,7 +173,7 @@ palette_create ()
/* The shell and main vbox */
palette->shell = gtk_dialog_new ();
gtk_window_set_wmclass (GTK_WINDOW (palette->shell), "color_palette", "Gimp");
session_set_window_geometry (palette->shell, &palette_geometry, FALSE);
session_set_window_geometry (palette->shell, &palette_session_info, FALSE);
gtk_window_set_policy (GTK_WINDOW (palette->shell), FALSE, FALSE, FALSE);
gtk_window_set_title (GTK_WINDOW (palette->shell), "Color Palette");
vbox = gtk_vbox_new (FALSE, 1);
@ -298,7 +298,7 @@ palette_free ()
if (palette->color_select)
color_select_free (palette->color_select);
session_get_window_geometry (palette->shell, &palette_geometry);
session_get_window_info (palette->shell, &palette_session_info);
g_free (palette);

View File

@ -94,7 +94,7 @@ pattern_select_new ()
psp->shell = gtk_dialog_new ();
gtk_window_set_wmclass (GTK_WINDOW (psp->shell), "patternselection", "Gimp");
gtk_window_set_title (GTK_WINDOW (psp->shell), "Pattern Selection");
session_set_window_geometry (psp->shell, &pattern_select_geometry, TRUE);
session_set_window_geometry (psp->shell, &pattern_select_session_info, TRUE);
gtk_window_set_policy(GTK_WINDOW(psp->shell), FALSE, TRUE, FALSE);
vbox = gtk_vbox_new (FALSE, 1);
@ -204,7 +204,7 @@ pattern_select_free (PatternSelectP psp)
{
if (psp)
{
session_get_window_geometry (psp->shell, &pattern_select_geometry);
session_get_window_info (psp->shell, &pattern_select_session_info);
if (psp->pattern_popup != NULL)
gtk_widget_destroy (psp->pattern_popup);
g_free (psp);

View File

@ -66,7 +66,7 @@ static void file_prefs_toggle_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 void file_prefs_clear_session_info_callback (GtkWidget *, gpointer);
/* static variables */
static int last_type = RGB;
@ -83,7 +83,8 @@ static int old_no_cursor_updating;
static int old_show_tool_tips;
static int old_cubic_interpolation;
static int old_confirm_on_close;
static int old_save_window_positions_on_exit;
static int old_save_session_info;
static int old_always_restore_session;
static int old_default_width;
static int old_default_height;
static int old_default_type;
@ -294,11 +295,13 @@ file_prefs_save_callback (GtkWidget *widget,
update = g_list_append (update, "confirm-on-close");
remove = g_list_append (remove, "dont-confirm-on-close");
}
if (save_window_positions_on_exit != old_save_window_positions_on_exit)
if (save_session_info != old_save_session_info)
{
update = g_list_append (update, "save-window-positions-on-exit");
remove = g_list_append (remove, "dont-save-window-positions-on-exit");
update = g_list_append (update, "save-session-info");
remove = g_list_append (remove, "dont-save-session-info");
}
if (always_restore_session != old_always_restore_session)
update = g_list_append (update, "always-restore-session");
if (default_width != old_default_width ||
default_height != old_default_height)
update = g_list_append (update, "default-image-size");
@ -424,7 +427,7 @@ file_prefs_cancel_callback (GtkWidget *widget,
show_tool_tips = old_show_tool_tips;
cubic_interpolation = old_cubic_interpolation;
confirm_on_close = old_confirm_on_close;
save_window_positions_on_exit = old_save_window_positions_on_exit;
save_session_info = old_save_session_info;
default_width = old_default_width;
default_height = old_default_height;
default_type = old_default_type;
@ -478,8 +481,10 @@ file_prefs_toggle_callback (GtkWidget *widget,
cubic_interpolation = GTK_TOGGLE_BUTTON (widget)->active;
else if (data == &confirm_on_close)
confirm_on_close = GTK_TOGGLE_BUTTON (widget)->active;
else if (data == &save_window_positions_on_exit)
save_window_positions_on_exit = GTK_TOGGLE_BUTTON (widget)->active;
else if (data == &save_session_info)
save_session_info = GTK_TOGGLE_BUTTON (widget)->active;
else if (data == &always_restore_session)
always_restore_session = 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)
@ -560,11 +565,11 @@ file_prefs_string_callback (GtkWidget *widget,
}
static void
file_prefs_clear_window_positions_callback (GtkWidget *widget,
gpointer data)
file_prefs_clear_session_info_callback (GtkWidget *widget,
gpointer data)
{
g_list_free (session_geometry_updates);
session_geometry_updates = NULL;
g_list_free (session_info_updates);
session_info_updates = NULL;
}
void
@ -686,7 +691,8 @@ file_pref_cmd_callback (GtkWidget *widget,
old_show_tool_tips = show_tool_tips;
old_cubic_interpolation = cubic_interpolation;
old_confirm_on_close = confirm_on_close;
old_save_window_positions_on_exit = save_window_positions_on_exit;
old_save_session_info = save_session_info;
old_always_restore_session = always_restore_session;
old_default_width = default_width;
old_default_height = default_height;
old_default_type = default_type;
@ -1131,11 +1137,11 @@ file_pref_cmd_callback (GtkWidget *widget,
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);
save_session_info);
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);
&save_session_info);
gtk_widget_show (button);
hbox = gtk_hbox_new (FALSE, 2);
@ -1146,10 +1152,19 @@ file_pref_cmd_callback (GtkWidget *widget,
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,
(GtkSignalFunc) file_prefs_clear_session_info_callback,
NULL);
gtk_widget_show (button);
button = gtk_check_button_new_with_label ("Always try to restore session");
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button),
always_restore_session);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "toggled",
(GtkSignalFunc) file_prefs_toggle_callback,
&always_restore_session);
gtk_widget_show (button);
label = gtk_label_new ("Session");
gtk_notebook_append_page (GTK_NOTEBOOK(notebook), out_frame, label);

View File

@ -17,25 +17,29 @@
*/
/* Session-managment stuff
/* Session-managment stuff Copyright (C) 1998 Sven Neumann <sven@gimp.org>
I include a short description here on what is done and what problems
are left.
are left:
Since everything saved in sessionrc changes often (with each session?)
the whole file is rewritten each time the gimp exits. I don't see any
use in implementing a more flexible scheme like it is used for gimprc.
Right now session-managment is limited to window geometry. I plan to add
at least the saving of Last-Used-Images (using nuke's patch).
Right now session-managment is limited to window geometry. Restoring
openend images is planned, but I'm still not sure how to deal with dirty
images.
There is a problem with the offset introduced by the window-manager adding
decorations to the windows. This is annoying and should be fixed somehow.
( Update: I was promised that this will be fixed in gtk. )
Still not sure how to implement stuff for opening windows on start-up.
Probably the best thing to do, would be to have a list of dialogs in
the preferences-dialog that should always be opened.
Dialogs are now reopened if the gimp is called with the command-line-option
--restore-session or if the related entry is set in gimprc.
Probably there should alternatively be a list of dialogs in the preferences
that should always be opened on start-up.
Please point me into the right direction to make this work with Gnome-SM.
*/
#include <stdlib.h>
@ -43,50 +47,69 @@
#include <unistd.h>
#include "appenv.h"
#include "commands.h"
#include "gimprc.h"
#include "session.h"
static void sessionrc_write_geometry (SessionGeometry *, FILE *);
static void sessionrc_write_info (SessionInfo *, FILE *);
static void session_open_dialog (SessionInfo *info);
static void session_reset_open_state (SessionInfo *info);
GList *session_geometry_updates = NULL;
GList *session_info_updates = NULL;
/* global session variables */
SessionGeometry toolbox_geometry = { "toolbox", 0, 0, 0, 0 };
SessionGeometry lc_dialog_geometry = { "lc-dialog", 0, 400, 0, 0 };
SessionGeometry info_dialog_geometry = { "info-dialog", 165, 0, 0, 0 };
SessionGeometry tool_options_geometry = { "tool-options", 0, 345, 0, 0 };
SessionGeometry palette_geometry = { "palette", 140, 180, 0, 0 };
SessionGeometry brush_select_geometry = { "brush-select", 150, 180, 0, 0 };
SessionGeometry pattern_select_geometry = { "pattern-select", 160, 180, 0, 0 };
SessionGeometry gradient_editor_geometry = { "gradient-editor", 170, 180, 0, 0 };
SessionInfo toolbox_session_info =
{ "toolbox", NULL, 0, 0, 0, 0, FALSE };
SessionInfo lc_dialog_session_info =
{ "lc-dialog", dialogs_lc_cmd_callback, 0, 400, 0, 0, FALSE };
SessionInfo info_dialog_session_info =
{ "info-dialog", NULL, 165, 0, 0, 0, FALSE };
SessionInfo tool_options_session_info =
{ "tool-options", dialogs_tools_options_cmd_callback, 0, 345, 0, 0, FALSE };
SessionInfo palette_session_info =
{ "palette", dialogs_palette_cmd_callback, 140, 180, 0, 0, FALSE };
SessionInfo brush_select_session_info =
{ "brush-select", dialogs_brushes_cmd_callback, 150, 180, 0, 0, FALSE };
SessionInfo pattern_select_session_info =
{ "pattern-select", dialogs_patterns_cmd_callback, 160, 180, 0, 0, FALSE };
SessionInfo gradient_editor_session_info =
{ "gradient-editor", dialogs_gradient_editor_cmd_callback, 170, 180, 0, 0, FALSE };
/* public functions */
void
session_get_window_geometry (GtkWidget *window,
SessionGeometry *geometry)
session_get_window_info (GtkWidget *window,
SessionInfo *info)
{
if ( !save_window_positions_on_exit || geometry == NULL || window->window == NULL )
if ( !save_session_info || info == NULL || window->window == NULL )
return;
gdk_window_get_origin (window->window, &geometry->x, &geometry->y);
gdk_window_get_size (window->window, &geometry->width, &geometry->height);
gdk_window_get_origin (window->window, &info->x, &info->y);
gdk_window_get_size (window->window, &info->width, &info->height);
if (g_list_find (session_geometry_updates, geometry) == NULL)
session_geometry_updates = g_list_append (session_geometry_updates, geometry);
/* This is a very ugly hack to work against the offset
introduced by window decorations.
The problem should be handled in gtk ... */
info->y += -20;
if ( we_are_exiting )
info->open = GTK_WIDGET_VISIBLE (window);
if ( g_list_find (session_info_updates, info) == NULL )
session_info_updates = g_list_append (session_info_updates, info);
}
void
session_set_window_geometry (GtkWidget *window,
SessionGeometry *geometry,
int set_size)
session_set_window_geometry (GtkWidget *window,
SessionInfo *info,
int set_size)
{
if ( window == NULL || geometry == NULL)
if ( window == NULL || info == NULL)
return;
gtk_widget_set_uposition (window, geometry->x, geometry->y);
gtk_widget_set_uposition (window, info->x, info->y);
if ( (set_size) && (geometry->width > 0) && (geometry->height > 0) )
gtk_widget_set_usize (window, geometry->width, geometry->height);
if ( (set_size) && (info->width > 0) && (info->height > 0) )
gtk_widget_set_usize (window, info->width, info->height);
}
void
@ -114,7 +137,7 @@ save_sessionrc (void)
fprintf(fp, "# are used.\n\n");
/* save window geometries */
g_list_foreach (session_geometry_updates, (GFunc)sessionrc_write_geometry, fp);
g_list_foreach (session_info_updates, (GFunc)sessionrc_write_info, fp);
/* save last tip shown */
fprintf(fp, "(last-tip-shown %d)\n\n", last_tip + 1);
@ -138,17 +161,48 @@ session_init (void)
}
}
void
session_restore (void)
{
/* open dialogs */
if (restore_session)
g_list_foreach (session_info_updates, (GFunc)session_open_dialog, NULL);
/* reset the open state in the session_infos */
g_list_foreach (session_info_updates, (GFunc)session_reset_open_state, NULL);
}
/* internal function */
static void
sessionrc_write_geometry (SessionGeometry *geometry, FILE *fp)
sessionrc_write_info (SessionInfo *info, FILE *fp)
{
if (fp == NULL || geometry == NULL)
if (fp == NULL || info == NULL)
return;
fprintf (fp,"(session-geometry \"%s\"\n", geometry->name);
fprintf (fp," (position %d %d)\n", geometry->x, geometry->y);
fprintf (fp," (size %d %d))\n\n", geometry->width, geometry->height);
fprintf (fp,"(session-info \"%s\"\n", info->name);
fprintf (fp," (position %d %d)\n", info->x, info->y);
fprintf (fp," (size %d %d)", info->width, info->height);
if ( info->open )
fprintf (fp,"\n (open-on-exit)");
fprintf (fp,")\n\n");
}
static void
session_open_dialog (SessionInfo *info)
{
if (info == NULL || info->open == FALSE)
return;
(info->open_callback) (NULL, NULL);
}
static void
session_reset_open_state (SessionInfo *info)
{
if (info == NULL )
return;
info->open = FALSE;
}
@ -159,4 +213,3 @@ sessionrc_write_geometry (SessionGeometry *geometry, FILE *fp)

View File

@ -21,38 +21,41 @@
#include <glib.h>
/* Structures */
typedef struct _SessionGeometry SessionGeometry;
typedef struct _SessionInfo SessionInfo;
struct _SessionGeometry
struct _SessionInfo
{
char name[16];
char name[16];
GtkItemFactoryCallback open_callback;
int x;
int y;
int width;
int height;
int open;
};
/* global session variables */
extern SessionGeometry toolbox_geometry;
extern SessionGeometry lc_dialog_geometry;
extern SessionGeometry info_dialog_geometry;
extern SessionGeometry tool_options_geometry;
extern SessionGeometry palette_geometry;
extern SessionGeometry brush_select_geometry;
extern SessionGeometry pattern_select_geometry;
extern SessionGeometry gradient_editor_geometry;
extern SessionInfo toolbox_session_info;
extern SessionInfo lc_dialog_session_info;
extern SessionInfo info_dialog_session_info;
extern SessionInfo tool_options_session_info;
extern SessionInfo palette_session_info;
extern SessionInfo brush_select_session_info;
extern SessionInfo pattern_select_session_info;
extern SessionInfo gradient_editor_session_info;
extern GList *session_geometry_updates; /* This list holds all geometries
that should be written to the
sessionrc on exit. */
extern GList *session_info_updates; /* This list holds all session_infos
that should be written to the
sessionrc on exit. */
/* function prototypes */
void session_get_window_geometry (GtkWidget *window,
SessionGeometry *geometry);
void session_set_window_geometry (GtkWidget *window,
SessionGeometry *geometry,
int set_size);
void session_get_window_info (GtkWidget *window,
SessionInfo *info);
void session_set_window_geometry (GtkWidget *window,
SessionInfo *info,
int set_size);
void session_init (void);
void session_restore (void);
void save_sessionrc (void);
#endif /* __SESSION_H__ */

View File

@ -86,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);
session_set_window_geometry (shell, &info_dialog_geometry, FALSE );
session_set_window_geometry (shell, &info_dialog_session_info, FALSE );
gtk_signal_connect (GTK_OBJECT (shell), "delete_event",
GTK_SIGNAL_FUNC (info_dialog_delete_callback),
@ -140,7 +140,7 @@ 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);
session_get_window_info (idialog->shell, &info_dialog_session_info);
/* Destroy the associated widgets */
gtk_widget_destroy (idialog->shell);

View File

@ -443,7 +443,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");
session_set_window_geometry (window, &toolbox_geometry, TRUE);
session_set_window_geometry (window, &toolbox_session_info, TRUE);
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
GTK_SIGNAL_FUNC (toolbox_delete),
NULL);
@ -521,7 +521,7 @@ toolbox_free ()
{
int i;
session_get_window_geometry (toolbox_shell, &toolbox_geometry);
session_get_window_info (toolbox_shell, &toolbox_session_info);
gtk_widget_destroy (toolbox_shell);
for (i = 0; i < num_tools; i++)

View File

@ -306,7 +306,7 @@ lc_dialog_create (GimpImage* gimage)
gtk_window_set_title (GTK_WINDOW (lc_shell), "Layers & Channels");
gtk_window_set_wmclass (GTK_WINDOW (lc_shell), "layers_and_channels", "Gimp");
session_set_window_geometry (lc_shell, &lc_dialog_geometry, TRUE);
session_set_window_geometry (lc_shell, &lc_dialog_session_info, TRUE);
gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (lc_shell)->vbox), 2);
gtk_signal_connect (GTK_OBJECT (lc_shell),
"delete_event",
@ -457,7 +457,7 @@ lc_dialog_free ()
if (lc_shell == NULL)
return;
session_get_window_geometry (lc_shell, &lc_dialog_geometry);
session_get_window_info (lc_shell, &lc_dialog_session_info);
layers_dialog_free ();
channels_dialog_free ();

View File

@ -47,6 +47,7 @@ int be_verbose;
int use_shm;
int use_debug_handler;
int console_messages;
int restore_session;
GimpSet* image_context;
MessageHandlerType message_handler;
@ -113,6 +114,7 @@ main (int argc, char **argv)
no_splash_image = FALSE;
use_shm = TRUE;
use_debug_handler = FALSE;
restore_session = FALSE;
console_messages = FALSE;
message_handler = CONSOLE;
@ -206,6 +208,11 @@ main (int argc, char **argv)
{
console_messages = TRUE;
}
else if ((strcmp (argv[i], "--restore-session") == 0) ||
(strcmp (argv[i], "-r") == 0))
{
restore_session = TRUE;
}
/*
* ANYTHING ELSE starting with a '-' is an error.
*/
@ -227,6 +234,7 @@ main (int argc, char **argv)
g_print (" -b --batch <commands> Run in batch mode.\n");
g_print (" -g --gimprc <gimprc> Use an alternate gimprc file.\n");
g_print (" -n --no-interface Run without a user interface.\n");
g_print (" -r --restore-session Try to restore saved session.\n");
g_print (" --no-data Do not load patterns, gradients, palettes, brushes.\n");
g_print (" --verbose Show startup messages.\n");
g_print (" --no-splash Do not show the startup window.\n");
@ -237,7 +245,6 @@ main (int argc, char **argv)
g_print (" --debug-handlers Enable debugging signal handlers.\n");
g_print (" --display <display> Use the designated X display.\n\n");
g_print (" --system-gimprc <gimprc> Use an alternate system gimprc file.\n");
}
if (show_version || show_help)

View File

@ -173,7 +173,7 @@ palette_create ()
/* The shell and main vbox */
palette->shell = gtk_dialog_new ();
gtk_window_set_wmclass (GTK_WINDOW (palette->shell), "color_palette", "Gimp");
session_set_window_geometry (palette->shell, &palette_geometry, FALSE);
session_set_window_geometry (palette->shell, &palette_session_info, FALSE);
gtk_window_set_policy (GTK_WINDOW (palette->shell), FALSE, FALSE, FALSE);
gtk_window_set_title (GTK_WINDOW (palette->shell), "Color Palette");
vbox = gtk_vbox_new (FALSE, 1);
@ -298,7 +298,7 @@ palette_free ()
if (palette->color_select)
color_select_free (palette->color_select);
session_get_window_geometry (palette->shell, &palette_geometry);
session_get_window_info (palette->shell, &palette_session_info);
g_free (palette);

View File

@ -94,7 +94,7 @@ pattern_select_new ()
psp->shell = gtk_dialog_new ();
gtk_window_set_wmclass (GTK_WINDOW (psp->shell), "patternselection", "Gimp");
gtk_window_set_title (GTK_WINDOW (psp->shell), "Pattern Selection");
session_set_window_geometry (psp->shell, &pattern_select_geometry, TRUE);
session_set_window_geometry (psp->shell, &pattern_select_session_info, TRUE);
gtk_window_set_policy(GTK_WINDOW(psp->shell), FALSE, TRUE, FALSE);
vbox = gtk_vbox_new (FALSE, 1);
@ -204,7 +204,7 @@ pattern_select_free (PatternSelectP psp)
{
if (psp)
{
session_get_window_geometry (psp->shell, &pattern_select_geometry);
session_get_window_info (psp->shell, &pattern_select_session_info);
if (psp->pattern_popup != NULL)
gtk_widget_destroy (psp->pattern_popup);
g_free (psp);

View File

@ -66,7 +66,7 @@ static void file_prefs_toggle_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 void file_prefs_clear_session_info_callback (GtkWidget *, gpointer);
/* static variables */
static int last_type = RGB;
@ -83,7 +83,8 @@ static int old_no_cursor_updating;
static int old_show_tool_tips;
static int old_cubic_interpolation;
static int old_confirm_on_close;
static int old_save_window_positions_on_exit;
static int old_save_session_info;
static int old_always_restore_session;
static int old_default_width;
static int old_default_height;
static int old_default_type;
@ -294,11 +295,13 @@ file_prefs_save_callback (GtkWidget *widget,
update = g_list_append (update, "confirm-on-close");
remove = g_list_append (remove, "dont-confirm-on-close");
}
if (save_window_positions_on_exit != old_save_window_positions_on_exit)
if (save_session_info != old_save_session_info)
{
update = g_list_append (update, "save-window-positions-on-exit");
remove = g_list_append (remove, "dont-save-window-positions-on-exit");
update = g_list_append (update, "save-session-info");
remove = g_list_append (remove, "dont-save-session-info");
}
if (always_restore_session != old_always_restore_session)
update = g_list_append (update, "always-restore-session");
if (default_width != old_default_width ||
default_height != old_default_height)
update = g_list_append (update, "default-image-size");
@ -424,7 +427,7 @@ file_prefs_cancel_callback (GtkWidget *widget,
show_tool_tips = old_show_tool_tips;
cubic_interpolation = old_cubic_interpolation;
confirm_on_close = old_confirm_on_close;
save_window_positions_on_exit = old_save_window_positions_on_exit;
save_session_info = old_save_session_info;
default_width = old_default_width;
default_height = old_default_height;
default_type = old_default_type;
@ -478,8 +481,10 @@ file_prefs_toggle_callback (GtkWidget *widget,
cubic_interpolation = GTK_TOGGLE_BUTTON (widget)->active;
else if (data == &confirm_on_close)
confirm_on_close = GTK_TOGGLE_BUTTON (widget)->active;
else if (data == &save_window_positions_on_exit)
save_window_positions_on_exit = GTK_TOGGLE_BUTTON (widget)->active;
else if (data == &save_session_info)
save_session_info = GTK_TOGGLE_BUTTON (widget)->active;
else if (data == &always_restore_session)
always_restore_session = 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)
@ -560,11 +565,11 @@ file_prefs_string_callback (GtkWidget *widget,
}
static void
file_prefs_clear_window_positions_callback (GtkWidget *widget,
gpointer data)
file_prefs_clear_session_info_callback (GtkWidget *widget,
gpointer data)
{
g_list_free (session_geometry_updates);
session_geometry_updates = NULL;
g_list_free (session_info_updates);
session_info_updates = NULL;
}
void
@ -686,7 +691,8 @@ file_pref_cmd_callback (GtkWidget *widget,
old_show_tool_tips = show_tool_tips;
old_cubic_interpolation = cubic_interpolation;
old_confirm_on_close = confirm_on_close;
old_save_window_positions_on_exit = save_window_positions_on_exit;
old_save_session_info = save_session_info;
old_always_restore_session = always_restore_session;
old_default_width = default_width;
old_default_height = default_height;
old_default_type = default_type;
@ -1131,11 +1137,11 @@ file_pref_cmd_callback (GtkWidget *widget,
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);
save_session_info);
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);
&save_session_info);
gtk_widget_show (button);
hbox = gtk_hbox_new (FALSE, 2);
@ -1146,10 +1152,19 @@ file_pref_cmd_callback (GtkWidget *widget,
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,
(GtkSignalFunc) file_prefs_clear_session_info_callback,
NULL);
gtk_widget_show (button);
button = gtk_check_button_new_with_label ("Always try to restore session");
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button),
always_restore_session);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "toggled",
(GtkSignalFunc) file_prefs_toggle_callback,
&always_restore_session);
gtk_widget_show (button);
label = gtk_label_new ("Session");
gtk_notebook_append_page (GTK_NOTEBOOK(notebook), out_frame, label);

View File

@ -17,25 +17,29 @@
*/
/* Session-managment stuff
/* Session-managment stuff Copyright (C) 1998 Sven Neumann <sven@gimp.org>
I include a short description here on what is done and what problems
are left.
are left:
Since everything saved in sessionrc changes often (with each session?)
the whole file is rewritten each time the gimp exits. I don't see any
use in implementing a more flexible scheme like it is used for gimprc.
Right now session-managment is limited to window geometry. I plan to add
at least the saving of Last-Used-Images (using nuke's patch).
Right now session-managment is limited to window geometry. Restoring
openend images is planned, but I'm still not sure how to deal with dirty
images.
There is a problem with the offset introduced by the window-manager adding
decorations to the windows. This is annoying and should be fixed somehow.
( Update: I was promised that this will be fixed in gtk. )
Still not sure how to implement stuff for opening windows on start-up.
Probably the best thing to do, would be to have a list of dialogs in
the preferences-dialog that should always be opened.
Dialogs are now reopened if the gimp is called with the command-line-option
--restore-session or if the related entry is set in gimprc.
Probably there should alternatively be a list of dialogs in the preferences
that should always be opened on start-up.
Please point me into the right direction to make this work with Gnome-SM.
*/
#include <stdlib.h>
@ -43,50 +47,69 @@
#include <unistd.h>
#include "appenv.h"
#include "commands.h"
#include "gimprc.h"
#include "session.h"
static void sessionrc_write_geometry (SessionGeometry *, FILE *);
static void sessionrc_write_info (SessionInfo *, FILE *);
static void session_open_dialog (SessionInfo *info);
static void session_reset_open_state (SessionInfo *info);
GList *session_geometry_updates = NULL;
GList *session_info_updates = NULL;
/* global session variables */
SessionGeometry toolbox_geometry = { "toolbox", 0, 0, 0, 0 };
SessionGeometry lc_dialog_geometry = { "lc-dialog", 0, 400, 0, 0 };
SessionGeometry info_dialog_geometry = { "info-dialog", 165, 0, 0, 0 };
SessionGeometry tool_options_geometry = { "tool-options", 0, 345, 0, 0 };
SessionGeometry palette_geometry = { "palette", 140, 180, 0, 0 };
SessionGeometry brush_select_geometry = { "brush-select", 150, 180, 0, 0 };
SessionGeometry pattern_select_geometry = { "pattern-select", 160, 180, 0, 0 };
SessionGeometry gradient_editor_geometry = { "gradient-editor", 170, 180, 0, 0 };
SessionInfo toolbox_session_info =
{ "toolbox", NULL, 0, 0, 0, 0, FALSE };
SessionInfo lc_dialog_session_info =
{ "lc-dialog", dialogs_lc_cmd_callback, 0, 400, 0, 0, FALSE };
SessionInfo info_dialog_session_info =
{ "info-dialog", NULL, 165, 0, 0, 0, FALSE };
SessionInfo tool_options_session_info =
{ "tool-options", dialogs_tools_options_cmd_callback, 0, 345, 0, 0, FALSE };
SessionInfo palette_session_info =
{ "palette", dialogs_palette_cmd_callback, 140, 180, 0, 0, FALSE };
SessionInfo brush_select_session_info =
{ "brush-select", dialogs_brushes_cmd_callback, 150, 180, 0, 0, FALSE };
SessionInfo pattern_select_session_info =
{ "pattern-select", dialogs_patterns_cmd_callback, 160, 180, 0, 0, FALSE };
SessionInfo gradient_editor_session_info =
{ "gradient-editor", dialogs_gradient_editor_cmd_callback, 170, 180, 0, 0, FALSE };
/* public functions */
void
session_get_window_geometry (GtkWidget *window,
SessionGeometry *geometry)
session_get_window_info (GtkWidget *window,
SessionInfo *info)
{
if ( !save_window_positions_on_exit || geometry == NULL || window->window == NULL )
if ( !save_session_info || info == NULL || window->window == NULL )
return;
gdk_window_get_origin (window->window, &geometry->x, &geometry->y);
gdk_window_get_size (window->window, &geometry->width, &geometry->height);
gdk_window_get_origin (window->window, &info->x, &info->y);
gdk_window_get_size (window->window, &info->width, &info->height);
if (g_list_find (session_geometry_updates, geometry) == NULL)
session_geometry_updates = g_list_append (session_geometry_updates, geometry);
/* This is a very ugly hack to work against the offset
introduced by window decorations.
The problem should be handled in gtk ... */
info->y += -20;
if ( we_are_exiting )
info->open = GTK_WIDGET_VISIBLE (window);
if ( g_list_find (session_info_updates, info) == NULL )
session_info_updates = g_list_append (session_info_updates, info);
}
void
session_set_window_geometry (GtkWidget *window,
SessionGeometry *geometry,
int set_size)
session_set_window_geometry (GtkWidget *window,
SessionInfo *info,
int set_size)
{
if ( window == NULL || geometry == NULL)
if ( window == NULL || info == NULL)
return;
gtk_widget_set_uposition (window, geometry->x, geometry->y);
gtk_widget_set_uposition (window, info->x, info->y);
if ( (set_size) && (geometry->width > 0) && (geometry->height > 0) )
gtk_widget_set_usize (window, geometry->width, geometry->height);
if ( (set_size) && (info->width > 0) && (info->height > 0) )
gtk_widget_set_usize (window, info->width, info->height);
}
void
@ -114,7 +137,7 @@ save_sessionrc (void)
fprintf(fp, "# are used.\n\n");
/* save window geometries */
g_list_foreach (session_geometry_updates, (GFunc)sessionrc_write_geometry, fp);
g_list_foreach (session_info_updates, (GFunc)sessionrc_write_info, fp);
/* save last tip shown */
fprintf(fp, "(last-tip-shown %d)\n\n", last_tip + 1);
@ -138,17 +161,48 @@ session_init (void)
}
}
void
session_restore (void)
{
/* open dialogs */
if (restore_session)
g_list_foreach (session_info_updates, (GFunc)session_open_dialog, NULL);
/* reset the open state in the session_infos */
g_list_foreach (session_info_updates, (GFunc)session_reset_open_state, NULL);
}
/* internal function */
static void
sessionrc_write_geometry (SessionGeometry *geometry, FILE *fp)
sessionrc_write_info (SessionInfo *info, FILE *fp)
{
if (fp == NULL || geometry == NULL)
if (fp == NULL || info == NULL)
return;
fprintf (fp,"(session-geometry \"%s\"\n", geometry->name);
fprintf (fp," (position %d %d)\n", geometry->x, geometry->y);
fprintf (fp," (size %d %d))\n\n", geometry->width, geometry->height);
fprintf (fp,"(session-info \"%s\"\n", info->name);
fprintf (fp," (position %d %d)\n", info->x, info->y);
fprintf (fp," (size %d %d)", info->width, info->height);
if ( info->open )
fprintf (fp,"\n (open-on-exit)");
fprintf (fp,")\n\n");
}
static void
session_open_dialog (SessionInfo *info)
{
if (info == NULL || info->open == FALSE)
return;
(info->open_callback) (NULL, NULL);
}
static void
session_reset_open_state (SessionInfo *info)
{
if (info == NULL )
return;
info->open = FALSE;
}
@ -159,4 +213,3 @@ sessionrc_write_geometry (SessionGeometry *geometry, FILE *fp)

View File

@ -21,38 +21,41 @@
#include <glib.h>
/* Structures */
typedef struct _SessionGeometry SessionGeometry;
typedef struct _SessionInfo SessionInfo;
struct _SessionGeometry
struct _SessionInfo
{
char name[16];
char name[16];
GtkItemFactoryCallback open_callback;
int x;
int y;
int width;
int height;
int open;
};
/* global session variables */
extern SessionGeometry toolbox_geometry;
extern SessionGeometry lc_dialog_geometry;
extern SessionGeometry info_dialog_geometry;
extern SessionGeometry tool_options_geometry;
extern SessionGeometry palette_geometry;
extern SessionGeometry brush_select_geometry;
extern SessionGeometry pattern_select_geometry;
extern SessionGeometry gradient_editor_geometry;
extern SessionInfo toolbox_session_info;
extern SessionInfo lc_dialog_session_info;
extern SessionInfo info_dialog_session_info;
extern SessionInfo tool_options_session_info;
extern SessionInfo palette_session_info;
extern SessionInfo brush_select_session_info;
extern SessionInfo pattern_select_session_info;
extern SessionInfo gradient_editor_session_info;
extern GList *session_geometry_updates; /* This list holds all geometries
that should be written to the
sessionrc on exit. */
extern GList *session_info_updates; /* This list holds all session_infos
that should be written to the
sessionrc on exit. */
/* function prototypes */
void session_get_window_geometry (GtkWidget *window,
SessionGeometry *geometry);
void session_set_window_geometry (GtkWidget *window,
SessionGeometry *geometry,
int set_size);
void session_get_window_info (GtkWidget *window,
SessionInfo *info);
void session_set_window_geometry (GtkWidget *window,
SessionInfo *info,
int set_size);
void session_init (void);
void session_restore (void);
void save_sessionrc (void);
#endif /* __SESSION_H__ */

View File

@ -702,7 +702,7 @@ tools_options_dialog_new ()
gtk_window_set_wmclass (GTK_WINDOW (options_shell), "tool_options", "Gimp");
gtk_window_set_title (GTK_WINDOW (options_shell), "Tool Options");
gtk_window_set_policy (GTK_WINDOW (options_shell), FALSE, TRUE, TRUE);
session_set_window_geometry (options_shell, &tool_options_geometry, FALSE );
session_set_window_geometry (options_shell, &tool_options_session_info, FALSE );
options_vbox = gtk_vbox_new (FALSE, 2);
gtk_container_border_width (GTK_CONTAINER (options_vbox), 2);
@ -741,7 +741,7 @@ tools_options_dialog_show ()
void
tools_options_dialog_free ()
{
session_get_window_geometry (options_shell, &tool_options_geometry);
session_get_window_info (options_shell, &tool_options_session_info);
gtk_widget_destroy (options_shell);
}

View File

@ -702,7 +702,7 @@ tools_options_dialog_new ()
gtk_window_set_wmclass (GTK_WINDOW (options_shell), "tool_options", "Gimp");
gtk_window_set_title (GTK_WINDOW (options_shell), "Tool Options");
gtk_window_set_policy (GTK_WINDOW (options_shell), FALSE, TRUE, TRUE);
session_set_window_geometry (options_shell, &tool_options_geometry, FALSE );
session_set_window_geometry (options_shell, &tool_options_session_info, FALSE );
options_vbox = gtk_vbox_new (FALSE, 2);
gtk_container_border_width (GTK_CONTAINER (options_vbox), 2);
@ -741,7 +741,7 @@ tools_options_dialog_show ()
void
tools_options_dialog_free ()
{
session_get_window_geometry (options_shell, &tool_options_geometry);
session_get_window_info (options_shell, &tool_options_session_info);
gtk_widget_destroy (options_shell);
}

View File

@ -790,7 +790,7 @@ 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");
session_set_window_geometry (g_editor->shell, &gradient_editor_geometry, TRUE);
session_set_window_geometry (g_editor->shell, &gradient_editor_session_info, TRUE);
/* handle window manager close signals */
gtk_signal_connect (GTK_OBJECT (g_editor->shell), "delete_event",
@ -1067,7 +1067,7 @@ grad_free_gradient_editor(void)
/* FIXME */
if (g_editor)
session_get_window_geometry (g_editor->shell, &gradient_editor_geometry);
session_get_window_info (g_editor->shell, &gradient_editor_session_info);
} /* grad_free_gradient_editor */

View File

@ -173,7 +173,7 @@ palette_create ()
/* The shell and main vbox */
palette->shell = gtk_dialog_new ();
gtk_window_set_wmclass (GTK_WINDOW (palette->shell), "color_palette", "Gimp");
session_set_window_geometry (palette->shell, &palette_geometry, FALSE);
session_set_window_geometry (palette->shell, &palette_session_info, FALSE);
gtk_window_set_policy (GTK_WINDOW (palette->shell), FALSE, FALSE, FALSE);
gtk_window_set_title (GTK_WINDOW (palette->shell), "Color Palette");
vbox = gtk_vbox_new (FALSE, 1);
@ -298,7 +298,7 @@ palette_free ()
if (palette->color_select)
color_select_free (palette->color_select);
session_get_window_geometry (palette->shell, &palette_geometry);
session_get_window_info (palette->shell, &palette_session_info);
g_free (palette);

View File

@ -169,7 +169,11 @@
# By default GIMP remembers the positions and sizes of the main dialogs and
# advices your window-manager to place them there again the next time you
# use the GIMP. To disable this behaviour, uncomment the line below...
# (dont-save-window-positions-on-exit)
# (dont-save-session-info)
# To let GIMP try to restore your last saved session,
# uncomment the line below...
# (always-restore-session)
# Setting the level of interpolation
# Uncommenting this line will enable cubic interpolation.

View File

@ -169,7 +169,11 @@
# By default GIMP remembers the positions and sizes of the main dialogs and
# advices your window-manager to place them there again the next time you
# use the GIMP. To disable this behaviour, uncomment the line below...
# (dont-save-window-positions-on-exit)
# (dont-save-session-info)
# To let GIMP try to restore your last saved session,
# uncomment the line below...
# (always-restore-session)
# Setting the level of interpolation
# Uncommenting this line will enable cubic interpolation.