2009-09-23 18:24:22 +08:00
|
|
|
/* GIMP - The GNU 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <gegl.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2009-09-25 23:46:09 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2009-09-23 18:24:22 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "display-types.h"
|
|
|
|
|
2009-09-25 23:46:09 +08:00
|
|
|
#include "core/gimpimage.h"
|
2009-09-26 01:35:03 +08:00
|
|
|
#include "core/gimpprogress.h"
|
2009-09-25 23:46:09 +08:00
|
|
|
|
2009-09-23 20:52:33 +08:00
|
|
|
#include "widgets/gimpactiongroup.h"
|
2009-09-23 21:05:00 +08:00
|
|
|
#include "widgets/gimpdialogfactory.h"
|
2009-09-23 23:55:41 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2009-09-23 18:47:25 +08:00
|
|
|
#include "widgets/gimpmenufactory.h"
|
2009-09-25 07:56:30 +08:00
|
|
|
#include "widgets/gimpsessioninfo.h"
|
2009-09-23 18:47:25 +08:00
|
|
|
#include "widgets/gimpuimanager.h"
|
|
|
|
|
2009-09-23 21:05:00 +08:00
|
|
|
#include "gimpdisplay.h"
|
|
|
|
#include "gimpdisplay-foreach.h"
|
2009-09-23 19:06:11 +08:00
|
|
|
#include "gimpdisplayshell.h"
|
2009-09-25 19:58:25 +08:00
|
|
|
#include "gimpdisplayshell-appearance.h"
|
2009-09-26 04:41:50 +08:00
|
|
|
#include "gimpdisplayshell-callbacks.h"
|
2009-09-25 18:48:30 +08:00
|
|
|
#include "gimpdisplayshell-close.h"
|
2009-09-25 23:46:09 +08:00
|
|
|
#include "gimpdisplayshell-scroll.h"
|
2009-09-23 18:24:22 +08:00
|
|
|
#include "gimpimagewindow.h"
|
2009-09-23 23:55:41 +08:00
|
|
|
#include "gimpstatusbar.h"
|
2009-09-23 18:24:22 +08:00
|
|
|
|
2009-09-23 19:40:52 +08:00
|
|
|
#include "gimp-log.h"
|
2009-09-23 18:24:22 +08:00
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
2009-09-23 18:47:25 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2009-09-25 07:31:08 +08:00
|
|
|
PROP_MENU_FACTORY,
|
|
|
|
PROP_DISPLAY_FACTORY
|
2009-09-23 18:47:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-09-23 18:24:22 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2009-09-25 19:43:54 +08:00
|
|
|
static GObject * gimp_image_window_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params);
|
|
|
|
static void gimp_image_window_finalize (GObject *object);
|
|
|
|
static void gimp_image_window_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_image_window_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
|
|
|
static void gimp_image_window_destroy (GtkObject *object);
|
|
|
|
|
|
|
|
static gboolean gimp_image_window_delete_event (GtkWidget *widget,
|
|
|
|
GdkEventAny *event);
|
|
|
|
static gboolean gimp_image_window_configure_event (GtkWidget *widget,
|
|
|
|
GdkEventConfigure *event);
|
|
|
|
static gboolean gimp_image_window_window_state_event (GtkWidget *widget,
|
|
|
|
GdkEventWindowState *event);
|
|
|
|
static void gimp_image_window_style_set (GtkWidget *widget,
|
|
|
|
GtkStyle *prev_style);
|
|
|
|
|
|
|
|
static void gimp_image_window_show_tooltip (GimpUIManager *manager,
|
|
|
|
const gchar *tooltip,
|
|
|
|
GimpImageWindow *window);
|
|
|
|
static void gimp_image_window_hide_tooltip (GimpUIManager *manager,
|
|
|
|
GimpImageWindow *window);
|
2009-09-23 23:55:41 +08:00
|
|
|
|
2009-09-26 04:41:50 +08:00
|
|
|
static gboolean gimp_image_window_shell_events (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
GimpImageWindow *window);
|
|
|
|
|
2009-09-24 15:58:36 +08:00
|
|
|
static void gimp_image_window_image_notify (GimpDisplay *display,
|
|
|
|
const GParamSpec *pspec,
|
|
|
|
GimpImageWindow *window);
|
2009-09-24 01:33:36 +08:00
|
|
|
static void gimp_image_window_shell_scaled (GimpDisplayShell *shell,
|
|
|
|
GimpImageWindow *window);
|
|
|
|
static void gimp_image_window_shell_title_notify (GimpDisplayShell *shell,
|
|
|
|
const GParamSpec *pspec,
|
|
|
|
GimpImageWindow *window);
|
|
|
|
static void gimp_image_window_shell_status_notify (GimpDisplayShell *shell,
|
|
|
|
const GParamSpec *pspec,
|
|
|
|
GimpImageWindow *window);
|
2009-09-24 15:09:35 +08:00
|
|
|
static void gimp_image_window_shell_icon_notify (GimpDisplayShell *shell,
|
|
|
|
const GParamSpec *pspec,
|
|
|
|
GimpImageWindow *window);
|
2009-09-24 00:52:42 +08:00
|
|
|
|
2009-09-23 18:24:22 +08:00
|
|
|
|
|
|
|
G_DEFINE_TYPE (GimpImageWindow, gimp_image_window, GIMP_TYPE_WINDOW)
|
|
|
|
|
|
|
|
#define parent_class gimp_image_window_parent_class
|
|
|
|
|
|
|
|
|
2009-09-23 21:53:16 +08:00
|
|
|
static const gchar image_window_rc_style[] =
|
|
|
|
"style \"fullscreen-menubar-style\"\n"
|
|
|
|
"{\n"
|
|
|
|
" GtkMenuBar::shadow-type = none\n"
|
|
|
|
" GtkMenuBar::internal-padding = 0\n"
|
|
|
|
"}\n"
|
|
|
|
"widget \"*.gimp-menubar-fullscreen\" style \"fullscreen-menubar-style\"\n";
|
|
|
|
|
2009-09-23 18:24:22 +08:00
|
|
|
static void
|
|
|
|
gimp_image_window_class_init (GimpImageWindowClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
|
2009-09-23 19:40:52 +08:00
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->constructor = gimp_image_window_constructor;
|
|
|
|
object_class->finalize = gimp_image_window_finalize;
|
|
|
|
object_class->set_property = gimp_image_window_set_property;
|
|
|
|
object_class->get_property = gimp_image_window_get_property;
|
2009-09-23 18:24:22 +08:00
|
|
|
|
2009-09-23 19:40:52 +08:00
|
|
|
gtk_object_class->destroy = gimp_image_window_destroy;
|
2009-09-23 18:24:22 +08:00
|
|
|
|
2009-09-25 18:48:30 +08:00
|
|
|
widget_class->delete_event = gimp_image_window_delete_event;
|
2009-09-25 19:41:23 +08:00
|
|
|
widget_class->configure_event = gimp_image_window_configure_event;
|
2009-09-25 19:43:54 +08:00
|
|
|
widget_class->window_state_event = gimp_image_window_window_state_event;
|
2009-09-24 00:13:08 +08:00
|
|
|
widget_class->style_set = gimp_image_window_style_set;
|
2009-09-23 18:47:25 +08:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_MENU_FACTORY,
|
|
|
|
g_param_spec_object ("menu-factory",
|
|
|
|
NULL, NULL,
|
|
|
|
GIMP_TYPE_MENU_FACTORY,
|
|
|
|
GIMP_PARAM_WRITABLE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
2009-09-23 21:53:16 +08:00
|
|
|
|
2009-09-25 07:31:08 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_DISPLAY_FACTORY,
|
|
|
|
g_param_spec_object ("display-factory",
|
|
|
|
NULL, NULL,
|
|
|
|
GIMP_TYPE_DIALOG_FACTORY,
|
|
|
|
GIMP_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
2009-09-23 21:53:16 +08:00
|
|
|
gtk_rc_parse_string (image_window_rc_style);
|
2009-09-23 18:24:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_image_window_init (GimpImageWindow *window)
|
|
|
|
{
|
2009-09-24 15:18:19 +08:00
|
|
|
gtk_window_set_role (GTK_WINDOW (window), "gimp-image-window");
|
|
|
|
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
|
2009-09-23 18:24:22 +08:00
|
|
|
}
|
|
|
|
|
2009-09-23 18:47:25 +08:00
|
|
|
static GObject *
|
|
|
|
gimp_image_window_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params)
|
|
|
|
{
|
|
|
|
GObject *object;
|
|
|
|
GimpImageWindow *window;
|
|
|
|
|
|
|
|
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
|
|
|
|
|
|
|
window = GIMP_IMAGE_WINDOW (object);
|
|
|
|
|
|
|
|
g_assert (GIMP_IS_UI_MANAGER (window->menubar_manager));
|
|
|
|
|
2009-09-23 22:58:03 +08:00
|
|
|
gtk_window_add_accel_group (GTK_WINDOW (window),
|
|
|
|
gtk_ui_manager_get_accel_group (GTK_UI_MANAGER (window->menubar_manager)));
|
|
|
|
|
2009-09-23 23:55:41 +08:00
|
|
|
g_signal_connect (window->menubar_manager, "show-tooltip",
|
|
|
|
G_CALLBACK (gimp_image_window_show_tooltip),
|
|
|
|
window);
|
|
|
|
g_signal_connect (window->menubar_manager, "hide-tooltip",
|
|
|
|
G_CALLBACK (gimp_image_window_hide_tooltip),
|
|
|
|
window);
|
|
|
|
|
2009-09-23 21:46:44 +08:00
|
|
|
window->main_vbox = gtk_vbox_new (FALSE, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (window), window->main_vbox);
|
|
|
|
gtk_widget_show (window->main_vbox);
|
|
|
|
|
2009-09-23 22:58:03 +08:00
|
|
|
#ifndef GDK_WINDOWING_QUARTZ
|
|
|
|
window->menubar =
|
|
|
|
gtk_ui_manager_get_widget (GTK_UI_MANAGER (window->menubar_manager),
|
|
|
|
"/image-menubar");
|
|
|
|
#endif /* !GDK_WINDOWING_QUARTZ */
|
|
|
|
|
|
|
|
if (window->menubar)
|
|
|
|
{
|
|
|
|
gtk_box_pack_start (GTK_BOX (window->main_vbox),
|
|
|
|
window->menubar, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
/* make sure we can activate accels even if the menubar is invisible
|
|
|
|
* (see http://bugzilla.gnome.org/show_bug.cgi?id=137151)
|
|
|
|
*/
|
|
|
|
g_signal_connect (window->menubar, "can-activate-accel",
|
|
|
|
G_CALLBACK (gtk_true),
|
|
|
|
NULL);
|
2009-09-26 04:41:50 +08:00
|
|
|
|
|
|
|
/* active display callback */
|
|
|
|
g_signal_connect (window->menubar, "button-press-event",
|
|
|
|
G_CALLBACK (gimp_image_window_shell_events),
|
|
|
|
window);
|
|
|
|
g_signal_connect (window->menubar, "button-release-event",
|
|
|
|
G_CALLBACK (gimp_image_window_shell_events),
|
|
|
|
window);
|
|
|
|
g_signal_connect (window->menubar, "key-press-event",
|
|
|
|
G_CALLBACK (gimp_image_window_shell_events),
|
|
|
|
window);
|
2009-09-23 22:58:03 +08:00
|
|
|
}
|
|
|
|
|
2009-09-24 15:40:32 +08:00
|
|
|
window->statusbar = gimp_statusbar_new ();
|
2009-09-23 23:55:41 +08:00
|
|
|
gimp_help_set_help_data (window->statusbar, NULL,
|
|
|
|
GIMP_HELP_IMAGE_WINDOW_STATUS_BAR);
|
|
|
|
gtk_box_pack_end (GTK_BOX (window->main_vbox), window->statusbar,
|
|
|
|
FALSE, FALSE, 0);
|
|
|
|
|
2009-09-23 18:47:25 +08:00
|
|
|
return object;
|
|
|
|
}
|
|
|
|
|
2009-09-23 18:24:22 +08:00
|
|
|
static void
|
|
|
|
gimp_image_window_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GimpImageWindow *window = GIMP_IMAGE_WINDOW (object);
|
|
|
|
|
2009-09-25 07:35:03 +08:00
|
|
|
if (window->menubar_manager)
|
|
|
|
{
|
|
|
|
g_object_unref (window->menubar_manager);
|
|
|
|
window->menubar_manager = NULL;
|
|
|
|
}
|
|
|
|
|
2009-09-23 18:24:22 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_image_window_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpImageWindow *window = GIMP_IMAGE_WINDOW (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
2009-09-23 18:47:25 +08:00
|
|
|
case PROP_MENU_FACTORY:
|
|
|
|
{
|
|
|
|
GimpMenuFactory *factory = g_value_get_object (value);
|
|
|
|
|
|
|
|
window->menubar_manager = gimp_menu_factory_manager_new (factory,
|
|
|
|
"<Image>",
|
|
|
|
window,
|
|
|
|
FALSE);
|
|
|
|
}
|
|
|
|
break;
|
2009-09-25 07:31:08 +08:00
|
|
|
case PROP_DISPLAY_FACTORY:
|
|
|
|
window->display_factory = g_value_get_object (value);
|
|
|
|
break;
|
2009-09-23 18:47:25 +08:00
|
|
|
|
2009-09-23 18:24:22 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_image_window_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpImageWindow *window = GIMP_IMAGE_WINDOW (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
2009-09-25 07:31:08 +08:00
|
|
|
case PROP_DISPLAY_FACTORY:
|
|
|
|
g_value_set_object (value, window->display_factory);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_MENU_FACTORY:
|
2009-09-23 18:24:22 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_image_window_destroy (GtkObject *object)
|
|
|
|
{
|
|
|
|
GimpImageWindow *window = GIMP_IMAGE_WINDOW (object);
|
|
|
|
|
2009-09-23 18:47:25 +08:00
|
|
|
if (window->menubar_manager)
|
|
|
|
{
|
|
|
|
g_object_unref (window->menubar_manager);
|
|
|
|
window->menubar_manager = NULL;
|
|
|
|
}
|
|
|
|
|
2009-09-23 18:24:22 +08:00
|
|
|
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
|
|
|
}
|
2009-09-23 19:06:11 +08:00
|
|
|
|
2009-09-25 18:48:30 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_image_window_delete_event (GtkWidget *widget,
|
|
|
|
GdkEventAny *event)
|
|
|
|
{
|
2009-09-29 04:53:31 +08:00
|
|
|
GimpImageWindow *window = GIMP_IMAGE_WINDOW (widget);
|
|
|
|
GimpDisplayShell *shell = gimp_image_window_get_active_shell (window);
|
2009-09-25 18:48:30 +08:00
|
|
|
|
|
|
|
/* FIXME multiple shells */
|
2009-09-29 04:53:31 +08:00
|
|
|
gimp_display_shell_close (shell, FALSE);
|
2009-09-25 18:48:30 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-09-25 19:41:23 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_image_window_configure_event (GtkWidget *widget,
|
|
|
|
GdkEventConfigure *event)
|
|
|
|
{
|
|
|
|
GimpImageWindow *window = GIMP_IMAGE_WINDOW (widget);
|
|
|
|
gint current_width;
|
|
|
|
gint current_height;
|
|
|
|
|
|
|
|
/* Grab the size before we run the parent implementation */
|
|
|
|
current_width = widget->allocation.width;
|
|
|
|
current_height = widget->allocation.height;
|
|
|
|
|
|
|
|
/* Run the parent implementation */
|
|
|
|
if (GTK_WIDGET_CLASS (parent_class)->configure_event)
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->configure_event (widget, event);
|
|
|
|
|
|
|
|
/* If the window size has changed, make sure additoinal logic is run
|
|
|
|
* in the display shell's size-allocate
|
|
|
|
*/
|
|
|
|
if (event->width != current_width ||
|
|
|
|
event->height != current_height)
|
|
|
|
{
|
|
|
|
/* FIXME multiple shells */
|
2009-09-29 04:53:31 +08:00
|
|
|
GimpDisplayShell *shell = gimp_image_window_get_active_shell (window);
|
2009-09-25 19:41:23 +08:00
|
|
|
|
2009-09-29 04:53:31 +08:00
|
|
|
if (shell->display->image)
|
|
|
|
shell->size_allocate_from_configure_event = TRUE;
|
2009-09-25 19:41:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-09-23 19:40:52 +08:00
|
|
|
static gboolean
|
2009-09-25 19:43:54 +08:00
|
|
|
gimp_image_window_window_state_event (GtkWidget *widget,
|
|
|
|
GdkEventWindowState *event)
|
2009-09-23 19:40:52 +08:00
|
|
|
{
|
2009-09-29 04:53:31 +08:00
|
|
|
GimpImageWindow *window = GIMP_IMAGE_WINDOW (widget);
|
|
|
|
GimpDisplayShell *shell = gimp_image_window_get_active_shell (window);
|
2009-09-23 19:40:52 +08:00
|
|
|
|
|
|
|
window->window_state = event->new_window_state;
|
|
|
|
|
2009-09-23 20:52:33 +08:00
|
|
|
if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
|
|
|
|
{
|
2009-09-25 20:06:14 +08:00
|
|
|
gboolean fullscreen = gimp_image_window_get_fullscreen (window);
|
2009-09-23 20:52:33 +08:00
|
|
|
|
|
|
|
GIMP_LOG (WM, "Image window '%s' [%p] set fullscreen %s",
|
|
|
|
gtk_window_get_title (GTK_WINDOW (widget)),
|
|
|
|
widget,
|
|
|
|
fullscreen ? "TURE" : "FALSE");
|
|
|
|
|
2009-09-23 22:58:03 +08:00
|
|
|
if (window->menubar)
|
|
|
|
gtk_widget_set_name (window->menubar,
|
|
|
|
fullscreen ? "gimp-menubar-fullscreen" : NULL);
|
|
|
|
|
2009-09-23 23:55:41 +08:00
|
|
|
gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (window->statusbar),
|
|
|
|
! fullscreen);
|
|
|
|
|
2009-09-29 04:53:31 +08:00
|
|
|
gimp_display_shell_appearance_update (shell);
|
2009-09-23 20:52:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (event->changed_mask & GDK_WINDOW_STATE_ICONIFIED)
|
|
|
|
{
|
2009-09-26 01:04:10 +08:00
|
|
|
gboolean iconified = gimp_image_window_is_iconified (window);
|
2009-09-23 20:52:33 +08:00
|
|
|
|
|
|
|
GIMP_LOG (WM, "Image window '%s' [%p] set %s",
|
|
|
|
gtk_window_get_title (GTK_WINDOW (widget)),
|
|
|
|
widget,
|
|
|
|
iconified ? "iconified" : "uniconified");
|
2009-09-23 21:05:00 +08:00
|
|
|
|
|
|
|
if (iconified)
|
|
|
|
{
|
2009-09-29 04:53:31 +08:00
|
|
|
if (gimp_displays_get_num_visible (shell->display->gimp) == 0)
|
2009-09-23 21:05:00 +08:00
|
|
|
{
|
|
|
|
GIMP_LOG (WM, "No displays visible any longer");
|
|
|
|
|
|
|
|
gimp_dialog_factories_hide_with_display ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_dialog_factories_show_with_display ();
|
|
|
|
}
|
|
|
|
|
2009-09-26 01:35:03 +08:00
|
|
|
if (gimp_progress_is_active (GIMP_PROGRESS (window->statusbar)))
|
|
|
|
{
|
2009-09-29 04:53:31 +08:00
|
|
|
GimpStatusbar *statusbar = GIMP_STATUSBAR (window->statusbar);
|
2009-09-26 01:35:03 +08:00
|
|
|
|
|
|
|
if (iconified)
|
|
|
|
gimp_statusbar_override_window_title (statusbar);
|
|
|
|
else
|
|
|
|
gtk_window_set_title (GTK_WINDOW (window), shell->title);
|
|
|
|
}
|
2009-09-23 20:52:33 +08:00
|
|
|
}
|
|
|
|
|
2009-09-23 19:40:52 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-09-24 00:13:08 +08:00
|
|
|
static void
|
|
|
|
gimp_image_window_style_set (GtkWidget *widget,
|
|
|
|
GtkStyle *prev_style)
|
|
|
|
{
|
|
|
|
GimpImageWindow *window = GIMP_IMAGE_WINDOW (widget);
|
|
|
|
GtkRequisition requisition;
|
|
|
|
GdkGeometry geometry;
|
|
|
|
GdkWindowHints geometry_mask;
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
|
|
|
|
|
|
|
|
gtk_widget_size_request (window->statusbar, &requisition);
|
|
|
|
|
|
|
|
geometry.min_height = 23;
|
|
|
|
|
|
|
|
geometry.min_width = requisition.width;
|
|
|
|
geometry.min_height += requisition.height;
|
|
|
|
|
|
|
|
if (window->menubar)
|
|
|
|
{
|
|
|
|
gtk_widget_size_request (window->menubar, &requisition);
|
|
|
|
|
|
|
|
geometry.min_height += requisition.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
geometry_mask = GDK_HINT_MIN_SIZE;
|
|
|
|
|
|
|
|
/* Only set user pos on the empty display because it gets a pos
|
|
|
|
* set by gimp. All other displays should be placed by the window
|
|
|
|
* manager. See http://bugzilla.gnome.org/show_bug.cgi?id=559580
|
|
|
|
*/
|
2009-09-29 04:53:31 +08:00
|
|
|
if (! gimp_image_window_get_active_shell (window)->display->image)
|
2009-09-24 00:13:08 +08:00
|
|
|
geometry_mask |= GDK_HINT_USER_POS;
|
|
|
|
|
|
|
|
gtk_window_set_geometry_hints (GTK_WINDOW (widget), NULL,
|
|
|
|
&geometry, geometry_mask);
|
|
|
|
|
|
|
|
gimp_dialog_factory_set_has_min_size (GTK_WINDOW (widget), TRUE);
|
|
|
|
}
|
|
|
|
|
2009-09-23 19:06:11 +08:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2009-09-26 00:35:58 +08:00
|
|
|
void
|
2009-09-29 04:53:31 +08:00
|
|
|
gimp_image_window_add_shell (GimpImageWindow *window,
|
|
|
|
GimpDisplayShell *shell)
|
2009-09-26 00:35:58 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_IMAGE_WINDOW (window));
|
2009-09-29 04:53:31 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
g_return_if_fail (g_list_find (window->shells, shell) == NULL);
|
2009-09-26 00:35:58 +08:00
|
|
|
|
|
|
|
/* FIXME multiple shells */
|
2009-09-29 04:53:31 +08:00
|
|
|
g_assert (window->shells == NULL);
|
2009-09-26 00:35:58 +08:00
|
|
|
|
2009-09-29 04:53:31 +08:00
|
|
|
window->shells = g_list_append (window->shells, shell);
|
2009-09-26 00:35:58 +08:00
|
|
|
|
|
|
|
/* FIXME multiple shells */
|
|
|
|
gtk_box_pack_start (GTK_BOX (window->main_vbox),
|
2009-09-29 04:53:31 +08:00
|
|
|
shell->disp_vbox,
|
2009-09-26 00:35:58 +08:00
|
|
|
TRUE, TRUE, 0);
|
2009-09-29 04:53:31 +08:00
|
|
|
gtk_widget_show (shell->disp_vbox);
|
2009-09-26 00:35:58 +08:00
|
|
|
}
|
|
|
|
|
2009-09-24 00:22:50 +08:00
|
|
|
void
|
2009-09-29 04:53:31 +08:00
|
|
|
gimp_image_window_set_active_shell (GimpImageWindow *window,
|
|
|
|
GimpDisplayShell *shell)
|
2009-09-24 00:22:50 +08:00
|
|
|
{
|
2009-09-29 04:53:31 +08:00
|
|
|
GimpDisplay *active_display;
|
2009-09-24 00:52:42 +08:00
|
|
|
|
2009-09-24 00:22:50 +08:00
|
|
|
g_return_if_fail (GIMP_IS_IMAGE_WINDOW (window));
|
2009-09-29 04:53:31 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
2009-09-24 00:22:50 +08:00
|
|
|
|
2009-09-29 04:53:31 +08:00
|
|
|
if (shell == window->active_shell)
|
2009-09-24 00:22:50 +08:00
|
|
|
return;
|
|
|
|
|
2009-09-29 04:53:31 +08:00
|
|
|
if (window->active_shell)
|
2009-09-24 00:22:50 +08:00
|
|
|
{
|
2009-09-29 04:53:31 +08:00
|
|
|
active_display = window->active_shell->display;
|
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func (active_display,
|
2009-09-24 15:58:36 +08:00
|
|
|
gimp_image_window_image_notify,
|
|
|
|
window);
|
|
|
|
|
2009-09-29 04:53:31 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (window->active_shell,
|
2009-09-24 00:52:42 +08:00
|
|
|
gimp_image_window_shell_scaled,
|
|
|
|
window);
|
2009-09-29 04:53:31 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (window->active_shell,
|
2009-09-24 01:33:36 +08:00
|
|
|
gimp_image_window_shell_title_notify,
|
|
|
|
window);
|
2009-09-29 04:53:31 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (window->active_shell,
|
2009-09-24 01:33:36 +08:00
|
|
|
gimp_image_window_shell_status_notify,
|
|
|
|
window);
|
2009-09-29 04:53:31 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (window->active_shell,
|
2009-09-24 15:09:35 +08:00
|
|
|
gimp_image_window_shell_icon_notify,
|
|
|
|
window);
|
2009-09-24 00:22:50 +08:00
|
|
|
}
|
|
|
|
|
2009-09-29 04:53:31 +08:00
|
|
|
window->active_shell = shell;
|
2009-09-24 00:52:42 +08:00
|
|
|
|
2009-09-29 04:53:31 +08:00
|
|
|
active_display = window->active_shell->display;
|
|
|
|
|
|
|
|
g_signal_connect (active_display, "notify::image",
|
2009-09-24 15:58:36 +08:00
|
|
|
G_CALLBACK (gimp_image_window_image_notify),
|
|
|
|
window);
|
|
|
|
|
2009-09-29 04:53:31 +08:00
|
|
|
gimp_statusbar_set_shell (GIMP_STATUSBAR (window->statusbar),
|
|
|
|
window->active_shell);
|
2009-09-24 15:40:32 +08:00
|
|
|
|
2009-09-29 04:53:31 +08:00
|
|
|
g_signal_connect (window->active_shell, "scaled",
|
2009-09-24 00:52:42 +08:00
|
|
|
G_CALLBACK (gimp_image_window_shell_scaled),
|
|
|
|
window);
|
2009-09-24 01:33:36 +08:00
|
|
|
/* FIXME: "title" later */
|
2009-09-29 04:53:31 +08:00
|
|
|
g_signal_connect (window->active_shell, "notify::gimp-title",
|
2009-09-24 01:33:36 +08:00
|
|
|
G_CALLBACK (gimp_image_window_shell_title_notify),
|
|
|
|
window);
|
2009-09-29 04:53:31 +08:00
|
|
|
g_signal_connect (window->active_shell, "notify::status",
|
2009-09-24 01:33:36 +08:00
|
|
|
G_CALLBACK (gimp_image_window_shell_status_notify),
|
|
|
|
window);
|
2009-09-24 15:09:35 +08:00
|
|
|
/* FIXME: "icon" later */
|
2009-09-29 04:53:31 +08:00
|
|
|
g_signal_connect (window->active_shell, "notify::gimp-icon",
|
2009-09-24 15:09:35 +08:00
|
|
|
G_CALLBACK (gimp_image_window_shell_icon_notify),
|
|
|
|
window);
|
2009-09-24 00:52:42 +08:00
|
|
|
|
2009-09-29 04:53:31 +08:00
|
|
|
gimp_display_shell_appearance_update (window->active_shell);
|
2009-09-26 06:50:21 +08:00
|
|
|
|
2009-09-29 04:53:31 +08:00
|
|
|
if (! active_display->image)
|
2009-09-25 18:09:15 +08:00
|
|
|
{
|
|
|
|
gimp_statusbar_empty (GIMP_STATUSBAR (window->statusbar));
|
|
|
|
|
|
|
|
gimp_dialog_factory_add_foreign (window->display_factory,
|
|
|
|
"gimp-empty-image-window",
|
|
|
|
GTK_WIDGET (window));
|
|
|
|
}
|
|
|
|
|
2009-09-29 04:53:31 +08:00
|
|
|
gimp_ui_manager_update (window->menubar_manager, active_display);
|
2009-09-24 00:22:50 +08:00
|
|
|
}
|
|
|
|
|
2009-09-29 04:53:31 +08:00
|
|
|
GimpDisplayShell *
|
|
|
|
gimp_image_window_get_active_shell (GimpImageWindow *window)
|
2009-09-23 19:06:11 +08:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE_WINDOW (window), NULL);
|
|
|
|
|
2009-09-29 04:53:31 +08:00
|
|
|
return window->active_shell;
|
2009-09-23 19:06:11 +08:00
|
|
|
}
|
2009-09-23 20:52:33 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
gimp_image_window_set_fullscreen (GimpImageWindow *window,
|
|
|
|
gboolean fullscreen)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_IMAGE_WINDOW (window));
|
|
|
|
|
|
|
|
if (fullscreen != gimp_image_window_get_fullscreen (window))
|
|
|
|
{
|
|
|
|
if (fullscreen)
|
|
|
|
gtk_window_fullscreen (GTK_WINDOW (window));
|
|
|
|
else
|
|
|
|
gtk_window_unfullscreen (GTK_WINDOW (window));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_image_window_get_fullscreen (GimpImageWindow *window)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE_WINDOW (window), FALSE);
|
|
|
|
|
|
|
|
return (window->window_state & GDK_WINDOW_STATE_FULLSCREEN) != 0;
|
|
|
|
}
|
2009-09-23 23:55:41 +08:00
|
|
|
|
2009-09-26 01:04:10 +08:00
|
|
|
gboolean
|
|
|
|
gimp_image_window_is_iconified (GimpImageWindow *window)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE_WINDOW (window), FALSE);
|
|
|
|
|
|
|
|
return (window->window_state & GDK_WINDOW_STATE_ICONIFIED) != 0;
|
|
|
|
}
|
|
|
|
|
2009-09-25 23:46:09 +08:00
|
|
|
void
|
|
|
|
gimp_image_window_shrink_wrap (GimpImageWindow *window,
|
|
|
|
gboolean grow_only)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *active_shell;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GdkScreen *screen;
|
|
|
|
GdkRectangle rect;
|
|
|
|
gint monitor;
|
|
|
|
gint disp_width, disp_height;
|
|
|
|
gint width, height;
|
|
|
|
gint max_auto_width, max_auto_height;
|
|
|
|
gint border_width, border_height;
|
|
|
|
gboolean resize = FALSE;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_IMAGE_WINDOW (window));
|
|
|
|
|
|
|
|
if (! GTK_WIDGET_REALIZED (window))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* FIXME this so needs cleanup and shell/window separation */
|
|
|
|
|
2009-09-29 04:53:31 +08:00
|
|
|
active_shell = gimp_image_window_get_active_shell (window);
|
2009-09-25 23:46:09 +08:00
|
|
|
|
|
|
|
widget = GTK_WIDGET (window);
|
|
|
|
screen = gtk_widget_get_screen (widget);
|
|
|
|
|
|
|
|
monitor = gdk_screen_get_monitor_at_window (screen,
|
|
|
|
gtk_widget_get_window (widget));
|
|
|
|
gdk_screen_get_monitor_geometry (screen, monitor, &rect);
|
|
|
|
|
2009-09-29 04:53:31 +08:00
|
|
|
width = SCALEX (active_shell, gimp_image_get_width (active_shell->display->image));
|
|
|
|
height = SCALEY (active_shell, gimp_image_get_height (active_shell->display->image));
|
2009-09-25 23:46:09 +08:00
|
|
|
|
|
|
|
disp_width = active_shell->disp_width;
|
|
|
|
disp_height = active_shell->disp_height;
|
|
|
|
|
|
|
|
|
|
|
|
/* As long as the disp_width/disp_height is larger than 1 we
|
|
|
|
* can reliably depend on it to calculate the
|
|
|
|
* border_width/border_height because that means there is enough
|
|
|
|
* room in the top-level for the canvas as well as the rulers and
|
|
|
|
* scrollbars. If it is 1 or smaller it is likely that the rulers
|
|
|
|
* and scrollbars are overlapping each other and thus we cannot use
|
|
|
|
* the normal approach to border size, so special case that.
|
|
|
|
*/
|
|
|
|
if (disp_width > 1 || !active_shell->vsb)
|
|
|
|
border_width = widget->allocation.width - disp_width;
|
|
|
|
else
|
|
|
|
border_width = widget->allocation.width - disp_width + active_shell->vsb->allocation.width;
|
|
|
|
|
|
|
|
if (disp_height > 1 || !active_shell->hsb)
|
|
|
|
border_height = widget->allocation.height - disp_height;
|
|
|
|
else
|
|
|
|
border_height = widget->allocation.height - disp_height + active_shell->hsb->allocation.height;
|
|
|
|
|
|
|
|
|
|
|
|
max_auto_width = (rect.width - border_width) * 0.75;
|
|
|
|
max_auto_height = (rect.height - border_height) * 0.75;
|
|
|
|
|
|
|
|
/* If one of the display dimensions has changed and one of the
|
|
|
|
* dimensions fits inside the screen
|
|
|
|
*/
|
|
|
|
if (((width + border_width) < rect.width ||
|
|
|
|
(height + border_height) < rect.height) &&
|
|
|
|
(width != disp_width ||
|
|
|
|
height != disp_height))
|
|
|
|
{
|
|
|
|
width = ((width + border_width) < rect.width) ? width : max_auto_width;
|
|
|
|
height = ((height + border_height) < rect.height) ? height : max_auto_height;
|
|
|
|
|
|
|
|
resize = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the projected dimension is greater than current, but less than
|
|
|
|
* 3/4 of the screen size, expand automagically
|
|
|
|
*/
|
|
|
|
else if ((width > disp_width ||
|
|
|
|
height > disp_height) &&
|
|
|
|
(disp_width < max_auto_width ||
|
|
|
|
disp_height < max_auto_height))
|
|
|
|
{
|
|
|
|
width = MIN (max_auto_width, width);
|
|
|
|
height = MIN (max_auto_height, height);
|
|
|
|
|
|
|
|
resize = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (resize)
|
|
|
|
{
|
|
|
|
if (width < window->statusbar->requisition.width)
|
|
|
|
width = window->statusbar->requisition.width;
|
|
|
|
|
|
|
|
width = width + border_width;
|
|
|
|
height = height + border_height;
|
|
|
|
|
|
|
|
if (grow_only)
|
|
|
|
{
|
|
|
|
if (width < widget->allocation.width)
|
|
|
|
width = widget->allocation.width;
|
|
|
|
|
|
|
|
if (height < widget->allocation.height)
|
|
|
|
height = widget->allocation.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_window_resize (GTK_WINDOW (window), width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* A wrap always means that we should center the image too. If the
|
|
|
|
* window changes size another center will be done in
|
|
|
|
* GimpDisplayShell::configure_event().
|
|
|
|
*/
|
|
|
|
/* FIXME multiple shells */
|
|
|
|
gimp_display_shell_scroll_center_image (active_shell, TRUE, TRUE);
|
|
|
|
}
|
|
|
|
|
2009-09-23 23:55:41 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_image_window_show_tooltip (GimpUIManager *manager,
|
|
|
|
const gchar *tooltip,
|
|
|
|
GimpImageWindow *window)
|
|
|
|
{
|
|
|
|
gimp_statusbar_push (GIMP_STATUSBAR (window->statusbar), "menu-tooltip",
|
|
|
|
NULL, "%s", tooltip);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_image_window_hide_tooltip (GimpUIManager *manager,
|
|
|
|
GimpImageWindow *window)
|
|
|
|
{
|
|
|
|
gimp_statusbar_pop (GIMP_STATUSBAR (window->statusbar), "menu-tooltip");
|
|
|
|
}
|
|
|
|
|
2009-09-26 04:41:50 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_image_window_shell_events (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
GimpImageWindow *window)
|
|
|
|
{
|
2009-09-29 04:53:31 +08:00
|
|
|
GimpDisplayShell *shell = gimp_image_window_get_active_shell (window);
|
2009-09-26 04:41:50 +08:00
|
|
|
|
2009-09-29 04:53:31 +08:00
|
|
|
return gimp_display_shell_events (widget, event, shell);
|
2009-09-26 04:41:50 +08:00
|
|
|
}
|
|
|
|
|
2009-09-24 15:58:36 +08:00
|
|
|
static void
|
|
|
|
gimp_image_window_image_notify (GimpDisplay *display,
|
|
|
|
const GParamSpec *pspec,
|
|
|
|
GimpImageWindow *window)
|
|
|
|
{
|
|
|
|
if (display->image)
|
|
|
|
{
|
2009-09-25 08:03:30 +08:00
|
|
|
/* FIXME don't run this code for revert */
|
|
|
|
|
|
|
|
gimp_dialog_factory_remove_dialog (window->display_factory,
|
|
|
|
GTK_WIDGET (window));
|
|
|
|
|
|
|
|
gimp_statusbar_fill (GIMP_STATUSBAR (window->statusbar));
|
2009-09-24 15:58:36 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-09-25 07:56:30 +08:00
|
|
|
GimpSessionInfo *session_info;
|
|
|
|
gint width;
|
|
|
|
gint height;
|
|
|
|
|
|
|
|
gtk_window_unfullscreen (GTK_WINDOW (window));
|
|
|
|
|
|
|
|
/* get the NIW size before adding the display to the dialog
|
|
|
|
* factory so the window's current size doesn't affect the
|
|
|
|
* stored session info entry.
|
|
|
|
*/
|
|
|
|
session_info =
|
|
|
|
gimp_dialog_factory_find_session_info (window->display_factory,
|
|
|
|
"gimp-empty-image-window");
|
|
|
|
|
|
|
|
if (session_info)
|
|
|
|
{
|
|
|
|
width = gimp_session_info_get_width (session_info);
|
|
|
|
height = gimp_session_info_get_height (session_info);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
width = GTK_WIDGET (window)->allocation.width;
|
|
|
|
height = GTK_WIDGET (window)->allocation.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_dialog_factory_add_foreign (window->display_factory,
|
|
|
|
"gimp-empty-image-window",
|
|
|
|
GTK_WIDGET (window));
|
|
|
|
|
|
|
|
gimp_statusbar_empty (GIMP_STATUSBAR (window->statusbar));
|
|
|
|
|
|
|
|
gtk_window_unmaximize (GTK_WINDOW (window));
|
|
|
|
gtk_window_resize (GTK_WINDOW (window), width, height);
|
|
|
|
|
|
|
|
gimp_ui_manager_update (window->menubar_manager, display);
|
2009-09-24 15:58:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-24 00:52:42 +08:00
|
|
|
static void
|
|
|
|
gimp_image_window_shell_scaled (GimpDisplayShell *shell,
|
|
|
|
GimpImageWindow *window)
|
|
|
|
{
|
|
|
|
/* update the <Image>/View/Zoom menu */
|
|
|
|
gimp_ui_manager_update (window->menubar_manager,
|
|
|
|
shell->display);
|
|
|
|
}
|
2009-09-24 01:33:36 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_image_window_shell_title_notify (GimpDisplayShell *shell,
|
|
|
|
const GParamSpec *pspec,
|
|
|
|
GimpImageWindow *window)
|
|
|
|
{
|
|
|
|
gtk_window_set_title (GTK_WINDOW (window), shell->title);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_image_window_shell_status_notify (GimpDisplayShell *shell,
|
|
|
|
const GParamSpec *pspec,
|
|
|
|
GimpImageWindow *window)
|
|
|
|
{
|
|
|
|
gimp_statusbar_replace (GIMP_STATUSBAR (window->statusbar), "title",
|
|
|
|
NULL, "%s", shell->status);
|
|
|
|
}
|
2009-09-24 15:09:35 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_image_window_shell_icon_notify (GimpDisplayShell *shell,
|
|
|
|
const GParamSpec *pspec,
|
|
|
|
GimpImageWindow *window)
|
|
|
|
{
|
|
|
|
gtk_window_set_icon (GTK_WINDOW (window), shell->icon);
|
|
|
|
}
|