gimp/app/gui/session.c

123 lines
3.2 KiB
C
Raw Normal View History

/* 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.
*/
/* 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:
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. Restoring
openend images is planned, but I'm still not sure how to deal with dirty
images.
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.
*/
1999-03-07 20:56:03 +08:00
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
1999-03-07 20:56:03 +08:00
#ifdef HAVE_UNISTD_H
#include <unistd.h>
1999-03-07 20:56:03 +08:00
#endif
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "apptypes.h"
#include "widgets/widgets-types.h"
#include "widgets/gimpdialogfactory.h"
app/Makefile.am app/gui/Makefile.am app/about_dialog.[ch] 2001-04-17 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gui/Makefile.am * app/about_dialog.[ch] * app/brush_edit.[ch] * app/brush_select.[ch] * app/channels_dialog.[ch] * app/color_area.[ch] * app/color_notebook.[ch] * app/color_select.[ch] * app/colormap_dialog.[ch] * app/commands.[ch] * app/file_new_dialog.[ch] * app/gradient_editor.[ch] * app/gradient_select.[ch] * app/indicator_area.[ch] * app/info_dialog.[ch] * app/info_window.[ch] * app/layer_select.[ch] * app/layers_dialog.[ch] * app/menus.[ch] * app/palette.[ch] * app/palette_import.[ch] * app/palette_select.[ch] * app/paths_dialog.[ch] * app/pattern_select.[ch] * app/preferences_dialog.[ch] * app/session.[ch] * app/test_commands.[ch] * app/tips_dialog.[ch] * app/toolbox.[ch]: moved to gui/ (s/_/-/ and some more useful filenames on the way). * app/app_procs.c * app/context_manager.c * app/convert.c * app/disp_callbacks.c * app/errorconsole.c * app/file-open.c * app/file-save.c * app/file-utils.c * app/gdisplay.c * app/gimage.c * app/gimprc.c * app/image_new.c * app/interface.c * app/nav_window.c * app/path.c * app/plug_in.c * app/gui/dialogs-constructors.c * app/pdb/brush_select_cmds.c * app/pdb/convert_cmds.c * app/pdb/gradient_select_cmds.c * app/pdb/pattern_select_cmds.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimpscaletool.c * app/tools/gimptransformtool.c * app/widgets/gimpcolorpanel.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/pattern_select.pdb * po/POTFILES.in: changed accordingly.
2001-04-18 05:43:29 +08:00
#include "color-notebook.h"
#include "session.h"
#include "app_procs.h"
#include "appenv.h"
#include "gimprc.h"
/* public functions */
void
session_init (void)
{
gchar *filename;
filename = gimp_personal_rc_file ("sessionrc");
app_init_update_status (NULL, filename, -1);
removed the gimp_busy boolean, check whether user_installation is needed 2001-07-10 Michael Natterer <mitch@gimp.org> * app/app_procs.[ch]: removed the gimp_busy boolean, check whether user_installation is needed here, not in user_install.c, parse gtkrc an friends only if(!no_interface), create the Gimp object before parsing gimp's rc files an pas it to the parse functions, many other cleanups. * app/appenums.h: added MessageHandlerType and StackTraceMode. * app/appenv.h: removed MessageHandlerType, declare all global variables from main.c (no more hidden global stuff please). * app/errors.[ch]: added the fatal message func here (from main.c), removed the StackTraceMode enum. * app/gimprc.[ch]: renamed functions to gimprc_*(), pass a Gimp pointer to some functions. * app/gimpunit.c * app/unitrc.h: ok, this is ugly: renamed all functions to _gimp_unit_*() and made them public. The unit list is part of the Gimp object now, so pass a Gimp* to all functions. * app/libgimp_glue.[ch]: added EEKy wrappers for all gimp_unit_*() functions which are used by widgets. * app/main.c: cleaned up the global variables, removed the fatal message handler, call app_init() directly, not via the user_install stuff, misc. cleanups. * app/user_install.[ch]: removed the check if user_installation is needed (done by app_procs.c now). * app/core/gimp.[ch]: added the user_unit list and the "busy" boolean. Moved gimp_[set|unset]_busy() here. Added gimp_initialize() which is called after unitrc and gimprc are parsed. * app/batch.c * app/colormaps.c * app/devices.c * app/disp_callbacks.c * app/gdisplay_ops.c * app/gimphelp.c * app/module_db.c * app/nav_window.c * app/plug_in.c * app/core/gimpcontext.c * app/core/gimpdatafiles.c * app/core/gimpimage-convert.c * app/core/gimpimage-duplicate.c * app/core/gimpimage.c * app/core/gimpparasite.c * app/core/gimpparasitelist.h * app/gui/file-open-dialog.c * app/gui/gui.[ch] * app/gui/info-dialog.c * app/gui/info-window.c * app/gui/preferences-dialog.c * app/gui/session.c * app/gui/tips-dialog.c * app/gui/toolbox.c * app/tools/gimpblendtool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimptransformtool.c * app/tools/tool_manager.c * app/widgets/gimpcolorpanel.c * app/widgets/gimpcursor.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * app/xcf/xcf.c * tools/pdbgen/Makefile.am * tools/pdbgen/app.pl * tools/pdbgen/enums.pl * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/message.pdb * tools/pdbgen/pdb/unit.pdb * app/pdb/image_cmds.c * app/pdb/message_cmds.c * app/pdb/unit_cmds.c: changed accordingly, minor cleanups.
2001-07-11 03:16:16 +08:00
if (! gimprc_parse_file (filename))
{
/* always show L&C&P, Tool Options and Brushes on first invocation */
/* TODO */
}
g_free (filename);
}
void
session_restore (void)
{
if (restore_session)
gimp_dialog_factories_session_restore ();
}
void
session_save (void)
{
gchar *filename;
FILE *fp;
1999-03-07 20:56:03 +08:00
filename = gimp_personal_rc_file ("sessionrc");
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;
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"));
gimp_dialog_factories_session_save (fp);
1999-03-07 20:56:03 +08:00
/* save last tip shown */
fprintf (fp, "(last-tip-shown %d)\n\n", gimprc.last_tip + 1);
color_history_write (fp);
1999-03-07 20:56:03 +08:00
fclose (fp);
}