2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1998-06-23 01:30:40 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2001-12-18 20:39:45 +08:00
|
|
|
* Session-managment stuff
|
|
|
|
* Copyright (C) 1998 Sven Neumann <sven@gimp.org>
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1998-06-23 01:30:40 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1998-06-23 01:30:40 +08:00
|
|
|
* (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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1998-06-23 01:30:40 +08:00
|
|
|
*/
|
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1998-07-19 20:02:29 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-05-22 04:30:16 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2005-01-26 03:11:26 +08:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2001-04-18 00:00:27 +08:00
|
|
|
|
2001-08-17 22:27:31 +08:00
|
|
|
#include "gui-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2005-01-25 06:41:24 +08:00
|
|
|
#include "config/gimpconfig-file.h"
|
2002-11-19 04:50:31 +08:00
|
|
|
#include "config/gimpguiconfig.h"
|
|
|
|
|
2001-10-24 00:23:32 +08:00
|
|
|
#include "core/gimp.h"
|
2014-07-02 01:54:50 +08:00
|
|
|
#include "core/gimperror.h"
|
2001-10-24 00:23:32 +08:00
|
|
|
|
2001-04-17 02:49:29 +08:00
|
|
|
#include "widgets/gimpdialogfactory.h"
|
2003-10-10 23:59:12 +08:00
|
|
|
#include "widgets/gimpsessioninfo.h"
|
2014-05-02 19:23:25 +08:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2008-05-17 00:06:42 +08:00
|
|
|
#include "dialogs/dialogs.h"
|
|
|
|
|
2001-04-18 05:43:29 +08:00
|
|
|
#include "session.h"
|
2009-09-21 01:08:48 +08:00
|
|
|
#include "gimp-log.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2002-06-03 03:48:01 +08:00
|
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
SESSION_INFO = 1,
|
2011-11-06 00:52:45 +08:00
|
|
|
HIDE_DOCKS,
|
|
|
|
SINGLE_WINDOW_MODE,
|
2013-09-15 18:56:17 +08:00
|
|
|
TABS_POSITION,
|
2003-10-10 23:59:12 +08:00
|
|
|
LAST_TIP_SHOWN
|
|
|
|
};
|
2002-06-03 03:48:01 +08:00
|
|
|
|
2003-03-11 03:01:07 +08:00
|
|
|
|
2014-07-02 01:54:50 +08:00
|
|
|
static GFile * session_file (Gimp *gimp);
|
2003-11-13 22:14:20 +08:00
|
|
|
|
|
|
|
|
2004-07-22 00:11:31 +08:00
|
|
|
/* private variables */
|
|
|
|
|
|
|
|
static gboolean sessionrc_deleted = FALSE;
|
|
|
|
|
|
|
|
|
2003-10-10 23:59:12 +08:00
|
|
|
/* public functions */
|
2002-06-03 03:48:01 +08:00
|
|
|
|
2001-04-18 00:00:27 +08:00
|
|
|
void
|
2001-10-24 00:23:32 +08:00
|
|
|
session_init (Gimp *gimp)
|
1998-06-23 01:30:40 +08:00
|
|
|
{
|
2014-07-02 01:54:50 +08:00
|
|
|
GFile *file;
|
2002-06-03 03:48:01 +08:00
|
|
|
GScanner *scanner;
|
|
|
|
GTokenType token;
|
|
|
|
GError *error = NULL;
|
1998-07-12 06:23:23 +08:00
|
|
|
|
2001-10-24 00:23:32 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
2014-07-02 01:54:50 +08:00
|
|
|
file = session_file (gimp);
|
2003-11-13 22:14:20 +08:00
|
|
|
|
2014-07-02 01:54:50 +08:00
|
|
|
scanner = gimp_scanner_new_gfile (file, &error);
|
2000-03-25 06:10:28 +08:00
|
|
|
|
2003-11-05 05:58:39 +08:00
|
|
|
if (! scanner && error->code == GIMP_CONFIG_ERROR_OPEN_ENOENT)
|
|
|
|
{
|
|
|
|
g_clear_error (&error);
|
2014-07-02 01:54:50 +08:00
|
|
|
g_object_unref (file);
|
2003-11-05 05:58:39 +08:00
|
|
|
|
2014-07-28 08:04:01 +08:00
|
|
|
file = gimp_sysconf_directory_file ("sessionrc", NULL);
|
2014-07-02 01:54:50 +08:00
|
|
|
|
|
|
|
scanner = gimp_scanner_new_gfile (file, NULL);
|
2003-11-05 05:58:39 +08:00
|
|
|
}
|
|
|
|
|
2002-06-03 03:48:01 +08:00
|
|
|
if (! scanner)
|
2000-03-25 06:10:28 +08:00
|
|
|
{
|
2003-11-05 05:58:39 +08:00
|
|
|
g_clear_error (&error);
|
2014-07-02 01:54:50 +08:00
|
|
|
g_object_unref (file);
|
2002-06-03 03:48:01 +08:00
|
|
|
return;
|
2000-03-25 06:10:28 +08:00
|
|
|
}
|
|
|
|
|
2005-11-07 06:01:25 +08:00
|
|
|
if (gimp->be_verbose)
|
2014-07-02 01:54:50 +08:00
|
|
|
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
|
2005-11-07 06:01:25 +08:00
|
|
|
|
2002-06-03 03:48:01 +08:00
|
|
|
g_scanner_scope_add_symbol (scanner, 0, "session-info",
|
|
|
|
GINT_TO_POINTER (SESSION_INFO));
|
2011-11-06 00:52:45 +08:00
|
|
|
g_scanner_scope_add_symbol (scanner, 0, "hide-docks",
|
|
|
|
GINT_TO_POINTER (HIDE_DOCKS));
|
|
|
|
g_scanner_scope_add_symbol (scanner, 0, "single-window-mode",
|
|
|
|
GINT_TO_POINTER (SINGLE_WINDOW_MODE));
|
2013-09-15 18:56:17 +08:00
|
|
|
g_scanner_scope_add_symbol (scanner, 0, "tabs-position",
|
|
|
|
GINT_TO_POINTER (TABS_POSITION));
|
2002-06-03 03:48:01 +08:00
|
|
|
g_scanner_scope_add_symbol (scanner, 0, "last-tip-shown",
|
|
|
|
GINT_TO_POINTER (LAST_TIP_SHOWN));
|
|
|
|
|
|
|
|
token = G_TOKEN_LEFT_PAREN;
|
|
|
|
|
|
|
|
while (g_scanner_peek_next_token (scanner) == token)
|
|
|
|
{
|
|
|
|
token = g_scanner_get_next_token (scanner);
|
|
|
|
|
|
|
|
switch (token)
|
|
|
|
{
|
|
|
|
case G_TOKEN_LEFT_PAREN:
|
|
|
|
token = G_TOKEN_SYMBOL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_TOKEN_SYMBOL:
|
|
|
|
if (scanner->value.v_symbol == GINT_TO_POINTER (SESSION_INFO))
|
|
|
|
{
|
2010-01-20 05:23:23 +08:00
|
|
|
GimpDialogFactory *factory = NULL;
|
|
|
|
GimpSessionInfo *info = NULL;
|
|
|
|
gchar *factory_name = NULL;
|
|
|
|
gchar *entry_name = NULL;
|
|
|
|
GimpDialogFactoryEntry *entry = NULL;
|
2002-06-03 03:48:01 +08:00
|
|
|
|
2008-05-17 00:06:42 +08:00
|
|
|
token = G_TOKEN_STRING;
|
|
|
|
|
|
|
|
if (! gimp_scanner_parse_string (scanner, &factory_name))
|
|
|
|
break;
|
|
|
|
|
2010-02-20 16:26:57 +08:00
|
|
|
/* In versions <= GIMP 2.6 there was a "toolbox", a
|
2010-02-20 17:58:29 +08:00
|
|
|
* "dock", a "display" and a "toplevel" factory. These
|
2010-03-01 06:20:57 +08:00
|
|
|
* are now merged to a single gimp_dialog_factory_get_singleton (). We
|
2010-03-01 02:58:37 +08:00
|
|
|
* need the legacy name though, so keep it around.
|
2010-01-21 01:29:54 +08:00
|
|
|
*/
|
2010-03-01 06:20:57 +08:00
|
|
|
factory = gimp_dialog_factory_get_singleton ();
|
2008-05-17 00:06:42 +08:00
|
|
|
|
|
|
|
info = gimp_session_info_new ();
|
|
|
|
|
2010-02-20 19:13:55 +08:00
|
|
|
/* GIMP 2.6 has the entry name as part of the
|
|
|
|
* session-info header, so try to get it
|
2009-09-20 00:00:15 +08:00
|
|
|
*/
|
2010-02-20 19:13:55 +08:00
|
|
|
gimp_scanner_parse_string (scanner, &entry_name);
|
|
|
|
if (entry_name)
|
2010-01-20 05:23:23 +08:00
|
|
|
{
|
2010-02-20 19:13:55 +08:00
|
|
|
/* Previously, GimpDock was a toplevel. That is why
|
|
|
|
* versions <= GIMP 2.6 has "dock" as the entry name. We
|
|
|
|
* want "dock" to be interpreted as 'dock window'
|
|
|
|
* however so have some special-casing for that. When
|
|
|
|
* the entry name is "dock" the factory name is either
|
|
|
|
* "dock" or "toolbox".
|
|
|
|
*/
|
|
|
|
if (strcmp (entry_name, "dock") == 0)
|
|
|
|
{
|
|
|
|
entry =
|
|
|
|
gimp_dialog_factory_find_entry (factory,
|
|
|
|
(strcmp (factory_name, "toolbox") == 0 ?
|
|
|
|
"gimp-toolbox-window" :
|
|
|
|
"gimp-dock-window"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
entry = gimp_dialog_factory_find_entry (factory,
|
|
|
|
entry_name);
|
|
|
|
}
|
2008-05-17 00:06:42 +08:00
|
|
|
}
|
|
|
|
|
2010-01-20 05:23:23 +08:00
|
|
|
/* We're done with these now */
|
|
|
|
g_free (factory_name);
|
2008-07-22 14:51:59 +08:00
|
|
|
g_free (entry_name);
|
|
|
|
|
2010-02-20 19:13:55 +08:00
|
|
|
/* We can get the factory entry either now (the GIMP <=
|
|
|
|
* 2.6 way), or when we deserialize (the GIMP 2.8 way)
|
|
|
|
*/
|
2010-01-20 05:23:23 +08:00
|
|
|
if (entry)
|
|
|
|
{
|
|
|
|
gimp_session_info_set_factory_entry (info, entry);
|
|
|
|
}
|
|
|
|
|
2010-02-20 19:13:55 +08:00
|
|
|
/* Always try to deserialize */
|
2009-09-20 00:00:15 +08:00
|
|
|
if (gimp_config_deserialize (GIMP_CONFIG (info), scanner, 1, NULL))
|
2008-05-17 00:06:42 +08:00
|
|
|
{
|
2010-02-20 19:13:55 +08:00
|
|
|
/* Make sure we got a factory entry either the 2.6
|
|
|
|
* or 2.8 way
|
|
|
|
*/
|
|
|
|
if (gimp_session_info_get_factory_entry (info))
|
2008-05-17 00:06:42 +08:00
|
|
|
{
|
2009-09-21 01:08:48 +08:00
|
|
|
GIMP_LOG (DIALOG_FACTORY,
|
|
|
|
"successfully parsed and added session info %p",
|
|
|
|
info);
|
|
|
|
|
2009-12-21 03:19:31 +08:00
|
|
|
gimp_dialog_factory_add_session_info (factory, info);
|
2008-05-17 00:06:42 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-09-21 01:08:48 +08:00
|
|
|
GIMP_LOG (DIALOG_FACTORY,
|
|
|
|
"failed to parse session info %p, not adding",
|
|
|
|
info);
|
2008-05-17 00:06:42 +08:00
|
|
|
}
|
2011-05-13 03:12:59 +08:00
|
|
|
|
|
|
|
g_object_unref (info);
|
2008-05-17 00:06:42 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_object_unref (info);
|
2012-03-30 16:09:14 +08:00
|
|
|
|
|
|
|
/* set token to left paren to we won't set another
|
|
|
|
* error below, gimp_config_deserialize() already did
|
|
|
|
*/
|
|
|
|
token = G_TOKEN_LEFT_PAREN;
|
|
|
|
goto error;
|
2008-05-17 00:06:42 +08:00
|
|
|
}
|
2002-06-03 03:48:01 +08:00
|
|
|
}
|
2011-11-06 00:52:45 +08:00
|
|
|
else if (scanner->value.v_symbol == GINT_TO_POINTER (HIDE_DOCKS))
|
|
|
|
{
|
|
|
|
gboolean hide_docks;
|
|
|
|
|
|
|
|
token = G_TOKEN_IDENTIFIER;
|
|
|
|
|
|
|
|
if (! gimp_scanner_parse_boolean (scanner, &hide_docks))
|
|
|
|
break;
|
|
|
|
|
|
|
|
g_object_set (gimp->config,
|
|
|
|
"hide-docks", hide_docks,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
else if (scanner->value.v_symbol == GINT_TO_POINTER (SINGLE_WINDOW_MODE))
|
|
|
|
{
|
|
|
|
gboolean single_window_mode;
|
|
|
|
|
|
|
|
token = G_TOKEN_IDENTIFIER;
|
|
|
|
|
|
|
|
if (! gimp_scanner_parse_boolean (scanner, &single_window_mode))
|
|
|
|
break;
|
|
|
|
|
|
|
|
g_object_set (gimp->config,
|
|
|
|
"single-window-mode", single_window_mode,
|
|
|
|
NULL);
|
|
|
|
}
|
2013-09-15 18:56:17 +08:00
|
|
|
else if (scanner->value.v_symbol == GINT_TO_POINTER (TABS_POSITION))
|
|
|
|
{
|
|
|
|
gint tabs_position;
|
|
|
|
|
|
|
|
token = G_TOKEN_INT;
|
|
|
|
|
|
|
|
if (! gimp_scanner_parse_int (scanner, &tabs_position))
|
|
|
|
break;
|
|
|
|
|
|
|
|
g_object_set (gimp->config,
|
|
|
|
"tabs-position", tabs_position,
|
|
|
|
NULL);
|
|
|
|
}
|
2002-06-03 03:48:01 +08:00
|
|
|
else if (scanner->value.v_symbol == GINT_TO_POINTER (LAST_TIP_SHOWN))
|
|
|
|
{
|
2011-11-06 00:52:45 +08:00
|
|
|
gint last_tip_shown;
|
2002-11-19 04:50:31 +08:00
|
|
|
|
2002-06-03 03:48:01 +08:00
|
|
|
token = G_TOKEN_INT;
|
|
|
|
|
2011-11-06 00:52:45 +08:00
|
|
|
if (! gimp_scanner_parse_int (scanner, &last_tip_shown))
|
2002-06-03 03:48:01 +08:00
|
|
|
break;
|
2011-11-06 00:52:45 +08:00
|
|
|
|
|
|
|
g_object_set (gimp->config,
|
|
|
|
"last-tip-shown", last_tip_shown,
|
|
|
|
NULL);
|
2002-06-03 03:48:01 +08:00
|
|
|
}
|
|
|
|
token = G_TOKEN_RIGHT_PAREN;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_TOKEN_RIGHT_PAREN:
|
|
|
|
token = G_TOKEN_LEFT_PAREN;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: /* do nothing */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-30 16:09:14 +08:00
|
|
|
error:
|
|
|
|
|
2002-06-03 03:48:01 +08:00
|
|
|
if (token != G_TOKEN_LEFT_PAREN)
|
|
|
|
{
|
|
|
|
g_scanner_get_next_token (scanner);
|
|
|
|
g_scanner_unexp_token (scanner, token, NULL, NULL, NULL,
|
|
|
|
_("fatal parse error"), TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
{
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
|
2002-06-03 03:48:01 +08:00
|
|
|
g_clear_error (&error);
|
2003-10-22 02:14:58 +08:00
|
|
|
|
2014-07-02 02:02:13 +08:00
|
|
|
gimp_config_file_backup_on_error (file, "sessionrc", NULL);
|
2002-06-03 03:48:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gimp_scanner_destroy (scanner);
|
2014-07-02 01:54:50 +08:00
|
|
|
g_object_unref (file);
|
2008-05-17 00:06:42 +08:00
|
|
|
|
|
|
|
dialogs_load_recent_docks (gimp);
|
2001-04-18 00:00:27 +08:00
|
|
|
}
|
2000-03-25 06:10:28 +08:00
|
|
|
|
2004-07-22 00:11:31 +08:00
|
|
|
void
|
|
|
|
session_exit (Gimp *gimp)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
}
|
|
|
|
|
2001-04-18 00:00:27 +08:00
|
|
|
void
|
2014-05-03 03:15:01 +08:00
|
|
|
session_restore (Gimp *gimp,
|
|
|
|
GdkScreen *screen,
|
|
|
|
gint monitor)
|
2001-04-18 00:00:27 +08:00
|
|
|
{
|
2001-10-24 00:23:32 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
2014-05-03 03:15:01 +08:00
|
|
|
g_return_if_fail (GDK_IS_SCREEN (screen));
|
2014-05-02 09:01:23 +08:00
|
|
|
|
|
|
|
gimp_dialog_factory_restore (gimp_dialog_factory_get_singleton (),
|
|
|
|
screen, monitor);
|
2013-11-22 06:00:44 +08:00
|
|
|
|
|
|
|
/* make sure GimpImageWindow acts upon hide-docks at the right time,
|
|
|
|
* see bug #678043.
|
|
|
|
*/
|
|
|
|
if (GIMP_GUI_CONFIG (gimp->config)->single_window_mode &&
|
|
|
|
GIMP_GUI_CONFIG (gimp->config)->hide_docks)
|
|
|
|
{
|
|
|
|
g_object_notify (G_OBJECT (gimp->config), "hide-docks");
|
|
|
|
}
|
1998-06-23 01:30:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-07-22 00:11:31 +08:00
|
|
|
session_save (Gimp *gimp,
|
|
|
|
gboolean always_save)
|
1998-06-23 01:30:40 +08:00
|
|
|
{
|
2003-03-11 03:01:07 +08:00
|
|
|
GimpConfigWriter *writer;
|
2014-07-02 01:54:50 +08:00
|
|
|
GFile *file;
|
2006-10-10 02:49:15 +08:00
|
|
|
GError *error = NULL;
|
1998-06-23 01:30:40 +08:00
|
|
|
|
2001-10-24 00:23:32 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
2004-07-22 00:11:31 +08:00
|
|
|
if (sessionrc_deleted && ! always_save)
|
|
|
|
return;
|
|
|
|
|
2014-07-02 01:54:50 +08:00
|
|
|
file = session_file (gimp);
|
1998-06-23 01:30:40 +08:00
|
|
|
|
2005-11-07 06:01:25 +08:00
|
|
|
if (gimp->be_verbose)
|
2014-07-02 01:54:50 +08:00
|
|
|
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
|
2005-11-07 06:01:25 +08:00
|
|
|
|
2003-06-24 06:02:56 +08:00
|
|
|
writer =
|
2014-07-02 01:54:50 +08:00
|
|
|
gimp_config_writer_new_gfile (file,
|
|
|
|
TRUE,
|
|
|
|
"GIMP sessionrc\n\n"
|
|
|
|
"This file takes session-specific info "
|
|
|
|
"(that is info, you want to keep between "
|
|
|
|
"two GIMP sessions). You are not supposed "
|
|
|
|
"to edit it manually, but of course you "
|
|
|
|
"can do. The sessionrc will be entirely "
|
|
|
|
"rewritten every time you quit GIMP. "
|
|
|
|
"If this file isn't found, defaults are "
|
|
|
|
"used.",
|
|
|
|
NULL);
|
|
|
|
g_object_unref (file);
|
2003-03-11 03:01:07 +08:00
|
|
|
|
|
|
|
if (!writer)
|
1999-03-07 20:56:03 +08:00
|
|
|
return;
|
1998-06-24 06:50:16 +08:00
|
|
|
|
2010-03-01 06:20:57 +08:00
|
|
|
gimp_dialog_factory_save (gimp_dialog_factory_get_singleton (), writer);
|
2003-03-11 03:01:07 +08:00
|
|
|
gimp_config_writer_linefeed (writer);
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2011-11-06 00:52:45 +08:00
|
|
|
gimp_config_writer_open (writer, "hide-docks");
|
|
|
|
gimp_config_writer_identifier (writer,
|
|
|
|
GIMP_GUI_CONFIG (gimp->config)->hide_docks ?
|
|
|
|
"yes" : "no");
|
|
|
|
gimp_config_writer_close (writer);
|
|
|
|
|
|
|
|
gimp_config_writer_open (writer, "single-window-mode");
|
|
|
|
gimp_config_writer_identifier (writer,
|
|
|
|
GIMP_GUI_CONFIG (gimp->config)->single_window_mode ?
|
|
|
|
"yes" : "no");
|
|
|
|
gimp_config_writer_close (writer);
|
|
|
|
|
2013-09-15 18:56:17 +08:00
|
|
|
gimp_config_writer_open (writer, "tabs-position");
|
|
|
|
gimp_config_writer_printf (writer, "%d",
|
|
|
|
GIMP_GUI_CONFIG (gimp->config)->tabs_position);
|
|
|
|
gimp_config_writer_close (writer);
|
|
|
|
|
2003-03-11 03:01:07 +08:00
|
|
|
gimp_config_writer_open (writer, "last-tip-shown");
|
|
|
|
gimp_config_writer_printf (writer, "%d",
|
2011-11-06 00:52:45 +08:00
|
|
|
GIMP_GUI_CONFIG (gimp->config)->last_tip_shown);
|
2003-03-11 03:01:07 +08:00
|
|
|
gimp_config_writer_close (writer);
|
2000-02-12 23:01:33 +08:00
|
|
|
|
2006-10-10 02:49:15 +08:00
|
|
|
if (! gimp_config_writer_finish (writer, "end of sessionrc", &error))
|
|
|
|
{
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
|
2006-10-10 02:49:15 +08:00
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
2004-07-22 00:11:31 +08:00
|
|
|
|
2008-05-17 00:06:42 +08:00
|
|
|
dialogs_save_recent_docks (gimp);
|
|
|
|
|
2004-07-22 00:11:31 +08:00
|
|
|
sessionrc_deleted = FALSE;
|
1998-06-23 01:30:40 +08:00
|
|
|
}
|
2002-06-03 03:48:01 +08:00
|
|
|
|
2004-07-22 00:11:31 +08:00
|
|
|
gboolean
|
|
|
|
session_clear (Gimp *gimp,
|
|
|
|
GError **error)
|
2003-04-08 18:02:42 +08:00
|
|
|
{
|
2014-07-02 01:54:50 +08:00
|
|
|
GFile *file;
|
|
|
|
GError *my_error = NULL;
|
|
|
|
gboolean success = TRUE;
|
2004-07-22 00:11:31 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
|
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
|
|
|
|
2014-07-02 01:54:50 +08:00
|
|
|
file = session_file (gimp);
|
2004-07-22 00:11:31 +08:00
|
|
|
|
2014-07-02 01:54:50 +08:00
|
|
|
if (! g_file_delete (file, NULL, &my_error) &&
|
|
|
|
my_error->code != G_IO_ERROR_NOT_FOUND)
|
2004-07-22 00:11:31 +08:00
|
|
|
{
|
|
|
|
success = FALSE;
|
2014-07-02 01:54:50 +08:00
|
|
|
|
|
|
|
g_set_error (error, GIMP_ERROR, GIMP_FAILED,
|
|
|
|
_("Deleting \"%s\" failed: %s"),
|
|
|
|
gimp_file_get_utf8_name (file), my_error->message);
|
2004-07-22 00:11:31 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sessionrc_deleted = TRUE;
|
|
|
|
}
|
|
|
|
|
2014-07-02 01:54:50 +08:00
|
|
|
g_clear_error (&my_error);
|
|
|
|
g_object_unref (file);
|
2003-04-08 18:02:42 +08:00
|
|
|
|
2004-07-22 00:11:31 +08:00
|
|
|
return success;
|
2003-04-08 18:02:42 +08:00
|
|
|
}
|
2003-11-13 22:14:20 +08:00
|
|
|
|
|
|
|
|
2014-07-02 01:54:50 +08:00
|
|
|
static GFile *
|
|
|
|
session_file (Gimp *gimp)
|
2003-11-13 22:14:20 +08:00
|
|
|
{
|
2011-05-21 01:06:57 +08:00
|
|
|
const gchar *basename;
|
|
|
|
gchar *filename;
|
2014-07-02 01:54:50 +08:00
|
|
|
GFile *file;
|
2011-05-16 13:11:44 +08:00
|
|
|
|
2011-05-21 01:06:57 +08:00
|
|
|
basename = g_getenv ("GIMP_TESTING_SESSIONRC_NAME");
|
|
|
|
if (! basename)
|
|
|
|
basename = "sessionrc";
|
2011-05-16 13:11:44 +08:00
|
|
|
|
2003-11-13 22:14:20 +08:00
|
|
|
if (gimp->session_name)
|
2014-07-28 17:05:56 +08:00
|
|
|
filename = g_strconcat (basename, ".", gimp->session_name, NULL);
|
|
|
|
else
|
|
|
|
filename = g_strdup (basename);
|
2003-11-13 22:14:20 +08:00
|
|
|
|
2014-07-28 17:05:56 +08:00
|
|
|
file = gimp_directory_file (filename, NULL);
|
2003-11-13 22:14:20 +08:00
|
|
|
|
2014-07-02 01:54:50 +08:00
|
|
|
g_free (filename);
|
|
|
|
|
|
|
|
return file;
|
2003-11-13 22:14:20 +08:00
|
|
|
}
|