2001-04-07 22:44:12 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* gimpdockable.c
|
2003-10-11 05:24:12 +08:00
|
|
|
* Copyright (C) 2001-2003 Michael Natterer <mitch@gimp.org>
|
2001-04-07 22:44:12 +08:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2003-08-26 09:30:05 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-05-08 11:48:54 +08:00
|
|
|
#include "widgets-types.h"
|
2001-04-07 22:44:12 +08:00
|
|
|
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
|
2003-10-07 20:24:01 +08:00
|
|
|
#include "gimpdialogfactory.h"
|
2003-10-06 01:26:21 +08:00
|
|
|
#include "gimpdnd.h"
|
2003-10-08 23:44:35 +08:00
|
|
|
#include "gimpdock.h"
|
2001-04-07 22:44:12 +08:00
|
|
|
#include "gimpdockable.h"
|
2001-04-16 00:16:13 +08:00
|
|
|
#include "gimpdockbook.h"
|
2003-10-11 05:24:12 +08:00
|
|
|
#include "gimpdocked.h"
|
2004-08-18 17:53:38 +08:00
|
|
|
#include "gimphelp-ids.h"
|
2004-04-23 01:14:22 +08:00
|
|
|
#include "gimpuimanager.h"
|
2003-10-01 02:50:55 +08:00
|
|
|
#include "gimpwidgets-utils.h"
|
2001-04-07 22:44:12 +08:00
|
|
|
|
2003-10-19 06:12:32 +08:00
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
2001-04-07 22:44:12 +08:00
|
|
|
|
2005-12-29 12:28:41 +08:00
|
|
|
#define DRAG_OFFSET (-4)
|
|
|
|
|
|
|
|
|
2003-10-11 05:24:12 +08:00
|
|
|
static void gimp_dockable_destroy (GtkObject *object);
|
|
|
|
static void gimp_dockable_size_request (GtkWidget *widget,
|
|
|
|
GtkRequisition *requisition);
|
|
|
|
static void gimp_dockable_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation);
|
|
|
|
static void gimp_dockable_realize (GtkWidget *widget);
|
|
|
|
static void gimp_dockable_unrealize (GtkWidget *widget);
|
|
|
|
static void gimp_dockable_map (GtkWidget *widget);
|
|
|
|
static void gimp_dockable_unmap (GtkWidget *widget);
|
|
|
|
|
|
|
|
static gboolean gimp_dockable_drag_drop (GtkWidget *widget,
|
|
|
|
GdkDragContext *context,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
guint time);
|
|
|
|
static void gimp_dockable_style_set (GtkWidget *widget,
|
|
|
|
GtkStyle *prev_style);
|
|
|
|
static gboolean gimp_dockable_expose_event (GtkWidget *widget,
|
|
|
|
GdkEventExpose *event);
|
2005-12-29 11:12:26 +08:00
|
|
|
static gboolean gimp_dockable_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *event);
|
2005-12-29 12:28:41 +08:00
|
|
|
static gboolean gimp_dockable_button_release (GtkWidget *widget);
|
2003-10-11 05:24:12 +08:00
|
|
|
static gboolean gimp_dockable_popup_menu (GtkWidget *widget);
|
|
|
|
|
2003-10-21 22:49:12 +08:00
|
|
|
static void gimp_dockable_add (GtkContainer *container,
|
|
|
|
GtkWidget *widget);
|
|
|
|
static void gimp_dockable_remove (GtkContainer *container,
|
|
|
|
GtkWidget *widget);
|
2003-10-11 05:24:12 +08:00
|
|
|
static GType gimp_dockable_child_type (GtkContainer *container);
|
|
|
|
static void gimp_dockable_forall (GtkContainer *container,
|
|
|
|
gboolean include_internals,
|
|
|
|
GtkCallback callback,
|
|
|
|
gpointer callback_data);
|
|
|
|
|
|
|
|
static void gimp_dockable_get_title_area (GimpDockable *dockable,
|
|
|
|
GdkRectangle *area);
|
2005-12-29 07:43:53 +08:00
|
|
|
static void gimp_dockable_clear_title_area (GimpDockable *dockable);
|
2003-10-11 05:24:12 +08:00
|
|
|
|
|
|
|
static gboolean gimp_dockable_menu_button_press (GtkWidget *button,
|
|
|
|
GdkEventButton *bevent,
|
|
|
|
GimpDockable *dockable);
|
|
|
|
static gboolean gimp_dockable_show_menu (GimpDockable *dockable);
|
2005-01-18 23:18:35 +08:00
|
|
|
static gboolean gimp_dockable_blink_timeout (GimpDockable *dockable);
|
2001-04-07 22:44:12 +08:00
|
|
|
|
2003-10-21 22:49:12 +08:00
|
|
|
static void gimp_dockable_title_changed (GimpDocked *docked,
|
|
|
|
GimpDockable *dockable);
|
|
|
|
|
2001-08-04 03:43:19 +08:00
|
|
|
|
2005-12-20 06:37:49 +08:00
|
|
|
G_DEFINE_TYPE (GimpDockable, gimp_dockable, GTK_TYPE_BIN);
|
2001-04-07 22:44:12 +08:00
|
|
|
|
2005-12-20 06:37:49 +08:00
|
|
|
#define parent_class gimp_dockable_parent_class
|
2003-10-06 01:26:21 +08:00
|
|
|
|
2005-12-20 06:37:49 +08:00
|
|
|
static GtkTargetEntry dialog_target_table[] = { GIMP_TARGET_DIALOG };
|
2001-04-07 22:44:12 +08:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dockable_class_init (GimpDockableClass *klass)
|
|
|
|
{
|
2004-09-01 05:29:30 +08:00
|
|
|
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
|
2001-04-07 22:44:12 +08:00
|
|
|
|
2003-04-12 00:51:49 +08:00
|
|
|
object_class->destroy = gimp_dockable_destroy;
|
2001-08-04 03:43:19 +08:00
|
|
|
|
2003-04-12 00:51:49 +08:00
|
|
|
widget_class->size_request = gimp_dockable_size_request;
|
|
|
|
widget_class->size_allocate = gimp_dockable_size_allocate;
|
2003-10-06 01:26:21 +08:00
|
|
|
widget_class->realize = gimp_dockable_realize;
|
|
|
|
widget_class->unrealize = gimp_dockable_unrealize;
|
|
|
|
widget_class->map = gimp_dockable_map;
|
|
|
|
widget_class->unmap = gimp_dockable_unmap;
|
2003-04-12 00:51:49 +08:00
|
|
|
widget_class->style_set = gimp_dockable_style_set;
|
2003-10-06 01:26:21 +08:00
|
|
|
widget_class->drag_drop = gimp_dockable_drag_drop;
|
2003-09-22 03:35:54 +08:00
|
|
|
widget_class->expose_event = gimp_dockable_expose_event;
|
2003-09-24 00:17:25 +08:00
|
|
|
widget_class->popup_menu = gimp_dockable_popup_menu;
|
2003-09-22 03:35:54 +08:00
|
|
|
|
2003-10-21 22:49:12 +08:00
|
|
|
container_class->add = gimp_dockable_add;
|
|
|
|
container_class->remove = gimp_dockable_remove;
|
2003-10-11 05:24:12 +08:00
|
|
|
container_class->child_type = gimp_dockable_child_type;
|
2003-09-22 03:35:54 +08:00
|
|
|
container_class->forall = gimp_dockable_forall;
|
2001-08-04 03:43:19 +08:00
|
|
|
|
|
|
|
gtk_widget_class_install_style_property (widget_class,
|
2005-05-28 00:51:39 +08:00
|
|
|
g_param_spec_int ("content-border",
|
2001-08-04 03:43:19 +08:00
|
|
|
NULL, NULL,
|
|
|
|
0,
|
|
|
|
G_MAXINT,
|
|
|
|
0,
|
|
|
|
G_PARAM_READABLE));
|
2001-04-07 22:44:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dockable_init (GimpDockable *dockable)
|
|
|
|
{
|
2003-09-22 03:35:54 +08:00
|
|
|
GtkWidget *image;
|
|
|
|
|
2003-10-11 05:24:12 +08:00
|
|
|
dockable->name = NULL;
|
|
|
|
dockable->blurb = NULL;
|
|
|
|
dockable->stock_id = NULL;
|
|
|
|
dockable->help_id = NULL;
|
|
|
|
dockable->tab_style = GIMP_TAB_STYLE_PREVIEW;
|
|
|
|
dockable->dockbook = NULL;
|
|
|
|
dockable->context = NULL;
|
2003-09-22 03:35:54 +08:00
|
|
|
|
2003-10-11 05:24:12 +08:00
|
|
|
dockable->title_layout = NULL;
|
|
|
|
dockable->title_window = NULL;
|
2003-09-24 02:11:09 +08:00
|
|
|
|
2005-12-29 12:28:41 +08:00
|
|
|
dockable->button_x = DRAG_OFFSET;
|
|
|
|
dockable->button_y = DRAG_OFFSET;
|
2005-12-29 11:12:26 +08:00
|
|
|
|
2003-09-22 03:35:54 +08:00
|
|
|
gtk_widget_push_composite_child ();
|
|
|
|
dockable->menu_button = gtk_button_new ();
|
|
|
|
gtk_widget_pop_composite_child ();
|
|
|
|
|
|
|
|
GTK_WIDGET_UNSET_FLAGS (dockable->menu_button, GTK_CAN_FOCUS);
|
|
|
|
gtk_widget_set_parent (dockable->menu_button, GTK_WIDGET (dockable));
|
|
|
|
gtk_button_set_relief (GTK_BUTTON (dockable->menu_button), GTK_RELIEF_NONE);
|
2003-09-24 00:17:25 +08:00
|
|
|
gtk_widget_show (dockable->menu_button);
|
2003-09-22 03:35:54 +08:00
|
|
|
|
2003-09-23 20:30:53 +08:00
|
|
|
image = gtk_image_new_from_stock (GIMP_STOCK_MENU_LEFT, GTK_ICON_SIZE_MENU);
|
2003-09-22 03:35:54 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (dockable->menu_button), image);
|
|
|
|
gtk_widget_show (image);
|
|
|
|
|
2005-02-19 10:13:33 +08:00
|
|
|
gimp_help_set_help_data (dockable->menu_button, _("Configure this tab"),
|
|
|
|
GIMP_HELP_DOCK_TAB_MENU);
|
|
|
|
|
2005-05-28 00:51:39 +08:00
|
|
|
g_signal_connect (dockable->menu_button, "button-press-event",
|
2003-09-22 03:35:54 +08:00
|
|
|
G_CALLBACK (gimp_dockable_menu_button_press),
|
|
|
|
dockable);
|
|
|
|
|
2003-10-06 01:26:21 +08:00
|
|
|
gtk_drag_dest_set (GTK_WIDGET (dockable),
|
|
|
|
GTK_DEST_DEFAULT_ALL,
|
|
|
|
dialog_target_table, G_N_ELEMENTS (dialog_target_table),
|
|
|
|
GDK_ACTION_MOVE);
|
2003-12-12 03:34:37 +08:00
|
|
|
|
|
|
|
/* Filter out all button_press events not coming from the event window
|
|
|
|
over the title area. This keeps events that originate from widgets
|
|
|
|
in the dockable to start a drag.
|
|
|
|
*/
|
2005-05-28 00:51:39 +08:00
|
|
|
g_signal_connect (dockable, "button-press-event",
|
2005-12-29 11:12:26 +08:00
|
|
|
G_CALLBACK (gimp_dockable_button_press),
|
2003-12-12 03:34:37 +08:00
|
|
|
NULL);
|
2005-12-29 12:28:41 +08:00
|
|
|
g_signal_connect (dockable, "button-release-event",
|
|
|
|
G_CALLBACK (gimp_dockable_button_release),
|
|
|
|
NULL);
|
2001-04-07 22:44:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dockable_destroy (GtkObject *object)
|
|
|
|
{
|
2003-09-22 03:35:54 +08:00
|
|
|
GimpDockable *dockable = GIMP_DOCKABLE (object);
|
2001-04-07 22:44:12 +08:00
|
|
|
|
2005-12-29 07:43:53 +08:00
|
|
|
gimp_dockable_blink_cancel (dockable);
|
|
|
|
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
if (dockable->context)
|
|
|
|
gimp_dockable_set_context (dockable, NULL);
|
|
|
|
|
2003-10-01 02:50:55 +08:00
|
|
|
if (dockable->blurb && dockable->blurb != dockable->name)
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
{
|
2003-10-01 02:50:55 +08:00
|
|
|
g_free (dockable->blurb);
|
|
|
|
dockable->blurb = NULL;
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
}
|
|
|
|
|
2003-10-01 02:50:55 +08:00
|
|
|
if (dockable->name)
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
{
|
2003-10-01 02:50:55 +08:00
|
|
|
g_free (dockable->name);
|
|
|
|
dockable->name = NULL;
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
}
|
2001-04-07 22:44:12 +08:00
|
|
|
|
2002-05-10 22:50:27 +08:00
|
|
|
if (dockable->stock_id)
|
|
|
|
{
|
|
|
|
g_free (dockable->stock_id);
|
|
|
|
dockable->stock_id = NULL;
|
|
|
|
}
|
|
|
|
|
2003-08-25 22:18:33 +08:00
|
|
|
if (dockable->help_id)
|
|
|
|
{
|
|
|
|
g_free (dockable->help_id);
|
|
|
|
dockable->help_id = NULL;
|
|
|
|
}
|
|
|
|
|
2003-09-24 02:11:09 +08:00
|
|
|
if (dockable->title_layout)
|
|
|
|
{
|
|
|
|
g_object_unref (dockable->title_layout);
|
|
|
|
dockable->title_layout = NULL;
|
|
|
|
}
|
|
|
|
|
2003-09-22 03:35:54 +08:00
|
|
|
if (dockable->menu_button)
|
|
|
|
{
|
|
|
|
gtk_widget_unparent (dockable->menu_button);
|
|
|
|
dockable->menu_button = NULL;
|
|
|
|
}
|
|
|
|
|
2003-04-09 03:54:22 +08:00
|
|
|
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
2001-04-07 22:44:12 +08:00
|
|
|
}
|
|
|
|
|
2003-04-12 00:51:49 +08:00
|
|
|
static void
|
|
|
|
gimp_dockable_size_request (GtkWidget *widget,
|
|
|
|
GtkRequisition *requisition)
|
|
|
|
{
|
2004-09-01 05:29:30 +08:00
|
|
|
GtkContainer *container = GTK_CONTAINER (widget);
|
|
|
|
GtkBin *bin = GTK_BIN (widget);
|
|
|
|
GimpDockable *dockable = GIMP_DOCKABLE (widget);
|
|
|
|
GtkRequisition child_requisition;
|
2003-04-12 00:51:49 +08:00
|
|
|
|
2003-09-22 03:35:54 +08:00
|
|
|
requisition->width = container->border_width * 2;
|
|
|
|
requisition->height = container->border_width * 2;
|
|
|
|
|
2005-04-22 07:30:38 +08:00
|
|
|
if (dockable->menu_button && GTK_WIDGET_VISIBLE (dockable->menu_button))
|
2003-04-12 00:51:49 +08:00
|
|
|
{
|
2005-04-22 07:30:38 +08:00
|
|
|
gtk_widget_size_request (dockable->menu_button, &child_requisition);
|
2003-09-22 03:35:54 +08:00
|
|
|
|
|
|
|
if (! bin->child)
|
|
|
|
requisition->width += child_requisition.width;
|
2003-08-26 09:30:05 +08:00
|
|
|
|
2003-09-22 03:35:54 +08:00
|
|
|
requisition->height += child_requisition.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
|
|
|
|
{
|
2003-04-12 00:51:49 +08:00
|
|
|
gtk_widget_size_request (bin->child, &child_requisition);
|
|
|
|
|
|
|
|
requisition->width += child_requisition.width;
|
|
|
|
requisition->height += child_requisition.height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dockable_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation)
|
|
|
|
{
|
2004-09-01 05:29:30 +08:00
|
|
|
GtkContainer *container = GTK_CONTAINER (widget);
|
|
|
|
GtkBin *bin = GTK_BIN (widget);
|
|
|
|
GimpDockable *dockable = GIMP_DOCKABLE (widget);
|
|
|
|
|
2003-09-22 03:35:54 +08:00
|
|
|
GtkRequisition button_requisition = { 0, };
|
|
|
|
GtkAllocation child_allocation;
|
|
|
|
|
2003-04-12 00:51:49 +08:00
|
|
|
widget->allocation = *allocation;
|
|
|
|
|
2005-04-22 07:30:38 +08:00
|
|
|
if (dockable->menu_button && GTK_WIDGET_VISIBLE (dockable->menu_button))
|
2003-04-12 00:51:49 +08:00
|
|
|
{
|
2005-04-22 07:30:38 +08:00
|
|
|
gtk_widget_size_request (dockable->menu_button, &button_requisition);
|
2003-09-22 03:35:54 +08:00
|
|
|
|
2003-09-24 02:11:09 +08:00
|
|
|
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
|
|
|
|
child_allocation.x = (allocation->x +
|
2003-09-22 03:35:54 +08:00
|
|
|
allocation->width -
|
|
|
|
container->border_width -
|
|
|
|
button_requisition.width);
|
2003-09-24 02:11:09 +08:00
|
|
|
else
|
|
|
|
child_allocation.x = (allocation->x + container->border_width +
|
|
|
|
button_requisition.width);
|
|
|
|
|
2003-09-22 03:35:54 +08:00
|
|
|
child_allocation.y = allocation->y + container->border_width;
|
|
|
|
child_allocation.width = button_requisition.width;
|
|
|
|
child_allocation.height = button_requisition.height;
|
|
|
|
|
|
|
|
gtk_widget_size_allocate (dockable->menu_button, &child_allocation);
|
|
|
|
}
|
2003-04-12 00:51:49 +08:00
|
|
|
|
2005-04-22 07:30:38 +08:00
|
|
|
if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
|
2003-09-22 03:35:54 +08:00
|
|
|
{
|
|
|
|
child_allocation.x = allocation->x + container->border_width;
|
|
|
|
child_allocation.y = allocation->y + container->border_width;
|
2003-04-12 00:51:49 +08:00
|
|
|
child_allocation.width = MAX (allocation->width -
|
2003-09-22 03:35:54 +08:00
|
|
|
container->border_width * 2,
|
2003-04-12 00:51:49 +08:00
|
|
|
0);
|
|
|
|
child_allocation.height = MAX (allocation->height -
|
2003-09-22 03:35:54 +08:00
|
|
|
container->border_width * 2 -
|
|
|
|
button_requisition.height,
|
2003-04-12 00:51:49 +08:00
|
|
|
0);
|
|
|
|
|
2003-09-22 03:35:54 +08:00
|
|
|
child_allocation.y += button_requisition.height;
|
|
|
|
|
2003-04-12 00:51:49 +08:00
|
|
|
gtk_widget_size_allocate (bin->child, &child_allocation);
|
|
|
|
}
|
2003-10-06 01:26:21 +08:00
|
|
|
|
|
|
|
if (dockable->title_window)
|
|
|
|
{
|
|
|
|
GdkRectangle area;
|
|
|
|
|
|
|
|
gimp_dockable_get_title_area (dockable, &area);
|
|
|
|
|
|
|
|
gdk_window_move_resize (dockable->title_window,
|
|
|
|
area.x, area.y, area.width, area.height);
|
2005-05-25 17:45:06 +08:00
|
|
|
|
|
|
|
if (dockable->title_layout)
|
|
|
|
pango_layout_set_width (dockable->title_layout,
|
|
|
|
PANGO_SCALE * area.width);
|
2003-10-06 01:26:21 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dockable_realize (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GimpDockable *dockable = GIMP_DOCKABLE (widget);
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->realize (widget);
|
|
|
|
|
|
|
|
if (! dockable->title_window)
|
|
|
|
{
|
2003-11-02 08:50:57 +08:00
|
|
|
GdkWindowAttr attributes;
|
|
|
|
GdkRectangle area;
|
|
|
|
GdkCursor *cursor;
|
2003-10-06 01:26:21 +08:00
|
|
|
|
|
|
|
gimp_dockable_get_title_area (dockable, &area);
|
|
|
|
|
|
|
|
attributes.x = area.x;
|
|
|
|
attributes.y = area.y;
|
|
|
|
attributes.width = area.width;
|
|
|
|
attributes.height = area.height;
|
2005-10-24 16:50:14 +08:00
|
|
|
attributes.window_type = GDK_WINDOW_CHILD;
|
2003-10-06 01:26:21 +08:00
|
|
|
attributes.wclass = GDK_INPUT_ONLY;
|
|
|
|
attributes.override_redirect = TRUE;
|
|
|
|
attributes.event_mask = (GDK_BUTTON_PRESS_MASK |
|
|
|
|
GDK_BUTTON_RELEASE_MASK |
|
|
|
|
GDK_BUTTON_MOTION_MASK |
|
|
|
|
gtk_widget_get_events (widget));
|
|
|
|
|
|
|
|
dockable->title_window = gdk_window_new (widget->window,
|
|
|
|
&attributes,
|
|
|
|
(GDK_WA_X |
|
|
|
|
GDK_WA_Y |
|
|
|
|
GDK_WA_NOREDIR));
|
|
|
|
|
|
|
|
gdk_window_set_user_data (dockable->title_window, widget);
|
2003-11-02 08:50:57 +08:00
|
|
|
|
|
|
|
cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
|
|
|
|
GDK_HAND2);
|
|
|
|
gdk_window_set_cursor (dockable->title_window, cursor);
|
|
|
|
gdk_cursor_unref (cursor);
|
2003-10-06 01:26:21 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dockable_unrealize (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GimpDockable *dockable = GIMP_DOCKABLE (widget);
|
|
|
|
|
|
|
|
if (dockable->title_window)
|
|
|
|
{
|
|
|
|
gdk_window_set_user_data (dockable->title_window, NULL);
|
|
|
|
gdk_window_destroy (dockable->title_window);
|
|
|
|
dockable->title_window = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dockable_map (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GimpDockable *dockable = GIMP_DOCKABLE (widget);
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->map (widget);
|
|
|
|
|
|
|
|
if (dockable->title_window)
|
|
|
|
gdk_window_show (dockable->title_window);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dockable_unmap (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GimpDockable *dockable = GIMP_DOCKABLE (widget);
|
|
|
|
|
|
|
|
if (dockable->title_window)
|
|
|
|
gdk_window_hide (dockable->title_window);
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->unmap (widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_dockable_drag_drop (GtkWidget *widget,
|
|
|
|
GdkDragContext *context,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
guint time)
|
|
|
|
{
|
|
|
|
return gimp_dockbook_drop_dockable (GIMP_DOCKABLE (widget)->dockbook,
|
|
|
|
gtk_drag_get_source_widget (context));
|
2003-04-12 00:51:49 +08:00
|
|
|
}
|
|
|
|
|
2001-08-04 03:43:19 +08:00
|
|
|
static void
|
|
|
|
gimp_dockable_style_set (GtkWidget *widget,
|
2004-09-01 05:29:30 +08:00
|
|
|
GtkStyle *prev_style)
|
2001-08-04 03:43:19 +08:00
|
|
|
{
|
2003-09-24 02:11:09 +08:00
|
|
|
GimpDockable *dockable;
|
|
|
|
gint content_border;
|
2001-08-04 03:43:19 +08:00
|
|
|
|
|
|
|
gtk_widget_style_get (widget,
|
2005-05-28 00:51:39 +08:00
|
|
|
"content-border", &content_border,
|
2004-09-01 05:29:30 +08:00
|
|
|
NULL);
|
2001-08-04 03:43:19 +08:00
|
|
|
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (widget), content_border);
|
|
|
|
|
2003-09-24 02:11:09 +08:00
|
|
|
dockable = GIMP_DOCKABLE (widget);
|
|
|
|
|
|
|
|
if (dockable->title_layout)
|
|
|
|
{
|
|
|
|
g_object_unref (dockable->title_layout);
|
|
|
|
dockable->title_layout = NULL;
|
|
|
|
}
|
|
|
|
|
2001-08-04 03:43:19 +08:00
|
|
|
if (GTK_WIDGET_CLASS (parent_class)->style_set)
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
|
|
|
|
}
|
|
|
|
|
2003-09-22 03:35:54 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_dockable_expose_event (GtkWidget *widget,
|
|
|
|
GdkEventExpose *event)
|
|
|
|
{
|
|
|
|
if (GTK_WIDGET_DRAWABLE (widget))
|
|
|
|
{
|
2004-09-01 05:29:30 +08:00
|
|
|
GimpDockable *dockable = GIMP_DOCKABLE (widget);
|
2003-09-22 03:35:54 +08:00
|
|
|
GdkRectangle title_area;
|
|
|
|
GdkRectangle expose_area;
|
|
|
|
|
2005-12-29 10:27:32 +08:00
|
|
|
if (! gtk_notebook_get_show_tabs (GTK_NOTEBOOK (dockable->dockbook)))
|
|
|
|
gtk_paint_extension (widget->style, widget->window,
|
|
|
|
widget->state, GTK_SHADOW_OUT,
|
|
|
|
&event->area, widget, "tab",
|
|
|
|
widget->allocation.x,
|
|
|
|
widget->allocation.y,
|
|
|
|
widget->allocation.width,
|
|
|
|
widget->allocation.height,
|
|
|
|
GTK_POS_BOTTOM);
|
|
|
|
|
2003-10-06 01:26:21 +08:00
|
|
|
gimp_dockable_get_title_area (dockable, &title_area);
|
2003-09-24 02:11:09 +08:00
|
|
|
|
2003-09-22 03:35:54 +08:00
|
|
|
if (gdk_rectangle_intersect (&title_area, &event->area, &expose_area))
|
|
|
|
{
|
2003-09-24 02:11:09 +08:00
|
|
|
gint layout_width;
|
|
|
|
gint layout_height;
|
|
|
|
gint text_x;
|
|
|
|
gint text_y;
|
2003-09-22 03:35:54 +08:00
|
|
|
|
2005-01-18 23:18:35 +08:00
|
|
|
if (dockable->blink_counter & 1)
|
|
|
|
{
|
|
|
|
gtk_paint_box (widget->style, widget->window,
|
|
|
|
GTK_STATE_SELECTED, GTK_SHADOW_NONE,
|
|
|
|
&expose_area, widget, "",
|
|
|
|
title_area.x, title_area.y,
|
|
|
|
title_area.width, title_area.height);
|
|
|
|
}
|
|
|
|
|
2003-10-21 22:49:12 +08:00
|
|
|
if (! dockable->title_layout)
|
2003-09-24 02:11:09 +08:00
|
|
|
{
|
2003-10-21 22:49:12 +08:00
|
|
|
GtkBin *bin = GTK_BIN (dockable);
|
|
|
|
gchar *title = NULL;
|
|
|
|
|
|
|
|
if (bin->child)
|
|
|
|
title = gimp_docked_get_title (GIMP_DOCKED (bin->child));
|
|
|
|
|
2005-12-29 10:27:32 +08:00
|
|
|
dockable->title_layout =
|
|
|
|
gtk_widget_create_pango_layout (widget,
|
|
|
|
title ?
|
|
|
|
title : dockable->blurb);
|
2003-10-21 22:49:12 +08:00
|
|
|
g_free (title);
|
2005-05-25 17:45:06 +08:00
|
|
|
|
|
|
|
pango_layout_set_width (dockable->title_layout,
|
|
|
|
PANGO_SCALE * title_area.width);
|
|
|
|
pango_layout_set_ellipsize (dockable->title_layout,
|
|
|
|
PANGO_ELLIPSIZE_END);
|
2003-09-24 02:11:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
pango_layout_get_pixel_size (dockable->title_layout,
|
|
|
|
&layout_width, &layout_height);
|
2003-09-22 03:35:54 +08:00
|
|
|
|
|
|
|
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
|
|
|
|
{
|
|
|
|
text_x = title_area.x;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
text_x = title_area.x + title_area.width - layout_width;
|
|
|
|
}
|
|
|
|
|
|
|
|
text_y = title_area.y + (title_area.height - layout_height) / 2;
|
|
|
|
|
|
|
|
gtk_paint_layout (widget->style, widget->window,
|
2005-01-19 04:03:11 +08:00
|
|
|
(dockable->blink_counter & 1) ?
|
|
|
|
GTK_STATE_SELECTED : widget->state, TRUE,
|
2003-09-22 03:35:54 +08:00
|
|
|
&expose_area, widget, NULL,
|
2003-09-24 02:11:09 +08:00
|
|
|
text_x, text_y, dockable->title_layout);
|
2003-09-22 03:35:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
|
|
|
|
}
|
|
|
|
|
2003-12-12 03:34:37 +08:00
|
|
|
static gboolean
|
2005-12-29 11:12:26 +08:00
|
|
|
gimp_dockable_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *event)
|
2003-12-12 03:34:37 +08:00
|
|
|
{
|
2005-12-29 11:12:26 +08:00
|
|
|
GimpDockable *dockable = GIMP_DOCKABLE (widget);
|
|
|
|
|
2005-12-29 12:28:41 +08:00
|
|
|
/* stop processing of events not coming from the title event window */
|
|
|
|
if (event->window != dockable->title_window)
|
|
|
|
return TRUE;
|
|
|
|
|
2005-12-29 11:12:26 +08:00
|
|
|
dockable->button_x = event->x;
|
|
|
|
dockable->button_y = event->y;
|
|
|
|
|
2005-12-29 12:28:41 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_dockable_button_release (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GimpDockable *dockable = GIMP_DOCKABLE (widget);
|
|
|
|
|
|
|
|
dockable->button_x = DRAG_OFFSET;
|
|
|
|
dockable->button_y = DRAG_OFFSET;
|
|
|
|
|
|
|
|
return FALSE;
|
2003-12-12 03:34:37 +08:00
|
|
|
}
|
|
|
|
|
2003-09-24 00:17:25 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_dockable_popup_menu (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
return gimp_dockable_show_menu (GIMP_DOCKABLE (widget));
|
|
|
|
}
|
|
|
|
|
2003-10-21 22:49:12 +08:00
|
|
|
static void
|
|
|
|
gimp_dockable_add (GtkContainer *container,
|
|
|
|
GtkWidget *widget)
|
|
|
|
{
|
2005-03-26 05:58:48 +08:00
|
|
|
GimpDockable *dockable;
|
|
|
|
|
2003-10-21 22:49:12 +08:00
|
|
|
g_return_if_fail (GTK_BIN (container)->child == NULL);
|
|
|
|
|
|
|
|
GTK_CONTAINER_CLASS (parent_class)->add (container, widget);
|
|
|
|
|
2005-05-28 00:51:39 +08:00
|
|
|
g_signal_connect (widget, "title-changed",
|
2003-10-21 22:49:12 +08:00
|
|
|
G_CALLBACK (gimp_dockable_title_changed),
|
|
|
|
container);
|
2005-03-26 05:58:48 +08:00
|
|
|
|
|
|
|
/* not all tab styles are supported by all children */
|
|
|
|
dockable = GIMP_DOCKABLE (container);
|
|
|
|
gimp_dockable_set_tab_style (dockable, dockable->tab_style);
|
2003-10-21 22:49:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dockable_remove (GtkContainer *container,
|
|
|
|
GtkWidget *widget)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_BIN (container)->child == widget);
|
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func (widget,
|
|
|
|
gimp_dockable_title_changed,
|
|
|
|
container);
|
|
|
|
|
|
|
|
GTK_CONTAINER_CLASS (parent_class)->remove (container, widget);
|
|
|
|
}
|
|
|
|
|
2003-10-11 05:24:12 +08:00
|
|
|
static GType
|
|
|
|
gimp_dockable_child_type (GtkContainer *container)
|
|
|
|
{
|
|
|
|
if (GTK_BIN (container)->child)
|
|
|
|
return G_TYPE_NONE;
|
|
|
|
|
|
|
|
return GIMP_TYPE_DOCKED;
|
|
|
|
}
|
|
|
|
|
2003-09-22 03:35:54 +08:00
|
|
|
static void
|
|
|
|
gimp_dockable_forall (GtkContainer *container,
|
|
|
|
gboolean include_internals,
|
|
|
|
GtkCallback callback,
|
|
|
|
gpointer callback_data)
|
|
|
|
{
|
|
|
|
GimpDockable *dockable = GIMP_DOCKABLE (container);
|
|
|
|
|
|
|
|
if (include_internals)
|
|
|
|
{
|
|
|
|
if (dockable->menu_button)
|
|
|
|
(* callback) (dockable->menu_button, callback_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
GTK_CONTAINER_CLASS (parent_class)->forall (container, include_internals,
|
|
|
|
callback, callback_data);
|
|
|
|
}
|
|
|
|
|
2005-01-18 23:18:35 +08:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2001-04-07 22:44:12 +08:00
|
|
|
GtkWidget *
|
2003-10-11 05:24:12 +08:00
|
|
|
gimp_dockable_new (const gchar *name,
|
2004-09-01 05:29:30 +08:00
|
|
|
const gchar *blurb,
|
2003-10-11 05:24:12 +08:00
|
|
|
const gchar *stock_id,
|
|
|
|
const gchar *help_id)
|
2001-04-07 22:44:12 +08:00
|
|
|
{
|
2001-04-11 00:03:40 +08:00
|
|
|
GimpDockable *dockable;
|
|
|
|
|
2001-04-07 22:44:12 +08:00
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
2003-07-08 23:07:56 +08:00
|
|
|
g_return_val_if_fail (stock_id != NULL, NULL);
|
2003-08-25 22:18:33 +08:00
|
|
|
g_return_val_if_fail (help_id != NULL, NULL);
|
2001-04-11 00:03:40 +08:00
|
|
|
|
2001-08-10 22:41:39 +08:00
|
|
|
dockable = g_object_new (GIMP_TYPE_DOCKABLE, NULL);
|
2001-04-11 00:03:40 +08:00
|
|
|
|
2003-07-08 23:07:56 +08:00
|
|
|
dockable->name = g_strdup (name);
|
|
|
|
dockable->stock_id = g_strdup (stock_id);
|
2003-08-25 22:18:33 +08:00
|
|
|
dockable->help_id = g_strdup (help_id);
|
2001-04-11 00:03:40 +08:00
|
|
|
|
2003-10-01 02:50:55 +08:00
|
|
|
if (blurb)
|
|
|
|
dockable->blurb = g_strdup (blurb);
|
|
|
|
else
|
|
|
|
dockable->blurb = dockable->name;
|
|
|
|
|
2003-08-26 09:30:05 +08:00
|
|
|
gimp_help_set_help_data (GTK_WIDGET (dockable), NULL, help_id);
|
|
|
|
|
2001-04-11 00:03:40 +08:00
|
|
|
return GTK_WIDGET (dockable);
|
|
|
|
}
|
|
|
|
|
2003-10-10 23:59:12 +08:00
|
|
|
void
|
|
|
|
gimp_dockable_set_aux_info (GimpDockable *dockable,
|
|
|
|
GList *aux_info)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DOCKABLE (dockable));
|
|
|
|
|
2003-10-11 05:24:12 +08:00
|
|
|
if (GTK_BIN (dockable)->child)
|
|
|
|
gimp_docked_set_aux_info (GIMP_DOCKED (GTK_BIN (dockable)->child),
|
|
|
|
aux_info);
|
2003-10-10 23:59:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GList *
|
|
|
|
gimp_dockable_get_aux_info (GimpDockable *dockable)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DOCKABLE (dockable), NULL);
|
|
|
|
|
2003-10-11 05:24:12 +08:00
|
|
|
|
|
|
|
if (GTK_BIN (dockable)->child)
|
|
|
|
return gimp_docked_get_aux_info (GIMP_DOCKED (GTK_BIN (dockable)->child));
|
|
|
|
|
|
|
|
return NULL;
|
2003-10-10 23:59:12 +08:00
|
|
|
}
|
|
|
|
|
2004-06-01 20:31:44 +08:00
|
|
|
void
|
|
|
|
gimp_dockable_set_tab_style (GimpDockable *dockable,
|
|
|
|
GimpTabStyle tab_style)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DOCKABLE (dockable));
|
|
|
|
|
|
|
|
if (GTK_BIN (dockable)->child &&
|
|
|
|
! GIMP_DOCKED_GET_INTERFACE (GTK_BIN (dockable)->child)->get_preview)
|
|
|
|
{
|
|
|
|
switch (tab_style)
|
|
|
|
{
|
|
|
|
case GIMP_TAB_STYLE_PREVIEW:
|
|
|
|
tab_style = GIMP_TAB_STYLE_ICON;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_TAB_STYLE_PREVIEW_NAME:
|
|
|
|
tab_style = GIMP_TAB_STYLE_ICON_BLURB;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_TAB_STYLE_PREVIEW_BLURB:
|
|
|
|
tab_style = GIMP_TAB_STYLE_ICON_BLURB;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dockable->tab_style = tab_style;
|
|
|
|
}
|
|
|
|
|
2001-04-11 00:03:40 +08:00
|
|
|
GtkWidget *
|
|
|
|
gimp_dockable_get_tab_widget (GimpDockable *dockable,
|
2003-07-08 23:07:56 +08:00
|
|
|
GimpContext *context,
|
|
|
|
GimpTabStyle tab_style,
|
|
|
|
GtkIconSize size)
|
2001-08-04 03:43:19 +08:00
|
|
|
{
|
2003-07-08 23:07:56 +08:00
|
|
|
GtkWidget *tab_widget = NULL;
|
|
|
|
GtkWidget *label = NULL;
|
|
|
|
GtkWidget *icon = NULL;
|
2001-08-04 03:43:19 +08:00
|
|
|
|
2003-10-11 05:24:12 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DOCKABLE (dockable), NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
|
|
|
|
2003-08-15 23:03:03 +08:00
|
|
|
switch (tab_style)
|
2003-07-08 23:07:56 +08:00
|
|
|
{
|
2003-08-15 23:03:03 +08:00
|
|
|
case GIMP_TAB_STYLE_NAME:
|
|
|
|
case GIMP_TAB_STYLE_ICON_NAME:
|
|
|
|
case GIMP_TAB_STYLE_PREVIEW_NAME:
|
2003-07-08 23:07:56 +08:00
|
|
|
label = gtk_label_new (dockable->name);
|
2003-08-15 23:03:03 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_TAB_STYLE_BLURB:
|
|
|
|
case GIMP_TAB_STYLE_ICON_BLURB:
|
|
|
|
case GIMP_TAB_STYLE_PREVIEW_BLURB:
|
2003-07-08 23:07:56 +08:00
|
|
|
label = gtk_label_new (dockable->blurb);
|
2003-08-15 23:03:03 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2003-07-08 23:07:56 +08:00
|
|
|
}
|
2001-04-07 22:44:12 +08:00
|
|
|
|
2003-08-15 23:03:03 +08:00
|
|
|
switch (tab_style)
|
2003-07-08 23:07:56 +08:00
|
|
|
{
|
2003-08-15 23:03:03 +08:00
|
|
|
case GIMP_TAB_STYLE_ICON:
|
|
|
|
case GIMP_TAB_STYLE_ICON_NAME:
|
|
|
|
case GIMP_TAB_STYLE_ICON_BLURB:
|
|
|
|
icon = gtk_image_new_from_stock (dockable->stock_id, size);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_TAB_STYLE_PREVIEW:
|
|
|
|
case GIMP_TAB_STYLE_PREVIEW_NAME:
|
|
|
|
case GIMP_TAB_STYLE_PREVIEW_BLURB:
|
2003-10-11 05:24:12 +08:00
|
|
|
if (GTK_BIN (dockable)->child)
|
|
|
|
icon = gimp_docked_get_preview (GIMP_DOCKED (GTK_BIN (dockable)->child),
|
|
|
|
context, size);
|
|
|
|
|
|
|
|
if (! icon)
|
2003-07-08 23:07:56 +08:00
|
|
|
icon = gtk_image_new_from_stock (dockable->stock_id, size);
|
2003-08-15 23:03:03 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2003-07-08 23:07:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (tab_style)
|
|
|
|
{
|
|
|
|
case GIMP_TAB_STYLE_ICON:
|
2003-08-15 23:03:03 +08:00
|
|
|
case GIMP_TAB_STYLE_PREVIEW:
|
2003-07-08 23:07:56 +08:00
|
|
|
tab_widget = icon;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_TAB_STYLE_NAME:
|
2003-08-15 23:03:03 +08:00
|
|
|
case GIMP_TAB_STYLE_BLURB:
|
2003-07-08 23:07:56 +08:00
|
|
|
tab_widget = label;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_TAB_STYLE_ICON_NAME:
|
|
|
|
case GIMP_TAB_STYLE_ICON_BLURB:
|
2003-08-15 23:03:03 +08:00
|
|
|
case GIMP_TAB_STYLE_PREVIEW_NAME:
|
|
|
|
case GIMP_TAB_STYLE_PREVIEW_BLURB:
|
2004-06-03 01:56:02 +08:00
|
|
|
tab_widget = gtk_hbox_new (FALSE, 2);
|
2003-07-08 23:07:56 +08:00
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (tab_widget), icon, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (icon);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (tab_widget), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
break;
|
|
|
|
}
|
2002-05-10 22:50:27 +08:00
|
|
|
|
2003-07-08 23:07:56 +08:00
|
|
|
return tab_widget;
|
2001-04-07 22:44:12 +08:00
|
|
|
}
|
2001-04-24 00:58:18 +08:00
|
|
|
|
2003-10-11 05:24:12 +08:00
|
|
|
void
|
|
|
|
gimp_dockable_set_context (GimpDockable *dockable,
|
|
|
|
GimpContext *context)
|
2001-04-24 00:58:18 +08:00
|
|
|
{
|
2003-10-11 05:24:12 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DOCKABLE (dockable));
|
|
|
|
g_return_if_fail (context == NULL || GIMP_IS_CONTEXT (context));
|
|
|
|
|
2004-05-23 18:04:41 +08:00
|
|
|
if (context != dockable->context)
|
2003-10-11 05:24:12 +08:00
|
|
|
{
|
2004-05-23 18:04:41 +08:00
|
|
|
if (GTK_BIN (dockable)->child)
|
|
|
|
gimp_docked_set_context (GIMP_DOCKED (GTK_BIN (dockable)->child),
|
|
|
|
context);
|
2001-08-04 03:43:19 +08:00
|
|
|
|
2004-05-23 18:04:41 +08:00
|
|
|
dockable->context = context;
|
|
|
|
}
|
2001-04-24 00:58:18 +08:00
|
|
|
}
|
2003-09-22 03:35:54 +08:00
|
|
|
|
2004-04-29 20:52:29 +08:00
|
|
|
GimpUIManager *
|
|
|
|
gimp_dockable_get_menu (GimpDockable *dockable,
|
|
|
|
const gchar **ui_path,
|
|
|
|
gpointer *popup_data)
|
2003-09-22 03:35:54 +08:00
|
|
|
{
|
2003-10-11 05:24:12 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DOCKABLE (dockable), NULL);
|
2004-04-29 20:52:29 +08:00
|
|
|
g_return_val_if_fail (ui_path != NULL, NULL);
|
2004-04-23 01:14:22 +08:00
|
|
|
g_return_val_if_fail (popup_data != NULL, NULL);
|
2003-10-11 05:24:12 +08:00
|
|
|
|
|
|
|
if (GTK_BIN (dockable)->child)
|
|
|
|
return gimp_docked_get_menu (GIMP_DOCKED (GTK_BIN (dockable)->child),
|
2004-04-29 20:52:29 +08:00
|
|
|
ui_path, popup_data);
|
2003-09-22 03:35:54 +08:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2003-10-11 05:24:12 +08:00
|
|
|
void
|
|
|
|
gimp_dockable_detach (GimpDockable *dockable)
|
|
|
|
{
|
|
|
|
GimpDock *src_dock;
|
|
|
|
GtkWidget *dock;
|
|
|
|
GtkWidget *dockbook;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DOCKABLE (dockable));
|
|
|
|
g_return_if_fail (GIMP_IS_DOCKBOOK (dockable->dockbook));
|
|
|
|
|
|
|
|
src_dock = dockable->dockbook->dock;
|
|
|
|
|
2003-11-08 23:32:38 +08:00
|
|
|
dock = gimp_dialog_factory_dock_new (src_dock->dialog_factory,
|
|
|
|
gtk_widget_get_screen (GTK_WIDGET (dockable)));
|
2003-10-11 05:24:12 +08:00
|
|
|
gimp_dock_setup (GIMP_DOCK (dock), src_dock);
|
|
|
|
|
|
|
|
dockbook = gimp_dockbook_new (GIMP_DOCK (dock)->dialog_factory->menu_factory);
|
|
|
|
|
|
|
|
gimp_dock_add_book (GIMP_DOCK (dock), GIMP_DOCKBOOK (dockbook), 0);
|
|
|
|
|
|
|
|
g_object_ref (dockable);
|
|
|
|
|
|
|
|
gimp_dockbook_remove (dockable->dockbook, dockable);
|
|
|
|
gimp_dockbook_add (GIMP_DOCKBOOK (dockbook), dockable, 0);
|
|
|
|
|
|
|
|
g_object_unref (dockable);
|
|
|
|
|
|
|
|
gtk_widget_show (dock);
|
|
|
|
}
|
|
|
|
|
2005-01-18 23:18:35 +08:00
|
|
|
void
|
|
|
|
gimp_dockable_blink (GimpDockable *dockable)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DOCKABLE (dockable));
|
|
|
|
|
|
|
|
if (dockable->blink_timeout_id)
|
|
|
|
g_source_remove (dockable->blink_timeout_id);
|
|
|
|
|
|
|
|
dockable->blink_timeout_id =
|
2005-12-29 07:43:53 +08:00
|
|
|
g_timeout_add (150, (GSourceFunc) gimp_dockable_blink_timeout, dockable);
|
2005-01-18 23:18:35 +08:00
|
|
|
|
|
|
|
gimp_dockable_blink_timeout (dockable);
|
|
|
|
}
|
|
|
|
|
2005-07-14 01:03:44 +08:00
|
|
|
void
|
|
|
|
gimp_dockable_blink_cancel (GimpDockable *dockable)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DOCKABLE (dockable));
|
|
|
|
|
|
|
|
if (dockable->blink_timeout_id)
|
|
|
|
{
|
|
|
|
g_source_remove (dockable->blink_timeout_id);
|
2005-12-29 07:43:53 +08:00
|
|
|
|
2005-07-14 01:03:44 +08:00
|
|
|
dockable->blink_timeout_id = 0;
|
|
|
|
dockable->blink_counter = 0;
|
2005-12-29 07:43:53 +08:00
|
|
|
|
|
|
|
gimp_dockable_clear_title_area (dockable);
|
2005-07-14 01:03:44 +08:00
|
|
|
}
|
|
|
|
}
|
2005-01-18 23:18:35 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2003-10-11 05:24:12 +08:00
|
|
|
static void
|
|
|
|
gimp_dockable_get_title_area (GimpDockable *dockable,
|
|
|
|
GdkRectangle *area)
|
|
|
|
{
|
|
|
|
GtkWidget *widget = GTK_WIDGET (dockable);
|
|
|
|
gint border = GTK_CONTAINER (dockable)->border_width;
|
|
|
|
|
|
|
|
area->x = widget->allocation.x + border;
|
|
|
|
area->y = widget->allocation.y + border;
|
|
|
|
area->width = (widget->allocation.width -
|
2005-04-22 07:30:38 +08:00
|
|
|
2 * border - dockable->menu_button->allocation.width);
|
|
|
|
area->height = dockable->menu_button->allocation.height;
|
2003-10-11 05:24:12 +08:00
|
|
|
|
|
|
|
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
|
2005-04-22 07:30:38 +08:00
|
|
|
area->x += dockable->menu_button->allocation.width;
|
2003-10-11 05:24:12 +08:00
|
|
|
}
|
|
|
|
|
2005-12-29 07:43:53 +08:00
|
|
|
static void
|
|
|
|
gimp_dockable_clear_title_area (GimpDockable *dockable)
|
|
|
|
{
|
|
|
|
if (GTK_WIDGET_DRAWABLE (dockable))
|
|
|
|
{
|
|
|
|
GdkRectangle area;
|
|
|
|
|
|
|
|
gimp_dockable_get_title_area (dockable, &area);
|
|
|
|
gtk_widget_queue_draw_area (GTK_WIDGET (dockable),
|
|
|
|
area.x, area.y, area.width, area.height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-24 00:17:25 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_dockable_menu_button_press (GtkWidget *button,
|
|
|
|
GdkEventButton *bevent,
|
|
|
|
GimpDockable *dockable)
|
|
|
|
{
|
|
|
|
if (bevent->button == 1 && bevent->type == GDK_BUTTON_PRESS)
|
|
|
|
{
|
|
|
|
return gimp_dockable_show_menu (dockable);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-09-22 03:35:54 +08:00
|
|
|
static void
|
|
|
|
gimp_dockable_menu_position (GtkMenu *menu,
|
|
|
|
gint *x,
|
|
|
|
gint *y,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2003-09-24 04:27:12 +08:00
|
|
|
GimpDockable *dockable = GIMP_DOCKABLE (data);
|
2003-09-22 03:35:54 +08:00
|
|
|
|
2003-09-24 04:27:12 +08:00
|
|
|
gimp_button_menu_position (dockable->menu_button, menu, GTK_POS_LEFT, x, y);
|
2003-09-22 03:35:54 +08:00
|
|
|
}
|
|
|
|
|
2003-10-07 20:24:01 +08:00
|
|
|
#define GIMP_DOCKABLE_DETACH_REF_KEY "gimp-dockable-detach-ref"
|
|
|
|
|
2003-09-24 00:17:25 +08:00
|
|
|
static void
|
|
|
|
gimp_dockable_menu_end (GimpDockable *dockable)
|
2003-09-22 03:35:54 +08:00
|
|
|
{
|
2004-04-23 01:14:22 +08:00
|
|
|
GimpUIManager *dialog_ui_manager;
|
2004-04-29 20:52:29 +08:00
|
|
|
const gchar *dialog_ui_path;
|
|
|
|
gpointer dialog_popup_data;
|
2003-09-22 03:35:54 +08:00
|
|
|
|
2004-04-29 20:52:29 +08:00
|
|
|
dialog_ui_manager = gimp_dockable_get_menu (dockable,
|
|
|
|
&dialog_ui_path,
|
|
|
|
&dialog_popup_data);
|
2003-09-22 03:35:54 +08:00
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
if (dialog_ui_manager && dialog_ui_path)
|
2004-04-23 01:14:22 +08:00
|
|
|
{
|
2005-02-09 04:55:00 +08:00
|
|
|
GtkWidget *child_menu_widget =
|
|
|
|
gtk_ui_manager_get_widget (GTK_UI_MANAGER (dialog_ui_manager),
|
|
|
|
dialog_ui_path);
|
2004-12-01 08:13:48 +08:00
|
|
|
|
|
|
|
if (child_menu_widget)
|
|
|
|
gtk_menu_detach (GTK_MENU (child_menu_widget));
|
2004-04-23 01:14:22 +08:00
|
|
|
}
|
2003-09-22 03:35:54 +08:00
|
|
|
|
2003-10-07 20:24:01 +08:00
|
|
|
/* release gimp_dockable_show_menu()'s references */
|
|
|
|
g_object_set_data (G_OBJECT (dockable), GIMP_DOCKABLE_DETACH_REF_KEY, NULL);
|
2003-09-24 00:17:25 +08:00
|
|
|
g_object_unref (dockable);
|
2003-09-22 03:35:54 +08:00
|
|
|
}
|
|
|
|
|
2003-09-24 00:17:25 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_dockable_show_menu (GimpDockable *dockable)
|
2003-09-22 03:35:54 +08:00
|
|
|
{
|
2004-09-01 05:29:30 +08:00
|
|
|
GimpUIManager *dockbook_ui_manager = dockable->dockbook->ui_manager;
|
2004-05-23 18:04:41 +08:00
|
|
|
GimpUIManager *dialog_ui_manager;
|
|
|
|
const gchar *dialog_ui_path;
|
|
|
|
gpointer dialog_popup_data;
|
|
|
|
GtkWidget *parent_menu_widget;
|
|
|
|
GtkAction *parent_menu_action;
|
2003-09-24 00:17:25 +08:00
|
|
|
|
2004-04-29 20:52:29 +08:00
|
|
|
if (! dockbook_ui_manager)
|
2003-09-24 00:17:25 +08:00
|
|
|
return FALSE;
|
|
|
|
|
2004-05-23 18:04:41 +08:00
|
|
|
parent_menu_widget =
|
2005-02-09 04:55:00 +08:00
|
|
|
gtk_ui_manager_get_widget (GTK_UI_MANAGER (dockbook_ui_manager),
|
|
|
|
"/dockable-popup/dockable-menu");
|
2004-05-23 18:04:41 +08:00
|
|
|
|
|
|
|
parent_menu_action =
|
|
|
|
gtk_ui_manager_get_action (GTK_UI_MANAGER (dockbook_ui_manager),
|
|
|
|
"/dockable-popup/dockable-menu");
|
|
|
|
|
2004-12-01 08:13:48 +08:00
|
|
|
if (! parent_menu_widget || ! parent_menu_action)
|
|
|
|
return FALSE;
|
|
|
|
|
2004-04-29 20:52:29 +08:00
|
|
|
dialog_ui_manager = gimp_dockable_get_menu (dockable,
|
|
|
|
&dialog_ui_path,
|
|
|
|
&dialog_popup_data);
|
2004-04-23 01:14:22 +08:00
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
if (dialog_ui_manager && dialog_ui_path)
|
2004-04-23 01:14:22 +08:00
|
|
|
{
|
2004-04-30 23:29:11 +08:00
|
|
|
GtkWidget *child_menu_widget;
|
2004-04-23 01:14:22 +08:00
|
|
|
GtkAction *child_menu_action;
|
|
|
|
const gchar *label;
|
|
|
|
|
2004-04-30 23:29:11 +08:00
|
|
|
child_menu_widget =
|
2005-02-09 04:55:00 +08:00
|
|
|
gtk_ui_manager_get_widget (GTK_UI_MANAGER (dialog_ui_manager),
|
|
|
|
dialog_ui_path);
|
2004-04-23 01:14:22 +08:00
|
|
|
|
|
|
|
child_menu_action =
|
|
|
|
gtk_ui_manager_get_action (GTK_UI_MANAGER (dialog_ui_manager),
|
2004-04-29 20:52:29 +08:00
|
|
|
dialog_ui_path);
|
2004-04-23 01:14:22 +08:00
|
|
|
|
2004-12-01 08:13:48 +08:00
|
|
|
if (! child_menu_widget || ! child_menu_action)
|
|
|
|
return FALSE;
|
|
|
|
|
2004-04-23 01:14:22 +08:00
|
|
|
g_object_get (child_menu_action,
|
|
|
|
"label", &label,
|
|
|
|
NULL);
|
2003-09-24 00:17:25 +08:00
|
|
|
|
2004-04-23 01:14:22 +08:00
|
|
|
g_object_set (parent_menu_action,
|
|
|
|
"label", label,
|
|
|
|
"stock-id", dockable->stock_id,
|
|
|
|
"visible", TRUE,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (! GTK_IS_MENU (child_menu_widget))
|
|
|
|
{
|
|
|
|
g_warning ("%s: child_menu_widget (%p) is not a GtkMenu",
|
|
|
|
G_STRFUNC, child_menu_widget);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-04-29 20:52:29 +08:00
|
|
|
/* FIXME */
|
|
|
|
{
|
2004-09-01 05:29:30 +08:00
|
|
|
GtkWidget *image = gtk_image_new_from_stock (dockable->stock_id,
|
|
|
|
GTK_ICON_SIZE_MENU);
|
2004-04-29 20:52:29 +08:00
|
|
|
|
|
|
|
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (parent_menu_widget),
|
|
|
|
image);
|
|
|
|
gtk_widget_show (image);
|
|
|
|
}
|
|
|
|
|
2004-04-23 01:14:22 +08:00
|
|
|
gtk_menu_item_set_submenu (GTK_MENU_ITEM (parent_menu_widget),
|
|
|
|
child_menu_widget);
|
|
|
|
|
|
|
|
gimp_ui_manager_update (dialog_ui_manager, dialog_popup_data);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_object_set (parent_menu_action, "visible", FALSE, NULL);
|
|
|
|
}
|
2003-09-24 00:17:25 +08:00
|
|
|
|
2004-04-29 20:52:29 +08:00
|
|
|
/* an action callback may destroy both dockable and dockbook, so
|
|
|
|
* reference them for gimp_dockable_menu_end()
|
2003-09-24 00:17:25 +08:00
|
|
|
*/
|
|
|
|
g_object_ref (dockable);
|
2003-10-07 20:24:01 +08:00
|
|
|
g_object_set_data_full (G_OBJECT (dockable), GIMP_DOCKABLE_DETACH_REF_KEY,
|
|
|
|
g_object_ref (dockable->dockbook),
|
|
|
|
g_object_unref);
|
2003-09-24 00:17:25 +08:00
|
|
|
|
2004-04-23 01:14:22 +08:00
|
|
|
gimp_ui_manager_update (dockbook_ui_manager, dockable);
|
|
|
|
gimp_ui_manager_ui_popup (dockbook_ui_manager, "/dockable-popup",
|
|
|
|
GTK_WIDGET (dockable),
|
|
|
|
gimp_dockable_menu_position, dockable,
|
2004-05-17 21:38:03 +08:00
|
|
|
(GtkDestroyNotify) gimp_dockable_menu_end, dockable);
|
2004-04-23 01:14:22 +08:00
|
|
|
|
2003-09-24 00:17:25 +08:00
|
|
|
return TRUE;
|
2003-09-22 03:35:54 +08:00
|
|
|
}
|
2003-10-21 22:49:12 +08:00
|
|
|
|
2005-01-18 23:18:35 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_dockable_blink_timeout (GimpDockable *dockable)
|
|
|
|
{
|
2005-12-29 07:43:53 +08:00
|
|
|
gimp_dockable_clear_title_area (dockable);
|
2005-01-18 23:18:35 +08:00
|
|
|
|
|
|
|
if (dockable->blink_counter++ > 3)
|
|
|
|
{
|
|
|
|
dockable->blink_timeout_id = 0;
|
|
|
|
dockable->blink_counter = 0;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-10-21 22:49:12 +08:00
|
|
|
static void
|
|
|
|
gimp_dockable_title_changed (GimpDocked *docked,
|
|
|
|
GimpDockable *dockable)
|
|
|
|
{
|
|
|
|
if (dockable->title_layout)
|
|
|
|
{
|
|
|
|
g_object_unref (dockable->title_layout);
|
|
|
|
dockable->title_layout = NULL;
|
|
|
|
}
|
|
|
|
|
2005-12-29 07:51:39 +08:00
|
|
|
if (GTK_WIDGET_DRAWABLE (dockable))
|
2003-10-21 22:49:12 +08:00
|
|
|
{
|
2005-12-29 07:51:39 +08:00
|
|
|
GdkRectangle area;
|
2003-10-21 22:49:12 +08:00
|
|
|
|
2005-12-29 07:51:39 +08:00
|
|
|
gimp_dockable_get_title_area (dockable, &area);
|
2003-10-21 22:49:12 +08:00
|
|
|
|
2005-12-29 07:51:39 +08:00
|
|
|
gdk_window_invalidate_rect (GTK_WIDGET (dockable)->window, &area, FALSE);
|
2003-10-21 22:49:12 +08:00
|
|
|
}
|
|
|
|
}
|