1998-06-22 17:30:40 +00:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
1998-07-11 22:23:23 +00:00
|
|
|
/* Session-managment stuff Copyright (C) 1998 Sven Neumann <sven@gimp.org>
|
1998-06-22 17:30:40 +00:00
|
|
|
|
|
|
|
I include a short description here on what is done and what problems
|
1998-07-11 22:23:23 +00:00
|
|
|
are left:
|
1998-06-22 17:30:40 +00:00
|
|
|
|
1998-06-23 22:50:16 +00:00
|
|
|
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.
|
|
|
|
|
1998-07-11 22:23:23 +00:00
|
|
|
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.
|
1998-06-22 17:30:40 +00:00
|
|
|
|
1998-07-11 22:23:23 +00:00
|
|
|
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.
|
1998-06-22 17:30:40 +00:00
|
|
|
*/
|
|
|
|
|
1999-03-07 12:56:03 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
1998-06-22 17:30:40 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
1999-03-07 12:56:03 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
1998-06-22 17:30:40 +00:00
|
|
|
#include <unistd.h>
|
1999-03-07 12:56:03 +00:00
|
|
|
#endif
|
1998-06-22 17:30:40 +00:00
|
|
|
|
1998-07-19 12:02:29 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-05-21 20:30:16 +00:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-04-17 16:00:27 +00:00
|
|
|
|
2000-12-16 21:37:03 +00:00
|
|
|
#include "apptypes.h"
|
2001-05-08 03:48:54 +00:00
|
|
|
#include "widgets/widgets-types.h"
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2001-04-16 18:49:29 +00:00
|
|
|
#include "widgets/gimpdialogfactory.h"
|
|
|
|
|
2001-04-17 21:43:29 +00:00
|
|
|
#include "color-notebook.h"
|
|
|
|
#include "session.h"
|
|
|
|
|
1998-07-23 14:05:55 +00:00
|
|
|
#include "app_procs.h"
|
1998-06-22 17:30:40 +00:00
|
|
|
#include "appenv.h"
|
|
|
|
#include "gimprc.h"
|
|
|
|
|
2000-02-12 15:01:33 +00:00
|
|
|
|
1998-06-22 17:30:40 +00:00
|
|
|
|
2001-01-16 14:47:09 +00:00
|
|
|
/* public functions */
|
|
|
|
|
2001-04-17 16:00:27 +00:00
|
|
|
void
|
|
|
|
session_init (void)
|
1998-06-22 17:30:40 +00:00
|
|
|
{
|
2001-04-17 16:00:27 +00:00
|
|
|
gchar *filename;
|
1998-07-11 22:23:23 +00:00
|
|
|
|
2001-04-17 16:00:27 +00:00
|
|
|
filename = gimp_personal_rc_file ("sessionrc");
|
|
|
|
app_init_update_status (NULL, filename, -1);
|
2000-03-24 22:10:28 +00:00
|
|
|
|
2001-04-17 16:00:27 +00:00
|
|
|
if (! parse_gimprc_file (filename))
|
2000-03-24 22:10:28 +00:00
|
|
|
{
|
2001-04-17 16:00:27 +00:00
|
|
|
/* always show L&C&P, Tool Options and Brushes on first invocation */
|
1998-06-22 17:30:40 +00:00
|
|
|
|
2001-04-17 16:00:27 +00:00
|
|
|
/* TODO */
|
2000-03-24 22:10:28 +00:00
|
|
|
}
|
|
|
|
|
2001-04-17 16:00:27 +00:00
|
|
|
g_free (filename);
|
|
|
|
}
|
2000-03-24 22:10:28 +00:00
|
|
|
|
2001-04-17 16:00:27 +00:00
|
|
|
void
|
|
|
|
session_restore (void)
|
|
|
|
{
|
|
|
|
if (restore_session)
|
|
|
|
gimp_dialog_factories_session_restore ();
|
1998-06-22 17:30:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-04-17 16:00:27 +00:00
|
|
|
session_save (void)
|
1998-06-22 17:30:40 +00:00
|
|
|
{
|
2000-02-12 15:01:33 +00:00
|
|
|
gchar *filename;
|
|
|
|
FILE *fp;
|
1998-06-22 17:30:40 +00:00
|
|
|
|
1999-03-07 12:56:03 +00:00
|
|
|
filename = gimp_personal_rc_file ("sessionrc");
|
1998-06-22 17:30:40 +00:00
|
|
|
|
1999-06-27 17:37:47 +00:00
|
|
|
fp = fopen (filename, "wt");
|
1999-03-07 12:56:03 +00:00
|
|
|
g_free (filename);
|
|
|
|
if (!fp)
|
|
|
|
return;
|
1998-06-23 22:50:16 +00:00
|
|
|
|
2000-02-12 15:01:33 +00:00
|
|
|
fprintf (fp, ("# GIMP sessionrc\n"
|
|
|
|
"# This file takes session-specific info (that is info,\n"
|
|
|
|
"# you want to keep between two gimp-sessions). You are\n"
|
|
|
|
"# not supposed to edit it manually, but of course you\n"
|
|
|
|
"# can do. This file will be entirely rewritten every time\n"
|
|
|
|
"# you quit the gimp. If this file isn't found, defaults\n"
|
|
|
|
"# are used.\n\n"));
|
|
|
|
|
2001-04-16 18:49:29 +00:00
|
|
|
gimp_dialog_factories_session_save (fp);
|
|
|
|
|
1999-03-07 12:56:03 +00:00
|
|
|
/* save last tip shown */
|
2001-06-03 20:40:50 +00:00
|
|
|
fprintf (fp, "(last-tip-shown %d)\n\n", gimprc.last_tip + 1);
|
2001-01-16 14:47:09 +00:00
|
|
|
|
|
|
|
color_history_write (fp);
|
2000-02-12 15:01:33 +00:00
|
|
|
|
1999-03-07 12:56:03 +00:00
|
|
|
fclose (fp);
|
1998-06-22 17:30:40 +00:00
|
|
|
}
|