Cleaned up the app init and exit stuff even more. Also reduces the number

2003-10-02  Michael Natterer  <mitch@gimp.org>

	Cleaned up the app init and exit stuff even more. Also reduces the
	number of missing symbols for gimp-console. Added init and exit
	debugging output (only for --verbose).

	* app/core/gimpmarshal.list
	* app/core/gimp.[ch]: added new signals "initialize" and
	"restore".  Moved plug_ins_init() to Gimp::restore()'s default
	implementation and plug_ins_exit() to Gimp::exit()'s default
	implementation. Renamed gimp_set_config() to gimp_load_config()
	and load GimpRC here. Moved base_init() and base_exit() to this
	file, too.

	* app/gui/Makefile.am
	* app/gui/gui-vtable.[ch]: new files split out of gui.c. It was
	simply too large.

	* app/gui/gui.[ch]: renamed gui_themes_init() to gui_init(),
	connect to Gimp's "initialize" and "restore" signals and create
	the GUI stuff in the callbacks. Removed most other public
	functions since they don't need to be called explicitly any more.
	Moved the whole tool initialization/shutdown code to this file.

	* app/gui/user-install-dialog.[ch]: changed
	user_install_dialog_create() to user_install_dialog_run() and
	added a gtk_main() at the end, so the install dialog's gtk_main()
	and gtk_main_quit() live in the same file.

	* app/app_procs.c: removed lots of stuff. app_init() is much
	simpler now.
This commit is contained in:
Michael Natterer 2003-10-02 11:26:26 +00:00 committed by Michael Natterer
parent a3ab230fdc
commit 89d936f3aa
14 changed files with 820 additions and 663 deletions

View File

@ -1,3 +1,35 @@
2003-10-02 Michael Natterer <mitch@gimp.org>
Cleaned up the app init and exit stuff even more. Also reduces the
number of missing symbols for gimp-console. Added init and exit
debugging output (only for --verbose).
* app/core/gimpmarshal.list
* app/core/gimp.[ch]: added new signals "initialize" and
"restore". Moved plug_ins_init() to Gimp::restore()'s default
implementation and plug_ins_exit() to Gimp::exit()'s default
implementation. Renamed gimp_set_config() to gimp_load_config()
and load GimpRC here. Moved base_init() and base_exit() to this
file, too.
* app/gui/Makefile.am
* app/gui/gui-vtable.[ch]: new files split out of gui.c. It was
simply too large.
* app/gui/gui.[ch]: renamed gui_themes_init() to gui_init(),
connect to Gimp's "initialize" and "restore" signals and create
the GUI stuff in the callbacks. Removed most other public
functions since they don't need to be called explicitly any more.
Moved the whole tool initialization/shutdown code to this file.
* app/gui/user-install-dialog.[ch]: changed
user_install_dialog_create() to user_install_dialog_run() and
added a gtk_main() at the end, so the install dialog's gtk_main()
and gtk_main_quit() live in the same file.
* app/app_procs.c: removed lots of stuff. app_init() is much
simpler now.
2003-10-02 Michael Natterer <mitch@gimp.org>
* app/gui/tool-options-commands.c

View File

