gimp/app/app_procs.c
Daniel Egger 1ed9180112 Convert ugly comments into named structure fields. Much cleaner and less
2001-12-02  Daniel Egger  <degger@fhm.edu>

	* app/gimprc.c: Convert ugly comments into named structure fields.
	Much cleaner and less errorprone though may cause troubles on
	older compilers and then needs to be reverted. Please report!

	* app/base/base-types.h: Add FIXME reminder.

	* app/base/gimplut.c: Use CLAMP macro instead of if-cascade.

	* app/base/temp-buf.c: Remove duplicated calculations and simplify
	checks.

	* app/base/tile-manager.c:
	- (tile_manager_get_tile_num): Return success and take an additional
	  pointer for the tilenumber.
	- Simplify logic in the rest of the file as a result.
	- Remove rotten debugging cruft.

	* app/core/gimpbrushgenerated.c: Fix two stylistic nits.

	* app/app_procs.c: Include <stdlib.h> for exit () prototype.

	* app/core/gimpdrawable-blend.c: Include <stdlib.h> for abs ()
	prototype.

	* app/display/gimpdisplay.c: Include <string.h> for memcpy ()
	prototype.

	* app/core/gimpimage-convert.c: (HIST_RGB): First parameter is
	not const. Fixes a gcc warning for a wrong return value.

	* libgimpwidgets/gimpunitmenu.c
	* app/core/gimpunit.c: Add suggested (by gcc 3.1 cvs) parentheses
	to group correct logic tests together.

	* app/paint-funcs/paint-funcs-generic.h: Fix my HAS_ALPHA macro
	to avoid gcc 3.1 cvs warning.

	* app/gimprc.h
	* pathP.h
	* base-config.h
	* app/base/boundary.h
	* app/base/gimplut.[ch]
	* app/base/pixel-region.h
	* app/base/pixel-surround.[ch]
	* app/base/temp-buf.[ch]
	* app/base/tile-manager-private.h
	* app/base/tile-manager.c
	* app/base/tile-private.h
	* app/base/tile.[ch]
	* app/core/gimp.h
	* app/core/gimpbrushgenerated.h
	* app/core/gimpbrushpipe.h
	* app/core/gimpchannel.[ch]
	* app/core/gimpcontainer.h
	* app/core/gimpcoreconfig.h
	* app/core/gimpdata.h
	* app/core/gimpdatafactory.[ch]
	* app/core/gimpdrawable-blend.c
	* app/core/gimpdrawable.[ch]
	* app/core/gimpimage.h
	* app/core/gimpimagefile.h
	* app/core/gimplayer.h
	* app/core/gimplayermask.h
	* app/core/gimpmoduleinfo.h
	* app/core/gimppalette.h
	* app/core/gimpundo.h
	* app/display/gimpdisplay.h
	* app/display/gimpdisplayshell-selection.h
	* app/display/gimpdisplayshell.h
	* app/gui/brush-select.h
	* app/gui/gradient-editor.h
	* app/gui/gradient-select.h
	* app/gui/info-dialog.h
	* app/gui/resize-dialog.h
	* app/tools/gimpbezierselecttool.h
	* app/tools/gimpcolorbalancetool.h
	* app/tools/gimpcolorpickertool.h
	* app/tools/gimpcurvestool.h
	* app/tools/gimpdodgeburntool.c
	* app/tools/gimpfreeselecttool.h
	* app/tools/gimpfuzzyselecttool.h
	* app/tools/gimphuesaturationtool.h
	* app/tools/gimpinktool-blob.h
	* app/tools/gimpinktool.h
	* app/tools/gimpiscissorstool.h
	* app/tools/gimpmagnifytool.h
	* app/tools/gimpmeasuretool.h
	* app/tools/gimppainttool.h
	* app/tools/gimppathtool.h
	* app/tools/gimprectselecttool.h
	* app/tools/gimpthresholdtool.h
	* app/tools/gimptool.h
	* app/tools/gimptransformtool.h
	* app/tools/path_toolP.h
	* app/widgets/gimpbrushfactoryview.h
	* app/widgets/gimpconstrainedhwrapbox.h
	* app/widgets/gimpcontainermenu.h
	* app/widgets/gimpcontainerview.h
	* app/widgets/gimpdialogfactory.h
	* app/widgets/gimpimagedock.h
	* app/widgets/gimplistitem.h
	* app/widgets/gimpmenuitem.h
	* app/widgets/gimpnavigationpreview.h
	* app/widgets/gimppreview.h: Unsignify lots of variables and
	parameters and use bitfields in structs where possible. First
	part of a huge cleanup all over the code...
