Commit 9d87e554 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

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.
parent d7fde9e6
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-09 Michael Natterer <mitch@gimp.org>
* app/Makefile.am
......
......@@ -341,7 +341,7 @@ plug_in_init (void)
filename = gimp_personal_rc_file ("pluginrc");
app_init_update_status (_("Resource configuration"), filename, -1);
parse_gimprc_file (filename);
gimprc_parse_file (filename);
/* query any plug-ins that have changed since we last wrote out
* the pluginrc file.
......
......@@ -23,6 +23,11 @@
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <gtk/gtk.h>
......@@ -42,7 +47,6 @@
#include "tools/tool_manager.h"
#include "gui/color-notebook.h"
#include "gui/file-open-dialog.h"
#include "gui/gui.h"
#include "gui/splash.h"
......@@ -51,16 +55,15 @@
#include "app_procs.h"
#include "batch.h"
#include "colormaps.h"
#include "docindex.h"
#include "errors.h"
#include "gdisplay.h"
#include "gdisplay_ops.h"
#include "gimprc.h"
#include "plug_in.h"
#include "module_db.h"
#include "plug_in.h"
#include "undo.h"
#include "unitrc.h"
#include "errors.h"
#include "docindex.h"
#include "user_install.h"
#ifdef DISPLAY_FILTERS
#include "gdisplay_color.h"
......@@ -72,9 +75,6 @@
Gimp *the_gimp = NULL;
/* FIXME: gimp_busy HACK */
gboolean gimp_busy = FALSE;
static gboolean is_app_exit_finish_done = FALSE;
......@@ -89,38 +89,77 @@ app_init_update_status (const gchar *text1,
}
}
/* #define RESET_BAR() app_init_update_status("", "", 0) */
#define RESET_BAR()
void
app_init (gint gimp_argc,
gchar **gimp_argv)
{
const gchar *gtkrc;
gchar *filename;
const gchar *gimp_dir;
struct stat stat_buf;
/* Create an instance of the "Gimp" object which is the root of the
* core object system
*/
the_gimp = gimp_new ();
gtk_object_ref (GTK_OBJECT (the_gimp));
gtk_object_sink (GTK_OBJECT (the_gimp));
/* parse the systemwide gtkrc */
gtkrc = gimp_gtkrc ();
/* Check if the usesr's gimp_directory exists
*/
gimp_dir = gimp_directory ();
if (be_verbose)
g_print (_("parsing \"%s\"\n"), gtkrc);
if (stat (gimp_dir, &stat_buf) != 0)
{
/* not properly installed */
if (no_interface)
{
g_print (_("The GIMP is not properly installed for the current user\n"));
g_print (_("User installation was skipped because the '--nointerface' flag was encountered\n"));
g_print (_("To perform user installation, run the GIMP without the '--nointerface' flag\n"));
}
else
{
user_install_dialog_create (the_gimp);
gtk_main ();
}
}
gtk_rc_parse (gtkrc);
if (! no_interface)
{
const gchar *gtkrc;
gchar *filename;
/* parse the systemwide gtkrc */
gtkrc = gimp_gtkrc ();
/* parse the user gtkrc */
filename = gimp_personal_rc_file ("gtkrc");
if (be_verbose)
g_print (_("parsing \"%s\"\n"), gtkrc);
if (be_verbose)
g_print (_("parsing \"%s\"\n"), filename);
gtk_rc_parse (gtkrc);
gtk_rc_parse (filename);
/* parse the user gtkrc */
filename = gimp_personal_rc_file ("gtkrc");
g_free (filename);
if (be_verbose)
g_print (_("parsing \"%s\"\n"), filename);
if (gimprc_init ())
gtk_rc_parse (filename);
g_free (filename);
}
/* The user_install dialog may have parsed unitrc and gimprc, so
* check gimprc_init()'s return value
*/
if (gimprc_init (the_gimp))
{
parse_unitrc (); /* this needs to be done before gimprc loading */
parse_gimprc (); /* parse the local GIMP configuration file */
/* this needs to be done before gimprc loading */
gimp_unitrc_load (the_gimp);
/* parse the local GIMP configuration file */
gimprc_parse (the_gimp);
}
if (! no_interface)
......@@ -134,13 +173,10 @@ app_init (gint gimp_argc,
/* initialize lowlevel stuff */
base_init ();
/* Create an instance of the "Gimp" object which is the root of the
* core object system
/* Create all members of the global Gimp instance which need an already
* parsed gimprc, e.g. the data factories
*/
the_gimp = gimp_new ();
gtk_object_ref (GTK_OBJECT (the_gimp));
gtk_object_sink (GTK_OBJECT (the_gimp));
gimp_initialize (the_gimp);
tool_manager_init (the_gimp);
......@@ -155,27 +191,25 @@ app_init (gint gimp_argc,
color_display_init ();
#endif /* DISPLAY_FILTERS */
RESET_BAR();
if (gimprc.always_restore_session)
restore_session = TRUE;
/* Initialize the xcf file format routines
*/
xcf_init (the_gimp);
/* Now we are ready to draw the splash-screen-image to the start-up window */
/* Now we are ready to draw the splash-screen-image
* to the start-up window
*/
if (! no_interface && ! no_splash_image)
{
splash_logo_load ();
}
RESET_BAR();
xcf_init (the_gimp); /* initialize the xcf file format routines */
/* load all data files */
gimp_restore (the_gimp);
/* Load all data files
*/
gimp_restore (the_gimp, no_data);
plug_in_init (); /* initialize the plug in structures */
module_db_init (); /* load any modules we need */
RESET_BAR();
if (! no_interface)
{
if (! no_splash)
......@@ -185,14 +219,12 @@ app_init (gint gimp_argc,
/* FIXME: This needs to go in preferences */
message_handler = MESSAGE_BOX;
}
if (! no_interface)
{
gui_restore (the_gimp);
}
/* Parse the rest of the command line arguments as images to load */
/* Parse the rest of the command line arguments as images to load
*/
if (gimp_argc > 0)
while (gimp_argc--)
{
......@@ -235,9 +267,7 @@ app_exit_finish (void)
}
module_db_free ();
gdisplays_delete ();
plug_in_kill ();
save_unitrc ();
tool_manager_exit (the_gimp);
......@@ -266,46 +296,3 @@ app_exit_finish_done (void)
{
return is_app_exit_finish_done;
}
void
gimp_set_busy (void)
{
/* FIXME: gimp_busy HACK */
gimp_busy = TRUE;
gui_set_busy (the_gimp);
}
static gboolean
gimp_idle_unset_busy (gpointer data)
{
gimp_unset_busy ();
*((guint *) data) = 0;
return FALSE;
}
void
gimp_set_busy_until_idle (void)
{
static guint busy_idle_id = 0;
if (! busy_idle_id)
{
gimp_set_busy ();
busy_idle_id = g_idle_add_full (G_PRIORITY_HIGH,
gimp_idle_unset_busy, &busy_idle_id,
NULL);
}
}
void
gimp_unset_busy (void)
{
gui_unset_busy (the_gimp);
/* FIXME: gimp_busy HACK */
gimp_busy = FALSE;
}
......@@ -26,19 +26,15 @@
extern Gimp *the_gimp;
void app_init_update_status (const gchar *label1,
const gchar *label2,
gdouble percentage);
void app_init (gint gimp_argc,
gchar **gimp_argv);
void app_exit (gboolean kill_it);
void app_exit_finish (void);
gboolean app_exit_finish_done (void);
void gimp_set_busy (void);
void gimp_set_busy_until_idle (void);
void gimp_unset_busy (void);
void app_init_update_status (const gchar *label1,
const gchar *label2,
gdouble percentage);
void app_init (gint gimp_argc,
gchar **gimp_argv);
void app_exit (gboolean kill_it);
void app_exit_finish (void);
gboolean app_exit_finish_done (void);
#endif /* __APP_PROCS_H__ */
......@@ -20,6 +20,20 @@
#define __APPENUMS_H__
typedef enum
{
MESSAGE_BOX,
CONSOLE,
ERROR_CONSOLE
} MessageHandlerType;
typedef enum
{
STACK_TRACE_NEVER,
STACK_TRACE_QUERY,
STACK_TRACE_ALWAYS
} StackTraceMode;
/* Brush application types */
typedef enum
{
......
......@@ -20,28 +20,25 @@
#define __APPENV_H__
typedef enum
{
MESSAGE_BOX,
CONSOLE,
ERROR_CONSOLE
} MessageHandlerType;
extern gboolean no_interface;
extern gboolean no_splash;
extern gboolean no_splash_image;
extern gboolean no_data;
extern gboolean be_verbose;
extern gboolean use_debug_handler;
extern gboolean console_messages;
extern gboolean restore_session;
extern gboolean double_speed;
extern MessageHandlerType message_handler;
/* FIXME: gimp_busy HACK */
extern gboolean gimp_busy;
/* command line options */
extern gboolean no_interface;
extern gboolean no_splash;
extern gboolean no_splash_image;
extern gboolean no_data;
extern gboolean be_verbose;
extern gboolean use_debug_handler;
extern gboolean console_messages;
extern gboolean restore_session;
extern StackTraceMode stack_trace_mode;
extern gchar *alternate_gimprc;
extern gchar *alternate_system_gimprc;
extern gchar **batch_cmds;
/* other global variables */
extern gchar *prog_name;
extern MessageHandlerType message_handler;
extern gboolean double_speed;
extern gboolean use_mmx;
#endif /* __APPENV_H__ */
......@@ -51,11 +51,10 @@ static void batch_pserver (Gimp *gimp,
static ProcRecord *eval_proc;
void
batch_init (Gimp *gimp)
{
extern gchar **batch_cmds;
gboolean read_from_stdin;
gboolean perl_server_already_running = FALSE;
gint i;
......
......@@ -20,7 +20,7 @@
#include <gtk/gtk.h>
#include "apptypes.h"
#include "core/core-types.h"
#include "colormaps.h"
#include "gimprc.h"
......
......@@ -149,7 +149,7 @@ gimp_parasiterc_load (Gimp *gimp)
gchar *filename;
filename = gimp_personal_rc_file ("parasiterc");
parse_gimprc_file (filename);
gimprc_parse_file (filename);
g_free (filename);
}
......
......@@ -558,7 +558,7 @@ gimp_transform_tool_doit (GimpTransformTool *gt_tool,
gboolean new_layer;
gint i, x, y;
gimp_set_busy ();
gimp_set_busy (gdisp->gimage->gimp);
tool = GIMP_TOOL (gt_tool);
......@@ -655,7 +655,7 @@ gimp_transform_tool_doit (GimpTransformTool *gt_tool,
}
}
gimp_unset_busy ();
gimp_unset_busy (gdisp->gimage->gimp);
gdisplays_flush ();
......
......@@ -45,16 +45,19 @@
#include "gimpparasite.h"
#include "gimptoolinfo.h"
#include "appenv.h"
#include "app_procs.h"
#include "unitrc.h"
#include "libgimp/gimpintl.h"
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_destroy (GtkObject *object);
static void gimp_destroy (GtkObject *object);
static void gimp_context_destroy_callback (GimpContext *context,
Gimp *gimp);
static GimpObjectClass *parent_class = NULL;
......@@ -100,40 +103,15 @@ gimp_class_init (GimpClass *klass)
static void
gimp_init (Gimp *gimp)
{
GimpContext *context;
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 gint n_brush_loader_entries = (sizeof (brush_loader_entries) /
sizeof (brush_loader_entries[0]));
static const GimpDataFactoryLoaderEntry pattern_loader_entries[] =
{
{ gimp_pattern_load, GIMP_PATTERN_FILE_EXTENSION }
};
static gint n_pattern_loader_entries = (sizeof (pattern_loader_entries) /
sizeof (pattern_loader_entries[0]));
gimp->create_display_func = NULL;
gimp->gui_set_busy_func = NULL;
gimp->gui_unset_busy_func = NULL;
static const GimpDataFactoryLoaderEntry gradient_loader_entries[] =
{
{ gimp_gradient_load, GIMP_GRADIENT_FILE_EXTENSION },
{ gimp_gradient_load, NULL /* legacy loader */ }
};
static gint n_gradient_loader_entries = (sizeof (gradient_loader_entries) /
sizeof (gradient_loader_entries[0]));
gimp->busy = FALSE;
gimp->busy_idle_id = 0;
static const GimpDataFactoryLoaderEntry palette_loader_entries[] =
{
{ gimp_palette_load, GIMP_PALETTE_FILE_EXTENSION },
{ gimp_palette_load, NULL /* legacy loader */ }
};
static gint n_palette_loader_entries = (sizeof (palette_loader_entries) /
sizeof (palette_loader_entries[0]));
gimp->user_units = NULL;
gimp->n_user_units = 0;
gimp->images = gimp_list_new (GIMP_TYPE_IMAGE,
GIMP_CONTAINER_POLICY_WEAK);
......@@ -146,47 +124,12 @@ gimp_init (Gimp *gimp)
gtk_object_ref (GTK_OBJECT (gimp->named_buffers));
gtk_object_sink (GTK_OBJECT (gimp->named_buffers));
gimp_parasites_init (gimp);
gimp->brush_factory =
gimp_data_factory_new (GIMP_TYPE_BRUSH,
(const gchar **) &core_config->brush_path,
brush_loader_entries,
n_brush_loader_entries,
gimp_brush_new,
gimp_brush_get_standard);
gtk_object_ref (GTK_OBJECT (gimp->brush_factory));
gtk_object_sink (GTK_OBJECT (gimp->brush_factory));
gimp->pattern_factory =
gimp_data_factory_new (GIMP_TYPE_PATTERN,
(const gchar **) &core_config->pattern_path,
pattern_loader_entries,
n_pattern_loader_entries,
gimp_pattern_new,
gimp_pattern_get_standard);
gtk_object_ref (GTK_OBJECT (gimp->pattern_factory));
gtk_object_sink (GTK_OBJECT (gimp->pattern_factory));
gimp->parasites = NULL;
gimp->gradient_factory =
gimp_data_factory_new (GIMP_TYPE_GRADIENT,
(const gchar **) &core_config->gradient_path,
gradient_loader_entries,
n_gradient_loader_entries,
gimp_gradient_new,
gimp_gradient_get_standard);
gtk_object_ref (GTK_OBJECT (gimp->gradient_factory));
gtk_object_sink (GTK_OBJECT (gimp->gradient_factory));
gimp->palette_factory =
gimp_data_factory_new (GIMP_TYPE_PALETTE,
(const gchar **) &core_config->palette_path,
palette_loader_entries,
n_palette_loader_entries,
gimp_palette_new,
gimp_palette_get_standard);
gtk_object_ref (GTK_OBJECT (gimp->palette_factory));
gtk_object_sink (GTK_OBJECT (gimp->palette_factory));
gimp->brush_factory = NULL;
gimp->pattern_factory = NULL;
gimp->gradient_factory = NULL;
gimp->palette_factory = NULL;
procedural_db_init (gimp);
......@@ -195,20 +138,15 @@ gimp_init (Gimp *gimp)
gtk_object_ref (GTK_OBJECT (gimp->tool_info_list));
gtk_object_sink (GTK_OBJECT (gimp->tool_info_list));
gimp_image_new_init (gimp);
gimp->standard_context = gimp_create_context (gimp, "Standard", NULL);
gtk_object_ref (GTK_OBJECT (gimp->standard_context));
gtk_object_sink (GTK_OBJECT (gimp->standard_context));
/* TODO: load from disk */
context = gimp_create_context (gimp, "Default", NULL);
gimp_set_default_context (gimp, context);
context = gimp_create_context (gimp, "User", context);
gimp_set_user_context (gimp, context);
gimp->image_base_type_names = NULL;
gimp->fill_type_names = NULL;
gimp->have_current_cut_buffer = FALSE;
gimp_set_current_context (gimp, context);
gimp->context_list = NULL;
gimp->standard_context = NULL;
gimp->default_context = NULL;
gimp->user_context = NULL;
gimp->current_context = NULL;
}
static void
......@@ -287,6 +225,15 @@ gimp_destroy (GtkObject *object)
gimp->images = NULL;
}
if (gimp->user_units)
{
g_list_foreach (gimp->user_units, (GFunc) g_free, NULL);
g_list_free (gimp->user_units);
gimp->user_units = NULL;
gimp->n_user_units = 0;
}
if (GTK_OBJECT_CLASS (parent_class)->destroy)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
......@@ -302,7 +249,107 @@ gimp_new (void)
}
void
gimp_restore (Gimp *gimp)
gimp_initialize (Gimp *gimp)
{
GimpContext *context;
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 },