@ -34,16 +34,11 @@
#include "libgimpbase/gimpbase.h"
#include "tools/tools-types.h"
#include "base/base.h"
#include "core/core-types.h"
#include "config/gimprc.h"
#include "core/gimp.h"
#include "core/gimp-units.h"
#include "plug-in/plug-ins.h"
#include "file/file-open.h"
#include "file/file-utils.h"
@ -51,7 +46,6 @@
#include "tools/gimp-tools.h"
#include "gui/gui.h"
#include "gui/splash.h"
#include "gui/user-install-dialog.h"
#include "app_procs.h"
@ -63,16 +57,11 @@
/* local prototypes */
static void app_init_update_splash (const gchar *text1,
const gchar *text2,
gdouble percentage);
static void app_init_update_none (const gchar *text1,
const gchar *text2,
gdouble percentage);
static gboolean app_exit_callback (Gimp *gimp,
gboolean kill_it);
static gboolean app_exit_finish_callback (Gimp *gimp,
gboolean kill_it);
static void app_init_update_none (const gchar *text1,
const gchar *text2,
gdouble percentage);
static gboolean app_exit_after_callback (Gimp *gimp,
gboolean kill_it);
/* global variables */
@ -107,27 +96,19 @@ app_init (const gchar *full_prog_name,
GimpStackTraceMode stack_trace_mode,
gboolean restore_session)
{
GimpInitStatusFunc update_status_func;
const gchar *gimp_dir;
GimpRc *gimprc;
if (no_interface || no_splash)
update_status_func = app_init_update_none;
else
update_status_func = app_init_update_splash;
GimpInitStatusFunc update_status_func = app_init_update_none;
/* Create an instance of the "Gimp" object which is the root of the
* core object system
*/
the_gimp = gimp_new (be_verbose,
the_gimp = gimp_new (full_prog_name,
be_verbose,
no_data,
no_interface,
use_shm,
console_messages,
stack_trace_mode);
gimp_object_set_name (GIMP_OBJECT (the_gimp), full_prog_name);
g_log_set_handler ("Gimp",
G_LOG_LEVEL_MESSAGE,
gimp_message_log_func,
@ -184,9 +165,7 @@ app_init (const gchar *full_prog_name,
/* Check if the user's gimp_directory exists
*/
gimp_dir = gimp_directory ();
if (! g_file_test (gimp_dir, G_FILE_TEST_IS_DIR))
if (! g_file_test (gimp_directory (), G_FILE_TEST_IS_DIR))
{
/* not properly installed */
@ -202,88 +181,37 @@ app_init (const gchar *full_prog_name,
}
else
{
user_install_dialog_create (alternate_system_gimprc,
alternate_gimprc,
be_verbose);
gtk_main ();
user_install_dialog_run (alternate_system_gimprc,
alternate_gimprc,
be_verbose);
}
}
/* this needs to be done before gimprc loading because gimprc can
* use user defined units
*/
gimp_unitrc_load (the_gimp);
gimprc = gimp_rc_new (alternate_system_gimprc,
alternate_gimprc,
be_verbose);
#if 0
/* solely for debugging */
g_signal_connect (gimprc, "notify",
G_CALLBACK (gimprc_notify_callback),
NULL);
#endif
/* initialize lowlevel stuff */
base_init (GIMP_BASE_CONFIG (gimprc), use_mmx);
gimp_set_config (the_gimp, GIMP_CORE_CONFIG (gimprc));
g_object_unref (gimprc);
gimprc = NULL;
gimp_load_config (the_gimp,
alternate_system_gimprc,
alternate_gimprc,
use_mmx);
if (! no_interface)
{
gui_themes_init (the_gimp);
update_status_func = gui_init (the_gimp, no_splash, no_splash_image);
if (! no_splash)
splash_create (! no_splash_image);
}
g_assert (update_status_func != NULL);
/* connect our "exit" callbacks after gui_init() so they are
* invoked after the GUI's "exit" callbacks
*/
g_signal_connect_after (the_gimp, "exit",
G_CALLBACK (app_exit_after_callback),
NULL);
/* Create all members of the global Gimp instance which need an already
* parsed gimprc, e.g. the data factories
*/
gimp_initialize (the_gimp, update_status_func);
if (! no_interface)
{
gui_environ_init (the_gimp);
gimp_tools_init (the_gimp);
}
/* Load all data files
*/
gimp_restore (the_gimp, update_status_func, no_data);
if (! no_interface)
{
gui_init (the_gimp);
gimp_tools_restore (the_gimp);
}
/* Initialize the plug-in structures
*/
plug_ins_init (the_gimp, update_status_func);
if (! no_interface)
{
if (! no_splash)
splash_destroy ();
gui_restore (the_gimp, restore_session);
}
/* connect our "exit" callbacks after gui_restore() so they are
* invoked after the GUI's "exit" callbacks
*/
g_signal_connect (the_gimp, "exit",
G_CALLBACK (app_exit_callback),
NULL);
g_signal_connect_after (the_gimp, "exit",
G_CALLBACK (app_exit_finish_callback),
NULL);
gimp_restore (the_gimp, update_status_func, restore_session);
/* enable autosave late so we don't autosave when the
* monitor resolution is set in gui_init()
@ -352,11 +280,6 @@ app_init (const gchar *full_prog_name,
batch_init (the_gimp, batch_cmds);
if (! no_interface)
{
gui_post_init (the_gimp);
}
if (no_interface)
{
GMainLoop *loop;
@ -371,6 +294,8 @@ app_init (const gchar *full_prog_name,
}
else
{
gui_post_init (the_gimp);
gtk_main ();
}
}
@ -378,14 +303,6 @@ app_init (const gchar *full_prog_name,
/* private functions */
static void
app_init_update_splash (const gchar *text1,
const gchar *text2,
gdouble percentage)
{
splash_update (text1, text2, percentage);
}
static void
app_init_update_none (const gchar *text1,
const gchar *text2,
@ -394,73 +311,21 @@ app_init_update_none (const gchar *text1,
}
static gboolean
app_exit_callback (Gimp *gimp,
gboolean kill_it)
app_exit_after_callback (Gimp *gimp,
gboolean kill_it)
{
plug_ins_exit (gimp);
if (gimp->be_verbose)
g_print ("EXIT: app_exit_after_callback\n");
if (! gimp->no_interface)
{
gimp_tools_save (gimp);
gimp_tools_exit (gimp);
}
return FALSE; /* continue exiting */
}
static gboolean
app_exit_finish_callback (Gimp *gimp,
gboolean kill_it)
{
g_object_unref (gimp);
the_gimp = NULL;
base_exit ();
#if 0
/* There used to be foo_main_quit() here, but there's a chance
* that foo_main() was never called before we reach this point. --Sven
*/
exit (0);
#endif
return FALSE;
}
#if 0
/****************************************
* gimprc debugging code, to be removed *
****************************************/
#include "config/gimpconfig-serialize.h"
static void
gimprc_notify_callback (GObject *object,
GParamSpec *pspec)
{
GString *str;
GValue value = { 0, };
g_return_if_fail (G_IS_OBJECT (object));
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
g_value_init (&value, pspec->value_type);
g_object_get_property (object, pspec->name, &value);
str = g_string_new (NULL);
if (gimp_config_serialize_value (&value, str, TRUE))
{
g_print (" %s -> %s\n", pspec->name, str->str);
}
else
{
g_print (" %s changed but we failed to serialize its value!\n",
pspec->name);
}
g_string_free (str, TRUE);
g_value_unset (&value);
}
#endif

View File

@ -31,9 +31,13 @@
#include "config/gimpconfig-path.h"
#include "config/gimprc.h"
#include "base/base.h"
#include "pdb/procedural_db.h"
#include "pdb/internal_procs.h"
#include "plug-in/plug-ins.h"
#include "paint/gimp-paint.h"
#include "text/gimp-fonts.h"
@ -71,29 +75,36 @@
enum
{
INITIALIZE,
RESTORE,
EXIT,
LAST_SIGNAL
};
static void gimp_class_init (GimpClass *klass);
static void gimp_init (Gimp *gimp);
static void gimp_class_init (GimpClass *klass);
static void gimp_init (Gimp *gimp);
static void gimp_dispose (GObject *object);
static void gimp_finalize (GObject *object);
static void gimp_dispose (GObject *object);
static void gimp_finalize (GObject *object);
static gsize gimp_get_memsize (GimpObject *object,
gsize *gui_size);
static gsize gimp_get_memsize (GimpObject *object,
gsize *gui_size);
static gboolean gimp_real_exit (Gimp *gimp,
gboolean kill_it);
static void gimp_real_initialize (Gimp *gimp,
GimpInitStatusFunc status_callback);
static void gimp_real_restore (Gimp *gimp,
GimpInitStatusFunc status_callback,
gboolean restore_session);
static gboolean gimp_real_exit (Gimp *gimp,
gboolean kill_it);
static void gimp_global_config_notify (GObject *global_config,
GParamSpec *param_spec,
GObject *edit_config);
static void gimp_edit_config_notify (GObject *edit_config,
GParamSpec *param_spec,
GObject *global_config);
static void gimp_global_config_notify (GObject *global_config,
GParamSpec *param_spec,
GObject *edit_config);
static void gimp_edit_config_notify (GObject *edit_config,
GParamSpec *param_spec,
GObject *global_config);
static GimpObjectClass *parent_class = NULL;
@ -156,6 +167,27 @@ gimp_class_init (GimpClass *klass)
parent_class = g_type_class_peek_parent (klass);
gimp_signals[INITIALIZE] =
g_signal_new ("initialize",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GimpClass, initialize),
NULL, NULL,
gimp_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
gimp_signals[RESTORE] =
g_signal_new ("restore",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GimpClass, restore),
NULL, NULL,
gimp_marshal_VOID__POINTER_BOOLEAN,
G_TYPE_NONE, 2,
G_TYPE_POINTER,
G_TYPE_BOOLEAN);
gimp_signals[EXIT] =
g_signal_new ("exit",
G_TYPE_FROM_CLASS (klass),
@ -171,6 +203,8 @@ gimp_class_init (GimpClass *klass)
gimp_object_class->get_memsize = gimp_get_memsize;
klass->initialize = gimp_real_initialize;
klass->restore = gimp_real_restore;
klass->exit = gimp_real_exit;
}
@ -442,6 +476,8 @@ gimp_finalize (GObject *object)
if (gimp->user_units)
gimp_units_exit (gimp);
base_exit ();
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@ -518,10 +554,142 @@ gimp_get_memsize (GimpObject *object,
gui_size);
}
static void
gimp_real_initialize (Gimp *gimp,
GimpInitStatusFunc status_callback)
{
GimpContext *context;
gchar *path;
static const GimpDataFactoryLoaderEntry brush_loader_entries[] =
{
{ gimp_brush_load, GIMP_BRUSH_FILE_EXTENSION },
{ gimp_brush_load, GIMP_BRUSH_PIXMAP_FILE_EXTENSION },
{ gimp_brush_generated_load, GIMP_BRUSH_GENERATED_FILE_EXTENSION },
{ gimp_brush_pipe_load, GIMP_BRUSH_PIPE_FILE_EXTENSION }
};
static const GimpDataFactoryLoaderEntry pattern_loader_entries[] =
{
{ gimp_pattern_load, GIMP_PATTERN_FILE_EXTENSION }
};
static const GimpDataFactoryLoaderEntry gradient_loader_entries[] =
{
{ gimp_gradient_load, GIMP_GRADIENT_FILE_EXTENSION },
{ gimp_gradient_load, NULL /* legacy loader */ }
};
static const GimpDataFactoryLoaderEntry palette_loader_entries[] =
{
{ gimp_palette_load, GIMP_PALETTE_FILE_EXTENSION },
{ gimp_palette_load, NULL /* legacy loader */ }
};
if (gimp->be_verbose)
g_print ("INIT: gimp_real_initialize\n");
gimp_fonts_init (gimp);
gimp->brush_factory =
gimp_data_factory_new (gimp,
GIMP_TYPE_BRUSH,
"brush_path",
brush_loader_entries,
G_N_ELEMENTS (brush_loader_entries),
gimp_brush_new,
gimp_brush_get_standard);
gimp_object_set_name (GIMP_OBJECT (gimp->brush_factory), "brush factory");
gimp->pattern_factory =
gimp_data_factory_new (gimp,
GIMP_TYPE_PATTERN,
"pattern_path",
pattern_loader_entries,
G_N_ELEMENTS (pattern_loader_entries),
gimp_pattern_new,
gimp_pattern_get_standard);
gimp_object_set_name (GIMP_OBJECT (gimp->pattern_factory), "pattern factory");
gimp->gradient_factory =
gimp_data_factory_new (gimp,
GIMP_TYPE_GRADIENT,
"gradient_path",
gradient_loader_entries,
G_N_ELEMENTS (gradient_loader_entries),
gimp_gradient_new,
gimp_gradient_get_standard);
gimp_object_set_name (GIMP_OBJECT (gimp->gradient_factory), "gradient factory");
gimp->palette_factory =
gimp_data_factory_new (gimp,
GIMP_TYPE_PALETTE,
"palette_path",
palette_loader_entries,
G_N_ELEMENTS (palette_loader_entries),
gimp_palette_new,
gimp_palette_get_standard);
gimp_object_set_name (GIMP_OBJECT (gimp->palette_factory), "palette factory");
gimp_paint_init (gimp);
/* Set the last values used to default values. */
gimp->image_new_last_template = gimp_template_new ("last values");
gimp_template_set_from_config (gimp->image_new_last_template, gimp->config);
gimp->have_current_cut_buffer = FALSE;
gimp->standard_context = gimp_context_new (gimp, "Standard", NULL);
/* the default context contains the user's saved preferences
*
* TODO: load from disk
*/
context = gimp_context_new (gimp, "Default", NULL);
gimp_set_default_context (gimp, context);
g_object_unref (context);
/* the initial user_context is a straight copy of the default context
*/
context = gimp_context_new (gimp, "User", context);
gimp_set_user_context (gimp, context);
g_object_unref (context);
gimp_set_current_context (gimp, context);
/* add the builtin FG -> BG etc. gradients */
gimp_gradients_init (gimp);
/* register all internal procedures */
(* status_callback) (_("Procedural Database"), NULL, -1);
internal_procs_init (gimp, status_callback);
(* status_callback) (_("Plug-In Environment"), "", -1);
path = gimp_config_path_expand (gimp->config->environ_path, TRUE, NULL);
gimp_environ_table_load (gimp->environ_table, path);
g_free (path);
}
static void
gimp_real_restore (Gimp *gimp,
GimpInitStatusFunc status_callback,
gboolean restore_session)
{
if (gimp->be_verbose)
g_print ("INIT: gimp_real_restore\n");
plug_ins_init (gimp, status_callback);
}
static gboolean
gimp_real_exit (Gimp *gimp,
gboolean kill_it)
{
if (gimp->be_verbose)
g_print ("EXIT: gimp_real_exit\n");
plug_ins_exit (gimp);
gimp_modules_unload (gimp);
gimp_data_factory_data_save (gimp->brush_factory);
gimp_data_factory_data_save (gimp->pattern_factory);
@ -537,7 +705,8 @@ gimp_real_exit (Gimp *gimp,
}
Gimp *
gimp_new (gboolean be_verbose,
gimp_new (const gchar *name,
gboolean be_verbose,
gboolean no_data,
gboolean no_interface,
gboolean use_shm,
@ -546,7 +715,9 @@ gimp_new (gboolean be_verbose,
{
Gimp *gimp;
gimp = g_object_new (GIMP_TYPE_GIMP, NULL);
g_return_val_if_fail (name != NULL, NULL);
gimp = g_object_new (GIMP_TYPE_GIMP, "name", name, NULL);
gimp->be_verbose = be_verbose ? TRUE : FALSE;
gimp->no_data = no_data ? TRUE : FALSE;
@ -636,15 +807,33 @@ gimp_edit_config_notify (GObject *edit_config,
}
void
gimp_set_config (Gimp *gimp,
GimpCoreConfig *core_config)
gimp_load_config (Gimp *gimp,
const gchar *alternate_system_gimprc,
const gchar *alternate_gimprc,
gboolean use_cpu_accel)
{
GimpRc *gimprc;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (GIMP_IS_CORE_CONFIG (core_config));
g_return_if_fail (gimp->config == NULL);
g_return_if_fail (gimp->edit_config == NULL);
gimp->config = g_object_ref (core_config);
if (gimp->be_verbose)
g_print ("INIT: gimp_load_config\n");
/* this needs to be done before gimprc loading because gimprc can
* use user defined units
*/
gimp_unitrc_load (gimp);
gimprc = gimp_rc_new (alternate_system_gimprc,
alternate_gimprc,
gimp->be_verbose);
/* initialize lowlevel stuff */
base_init (GIMP_BASE_CONFIG (gimprc), use_cpu_accel);
gimp->config = GIMP_CORE_CONFIG (gimprc);
gimp->edit_config =
GIMP_CORE_CONFIG (gimp_config_duplicate (G_OBJECT (gimp->config)));
@ -661,163 +850,65 @@ void
gimp_initialize (Gimp *gimp,
GimpInitStatusFunc status_callback)
{
GimpContext *context;
gchar *path;
static const GimpDataFactoryLoaderEntry brush_loader_entries[] =
{
{ gimp_brush_load, GIMP_BRUSH_FILE_EXTENSION },
{ gimp_brush_load, GIMP_BRUSH_PIXMAP_FILE_EXTENSION },
{ gimp_brush_generated_load, GIMP_BRUSH_GENERATED_FILE_EXTENSION },
{ gimp_brush_pipe_load, GIMP_BRUSH_PIPE_FILE_EXTENSION }
};
static const GimpDataFactoryLoaderEntry pattern_loader_entries[] =
{
{ gimp_pattern_load, GIMP_PATTERN_FILE_EXTENSION }
};
static const GimpDataFactoryLoaderEntry gradient_loader_entries[] =
{
{ gimp_gradient_load, GIMP_GRADIENT_FILE_EXTENSION },
{ gimp_gradient_load, NULL /* legacy loader */ }
};
static const GimpDataFactoryLoaderEntry palette_loader_entries[] =
{
{ gimp_palette_load, GIMP_PALETTE_FILE_EXTENSION },
{ gimp_palette_load, NULL /* legacy loader */ }
};
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (status_callback != NULL);
g_return_if_fail (GIMP_IS_CORE_CONFIG (gimp->config));
gimp_fonts_init (gimp);
if (gimp->be_verbose)
g_print ("INIT: gimp_initialize\n");
gimp->brush_factory =
gimp_data_factory_new (gimp,
GIMP_TYPE_BRUSH,
"brush_path",
brush_loader_entries,
G_N_ELEMENTS (brush_loader_entries),
gimp_brush_new,
gimp_brush_get_standard);
gimp_object_set_name (GIMP_OBJECT (gimp->brush_factory), "brush factory");
gimp->pattern_factory =
gimp_data_factory_new (gimp,
GIMP_TYPE_PATTERN,
"pattern_path",
pattern_loader_entries,
G_N_ELEMENTS (pattern_loader_entries),
gimp_pattern_new,
gimp_pattern_get_standard);
gimp_object_set_name (GIMP_OBJECT (gimp->pattern_factory), "pattern factory");
gimp->gradient_factory =
gimp_data_factory_new (gimp,
GIMP_TYPE_GRADIENT,
"gradient_path",
gradient_loader_entries,
G_N_ELEMENTS (gradient_loader_entries),
gimp_gradient_new,
gimp_gradient_get_standard);
gimp_object_set_name (GIMP_OBJECT (gimp->gradient_factory), "gradient factory");
gimp->palette_factory =
gimp_data_factory_new (gimp,
GIMP_TYPE_PALETTE,
"palette_path",
palette_loader_entries,
G_N_ELEMENTS (palette_loader_entries),
gimp_palette_new,
gimp_palette_get_standard);
gimp_object_set_name (GIMP_OBJECT (gimp->palette_factory), "palette factory");
gimp_paint_init (gimp);
/* Set the last values used to default values. */
gimp->image_new_last_template = gimp_template_new ("last values");
gimp_template_set_from_config (gimp->image_new_last_template, gimp->config);
gimp->have_current_cut_buffer = FALSE;
gimp->standard_context = gimp_context_new (gimp, "Standard", NULL);
/* the default context contains the user's saved preferences
*
* TODO: load from disk
*/
context = gimp_context_new (gimp, "Default", NULL);
gimp_set_default_context (gimp, context);
g_object_unref (context);
/* the initial user_context is a straight copy of the default context
*/
context = gimp_context_new (gimp, "User", context);
gimp_set_user_context (gimp, context);
g_object_unref (context);
gimp_set_current_context (gimp, context);
/* add the builtin FG -> BG etc. gradients */
gimp_gradients_init (gimp);
/* register all internal procedures */
(* status_callback) (_("Procedural Database"), NULL, -1);
internal_procs_init (gimp, status_callback);
(* status_callback) (_("Plug-In Environment"), "", -1);
path = gimp_config_path_expand (gimp->config->environ_path, TRUE, NULL);
gimp_environ_table_load (gimp->environ_table, path);
g_free (path);
g_signal_emit (gimp, gimp_signals[INITIALIZE], 0, status_callback);
}
void
gimp_restore (Gimp *gimp,
GimpInitStatusFunc status_callback,
gboolean no_data)
gboolean restore_session)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (status_callback != NULL);
if (gimp->be_verbose)
g_print ("INIT: gimp_restore\n");
/* initialize the global parasite table */
(* status_callback) (_("Looking for data files"), _("Parasites"), 0.00);
(* status_callback) (_("Looking for data files"), _("Parasites"), 0.0);
gimp_parasiterc_load (gimp);
/* initialize the list of gimp brushes */
(* status_callback) (NULL, _("Brushes"), 0.15);
gimp_data_factory_data_init (gimp->brush_factory, no_data);
(* status_callback) (NULL, _("Brushes"), 0.1);
gimp_data_factory_data_init (gimp->brush_factory, gimp->no_data);
/* initialize the list of gimp patterns */
(* status_callback) (NULL, _("Patterns"), 0.30);
gimp_data_factory_data_init (gimp->pattern_factory, no_data);
(* status_callback) (NULL, _("Patterns"), 0.2);
gimp_data_factory_data_init (gimp->pattern_factory, gimp->no_data);
/* initialize the list of gimp palettes */
(* status_callback) (NULL, _("Palettes"), 0.45);
gimp_data_factory_data_init (gimp->palette_factory, no_data);
(* status_callback) (NULL, _("Palettes"), 0.3);
gimp_data_factory_data_init (gimp->palette_factory, gimp->no_data);
/* initialize the list of gimp gradients */
(* status_callback) (NULL, _("Gradients"), 0.60);
gimp_data_factory_data_init (gimp->gradient_factory, no_data);
(* status_callback) (NULL, _("Gradients"), 0.4);
gimp_data_factory_data_init (gimp->gradient_factory, gimp->no_data);
/* initialize the list of gimp fonts */
(* status_callback) (NULL, _("Fonts"), 0.70);
(* status_callback) (NULL, _("Fonts"), 0.5);
gimp_fonts_load (gimp);
/* initialize the document history */
(* status_callback) (NULL, _("Documents"), 0.80);
(* status_callback) (NULL, _("Documents"), 0.6);
gimp_documents_load (gimp);
/* initialize the template list */
(* status_callback) (NULL, _("Templates"), 0.90);
(* status_callback) (NULL, _("Templates"), 0.7);
gimp_templates_load (gimp);
(* status_callback) (NULL, NULL, 1.00);
/* initialize the module list */
(* status_callback) (NULL, _("Modules"), 0.8);
gimp_modules_load (gimp);
g_signal_emit (gimp, gimp_signals[RESTORE], 0,
status_callback, restore_session);
}
void
@ -828,6 +919,9 @@ gimp_exit (Gimp *gimp,
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (gimp->be_verbose)
g_print ("EXIT: gimp_exit\n");
g_signal_emit (gimp, gimp_signals[EXIT], 0,
kill_it ? TRUE : FALSE,
&handled);

View File

@ -187,27 +187,35 @@ struct _GimpClass
{
GimpObjectClass parent_class;
gboolean (* exit) (Gimp *gimp,
gboolean kill_it);
void (* initialize) (Gimp *gimp,
GimpInitStatusFunc status_callback);
void (* restore) (Gimp *gimp,
GimpInitStatusFunc status_callback,
gboolean restore_session);
gboolean (* exit) (Gimp *gimp,
gboolean kill_it);
};
GType gimp_get_type (void) G_GNUC_CONST;
Gimp * gimp_new (gboolean be_verbose,
Gimp * gimp_new (const gchar *name,
gboolean be_verbose,
gboolean no_data,
gboolean no_interface,
gboolean use_shm,
gboolean console_messages,
GimpStackTraceMode stack_trace_mode);
void gimp_set_config (Gimp *gimp,
GimpCoreConfig *core_config);
void gimp_load_config (Gimp *gimp,
const gchar *alternate_system_gimprc,
const gchar *alternate_gimprc,
gboolean use_cpu_accel);
void gimp_initialize (Gimp *gimp,
GimpInitStatusFunc status_callback);
void gimp_restore (Gimp *gimp,
GimpInitStatusFunc status_callback,
gboolean no_data);
gboolean restore_session);
void gimp_exit (Gimp *gimp,
gboolean kill_it);

View File

@ -41,5 +41,6 @@ VOID: OBJECT
VOID: OBJECT, INT
VOID: OBJECT, POINTER
VOID: POINTER
VOID: POINTER, BOOLEAN
VOID: STRING, FLAGS
VOID: VOID

View File

@ -572,9 +572,9 @@ user_install_tv_fix_size_request (GtkWidget *widget,
}
void
user_install_dialog_create (const gchar *alternate_system_gimprc,
const gchar *alternate_gimprc,
gboolean verbose)
user_install_dialog_run (const gchar *alternate_system_gimprc,
const gchar *alternate_gimprc,
gboolean verbose)
{
GimpRc *gimprc;
GtkWidget *dialog;
@ -972,6 +972,8 @@ user_install_dialog_create (const gchar *alternate_system_gimprc,
gtk_widget_grab_default (continue_button);
gtk_widget_show (dialog);
gtk_main ();
}

View File

@ -20,9 +20,9 @@
#define __USER_INSTALL_DIALOG_H__
void user_install_dialog_create (const gchar *alternate_system_gimprc,
const gchar *alernate_gimprc,
gboolean verbose);
void user_install_dialog_run (const gchar *alternate_system_gimprc,
const gchar *alernate_gimprc,
gboolean verbose);
#endif /* __USER_INSTALL_DIALOG_H__ */

View File

@ -170,6 +170,8 @@ libappgui_a_SOURCES = \
color-history.h \
gui.c \
gui.h \
gui-vtable.c \
gui-vtable.h \
gui-types.h \
session.c \
session.h \

266
app/gui/gui-vtable.c Normal file
View File

@ -0,0 +1,266 @@
/* 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.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimperrorconsole.h"
#include "widgets/gimpitemfactory.h"
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpprogress.h"
#include "brush-select.h"
#include "dialogs.h"
#include "font-select.h"
#include "gradient-select.h"
#include "menus.h"
#include "palette-select.h"
#include "pattern-select.h"
#include "plug-in-menus.h"
/* local function prototypes */
static void gui_threads_enter (Gimp *gimp);
static void gui_threads_leave (Gimp *gimp);
static void gui_set_busy (Gimp *gimp);
static void gui_unset_busy (Gimp *gimp);
static void gui_message (Gimp *gimp,
const gchar *domain,
const gchar *message);
static GimpObject * gui_display_new (GimpImage *gimage,
guint scale);
static void gui_menus_init (Gimp *gimp,
GSList *plug_in_defs,
const gchar *plugins_domain);
static void gui_menus_create_entry (Gimp *gimp,
PlugInProcDef *proc_def,
const gchar *locale_domain,
const gchar *help_domain);
static void gui_menus_delete_entry (Gimp *gimp,
const gchar *menu_path);
static GimpProgress * gui_start_progress (Gimp *gimp,
gint gdisp_ID,
const gchar *message,
GCallback cancel_cb,
gpointer cancel_data);
static GimpProgress * gui_restart_progress (Gimp *gimp,
GimpProgress *progress,
const gchar *message,
GCallback cancel_cb,
gpointer cancel_data);
static void gui_update_progress (Gimp *gimp,
GimpProgress *progress,
gdouble percentage);
static void gui_end_progress (Gimp *gimp,
GimpProgress *progress);
static void gui_pdb_dialogs_check (Gimp *gimp);
/* public functions */
void
gui_vtable_init (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
gimp->gui_threads_enter_func = gui_threads_enter;
gimp->gui_threads_leave_func = gui_threads_leave;
gimp->gui_set_busy_func = gui_set_busy;
gimp->gui_unset_busy_func = gui_unset_busy;
gimp->gui_message_func = gui_message;
gimp->gui_create_display_func = gui_display_new;
gimp->gui_menus_init_func = gui_menus_init;
gimp->gui_menus_create_func = gui_menus_create_entry;
gimp->gui_menus_delete_func = gui_menus_delete_entry;
gimp->gui_progress_start_func = gui_start_progress;
gimp->gui_progress_restart_func = gui_restart_progress;
gimp->gui_progress_update_func = gui_update_progress;
gimp->gui_progress_end_func = gui_end_progress;
gimp->gui_pdb_dialogs_check_func = gui_pdb_dialogs_check;
}
/* private functions */
static void
gui_threads_enter (Gimp *gimp)
{
GDK_THREADS_ENTER ();
}
static void
gui_threads_leave (Gimp *gimp)
{
GDK_THREADS_LEAVE ();
}
static void
gui_set_busy (Gimp *gimp)
{
gimp_displays_set_busy (gimp);
gimp_dialog_factories_idle ();
gdk_flush ();
}
static void
gui_unset_busy (Gimp *gimp)
{
gimp_displays_unset_busy (gimp);
gimp_dialog_factories_unidle ();
gdk_flush ();
}
static void
gui_message (Gimp *gimp,
const gchar *domain,
const gchar *message)
{
if (gimp->message_handler == GIMP_ERROR_CONSOLE)
{
GtkWidget *dockable;
dockable = gimp_dialog_factory_dialog_raise (global_dock_factory,
"gimp-error-console", -1);
if (dockable)
{
GimpErrorConsole *console;
console = GIMP_ERROR_CONSOLE (GTK_BIN (dockable)->child);
gimp_error_console_add (console, GIMP_STOCK_WARNING, domain, message);
return;
}
gimp->message_handler = GIMP_MESSAGE_BOX;
}
gimp_message_box (GIMP_STOCK_WARNING, domain, message, NULL, NULL);
}
static GimpObject *
gui_display_new (GimpImage *gimage,
guint scale)
{
GimpDisplayShell *shell;
GimpDisplay *gdisp;
gdisp = gimp_display_new (gimage, scale,
global_menu_factory,
gimp_item_factory_from_path ("<Image>"));
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gimp_context_set_display (gimp_get_user_context (gimage->gimp), gdisp);
gimp_item_factory_update (shell->menubar_factory, shell);
return GIMP_OBJECT (gdisp);
}
static void
gui_menus_init (Gimp *gimp,
GSList *plug_in_defs,
const gchar *std_plugins_domain)
{
plug_in_menus_init (gimp, plug_in_defs, std_plugins_domain);
}
static void
gui_menus_create_entry (Gimp *gimp,
PlugInProcDef *proc_def,
const gchar *locale_domain,
const gchar *help_domain)
{
plug_in_menus_create_entry (NULL, proc_def, locale_domain, help_domain);
}
static void
gui_menus_delete_entry (Gimp *gimp,
const gchar *menu_path)
{
plug_in_menus_delete_entry (menu_path);
}
static GimpProgress *
gui_start_progress (Gimp *gimp,
gint gdisp_ID,
const gchar *message,
GCallback cancel_cb,
gpointer cancel_data)
{
GimpDisplay *gdisp = NULL;
if (gdisp_ID > 0)
gdisp = gimp_display_get_by_ID (gimp, gdisp_ID);
return gimp_progress_start (gdisp, message, TRUE, cancel_cb, cancel_data);
}
static GimpProgress *
gui_restart_progress (Gimp *gimp,
GimpProgress *progress,
const gchar *message,
GCallback cancel_cb,
gpointer cancel_data)
{
return gimp_progress_restart (progress, message, cancel_cb, cancel_data);
}
static void
gui_update_progress (Gimp *gimp,
GimpProgress *progress,
gdouble percentage)
{
gimp_progress_update (progress, percentage);
}
static void
gui_end_progress (Gimp *gimp,
GimpProgress *progress)
{
gimp_progress_end (progress);
}
static void
gui_pdb_dialogs_check (Gimp *gimp)
{
brush_select_dialogs_check ();
font_select_dialogs_check ();
gradient_select_dialogs_check ();
palette_select_dialogs_check ();
pattern_select_dialogs_check ();
}

26
app/gui/gui-vtable.h Normal file
View File

@ -0,0 +1,26 @@
/* 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.
*/
#ifndef __GUI_VTABLE_H__
#define __GUI_VTABLE_H__
void gui_vtable_init (Gimp *gimp);
#endif /* __GUI_VTABLE_H__ */

View File

@ -41,103 +41,75 @@
#include "display/gimpdisplay-foreach.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-render.h"
#include "display/gimpprogress.h"
#include "tools/gimp-tools.h"
#include "widgets/gimpdevices.h"
#include "widgets/gimpdevicestatus.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimperrorconsole.h"
#include "widgets/gimphelp.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpitemfactory.h"
#include "widgets/gimpmenufactory.h"
#include "widgets/gimpwidgets-utils.h"
#include "brush-select.h"
#include "dialogs.h"
#include "dialogs-commands.h"
#include "font-select.h"
#include "gradient-select.h"
#include "gui.h"
#include "gui-vtable.h"
#include "menus.h"
#include "palette-select.h"
#include "pattern-select.h"
#include "plug-in-menus.h"
#include "session.h"
#include "splash.h"
#include "themes.h"
#include "app_procs.h" /* FIXME */
#include "gimp-intl.h"
/* local function prototypes */
static void gui_help_func (const gchar *help_id,
gpointer help_data);
static gboolean gui_get_background_func (GimpRGB *color);
static gboolean gui_get_foreground_func (GimpRGB *color);
static void gui_help_func (const gchar *help_id,
gpointer help_data);
static gboolean gui_get_background_func (GimpRGB *color);
static gboolean gui_get_foreground_func (GimpRGB *color);
static void gui_threads_enter (Gimp *gimp);
static void gui_threads_leave (Gimp *gimp);
static void gui_set_busy (Gimp *gimp);
static void gui_unset_busy (Gimp *gimp);
static void gui_message (Gimp *gimp,
const gchar *domain,
const gchar *message);
static GimpObject * gui_display_new (GimpImage *gimage,
guint scale);
static void gui_menus_init (Gimp *gimp,
GSList *plug_in_defs,
const gchar *plugins_domain);
static void gui_menus_create_entry (Gimp *gimp,
PlugInProcDef *proc_def,
const gchar *locale_domain,
const gchar *help_domain);
static void gui_menus_delete_entry (Gimp *gimp,
const gchar *menu_path);
static GimpProgress * gui_start_progress (Gimp *gimp,
gint gdisp_ID,
const gchar *message,
GCallback cancel_cb,
gpointer cancel_data);
static GimpProgress * gui_restart_progress (Gimp *gimp,
GimpProgress *progress,
const gchar *message,
GCallback cancel_cb,
gpointer cancel_data);
static void gui_update_progress (Gimp *gimp,
GimpProgress *progress,
gdouble percentage);
static void gui_end_progress (Gimp *gimp,
GimpProgress *progress);
static void gui_pdb_dialogs_check (Gimp *gimp);
static void gui_initialize_after_callback (Gimp *gimp,
GimpInitStatusFunc callback);
static gboolean gui_exit_callback (Gimp *gimp,
gboolean kill_it);
static gboolean gui_exit_finish_callback (Gimp *gimp,
gboolean kill_it);
static void gui_really_quit_callback (GtkWidget *button,
gboolean quit,
gpointer data);
static void gui_show_tooltips_notify (GObject *config,
GParamSpec *param_spec,
Gimp *gimp);
static void gui_device_change_notify (Gimp *gimp);
static void gui_restore_callback (Gimp *gimp,
GimpInitStatusFunc callback,
gboolean restore_session);
static void gui_restore_after_callback (Gimp *gimp,
GimpInitStatusFunc callback,
gboolean restore_session);
static void gui_display_changed (GimpContext *context,
GimpDisplay *display,
Gimp *gimp);
static void gui_image_disconnect (GimpImage *gimage,
Gimp *gimp);
static gboolean gui_exit_callback (Gimp *gimp,
gboolean kill_it);
static gboolean gui_exit_after_callback (Gimp *gimp,
gboolean kill_it);
static void gui_really_quit_callback (GtkWidget *button,
gboolean quit,
gpointer data);
static void gui_show_tooltips_notify (GObject *config,
GParamSpec *param_spec,
Gimp *gimp);
static void gui_device_change_notify (Gimp *gimp);
static void gui_display_changed (GimpContext *context,
GimpDisplay *display,
Gimp *gimp);
static void gui_image_disconnect (GimpImage *gimage,
Gimp *gimp);
/* private variables */
static GQuark image_disconnect_handler_id = 0;
static Gimp *the_gui_gimp = NULL;
static GimpItemFactory *toolbox_item_factory = NULL;
static GimpItemFactory *image_item_factory = NULL;
static GQuark image_disconnect_handler_id = 0;
static GimpItemFactory *toolbox_item_factory = NULL;
static GimpItemFactory *image_item_factory = NULL;
/* public functions */
@ -175,13 +147,120 @@ gui_libs_init (gint *argc,
return TRUE;
}
GimpInitStatusFunc
gui_init (Gimp *gimp,
gboolean no_splash,
gboolean no_splash_image)
{
GimpInitStatusFunc status_callback = NULL;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (the_gui_gimp == NULL, NULL);
the_gui_gimp = gimp;
themes_init (gimp);
gdk_rgb_set_min_colors (CLAMP (gimp->config->min_colors, 27, 256));
gdk_rgb_set_install (gimp->config->install_cmap);
gtk_widget_set_default_colormap (gdk_rgb_get_colormap ());
if (! no_splash)
{
splash_create (! no_splash_image);
status_callback = splash_update;
}
g_signal_connect_after (gimp, "initialize",
G_CALLBACK (gui_initialize_after_callback),
NULL);
g_signal_connect (gimp, "restore",
G_CALLBACK (gui_restore_callback),
NULL);
g_signal_connect_after (gimp, "restore",
G_CALLBACK (gui_restore_after_callback),
NULL);
g_signal_connect (gimp, "exit",
G_CALLBACK (gui_exit_callback),
NULL);
g_signal_connect_after (gimp, "exit",
G_CALLBACK (gui_exit_after_callback),
NULL);
return status_callback;
}
void
gui_environ_init (Gimp *gimp)
gui_post_init (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (GIMP_GUI_CONFIG (gimp->config)->show_tips)
gimp_dialog_factory_dialog_new (global_dialog_factory,
"gimp-tips-dialog", -1);
#ifdef __GNUC__
#warning FIXME: remove this as soon as we depend on GTK+ >= 2.2.2
#endif
if (gtk_check_version (2, 2, 2) != NULL)
gimp_message_box (GIMP_STOCK_WILBER_EEK, NULL,
"Please upgrade your GTK+ installation!\n\n"
"The GTK+ version you are using is too old.\n"
"Please upgrade to GTK+ version 2.2.2 or better\n"
"or your extended input devices (tablets) will\n"
"not work at all!",
NULL, NULL);
}
/* private functions */
static void
gui_help_func (const gchar *help_id,
gpointer help_data)
{
g_return_if_fail (GIMP_IS_GIMP (the_gui_gimp));
gimp_help (the_gui_gimp, NULL, help_id);
}
static gboolean
gui_get_foreground_func (GimpRGB *color)
{
g_return_val_if_fail (color != NULL, FALSE);
g_return_val_if_fail (GIMP_IS_GIMP (the_gui_gimp), FALSE);
gimp_context_get_foreground (gimp_get_user_context (the_gui_gimp), color);
return TRUE;
}
static gboolean
gui_get_background_func (GimpRGB *color)
{
g_return_val_if_fail (color != NULL, FALSE);
g_return_val_if_fail (GIMP_IS_GIMP (the_gui_gimp), FALSE);
gimp_context_get_background (gimp_get_user_context (the_gui_gimp), color);
return TRUE;
}
static void
gui_initialize_after_callback (Gimp *gimp,
GimpInitStatusFunc status_callback)
{
const gchar *name = NULL;
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (gimp->be_verbose)
g_print ("INIT: gui_initialize_after_callback\n");
#if defined (GDK_WINDOWING_X11)
name = "DISPLAY";
#elif defined (GDK_WINDOWING_DIRECTFB) || defined (GDK_WINDOWING_FB)
@ -198,59 +277,38 @@ gui_environ_init (Gimp *gimp)
gimp_environ_table_add (gimp->environ_table, name, display, NULL);
g_free (display);
}
gimp_tools_init (gimp);
}
void
gui_themes_init (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
themes_init (gimp);
if (! GIMP_GUI_CONFIG (gimp->config)->show_tool_tips)
gimp_help_disable_tooltips ();
g_signal_connect (gimp->config, "notify::show-tool-tips",
G_CALLBACK (gui_show_tooltips_notify),
gimp);
gdk_rgb_set_min_colors (CLAMP (gimp->config->min_colors, 27, 256));
gdk_rgb_set_install (gimp->config->install_cmap);
gtk_widget_set_default_colormap (gdk_rgb_get_colormap ());
}
void
gui_init (Gimp *gimp)
static void
gui_restore_callback (Gimp *gimp,
GimpInitStatusFunc status_callback,
gboolean restore_session)
{
GimpDisplayConfig *display_config;
GimpGuiConfig *gui_config;
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (gimp->be_verbose)
g_print ("INIT: gui_restore_callback\n");
display_config = GIMP_DISPLAY_CONFIG (gimp->config);
gui_config = GIMP_GUI_CONFIG (gimp->config);
gimp->gui_threads_enter_func = gui_threads_enter;
gimp->gui_threads_leave_func = gui_threads_leave;
gimp->gui_set_busy_func = gui_set_busy;
gimp->gui_unset_busy_func = gui_unset_busy;
gimp->gui_message_func = gui_message;
gimp->gui_create_display_func = gui_display_new;
gimp->gui_menus_init_func = gui_menus_init;
gimp->gui_menus_create_func = gui_menus_create_entry;
gimp->gui_menus_delete_func = gui_menus_delete_entry;
gimp->gui_progress_start_func = gui_start_progress;
gimp->gui_progress_restart_func = gui_restart_progress;
gimp->gui_progress_update_func = gui_update_progress;
gimp->gui_progress_end_func = gui_end_progress;
gimp->gui_pdb_dialogs_check_func = gui_pdb_dialogs_check;
gui_vtable_init (gimp);
image_disconnect_handler_id =
gimp_container_add_handler (gimp->images, "disconnect",
G_CALLBACK (gui_image_disconnect),
gimp);
if (! gui_config->show_tool_tips)
gimp_help_disable_tooltips ();
g_signal_connect (gui_config, "notify::show-tool-tips",
G_CALLBACK (gui_show_tooltips_notify),
gimp);
g_signal_connect (gimp_get_user_context (gimp), "display_changed",
G_CALLBACK (gui_display_changed),
gimp);
@ -278,15 +336,20 @@ gui_init (Gimp *gimp)
gimp_devices_init (gimp, gui_device_change_notify);
session_init (gimp);
(* status_callback) (NULL, _("Tool Options"), 1.0);
gimp_tools_restore (gimp);
}
void
gui_restore (Gimp *gimp,
gboolean restore_session)
static void
gui_restore_after_callback (Gimp *gimp,
GimpInitStatusFunc status_callback,
gboolean restore_session)
{
GimpGuiConfig *gui_config;
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (gimp->be_verbose)
g_print ("INIT: gui_restore_after_callback\n");
gui_config = GIMP_GUI_CONFIG (gimp->config);
@ -309,222 +372,13 @@ gui_restore (Gimp *gimp,
gimp_devices_restore (gimp);
if (status_callback == splash_update)
splash_destroy ();
if (gui_config->restore_session || restore_session)
session_restore (gimp);
dialogs_show_toolbox ();
g_signal_connect (gimp, "exit",
G_CALLBACK (gui_exit_callback),
NULL);
g_signal_connect_after (gimp, "exit",
G_CALLBACK (gui_exit_finish_callback),
NULL);
#ifdef __GNUC__
#warning FIXME: remove this as soon as we depend on GTK+ >= 2.2.2
#endif
if (gtk_check_version (2, 2, 2) != NULL)
gimp_message_box (GIMP_STOCK_WILBER_EEK, NULL,
"Please upgrade your GTK+ installation!\n\n"
"The GTK+ version you are using is too old.\n"
"Please upgrade to GTK+ version 2.2.2 or better\n"
"or your extended input devices (tablets) will\n"
"not work at all!",
NULL, NULL);
}
void
gui_post_init (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (GIMP_GUI_CONFIG (gimp->config)->show_tips)
gimp_dialog_factory_dialog_new (global_dialog_factory,
"gimp-tips-dialog", -1);
}
/* private functions */
static void
gui_help_func (const gchar *help_id,
gpointer help_data)
{
gimp_help (the_gimp, NULL, help_id);
}
static gboolean
gui_get_foreground_func (GimpRGB *color)
{
g_return_val_if_fail (color != NULL, FALSE);
gimp_context_get_foreground (gimp_get_user_context (the_gimp), color);
return TRUE;
}
static gboolean
gui_get_background_func (GimpRGB *color)
{
g_return_val_if_fail (color != NULL, FALSE);
gimp_context_get_background (gimp_get_user_context (the_gimp), color);
return TRUE;
}
static void
gui_threads_enter (Gimp *gimp)
{
GDK_THREADS_ENTER ();
}
static void
gui_threads_leave (Gimp *gimp)
{
GDK_THREADS_LEAVE ();
}
static void
gui_set_busy (Gimp *gimp)
{
gimp_displays_set_busy (gimp);
gimp_dialog_factories_idle ();
gdk_flush ();
}
static void
gui_unset_busy (Gimp *gimp)
{
gimp_displays_unset_busy (gimp);
gimp_dialog_factories_unidle ();
gdk_flush ();
}
static void
gui_message (Gimp *gimp,
const gchar *domain,
const gchar *message)
{
if (gimp->message_handler == GIMP_ERROR_CONSOLE)
{
GtkWidget *dockable;
dockable = gimp_dialog_factory_dialog_raise (global_dock_factory,
"gimp-error-console", -1);
if (dockable)
{
GimpErrorConsole *console;
console = GIMP_ERROR_CONSOLE (GTK_BIN (dockable)->child);
gimp_error_console_add (console, GIMP_STOCK_WARNING, domain, message);
return;
}
gimp->message_handler = GIMP_MESSAGE_BOX;
}
gimp_message_box (GIMP_STOCK_WARNING, domain, message, NULL, NULL);
}
static GimpObject *
gui_display_new (GimpImage *gimage,
guint scale)
{
GimpDisplayShell *shell;
GimpDisplay *gdisp;
gdisp = gimp_display_new (gimage, scale,
global_menu_factory,
image_item_factory);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gimp_context_set_display (gimp_get_user_context (gimage->gimp), gdisp);
gimp_item_factory_update (shell->menubar_factory, shell);
return GIMP_OBJECT (gdisp);
}
static void
gui_menus_init (Gimp *gimp,
GSList *plug_in_defs,
const gchar *std_plugins_domain)
{
plug_in_menus_init (gimp, plug_in_defs, std_plugins_domain);
}
static void
gui_menus_create_entry (Gimp *gimp,
PlugInProcDef *proc_def,
const gchar *locale_domain,
const gchar *help_domain)
{
plug_in_menus_create_entry (NULL, proc_def, locale_domain, help_domain);
}
static void
gui_menus_delete_entry (Gimp *gimp,
const gchar *menu_path)
{
plug_in_menus_delete_entry (menu_path);
}
static GimpProgress *
gui_start_progress (Gimp *gimp,
gint gdisp_ID,
const gchar *message,
GCallback cancel_cb,
gpointer cancel_data)
{
GimpDisplay *gdisp = NULL;
if (gdisp_ID > 0)
gdisp = gimp_display_get_by_ID (gimp, gdisp_ID);
return gimp_progress_start (gdisp, message, TRUE, cancel_cb, cancel_data);
}
static GimpProgress *
gui_restart_progress (Gimp *gimp,
GimpProgress *progress,
const gchar *message,
GCallback cancel_cb,
gpointer cancel_data)
{
return gimp_progress_restart (progress, message, cancel_cb, cancel_data);
}
static void
gui_update_progress (Gimp *gimp,
GimpProgress *progress,
gdouble percentage)
{
gimp_progress_update (progress, percentage);
}
static void
gui_end_progress (Gimp *gimp,
GimpProgress *progress)
{
gimp_progress_end (progress);
}
static void
gui_pdb_dialogs_check (Gimp *gimp)
{
brush_select_dialogs_check ();
font_select_dialogs_check ();
gradient_select_dialogs_check ();
palette_select_dialogs_check ();
pattern_select_dialogs_check ();
}
static gboolean
@ -533,6 +387,9 @@ gui_exit_callback (Gimp *gimp,
{
GimpGuiConfig *gui_config;
if (gimp->be_verbose)
g_print ("EXIT: gui_exit_callback\n");
if (! kill_it && gimp_displays_dirty (gimp))
{
GtkWidget *dialog;
@ -571,13 +428,19 @@ gui_exit_callback (Gimp *gimp,
gimp_displays_delete (gimp);
gimp_tools_save (gimp);
gimp_tools_exit (gimp);
return FALSE; /* continue exiting */
}
static gboolean
gui_exit_finish_callback (Gimp *gimp,
gboolean kill_it)
gui_exit_after_callback (Gimp *gimp,
gboolean kill_it)
{
if (gimp->be_verbose)
g_print ("EXIT: gui_exit_after_callback\n");
g_signal_handlers_disconnect_by_func (gimp->config,
gui_show_tooltips_notify,
gimp);

View File

@ -20,17 +20,13 @@
#define __GUI_H__
gboolean gui_libs_init (gint *argc,
gchar ***argv);
gboolean gui_libs_init (gint *argc,
gchar ***argv);
void gui_environ_init (Gimp *gimp);
void gui_themes_init (Gimp *gimp);
void gui_init (Gimp *gimp);
void gui_restore (Gimp *gimp,
gboolean restore_session);
void gui_post_init (Gimp *gimp);
GimpInitStatusFunc gui_init (Gimp *gimp,
gboolean no_spash,
gboolean no_splash_image);
void gui_post_init (Gimp *gimp);
#endif /* __GUI_H__ */

View File

@ -572,9 +572,9 @@ user_install_tv_fix_size_request (GtkWidget *widget,
}
void
user_install_dialog_create (const gchar *alternate_system_gimprc,
const gchar *alternate_gimprc,
gboolean verbose)
user_install_dialog_run (const gchar *alternate_system_gimprc,
const gchar *alternate_gimprc,
gboolean verbose)
{
GimpRc *gimprc;
GtkWidget *dialog;
@ -972,6 +972,8 @@ user_install_dialog_create (const gchar *alternate_system_gimprc,
gtk_widget_grab_default (continue_button);
gtk_widget_show (dialog);
gtk_main ();
}

View File

@ -20,9 +20,9 @@
#define __USER_INSTALL_DIALOG_H__
void user_install_dialog_create (const gchar *alternate_system_gimprc,
const gchar *alernate_gimprc,
gboolean verbose);
void user_install_dialog_run (const gchar *alternate_system_gimprc,
const gchar *alernate_gimprc,
gboolean verbose);
#endif /* __USER_INSTALL_DIALOG_H__ */