gimp/app/widgets/gimpdockbook.c

1638 lines
55 KiB
C
Raw Normal View History

/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpdockbook.c
* Copyright (C) 2001-2007 Michael Natterer <mitch@gimp.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 <string.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
Move away from creating all item_factories statically in menus_init() but 2003-01-10 Michael Natterer <mitch@gimp.org> Move away from creating all item_factories statically in menus_init() but create a new one for each place where one is needed: * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpmenufactory.[ch]: new factory which creates and configures the GimpItemFactories it knows about on-the-fly. * app/widgets/gimpitemfactory.[ch]: added gimp_item_factory_update() which calls the "update_func". Added "gboolean update_on_popup" so item_factories can be configured to require manual updates (used for the <Image> factory). * app/gui/menus.[ch]: create a "global_menu_factory" and register all menus we have with it. Added various setup functions which do stuff like adding the "Open Recent" menu or reorder plug-in menu entries. Removed the debugging stuff... * app/gui/Makefile.am * app/gui/debug-commands.[ch]: ...and added it here. * app/gui/gui.c: create the <Toolbox>, the popup-<Image> and the <Paths> factories here because they are still global. * app/gui/plug-in-menus.[ch]: changed the "image_factory" parameters to "item_factory" and create/update the entries for the passed item_factory only. Makes the whole stuff much more straightforward. * app/plug-in/plug-ins.c: don't call plug_in_make_menu(). * app/display/gimpdisplay.[ch] * app/display/gimpdisplayshell.[ch]: added "menu_factory" and "popup_factory" parameters to gimp_display_new() and gimp_display_shell_new(). Create the menubar_factory and the qmask_factory dynamically. Pass the shell, not a Gimp to the QMask callbacks. Changed gimp_display_shell_set_menu_sensitivity() to gimp_display_shell_menu_update() and don't call it directly (it's a GimpItemFactory update_func now). Call gimp_item_factory_update() on the resp. factories instead. * app/gui/qmask-commands.c * app/display/gimpdisplayshell-callbacks.c * app/tools/gimpimagemaptool.c: changed accordingly. * app/widgets/gimpbrusheditor.c * app/widgets/gimpbrushfactoryview.[ch] * app/widgets/gimpbufferview.[ch] * app/widgets/gimpcolormapeditor.[ch] * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpdataeditor.[ch] * app/widgets/gimpdatafactoryview.[ch] * app/widgets/gimpdialogfactory.[ch] * app/widgets/gimpdock.c * app/widgets/gimpdockbook.[ch] * app/widgets/gimpdocumentview.[ch] * app/widgets/gimpgradienteditor.[ch] * app/widgets/gimpimageview.[ch] * app/widgets/gimpitemlistview.[ch] * app/widgets/gimppaletteeditor.[ch]: pass around lots of GimpMenuFactory pointers and menu_identifiers so all views can create their item_factories themselves. Unref the factories when they are no longer needed because they belong to the views now. * app/gui/dialogs-commands.c * app/gui/dialogs-constructors.c * app/gui/dialogs.c * app/gui/brush-select.c * app/gui/gradient-select.c * app/gui/palette-select.c * app/gui/pattern-select.c: changed accordingly. * app/gui/file-dialog-utils.[ch] (file_dialog_new): require menu_factory and menu_identifier parameters. * app/gui/file-open-dialog.[ch] * app/gui/file-save-dialog.[ch]: removed file_*_dialog_menu_init() (they went to menus.c as setup_funcs). Added file_*_dialog_set_type() and moved the <Load> and <Save> factory callbacks to file-commands.c * app/gui/file-commands.[ch]: changed accordingly. * app/gui/view-commands.c: changed the statusbar, menubar, rulers and guides callbacks to do their job only if the setting has actually changed. Don't update whole item factories afterwards. Instead, just change the state of the items that actually need update. Unrelated: * app/core/gimpchannel.c (gimp_channel_init): set "bounds_known" and friends to FALSE since we don't know that the new channel will be empty (fixes QMask and probably other stuff). * app/gui/image-commands.c * app/gui/vectors-commands.c: cleanup.
2003-01-11 01:55:53 +08:00
#include "core/gimpcontext.h"
#include "core/gimpmarshal.h"
Move away from creating all item_factories statically in menus_init() but 2003-01-10 Michael Natterer <mitch@gimp.org> Move away from creating all item_factories statically in menus_init() but create a new one for each place where one is needed: * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpmenufactory.[ch]: new factory which creates and configures the GimpItemFactories it knows about on-the-fly. * app/widgets/gimpitemfactory.[ch]: added gimp_item_factory_update() which calls the "update_func". Added "gboolean update_on_popup" so item_factories can be configured to require manual updates (used for the <Image> factory). * app/gui/menus.[ch]: create a "global_menu_factory" and register all menus we have with it. Added various setup functions which do stuff like adding the "Open Recent" menu or reorder plug-in menu entries. Removed the debugging stuff... * app/gui/Makefile.am * app/gui/debug-commands.[ch]: ...and added it here. * app/gui/gui.c: create the <Toolbox>, the popup-<Image> and the <Paths> factories here because they are still global. * app/gui/plug-in-menus.[ch]: changed the "image_factory" parameters to "item_factory" and create/update the entries for the passed item_factory only. Makes the whole stuff much more straightforward. * app/plug-in/plug-ins.c: don't call plug_in_make_menu(). * app/display/gimpdisplay.[ch] * app/display/gimpdisplayshell.[ch]: added "menu_factory" and "popup_factory" parameters to gimp_display_new() and gimp_display_shell_new(). Create the menubar_factory and the qmask_factory dynamically. Pass the shell, not a Gimp to the QMask callbacks. Changed gimp_display_shell_set_menu_sensitivity() to gimp_display_shell_menu_update() and don't call it directly (it's a GimpItemFactory update_func now). Call gimp_item_factory_update() on the resp. factories instead. * app/gui/qmask-commands.c * app/display/gimpdisplayshell-callbacks.c * app/tools/gimpimagemaptool.c: changed accordingly. * app/widgets/gimpbrusheditor.c * app/widgets/gimpbrushfactoryview.[ch] * app/widgets/gimpbufferview.[ch] * app/widgets/gimpcolormapeditor.[ch] * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpdataeditor.[ch] * app/widgets/gimpdatafactoryview.[ch] * app/widgets/gimpdialogfactory.[ch] * app/widgets/gimpdock.c * app/widgets/gimpdockbook.[ch] * app/widgets/gimpdocumentview.[ch] * app/widgets/gimpgradienteditor.[ch] * app/widgets/gimpimageview.[ch] * app/widgets/gimpitemlistview.[ch] * app/widgets/gimppaletteeditor.[ch]: pass around lots of GimpMenuFactory pointers and menu_identifiers so all views can create their item_factories themselves. Unref the factories when they are no longer needed because they belong to the views now. * app/gui/dialogs-commands.c * app/gui/dialogs-constructors.c * app/gui/dialogs.c * app/gui/brush-select.c * app/gui/gradient-select.c * app/gui/palette-select.c * app/gui/pattern-select.c: changed accordingly. * app/gui/file-dialog-utils.[ch] (file_dialog_new): require menu_factory and menu_identifier parameters. * app/gui/file-open-dialog.[ch] * app/gui/file-save-dialog.[ch]: removed file_*_dialog_menu_init() (they went to menus.c as setup_funcs). Added file_*_dialog_set_type() and moved the <Load> and <Save> factory callbacks to file-commands.c * app/gui/file-commands.[ch]: changed accordingly. * app/gui/view-commands.c: changed the statusbar, menubar, rulers and guides callbacks to do their job only if the setting has actually changed. Don't update whole item factories afterwards. Instead, just change the state of the items that actually need update. Unrelated: * app/core/gimpchannel.c (gimp_channel_init): set "bounds_known" and friends to FALSE since we don't know that the new channel will be empty (fixes QMask and probably other stuff). * app/gui/image-commands.c * app/gui/vectors-commands.c: cleanup.
2003-01-11 01:55:53 +08:00
#include "gimpdnd.h"
#include "gimpdock.h"
#include "gimpdockable.h"
#include "gimpdockbook.h"
#include "gimpdocked.h"
#include "gimpdockwindow.h"
#include "gimphelp-ids.h"
Move away from creating all item_factories statically in menus_init() but 2003-01-10 Michael Natterer <mitch@gimp.org> Move away from creating all item_factories statically in menus_init() but create a new one for each place where one is needed: * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpmenufactory.[ch]: new factory which creates and configures the GimpItemFactories it knows about on-the-fly. * app/widgets/gimpitemfactory.[ch]: added gimp_item_factory_update() which calls the "update_func". Added "gboolean update_on_popup" so item_factories can be configured to require manual updates (used for the <Image> factory). * app/gui/menus.[ch]: create a "global_menu_factory" and register all menus we have with it. Added various setup functions which do stuff like adding the "Open Recent" menu or reorder plug-in menu entries. Removed the debugging stuff... * app/gui/Makefile.am * app/gui/debug-commands.[ch]: ...and added it here. * app/gui/gui.c: create the <Toolbox>, the popup-<Image> and the <Paths> factories here because they are still global. * app/gui/plug-in-menus.[ch]: changed the "image_factory" parameters to "item_factory" and create/update the entries for the passed item_factory only. Makes the whole stuff much more straightforward. * app/plug-in/plug-ins.c: don't call plug_in_make_menu(). * app/display/gimpdisplay.[ch] * app/display/gimpdisplayshell.[ch]: added "menu_factory" and "popup_factory" parameters to gimp_display_new() and gimp_display_shell_new(). Create the menubar_factory and the qmask_factory dynamically. Pass the shell, not a Gimp to the QMask callbacks. Changed gimp_display_shell_set_menu_sensitivity() to gimp_display_shell_menu_update() and don't call it directly (it's a GimpItemFactory update_func now). Call gimp_item_factory_update() on the resp. factories instead. * app/gui/qmask-commands.c * app/display/gimpdisplayshell-callbacks.c * app/tools/gimpimagemaptool.c: changed accordingly. * app/widgets/gimpbrusheditor.c * app/widgets/gimpbrushfactoryview.[ch] * app/widgets/gimpbufferview.[ch] * app/widgets/gimpcolormapeditor.[ch] * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpdataeditor.[ch] * app/widgets/gimpdatafactoryview.[ch] * app/widgets/gimpdialogfactory.[ch] * app/widgets/gimpdock.c * app/widgets/gimpdockbook.[ch] * app/widgets/gimpdocumentview.[ch] * app/widgets/gimpgradienteditor.[ch] * app/widgets/gimpimageview.[ch] * app/widgets/gimpitemlistview.[ch] * app/widgets/gimppaletteeditor.[ch]: pass around lots of GimpMenuFactory pointers and menu_identifiers so all views can create their item_factories themselves. Unref the factories when they are no longer needed because they belong to the views now. * app/gui/dialogs-commands.c * app/gui/dialogs-constructors.c * app/gui/dialogs.c * app/gui/brush-select.c * app/gui/gradient-select.c * app/gui/palette-select.c * app/gui/pattern-select.c: changed accordingly. * app/gui/file-dialog-utils.[ch] (file_dialog_new): require menu_factory and menu_identifier parameters. * app/gui/file-open-dialog.[ch] * app/gui/file-save-dialog.[ch]: removed file_*_dialog_menu_init() (they went to menus.c as setup_funcs). Added file_*_dialog_set_type() and moved the <Load> and <Save> factory callbacks to file-commands.c * app/gui/file-commands.[ch]: changed accordingly. * app/gui/view-commands.c: changed the statusbar, menubar, rulers and guides callbacks to do their job only if the setting has actually changed. Don't update whole item factories afterwards. Instead, just change the state of the items that actually need update. Unrelated: * app/core/gimpchannel.c (gimp_channel_init): set "bounds_known" and friends to FALSE since we don't know that the new channel will be empty (fixes QMask and probably other stuff). * app/gui/image-commands.c * app/gui/vectors-commands.c: cleanup.
2003-01-11 01:55:53 +08:00
#include "gimpmenufactory.h"
#include "gimppanedbox.h"
#include "gimpstringaction.h"
#include "gimpuimanager.h"
#include "gimpview.h"
#include "gimpwidgets-utils.h"
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND Make drag-and-drop rearrangement of dockables happen directly in the existing widget hierarchy so we don't have to use special, ugly widgets (read GimpDockSeparator:s) for that. More specifically, make edges of dockables and dockbooks have the same semantics as the GimpDockSeparators had. We put a highlight colored GdkWindow on top of the widget in question to highlight these special drop areas. This GdkWindow is not taken into consideration in the GTK+ drag-and-drop code, so it does not interupt the DND interaction. To achive this, there is a problem we must solve: Drag events in GTK+ are propagated inwards and out, but we sometimes want ancenstor widgets to take care of drop events. We solve this by introducing the concept of "drag handlers". A drag handler is asked if it will handle a given drag event, and if it will, a client will let the drag event be propagated upwards in the widget hierarchy. Right now, the GimpPanedBox is the only "drag handler". The code could be generalized more but it doesn't feel worth it at this point. The size of the special drop area is 5px, the same size as the default GtkPaned handles. This is because the plan is to later use these handles as drop areas too. Other changes of interest are: * We need to take care of "drag-motion", "drag-drop" and widget highlightning ourselves. We can not use the GtkDestDefaults conveniences with gtk_drag_dest_set() any longer since we need more control. * Make the drop callback pass the insert index directly instead of a GimpDockSeparator * Add some GIMP_LOG() debug output for DND * Disable the GimpDockSeparator code in GimpToolbox
2009-11-30 01:22:12 +08:00
#include "gimp-log.h"
#include "gimp-intl.h"
#define DEFAULT_TAB_BORDER 0
#define DEFAULT_TAB_ICON_SIZE GTK_ICON_SIZE_BUTTON
#define DND_WIDGET_ICON_SIZE GTK_ICON_SIZE_BUTTON
#define MENU_WIDGET_ICON_SIZE GTK_ICON_SIZE_MENU
#define MENU_WIDGET_SPACING 4
#define TAB_HOVER_TIMEOUT 500
#define GIMP_N_TAB_STYLE_CANDIDATES 3 /* G_N_ELEMENTS (gimp_tab_style_candidates); */
#define GIMP_DOCKABLE_DETACH_REF_KEY "gimp-dockable-detach-ref"
added GimpDropMode... ...removed from here. 2001-05-06 Michael Natterer <mitch@gimp.org> * app/appenums.h: added GimpDropMode... * app/gimpdnd.h: ...removed from here. * app/gimpimage.[ch]: - New signal "mode_changed". - removed "const GimpImage*" from gimp_image_colormap_changed() because a signal emission is never "const" for the object which emits the signal. - Fixed gimp_image_[set|get]_component_[active|visible](): ALPHA_CHANNEL maps to ALPHA_PIX only in RGB mode, use ALPHA_G_PIX/ALPHA_I_PIX in GRAY/INDEXED mode. * app/gimpimage-convert.c * app/undo.c: call gimp_image_mode_changed(). * app/gimpviewable.c: added an implementation of "invalidate_preview" which frees the preview temp_buf which may be attached to the viewable. Subclasses need to chain up now. * app/gimpdrawable.c * app/gimpimage.c: chain up in invalidate_preview(). * app/widgets/gimpchannellistview.c: connect to the image's "mode_changed" signal and rebuild the channel list in the callback. * app/widgets/gimpcontainerview.h: indentation. * app/widgets/gimpdockbook.c: set the dockable's context to NULL in gimp_dockbook_remove() * app/widgets/gimpimagedock.c: forgot to actually set the dock's image in gimp_image_dock_new(). * app/gui/dialogs-constructors.c: added a get_name_func() for tool views which returns the tool's "blurb". It's safe to assume now that a dockable's context will exist as long as the dockable exists unless it's explicitely set to NULL, so remove ugly hacks handling context destruction. * app/tools/gimptool.c: removed COMPAT_CRUFT and useless #include's.
2001-05-07 00:14:34 +08:00
enum
{
DOCKABLE_ADDED,
DOCKABLE_REMOVED,
DOCKABLE_REORDERED,
LAST_SIGNAL
};
struct _GimpDockbookPrivate
{
GimpDock *dock;
GimpUIManager *ui_manager;
guint tab_hover_timeout;
GimpDockable *tab_hover_dockable;
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND Make drag-and-drop rearrangement of dockables happen directly in the existing widget hierarchy so we don't have to use special, ugly widgets (read GimpDockSeparator:s) for that. More specifically, make edges of dockables and dockbooks have the same semantics as the GimpDockSeparators had. We put a highlight colored GdkWindow on top of the widget in question to highlight these special drop areas. This GdkWindow is not taken into consideration in the GTK+ drag-and-drop code, so it does not interupt the DND interaction. To achive this, there is a problem we must solve: Drag events in GTK+ are propagated inwards and out, but we sometimes want ancenstor widgets to take care of drop events. We solve this by introducing the concept of "drag handlers". A drag handler is asked if it will handle a given drag event, and if it will, a client will let the drag event be propagated upwards in the widget hierarchy. Right now, the GimpPanedBox is the only "drag handler". The code could be generalized more but it doesn't feel worth it at this point. The size of the special drop area is 5px, the same size as the default GtkPaned handles. This is because the plan is to later use these handles as drop areas too. Other changes of interest are: * We need to take care of "drag-motion", "drag-drop" and widget highlightning ourselves. We can not use the GtkDestDefaults conveniences with gtk_drag_dest_set() any longer since we need more control. * Make the drop callback pass the insert index directly instead of a GimpDockSeparator * Add some GIMP_LOG() debug output for DND * Disable the GimpDockSeparator code in GimpToolbox
2009-11-30 01:22:12 +08:00
GimpPanedBox *drag_handler;
/* Cache for "what actual tab style for automatic styles can we use
* for a given dockbook width
*/
gint min_width_for_style[GIMP_N_TAB_STYLE_CANDIDATES];
/* We need a list separate from the GtkContainer children list,
* because we need to do calculations for all dockables before we
* can add a dockable as a child, namely automatic tab style
* calculations
*/
GList *dockables;
GtkWidget *menu_button;
};
static void gimp_dockbook_dispose (GObject *object);
static void gimp_dockbook_finalize (GObject *object);
static void gimp_dockbook_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gimp_dockbook_style_set (GtkWidget *widget,
GtkStyle *prev_style);
static void gimp_dockbook_drag_leave (GtkWidget *widget,
GdkDragContext *context,
guint time);
static gboolean gimp_dockbook_drag_motion (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time);
static gboolean gimp_dockbook_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time);
static gboolean gimp_dockbook_popup_menu (GtkWidget *widget);
static gboolean gimp_dockbook_menu_button_press (GimpDockbook *dockbook,
GdkEventButton *bevent,
GtkWidget *button);
static gboolean gimp_dockbook_show_menu (GimpDockbook *dockbook);
static void gimp_dockbook_menu_end (GimpDockable *dockable);
static void gimp_dockbook_dockable_added (GimpDockbook *dockbook,
GimpDockable *dockable);
static void gimp_dockbook_dockable_removed (GimpDockbook *dockbook,
GimpDockable *dockable);
static void gimp_dockbook_recreate_tab_widgets (GimpDockbook *dockbook,
gboolean only_auto);
static void gimp_dockbook_tab_drag_source_setup (GtkWidget *widget,
GimpDockable *dockable);
static void gimp_dockbook_tab_drag_begin (GtkWidget *widget,
GdkDragContext *context,
GimpDockable *dockable);
static void gimp_dockbook_tab_drag_end (GtkWidget *widget,
GdkDragContext *context,
GimpDockable *dockable);
static void gimp_dockbook_tab_drag_leave (GtkWidget *widget,
GdkDragContext *context,
guint time,
GimpDockable *dockable);
static gboolean gimp_dockbook_tab_drag_motion (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
GimpDockable *dockable);
static gboolean gimp_dockbook_tab_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time);
static GimpTabStyle gimp_dockbook_tab_style_to_prefered (GimpTabStyle tab_style,
GimpDockable *dockable);
static void gimp_dockbook_refresh_tab_layout_lut (GimpDockbook *dockbook);
static void gimp_dockbook_update_automatic_tab_style (GimpDockbook *dockbook);
static GtkWidget * gimp_dockable_create_event_box_tab_widget (GimpDockable *dockable,
GimpContext *context,
GimpTabStyle tab_style,
GtkIconSize size);
static GtkIconSize gimp_dockbook_get_tab_icon_size (GimpDockbook *dockbook);
static void gimp_dockbook_add_tab_timeout (GimpDockbook *dockbook,
GimpDockable *dockable);
static void gimp_dockbook_remove_tab_timeout (GimpDockbook *dockbook);
static gboolean gimp_dockbook_tab_timeout (GimpDockbook *dockbook);
static void gimp_dockbook_tab_locked_notify (GimpDockable *dockable,
GParamSpec *pspec,
GimpDockbook *dockbook);
static void gimp_dockbook_help_func (const gchar *help_id,
gpointer help_data);
static const gchar *gimp_dockbook_get_tab_style_name (GimpTabStyle tab_style);
G_DEFINE_TYPE (GimpDockbook, gimp_dockbook, GTK_TYPE_NOTEBOOK)
#define parent_class gimp_dockbook_parent_class
static guint dockbook_signals[LAST_SIGNAL] = { 0 };
static const GtkTargetEntry dialog_target_table[] = { GIMP_TARGET_DIALOG };
/* List of candidates for the automatic style, starting with the
* biggest first
*/
static GimpTabStyle gimp_tab_style_candidates[] =
{
GIMP_TAB_STYLE_PREVIEW_BLURB,
GIMP_TAB_STYLE_PREVIEW_NAME,
GIMP_TAB_STYLE_PREVIEW,
};
static void
gimp_dockbook_class_init (GimpDockbookClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
if (G_N_ELEMENTS (gimp_tab_style_candidates) != GIMP_N_TAB_STYLE_CANDIDATES)
g_error ("Update GIMP_N_TAB_STYLE_CANDIDATES");
dockbook_signals[DOCKABLE_ADDED] =
g_signal_new ("dockable-added",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpDockbookClass, dockable_added),
NULL, NULL,
gimp_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
GIMP_TYPE_DOCKABLE);
dockbook_signals[DOCKABLE_REMOVED] =
g_signal_new ("dockable-removed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpDockbookClass, dockable_removed),
NULL, NULL,
gimp_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
GIMP_TYPE_DOCKABLE);
dockbook_signals[DOCKABLE_REORDERED] =
g_signal_new ("dockable-reordered",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpDockbookClass, dockable_reordered),
NULL, NULL,
gimp_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
GIMP_TYPE_DOCKABLE);
object_class->dispose = gimp_dockbook_dispose;
object_class->finalize = gimp_dockbook_finalize;
widget_class->size_allocate = gimp_dockbook_size_allocate;
widget_class->style_set = gimp_dockbook_style_set;
widget_class->drag_leave = gimp_dockbook_drag_leave;
widget_class->drag_motion = gimp_dockbook_drag_motion;
widget_class->drag_drop = gimp_dockbook_drag_drop;
widget_class->popup_menu = gimp_dockbook_popup_menu;
klass->dockable_added = gimp_dockbook_dockable_added;
klass->dockable_removed = gimp_dockbook_dockable_removed;
klass->dockable_reordered = NULL;
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("tab-border",
NULL, NULL,
0, G_MAXINT,
DEFAULT_TAB_BORDER,
GIMP_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_enum ("tab-icon-size",
NULL, NULL,
GTK_TYPE_ICON_SIZE,
DEFAULT_TAB_ICON_SIZE,
GIMP_PARAM_READABLE));
g_type_class_add_private (klass, sizeof (GimpDockbookPrivate));
}
static void
gimp_dockbook_init (GimpDockbook *dockbook)
{
GtkNotebook *notebook = GTK_NOTEBOOK (dockbook);
GtkWidget *image = NULL;
dockbook->p = G_TYPE_INSTANCE_GET_PRIVATE (dockbook,
GIMP_TYPE_DOCKBOOK,
GimpDockbookPrivate);
/* Various init */
gtk_notebook_popup_enable (notebook);
gtk_notebook_set_scrollable (notebook, TRUE);
gtk_notebook_set_show_border (notebook, FALSE);
gtk_notebook_set_show_tabs (notebook, TRUE);
gtk_drag_dest_set (GTK_WIDGET (dockbook),
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND Make drag-and-drop rearrangement of dockables happen directly in the existing widget hierarchy so we don't have to use special, ugly widgets (read GimpDockSeparator:s) for that. More specifically, make edges of dockables and dockbooks have the same semantics as the GimpDockSeparators had. We put a highlight colored GdkWindow on top of the widget in question to highlight these special drop areas. This GdkWindow is not taken into consideration in the GTK+ drag-and-drop code, so it does not interupt the DND interaction. To achive this, there is a problem we must solve: Drag events in GTK+ are propagated inwards and out, but we sometimes want ancenstor widgets to take care of drop events. We solve this by introducing the concept of "drag handlers". A drag handler is asked if it will handle a given drag event, and if it will, a client will let the drag event be propagated upwards in the widget hierarchy. Right now, the GimpPanedBox is the only "drag handler". The code could be generalized more but it doesn't feel worth it at this point. The size of the special drop area is 5px, the same size as the default GtkPaned handles. This is because the plan is to later use these handles as drop areas too. Other changes of interest are: * We need to take care of "drag-motion", "drag-drop" and widget highlightning ourselves. We can not use the GtkDestDefaults conveniences with gtk_drag_dest_set() any longer since we need more control. * Make the drop callback pass the insert index directly instead of a GimpDockSeparator * Add some GIMP_LOG() debug output for DND * Disable the GimpDockSeparator code in GimpToolbox
2009-11-30 01:22:12 +08:00
0,
app/gimpprogress.[ch] s/GDisplay/GimpDisplay/ 2001-10-16 Michael Natterer <mitch@gimp.org> * app/gimpprogress.[ch] * app/undo.c: s/GDisplay/GimpDisplay/ * app/plug_in.[ch]: removed unused boolean "destroy" field of the PlugIn struct. * app/core/gimpedit.c: don't include "app_procs.h" * app/display/gimpdisplay-callbacks.c: moved the "grab_abd_scroll" stuff from gimpdisplay-scroll.* here (less complicated and easier to cleanup...) * app/display/gimpdisplay-scroll.[ch]: removed here. * app/display/gimpdisplay-render.[ch] * app/display/gimpdisplay-selection.[ch] * app/display/gimpdisplayshell.c: s/GDisplay/GimpDisplay/g * app/display/gimpdisplay.[ch]: ditto, removed gdisplay_active() which was just a wrapper around "gimp_context_get_display (gimp_get_user_context (the_gimp))" (which is more to type but makes the use of the global "the_gimp" variable more obvious). * app/gui/color-area.h * app/gui/edit-commands.c * app/gui/file-commands.c * app/gui/file-dialog-utils.c * app/gui/image-commands.c * app/gui/info-window.h * app/gui/paths-dialog.h * app/gui/select-commands.c * app/gui/tool-options-dialog.c * app/gui/tools-commands.c * app/gui/view-commands.c: s/GDisplay/GimpDisplay/, gdisplay_active() removal, include "app_procs.h" for "the_gimp". * app/tools/gimpbezierselecttool.h * app/tools/gimpbrightnesscontrasttool.[ch] * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.[ch] * app/tools/gimpcurvestool.[ch] * app/tools/gimpeditselectiontool.h * app/tools/gimphistogramtool.[ch] * app/tools/gimphuesaturationtool.[ch] * app/tools/gimplevelstool.[ch] * app/tools/gimpmovetool.h * app/tools/gimpperspectivetool.h * app/tools/gimpposterizetool.[ch] * app/tools/gimprotatetool.h * app/tools/gimpscaletool.h * app/tools/gimpsheartool.h * app/tools/gimptexttool.h * app/tools/gimpthresholdtool.[ch] * app/tools/gimptool.[ch] * app/tools/gimptransformtool.h * app/tools/tool_manager.[ch]: lots of s/GDisplay/GimpDisplay/, made all *_dialog_hide() functions private, cleanup. * app/widgets/*: removed GtkType and gtk_type_* stuff entirely and use GObject functions, removed lots of empty "destroy" methods and use more type checking class cast macros instead of casting directly. * app/widgets/gimpcontainermenu.c: fixed item insert order. * app/widgets/gimphistogramview.[ch]: cleaned up and renamed all functions. * app/widgets/gimpwidgets-utils.[ch]: removed gimp_dialog_hide() as Gtk+ does the right thing (TM) now. * tools/pdbgen/pdb/color.pdb: implemented "histogram" without digging into tools/ and widgets/ (needs to be done for all color PDB functions). * tools/pdbgen/pdb/gimprc.pdb: no need to use "the_gimp" in a PDB function as a "Gimp" pointer is passed to them all. * tools/pdbgen/pdb/image.pdb: don't include "app_procs.h" * app/pdb/color_cmds.c * app/pdb/gimprc_cmds.c * app/pdb/image_cmds.c: regenerated. * app/pdb/procedural_db.c: don't include "app_procs.h"
2001-10-17 19:33:43 +08:00
dialog_target_table, G_N_ELEMENTS (dialog_target_table),
GDK_ACTION_MOVE);
/* Menu button */
dockbook->p->menu_button = gtk_button_new ();
gtk_widget_set_can_focus (dockbook->p->menu_button, FALSE);
gtk_button_set_relief (GTK_BUTTON (dockbook->p->menu_button),
GTK_RELIEF_NONE);
gtk_widget_show (dockbook->p->menu_button);
image = gtk_image_new_from_stock (GIMP_STOCK_MENU_LEFT, GTK_ICON_SIZE_MENU);
gtk_container_add (GTK_CONTAINER (dockbook->p->menu_button), image);
gtk_widget_show (image);
gimp_help_set_help_data (dockbook->p->menu_button, _("Configure this tab"),
GIMP_HELP_DOCK_TAB_MENU);
g_signal_connect_swapped (dockbook->p->menu_button, "button-press-event",
G_CALLBACK (gimp_dockbook_menu_button_press),
dockbook);
gtk_notebook_set_action_widget (notebook,
dockbook->p->menu_button,
GTK_PACK_END);
gtk_widget_show (dockbook->p->menu_button);
}
static void
gimp_dockbook_dispose (GObject *object)
{
GimpDockbook *dockbook = GIMP_DOCKBOOK (object);
gimp_dockbook_remove_tab_timeout (dockbook);
while (dockbook->p->dockables)
gimp_dockbook_remove (dockbook, dockbook->p->dockables->data);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
Move away from creating all item_factories statically in menus_init() but 2003-01-10 Michael Natterer <mitch@gimp.org> Move away from creating all item_factories statically in menus_init() but create a new one for each place where one is needed: * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpmenufactory.[ch]: new factory which creates and configures the GimpItemFactories it knows about on-the-fly. * app/widgets/gimpitemfactory.[ch]: added gimp_item_factory_update() which calls the "update_func". Added "gboolean update_on_popup" so item_factories can be configured to require manual updates (used for the <Image> factory). * app/gui/menus.[ch]: create a "global_menu_factory" and register all menus we have with it. Added various setup functions which do stuff like adding the "Open Recent" menu or reorder plug-in menu entries. Removed the debugging stuff... * app/gui/Makefile.am * app/gui/debug-commands.[ch]: ...and added it here. * app/gui/gui.c: create the <Toolbox>, the popup-<Image> and the <Paths> factories here because they are still global. * app/gui/plug-in-menus.[ch]: changed the "image_factory" parameters to "item_factory" and create/update the entries for the passed item_factory only. Makes the whole stuff much more straightforward. * app/plug-in/plug-ins.c: don't call plug_in_make_menu(). * app/display/gimpdisplay.[ch] * app/display/gimpdisplayshell.[ch]: added "menu_factory" and "popup_factory" parameters to gimp_display_new() and gimp_display_shell_new(). Create the menubar_factory and the qmask_factory dynamically. Pass the shell, not a Gimp to the QMask callbacks. Changed gimp_display_shell_set_menu_sensitivity() to gimp_display_shell_menu_update() and don't call it directly (it's a GimpItemFactory update_func now). Call gimp_item_factory_update() on the resp. factories instead. * app/gui/qmask-commands.c * app/display/gimpdisplayshell-callbacks.c * app/tools/gimpimagemaptool.c: changed accordingly. * app/widgets/gimpbrusheditor.c * app/widgets/gimpbrushfactoryview.[ch] * app/widgets/gimpbufferview.[ch] * app/widgets/gimpcolormapeditor.[ch] * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpdataeditor.[ch] * app/widgets/gimpdatafactoryview.[ch] * app/widgets/gimpdialogfactory.[ch] * app/widgets/gimpdock.c * app/widgets/gimpdockbook.[ch] * app/widgets/gimpdocumentview.[ch] * app/widgets/gimpgradienteditor.[ch] * app/widgets/gimpimageview.[ch] * app/widgets/gimpitemlistview.[ch] * app/widgets/gimppaletteeditor.[ch]: pass around lots of GimpMenuFactory pointers and menu_identifiers so all views can create their item_factories themselves. Unref the factories when they are no longer needed because they belong to the views now. * app/gui/dialogs-commands.c * app/gui/dialogs-constructors.c * app/gui/dialogs.c * app/gui/brush-select.c * app/gui/gradient-select.c * app/gui/palette-select.c * app/gui/pattern-select.c: changed accordingly. * app/gui/file-dialog-utils.[ch] (file_dialog_new): require menu_factory and menu_identifier parameters. * app/gui/file-open-dialog.[ch] * app/gui/file-save-dialog.[ch]: removed file_*_dialog_menu_init() (they went to menus.c as setup_funcs). Added file_*_dialog_set_type() and moved the <Load> and <Save> factory callbacks to file-commands.c * app/gui/file-commands.[ch]: changed accordingly. * app/gui/view-commands.c: changed the statusbar, menubar, rulers and guides callbacks to do their job only if the setting has actually changed. Don't update whole item factories afterwards. Instead, just change the state of the items that actually need update. Unrelated: * app/core/gimpchannel.c (gimp_channel_init): set "bounds_known" and friends to FALSE since we don't know that the new channel will be empty (fixes QMask and probably other stuff). * app/gui/image-commands.c * app/gui/vectors-commands.c: cleanup.
2003-01-11 01:55:53 +08:00
static void
gimp_dockbook_finalize (GObject *object)
{
GimpDockbook *dockbook = GIMP_DOCKBOOK (object);
Move away from creating all item_factories statically in menus_init() but 2003-01-10 Michael Natterer <mitch@gimp.org> Move away from creating all item_factories statically in menus_init() but create a new one for each place where one is needed: * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpmenufactory.[ch]: new factory which creates and configures the GimpItemFactories it knows about on-the-fly. * app/widgets/gimpitemfactory.[ch]: added gimp_item_factory_update() which calls the "update_func". Added "gboolean update_on_popup" so item_factories can be configured to require manual updates (used for the <Image> factory). * app/gui/menus.[ch]: create a "global_menu_factory" and register all menus we have with it. Added various setup functions which do stuff like adding the "Open Recent" menu or reorder plug-in menu entries. Removed the debugging stuff... * app/gui/Makefile.am * app/gui/debug-commands.[ch]: ...and added it here. * app/gui/gui.c: create the <Toolbox>, the popup-<Image> and the <Paths> factories here because they are still global. * app/gui/plug-in-menus.[ch]: changed the "image_factory" parameters to "item_factory" and create/update the entries for the passed item_factory only. Makes the whole stuff much more straightforward. * app/plug-in/plug-ins.c: don't call plug_in_make_menu(). * app/display/gimpdisplay.[ch] * app/display/gimpdisplayshell.[ch]: added "menu_factory" and "popup_factory" parameters to gimp_display_new() and gimp_display_shell_new(). Create the menubar_factory and the qmask_factory dynamically. Pass the shell, not a Gimp to the QMask callbacks. Changed gimp_display_shell_set_menu_sensitivity() to gimp_display_shell_menu_update() and don't call it directly (it's a GimpItemFactory update_func now). Call gimp_item_factory_update() on the resp. factories instead. * app/gui/qmask-commands.c * app/display/gimpdisplayshell-callbacks.c * app/tools/gimpimagemaptool.c: changed accordingly. * app/widgets/gimpbrusheditor.c * app/widgets/gimpbrushfactoryview.[ch] * app/widgets/gimpbufferview.[ch] * app/widgets/gimpcolormapeditor.[ch] * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpdataeditor.[ch] * app/widgets/gimpdatafactoryview.[ch] * app/widgets/gimpdialogfactory.[ch] * app/widgets/gimpdock.c * app/widgets/gimpdockbook.[ch] * app/widgets/gimpdocumentview.[ch] * app/widgets/gimpgradienteditor.[ch] * app/widgets/gimpimageview.[ch] * app/widgets/gimpitemlistview.[ch] * app/widgets/gimppaletteeditor.[ch]: pass around lots of GimpMenuFactory pointers and menu_identifiers so all views can create their item_factories themselves. Unref the factories when they are no longer needed because they belong to the views now. * app/gui/dialogs-commands.c * app/gui/dialogs-constructors.c * app/gui/dialogs.c * app/gui/brush-select.c * app/gui/gradient-select.c * app/gui/palette-select.c * app/gui/pattern-select.c: changed accordingly. * app/gui/file-dialog-utils.[ch] (file_dialog_new): require menu_factory and menu_identifier parameters. * app/gui/file-open-dialog.[ch] * app/gui/file-save-dialog.[ch]: removed file_*_dialog_menu_init() (they went to menus.c as setup_funcs). Added file_*_dialog_set_type() and moved the <Load> and <Save> factory callbacks to file-commands.c * app/gui/file-commands.[ch]: changed accordingly. * app/gui/view-commands.c: changed the statusbar, menubar, rulers and guides callbacks to do their job only if the setting has actually changed. Don't update whole item factories afterwards. Instead, just change the state of the items that actually need update. Unrelated: * app/core/gimpchannel.c (gimp_channel_init): set "bounds_known" and friends to FALSE since we don't know that the new channel will be empty (fixes QMask and probably other stuff). * app/gui/image-commands.c * app/gui/vectors-commands.c: cleanup.
2003-01-11 01:55:53 +08:00
if (dockbook->p->ui_manager)
{
g_object_unref (dockbook->p->ui_manager);
dockbook->p->ui_manager = NULL;
}
if (dockbook->p->menu_button)
{
gtk_widget_unparent (dockbook->p->menu_button);
dockbook->p->menu_button = NULL;
}
Move away from creating all item_factories statically in menus_init() but 2003-01-10 Michael Natterer <mitch@gimp.org> Move away from creating all item_factories statically in menus_init() but create a new one for each place where one is needed: * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpmenufactory.[ch]: new factory which creates and configures the GimpItemFactories it knows about on-the-fly. * app/widgets/gimpitemfactory.[ch]: added gimp_item_factory_update() which calls the "update_func". Added "gboolean update_on_popup" so item_factories can be configured to require manual updates (used for the <Image> factory). * app/gui/menus.[ch]: create a "global_menu_factory" and register all menus we have with it. Added various setup functions which do stuff like adding the "Open Recent" menu or reorder plug-in menu entries. Removed the debugging stuff... * app/gui/Makefile.am * app/gui/debug-commands.[ch]: ...and added it here. * app/gui/gui.c: create the <Toolbox>, the popup-<Image> and the <Paths> factories here because they are still global. * app/gui/plug-in-menus.[ch]: changed the "image_factory" parameters to "item_factory" and create/update the entries for the passed item_factory only. Makes the whole stuff much more straightforward. * app/plug-in/plug-ins.c: don't call plug_in_make_menu(). * app/display/gimpdisplay.[ch] * app/display/gimpdisplayshell.[ch]: added "menu_factory" and "popup_factory" parameters to gimp_display_new() and gimp_display_shell_new(). Create the menubar_factory and the qmask_factory dynamically. Pass the shell, not a Gimp to the QMask callbacks. Changed gimp_display_shell_set_menu_sensitivity() to gimp_display_shell_menu_update() and don't call it directly (it's a GimpItemFactory update_func now). Call gimp_item_factory_update() on the resp. factories instead. * app/gui/qmask-commands.c * app/display/gimpdisplayshell-callbacks.c * app/tools/gimpimagemaptool.c: changed accordingly. * app/widgets/gimpbrusheditor.c * app/widgets/gimpbrushfactoryview.[ch] * app/widgets/gimpbufferview.[ch] * app/widgets/gimpcolormapeditor.[ch] * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpdataeditor.[ch] * app/widgets/gimpdatafactoryview.[ch] * app/widgets/gimpdialogfactory.[ch] * app/widgets/gimpdock.c * app/widgets/gimpdockbook.[ch] * app/widgets/gimpdocumentview.[ch] * app/widgets/gimpgradienteditor.[ch] * app/widgets/gimpimageview.[ch] * app/widgets/gimpitemlistview.[ch] * app/widgets/gimppaletteeditor.[ch]: pass around lots of GimpMenuFactory pointers and menu_identifiers so all views can create their item_factories themselves. Unref the factories when they are no longer needed because they belong to the views now. * app/gui/dialogs-commands.c * app/gui/dialogs-constructors.c * app/gui/dialogs.c * app/gui/brush-select.c * app/gui/gradient-select.c * app/gui/palette-select.c * app/gui/pattern-select.c: changed accordingly. * app/gui/file-dialog-utils.[ch] (file_dialog_new): require menu_factory and menu_identifier parameters. * app/gui/file-open-dialog.[ch] * app/gui/file-save-dialog.[ch]: removed file_*_dialog_menu_init() (they went to menus.c as setup_funcs). Added file_*_dialog_set_type() and moved the <Load> and <Save> factory callbacks to file-commands.c * app/gui/file-commands.[ch]: changed accordingly. * app/gui/view-commands.c: changed the statusbar, menubar, rulers and guides callbacks to do their job only if the setting has actually changed. Don't update whole item factories afterwards. Instead, just change the state of the items that actually need update. Unrelated: * app/core/gimpchannel.c (gimp_channel_init): set "bounds_known" and friends to FALSE since we don't know that the new channel will be empty (fixes QMask and probably other stuff). * app/gui/image-commands.c * app/gui/vectors-commands.c: cleanup.
2003-01-11 01:55:53 +08:00
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_dockbook_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GimpDockbook *dockbook = GIMP_DOCKBOOK (widget);
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
/* Update tab styles, also recreates if changed */
gimp_dockbook_update_automatic_tab_style (dockbook);
}
static void
gimp_dockbook_style_set (GtkWidget *widget,
GtkStyle *prev_style)
{
gint tab_border;
GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
/* Don't attempt to construct widgets that require a GimpContext if
* we are detached from a top-level, we're either on our way to
* destruction, in which case we don't care, or we will be given a
* new parent, in which case the widget style will be reset again
* anyway, i.e. this function will be called again
*/
if (! gtk_widget_is_toplevel (gtk_widget_get_toplevel (widget)))
return;
gtk_widget_style_get (widget,
"tab-border", &tab_border,
NULL);
g_object_set (widget,
"tab-border", tab_border,
CPPFLAGS: added -DGTK_DISABLE_DEPRECATED 2002-01-25 Michael Natterer <mitch@gimp.org> * configure.in: CPPFLAGS: added -DGTK_DISABLE_DEPRECATED * libgimpwidgets/gimpdialog.c: still use the deprecated gtk_window_set_policy() but spit out a #warning. * app/widgets/widgets-types.h * app/widgets/gimpitemfactory.[ch]: made it a GtkItemFactory subclass. This way we can reproduce the effect of gtk_item_factory_get_from_path() which is deprectated for good reasons. For GIMP, using it its perfectly OK since we only have one item factory per "<prefix>". * app/widgets/gimpbrushfactoryview.[ch] * app/widgets/gimpbufferview.[ch] * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpdatafactoryview.[ch] * app/widgets/gimpdialogfactory.[ch] * app/widgets/gimpdock.c * app/widgets/gimpdockbook.c * app/widgets/gimpdocumentview.[ch] * app/widgets/gimpdrawablelistview.[ch] * app/widgets/gimppreview.c * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell.[ch]: pass around GimpItemFactory pointers instead of "const gchar *" item factory identifiers. Replaced gtk_window_set_policy() by gtk_window_set_resizable() and other recommended stuff. * app/gui/about-dialog.c * app/gui/dialogs-constructors.c * app/gui/dialogs.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/menus.c * app/gui/offset-dialog.c * app/gui/splash.c * app/gui/tips-dialog.c * app/gui/toolbox.c: lots of s/gtk_item_factory_from_path/gimp_item_factory_from_path/, gtk_window_set_policy() replacements, misc fixes. * plug-ins/gdyntext/charmap_window.c * plug-ins/gdyntext/gdyntext_ui.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_main.c: replaced gtk_window_set_policy().
2002-01-26 02:34:33 +08:00
NULL);
gimp_dockbook_recreate_tab_widgets (GIMP_DOCKBOOK (widget),
FALSE /*only_auto*/);
}
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND Make drag-and-drop rearrangement of dockables happen directly in the existing widget hierarchy so we don't have to use special, ugly widgets (read GimpDockSeparator:s) for that. More specifically, make edges of dockables and dockbooks have the same semantics as the GimpDockSeparators had. We put a highlight colored GdkWindow on top of the widget in question to highlight these special drop areas. This GdkWindow is not taken into consideration in the GTK+ drag-and-drop code, so it does not interupt the DND interaction. To achive this, there is a problem we must solve: Drag events in GTK+ are propagated inwards and out, but we sometimes want ancenstor widgets to take care of drop events. We solve this by introducing the concept of "drag handlers". A drag handler is asked if it will handle a given drag event, and if it will, a client will let the drag event be propagated upwards in the widget hierarchy. Right now, the GimpPanedBox is the only "drag handler". The code could be generalized more but it doesn't feel worth it at this point. The size of the special drop area is 5px, the same size as the default GtkPaned handles. This is because the plan is to later use these handles as drop areas too. Other changes of interest are: * We need to take care of "drag-motion", "drag-drop" and widget highlightning ourselves. We can not use the GtkDestDefaults conveniences with gtk_drag_dest_set() any longer since we need more control. * Make the drop callback pass the insert index directly instead of a GimpDockSeparator * Add some GIMP_LOG() debug output for DND * Disable the GimpDockSeparator code in GimpToolbox
2009-11-30 01:22:12 +08:00
static void
gimp_dockbook_drag_leave (GtkWidget *widget,
GdkDragContext *context,
guint time)
{
gimp_highlight_widget (widget, FALSE);
}
static gboolean
gimp_dockbook_drag_motion (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time)
{
GimpDockbook *dockbook = GIMP_DOCKBOOK (widget);
gboolean other_will_handle = FALSE;
other_will_handle = gimp_paned_box_will_handle_drag (dockbook->p->drag_handler,
widget,
context,
x, y,
time);
gdk_drag_status (context, other_will_handle ? 0 : GDK_ACTION_MOVE, time);
gimp_highlight_widget (widget, ! other_will_handle);
return other_will_handle ? FALSE : TRUE;
}
static gboolean
gimp_dockbook_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time)
{
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND Make drag-and-drop rearrangement of dockables happen directly in the existing widget hierarchy so we don't have to use special, ugly widgets (read GimpDockSeparator:s) for that. More specifically, make edges of dockables and dockbooks have the same semantics as the GimpDockSeparators had. We put a highlight colored GdkWindow on top of the widget in question to highlight these special drop areas. This GdkWindow is not taken into consideration in the GTK+ drag-and-drop code, so it does not interupt the DND interaction. To achive this, there is a problem we must solve: Drag events in GTK+ are propagated inwards and out, but we sometimes want ancenstor widgets to take care of drop events. We solve this by introducing the concept of "drag handlers". A drag handler is asked if it will handle a given drag event, and if it will, a client will let the drag event be propagated upwards in the widget hierarchy. Right now, the GimpPanedBox is the only "drag handler". The code could be generalized more but it doesn't feel worth it at this point. The size of the special drop area is 5px, the same size as the default GtkPaned handles. This is because the plan is to later use these handles as drop areas too. Other changes of interest are: * We need to take care of "drag-motion", "drag-drop" and widget highlightning ourselves. We can not use the GtkDestDefaults conveniences with gtk_drag_dest_set() any longer since we need more control. * Make the drop callback pass the insert index directly instead of a GimpDockSeparator * Add some GIMP_LOG() debug output for DND * Disable the GimpDockSeparator code in GimpToolbox
2009-11-30 01:22:12 +08:00
GimpDockbook *dockbook = GIMP_DOCKBOOK (widget);
gboolean handled = FALSE;
if (gimp_paned_box_will_handle_drag (dockbook->p->drag_handler,
widget,
context,
x, y,
time))
{
/* Make event fall through to the drag handler */
handled = FALSE;
}
else
{
handled =
gimp_dockbook_drop_dockable (dockbook,
gtk_drag_get_source_widget (context));
}
/* We must call gtk_drag_finish() ourselves */
if (handled)
gtk_drag_finish (context, TRUE, TRUE, time);
return handled;
}
static gboolean
gimp_dockbook_popup_menu (GtkWidget *widget)
{
return gimp_dockbook_show_menu (GIMP_DOCKBOOK (widget));
}
static gboolean
gimp_dockbook_menu_button_press (GimpDockbook *dockbook,
GdkEventButton *bevent,
GtkWidget *button)
{
gboolean handled = FALSE;
if (bevent->button == 1 && bevent->type == GDK_BUTTON_PRESS)
handled = gimp_dockbook_show_menu (dockbook);
return handled;
}
static void
gimp_dockbook_menu_position (GtkMenu *menu,
gint *x,
gint *y,
gpointer data)
{
GimpDockbook *dockbook = GIMP_DOCKBOOK (data);
gimp_button_menu_position (dockbook->p->menu_button, menu, GTK_POS_LEFT, x, y);
}
static gboolean
gimp_dockbook_show_menu (GimpDockbook *dockbook)
{
GimpUIManager *dockbook_ui_manager = NULL;
GimpUIManager *dialog_ui_manager = NULL;
const gchar *dialog_ui_path = NULL;
gpointer dialog_popup_data = FALSE;
GtkWidget *parent_menu_widget = NULL;
GtkAction *parent_menu_action = NULL;
GimpDockable *dockable = NULL;
gint page_num = -1;
dockbook_ui_manager = gimp_dockbook_get_ui_manager (dockbook);
if (! dockbook_ui_manager)
return FALSE;
parent_menu_widget =
gtk_ui_manager_get_widget (GTK_UI_MANAGER (dockbook_ui_manager),
"/dockable-popup/dockable-menu");
parent_menu_action =
gtk_ui_manager_get_action (GTK_UI_MANAGER (dockbook_ui_manager),
"/dockable-popup/dockable-menu");
if (! parent_menu_widget || ! parent_menu_action)
return FALSE;
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
dockable = GIMP_DOCKABLE (gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook),
page_num));
if (! dockable)
return FALSE;
dialog_ui_manager = gimp_dockable_get_menu (dockable,
&dialog_ui_path,
&dialog_popup_data);
if (dialog_ui_manager && dialog_ui_path)
{
GtkWidget *child_menu_widget;
GtkAction *child_menu_action;
gchar *label;
child_menu_widget =
gtk_ui_manager_get_widget (GTK_UI_MANAGER (dialog_ui_manager),
dialog_ui_path);
if (! child_menu_widget)
{
g_warning ("%s: UI manager '%s' has now widget at path '%s'",
G_STRFUNC, dialog_ui_manager->name, dialog_ui_path);
return FALSE;
}
child_menu_action =
gtk_ui_manager_get_action (GTK_UI_MANAGER (dialog_ui_manager),
dialog_ui_path);
if (! child_menu_action)
{
g_warning ("%s: UI manager '%s' has no action at path '%s'",
G_STRFUNC, dialog_ui_manager->name, dialog_ui_path);
return FALSE;
}
g_object_get (child_menu_action,
"label", &label,
NULL);
g_object_set (parent_menu_action,
"label", label,
"stock-id", gimp_dockable_get_stock_id (dockable),
"visible", TRUE,
NULL);
g_free (label);
if (gimp_dockable_get_stock_id (dockable))
{
if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default (),
gimp_dockable_get_stock_id (dockable)))
{
gtk_action_set_icon_name (parent_menu_action,
gimp_dockable_get_stock_id (dockable));
}
}
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;
}
{
GtkWidget *image = gimp_dockable_get_icon (dockable,
GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (parent_menu_widget),
image);
gtk_widget_show (image);
}
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);
}
/* an action callback may destroy both dockable and dockbook, so
* reference them for gimp_dockbook_menu_end()
*/
g_object_ref (dockable);
g_object_set_data_full (G_OBJECT (dockable), GIMP_DOCKABLE_DETACH_REF_KEY,
g_object_ref (dockbook),
g_object_unref);
gimp_ui_manager_update (dockbook_ui_manager, dockable);
gimp_ui_manager_ui_popup (dockbook_ui_manager, "/dockable-popup",
GTK_WIDGET (dockable),
gimp_dockbook_menu_position, dockbook,
(GDestroyNotify) gimp_dockbook_menu_end, dockable);
return TRUE;
}
static void
gimp_dockbook_menu_end (GimpDockable *dockable)
{
GimpUIManager *dialog_ui_manager;
const gchar *dialog_ui_path;
gpointer dialog_popup_data;
dialog_ui_manager = gimp_dockable_get_menu (dockable,
&dialog_ui_path,
&dialog_popup_data);
if (dialog_ui_manager && dialog_ui_path)
{
GtkWidget *child_menu_widget =
gtk_ui_manager_get_widget (GTK_UI_MANAGER (dialog_ui_manager),
dialog_ui_path);
if (child_menu_widget)
gtk_menu_detach (GTK_MENU (child_menu_widget));
}
/* release gimp_dockbook_show_menu()'s references */
g_object_set_data (G_OBJECT (dockable), GIMP_DOCKABLE_DETACH_REF_KEY, NULL);
g_object_unref (dockable);
}
static void
gimp_dockbook_dockable_added (GimpDockbook *dockbook,
GimpDockable *dockable)
{
gtk_notebook_set_current_page (GTK_NOTEBOOK (dockbook),
gtk_notebook_page_num (GTK_NOTEBOOK (dockbook),
GTK_WIDGET (dockable)));
}
static void
gimp_dockbook_dockable_removed (GimpDockbook *dockbook,
GimpDockable *dockable)
{
}
/**
* gimp_dockbook_get_dockable_tab_width:
* @dockable:
* @tab_style:
*
* Returns: Width of tab when the dockable is using the specified tab
* style.
**/
static gint
gimp_dockbook_get_dockable_tab_width (GimpDockbook *dockbook,
GimpDockable *dockable,
GimpTabStyle tab_style)
{
GtkRequisition dockable_request;
GtkWidget *tab_widget;
tab_widget =
gimp_dockable_create_event_box_tab_widget (dockable,
gimp_dock_get_context (dockbook->p->dock),
tab_style,
gimp_dockbook_get_tab_icon_size (dockbook));
/* So font-scale is applied. We can't apply styles without having a
* GdkScreen :(
*/
gimp_dock_temp_add (dockbook->p->dock, tab_widget);
gtk_widget_size_request (tab_widget, &dockable_request);
/* Also destroys the widget */
gimp_dock_temp_remove (dockbook->p->dock, tab_widget);
return dockable_request.width;
}
/**
* gimp_dockbook_tab_style_to_prefered:
* @tab_style:
* @dockable:
*
* The list of tab styles to try in automatic mode only consists of
* preview styles. For some dockables, like the tool options dockable,
* we rather want to use the icon tab styles for the automatic
* mode. This function is used to convert tab styles for such
* dockables.
*
* Returns: An icon tab style if the dockable prefers icon tab styles
* in automatic mode.
**/
static GimpTabStyle
gimp_dockbook_tab_style_to_prefered (GimpTabStyle tab_style,
GimpDockable *dockable)
{
GimpDocked *docked = GIMP_DOCKED (gtk_bin_get_child (GTK_BIN (dockable)));
if (gimp_docked_get_prefer_icon (docked))
tab_style = gimp_preview_tab_style_to_icon (tab_style);
return tab_style;
}
/**
* gimp_dockbook_refresh_tab_layout_lut:
* @dockbook:
*
* For each given set of tab widgets, there is a fixed mapping between
* the width of the dockbook and the actual tab style to use for auto
* tab widgets. This function refreshes that look-up table.
**/
static void
gimp_dockbook_refresh_tab_layout_lut (GimpDockbook *dockbook)
{
GList *auto_dockables = NULL;
GList *iter = NULL;
gint fixed_tab_style_space = 0;
int i = 0;
/* Calculate space taken by dockables with fixed tab styles */
fixed_tab_style_space = 0;
for (iter = dockbook->p->dockables; iter; iter = g_list_next (iter))
{
GimpDockable *dockable = GIMP_DOCKABLE (iter->data);
GimpTabStyle tab_style = gimp_dockable_get_tab_style (dockable);
if (tab_style == GIMP_TAB_STYLE_AUTOMATIC)
auto_dockables = g_list_prepend (auto_dockables, dockable);
else
fixed_tab_style_space +=
gimp_dockbook_get_dockable_tab_width (dockbook,
dockable,
tab_style);
}
/* Calculate space taken with auto tab style for all candidates */
for (i = 0; i < GIMP_N_TAB_STYLE_CANDIDATES; i++)
{
gint size_with_candidate = 0;
GimpTabStyle candidate = gimp_tab_style_candidates[i];
for (iter = auto_dockables; iter; iter = g_list_next (iter))
{
GimpDockable *dockable = GIMP_DOCKABLE (iter->data);
GimpTabStyle style_to_use;
style_to_use = gimp_dockbook_tab_style_to_prefered (candidate,
dockable);
size_with_candidate +=
gimp_dockbook_get_dockable_tab_width (dockbook,
dockable,
style_to_use);
}
dockbook->p->min_width_for_style[i] =
fixed_tab_style_space + size_with_candidate;
GIMP_LOG (AUTO_TAB_STYLE, "Total tab space taken for auto tab style %s = %d",
gimp_dockbook_get_tab_style_name (candidate),
dockbook->p->min_width_for_style[i]);
}
g_list_free (auto_dockables);
}
/**
* gimp_dockbook_update_automatic_tab_style:
* @dockbook:
*
* Based on widget allocation, sets actual tab style for dockables
* with automatic tab styles. Takes care of recreating tab widgets if
* necessary.
**/
static void
gimp_dockbook_update_automatic_tab_style (GimpDockbook *dockbook)
{
GtkWidget *widget = GTK_WIDGET (dockbook);
gboolean changed = FALSE;
GList *iter = NULL;
GtkAllocation dockbook_allocation = { 0, };
GtkAllocation button_allocation = { 0, };
GimpTabStyle tab_style = 0;
int i = 0;
gint available_space = 0;
guint tab_hborder = 0;
gint xthickness = 0;
gint tab_curvature = 0;
gint focus_width = 0;
gint tab_overlap = 0;
gint tab_padding = 0;
gint border_loss = 0;
gint action_widget_size = 0;
xthickness = gtk_widget_get_style (widget)->xthickness;
g_object_get (widget,
"tab-hborder", &tab_hborder,
NULL);
gtk_widget_style_get (widget,
"tab-curvature", &tab_curvature,
"focus-line-width", &focus_width,
"tab-overlap", &tab_overlap,
NULL);
gtk_widget_get_allocation (dockbook->p->menu_button,
&button_allocation);
/* Calculate available space. Based on code in GTK+ internal
* functions gtk_notebook_size_request() and
* gtk_notebook_pages_allocate()
*/
gtk_widget_get_allocation (widget, &dockbook_allocation);
/* Border on both sides */
border_loss = gtk_container_get_border_width (GTK_CONTAINER (dockbook)) * 2;
/* Space taken by action widget */
action_widget_size = button_allocation.width + xthickness;
/* Space taken by the tabs but not the tab widgets themselves */
tab_padding = gtk_notebook_get_n_pages (GTK_NOTEBOOK (dockbook)) *
(2 * (xthickness + tab_curvature + focus_width + tab_hborder) -
tab_overlap);
available_space = dockbook_allocation.width
- border_loss
- action_widget_size
- tab_padding
- tab_overlap;
GIMP_LOG (AUTO_TAB_STYLE, "\n"
" available_space = %d where\n"
" dockbook_allocation.width = %d\n"
" border_loss = %d\n"
" action_widget_size = %d\n"
" tab_padding = %d\n"
" tab_overlap = %d\n",
available_space,
dockbook_allocation.width,
border_loss,
action_widget_size,
tab_padding,
tab_overlap);
/* Try all candidates, if we don't get any hit we still end up on
* the smallest style (which we always fall back to if we don't get
* a better match)
*/
for (i = 0; i < GIMP_N_TAB_STYLE_CANDIDATES; i++)
{
tab_style = gimp_tab_style_candidates[i];
if (available_space > dockbook->p->min_width_for_style[i])
{
GIMP_LOG (AUTO_TAB_STYLE, "Choosing tab style %s",
gimp_dockbook_get_tab_style_name (tab_style));
break;
}
}
for (iter = dockbook->p->dockables; iter; iter = g_list_next (iter))
{
GimpDockable *dockable = GIMP_DOCKABLE (iter->data);
GimpTabStyle actual_tab_style = tab_style;
if (gimp_dockable_get_tab_style (dockable) != GIMP_TAB_STYLE_AUTOMATIC)
continue;
actual_tab_style = gimp_dockbook_tab_style_to_prefered (tab_style,
dockable);
if (gimp_dockable_set_actual_tab_style (dockable, actual_tab_style))
changed = TRUE;
}
if (changed)
gimp_dockbook_recreate_tab_widgets (dockbook,
TRUE /*only_auto*/);
}
GtkWidget *
gimp_dockbook_new (GimpMenuFactory *menu_factory)
{
GimpDockbook *dockbook;
g_return_val_if_fail (GIMP_IS_MENU_FACTORY (menu_factory), NULL);
dockbook = g_object_new (GIMP_TYPE_DOCKBOOK, NULL);
dockbook->p->ui_manager = gimp_menu_factory_manager_new (menu_factory,
"<Dockable>",
dockbook,
FALSE);
gimp_help_connect (GTK_WIDGET (dockbook), gimp_dockbook_help_func,
GIMP_HELP_DOCK, dockbook);
return GTK_WIDGET (dockbook);
}
GimpDock *
gimp_dockbook_get_dock (GimpDockbook *dockbook)
{
g_return_val_if_fail (GIMP_IS_DOCKBOOK (dockbook), NULL);
return dockbook->p->dock;
}
void
gimp_dockbook_set_dock (GimpDockbook *dockbook,
GimpDock *dock)
{
g_return_if_fail (GIMP_IS_DOCKBOOK (dockbook));
g_return_if_fail (dock == NULL || GIMP_IS_DOCK (dock));
dockbook->p->dock = dock;
}
GimpUIManager *
gimp_dockbook_get_ui_manager (GimpDockbook *dockbook)
{
g_return_val_if_fail (GIMP_IS_DOCKBOOK (dockbook), NULL);
return dockbook->p->ui_manager;
}
void
gimp_dockbook_add (GimpDockbook *dockbook,
GimpDockable *dockable,
gint position)
{
GtkWidget *tab_widget;
GtkWidget *menu_widget;
g_return_if_fail (GIMP_IS_DOCKBOOK (dockbook));
g_return_if_fail (dockbook->p->dock != NULL);
g_return_if_fail (GIMP_IS_DOCKABLE (dockable));
g_return_if_fail (gimp_dockable_get_dockbook (dockable) == NULL);
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND Make drag-and-drop rearrangement of dockables happen directly in the existing widget hierarchy so we don't have to use special, ugly widgets (read GimpDockSeparator:s) for that. More specifically, make edges of dockables and dockbooks have the same semantics as the GimpDockSeparators had. We put a highlight colored GdkWindow on top of the widget in question to highlight these special drop areas. This GdkWindow is not taken into consideration in the GTK+ drag-and-drop code, so it does not interupt the DND interaction. To achive this, there is a problem we must solve: Drag events in GTK+ are propagated inwards and out, but we sometimes want ancenstor widgets to take care of drop events. We solve this by introducing the concept of "drag handlers". A drag handler is asked if it will handle a given drag event, and if it will, a client will let the drag event be propagated upwards in the widget hierarchy. Right now, the GimpPanedBox is the only "drag handler". The code could be generalized more but it doesn't feel worth it at this point. The size of the special drop area is 5px, the same size as the default GtkPaned handles. This is because the plan is to later use these handles as drop areas too. Other changes of interest are: * We need to take care of "drag-motion", "drag-drop" and widget highlightning ourselves. We can not use the GtkDestDefaults conveniences with gtk_drag_dest_set() any longer since we need more control. * Make the drop callback pass the insert index directly instead of a GimpDockSeparator * Add some GIMP_LOG() debug output for DND * Disable the GimpDockSeparator code in GimpToolbox
2009-11-30 01:22:12 +08:00
GIMP_LOG (DND, "Adding GimpDockable %p to GimpDockbook %p", dockable, dockbook);
/* Add to internal list before doing automatic tab style
* calculations
*/
dockbook->p->dockables = g_list_insert (dockbook->p->dockables,
dockable,
position);
gimp_dockbook_update_auto_tab_style (dockbook);
/* Create the new tab widget, it will get the correct tab style now */
tab_widget = gimp_dockbook_create_tab_widget (dockbook, 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
g_return_if_fail (GTK_IS_WIDGET (tab_widget));
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND Make drag-and-drop rearrangement of dockables happen directly in the existing widget hierarchy so we don't have to use special, ugly widgets (read GimpDockSeparator:s) for that. More specifically, make edges of dockables and dockbooks have the same semantics as the GimpDockSeparators had. We put a highlight colored GdkWindow on top of the widget in question to highlight these special drop areas. This GdkWindow is not taken into consideration in the GTK+ drag-and-drop code, so it does not interupt the DND interaction. To achive this, there is a problem we must solve: Drag events in GTK+ are propagated inwards and out, but we sometimes want ancenstor widgets to take care of drop events. We solve this by introducing the concept of "drag handlers". A drag handler is asked if it will handle a given drag event, and if it will, a client will let the drag event be propagated upwards in the widget hierarchy. Right now, the GimpPanedBox is the only "drag handler". The code could be generalized more but it doesn't feel worth it at this point. The size of the special drop area is 5px, the same size as the default GtkPaned handles. This is because the plan is to later use these handles as drop areas too. Other changes of interest are: * We need to take care of "drag-motion", "drag-drop" and widget highlightning ourselves. We can not use the GtkDestDefaults conveniences with gtk_drag_dest_set() any longer since we need more control. * Make the drop callback pass the insert index directly instead of a GimpDockSeparator * Add some GIMP_LOG() debug output for DND * Disable the GimpDockSeparator code in GimpToolbox
2009-11-30 01:22:12 +08:00
gimp_dockable_set_drag_handler (dockable, dockbook->p->drag_handler);
/* For the notebook right-click menu, always use the icon style */
menu_widget =
gimp_dockable_create_tab_widget (dockable,
gimp_dock_get_context (dockbook->p->dock),
GIMP_TAB_STYLE_ICON_BLURB,
MENU_WIDGET_ICON_SIZE);
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
g_return_if_fail (GTK_IS_WIDGET (menu_widget));
if (position == -1)
{
gtk_notebook_append_page_menu (GTK_NOTEBOOK (dockbook),
GTK_WIDGET (dockable),
tab_widget,
menu_widget);
}
else
{
gtk_notebook_insert_page_menu (GTK_NOTEBOOK (dockbook),
GTK_WIDGET (dockable),
tab_widget,
menu_widget,
position);
}
gtk_widget_show (GTK_WIDGET (dockable));
gimp_dockable_set_dockbook (dockable, dockbook);
gimp_dockable_set_context (dockable, gimp_dock_get_context (dockbook->p->dock));
g_signal_connect (dockable, "notify::locked",
G_CALLBACK (gimp_dockbook_tab_locked_notify),
dockbook);
g_signal_emit (dockbook, dockbook_signals[DOCKABLE_ADDED], 0, dockable);
}
void
gimp_dockbook_remove (GimpDockbook *dockbook,
GimpDockable *dockable)
{
g_return_if_fail (GIMP_IS_DOCKBOOK (dockbook));
g_return_if_fail (GIMP_IS_DOCKABLE (dockable));
g_return_if_fail (gimp_dockable_get_dockbook (dockable) == dockbook);
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND Make drag-and-drop rearrangement of dockables happen directly in the existing widget hierarchy so we don't have to use special, ugly widgets (read GimpDockSeparator:s) for that. More specifically, make edges of dockables and dockbooks have the same semantics as the GimpDockSeparators had. We put a highlight colored GdkWindow on top of the widget in question to highlight these special drop areas. This GdkWindow is not taken into consideration in the GTK+ drag-and-drop code, so it does not interupt the DND interaction. To achive this, there is a problem we must solve: Drag events in GTK+ are propagated inwards and out, but we sometimes want ancenstor widgets to take care of drop events. We solve this by introducing the concept of "drag handlers". A drag handler is asked if it will handle a given drag event, and if it will, a client will let the drag event be propagated upwards in the widget hierarchy. Right now, the GimpPanedBox is the only "drag handler". The code could be generalized more but it doesn't feel worth it at this point. The size of the special drop area is 5px, the same size as the default GtkPaned handles. This is because the plan is to later use these handles as drop areas too. Other changes of interest are: * We need to take care of "drag-motion", "drag-drop" and widget highlightning ourselves. We can not use the GtkDestDefaults conveniences with gtk_drag_dest_set() any longer since we need more control. * Make the drop callback pass the insert index directly instead of a GimpDockSeparator * Add some GIMP_LOG() debug output for DND * Disable the GimpDockSeparator code in GimpToolbox
2009-11-30 01:22:12 +08:00
GIMP_LOG (DND, "Removing GimpDockable %p from GimpDockbook %p", dockable, dockbook);
gimp_dockable_set_drag_handler (dockable, NULL);
g_object_ref (dockable);
g_signal_handlers_disconnect_by_func (dockable,
G_CALLBACK (gimp_dockbook_tab_locked_notify),
dockbook);
if (dockbook->p->tab_hover_dockable == dockable)
gimp_dockbook_remove_tab_timeout (dockbook);
gimp_dockable_set_dockbook (dockable, NULL);
added GimpDropMode... ...removed from here. 2001-05-06 Michael Natterer <mitch@gimp.org> * app/appenums.h: added GimpDropMode... * app/gimpdnd.h: ...removed from here. * app/gimpimage.[ch]: - New signal "mode_changed". - removed "const GimpImage*" from gimp_image_colormap_changed() because a signal emission is never "const" for the object which emits the signal. - Fixed gimp_image_[set|get]_component_[active|visible](): ALPHA_CHANNEL maps to ALPHA_PIX only in RGB mode, use ALPHA_G_PIX/ALPHA_I_PIX in GRAY/INDEXED mode. * app/gimpimage-convert.c * app/undo.c: call gimp_image_mode_changed(). * app/gimpviewable.c: added an implementation of "invalidate_preview" which frees the preview temp_buf which may be attached to the viewable. Subclasses need to chain up now. * app/gimpdrawable.c * app/gimpimage.c: chain up in invalidate_preview(). * app/widgets/gimpchannellistview.c: connect to the image's "mode_changed" signal and rebuild the channel list in the callback. * app/widgets/gimpcontainerview.h: indentation. * app/widgets/gimpdockbook.c: set the dockable's context to NULL in gimp_dockbook_remove() * app/widgets/gimpimagedock.c: forgot to actually set the dock's image in gimp_image_dock_new(). * app/gui/dialogs-constructors.c: added a get_name_func() for tool views which returns the tool's "blurb". It's safe to assume now that a dockable's context will exist as long as the dockable exists unless it's explicitely set to NULL, so remove ugly hacks handling context destruction. * app/tools/gimptool.c: removed COMPAT_CRUFT and useless #include's.
2001-05-07 00:14:34 +08:00
gimp_dockable_set_context (dockable, NULL);
gtk_container_remove (GTK_CONTAINER (dockbook), GTK_WIDGET (dockable));
dockbook->p->dockables = g_list_remove (dockbook->p->dockables,
dockable);
g_signal_emit (dockbook, dockbook_signals[DOCKABLE_REMOVED], 0, dockable);
g_object_unref (dockable);
if (dockbook->p->dock)
{
GList *children = gtk_container_get_children (GTK_CONTAINER (dockbook));
if (children)
gimp_dockbook_update_auto_tab_style (dockbook);
else
gimp_dock_remove_book (dockbook->p->dock, dockbook);
g_list_free (children);
}
}
/**
* gimp_dockbook_update_with_context:
* @dockbook:
* @context:
*
* Set @context on all dockables in @dockbook.
**/
void
gimp_dockbook_update_with_context (GimpDockbook *dockbook,
GimpContext *context)
{
GList *children = gtk_container_get_children (GTK_CONTAINER (dockbook));
GList *iter = NULL;
for (iter = children;
iter;
iter = g_list_next (iter))
{
GimpDockable *dockable = GIMP_DOCKABLE (iter->data);
gimp_dockable_set_context (dockable, context);
}
g_list_free (children);
}
Added configurable styles for dockable tabs (fixes bug #87376): 2003-07-08 Michael Natterer <mitch@gimp.org> Added configurable styles for dockable tabs (fixes bug #87376): * app/widgets/widgets-enums.[ch]: added new enum GimpTabStyle which can be one on { ICON, NAME, ICON_NAME, ICON_BLURB }. * app/widgets/gimpdockable.[ch]: added a GimpTabStyle member to the GimpDockable struct which defaults to GIMP_TAB_STYLE_ICON. Renamed "short_name" to "name" and "name" to "blurb". Renamed GimpDockableGetTabFunc to GimpDockableGetIconFunc. Implemented all tab styles in gimp_dockable_real_get_tab_widget() and use the "get_icon_func" only for creating the tab's icon, not the entire tab widget. * app/widgets/gimpdockbook.[ch]: changed accordingly. Create the menu widgets and the DND icon using gimp_dockable_get_tab_widget() with tab_style == GIMP_TAB_STYLE_ICON_BLURB instead of duplicating tons of code. Made gimp_dockbook_get_tab_widget() public because it's needed for exchanging tabs on-the-fly. * app/widgets/gimpimagedock.c: changed accordingly. * app/widgets/gimpdialogfactory.c: remember the dockables' tab style in sessionrc. * app/gui/dialogs-menu.c: added a submenu to select the tab style for each dockable. * app/gui/dialogs-commands.[ch]: new callback dialogs_tab_style_cmd_callback(). * app/gui/dialogs-constructors.[ch]: added stock_ids to all dockables, swapped the "name" and "blurb" parameters, reordered functions, cleanup. * app/gui/dialogs-menu.c * app/gui/image-menu.c * app/gui/toolbox-menu.c: use GIMP_STOCK_DEFAULT_COLORS for the color editor dockable and renamed it to "FG/BG Color".
2003-07-08 23:07:56 +08:00
GtkWidget *
gimp_dockbook_create_tab_widget (GimpDockbook *dockbook,
GimpDockable *dockable)
{
GtkWidget *tab_widget;
GimpDockWindow *dock_window;
GtkAction *action = NULL;
tab_widget =
gimp_dockable_create_event_box_tab_widget (dockable,
gimp_dock_get_context (dockbook->p->dock),
gimp_dockable_get_actual_tab_style (dockable),
gimp_dockbook_get_tab_icon_size (dockbook));
/* EEK */
dock_window = gimp_dock_window_from_dock (dockbook->p->dock);
if (dock_window && gimp_dock_window_get_ui_manager (dock_window))
{
const gchar *dialog_id;
dialog_id = g_object_get_data (G_OBJECT (dockable),
"gimp-dialog-identifier");
if (dialog_id)
{
GimpActionGroup *group;
group = gimp_ui_manager_get_action_group
(gimp_dock_window_get_ui_manager (dock_window), "dialogs");
if (group)
{
GList *actions;
GList *list;
actions = gtk_action_group_list_actions (GTK_ACTION_GROUP (group));
for (list = actions; list; list = g_list_next (list))
{
if (GIMP_IS_STRING_ACTION (list->data) &&
strstr (GIMP_STRING_ACTION (list->data)->value,
dialog_id))
{
action = list->data;
break;
}
}
g_list_free (actions);
}
}
}
if (action)
gimp_widget_set_accel_help (tab_widget, action);
else
gimp_help_set_help_data (tab_widget,
gimp_dockable_get_blurb (dockable),
gimp_dockable_get_help_id (dockable));
g_object_set_data (G_OBJECT (tab_widget), "gimp-dockable", dockable);
gimp_dockbook_tab_drag_source_setup (tab_widget, dockable);
g_signal_connect_object (tab_widget, "drag-begin",
G_CALLBACK (gimp_dockbook_tab_drag_begin),
dockable, 0);
g_signal_connect_object (tab_widget, "drag-end",
G_CALLBACK (gimp_dockbook_tab_drag_end),
dockable, 0);
g_signal_connect_object (dockable, "drag-begin",
G_CALLBACK (gimp_dockbook_tab_drag_begin),
dockable, 0);
g_signal_connect_object (dockable, "drag-end",
G_CALLBACK (gimp_dockbook_tab_drag_end),
dockable, 0);
gtk_drag_dest_set (tab_widget,
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND Make drag-and-drop rearrangement of dockables happen directly in the existing widget hierarchy so we don't have to use special, ugly widgets (read GimpDockSeparator:s) for that. More specifically, make edges of dockables and dockbooks have the same semantics as the GimpDockSeparators had. We put a highlight colored GdkWindow on top of the widget in question to highlight these special drop areas. This GdkWindow is not taken into consideration in the GTK+ drag-and-drop code, so it does not interupt the DND interaction. To achive this, there is a problem we must solve: Drag events in GTK+ are propagated inwards and out, but we sometimes want ancenstor widgets to take care of drop events. We solve this by introducing the concept of "drag handlers". A drag handler is asked if it will handle a given drag event, and if it will, a client will let the drag event be propagated upwards in the widget hierarchy. Right now, the GimpPanedBox is the only "drag handler". The code could be generalized more but it doesn't feel worth it at this point. The size of the special drop area is 5px, the same size as the default GtkPaned handles. This is because the plan is to later use these handles as drop areas too. Other changes of interest are: * We need to take care of "drag-motion", "drag-drop" and widget highlightning ourselves. We can not use the GtkDestDefaults conveniences with gtk_drag_dest_set() any longer since we need more control. * Make the drop callback pass the insert index directly instead of a GimpDockSeparator * Add some GIMP_LOG() debug output for DND * Disable the GimpDockSeparator code in GimpToolbox
2009-11-30 01:22:12 +08:00
0,
dialog_target_table, G_N_ELEMENTS (dialog_target_table),
GDK_ACTION_MOVE);
g_signal_connect_object (tab_widget, "drag-leave",
G_CALLBACK (gimp_dockbook_tab_drag_leave),
dockable, 0);
g_signal_connect_object (tab_widget, "drag-motion",
G_CALLBACK (gimp_dockbook_tab_drag_motion),
dockable, 0);
g_signal_connect_object (tab_widget, "drag-drop",
G_CALLBACK (gimp_dockbook_tab_drag_drop),
dockbook, 0);
return tab_widget;
}
/**
* gimp_dockbook_update_auto_tab_style:
* @dockbook:
*
* Refresh the table that we use to map dockbook width to actual auto
* tab style, then update auto tabs (also recreate tab widgets if
* necessary).
**/
void
gimp_dockbook_update_auto_tab_style (GimpDockbook *dockbook)
{
g_return_if_fail (GIMP_IS_DOCKBOOK (dockbook));
gimp_dockbook_refresh_tab_layout_lut (dockbook);
gimp_dockbook_update_automatic_tab_style (dockbook);
}
gboolean
gimp_dockbook_drop_dockable (GimpDockbook *dockbook,
GtkWidget *drag_source)
{
g_return_val_if_fail (GIMP_IS_DOCKBOOK (dockbook), FALSE);
if (drag_source)
{
GimpDockable *dockable =
gimp_dockbook_drag_source_to_dockable (drag_source);
if (dockable)
{
if (gimp_dockable_get_dockbook (dockable) == dockbook)
{
gtk_notebook_reorder_child (GTK_NOTEBOOK (dockbook),
GTK_WIDGET (dockable), -1);
}
else
{
g_object_ref (dockable);
gimp_dockbook_remove (gimp_dockable_get_dockbook (dockable), dockable);
gimp_dockbook_add (dockbook, dockable, -1);
g_object_unref (dockable);
}
return TRUE;
}
}
return FALSE;
}
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND Make drag-and-drop rearrangement of dockables happen directly in the existing widget hierarchy so we don't have to use special, ugly widgets (read GimpDockSeparator:s) for that. More specifically, make edges of dockables and dockbooks have the same semantics as the GimpDockSeparators had. We put a highlight colored GdkWindow on top of the widget in question to highlight these special drop areas. This GdkWindow is not taken into consideration in the GTK+ drag-and-drop code, so it does not interupt the DND interaction. To achive this, there is a problem we must solve: Drag events in GTK+ are propagated inwards and out, but we sometimes want ancenstor widgets to take care of drop events. We solve this by introducing the concept of "drag handlers". A drag handler is asked if it will handle a given drag event, and if it will, a client will let the drag event be propagated upwards in the widget hierarchy. Right now, the GimpPanedBox is the only "drag handler". The code could be generalized more but it doesn't feel worth it at this point. The size of the special drop area is 5px, the same size as the default GtkPaned handles. This is because the plan is to later use these handles as drop areas too. Other changes of interest are: * We need to take care of "drag-motion", "drag-drop" and widget highlightning ourselves. We can not use the GtkDestDefaults conveniences with gtk_drag_dest_set() any longer since we need more control. * Make the drop callback pass the insert index directly instead of a GimpDockSeparator * Add some GIMP_LOG() debug output for DND * Disable the GimpDockSeparator code in GimpToolbox
2009-11-30 01:22:12 +08:00
/**
* gimp_dockable_set_drag_handler:
* @dockable:
* @handler:
*
* Set a drag handler that will be asked if it will handle drag events
* before the dockbook handles the event itself.
**/
void
gimp_dockbook_set_drag_handler (GimpDockbook *dockbook,
GimpPanedBox *drag_handler)
{
g_return_if_fail (GIMP_IS_DOCKBOOK (dockbook));
dockbook->p->drag_handler = drag_handler;
}
/**
* gimp_dockbook_drag_source_to_dockable:
* @drag_source: A drag-and-drop source widget
*
* Gets the dockable associated with a drag-and-drop source. If
* successfull, the function will also cleanup the dockable.
*
* Returns: The dockable
**/
GimpDockable *
gimp_dockbook_drag_source_to_dockable (GtkWidget *drag_source)
{
GimpDockable *dockable = NULL;
if (GIMP_IS_DOCKABLE (drag_source))
dockable = GIMP_DOCKABLE (drag_source);
else
dockable = g_object_get_data (G_OBJECT (drag_source),
"gimp-dockable");
if (dockable)
g_object_set_data (G_OBJECT (dockable),
"gimp-dock-drag-widget", NULL);
return dockable;
}
/* tab DND source side */
static void
gimp_dockbook_recreate_tab_widgets (GimpDockbook *dockbook,
gboolean only_auto)
{
GList *dockables = gtk_container_get_children (GTK_CONTAINER (dockbook));
GList *iter = NULL;
for (iter = dockables; iter; iter = g_list_next (iter))
{
GimpDockable *dockable = GIMP_DOCKABLE (iter->data);
GtkWidget *tab_widget;
if (only_auto &&
! gimp_dockable_get_tab_style (dockable) == GIMP_TAB_STYLE_AUTOMATIC)
continue;
tab_widget = gimp_dockbook_create_tab_widget (dockbook, dockable);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (dockbook),
GTK_WIDGET (dockable),
tab_widget);
}
g_list_free (dockables);
}
static void
gimp_dockbook_tab_drag_source_setup (GtkWidget *widget,
GimpDockable *dockable)
{
if (gimp_dockable_is_locked (dockable))
{
if (widget)
gtk_drag_source_unset (widget);
gtk_drag_source_unset (GTK_WIDGET (dockable));
}
else
{
if (widget)
gtk_drag_source_set (widget,
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
dialog_target_table,
G_N_ELEMENTS (dialog_target_table),
GDK_ACTION_MOVE);
gtk_drag_source_set (GTK_WIDGET (dockable),
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
dialog_target_table,
G_N_ELEMENTS (dialog_target_table),
GDK_ACTION_MOVE);
}
}
static void
gimp_dockbook_tab_drag_begin (GtkWidget *widget,
GdkDragContext *context,
GimpDockable *dockable)
{
GtkAllocation allocation;
GtkWidget *window;
GtkWidget *view;
GtkRequisition requisition;
gint drag_x;
gint drag_y;
gtk_widget_get_allocation (widget, &allocation);
window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DND);
gtk_window_set_screen (GTK_WINDOW (window), gtk_widget_get_screen (widget));
view = gimp_dockable_create_drag_widget (dockable);
gtk_container_add (GTK_CONTAINER (window), view);
gtk_widget_show (view);
gtk_widget_size_request (view, &requisition);
if (requisition.width < allocation.width)
gtk_widget_set_size_request (view, allocation.width, -1);
gtk_widget_show (window);
g_object_set_data_full (G_OBJECT (dockable), "gimp-dock-drag-widget",
window,
(GDestroyNotify) gtk_widget_destroy);
gimp_dockable_get_drag_pos (dockable, &drag_x, &drag_y);
gtk_drag_set_icon_widget (context, window, drag_x, drag_y);
/*
* Set the source dockable insensitive to give a visual clue that
* it's the dockable that's being dragged around
*/
gtk_widget_set_sensitive (GTK_WIDGET (dockable), FALSE);
}
static void
gimp_dockbook_tab_drag_end (GtkWidget *widget,
GdkDragContext *context,
GimpDockable *dockable)
{
GtkWidget *drag_widget;
drag_widget = g_object_get_data (G_OBJECT (dockable),
"gimp-dock-drag-widget");
/* finding the drag_widget means the drop was not successful, so
* pop up a new dock and move the dockable there
*/
if (drag_widget)
{
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
g_object_set_data (G_OBJECT (dockable), "gimp-dock-drag-widget", NULL);
gimp_dockable_detach (dockable);
}
gimp_dockable_set_drag_pos (dockable,
GIMP_DOCKABLE_DRAG_OFFSET,
GIMP_DOCKABLE_DRAG_OFFSET);
gtk_widget_set_sensitive (GTK_WIDGET (dockable), TRUE);
}
/* tab DND target side */
static void
gimp_dockbook_tab_drag_leave (GtkWidget *widget,
GdkDragContext *context,
guint time,
GimpDockable *dockable)
{
GimpDockbook *dockbook = gimp_dockable_get_dockbook (dockable);
gimp_dockbook_remove_tab_timeout (dockbook);
gimp_highlight_widget (widget, FALSE);
}
static gboolean
gimp_dockbook_tab_drag_motion (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
GimpDockable *dockable)
{
GimpDockbook *dockbook = gimp_dockable_get_dockbook (dockable);
GtkTargetList *target_list;
GdkAtom target_atom;
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND Make drag-and-drop rearrangement of dockables happen directly in the existing widget hierarchy so we don't have to use special, ugly widgets (read GimpDockSeparator:s) for that. More specifically, make edges of dockables and dockbooks have the same semantics as the GimpDockSeparators had. We put a highlight colored GdkWindow on top of the widget in question to highlight these special drop areas. This GdkWindow is not taken into consideration in the GTK+ drag-and-drop code, so it does not interupt the DND interaction. To achive this, there is a problem we must solve: Drag events in GTK+ are propagated inwards and out, but we sometimes want ancenstor widgets to take care of drop events. We solve this by introducing the concept of "drag handlers". A drag handler is asked if it will handle a given drag event, and if it will, a client will let the drag event be propagated upwards in the widget hierarchy. Right now, the GimpPanedBox is the only "drag handler". The code could be generalized more but it doesn't feel worth it at this point. The size of the special drop area is 5px, the same size as the default GtkPaned handles. This is because the plan is to later use these handles as drop areas too. Other changes of interest are: * We need to take care of "drag-motion", "drag-drop" and widget highlightning ourselves. We can not use the GtkDestDefaults conveniences with gtk_drag_dest_set() any longer since we need more control. * Make the drop callback pass the insert index directly instead of a GimpDockSeparator * Add some GIMP_LOG() debug output for DND * Disable the GimpDockSeparator code in GimpToolbox
2009-11-30 01:22:12 +08:00
gboolean handle = FALSE;
/* If the handler will handle the drag, return FALSE */
if (gimp_paned_box_will_handle_drag (dockbook->p->drag_handler,
widget,
context,
x, y,
time))
{
handle = FALSE;
goto finish;
}
if (! dockbook->p->tab_hover_timeout ||
dockbook->p->tab_hover_dockable != dockable)
{
gint page_num;
gimp_dockbook_remove_tab_timeout (dockbook);
page_num = gtk_notebook_page_num (GTK_NOTEBOOK (dockbook),
GTK_WIDGET (dockable));
if (page_num != gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook)))
gimp_dockbook_add_tab_timeout (dockbook, dockable);
}
target_list = gtk_drag_dest_get_target_list (widget);
target_atom = gtk_drag_dest_find_target (widget, context, target_list);
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND Make drag-and-drop rearrangement of dockables happen directly in the existing widget hierarchy so we don't have to use special, ugly widgets (read GimpDockSeparator:s) for that. More specifically, make edges of dockables and dockbooks have the same semantics as the GimpDockSeparators had. We put a highlight colored GdkWindow on top of the widget in question to highlight these special drop areas. This GdkWindow is not taken into consideration in the GTK+ drag-and-drop code, so it does not interupt the DND interaction. To achive this, there is a problem we must solve: Drag events in GTK+ are propagated inwards and out, but we sometimes want ancenstor widgets to take care of drop events. We solve this by introducing the concept of "drag handlers". A drag handler is asked if it will handle a given drag event, and if it will, a client will let the drag event be propagated upwards in the widget hierarchy. Right now, the GimpPanedBox is the only "drag handler". The code could be generalized more but it doesn't feel worth it at this point. The size of the special drop area is 5px, the same size as the default GtkPaned handles. This is because the plan is to later use these handles as drop areas too. Other changes of interest are: * We need to take care of "drag-motion", "drag-drop" and widget highlightning ourselves. We can not use the GtkDestDefaults conveniences with gtk_drag_dest_set() any longer since we need more control. * Make the drop callback pass the insert index directly instead of a GimpDockSeparator * Add some GIMP_LOG() debug output for DND * Disable the GimpDockSeparator code in GimpToolbox
2009-11-30 01:22:12 +08:00
handle = gtk_target_list_find (target_list, target_atom, NULL);
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND Make drag-and-drop rearrangement of dockables happen directly in the existing widget hierarchy so we don't have to use special, ugly widgets (read GimpDockSeparator:s) for that. More specifically, make edges of dockables and dockbooks have the same semantics as the GimpDockSeparators had. We put a highlight colored GdkWindow on top of the widget in question to highlight these special drop areas. This GdkWindow is not taken into consideration in the GTK+ drag-and-drop code, so it does not interupt the DND interaction. To achive this, there is a problem we must solve: Drag events in GTK+ are propagated inwards and out, but we sometimes want ancenstor widgets to take care of drop events. We solve this by introducing the concept of "drag handlers". A drag handler is asked if it will handle a given drag event, and if it will, a client will let the drag event be propagated upwards in the widget hierarchy. Right now, the GimpPanedBox is the only "drag handler". The code could be generalized more but it doesn't feel worth it at this point. The size of the special drop area is 5px, the same size as the default GtkPaned handles. This is because the plan is to later use these handles as drop areas too. Other changes of interest are: * We need to take care of "drag-motion", "drag-drop" and widget highlightning ourselves. We can not use the GtkDestDefaults conveniences with gtk_drag_dest_set() any longer since we need more control. * Make the drop callback pass the insert index directly instead of a GimpDockSeparator * Add some GIMP_LOG() debug output for DND * Disable the GimpDockSeparator code in GimpToolbox
2009-11-30 01:22:12 +08:00
finish:
gdk_drag_status (context, handle ? GDK_ACTION_MOVE : 0, time);
gimp_highlight_widget (widget, handle);
return handle;
}
static gboolean
gimp_dockbook_tab_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time)
{
GimpDockable *dest_dockable;
GtkWidget *source;
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND Make drag-and-drop rearrangement of dockables happen directly in the existing widget hierarchy so we don't have to use special, ugly widgets (read GimpDockSeparator:s) for that. More specifically, make edges of dockables and dockbooks have the same semantics as the GimpDockSeparators had. We put a highlight colored GdkWindow on top of the widget in question to highlight these special drop areas. This GdkWindow is not taken into consideration in the GTK+ drag-and-drop code, so it does not interupt the DND interaction. To achive this, there is a problem we must solve: Drag events in GTK+ are propagated inwards and out, but we sometimes want ancenstor widgets to take care of drop events. We solve this by introducing the concept of "drag handlers". A drag handler is asked if it will handle a given drag event, and if it will, a client will let the drag event be propagated upwards in the widget hierarchy. Right now, the GimpPanedBox is the only "drag handler". The code could be generalized more but it doesn't feel worth it at this point. The size of the special drop area is 5px, the same size as the default GtkPaned handles. This is because the plan is to later use these handles as drop areas too. Other changes of interest are: * We need to take care of "drag-motion", "drag-drop" and widget highlightning ourselves. We can not use the GtkDestDefaults conveniences with gtk_drag_dest_set() any longer since we need more control. * Make the drop callback pass the insert index directly instead of a GimpDockSeparator * Add some GIMP_LOG() debug output for DND * Disable the GimpDockSeparator code in GimpToolbox
2009-11-30 01:22:12 +08:00
gboolean handle = FALSE;
dest_dockable = g_object_get_data (G_OBJECT (widget), "gimp-dockable");
source = gtk_drag_get_source_widget (context);
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND Make drag-and-drop rearrangement of dockables happen directly in the existing widget hierarchy so we don't have to use special, ugly widgets (read GimpDockSeparator:s) for that. More specifically, make edges of dockables and dockbooks have the same semantics as the GimpDockSeparators had. We put a highlight colored GdkWindow on top of the widget in question to highlight these special drop areas. This GdkWindow is not taken into consideration in the GTK+ drag-and-drop code, so it does not interupt the DND interaction. To achive this, there is a problem we must solve: Drag events in GTK+ are propagated inwards and out, but we sometimes want ancenstor widgets to take care of drop events. We solve this by introducing the concept of "drag handlers". A drag handler is asked if it will handle a given drag event, and if it will, a client will let the drag event be propagated upwards in the widget hierarchy. Right now, the GimpPanedBox is the only "drag handler". The code could be generalized more but it doesn't feel worth it at this point. The size of the special drop area is 5px, the same size as the default GtkPaned handles. This is because the plan is to later use these handles as drop areas too. Other changes of interest are: * We need to take care of "drag-motion", "drag-drop" and widget highlightning ourselves. We can not use the GtkDestDefaults conveniences with gtk_drag_dest_set() any longer since we need more control. * Make the drop callback pass the insert index directly instead of a GimpDockSeparator * Add some GIMP_LOG() debug output for DND * Disable the GimpDockSeparator code in GimpToolbox
2009-11-30 01:22:12 +08:00
/* If the handler will handle the drag, return FALSE */
if (gimp_paned_box_will_handle_drag (gimp_dockable_get_drag_handler (dest_dockable),
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND Make drag-and-drop rearrangement of dockables happen directly in the existing widget hierarchy so we don't have to use special, ugly widgets (read GimpDockSeparator:s) for that. More specifically, make edges of dockables and dockbooks have the same semantics as the GimpDockSeparators had. We put a highlight colored GdkWindow on top of the widget in question to highlight these special drop areas. This GdkWindow is not taken into consideration in the GTK+ drag-and-drop code, so it does not interupt the DND interaction. To achive this, there is a problem we must solve: Drag events in GTK+ are propagated inwards and out, but we sometimes want ancenstor widgets to take care of drop events. We solve this by introducing the concept of "drag handlers". A drag handler is asked if it will handle a given drag event, and if it will, a client will let the drag event be propagated upwards in the widget hierarchy. Right now, the GimpPanedBox is the only "drag handler". The code could be generalized more but it doesn't feel worth it at this point. The size of the special drop area is 5px, the same size as the default GtkPaned handles. This is because the plan is to later use these handles as drop areas too. Other changes of interest are: * We need to take care of "drag-motion", "drag-drop" and widget highlightning ourselves. We can not use the GtkDestDefaults conveniences with gtk_drag_dest_set() any longer since we need more control. * Make the drop callback pass the insert index directly instead of a GimpDockSeparator * Add some GIMP_LOG() debug output for DND * Disable the GimpDockSeparator code in GimpToolbox
2009-11-30 01:22:12 +08:00
widget,
context,
x, y,
time))
{
handle = FALSE;
goto finish;
}
added GimpDropMode... ...removed from here. 2001-05-06 Michael Natterer <mitch@gimp.org> * app/appenums.h: added GimpDropMode... * app/gimpdnd.h: ...removed from here. * app/gimpimage.[ch]: - New signal "mode_changed". - removed "const GimpImage*" from gimp_image_colormap_changed() because a signal emission is never "const" for the object which emits the signal. - Fixed gimp_image_[set|get]_component_[active|visible](): ALPHA_CHANNEL maps to ALPHA_PIX only in RGB mode, use ALPHA_G_PIX/ALPHA_I_PIX in GRAY/INDEXED mode. * app/gimpimage-convert.c * app/undo.c: call gimp_image_mode_changed(). * app/gimpviewable.c: added an implementation of "invalidate_preview" which frees the preview temp_buf which may be attached to the viewable. Subclasses need to chain up now. * app/gimpdrawable.c * app/gimpimage.c: chain up in invalidate_preview(). * app/widgets/gimpchannellistview.c: connect to the image's "mode_changed" signal and rebuild the channel list in the callback. * app/widgets/gimpcontainerview.h: indentation. * app/widgets/gimpdockbook.c: set the dockable's context to NULL in gimp_dockbook_remove() * app/widgets/gimpimagedock.c: forgot to actually set the dock's image in gimp_image_dock_new(). * app/gui/dialogs-constructors.c: added a get_name_func() for tool views which returns the tool's "blurb". It's safe to assume now that a dockable's context will exist as long as the dockable exists unless it's explicitely set to NULL, so remove ugly hacks handling context destruction. * app/tools/gimptool.c: removed COMPAT_CRUFT and useless #include's.
2001-05-07 00:14:34 +08:00
if (dest_dockable && source)
{
GimpDockable *src_dockable =
gimp_dockbook_drag_source_to_dockable (source);
if (src_dockable)
{
gint dest_index;
dest_index =
gtk_notebook_page_num (GTK_NOTEBOOK (gimp_dockable_get_dockbook (dest_dockable)),
GTK_WIDGET (dest_dockable));
if (gimp_dockable_get_dockbook (src_dockable) !=
gimp_dockable_get_dockbook (dest_dockable))
{
g_object_ref (src_dockable);
gimp_dockbook_remove (gimp_dockable_get_dockbook (src_dockable), src_dockable);
gimp_dockbook_add (gimp_dockable_get_dockbook (dest_dockable), src_dockable,
dest_index);
g_object_unref (src_dockable);
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND Make drag-and-drop rearrangement of dockables happen directly in the existing widget hierarchy so we don't have to use special, ugly widgets (read GimpDockSeparator:s) for that. More specifically, make edges of dockables and dockbooks have the same semantics as the GimpDockSeparators had. We put a highlight colored GdkWindow on top of the widget in question to highlight these special drop areas. This GdkWindow is not taken into consideration in the GTK+ drag-and-drop code, so it does not interupt the DND interaction. To achive this, there is a problem we must solve: Drag events in GTK+ are propagated inwards and out, but we sometimes want ancenstor widgets to take care of drop events. We solve this by introducing the concept of "drag handlers". A drag handler is asked if it will handle a given drag event, and if it will, a client will let the drag event be propagated upwards in the widget hierarchy. Right now, the GimpPanedBox is the only "drag handler". The code could be generalized more but it doesn't feel worth it at this point. The size of the special drop area is 5px, the same size as the default GtkPaned handles. This is because the plan is to later use these handles as drop areas too. Other changes of interest are: * We need to take care of "drag-motion", "drag-drop" and widget highlightning ourselves. We can not use the GtkDestDefaults conveniences with gtk_drag_dest_set() any longer since we need more control. * Make the drop callback pass the insert index directly instead of a GimpDockSeparator * Add some GIMP_LOG() debug output for DND * Disable the GimpDockSeparator code in GimpToolbox
2009-11-30 01:22:12 +08:00
handle = TRUE;
}
else if (src_dockable != dest_dockable)
{
gtk_notebook_reorder_child (GTK_NOTEBOOK (gimp_dockable_get_dockbook (src_dockable)),
GTK_WIDGET (src_dockable),
dest_index);
g_signal_emit (gimp_dockable_get_dockbook (src_dockable),
dockbook_signals[DOCKABLE_REORDERED], 0,
src_dockable);
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND Make drag-and-drop rearrangement of dockables happen directly in the existing widget hierarchy so we don't have to use special, ugly widgets (read GimpDockSeparator:s) for that. More specifically, make edges of dockables and dockbooks have the same semantics as the GimpDockSeparators had. We put a highlight colored GdkWindow on top of the widget in question to highlight these special drop areas. This GdkWindow is not taken into consideration in the GTK+ drag-and-drop code, so it does not interupt the DND interaction. To achive this, there is a problem we must solve: Drag events in GTK+ are propagated inwards and out, but we sometimes want ancenstor widgets to take care of drop events. We solve this by introducing the concept of "drag handlers". A drag handler is asked if it will handle a given drag event, and if it will, a client will let the drag event be propagated upwards in the widget hierarchy. Right now, the GimpPanedBox is the only "drag handler". The code could be generalized more but it doesn't feel worth it at this point. The size of the special drop area is 5px, the same size as the default GtkPaned handles. This is because the plan is to later use these handles as drop areas too. Other changes of interest are: * We need to take care of "drag-motion", "drag-drop" and widget highlightning ourselves. We can not use the GtkDestDefaults conveniences with gtk_drag_dest_set() any longer since we need more control. * Make the drop callback pass the insert index directly instead of a GimpDockSeparator * Add some GIMP_LOG() debug output for DND * Disable the GimpDockSeparator code in GimpToolbox
2009-11-30 01:22:12 +08:00
handle = TRUE;
}
}
}
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND Make drag-and-drop rearrangement of dockables happen directly in the existing widget hierarchy so we don't have to use special, ugly widgets (read GimpDockSeparator:s) for that. More specifically, make edges of dockables and dockbooks have the same semantics as the GimpDockSeparators had. We put a highlight colored GdkWindow on top of the widget in question to highlight these special drop areas. This GdkWindow is not taken into consideration in the GTK+ drag-and-drop code, so it does not interupt the DND interaction. To achive this, there is a problem we must solve: Drag events in GTK+ are propagated inwards and out, but we sometimes want ancenstor widgets to take care of drop events. We solve this by introducing the concept of "drag handlers". A drag handler is asked if it will handle a given drag event, and if it will, a client will let the drag event be propagated upwards in the widget hierarchy. Right now, the GimpPanedBox is the only "drag handler". The code could be generalized more but it doesn't feel worth it at this point. The size of the special drop area is 5px, the same size as the default GtkPaned handles. This is because the plan is to later use these handles as drop areas too. Other changes of interest are: * We need to take care of "drag-motion", "drag-drop" and widget highlightning ourselves. We can not use the GtkDestDefaults conveniences with gtk_drag_dest_set() any longer since we need more control. * Make the drop callback pass the insert index directly instead of a GimpDockSeparator * Add some GIMP_LOG() debug output for DND * Disable the GimpDockSeparator code in GimpToolbox
2009-11-30 01:22:12 +08:00
finish:
if (handle)
gtk_drag_finish (context, TRUE, TRUE, time);
return handle;
}
static GtkWidget *
gimp_dockable_create_event_box_tab_widget (GimpDockable *dockable,
GimpContext *context,
GimpTabStyle tab_style,
GtkIconSize size)
{
GtkWidget *tab_widget;
tab_widget =
gimp_dockable_create_tab_widget (dockable,
context,
tab_style,
size);
if (! GIMP_IS_VIEW (tab_widget))
{
GtkWidget *event_box;
event_box = gtk_event_box_new ();
gtk_event_box_set_visible_window (GTK_EVENT_BOX (event_box), FALSE);
gtk_event_box_set_above_child (GTK_EVENT_BOX (event_box), TRUE);
gtk_container_add (GTK_CONTAINER (event_box), tab_widget);
gtk_widget_show (tab_widget);
tab_widget = event_box;
}
return tab_widget;
}
static GtkIconSize
gimp_dockbook_get_tab_icon_size (GimpDockbook *dockbook)
{
GtkIconSize tab_size = DEFAULT_TAB_ICON_SIZE;
gtk_widget_style_get (GTK_WIDGET (dockbook),
"tab-icon-size", &tab_size,
NULL);
return tab_size;
}
static void
gimp_dockbook_add_tab_timeout (GimpDockbook *dockbook,
GimpDockable *dockable)
{
dockbook->p->tab_hover_timeout =
g_timeout_add (TAB_HOVER_TIMEOUT,
(GSourceFunc) gimp_dockbook_tab_timeout,
dockbook);
dockbook->p->tab_hover_dockable = dockable;
}
static void
gimp_dockbook_remove_tab_timeout (GimpDockbook *dockbook)
{
if (dockbook->p->tab_hover_timeout)
{
g_source_remove (dockbook->p->tab_hover_timeout);
dockbook->p->tab_hover_timeout = 0;
dockbook->p->tab_hover_dockable = NULL;
}
}
static gboolean
gimp_dockbook_tab_timeout (GimpDockbook *dockbook)
{
gint page_num;
GDK_THREADS_ENTER ();
page_num = gtk_notebook_page_num (GTK_NOTEBOOK (dockbook),
GTK_WIDGET (dockbook->p->tab_hover_dockable));
gtk_notebook_set_current_page (GTK_NOTEBOOK (dockbook), page_num);
dockbook->p->tab_hover_timeout = 0;
dockbook->p->tab_hover_dockable = NULL;
GDK_THREADS_LEAVE ();
return FALSE;
}
static void
gimp_dockbook_tab_locked_notify (GimpDockable *dockable,
GParamSpec *pspec,
GimpDockbook *dockbook)
{
GtkWidget *tab_widget;
tab_widget = gtk_notebook_get_tab_label (GTK_NOTEBOOK (dockbook),
GTK_WIDGET (dockable));
gimp_dockbook_tab_drag_source_setup (tab_widget, dockable);
}
static void
gimp_dockbook_help_func (const gchar *help_id,
gpointer help_data)
{
GimpDockbook *dockbook = GIMP_DOCKBOOK (help_data);
GtkWidget *dockable;
gint page_num;
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
dockable = gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (GIMP_IS_DOCKABLE (dockable))
gimp_standard_help_func (gimp_dockable_get_help_id (GIMP_DOCKABLE (dockable)),
NULL);
else
gimp_standard_help_func (GIMP_HELP_DOCK, NULL);
}
static const gchar *
gimp_dockbook_get_tab_style_name (GimpTabStyle tab_style)
{
return g_enum_get_value (g_type_class_peek (GIMP_TYPE_TAB_STYLE),
tab_style)->value_name;
}