2001-12-02 14:59:30 +00:00

252 lines
5.4 KiB
C

/* 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 <stdio.h>
#include <string.h>
#include <stdlib.h>
#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>
#include "libgimpbase/gimpbase.h"
#include "tools/tools-types.h"
#include "base/base.h"
#include "core/gimp.h"
#include "core/gimpdatafactory.h"
#include "core/gimpunit.h"
#include "plug-in/plug-in.h"
#include "file/file-open.h"
#include "display/gimpdisplay-foreach.h"
#include "tools/tool_manager.h"
#include "gui/gui.h"
#include "gui/splash.h"
#include "gui/user-install-dialog.h"
#include "appenv.h"
#include "app_procs.h"
#include "batch.h"
#include "gimprc.h"
#include "undo.h"
#include "libgimp/gimpintl.h"
/* local prototypes */
static void app_init_update_status (const gchar *text1,
const gchar *text2,
gdouble percentage);
static void app_exit_finish (void);
/* global variables */
Gimp *the_gimp = NULL;
/* public functions */
void
app_init (gint gimp_argc,
gchar **gimp_argv)
{
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 (be_verbose,
no_data,
no_interface,
stack_trace_mode);
gimp_object_set_name (GIMP_OBJECT (the_gimp), prog_name);
/* Check if the user's gimp_directory exists
*/
gimp_dir = gimp_directory ();
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 ();
}
}
/* The user_install dialog may have parsed unitrc and gimprc, so
* check gimprc_init()'s return value
*/
if (gimprc_init (the_gimp))
{
/* this needs to be done before gimprc loading */
gimp_unitrc_load (the_gimp);
/* parse the local GIMP configuration file */
gimprc_parse (the_gimp, alternate_system_gimprc, alternate_gimprc);
}
/* initialize lowlevel stuff */
base_init ();
if (! no_interface)
{
gui_themes_init (the_gimp);
if (! no_splash)
splash_create (! no_splash_image);
}
/* Create all members of the global Gimp instance which need an already
* parsed gimprc, e.g. the data factories
*/
gimp_initialize (the_gimp, app_init_update_status);
if (! no_interface)
{
tool_manager_init (the_gimp);
}
/* Load all data files
*/
gimp_restore (the_gimp, app_init_update_status, no_data);
if (! no_interface)
{
gui_init (the_gimp);
}
/* Initialize the plug-in structures
*/
plug_in_init (the_gimp, app_init_update_status);
if (! no_interface)
{
if (! no_splash)
splash_destroy ();
gui_restore (the_gimp, restore_session);
}
/* Parse the rest of the command line arguments as images to load
*/
if (gimp_argc > 0)
{
gint i;
for (i = 0; i < gimp_argc; i++)
{
if (gimp_argv[i])
{
file_open_with_display (the_gimp, gimp_argv[i]);
}
}
}
batch_init (the_gimp, batch_cmds);
if (! no_interface)
{
gui_post_init (the_gimp);
}
gimp_main_loop (the_gimp);
}
void
app_exit (gboolean kill_it)
{
/* If it's the user's perogative, and there are dirty images */
if (! kill_it && gdisplays_dirty () && ! no_interface)
gui_really_quit_dialog (G_CALLBACK (app_exit_finish));
else
app_exit_finish ();
}
/* private functions */
static void
app_init_update_status (const gchar *text1,
const gchar *text2,
gdouble percentage)
{
if (! no_interface && ! no_splash)
{
splash_update (text1, text2, percentage);
}
}
static void
app_exit_finish (void)
{
if (! no_interface)
{
gui_shutdown (the_gimp);
}
plug_in_kill ();
if (! no_interface)
{
tool_manager_exit (the_gimp);
gui_exit (the_gimp);
}
gimp_shutdown (the_gimp);
g_object_unref (G_OBJECT (the_gimp));
the_gimp = NULL;
base_exit ();
/* 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);
}