Commit 1f1305c3 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

Some dock refactoring which separates the docking logic from active image

2005-05-11  Michael Natterer  <mitch@gimp.org>

	Some dock refactoring which separates the docking logic from
	active image and UI manager stuff:

	* app/widgets/gimpmenudock.[ch]: new widget renamed from
	GimpImageDock, zero changes except the name change.

	* app/widgets/gimpimagedock.[ch]: new widget derived from
	GimpDock. Keeps the UI manager.

	* app/widgets/gimpdock.[ch]: removed the UI manager. GimpDock only
	contains the basic docking logic again.

	* app/widgets/gimpmenudock.[ch]
	* app/widgets/gimptoolbox.[ch]: derive them from GimpImageDock.

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h
	* app/actions/dialogs-commands.c
	* app/actions/dock-actions.c
	* app/actions/dock-commands.c
	* app/actions/dockable-commands.c
	* app/dialogs/dialogs-constructors.c: changed accordingly.
parent 5c4278d0
2005-05-11 Michael Natterer <mitch@gimp.org>
Some dock refactoring which separates the docking logic from
active image and UI manager stuff:
* app/widgets/gimpmenudock.[ch]: new widget renamed from
GimpImageDock, zero changes except the name change.
* app/widgets/gimpimagedock.[ch]: new widget derived from
GimpDock. Keeps the UI manager.
* app/widgets/gimpdock.[ch]: removed the UI manager. GimpDock only
contains the basic docking logic again.
* app/widgets/gimpmenudock.[ch]
* app/widgets/gimptoolbox.[ch]: derive them from GimpImageDock.
* app/widgets/Makefile.am
* app/widgets/widgets-types.h
* app/actions/dialogs-commands.c
* app/actions/dock-actions.c
* app/actions/dock-commands.c
* app/actions/dockable-commands.c
* app/dialogs/dialogs-constructors.c: changed accordingly.
2005-05-11 Sven Neumann <sven@gimp.org>
* app/display/gimpdisplayshell-scale.c (gimp_display_shell_scale):
......
......@@ -31,7 +31,7 @@
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpdockable.h"
#include "widgets/gimpdockbook.h"
#include "widgets/gimpimagedock.h"
#include "widgets/gimpmenudock.h"
#include "dialogs/dialogs.h"
......@@ -176,7 +176,7 @@ dialogs_create_dock (GdkScreen *screen,
dock = gimp_dialog_factory_dock_new (global_dock_factory, screen);
gimp_image_dock_set_show_image_menu (GIMP_IMAGE_DOCK (dock), show_image_menu);
gimp_menu_dock_set_show_image_menu (GIMP_MENU_DOCK (dock), show_image_menu);
dockbook = gimp_dockbook_new (global_dock_factory->menu_factory);
......
......@@ -26,7 +26,7 @@
#include "widgets/gimpactiongroup.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpimagedock.h"
#include "widgets/gimpmenudock.h"
#include "actions.h"
#include "dock-actions.h"
......@@ -84,8 +84,8 @@ void
dock_actions_update (GimpActionGroup *group,
gpointer data)
{
GtkWidget *widget = action_data_get_widget (data);
GtkWidget *toplevel = NULL;
GtkWidget *widget = action_data_get_widget (data);
GtkWidget *toplevel = NULL;
if (widget)
toplevel = gtk_widget_get_toplevel (widget);
......@@ -95,15 +95,15 @@ dock_actions_update (GimpActionGroup *group,
#define SET_VISIBLE(action,active) \
gimp_action_group_set_action_visible (group, action, (active) != 0)
if (GIMP_IS_IMAGE_DOCK (toplevel))
if (GIMP_IS_MENU_DOCK (toplevel))
{
GimpImageDock *image_dock = GIMP_IMAGE_DOCK (toplevel);
GimpMenuDock *menu_dock = GIMP_MENU_DOCK (toplevel);
SET_VISIBLE ("dock-show-image-menu", TRUE);
SET_VISIBLE ("dock-auto-follow-active", TRUE);
SET_ACTIVE ("dock-show-image-menu", image_dock->show_image_menu);
SET_ACTIVE ("dock-auto-follow-active", image_dock->auto_follow_active);
SET_ACTIVE ("dock-show-image-menu", menu_dock->show_image_menu);
SET_ACTIVE ("dock-auto-follow-active", menu_dock->auto_follow_active);
}
else
{
......
......@@ -24,7 +24,7 @@
#include "actions-types.h"
#include "widgets/gimpimagedock.h"
#include "widgets/gimpmenudock.h"
#include "actions.h"
#include "dock-commands.h"
......@@ -94,8 +94,8 @@ dock_toggle_image_menu_cmd_callback (GtkAction *action,
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
if (GIMP_IS_IMAGE_DOCK (widget))
gimp_image_dock_set_show_image_menu (GIMP_IMAGE_DOCK (widget), active);
if (GIMP_IS_MENU_DOCK (widget))
gimp_menu_dock_set_show_image_menu (GIMP_MENU_DOCK (widget), active);
}
void
......@@ -111,6 +111,6 @@ dock_toggle_auto_cmd_callback (GtkAction *action,
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
if (GIMP_IS_IMAGE_DOCK (widget))
gimp_image_dock_set_auto_follow_active (GIMP_IMAGE_DOCK (widget), active);
if (GIMP_IS_MENU_DOCK (widget))
gimp_menu_dock_set_auto_follow_active (GIMP_MENU_DOCK (widget), active);
}
......@@ -29,9 +29,9 @@
#include "widgets/gimpcontainerview.h"
#include "widgets/gimpcontainerview-utils.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpdock.h"
#include "widgets/gimpdockable.h"
#include "widgets/gimpdockbook.h"
#include "widgets/gimpimagedock.h"
#include "widgets/gimpsessioninfo.h"
#include "dialogs/dialogs.h"
......
......@@ -52,9 +52,9 @@
#include "widgets/gimpgradienteditor.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimphistogrameditor.h"
#include "widgets/gimpimagedock.h"
#include "widgets/gimpimageview.h"
#include "widgets/gimplayertreeview.h"
#include "widgets/gimpmenudock.h"
#include "widgets/gimppaletteeditor.h"
#include "widgets/gimppatternfactoryview.h"
#include "widgets/gimpsamplepointeditor.h"
......@@ -196,9 +196,9 @@ dialogs_dock_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
return gimp_image_dock_new (factory,
context->gimp->images,
context->gimp->displays);
return gimp_menu_dock_new (factory,
context->gimp->images,
context->gimp->displays);
}
......
......@@ -173,6 +173,8 @@ libappwidgets_a_sources = \
gimpitemtreeview.h \
gimplayertreeview.c \
gimplayertreeview.h \
gimpmenudock.c \
gimpmenudock.h \
gimpmenufactory.c \
gimpmenufactory.h \
gimpmessagebox.c \
......
......@@ -2,7 +2,7 @@
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpdock.c
* Copyright (C) 2001-2003 Michael Natterer <mitch@gimp.org>
* Copyright (C) 2001-2005 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
......@@ -30,7 +30,6 @@
#include "config/gimpguiconfig.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpmarshal.h"
......@@ -40,10 +39,8 @@
#include "gimpdockable.h"
#include "gimpdockbook.h"
#include "gimphelp-ids.h"
#include "gimpmenufactory.h"
#include "gimpmessagebox.h"
#include "gimpmessagedialog.h"
#include "gimpuimanager.h"
#include "gimpwidgets-utils.h"
#include "gimp-intl.h"
......@@ -97,12 +94,6 @@ static void gimp_dock_real_book_added (GimpDock *dock,
static void gimp_dock_real_book_removed (GimpDock *dock,
GimpDockbook *dockbook);
static void gimp_dock_display_changed (GimpContext *context,
GimpObject *display,
GimpDock *dock);
static void gimp_dock_image_flush (GimpImage *image,
GimpDock *dock);
static GtkWidget * gimp_dock_separator_new (GimpDock *dock);
static void gimp_dock_separator_drag_leave (GtkWidget *widget,
GdkDragContext *context,
......@@ -124,10 +115,7 @@ static gboolean gimp_dock_separator_drag_drop (GtkWidget *widget,
static GtkWindowClass *parent_class = NULL;
static guint dock_signals[LAST_SIGNAL] = { 0 };
static GtkTargetEntry dialog_target_table[] =
{
GIMP_TARGET_DIALOG
};
static GtkTargetEntry dialog_target_table[] = { GIMP_TARGET_DIALOG };
GType
......@@ -201,8 +189,6 @@ gimp_dock_class_init (GimpDockClass *klass)
klass->book_added = gimp_dock_real_book_added;
klass->book_removed = gimp_dock_real_book_removed;
klass->ui_manager_name = "<Dock>";
g_object_class_install_property (object_class, PROP_CONTEXT,
g_param_spec_object ("context", NULL, NULL,
GIMP_TYPE_CONTEXT,
......@@ -215,14 +201,14 @@ gimp_dock_class_init (GimpDockClass *klass)
G_PARAM_CONSTRUCT_ONLY));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("default_height",
g_param_spec_int ("default-height",
NULL, NULL,
-1,
G_MAXINT,
DEFAULT_DOCK_HEIGHT,
G_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("separator_height",
g_param_spec_int ("separator-height",
NULL, NULL,
0,
G_MAXINT,
......@@ -235,7 +221,8 @@ gimp_dock_init (GimpDock *dock)
{
GtkWidget *separator;
dock->context = NULL;
dock->context = NULL;
dock->dialog_factory = NULL;
gtk_window_set_role (GTK_WINDOW (dock), "gimp-dock");
gtk_window_set_resizable (GTK_WINDOW (dock), TRUE);
......@@ -261,7 +248,6 @@ gimp_dock_constructor (GType type,
GObject *object;
GimpDock *dock;
GimpGuiConfig *config;
GtkAccelGroup *accel_group;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
......@@ -274,26 +260,6 @@ gimp_dock_constructor (GType type,
gimp_window_set_hint (GTK_WINDOW (dock), config->dock_window_hint);
dock->ui_manager =
gimp_menu_factory_manager_new (dock->dialog_factory->menu_factory,
GIMP_DOCK_GET_CLASS (dock)->ui_manager_name,
dock,
config->tearoff_menus);
accel_group =
gtk_ui_manager_get_accel_group (GTK_UI_MANAGER (dock->ui_manager));
gtk_window_add_accel_group (GTK_WINDOW (object), accel_group);
dock->image_flush_handler_id =
gimp_container_add_handler (dock->context->gimp->images, "flush",
G_CALLBACK (gimp_dock_image_flush),
dock);
g_signal_connect_object (dock->context, "display-changed",
G_CALLBACK (gimp_dock_display_changed),
dock, 0);
return object;
}
......@@ -349,19 +315,6 @@ gimp_dock_destroy (GtkObject *object)
while (dock->dockbooks)
gimp_dock_remove_book (dock, GIMP_DOCKBOOK (dock->dockbooks->data));
if (dock->image_flush_handler_id)
{
gimp_container_remove_handler (dock->context->gimp->images,
dock->image_flush_handler_id);
dock->image_flush_handler_id = 0;
}
if (dock->ui_manager)
{
g_object_unref (dock->ui_manager);
dock->ui_manager = NULL;
}
if (dock->context)
{
g_object_unref (dock->context);
......@@ -375,9 +328,9 @@ static gboolean
gimp_dock_delete_event (GtkWidget *widget,
GdkEventAny *event)
{
GimpDock *dock = GIMP_DOCK (widget);
GList *list;
GimpDock *dock = GIMP_DOCK (widget);
gboolean retval = FALSE;
GList *list;
gint n;
for (list = dock->dockbooks, n = 0; list; list = list->next)
......@@ -445,20 +398,18 @@ static void
gimp_dock_style_set (GtkWidget *widget,
GtkStyle *prev_style)
{
GimpDock *dock;
GimpDock *dock = GIMP_DOCK (widget);
GList *children;
GList *list;
gint default_height;
gint separator_height;
dock = GIMP_DOCK (widget);
if (GTK_WIDGET_CLASS (parent_class)->style_set)
GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
gtk_widget_style_get (widget,
"default_height", &default_height,
"separator_height", &separator_height,
"default-height", &default_height,
"separator-height", &separator_height,
NULL);
gtk_window_set_default_size (GTK_WINDOW (widget), -1, default_height);
......@@ -713,27 +664,6 @@ gimp_dock_remove_book (GimpDock *dock,
/* private functions */
static void
gimp_dock_display_changed (GimpContext *context,
GimpObject *display,
GimpDock *dock)
{
gimp_ui_manager_update (dock->ui_manager, display);
}
static void
gimp_dock_image_flush (GimpImage *image,
GimpDock *dock)
{
if (image == gimp_context_get_image (dock->context))
{
GimpObject *display = gimp_context_get_display (dock->context);
if (display)
gimp_ui_manager_update (dock->ui_manager, display);
}
}
static GtkWidget *
gimp_dock_separator_new (GimpDock *dock)
{
......
......@@ -2,7 +2,7 @@
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpdock.h
* Copyright (C) 2001 Michael Natterer <mitch@gimp.org>
* Copyright (C) 2001-2005 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
......@@ -43,9 +43,6 @@ struct _GimpDock
GimpDialogFactory *dialog_factory;
GimpContext *context;
GimpUIManager *ui_manager;
GQuark image_flush_handler_id;
GtkWidget *main_vbox;
GtkWidget *vbox;
......@@ -68,8 +65,6 @@ struct _GimpDockClass
GimpDockbook *dockbook);
void (* book_removed) (GimpDock *dock,
GimpDockbook *dockbook);
const gchar *ui_manager_name;
};
......
......@@ -2,7 +2,7 @@
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpimagedock.c
* Copyright (C) 2001-2004 Michael Natterer <mitch@gimp.org>
* Copyright (C) 2001-2005 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
......@@ -21,74 +21,36 @@
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
#include "config/gimpguiconfig.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimplist.h"
#include "core/gimptoolinfo.h"
#include "gimpdialogfactory.h"
#include "gimpimagedock.h"
#include "gimpcontainercombobox.h"
#include "gimpcontainerview.h"
#include "gimpdockable.h"
#include "gimpdockbook.h"
#include "gimphelp-ids.h"
#include "gimpsessioninfo.h"
#include "gimp-intl.h"
#define DEFAULT_MINIMAL_WIDTH 250
#define DEFAULT_MENU_PREVIEW_SIZE GTK_ICON_SIZE_SMALL_TOOLBAR
static void gimp_image_dock_class_init (GimpImageDockClass *klass);
static void gimp_image_dock_init (GimpImageDock *dock);
static GObject * gimp_image_dock_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_image_dock_destroy (GtkObject *object);
static void gimp_image_dock_style_set (GtkWidget *widget,
GtkStyle *prev_style);
static void gimp_image_dock_setup (GimpDock *dock,
const GimpDock *template);
static void gimp_image_dock_set_aux_info (GimpDock *dock,
GList *aux_info);
static GList *gimp_image_dock_get_aux_info (GimpDock *dock);
static void gimp_image_dock_book_added (GimpDock *dock,
GimpDockbook *dockbook);
static void gimp_image_dock_book_removed (GimpDock *dock,
GimpDockbook *dockbook);
static void gimp_image_dock_dockbook_changed (GimpDockbook *dockbook,
GimpDockable *dockable,
GimpImageDock *dock);
static void gimp_image_dock_update_title (GimpImageDock *dock);
static void gimp_image_dock_factory_display_changed (GimpContext *context,
GimpObject *display,
GimpDock *dock);
static void gimp_image_dock_factory_image_changed (GimpContext *context,
GimpImage *gimage,
GimpDock *dock);
static void gimp_image_dock_image_changed (GimpContext *context,
GimpImage *gimage,
GimpDock *dock);
static void gimp_image_dock_auto_clicked (GtkWidget *widget,
GimpDock *dock);
#include "gimpmenufactory.h"
#include "gimpuimanager.h"
static void gimp_image_dock_class_init (GimpImageDockClass *klass);
static void gimp_image_dock_init (GimpImageDock *dock);
static GObject * gimp_image_dock_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_image_dock_destroy (GtkObject *object);
static void gimp_image_dock_display_changed (GimpContext *context,
GimpObject *display,
GimpImageDock *dock);
static void gimp_image_dock_image_flush (GimpImage *image,
GimpImageDock *dock);
static GimpDockClass *parent_class = NULL;
......@@ -127,8 +89,6 @@ gimp_image_dock_class_init (GimpImageDockClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GimpDockClass *dock_class = GIMP_DOCK_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
......@@ -136,72 +96,14 @@ gimp_image_dock_class_init (GimpImageDockClass *klass)
gtk_object_class->destroy = gimp_image_dock_destroy;
widget_class->style_set = gimp_image_dock_style_set;
dock_class->setup = gimp_image_dock_setup;
dock_class->set_aux_info = gimp_image_dock_set_aux_info;
dock_class->get_aux_info = gimp_image_dock_get_aux_info;
dock_class->book_added = gimp_image_dock_book_added;
dock_class->book_removed = gimp_image_dock_book_removed;
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("minimal-width",
NULL, NULL,
0,
G_MAXINT,
DEFAULT_MINIMAL_WIDTH,
G_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_enum ("menu-preview-size",
NULL, NULL,
GTK_TYPE_ICON_SIZE,
DEFAULT_MENU_PREVIEW_SIZE,
G_PARAM_READABLE));
klass->ui_manager_name = "<Dock>";
}
static void
gimp_image_dock_init (GimpImageDock *dock)
{
GtkWidget *hbox;
dock->image_container = NULL;
dock->display_container = NULL;
dock->show_image_menu = FALSE;
dock->auto_follow_active = TRUE;
dock->update_title_idle_id = 0;
hbox = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (GIMP_DOCK (dock)->main_vbox), hbox,
FALSE, FALSE, 0);
gtk_box_reorder_child (GTK_BOX (GIMP_DOCK (dock)->main_vbox), hbox, 0);
if (dock->show_image_menu)
gtk_widget_show (hbox);
dock->image_combo = gimp_container_combo_box_new (NULL, NULL, 16, 1);
gtk_box_pack_start (GTK_BOX (hbox), dock->image_combo, TRUE, TRUE, 0);
gtk_widget_show (dock->image_combo);
g_signal_connect (dock->image_combo, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&dock->image_combo);
gimp_help_set_help_data (dock->image_combo, NULL, GIMP_HELP_DOCK_IMAGE_MENU);
dock->auto_button = gtk_toggle_button_new_with_label (_("Auto"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dock->auto_button),
dock->auto_follow_active);
gtk_box_pack_start (GTK_BOX (hbox), dock->auto_button, FALSE, FALSE, 0);
gtk_widget_show (dock->auto_button);
g_signal_connect (dock->auto_button, "clicked",
G_CALLBACK (gimp_image_dock_auto_clicked),
dock);
gimp_help_set_help_data (dock->auto_button,
_("When enabled the dialog automatically "
"follows the image you are working on."),
GIMP_HELP_DOCK_AUTO_BUTTON);
dock->ui_manager = NULL;
dock->image_flush_handler_id = 0;
}
static GObject *
......@@ -211,477 +113,76 @@ gimp_image_dock_constructor (GType type,
{
GObject *object;
GimpImageDock *dock;
GimpGuiConfig *config;
GtkAccelGroup *accel_group;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
dock = GIMP_IMAGE_DOCK (object);
return object;
}
config = GIMP_GUI_CONFIG (GIMP_DOCK (dock)->context->gimp->config);
static void
gimp_image_dock_destroy (GtkObject *object)
{
GimpImageDock *dock = GIMP_IMAGE_DOCK (object);
dock->ui_manager =
gimp_menu_factory_manager_new (GIMP_DOCK (dock)->dialog_factory->menu_factory,
GIMP_IMAGE_DOCK_GET_CLASS (dock)->ui_manager_name,
dock,
config->tearoff_menus);
if (dock->update_title_idle_id)
{
g_source_remove (dock->update_title_idle_id);
dock->update_title_idle_id = 0;
}
accel_group =
gtk_ui_manager_get_accel_group (GTK_UI_MANAGER (dock->ui_manager));
/* remove the image menu and the auto button manually here because
* of weird cross-connections with GimpDock's context
*/
if (GIMP_DOCK (dock)->main_vbox &&
dock->image_combo &&
dock->image_combo->parent)
{