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>
|
|
|
|
|
1998-07-23 22:05:55 +08:00
|
|
|
#include "app_procs.h"
|
1998-06-23 01:30:40 +08:00
|
|
|
#include "appenv.h"
|
1998-07-12 06:23:23 +08:00
|
|
|
#include "commands.h"
|
1998-06-23 01:30:40 +08:00
|
|
|
#include "gimprc.h"
|
|
|
|
#include "session.h"
|
|
|
|
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
1999-03-07 20:56:03 +08:00
|
|
|
#include "libgimp/gimpenv.h"
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
|
1998-07-12 06:23:23 +08:00
|
|
|
static void sessionrc_write_info (SessionInfo *, FILE *);
|
1998-07-23 07:55:43 +08:00
|
|
|
static void session_open_dialog (SessionInfo *);
|
|
|
|
static void session_reset_open_state (SessionInfo *);
|
1998-06-23 01:30:40 +08:00
|
|
|
|
1998-07-12 06:23:23 +08:00
|
|
|
GList *session_info_updates = NULL;
|
1998-06-23 01:30:40 +08:00
|
|
|
|
|
|
|
/* global session variables */
|
1998-07-12 06:23:23 +08:00
|
|
|
SessionInfo toolbox_session_info =
|
|
|
|
{ "toolbox", NULL, 0, 0, 0, 0, FALSE };
|
|
|
|
SessionInfo lc_dialog_session_info =
|
1998-07-19 20:02:29 +08:00
|
|
|
{ "lc-dialog", (GtkItemFactoryCallback)dialogs_lc_cmd_callback, 0, 400, 0, 0, FALSE };
|
1998-07-12 06:23:23 +08:00
|
|
|
SessionInfo info_dialog_session_info =
|
|
|
|
{ "info-dialog", NULL, 165, 0, 0, 0, FALSE };
|
|
|
|
SessionInfo tool_options_session_info =
|
1998-07-19 20:02:29 +08:00
|
|
|
{ "tool-options", (GtkItemFactoryCallback)dialogs_tools_options_cmd_callback, 0, 345, 0, 0, FALSE };
|
1998-07-12 06:23:23 +08:00
|
|
|
SessionInfo palette_session_info =
|
1998-07-19 20:02:29 +08:00
|
|
|
{ "palette", (GtkItemFactoryCallback)dialogs_palette_cmd_callback, 140, 180, 0, 0, FALSE };
|
1998-07-12 06:23:23 +08:00
|
|
|
SessionInfo brush_select_session_info =
|
1998-07-19 20:02:29 +08:00
|
|
|
{ "brush-select", (GtkItemFactoryCallback)dialogs_brushes_cmd_callback, 150, 180, 0, 0, FALSE };
|
1998-07-12 06:23:23 +08:00
|
|
|
SessionInfo pattern_select_session_info =
|
1998-07-19 20:02:29 +08:00
|
|
|
{ "pattern-select", (GtkItemFactoryCallback)dialogs_patterns_cmd_callback, 160, 180, 0, 0, FALSE };
|
1998-11-01 00:22:37 +08:00
|
|
|
SessionInfo gradient_select_session_info =
|
1998-07-19 20:02:29 +08:00
|
|
|
{ "gradient-editor", (GtkItemFactoryCallback)dialogs_gradient_editor_cmd_callback, 170, 180, 0, 0, FALSE };
|
1998-07-21 08:15:24 +08:00
|
|
|
SessionInfo device_status_session_info =
|
|
|
|
{ "device-status", (GtkItemFactoryCallback)dialogs_device_status_cmd_callback, 0, 600, 0, 0, FALSE };
|
1998-08-03 03:05:02 +08:00
|
|
|
SessionInfo error_console_session_info =
|
|
|
|
{ "error-console", (GtkItemFactoryCallback)dialogs_error_console_cmd_callback, 400, 0, 250, 300, FALSE };
|
1998-06-23 01:30:40 +08:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
void
|
1998-07-12 06:23:23 +08:00
|
|
|
session_get_window_info (GtkWidget *window,
|
|
|
|
SessionInfo *info)
|
1998-06-23 01:30:40 +08:00
|
|
|
{
|
1998-07-12 06:23:23 +08:00
|
|
|
if ( !save_session_info || info == NULL || window->window == NULL )
|
1998-06-23 01:30:40 +08:00
|
|
|
return;
|
|
|
|
|
1998-11-09 23:23:29 +08:00
|
|
|
gdk_window_get_root_origin (window->window, &info->x, &info->y);
|
1998-07-12 06:23:23 +08:00
|
|
|
gdk_window_get_size (window->window, &info->width, &info->height);
|
|
|
|
|
|
|
|
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);
|
1998-06-23 01:30:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-07-12 06:23:23 +08:00
|
|
|
session_set_window_geometry (GtkWidget *window,
|
|
|
|
SessionInfo *info,
|
|
|
|
int set_size)
|
1998-06-23 01:30:40 +08:00
|
|
|
{
|
1998-07-12 06:23:23 +08:00
|
|
|
if ( window == NULL || info == NULL)
|
1998-06-23 01:30:40 +08:00
|
|
|
return;
|
|
|
|
|
1999-06-15 06:18:02 +08:00
|
|
|
#if defined(GDK_WINDOWING) && (GDK_WINDOWING == GDK_WINDOWING_WIN32)
|
1999-03-07 20:56:03 +08:00
|
|
|
/* We should not position windows so that no decoration is visible */
|
|
|
|
if (info->y > 0)
|
|
|
|
gtk_widget_set_uposition (window, info->x, info->y);
|
|
|
|
#else
|
1998-07-12 06:23:23 +08:00
|
|
|
gtk_widget_set_uposition (window, info->x, info->y);
|
1999-03-07 20:56:03 +08:00
|
|
|
#endif
|
1998-06-23 01:30:40 +08:00
|
|
|
|
1998-07-12 06:23:23 +08:00
|
|
|
if ( (set_size) && (info->width > 0) && (info->height > 0) )
|
1998-12-19 22:22:35 +08:00
|
|
|
gtk_window_set_default_size (GTK_WINDOW(window), info->width, info->height);
|
1998-06-23 01:30:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
save_sessionrc (void)
|
|
|
|
{
|
1999-03-07 20:56:03 +08:00
|
|
|
char *filename;
|
1998-06-23 01:30:40 +08:00
|
|
|
FILE *fp;
|
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
filename = gimp_personal_rc_file ("sessionrc");
|
1998-06-23 01:30:40 +08:00
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
fp = fopen (filename, "w");
|
|
|
|
g_free (filename);
|
|
|
|
if (!fp)
|
|
|
|
return;
|
1998-06-24 06:50:16 +08:00
|
|
|
|
1999-05-30 00:35:47 +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"));
|
1999-03-07 20:56:03 +08:00
|
|
|
|
|
|
|
/* save window geometries */
|
|
|
|
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);
|
|
|
|
|
|
|
|
fclose (fp);
|
1998-06-23 01:30:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
session_init (void)
|
|
|
|
{
|
1999-06-02 00:43:46 +08:00
|
|
|
gchar *filename;
|
1998-06-23 01:30:40 +08:00
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
filename = gimp_personal_rc_file ("sessionrc");
|
1999-06-02 00:43:46 +08:00
|
|
|
app_init_update_status (NULL, filename, -1);
|
|
|
|
|
|
|
|
/* always show L&C and Brushes on first invocation */
|
|
|
|
if (! parse_gimprc_file (filename) && save_session_info)
|
|
|
|
{
|
|
|
|
lc_dialog_session_info.open = TRUE;
|
|
|
|
session_info_updates =
|
|
|
|
g_list_append (session_info_updates, &lc_dialog_session_info);
|
|
|
|
|
|
|
|
brush_select_session_info.open = TRUE;
|
|
|
|
session_info_updates =
|
|
|
|
g_list_append (session_info_updates, &brush_select_session_info);
|
|
|
|
}
|
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
g_free (filename);
|
1998-06-23 01:30:40 +08:00
|
|
|
}
|
|
|
|
|
1998-07-12 06:23:23 +08:00
|
|
|
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);
|
|
|
|
}
|
1998-06-23 01:30:40 +08:00
|
|
|
|
|
|
|
/* internal function */
|
|
|
|
static void
|
1998-07-12 06:23:23 +08:00
|
|
|
sessionrc_write_info (SessionInfo *info, FILE *fp)
|
1998-06-23 01:30:40 +08:00
|
|
|
{
|
1998-07-12 06:23:23 +08:00
|
|
|
if (fp == NULL || info == NULL)
|
1998-06-23 01:30:40 +08:00
|
|
|
return;
|
|
|
|
|
1998-07-12 06:23:23 +08:00
|
|
|
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
|
1998-07-23 07:55:43 +08:00
|
|
|
session_open_dialog (SessionInfo *info)
|
1998-07-12 06:23:23 +08:00
|
|
|
{
|
1999-04-03 03:46:59 +08:00
|
|
|
if (info == NULL || info->open == FALSE || info->open_callback == NULL)
|
1998-07-12 06:23:23 +08:00
|
|
|
return;
|
|
|
|
|
1998-07-19 20:02:29 +08:00
|
|
|
(info->open_callback) ();
|
1998-06-23 01:30:40 +08:00
|
|
|
}
|
|
|
|
|
1998-07-12 06:23:23 +08:00
|
|
|
static void
|
|
|
|
session_reset_open_state (SessionInfo *info)
|
|
|
|
{
|
|
|
|
if (info == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
info->open = FALSE;
|
|
|
|
}
|