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 <stdio.h>
|
|
|
|
|
|
|
|
#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"
|
|
|
|
|
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"
|
2002-12-30 08:01:30 +08:00
|
|
|
#include "config/gimpconfig-path.h"
|
2002-11-19 04:50:31 +08:00
|
|
|
|
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"
|
2001-09-26 07:23:09 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
#include "widgets/gimpdevices.h"
|
2001-04-18 00:00:27 +08:00
|
|
|
#include "widgets/gimpdialogfactory.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"
|
2001-12-02 05:02:34 +08:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
2001-04-18 00:00:27 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
#include "device-status-dialog.h"
|
2001-04-16 04:12:16 +08:00
|
|
|
#include "dialogs.h"
|
2002-03-15 01:07:02 +08:00
|
|
|
#include "dialogs-commands.h"
|
2001-12-02 05:02:34 +08:00
|
|
|
#include "error-console-dialog.h"
|
2001-04-16 04:12:16 +08:00
|
|
|
#include "gui.h"
|
|
|
|
#include "menus.h"
|
|
|
|
#include "session.h"
|
|
|
|
|
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-05-22 01:38:14 +08:00
|
|
|
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 *message);
|
|
|
|
static GimpObject * gui_display_new (GimpImage *gimage,
|
|
|
|
guint scale);
|
|
|
|
|
|
|
|
static void gui_themes_dir_foreach_func (GimpDatafileData *file_data);
|
|
|
|
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_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 */
|
|
|
|
|
2001-12-18 07:41:01 +08:00
|
|
|
static GQuark image_disconnect_handler_id = 0;
|
2001-07-08 02:16:18 +08:00
|
|
|
|
2001-08-06 04:34:10 +08:00
|
|
|
static GHashTable *themes_hash = NULL;
|
|
|
|
|
2003-01-11 01:55:53 +08:00
|
|
|
static GimpItemFactory *toolbox_item_factory = NULL;
|
|
|
|
static GimpItemFactory *image_item_factory = NULL;
|
|
|
|
|
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
|
|
|
|
2003-01-09 07:43:31 +08:00
|
|
|
if (!gtk_init_check (argc, argv))
|
|
|
|
return FALSE;
|
2001-11-18 00:32:34 +08:00
|
|
|
|
2001-11-28 09:14:06 +08:00
|
|
|
gimp_widgets_init ();
|
2002-10-20 18:14:17 +08:00
|
|
|
|
|
|
|
g_type_class_ref (GIMP_TYPE_COLOR_SELECT);
|
2003-01-09 07:43:31 +08:00
|
|
|
|
|
|
|
return TRUE;
|
2001-11-18 00:32:34 +08:00
|
|
|
}
|
|
|
|
|
2002-11-25 08:04:26 +08:00
|
|
|
void
|
|
|
|
gui_environ_init (Gimp *gimp)
|
|
|
|
{
|
2003-03-06 06:31:13 +08:00
|
|
|
gchar *display, *name = NULL;
|
2002-11-25 08:04:26 +08:00
|
|
|
|
|
|
|
#if defined (GDK_WINDOWING_X11)
|
|
|
|
name = "DISPLAY";
|
|
|
|
#elif defined (GDK_WINDOWING_DIRECTFB) || defined (GDK_WINDOWING_FB)
|
|
|
|
name = "GDK_DISPLAY";
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* TODO: Need to care about display migration with GTK+ 2.2 at some point */
|
|
|
|
|
|
|
|
if (name)
|
2003-03-06 06:31:13 +08:00
|
|
|
{
|
|
|
|
display = gdk_get_display ();
|
|
|
|
gimp_environ_table_add (gimp->environ_table, name, display, NULL);
|
|
|
|
g_free (display);
|
|
|
|
}
|
2002-11-25 08:04:26 +08:00
|
|
|
}
|
|
|
|
|
2001-11-18 00:32:34 +08:00
|
|
|
void
|
|
|
|
gui_themes_init (Gimp *gimp)
|
2001-08-04 22:10:58 +08:00
|
|
|
{
|
2002-11-19 04:50:31 +08:00
|
|
|
GimpGuiConfig *config;
|
|
|
|
const gchar *theme_dir;
|
|
|
|
gchar *gtkrc;
|
2001-08-04 22:10:58 +08:00
|
|
|
|
2001-10-24 00:23:32 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
config = GIMP_GUI_CONFIG (gimp->config);
|
|
|
|
|
2001-08-06 04:34:10 +08:00
|
|
|
themes_hash = g_hash_table_new_full (g_str_hash,
|
|
|
|
g_str_equal,
|
|
|
|
g_free,
|
|
|
|
g_free);
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
if (config->theme_path)
|
2001-08-06 04:34:10 +08:00
|
|
|
{
|
2002-12-30 08:01:30 +08:00
|
|
|
gchar *path;
|
|
|
|
|
|
|
|
path = gimp_config_path_expand (config->theme_path, TRUE, NULL);
|
|
|
|
|
|
|
|
gimp_datafiles_read_directories (path,
|
2002-10-23 22:55:07 +08:00
|
|
|
G_FILE_TEST_IS_DIR,
|
2001-08-06 04:34:10 +08:00
|
|
|
gui_themes_dir_foreach_func,
|
2001-10-25 21:30:01 +08:00
|
|
|
gimp);
|
2002-12-30 08:01:30 +08:00
|
|
|
|
|
|
|
g_free (path);
|
2001-08-06 04:34:10 +08:00
|
|
|
}
|
|
|
|
|
2002-02-28 21:47:03 +08:00
|
|
|
theme_dir = gui_themes_get_theme_dir (gimp);
|
2001-08-06 04:34:10 +08:00
|
|
|
|
|
|
|
if (theme_dir)
|
|
|
|
{
|
2001-10-24 23:56:33 +08:00
|
|
|
gtkrc = g_build_filename (theme_dir, "gtkrc", NULL);
|
2001-08-06 04:34:10 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* get the hardcoded default theme gtkrc */
|
|
|
|
|
|
|
|
gtkrc = g_strdup (gimp_gtkrc ());
|
|
|
|
}
|
2001-08-04 22:10:58 +08:00
|
|
|
|
2001-10-25 21:30:01 +08:00
|
|
|
if (gimp->be_verbose)
|
2001-12-01 00:52:28 +08:00
|
|
|
g_print (_("Parsing '%s'\n"), gtkrc);
|
2001-08-04 22:10:58 +08:00
|
|
|
|
|
|
|
gtk_rc_parse (gtkrc);
|
|
|
|
|
2001-08-06 04:34:10 +08:00
|
|
|
g_free (gtkrc);
|
|
|
|
|
2001-08-04 22:10:58 +08:00
|
|
|
/* parse the user gtkrc */
|
2001-08-06 04:34:10 +08:00
|
|
|
|
|
|
|
gtkrc = gimp_personal_rc_file ("gtkrc");
|
2001-08-04 22:10:58 +08:00
|
|
|
|
2001-10-25 21:30:01 +08:00
|
|
|
if (gimp->be_verbose)
|
2001-12-01 00:52:28 +08:00
|
|
|
g_print (_("Parsing '%s'\n"), gtkrc);
|
2001-08-04 22:10:58 +08:00
|
|
|
|
2001-08-06 04:34:10 +08:00
|
|
|
gtk_rc_parse (gtkrc);
|
2001-08-04 22:10:58 +08:00
|
|
|
|
2001-08-06 04:34:10 +08:00
|
|
|
g_free (gtkrc);
|
2001-11-24 00:25:01 +08:00
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
if (! config->show_tool_tips)
|
2001-11-24 00:25:01 +08:00
|
|
|
gimp_help_disable_tooltips ();
|
2001-12-01 00:39:40 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (gimp->config, "notify::show-tool-tips",
|
2002-11-21 23:46:19 +08:00
|
|
|
G_CALLBACK (gui_show_tooltips_notify),
|
|
|
|
gimp);
|
|
|
|
|
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
|
|
|
|
|
|
|
gtk_widget_set_default_colormap (gdk_rgb_get_colormap ());
|
2001-08-04 22:10:58 +08:00
|
|
|
}
|
|
|
|
|
2002-02-28 21:47:03 +08:00
|
|
|
const gchar *
|
|
|
|
gui_themes_get_theme_dir (Gimp *gimp)
|
|
|
|
{
|
2002-11-19 04:50:31 +08:00
|
|
|
GimpGuiConfig *config = GIMP_GUI_CONFIG (gimp->config);
|
|
|
|
|
|
|
|
if (config->theme)
|
|
|
|
return g_hash_table_lookup (themes_hash, config->theme);
|
2002-02-28 21:47:03 +08:00
|
|
|
|
|
|
|
return g_hash_table_lookup (themes_hash, "Default");
|
|
|
|
}
|
|
|
|
|
2001-04-16 04:12:16 +08:00
|
|
|
void
|
2001-07-05 23:34:26 +08:00
|
|
|
gui_init (Gimp *gimp)
|
2001-04-16 04:12:16 +08:00
|
|
|
{
|
2002-11-19 04:50:31 +08:00
|
|
|
GimpDisplayConfig *display_config;
|
|
|
|
GimpGuiConfig *gui_config;
|
|
|
|
|
2001-10-24 00:23:32 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
display_config = GIMP_DISPLAY_CONFIG (gimp->config);
|
|
|
|
gui_config = GIMP_GUI_CONFIG (gimp->config);
|
|
|
|
|
2003-02-03 21:21:31 +08:00
|
|
|
gimp->gui_threads_enter_func = gui_threads_enter;
|
|
|
|
gimp->gui_threads_leave_func = gui_threads_leave;
|
2001-11-18 00:32:34 +08:00
|
|
|
gimp->gui_set_busy_func = gui_set_busy;
|
|
|
|
gimp->gui_unset_busy_func = gui_unset_busy;
|
2001-12-02 05:02:34 +08:00
|
|
|
gimp->gui_message_func = gui_message;
|
|
|
|
gimp->gui_create_display_func = gui_display_new;
|
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
|
|
|
|
2001-08-12 05:10:44 +08:00
|
|
|
image_disconnect_handler_id =
|
|
|
|
gimp_container_add_handler (gimp->images, "disconnect",
|
|
|
|
G_CALLBACK (gui_image_disconnect),
|
2001-07-08 02:16:18 +08:00
|
|
|
gimp);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (gimp_get_user_context (gimp), "display_changed",
|
2001-08-01 07:28:56 +08:00
|
|
|
G_CALLBACK (gui_display_changed),
|
|
|
|
gimp);
|
2001-07-07 20:17:23 +08:00
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
/* make sure the monitor resolution is valid */
|
2002-11-19 04:50:31 +08:00
|
|
|
if (display_config->monitor_res_from_gdk ||
|
|
|
|
display_config->monitor_xres < GIMP_MIN_RESOLUTION ||
|
|
|
|
display_config->monitor_yres < GIMP_MIN_RESOLUTION)
|
2001-07-05 03:31:35 +08:00
|
|
|
{
|
2002-11-19 04:50:31 +08:00
|
|
|
gdouble xres, yres;
|
|
|
|
|
|
|
|
gui_get_screen_resolution (&xres, &yres);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_object_set (gimp->config,
|
|
|
|
"monitor-xresolution", xres,
|
|
|
|
"monitor-yresolution", yres,
|
|
|
|
"monitor-resolution-from-windowing-system", TRUE,
|
|
|
|
NULL);
|
2001-07-05 03:31:35 +08:00
|
|
|
}
|
|
|
|
|
2001-10-24 00:23:32 +08:00
|
|
|
menus_init (gimp);
|
2002-11-21 23:46:19 +08:00
|
|
|
render_init (gimp);
|
2001-10-23 01:27:46 +08:00
|
|
|
|
2001-10-24 00:23:32 +08:00
|
|
|
dialogs_init (gimp);
|
2001-04-16 04:12:16 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
gimp_devices_init (gimp, device_status_dialog_update_current);
|
2001-10-24 00:23:32 +08:00
|
|
|
session_init (gimp);
|
2001-04-16 04:12:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-10-25 21:30:01 +08:00
|
|
|
gui_restore (Gimp *gimp,
|
|
|
|
gboolean restore_session)
|
2001-04-16 04:12:16 +08:00
|
|
|
{
|
2001-10-24 00:23:32 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
2001-12-02 05:02:34 +08:00
|
|
|
gimp->message_handler = GIMP_MESSAGE_BOX;
|
|
|
|
|
2003-04-08 18:02:42 +08:00
|
|
|
menus_restore (gimp);
|
|
|
|
|
2003-01-11 01:55:53 +08:00
|
|
|
toolbox_item_factory = gimp_menu_factory_menu_new (global_menu_factory,
|
|
|
|
"<Toolbox>",
|
|
|
|
GTK_TYPE_MENU_BAR,
|
|
|
|
gimp,
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
image_item_factory = gimp_menu_factory_menu_new (global_menu_factory,
|
|
|
|
"<Image>",
|
|
|
|
GTK_TYPE_MENU,
|
|
|
|
gimp,
|
|
|
|
TRUE);
|
2001-10-24 00:23:32 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
gimp_devices_restore (gimp);
|
2001-10-22 20:13:44 +08:00
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
if (GIMP_GUI_CONFIG (gimp->config)->restore_session || restore_session)
|
2001-10-24 00:23:32 +08:00
|
|
|
session_restore (gimp);
|
2002-03-15 01:07:02 +08:00
|
|
|
|
|
|
|
dialogs_show_toolbox ();
|
2002-12-05 23:49:59 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (gimp, "exit",
|
2002-12-05 23:49:59 +08:00
|
|
|
G_CALLBACK (gui_exit_callback),
|
|
|
|
NULL);
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect_after (gimp, "exit",
|
2002-12-05 23:49:59 +08:00
|
|
|
G_CALLBACK (gui_exit_finish_callback),
|
|
|
|
NULL);
|
2001-04-16 04:12:16 +08:00
|
|
|
}
|
|
|
|
|
2001-05-01 21:16:59 +08:00
|
|
|
void
|
2001-07-07 20:17:23 +08:00
|
|
|
gui_post_init (Gimp *gimp)
|
2001-05-01 21:16:59 +08:00
|
|
|
{
|
2001-10-24 00:23:32 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
if (GIMP_GUI_CONFIG (gimp->config)->show_tips)
|
2003-04-08 18:02:42 +08:00
|
|
|
gimp_dialog_factory_dialog_new (global_dialog_factory,
|
|
|
|
"gimp-tips-dialog", -1);
|
2001-05-01 21:16:59 +08:00
|
|
|
}
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
void
|
2002-05-30 08:26:27 +08:00
|
|
|
gui_get_screen_resolution (gdouble *xres,
|
|
|
|
gdouble *yres)
|
2001-11-01 05:20:09 +08:00
|
|
|
{
|
2002-05-30 08:26:27 +08:00
|
|
|
gint width, height;
|
|
|
|
gint width_mm, height_mm;
|
|
|
|
gdouble x = 0.0;
|
|
|
|
gdouble y = 0.0;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
|
|
|
g_return_if_fail (xres != NULL);
|
|
|
|
g_return_if_fail (yres != NULL);
|
|
|
|
|
|
|
|
width = gdk_screen_width ();
|
|
|
|
height = gdk_screen_height ();
|
|
|
|
|
2002-05-30 08:26:27 +08:00
|
|
|
width_mm = gdk_screen_width_mm ();
|
|
|
|
height_mm = gdk_screen_height_mm ();
|
2001-11-01 05:20:09 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* From xdpyinfo.c:
|
|
|
|
*
|
|
|
|
* there are 2.54 centimeters to an inch; so there are 25.4 millimeters.
|
|
|
|
*
|
|
|
|
* dpi = N pixels / (M millimeters / (25.4 millimeters / 1 inch))
|
|
|
|
* = N pixels / (M inch / 25.4)
|
|
|
|
* = N * 25.4 pixels / M inch
|
|
|
|
*/
|
|
|
|
|
2002-05-30 08:26:27 +08:00
|
|
|
if (width_mm > 0 && height_mm > 0)
|
|
|
|
{
|
|
|
|
x = (width * 25.4) / (gdouble) width_mm;
|
|
|
|
y = (height * 25.4) / (gdouble) height_mm;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x < GIMP_MIN_RESOLUTION || x > GIMP_MAX_RESOLUTION ||
|
|
|
|
y < GIMP_MIN_RESOLUTION || y > GIMP_MAX_RESOLUTION)
|
|
|
|
{
|
|
|
|
g_warning ("GDK returned bogus values for the screen resolution, "
|
|
|
|
"using 75 dpi instead.");
|
|
|
|
|
|
|
|
x = 75.0;
|
|
|
|
y = 75.0;
|
|
|
|
}
|
|
|
|
|
2003-01-11 05:15:41 +08:00
|
|
|
/* round the value to full integers to give more pleasant results */
|
|
|
|
*xres = RINT (x);
|
|
|
|
*yres = RINT (y);
|
2001-11-01 05:20:09 +08:00
|
|
|
}
|
|
|
|
|
2001-04-16 04:12:16 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2001-11-18 00:32:34 +08:00
|
|
|
static void
|
2003-02-03 21:21:31 +08:00
|
|
|
gui_threads_enter (Gimp *gimp)
|
2001-11-18 00:32:34 +08:00
|
|
|
{
|
2003-02-03 21:21:31 +08:00
|
|
|
GDK_THREADS_ENTER ();
|
2001-11-18 00:32:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-02-03 21:21:31 +08:00
|
|
|
gui_threads_leave (Gimp *gimp)
|
2001-11-18 00:32:34 +08:00
|
|
|
{
|
2003-02-03 21:21:31 +08:00
|
|
|
GDK_THREADS_LEAVE ();
|
2001-11-18 00:32:34 +08:00
|
|
|
}
|
|
|
|
|
2001-12-02 05:02:34 +08:00
|
|
|
static void
|
|
|
|
gui_set_busy (Gimp *gimp)
|
|
|
|
{
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_displays_set_busy (gimp);
|
2001-12-02 05:02:34 +08:00
|
|
|
gimp_dialog_factories_idle ();
|
|
|
|
|
|
|
|
gdk_flush ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gui_unset_busy (Gimp *gimp)
|
|
|
|
{
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_displays_unset_busy (gimp);
|
2001-12-02 05:02:34 +08:00
|
|
|
gimp_dialog_factories_unidle ();
|
|
|
|
|
|
|
|
gdk_flush ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gui_message (Gimp *gimp,
|
|
|
|
const gchar *message)
|
|
|
|
{
|
|
|
|
switch (gimp->message_handler)
|
|
|
|
{
|
|
|
|
case GIMP_MESSAGE_BOX:
|
|
|
|
gimp_message_box (message, NULL, NULL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_ERROR_CONSOLE:
|
|
|
|
gimp_dialog_factory_dialog_raise (global_dock_factory,
|
2002-03-21 20:17:17 +08:00
|
|
|
"gimp-error-console", -1);
|
2001-12-02 05:02:34 +08:00
|
|
|
error_console_add (gimp, message);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
static GimpObject *
|
|
|
|
gui_display_new (GimpImage *gimage,
|
|
|
|
guint scale)
|
2001-07-05 23:34:26 +08:00
|
|
|
{
|
2002-12-14 22:13:54 +08:00
|
|
|
GimpDisplayShell *shell;
|
2003-01-11 01:55:53 +08:00
|
|
|
GimpDisplay *gdisp;
|
2001-07-05 23:34:26 +08:00
|
|
|
|
2003-01-11 01:55:53 +08:00
|
|
|
gdisp = gimp_display_new (gimage, scale,
|
|
|
|
global_menu_factory,
|
|
|
|
image_item_factory);
|
2001-07-05 23:34:26 +08:00
|
|
|
|
2002-12-14 22:13:54 +08:00
|
|
|
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
2001-07-05 23:34:26 +08:00
|
|
|
|
2002-12-14 22:13:54 +08:00
|
|
|
gimp_context_set_display (gimp_get_user_context (gimage->gimp), gdisp);
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2003-03-20 19:31:33 +08:00
|
|
|
gimp_item_factory_update (shell->menubar_factory, shell);
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
return GIMP_OBJECT (gdisp);
|
2001-07-05 23:34:26 +08:00
|
|
|
}
|
|
|
|
|
2002-02-28 21:47:03 +08:00
|
|
|
static void
|
2002-10-23 22:55:07 +08:00
|
|
|
gui_themes_dir_foreach_func (GimpDatafileData *file_data)
|
2002-02-28 21:47:03 +08:00
|
|
|
{
|
|
|
|
Gimp *gimp;
|
|
|
|
gchar *basename;
|
|
|
|
|
2002-10-23 22:55:07 +08:00
|
|
|
gimp = (Gimp *) file_data->user_data;
|
2002-02-28 21:47:03 +08:00
|
|
|
|
2002-10-23 22:55:07 +08:00
|
|
|
basename = g_path_get_basename (file_data->filename);
|
2002-02-28 21:47:03 +08:00
|
|
|
|
|
|
|
if (gimp->be_verbose)
|
2002-10-23 22:55:07 +08:00
|
|
|
g_print (_("Adding theme '%s' (%s)\n"), basename, file_data->filename);
|
2002-02-28 21:47:03 +08:00
|
|
|
|
|
|
|
g_hash_table_insert (themes_hash,
|
|
|
|
basename,
|
2002-10-23 22:55:07 +08:00
|
|
|
g_strdup (file_data->filename));
|
2002-02-28 21:47:03 +08:00
|
|
|
}
|
|
|
|
|
2002-12-05 23:49:59 +08:00
|
|
|
static gboolean
|
|
|
|
gui_exit_callback (Gimp *gimp,
|
|
|
|
gboolean kill_it)
|
|
|
|
{
|
|
|
|
if (! kill_it && gimp_displays_dirty (gimp))
|
|
|
|
{
|
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?"),
|
|
|
|
gimp_standard_help_func,
|
|
|
|
"dialogs/really_quit.html",
|
|
|
|
GIMP_STOCK_WILBER_EEK,
|
|
|
|
_("Some files are unsaved.\n"
|
|
|
|
"\nReally quit The GIMP?"),
|
|
|
|
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;
|
|
|
|
|
|
|
|
session_save (gimp);
|
2003-04-08 18:02:42 +08:00
|
|
|
menus_save (gimp);
|
2002-12-05 23:49:59 +08:00
|
|
|
|
|
|
|
if (GIMP_GUI_CONFIG (gimp->config)->save_device_status)
|
|
|
|
gimp_devices_save (gimp);
|
|
|
|
|
|
|
|
gimp_displays_delete (gimp);
|
|
|
|
|
|
|
|
return FALSE; /* continue exiting */
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gui_exit_finish_callback (Gimp *gimp,
|
|
|
|
gboolean kill_it)
|
|
|
|
{
|
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);
|
|
|
|
|
|
|
|
if (themes_hash)
|
|
|
|
{
|
|
|
|
g_hash_table_destroy (themes_hash);
|
|
|
|
themes_hash = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2002-12-05 23:49:59 +08:00
|
|
|
Gimp *gimp;
|
2001-10-25 21:30:01 +08:00
|
|
|
|
2002-12-05 23:49:59 +08:00
|
|
|
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 ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#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
|
|
|
{
|
2003-01-11 01:55:53 +08:00
|
|
|
GimpItemFactory *item_factory;
|
2002-03-20 23:32:35 +08:00
|
|
|
GimpDisplayShell *shell = NULL;
|
2001-07-08 02:16:18 +08:00
|
|
|
|
2003-01-11 01:55:53 +08:00
|
|
|
item_factory = gimp_item_factory_from_path ("<Image>");
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
if (display)
|
2002-03-20 23:32:35 +08:00
|
|
|
shell = GIMP_DISPLAY_SHELL (display->shell);
|
|
|
|
|
2003-01-11 01:55:53 +08:00
|
|
|
gimp_item_factory_update (item_factory, shell);
|
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
|
|
|
}
|
|
|
|
}
|