1998-06-23 01:30:40 +08: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-12 06:23:23 +08:00
|
|
|
/* Session-managment stuff Copyright (C) 1998 Sven Neumann <sven@gimp.org>
|
1998-06-23 01:30:40 +08:00
|
|
|
|
|
|
|
I include a short description here on what is done and what problems
|
1998-07-12 06:23:23 +08:00
|
|
|
are left:
|
1998-06-23 01:30:40 +08:00
|
|
|
|
1998-06-24 06:50:16 +08: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-12 06:23:23 +08: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-23 01:30:40 +08:00
|
|
|
|
1998-07-12 06:23:23 +08: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-23 01:30:40 +08:00
|
|
|
*/
|
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1998-06-23 01:30:40 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
1999-03-07 20:56:03 +08:00
|
|
|
#ifdef HAVE_UNISTD_H
|
1998-06-23 01:30:40 +08:00
|
|
|
#include <unistd.h>
|
1999-03-07 20:56:03 +08:00
|
|
|
#endif
|
1998-06-23 01:30:40 +08:00
|
|
|
|
1998-07-19 20:02:29 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-05-22 04:30:16 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-04-18 00:00:27 +08:00
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include "apptypes.h"
|
2001-05-08 11:48:54 +08:00
|
|
|
#include "widgets/widgets-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-04-17 02:49:29 +08:00
|
|
|
#include "widgets/gimpdialogfactory.h"
|
|
|
|
|
2001-04-18 05:43:29 +08:00
|
|
|
#include "color-notebook.h"
|
|
|
|
#include "session.h"
|
|
|
|
|
1998-07-23 22:05:55 +08:00
|
|
|
#include "app_procs.h"
|
1998-06-23 01:30:40 +08:00
|
|
|
#include "appenv.h"
|
|
|
|
#include "gimprc.h"
|
|
|
|
|
2000-02-12 23:01:33 +08:00
|
|
|
|
1998-06-23 01:30:40 +08:00
|
|
|
|
2001-01-16 22:47:09 +08:00
|
|
|
/* public functions */
|
|
|
|
|
2001-04-18 00:00:27 +08:00
|
|
|
void
|
|
|
|
session_init (void)
|
1998-06-23 01:30:40 +08:00
|
|
|
{
|
2001-04-18 00:00:27 +08:00
|
|
|
gchar *filename;
|
1998-07-12 06:23:23 +08:00
|
|
|
|
2001-04-18 00:00:27 +08:00
|
|
|
filename = gimp_personal_rc_file ("sessionrc");
|
|
|
|
app_init_update_status (NULL, filename, -1);
|
2000-03-25 06:10:28 +08:00
|
|
|
|
2001-04-18 00:00:27 +08:00
|
|
|
if (! parse_gimprc_file (filename))
|
2000-03-25 06:10:28 +08:00
|
|
|
{
|
2001-04-18 00:00:27 +08:00
|
|
|
/* always show L&C&P, Tool Options and Brushes on first invocation */
|
1998-06-23 01:30:40 +08:00
|
|
|
|
2001-04-18 00:00:27 +08:00
|
|
|
/* TODO */
|
2000-03-25 06:10:28 +08:00
|
|
|
}
|
|
|
|
|
2001-04-18 00:00:27 +08:00
|
|
|
g_free (filename);
|
|
|
|
}
|
2000-03-25 06:10:28 +08:00
|
|
|
|
2001-04-18 00:00:27 +08:00
|
|
|
void
|
|
|
|
session_restore (void)
|
|
|
|
{
|
|
|
|
if (restore_session)
|
|
|
|
gimp_dialog_factories_session_restore ();
|
1998-06-23 01:30:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-04-18 00:00:27 +08:00
|
|
|
session_save (void)
|
1998-06-23 01:30:40 +08:00
|
|
|
{
|
2000-02-12 23:01:33 +08:00
|
|
|
gchar *filename;
|
|
|
|
FILE *fp;
|
1998-06-23 01:30:40 +08:00
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
filename = gimp_personal_rc_file ("sessionrc");
|
1998-06-23 01:30:40 +08:00
|
|
|
|
1999-06-28 01:37:47 +08:00
|
|
|
fp = fopen (filename, "wt");
|
1999-03-07 20:56:03 +08:00
|
|
|
g_free (filename);
|
|
|
|
if (!fp)
|
|
|
|
return;
|
1998-06-24 06:50:16 +08:00
|
|
|
|
2000-02-12 23:01:33 +08: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-17 02:49:29 +08:00
|
|
|
gimp_dialog_factories_session_save (fp);
|
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
/* save last tip shown */
|
2001-01-16 22:47:09 +08:00
|
|
|
fprintf (fp, "(last-tip-shown %d)\n\n", last_tip + 1);
|
|
|
|
|
|
|
|
color_history_write (fp);
|
2000-02-12 23:01:33 +08:00
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
fclose (fp);
|
1998-06-23 01:30:40 +08:00
|
|
|
}
|