2009-09-10 00:15:34 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* gimpdockwindow.c
|
|
|
|
* Copyright (C) 2001-2005 Michael Natterer <mitch@gimp.org>
|
|
|
|
* Copyright (C) 2009 Martin Nordholts <martinn@src.gnome.org>
|
|
|
|
*
|
|
|
|
* 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 <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "widgets-types.h"
|
|
|
|
|
2009-09-13 18:04:50 +08:00
|
|
|
#include "dialogs/dialogs.h" /* FIXME, we are in the widget layer */
|
|
|
|
|
2009-09-11 04:03:04 +08:00
|
|
|
#include "config/gimpguiconfig.h"
|
|
|
|
|
|
|
|
#include "core/gimp.h"
|
2009-09-11 03:34:49 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2009-09-13 15:22:59 +08:00
|
|
|
#include "core/gimpcontainer.h"
|
2009-09-13 18:04:50 +08:00
|
|
|
#include "core/gimpcontainer.h"
|
2009-09-11 03:34:49 +08:00
|
|
|
|
2009-09-13 15:22:59 +08:00
|
|
|
#include "gimpdialogfactory.h"
|
2009-09-13 18:04:50 +08:00
|
|
|
#include "gimpdock.h"
|
|
|
|
#include "gimpdockbook.h"
|
2009-09-10 00:15:34 +08:00
|
|
|
#include "gimpdockwindow.h"
|
2009-09-13 15:22:59 +08:00
|
|
|
#include "gimpmenufactory.h"
|
2009-09-13 18:04:50 +08:00
|
|
|
#include "gimpsessioninfo.h"
|
2009-09-13 15:22:59 +08:00
|
|
|
#include "gimpuimanager.h"
|
2009-09-11 04:03:04 +08:00
|
|
|
#include "gimpwidgets-utils.h"
|
2009-09-10 00:15:34 +08:00
|
|
|
#include "gimpwindow.h"
|
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
2009-09-13 17:23:02 +08:00
|
|
|
#define DEFAULT_DOCK_HEIGHT 300
|
|
|
|
#define DEFAULT_DOCK_FONT_SCALE PANGO_SCALE_SMALL
|
|
|
|
|
|
|
|
|
2009-09-11 03:34:49 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_CONTEXT,
|
2009-09-13 15:49:56 +08:00
|
|
|
PROP_DIALOG_FACTORY,
|
2009-09-13 15:22:59 +08:00
|
|
|
PROP_UI_MANAGER_NAME,
|
2009-09-11 03:34:49 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-09-10 00:15:34 +08:00
|
|
|
struct _GimpDockWindowPrivate
|
|
|
|
{
|
2009-09-13 15:49:56 +08:00
|
|
|
GimpContext *context;
|
2009-09-13 15:22:59 +08:00
|
|
|
|
2009-09-13 15:49:56 +08:00
|
|
|
GimpDialogFactory *dialog_factory;
|
|
|
|
|
|
|
|
gchar *ui_manager_name;
|
|
|
|
GimpUIManager *ui_manager;
|
|
|
|
GQuark image_flush_handler_id;
|
2009-09-13 17:23:02 +08:00
|
|
|
|
2009-09-13 19:14:18 +08:00
|
|
|
guint update_title_idle_id;
|
|
|
|
|
2009-09-13 17:23:02 +08:00
|
|
|
gint ID;
|
2009-09-10 00:15:34 +08:00
|
|
|
};
|
|
|
|
|
2009-09-13 18:04:50 +08:00
|
|
|
static GObject * gimp_dock_window_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params);
|
|
|
|
static void gimp_dock_window_dispose (GObject *object);
|
|
|
|
static void gimp_dock_window_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_dock_window_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_dock_window_style_set (GtkWidget *widget,
|
|
|
|
GtkStyle *prev_style);
|
|
|
|
static gboolean gimp_dock_window_delete_event (GtkWidget *widget,
|
|
|
|
GdkEventAny *event);
|
|
|
|
static void gimp_dock_window_display_changed (GimpDockWindow *dock_window,
|
|
|
|
GimpObject *display,
|
|
|
|
GimpContext *context);
|
|
|
|
static void gimp_dock_window_image_changed (GimpDockWindow *dock_window,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpContext *context);
|
|
|
|
static void gimp_dock_window_image_flush (GimpImage *image,
|
|
|
|
gboolean invalidate_preview,
|
|
|
|
GimpDockWindow *dock_window);
|
2009-09-13 19:14:18 +08:00
|
|
|
static void gimp_dock_window_update_title (GimpDockWindow *dock_window);
|
|
|
|
static gboolean gimp_dock_window_update_title_idle (GimpDockWindow *dock_window);
|
2009-09-26 21:24:05 +08:00
|
|
|
static void gimp_dock_window_dock_book_removed (GimpDockWindow *dock_window,
|
|
|
|
GimpDockbook *dockbook,
|
|
|
|
GimpDock *dock);
|
2009-09-11 03:34:49 +08:00
|
|
|
|
2009-09-10 00:15:34 +08:00
|
|
|
|
|
|
|
G_DEFINE_TYPE (GimpDockWindow, gimp_dock_window, GIMP_TYPE_WINDOW)
|
|
|
|
|
|
|
|
#define parent_class gimp_dock_window_parent_class
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dock_window_class_init (GimpDockWindowClass *klass)
|
|
|
|
{
|
2009-09-13 17:23:02 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
2009-09-11 03:34:49 +08:00
|
|
|
|
2009-09-11 04:03:04 +08:00
|
|
|
object_class->constructor = gimp_dock_window_constructor;
|
2009-09-11 03:34:49 +08:00
|
|
|
object_class->dispose = gimp_dock_window_dispose;
|
|
|
|
object_class->set_property = gimp_dock_window_set_property;
|
|
|
|
object_class->get_property = gimp_dock_window_get_property;
|
|
|
|
|
2009-09-13 17:23:02 +08:00
|
|
|
widget_class->style_set = gimp_dock_window_style_set;
|
2009-09-13 18:04:50 +08:00
|
|
|
widget_class->delete_event = gimp_dock_window_delete_event;
|
2009-09-13 17:23:02 +08:00
|
|
|
|
2009-09-11 03:34:49 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_CONTEXT,
|
|
|
|
g_param_spec_object ("gimp-context", NULL, NULL,
|
|
|
|
GIMP_TYPE_CONTEXT,
|
|
|
|
GIMP_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
2009-09-13 15:49:56 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_DIALOG_FACTORY,
|
|
|
|
g_param_spec_object ("gimp-dialog-factory",
|
|
|
|
NULL, NULL,
|
|
|
|
GIMP_TYPE_DIALOG_FACTORY,
|
|
|
|
GIMP_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
2009-09-13 15:22:59 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_UI_MANAGER_NAME,
|
|
|
|
g_param_spec_string ("ui-manager-name",
|
|
|
|
NULL, NULL,
|
|
|
|
NULL,
|
|
|
|
GIMP_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
2009-09-13 17:23:02 +08:00
|
|
|
gtk_widget_class_install_style_property (widget_class,
|
|
|
|
g_param_spec_int ("default-height",
|
|
|
|
NULL, NULL,
|
|
|
|
-1, G_MAXINT,
|
|
|
|
DEFAULT_DOCK_HEIGHT,
|
|
|
|
GIMP_PARAM_READABLE));
|
|
|
|
gtk_widget_class_install_style_property (widget_class,
|
|
|
|
g_param_spec_double ("font-scale",
|
|
|
|
NULL, NULL,
|
|
|
|
0.0,
|
|
|
|
G_MAXDOUBLE,
|
|
|
|
DEFAULT_DOCK_FONT_SCALE,
|
|
|
|
GIMP_PARAM_READABLE));
|
|
|
|
|
2009-09-10 00:15:34 +08:00
|
|
|
g_type_class_add_private (klass, sizeof (GimpDockWindowPrivate));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dock_window_init (GimpDockWindow *dock_window)
|
|
|
|
{
|
2009-09-13 17:23:02 +08:00
|
|
|
static gint dock_ID = 1;
|
|
|
|
gchar *name;
|
|
|
|
|
|
|
|
/* Initialize members */
|
2009-09-10 00:15:34 +08:00
|
|
|
dock_window->p = G_TYPE_INSTANCE_GET_PRIVATE (dock_window,
|
|
|
|
GIMP_TYPE_DOCK_WINDOW,
|
|
|
|
GimpDockWindowPrivate);
|
2009-09-13 15:22:59 +08:00
|
|
|
dock_window->p->context = NULL;
|
2009-09-13 16:14:26 +08:00
|
|
|
dock_window->p->dialog_factory = NULL;
|
2009-09-13 15:22:59 +08:00
|
|
|
dock_window->p->ui_manager_name = NULL;
|
|
|
|
dock_window->p->ui_manager = NULL;
|
|
|
|
dock_window->p->image_flush_handler_id = 0;
|
2009-09-13 17:23:02 +08:00
|
|
|
dock_window->p->ID = dock_ID++;
|
2009-09-13 19:14:18 +08:00
|
|
|
dock_window->p->update_title_idle_id = 0;
|
2009-09-11 04:13:21 +08:00
|
|
|
|
2009-09-13 17:23:02 +08:00
|
|
|
/* Some common initialization for all dock windows */
|
2009-09-11 04:13:21 +08:00
|
|
|
gtk_window_set_resizable (GTK_WINDOW (dock_window), TRUE);
|
|
|
|
gtk_window_set_focus_on_map (GTK_WINDOW (dock_window), FALSE);
|
2009-09-13 17:23:02 +08:00
|
|
|
|
|
|
|
/* Initialize theming and style-setting stuff */
|
|
|
|
name = g_strdup_printf ("gimp-dock-%d", dock_window->p->ID);
|
|
|
|
gtk_widget_set_name (GTK_WIDGET (dock_window), name);
|
|
|
|
g_free (name);
|
2009-09-11 03:34:49 +08:00
|
|
|
}
|
|
|
|
|
2009-09-11 04:03:04 +08:00
|
|
|
static GObject *
|
|
|
|
gimp_dock_window_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params)
|
|
|
|
{
|
|
|
|
GObject *object;
|
|
|
|
GimpDockWindow *dock_window;
|
|
|
|
GimpGuiConfig *config;
|
2009-09-13 15:22:59 +08:00
|
|
|
GtkAccelGroup *accel_group;
|
2009-09-11 04:03:04 +08:00
|
|
|
|
2009-09-13 15:22:59 +08:00
|
|
|
/* Init */
|
2009-09-11 04:03:04 +08:00
|
|
|
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
|
|
|
dock_window = GIMP_DOCK_WINDOW (object);
|
|
|
|
config = GIMP_GUI_CONFIG (dock_window->p->context->gimp->config);
|
|
|
|
|
2009-09-13 15:22:59 +08:00
|
|
|
/* Setup hints */
|
2009-09-11 04:03:04 +08:00
|
|
|
gimp_window_set_hint (GTK_WINDOW (dock_window), config->dock_window_hint);
|
|
|
|
|
2009-09-13 15:22:59 +08:00
|
|
|
/* Make image window related keyboard shortcuts work also when a
|
|
|
|
* dock window is the focused window
|
|
|
|
*/
|
|
|
|
dock_window->p->ui_manager =
|
2009-09-13 15:49:56 +08:00
|
|
|
gimp_menu_factory_manager_new (dock_window->p->dialog_factory->menu_factory,
|
2009-09-13 15:22:59 +08:00
|
|
|
dock_window->p->ui_manager_name,
|
|
|
|
dock_window,
|
|
|
|
config->tearoff_menus);
|
|
|
|
accel_group =
|
|
|
|
gtk_ui_manager_get_accel_group (GTK_UI_MANAGER (dock_window->p->ui_manager));
|
|
|
|
|
|
|
|
gtk_window_add_accel_group (GTK_WINDOW (dock_window), accel_group);
|
|
|
|
|
|
|
|
g_signal_connect_object (dock_window->p->context, "display-changed",
|
|
|
|
G_CALLBACK (gimp_dock_window_display_changed),
|
|
|
|
dock_window,
|
|
|
|
G_CONNECT_SWAPPED);
|
|
|
|
g_signal_connect_object (dock_window->p->context, "image-changed",
|
|
|
|
G_CALLBACK (gimp_dock_window_image_changed),
|
|
|
|
dock_window,
|
|
|
|
G_CONNECT_SWAPPED);
|
|
|
|
|
|
|
|
dock_window->p->image_flush_handler_id =
|
|
|
|
gimp_container_add_handler (dock_window->p->context->gimp->images, "flush",
|
|
|
|
G_CALLBACK (gimp_dock_window_image_flush),
|
|
|
|
dock_window);
|
|
|
|
|
|
|
|
/* Done! */
|
2009-09-11 04:03:04 +08:00
|
|
|
return object;
|
|
|
|
}
|
|
|
|
|
2009-09-11 03:34:49 +08:00
|
|
|
static void
|
|
|
|
gimp_dock_window_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
GimpDockWindow *dock_window = GIMP_DOCK_WINDOW (object);
|
|
|
|
|
2009-09-13 19:14:18 +08:00
|
|
|
if (dock_window->p->update_title_idle_id)
|
|
|
|
{
|
|
|
|
g_source_remove (dock_window->p->update_title_idle_id);
|
|
|
|
dock_window->p->update_title_idle_id = 0;
|
|
|
|
}
|
|
|
|
|
2009-09-13 15:22:59 +08:00
|
|
|
if (dock_window->p->image_flush_handler_id)
|
|
|
|
{
|
|
|
|
gimp_container_remove_handler (dock_window->p->context->gimp->images,
|
|
|
|
dock_window->p->image_flush_handler_id);
|
|
|
|
dock_window->p->image_flush_handler_id = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dock_window->p->ui_manager)
|
|
|
|
{
|
|
|
|
g_object_unref (dock_window->p->ui_manager);
|
|
|
|
dock_window->p->ui_manager = NULL;
|
|
|
|
}
|
|
|
|
|
2009-09-13 15:49:56 +08:00
|
|
|
if (dock_window->p->dialog_factory)
|
|
|
|
{
|
|
|
|
g_object_unref (dock_window->p->dialog_factory);
|
|
|
|
dock_window->p->dialog_factory = NULL;
|
|
|
|
}
|
|
|
|
|
2009-09-11 03:34:49 +08:00
|
|
|
if (dock_window->p->context)
|
|
|
|
{
|
|
|
|
g_object_unref (dock_window->p->context);
|
|
|
|
dock_window->p->context = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dock_window_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpDockWindow *dock_window = GIMP_DOCK_WINDOW (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_CONTEXT:
|
|
|
|
dock_window->p->context = g_value_dup_object (value);
|
|
|
|
break;
|
|
|
|
|
2009-09-13 15:49:56 +08:00
|
|
|
case PROP_DIALOG_FACTORY:
|
|
|
|
dock_window->p->dialog_factory = g_value_dup_object (value);
|
|
|
|
break;
|
|
|
|
|
2009-09-13 15:22:59 +08:00
|
|
|
case PROP_UI_MANAGER_NAME:
|
|
|
|
g_free (dock_window->p->ui_manager_name);
|
|
|
|
dock_window->p->ui_manager_name = g_value_dup_string (value);
|
|
|
|
break;
|
|
|
|
|
2009-09-11 03:34:49 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dock_window_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpDockWindow *dock_window = GIMP_DOCK_WINDOW (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_CONTEXT:
|
|
|
|
g_value_set_object (value, dock_window->p->context);
|
|
|
|
break;
|
|
|
|
|
2009-09-13 15:49:56 +08:00
|
|
|
case PROP_DIALOG_FACTORY:
|
|
|
|
g_value_set_object (value, dock_window->p->dialog_factory);
|
|
|
|
break;
|
|
|
|
|
2009-09-13 15:22:59 +08:00
|
|
|
case PROP_UI_MANAGER_NAME:
|
|
|
|
g_value_set_string (value, dock_window->p->ui_manager_name);
|
|
|
|
break;
|
|
|
|
|
2009-09-11 03:34:49 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
2009-09-10 00:15:34 +08:00
|
|
|
}
|
2009-09-13 15:22:59 +08:00
|
|
|
|
2009-09-13 17:23:02 +08:00
|
|
|
static void
|
|
|
|
gimp_dock_window_style_set (GtkWidget *widget,
|
|
|
|
GtkStyle *prev_style)
|
|
|
|
{
|
|
|
|
GimpDockWindow *dock_window = GIMP_DOCK_WINDOW (widget);
|
|
|
|
gint default_height;
|
|
|
|
gdouble font_scale;
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
|
|
|
|
|
|
|
|
gtk_widget_style_get (widget,
|
|
|
|
"default-height", &default_height,
|
|
|
|
"font-scale", &font_scale,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gtk_window_set_default_size (GTK_WINDOW (widget), -1, default_height);
|
|
|
|
|
|
|
|
if (font_scale != 1.0)
|
|
|
|
{
|
|
|
|
PangoContext *context;
|
|
|
|
PangoFontDescription *font_desc;
|
|
|
|
gint font_size;
|
|
|
|
gchar *font_str;
|
|
|
|
gchar *rc_string;
|
|
|
|
|
|
|
|
context = gtk_widget_get_pango_context (widget);
|
|
|
|
font_desc = pango_context_get_font_description (context);
|
|
|
|
font_desc = pango_font_description_copy (font_desc);
|
|
|
|
|
|
|
|
font_size = pango_font_description_get_size (font_desc);
|
|
|
|
font_size = font_scale * font_size;
|
|
|
|
pango_font_description_set_size (font_desc, font_size);
|
|
|
|
|
|
|
|
font_str = pango_font_description_to_string (font_desc);
|
|
|
|
pango_font_description_free (font_desc);
|
|
|
|
|
|
|
|
rc_string =
|
|
|
|
g_strdup_printf ("style \"gimp-dock-style\""
|
|
|
|
"{"
|
|
|
|
" font_name = \"%s\""
|
|
|
|
"}"
|
|
|
|
"widget \"gimp-dock-%d.*\" style \"gimp-dock-style\"",
|
|
|
|
font_str,
|
|
|
|
dock_window->p->ID);
|
|
|
|
g_free (font_str);
|
|
|
|
|
|
|
|
gtk_rc_parse_string (rc_string);
|
|
|
|
g_free (rc_string);
|
|
|
|
|
|
|
|
if (gtk_bin_get_child (GTK_BIN (widget)))
|
|
|
|
gtk_widget_reset_rc_styles (gtk_bin_get_child (GTK_BIN (widget)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-13 18:04:50 +08:00
|
|
|
/**
|
|
|
|
* gimp_dock_window_delete_event:
|
|
|
|
* @widget:
|
|
|
|
* @event:
|
|
|
|
*
|
|
|
|
* Makes sure that when dock windows are closed they are added to the
|
|
|
|
* list of recently closed docks so that they are easy to bring back.
|
|
|
|
**/
|
|
|
|
static gboolean
|
|
|
|
gimp_dock_window_delete_event (GtkWidget *widget,
|
|
|
|
GdkEventAny *event)
|
|
|
|
{
|
|
|
|
GimpDockWindow *dock_window = GIMP_DOCK_WINDOW (widget);
|
|
|
|
GimpDock *dock = gimp_dock_window_get_dock (dock_window);
|
|
|
|
GimpSessionInfo *info = NULL;
|
|
|
|
|
|
|
|
/* Don't add docks with just a singe dockable to the list of
|
|
|
|
* recently closed dock since those can be brought back through the
|
|
|
|
* normal Windows->Dockable Dialogs menu
|
|
|
|
*/
|
|
|
|
if (gimp_dock_get_n_dockables (dock) < 2)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
info = gimp_session_info_new ();
|
|
|
|
|
|
|
|
gimp_object_set_name (GIMP_OBJECT (info),
|
|
|
|
gtk_window_get_title (GTK_WINDOW (dock_window)));
|
|
|
|
|
2009-09-26 22:21:10 +08:00
|
|
|
gimp_session_info_set_widget (info, GTK_WIDGET (dock_window));
|
2009-09-13 18:04:50 +08:00
|
|
|
gimp_session_info_get_info (info);
|
2009-09-20 20:51:03 +08:00
|
|
|
gimp_session_info_set_widget (info, NULL);
|
2009-09-13 18:04:50 +08:00
|
|
|
|
|
|
|
gimp_container_add (global_recent_docks, GIMP_OBJECT (info));
|
|
|
|
g_object_unref (info);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-09-13 15:22:59 +08:00
|
|
|
static void
|
|
|
|
gimp_dock_window_display_changed (GimpDockWindow *dock_window,
|
|
|
|
GimpObject *display,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
gimp_ui_manager_update (dock_window->p->ui_manager,
|
|
|
|
display);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dock_window_image_changed (GimpDockWindow *dock_window,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
gimp_ui_manager_update (dock_window->p->ui_manager,
|
|
|
|
gimp_context_get_display (context));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dock_window_image_flush (GimpImage *image,
|
|
|
|
gboolean invalidate_preview,
|
|
|
|
GimpDockWindow *dock_window)
|
|
|
|
{
|
|
|
|
if (image == gimp_context_get_image (dock_window->p->context))
|
|
|
|
{
|
|
|
|
GimpObject *display = gimp_context_get_display (dock_window->p->context);
|
|
|
|
|
|
|
|
if (display)
|
|
|
|
gimp_ui_manager_update (dock_window->p->ui_manager, display);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-13 19:14:18 +08:00
|
|
|
static void
|
|
|
|
gimp_dock_window_update_title (GimpDockWindow *dock_window)
|
|
|
|
{
|
|
|
|
if (dock_window->p->update_title_idle_id)
|
|
|
|
g_source_remove (dock_window->p->update_title_idle_id);
|
|
|
|
|
|
|
|
dock_window->p->update_title_idle_id =
|
|
|
|
g_idle_add ((GSourceFunc) gimp_dock_window_update_title_idle,
|
|
|
|
dock_window);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_dock_window_update_title_idle (GimpDockWindow *dock_window)
|
|
|
|
{
|
2009-09-26 22:21:10 +08:00
|
|
|
GimpDock *dock = NULL;
|
|
|
|
gchar *title = NULL;
|
|
|
|
|
|
|
|
dock = gimp_dock_window_get_dock (dock_window);
|
|
|
|
|
|
|
|
if (! dock)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
title = gimp_dock_get_title (dock);
|
2009-09-13 19:14:18 +08:00
|
|
|
|
|
|
|
if (title)
|
|
|
|
gtk_window_set_title (GTK_WINDOW (dock_window), title);
|
|
|
|
|
|
|
|
g_free (title);
|
|
|
|
|
|
|
|
dock_window->p->update_title_idle_id = 0;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-09-26 21:24:05 +08:00
|
|
|
static void
|
|
|
|
gimp_dock_window_dock_book_removed (GimpDockWindow *dock_window,
|
|
|
|
GimpDockbook *dockbook,
|
|
|
|
GimpDock *dock)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DOCK (dock));
|
|
|
|
|
|
|
|
if (gimp_dock_get_dockbooks (dock) == NULL)
|
|
|
|
gtk_widget_destroy (GTK_WIDGET (dock_window));
|
|
|
|
}
|
|
|
|
|
2009-09-26 21:38:08 +08:00
|
|
|
void
|
|
|
|
gimp_dock_window_set_dock (GimpDockWindow *dock_window,
|
|
|
|
GimpDock *dock)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DOCK_WINDOW (dock_window));
|
|
|
|
g_return_if_fail (GIMP_IS_DOCK (dock));
|
|
|
|
|
2009-09-26 22:21:10 +08:00
|
|
|
/* FIXME: Handle more than one call to this function */
|
|
|
|
gtk_container_add (GTK_CONTAINER (dock_window), GTK_WIDGET (dock));
|
|
|
|
|
2009-09-26 21:38:08 +08:00
|
|
|
/* Update window title now and when docks title is invalidated */
|
|
|
|
gimp_dock_window_update_title (dock_window);
|
|
|
|
g_signal_connect_object (dock, "title-invalidated",
|
|
|
|
G_CALLBACK (gimp_dock_window_update_title),
|
|
|
|
dock_window,
|
|
|
|
G_CONNECT_SWAPPED);
|
|
|
|
|
|
|
|
/* Some docks like the toolbox dock needs to maintain special hints
|
|
|
|
* on its container GtkWindow, allow those to do so
|
|
|
|
*/
|
|
|
|
gimp_dock_set_host_geometry_hints (dock, GTK_WINDOW (dock_window));
|
|
|
|
g_signal_connect_object (dock, "geometry-invalidated",
|
|
|
|
G_CALLBACK (gimp_dock_set_host_geometry_hints),
|
|
|
|
dock_window, 0);
|
|
|
|
|
|
|
|
/* Destroy the dock window when the last book is removed */
|
|
|
|
g_signal_connect_object (dock, "book-removed",
|
|
|
|
G_CALLBACK (gimp_dock_window_dock_book_removed),
|
|
|
|
dock_window,
|
|
|
|
G_CONNECT_SWAPPED);
|
|
|
|
}
|
|
|
|
|
2009-09-13 17:23:02 +08:00
|
|
|
gint
|
|
|
|
gimp_dock_window_get_id (GimpDockWindow *dock_window)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DOCK_WINDOW (dock_window), 0);
|
|
|
|
|
|
|
|
return dock_window->p->ID;
|
|
|
|
}
|
|
|
|
|
2009-09-13 15:22:59 +08:00
|
|
|
GimpUIManager *
|
|
|
|
gimp_dock_window_get_ui_manager (GimpDockWindow *dock_window)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DOCK_WINDOW (dock_window), NULL);
|
|
|
|
|
|
|
|
return dock_window->p->ui_manager;
|
|
|
|
}
|
2009-09-15 13:58:14 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_dock_window_from_dock:
|
|
|
|
* @dock:
|
|
|
|
*
|
|
|
|
* For convenience.
|
|
|
|
*
|
|
|
|
* Returns: If the toplevel widget for the dock is a GimpDockWindow,
|
|
|
|
* return that. Otherwise return %NULL.
|
|
|
|
**/
|
|
|
|
GimpDockWindow *
|
|
|
|
gimp_dock_window_from_dock (GimpDock *dock)
|
|
|
|
{
|
|
|
|
GtkWidget *toplevel = NULL;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_DOCK (dock), NULL);
|
|
|
|
|
|
|
|
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (dock));
|
|
|
|
|
|
|
|
if (GIMP_IS_DOCK_WINDOW (toplevel))
|
|
|
|
return GIMP_DOCK_WINDOW (toplevel);
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
2009-09-21 02:09:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_dock_window_get_dock:
|
|
|
|
* @dock_window:
|
|
|
|
*
|
|
|
|
* Get the #GimpDock within the #GimpDockWindow.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
**/
|
|
|
|
GimpDock *
|
|
|
|
gimp_dock_window_get_dock (GimpDockWindow *dock_window)
|
|
|
|
{
|
2009-09-26 22:21:10 +08:00
|
|
|
return GIMP_DOCK (gtk_bin_get_child (GTK_BIN (dock_window)));
|
2009-09-21 02:09:59 +08:00
|
|
|
}
|