2001-04-16 04:12:16 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2001-11-18 00:32:34 +08:00
|
|
|
#include <stdlib.h>
|
2001-04-16 04:12:16 +08:00
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-04-16 04:12:16 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2003-05-24 02:27:05 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets-private.h"
|
2001-04-16 04:12:16 +08:00
|
|
|
|
2001-10-13 20:52:30 +08:00
|
|
|
#include "gui-types.h"
|
2001-04-16 04:12:16 +08:00
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
#include "config/gimpguiconfig.h"
|
|
|
|
|
2001-07-05 23:34:26 +08:00
|
|
|
#include "core/gimp.h"
|
2001-07-08 02:16:18 +08:00
|
|
|
#include "core/gimpcontainer.h"
|
2001-07-05 23:34:26 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2002-11-25 08:04:26 +08:00
|
|
|
#include "core/gimpenvirontable.h"
|
2001-07-07 20:17:23 +08:00
|
|
|
#include "core/gimpimage.h"
|
2001-07-05 23:34:26 +08:00
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
2001-10-13 20:52:30 +08:00
|
|
|
#include "display/gimpdisplay-foreach.h"
|
2001-11-01 05:20:09 +08:00
|
|
|
#include "display/gimpdisplayshell.h"
|
2001-11-02 17:31:21 +08:00
|
|
|
#include "display/gimpdisplayshell-render.h"
|
2003-10-02 19:26:26 +08:00
|
|
|
|
|
|
|
#include "tools/gimp-tools.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
#include "widgets/gimpdevices.h"
|
2003-07-07 21:37:19 +08:00
|
|
|
#include "widgets/gimpdevicestatus.h"
|
2001-04-18 00:00:27 +08:00
|
|
|
#include "widgets/gimpdialogfactory.h"
|
2003-11-04 07:24:32 +08:00
|
|
|
#include "widgets/gimpdnd.h"
|
2003-05-25 20:13:57 +08:00
|
|
|
#include "widgets/gimphelp.h"
|
2003-08-22 09:42:57 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2001-11-28 03:27:55 +08:00
|
|
|
#include "widgets/gimpitemfactory.h"
|
2003-01-11 01:55:53 +08:00
|
|
|
#include "widgets/gimpmenufactory.h"
|
2003-10-10 23:59:12 +08:00
|
|
|
#include "widgets/gimpsessioninfo.h"
|
2001-12-02 05:02:34 +08:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
2001-04-18 00:00:27 +08:00
|
|
|
|
2004-04-20 21:25:55 +08:00
|
|
|
#include "actions/dialogs-commands.h"
|
|
|
|
|
2003-11-13 23:25:38 +08:00
|
|
|
#include "color-history.h"
|
2001-04-16 04:12:16 +08:00
|
|
|
#include "dialogs.h"
|
|
|
|
#include "gui.h"
|
2003-10-02 19:26:26 +08:00
|
|
|
#include "gui-vtable.h"
|
2001-04-16 04:12:16 +08:00
|
|
|
#include "menus.h"
|
|
|
|
#include "session.h"
|
2003-10-02 19:26:26 +08:00
|
|
|
#include "splash.h"
|
2003-09-11 07:42:59 +08:00
|
|
|
#include "themes.h"
|
2001-04-16 04:12:16 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2001-04-16 04:12:16 +08:00
|
|
|
|
|
|
|
|
2001-07-05 23:34:26 +08:00
|
|
|
/* local function prototypes */
|
2001-04-16 04:12:16 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
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_initialize_after_callback (Gimp *gimp,
|
|
|
|
GimpInitStatusFunc callback);
|
|
|
|
|
|
|
|
static void gui_restore_callback (Gimp *gimp,
|
2003-11-13 22:14:20 +08:00
|
|
|
GimpInitStatusFunc callback);
|
2003-10-02 19:26:26 +08:00
|
|
|
static void gui_restore_after_callback (Gimp *gimp,
|
2003-11-13 22:14:20 +08:00
|
|
|
GimpInitStatusFunc callback);
|
2003-10-02 19:26:26 +08:00
|
|
|
|
|
|
|
static gboolean gui_exit_callback (Gimp *gimp,
|
2003-12-01 00:05:56 +08:00
|
|
|
gboolean force);
|
2003-10-02 19:26:26 +08:00
|
|
|
static gboolean gui_exit_after_callback (Gimp *gimp,
|
2003-12-01 00:05:56 +08:00
|
|
|
gboolean force);
|
2003-10-02 19:26:26 +08:00
|
|
|
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);
|
2001-07-05 23:34:26 +08:00
|
|
|
|
|
|
|
|
2001-07-08 02:16:18 +08:00
|
|
|
/* private variables */
|
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
static Gimp *the_gui_gimp = NULL;
|
2001-07-08 02:16:18 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
static GQuark image_disconnect_handler_id = 0;
|
|
|
|
|
|
|
|
static GimpItemFactory *toolbox_item_factory = NULL;
|
|
|
|
static GimpItemFactory *image_item_factory = NULL;
|
2003-01-11 01:55:53 +08:00
|
|
|
|
2001-07-08 02:16:18 +08:00
|
|
|
|
2001-04-16 04:12:16 +08:00
|
|
|
/* public functions */
|
|
|
|
|
2003-01-09 07:43:31 +08:00
|
|
|
gboolean
|
2001-11-18 00:32:34 +08:00
|
|
|
gui_libs_init (gint *argc,
|
2001-08-04 22:10:58 +08:00
|
|
|
gchar ***argv)
|
2001-11-18 00:32:34 +08:00
|
|
|
{
|
2003-01-09 07:43:31 +08:00
|
|
|
g_return_val_if_fail (argc != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (argv != NULL, FALSE);
|
2001-11-18 00:32:34 +08:00
|
|
|
|
2004-03-30 19:32:21 +08:00
|
|
|
if (! gtk_init_check (argc, argv))
|
2003-01-09 07:43:31 +08:00
|
|
|
return FALSE;
|
2001-11-18 00:32:34 +08:00
|
|
|
|
2003-11-16 06:53:28 +08:00
|
|
|
gimp_widgets_init (gui_help_func,
|
2003-05-25 22:23:43 +08:00
|
|
|
gui_get_foreground_func,
|
2003-11-12 01:55:45 +08:00
|
|
|
gui_get_background_func,
|
|
|
|
NULL);
|
2002-10-20 18:14:17 +08:00
|
|
|
|
|
|
|
g_type_class_ref (GIMP_TYPE_COLOR_SELECT);
|
2003-08-14 01:23:49 +08:00
|
|
|
|
2004-03-30 19:32:21 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
2003-10-27 04:25:34 +08:00
|
|
|
|
2004-03-30 19:32:21 +08:00
|
|
|
void
|
|
|
|
gui_abort (const gchar *abort_message)
|
|
|
|
{
|
|
|
|
g_return_if_fail (abort_message != NULL);
|
2003-10-27 04:25:34 +08:00
|
|
|
|
2004-03-30 19:32:21 +08:00
|
|
|
gimp_message_box (GIMP_STOCK_WILBER_EEK, NULL, abort_message,
|
|
|
|
(GtkCallback) gtk_main_quit, NULL);
|
|
|
|
gtk_main ();
|
2001-11-18 00:32:34 +08:00
|
|
|
}
|
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
GimpInitStatusFunc
|
|
|
|
gui_init (Gimp *gimp,
|
2004-03-15 08:17:21 +08:00
|
|
|
gboolean no_splash)
|
2002-11-25 08:04:26 +08:00
|
|
|
{
|
2003-11-02 04:06:01 +08:00
|
|
|
GimpInitStatusFunc status_callback = NULL;
|
|
|
|
GdkScreen *screen;
|
2003-09-11 07:42:59 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
|
|
|
g_return_val_if_fail (the_gui_gimp == NULL, NULL);
|
2002-11-25 08:04:26 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
the_gui_gimp = gimp;
|
2001-10-24 00:23:32 +08:00
|
|
|
|
2003-11-04 07:24:32 +08:00
|
|
|
gimp_dnd_init (gimp);
|
|
|
|
|
2003-09-11 07:42:59 +08:00
|
|
|
themes_init (gimp);
|
2001-08-04 22:10:58 +08:00
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
gdk_rgb_set_min_colors (CLAMP (gimp->config->min_colors, 27, 256));
|
|
|
|
gdk_rgb_set_install (gimp->config->install_cmap);
|
2001-12-01 00:39:40 +08:00
|
|
|
|
2003-11-02 04:06:01 +08:00
|
|
|
screen = gdk_screen_get_default ();
|
|
|
|
gtk_widget_set_default_colormap (gdk_screen_get_rgb_colormap (screen));
|
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.
2001-07-11 03:16:16 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
if (! no_splash)
|
2001-07-05 03:31:35 +08:00
|
|
|
{
|
2004-03-15 08:17:21 +08:00
|
|
|
splash_create ();
|
2003-10-02 19:26:26 +08:00
|
|
|
status_callback = splash_update;
|
2001-07-05 03:31:35 +08:00
|
|
|
}
|
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
g_signal_connect_after (gimp, "initialize",
|
|
|
|
G_CALLBACK (gui_initialize_after_callback),
|
|
|
|
NULL);
|
2001-10-23 01:27:46 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
g_signal_connect (gimp, "restore",
|
|
|
|
G_CALLBACK (gui_restore_callback),
|
|
|
|
NULL);
|
|
|
|
g_signal_connect_after (gimp, "restore",
|
|
|
|
G_CALLBACK (gui_restore_after_callback),
|
|
|
|
NULL);
|
2001-04-16 04:12:16 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
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;
|
2001-04-16 04:12:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-10-02 19:26:26 +08:00
|
|
|
gui_post_init (Gimp *gimp)
|
2001-04-16 04:12:16 +08:00
|
|
|
{
|
2001-10-24 00:23:32 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
if (GIMP_GUI_CONFIG (gimp->config)->show_tips)
|
|
|
|
gimp_dialog_factory_dialog_new (global_dialog_factory,
|
2003-11-08 23:29:47 +08:00
|
|
|
gdk_screen_get_default (),
|
2003-10-02 19:26:26 +08:00
|
|
|
"gimp-tips-dialog", -1);
|
2001-04-16 04:12:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2003-05-25 20:13:57 +08:00
|
|
|
static void
|
2003-08-24 03:35:05 +08:00
|
|
|
gui_help_func (const gchar *help_id,
|
|
|
|
gpointer help_data)
|
2003-05-25 20:13:57 +08:00
|
|
|
{
|
2003-10-02 19:26:26 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (the_gui_gimp));
|
|
|
|
|
|
|
|
gimp_help (the_gui_gimp, NULL, help_id);
|
2003-05-25 20:13:57 +08:00
|
|
|
}
|
|
|
|
|
2003-05-25 22:23:43 +08:00
|
|
|
static gboolean
|
|
|
|
gui_get_foreground_func (GimpRGB *color)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (color != NULL, FALSE);
|
2003-10-02 19:26:26 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (the_gui_gimp), FALSE);
|
2003-05-25 22:23:43 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
gimp_context_get_foreground (gimp_get_user_context (the_gui_gimp), color);
|
2003-05-25 22:23:43 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gui_get_background_func (GimpRGB *color)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (color != NULL, FALSE);
|
2003-10-02 19:26:26 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (the_gui_gimp), FALSE);
|
2003-05-25 22:23:43 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
gimp_context_get_background (gimp_get_user_context (the_gui_gimp), color);
|
2003-05-25 22:23:43 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-11-18 00:32:34 +08:00
|
|
|
static void
|
2003-10-02 19:26:26 +08:00
|
|
|
gui_initialize_after_callback (Gimp *gimp,
|
|
|
|
GimpInitStatusFunc status_callback)
|
2001-11-18 00:32:34 +08:00
|
|
|
{
|
2003-10-02 19:26:26 +08:00
|
|
|
const gchar *name = NULL;
|
2001-11-18 00:32:34 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
2001-11-18 00:32:34 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
if (gimp->be_verbose)
|
|
|
|
g_print ("INIT: gui_initialize_after_callback\n");
|
2001-12-02 05:02:34 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
#if defined (GDK_WINDOWING_X11)
|
|
|
|
name = "DISPLAY";
|
|
|
|
#elif defined (GDK_WINDOWING_DIRECTFB) || defined (GDK_WINDOWING_FB)
|
|
|
|
name = "GDK_DISPLAY";
|
|
|
|
#endif
|
2001-12-02 05:02:34 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
/* TODO: Need to care about display migration with GTK+ 2.2 at some point */
|
|
|
|
|
|
|
|
if (name)
|
|
|
|
{
|
|
|
|
gchar *display;
|
|
|
|
|
|
|
|
display = gdk_get_display ();
|
|
|
|
gimp_environ_table_add (gimp->environ_table, name, display, NULL);
|
|
|
|
g_free (display);
|
|
|
|
}
|
2001-12-02 05:02:34 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
gimp_tools_init (gimp);
|
2001-12-02 05:02:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-10-02 19:26:26 +08:00
|
|
|
gui_restore_callback (Gimp *gimp,
|
2003-11-13 22:14:20 +08:00
|
|
|
GimpInitStatusFunc status_callback)
|
2001-12-02 05:02:34 +08:00
|
|
|
{
|
2003-11-09 02:16:25 +08:00
|
|
|
GimpDisplayConfig *display_config = GIMP_DISPLAY_CONFIG (gimp->config);
|
|
|
|
GimpGuiConfig *gui_config = GIMP_GUI_CONFIG (gimp->config);
|
2003-06-13 22:37:00 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
if (gimp->be_verbose)
|
|
|
|
g_print ("INIT: gui_restore_callback\n");
|
2003-06-13 22:37:00 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
gui_vtable_init (gimp);
|
2003-06-13 22:37:00 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
image_disconnect_handler_id =
|
|
|
|
gimp_container_add_handler (gimp->images, "disconnect",
|
|
|
|
G_CALLBACK (gui_image_disconnect),
|
|
|
|
gimp);
|
2003-06-13 22:37:00 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
if (! gui_config->show_tool_tips)
|
|
|
|
gimp_help_disable_tooltips ();
|
2003-06-13 22:37:00 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
g_signal_connect (gui_config, "notify::show-tool-tips",
|
|
|
|
G_CALLBACK (gui_show_tooltips_notify),
|
|
|
|
gimp);
|
2003-06-13 22:37:00 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
g_signal_connect (gimp_get_user_context (gimp), "display_changed",
|
|
|
|
G_CALLBACK (gui_display_changed),
|
|
|
|
gimp);
|
2001-12-02 05:02:34 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
/* make sure the monitor resolution is valid */
|
|
|
|
if (display_config->monitor_res_from_gdk ||
|
|
|
|
display_config->monitor_xres < GIMP_MIN_RESOLUTION ||
|
|
|
|
display_config->monitor_yres < GIMP_MIN_RESOLUTION)
|
|
|
|
{
|
|
|
|
gdouble xres, yres;
|
2001-07-05 23:34:26 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
gimp_get_screen_resolution (NULL, &xres, &yres);
|
2001-07-05 23:34:26 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
g_object_set (gimp->config,
|
|
|
|
"monitor-xresolution", xres,
|
|
|
|
"monitor-yresolution", yres,
|
|
|
|
"monitor-resolution-from-windowing-system", TRUE,
|
|
|
|
NULL);
|
|
|
|
}
|
2001-07-05 23:34:26 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
menus_init (gimp);
|
|
|
|
render_init (gimp);
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
dialogs_init (gimp);
|
2003-03-20 19:31:33 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
gimp_devices_init (gimp, gui_device_change_notify);
|
|
|
|
session_init (gimp);
|
2001-07-05 23:34:26 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
(* status_callback) (NULL, _("Tool Options"), 1.0);
|
|
|
|
gimp_tools_restore (gimp);
|
2003-09-11 06:06:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-10-02 19:26:26 +08:00
|
|
|
gui_restore_after_callback (Gimp *gimp,
|
2003-11-13 22:14:20 +08:00
|
|
|
GimpInitStatusFunc status_callback)
|
2003-09-11 06:06:45 +08:00
|
|
|
{
|
2003-11-09 02:16:25 +08:00
|
|
|
GimpGuiConfig *gui_config = GIMP_GUI_CONFIG (gimp->config);
|
2003-09-11 06:06:45 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
if (gimp->be_verbose)
|
|
|
|
g_print ("INIT: gui_restore_after_callback\n");
|
2003-09-11 06:06:45 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
gimp->message_handler = GIMP_MESSAGE_BOX;
|
2003-09-11 06:06:45 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
if (gui_config->restore_accels)
|
|
|
|
menus_restore (gimp);
|
2003-09-11 06:06:45 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
toolbox_item_factory = gimp_menu_factory_menu_new (global_menu_factory,
|
|
|
|
"<Toolbox>",
|
|
|
|
GTK_TYPE_MENU_BAR,
|
|
|
|
gimp,
|
|
|
|
TRUE);
|
2003-09-11 06:06:45 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
image_item_factory = gimp_menu_factory_menu_new (global_menu_factory,
|
|
|
|
"<Image>",
|
|
|
|
GTK_TYPE_MENU,
|
|
|
|
gimp,
|
|
|
|
TRUE);
|
2003-09-11 06:06:45 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
gimp_devices_restore (gimp);
|
2003-09-11 06:06:45 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
if (status_callback == splash_update)
|
|
|
|
splash_destroy ();
|
|
|
|
|
2003-11-13 23:25:38 +08:00
|
|
|
color_history_restore ();
|
|
|
|
|
2003-11-13 22:14:20 +08:00
|
|
|
if (gui_config->restore_session)
|
2003-10-02 19:26:26 +08:00
|
|
|
session_restore (gimp);
|
|
|
|
|
|
|
|
dialogs_show_toolbox ();
|
2003-09-11 06:06:45 +08:00
|
|
|
}
|
|
|
|
|
2002-12-05 23:49:59 +08:00
|
|
|
static gboolean
|
|
|
|
gui_exit_callback (Gimp *gimp,
|
2003-12-01 00:05:56 +08:00
|
|
|
gboolean force)
|
2002-12-05 23:49:59 +08:00
|
|
|
{
|
2003-11-09 02:16:25 +08:00
|
|
|
GimpGuiConfig *gui_config = GIMP_GUI_CONFIG (gimp->config);
|
2003-09-22 23:31:54 +08:00
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
if (gimp->be_verbose)
|
|
|
|
g_print ("EXIT: gui_exit_callback\n");
|
|
|
|
|
2003-12-01 00:05:56 +08:00
|
|
|
if (! force && gimp_displays_dirty (gimp))
|
2002-12-05 23:49:59 +08:00
|
|
|
{
|
2002-12-11 00:38:16 +08:00
|
|
|
GtkWidget *dialog;
|
2002-12-05 23:49:59 +08:00
|
|
|
|
2002-12-11 00:38:16 +08:00
|
|
|
gimp_item_factories_set_sensitive ("<Toolbox>", "/File/Quit", FALSE);
|
|
|
|
gimp_item_factories_set_sensitive ("<Image>", "/File/Quit", FALSE);
|
2002-12-05 23:49:59 +08:00
|
|
|
|
|
|
|
dialog = gimp_query_boolean_box (_("Quit The GIMP?"),
|
2003-11-08 23:29:47 +08:00
|
|
|
NULL,
|
2002-12-05 23:49:59 +08:00
|
|
|
gimp_standard_help_func,
|
2003-08-22 09:42:57 +08:00
|
|
|
GIMP_HELP_FILE_QUIT_CONFIRM,
|
2002-12-05 23:49:59 +08:00
|
|
|
GIMP_STOCK_WILBER_EEK,
|
2003-11-14 23:33:40 +08:00
|
|
|
_("Some files are unsaved.\n\n"
|
|
|
|
"Really quit The GIMP?"),
|
2002-12-05 23:49:59 +08:00
|
|
|
GTK_STOCK_QUIT, GTK_STOCK_CANCEL,
|
|
|
|
NULL, NULL,
|
|
|
|
gui_really_quit_callback,
|
|
|
|
gimp);
|
|
|
|
|
|
|
|
gtk_widget_show (dialog);
|
|
|
|
|
|
|
|
return TRUE; /* stop exit for now */
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp->message_handler = GIMP_CONSOLE;
|
|
|
|
|
2003-09-22 23:31:54 +08:00
|
|
|
if (gui_config->save_session_info)
|
|
|
|
session_save (gimp);
|
|
|
|
|
2003-11-13 23:25:38 +08:00
|
|
|
color_history_save ();
|
|
|
|
|
2003-09-22 23:31:54 +08:00
|
|
|
if (gui_config->save_accels)
|
|
|
|
menus_save (gimp);
|
2002-12-05 23:49:59 +08:00
|
|
|
|
2003-09-22 23:31:54 +08:00
|
|
|
if (gui_config->save_device_status)
|
2002-12-05 23:49:59 +08:00
|
|
|
gimp_devices_save (gimp);
|
|
|
|
|
|
|
|
gimp_displays_delete (gimp);
|
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
gimp_tools_save (gimp);
|
|
|
|
gimp_tools_exit (gimp);
|
|
|
|
|
2002-12-05 23:49:59 +08:00
|
|
|
return FALSE; /* continue exiting */
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2003-10-02 19:26:26 +08:00
|
|
|
gui_exit_after_callback (Gimp *gimp,
|
2003-12-01 00:05:56 +08:00
|
|
|
gboolean force)
|
2002-12-05 23:49:59 +08:00
|
|
|
{
|
2003-10-02 19:26:26 +08:00
|
|
|
if (gimp->be_verbose)
|
|
|
|
g_print ("EXIT: gui_exit_after_callback\n");
|
|
|
|
|
2003-02-27 00:17:10 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (gimp->config,
|
|
|
|
gui_show_tooltips_notify,
|
|
|
|
gimp);
|
|
|
|
|
|
|
|
gimp_container_remove_handler (gimp->images, image_disconnect_handler_id);
|
|
|
|
image_disconnect_handler_id = 0;
|
|
|
|
|
2003-01-11 01:55:53 +08:00
|
|
|
g_object_unref (toolbox_item_factory);
|
|
|
|
toolbox_item_factory = NULL;
|
|
|
|
|
|
|
|
g_object_unref (image_item_factory);
|
|
|
|
image_item_factory = NULL;
|
|
|
|
|
2002-12-05 23:49:59 +08:00
|
|
|
menus_exit (gimp);
|
|
|
|
render_exit (gimp);
|
|
|
|
|
|
|
|
dialogs_exit (gimp);
|
|
|
|
gimp_devices_exit (gimp);
|
|
|
|
|
2003-09-11 07:42:59 +08:00
|
|
|
themes_exit (gimp);
|
2002-12-05 23:49:59 +08:00
|
|
|
|
|
|
|
g_type_class_unref (g_type_class_peek (GIMP_TYPE_COLOR_SELECT));
|
|
|
|
|
|
|
|
return FALSE; /* continue exiting */
|
|
|
|
}
|
|
|
|
|
2001-07-05 23:34:26 +08:00
|
|
|
static void
|
|
|
|
gui_really_quit_callback (GtkWidget *button,
|
|
|
|
gboolean quit,
|
|
|
|
gpointer data)
|
2001-04-16 04:12:16 +08:00
|
|
|
{
|
2003-11-09 02:16:25 +08:00
|
|
|
Gimp *gimp = GIMP (data);
|
2001-10-25 21:30:01 +08:00
|
|
|
|
2001-04-16 04:12:16 +08:00
|
|
|
if (quit)
|
|
|
|
{
|
2002-12-05 23:49:59 +08:00
|
|
|
gimp_exit (gimp, TRUE);
|
2001-04-16 04:12:16 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-12-11 00:38:16 +08:00
|
|
|
gimp_item_factories_set_sensitive ("<Toolbox>", "/File/Quit", TRUE);
|
|
|
|
gimp_item_factories_set_sensitive ("<Image>", "/File/Quit", TRUE);
|
2001-04-16 04:12:16 +08:00
|
|
|
}
|
|
|
|
}
|
2001-07-07 20:17:23 +08:00
|
|
|
|
2002-11-21 23:46:19 +08:00
|
|
|
static void
|
|
|
|
gui_show_tooltips_notify (GObject *config,
|
|
|
|
GParamSpec *param_spec,
|
|
|
|
Gimp *gimp)
|
|
|
|
{
|
|
|
|
gboolean show_tool_tips;
|
|
|
|
|
|
|
|
g_object_get (config,
|
|
|
|
"show-tool-tips", &show_tool_tips,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (show_tool_tips)
|
|
|
|
gimp_help_enable_tooltips ();
|
|
|
|
else
|
|
|
|
gimp_help_disable_tooltips ();
|
|
|
|
}
|
|
|
|
|
2003-07-07 21:37:19 +08:00
|
|
|
static void
|
|
|
|
gui_device_change_notify (Gimp *gimp)
|
|
|
|
{
|
|
|
|
GimpSessionInfo *session_info;
|
|
|
|
|
|
|
|
session_info = gimp_dialog_factory_find_session_info (global_dock_factory,
|
|
|
|
"gimp-device-status");
|
|
|
|
|
|
|
|
if (session_info && session_info->widget)
|
2003-09-19 20:38:30 +08:00
|
|
|
{
|
|
|
|
GtkWidget *device_status;
|
|
|
|
|
|
|
|
device_status = GTK_BIN (session_info->widget)->child;
|
|
|
|
|
|
|
|
gimp_device_status_update (GIMP_DEVICE_STATUS (device_status));
|
|
|
|
}
|
2003-07-07 21:37:19 +08:00
|
|
|
}
|
|
|
|
|
2002-11-21 23:46:19 +08:00
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#warning FIXME: this junk should mostly go to the display subsystem
|
|
|
|
#endif
|
2001-07-08 02:16:18 +08:00
|
|
|
|
2001-07-07 20:17:23 +08:00
|
|
|
static void
|
|
|
|
gui_display_changed (GimpContext *context,
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpDisplay *display,
|
2002-03-20 23:32:35 +08:00
|
|
|
Gimp *gimp)
|
2001-07-07 20:17:23 +08:00
|
|
|
{
|
2004-02-01 04:23:53 +08:00
|
|
|
gimp_item_factory_update (gimp_item_factory_from_path ("<Image>"), display);
|
2001-07-07 20:17:23 +08:00
|
|
|
}
|
2001-07-08 02:16:18 +08:00
|
|
|
|
|
|
|
static void
|
2001-08-12 05:10:44 +08:00
|
|
|
gui_image_disconnect (GimpImage *gimage,
|
2002-11-30 21:08:44 +08:00
|
|
|
Gimp *gimp)
|
2001-07-08 02:16:18 +08:00
|
|
|
{
|
2002-11-30 21:08:44 +08:00
|
|
|
/* check if this is the last image and if it had a display */
|
|
|
|
if (gimp_container_num_children (gimp->images) == 1 &&
|
|
|
|
gimage->instance_count > 0)
|
2001-07-08 02:16:18 +08:00
|
|
|
{
|
2002-03-15 01:07:02 +08:00
|
|
|
dialogs_show_toolbox ();
|
2001-07-08 02:16:18 +08:00
|
|
|
}
|
|
|
|
}
|