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

added "book_added" and "book_removed" signals. Removed the

2002-10-25  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpdock.[ch]: added "book_added" and "book_removed"
	signals. Removed the "destroy_if_empty" flag and destroy empty
	docks in book_removed's default implementation.

	* app/widgets/gimptoolbox.c: implement "dock_added" and
	"dock_removed" and set the window to freely resizable vertically
	if it contains dockbooks, and to the current behaviour of snapping
	to multiples of tool_button height otherwise. Fixes bug #93309.

	* app/widgets/gimpimagedock.c: changed accordingly.
parent f8124260
2002-10-25 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpdock.[ch]: added "book_added" and "book_removed"
signals. Removed the "destroy_if_empty" flag and destroy empty
docks in book_removed's default implementation.
* app/widgets/gimptoolbox.c: implement "dock_added" and
"dock_removed" and set the window to freely resizable vertically
if it contains dockbooks, and to the current behaviour of snapping
to multiples of tool_button height otherwise. Fixes bug #93309.
* app/widgets/gimpimagedock.c: changed accordingly.
2002-10-25 Michael Natterer <mitch@gimp.org>
 
* app/display/gimpdisplayshell.c
......@@ -20,7 +33,7 @@
* plug-ins/gfig/gfig.c
* plug-ins/gimpressionist/general.c
* plug-ins/gimpressionist/gimpressionist.c: replaced all sorts of
gtk_widget_show()/gdk_window_rise() combinations by
gtk_widget_show()/gdk_window_raise() combinations by
gtk_window_present().
 
2002-10-25 Michael Natterer <mitch@gimp.org>
......
......@@ -28,6 +28,7 @@
#include "widgets-types.h"
#include "core/gimpcontext.h"
#include "core/gimpmarshal.h"
#include "gimpdialogfactory.h"
#include "gimpdnd.h"
......@@ -39,6 +40,14 @@
#define DEFAULT_SEPARATOR_HEIGHT 6
enum
{
BOOK_ADDED,
BOOK_REMOVED,
LAST_SIGNAL
};
static void gimp_dock_class_init (GimpDockClass *klass);
static void gimp_dock_init (GimpDock *dock);
......@@ -48,6 +57,11 @@ static void gimp_dock_destroy (GtkObject *object);
static void gimp_dock_style_set (GtkWidget *widget,
GtkStyle *prev_style);
static void gimp_dock_real_book_added (GimpDock *dock,
GimpDockbook *dockbook);
static void gimp_dock_real_book_removed (GimpDock *dock,
GimpDockbook *dockbook);
static gboolean gimp_dock_separator_button_press (GtkWidget *widget,
GdkEventButton *bevent,
gpointer data);
......@@ -74,6 +88,8 @@ 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
......@@ -119,10 +135,33 @@ gimp_dock_class_init (GimpDockClass *klass)
parent_class = g_type_class_peek_parent (klass);
dock_signals[BOOK_ADDED] =
g_signal_new ("book_added",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpDockClass, book_added),
NULL, NULL,
gimp_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
GIMP_TYPE_DOCKBOOK);
dock_signals[BOOK_REMOVED] =
g_signal_new ("book_removed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpDockClass, book_removed),
NULL, NULL,
gimp_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
GIMP_TYPE_DOCKBOOK);
object_class->destroy = gimp_dock_destroy;
widget_class->style_set = gimp_dock_style_set;
klass->book_added = gimp_dock_real_book_added;
klass->book_added = gimp_dock_real_book_removed;
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("separator_height",
NULL, NULL,
......@@ -137,8 +176,7 @@ gimp_dock_init (GimpDock *dock)
{
GtkWidget *separator;
dock->context = NULL;
dock->destroy_if_empty = FALSE;
dock->context = NULL;
gtk_window_set_wmclass (GTK_WINDOW (dock), "dock", "Gimp");
gtk_window_set_resizable (GTK_WINDOW (dock), TRUE);
......@@ -208,6 +246,20 @@ gimp_dock_style_set (GtkWidget *widget,
g_list_free (children);
}
static void
gimp_dock_real_book_added (GimpDock *dock,
GimpDockbook *dockbook)
{
}
static void
gimp_dock_real_book_removed (GimpDock *dock,
GimpDockbook *dockbook)
{
if (dock->dockbooks == NULL)
gtk_widget_destroy (GTK_WIDGET (dock));
}
static GtkWidget *
gimp_dock_separator_new (GimpDock *dock)
{
......@@ -251,16 +303,14 @@ gimp_dock_separator_new (GimpDock *dock)
gboolean
gimp_dock_construct (GimpDock *dock,
GimpDialogFactory *dialog_factory,
GimpContext *context,
gboolean destroy_if_empty)
GimpContext *context)
{
g_return_val_if_fail (GIMP_IS_DOCK (dock), FALSE);
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (dialog_factory), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
dock->dialog_factory = dialog_factory;
dock->context = context;
dock->destroy_if_empty = destroy_if_empty ? TRUE : FALSE;
dock->dialog_factory = dialog_factory;
dock->context = context;
g_object_ref (G_OBJECT (dock->context));
......@@ -385,6 +435,8 @@ gimp_dock_add_book (GimpDock *dock,
}
gtk_widget_show (GTK_WIDGET (dockbook));
g_signal_emit (G_OBJECT (dock), dock_signals[BOOK_ADDED], 0, dockbook);
}
void
......@@ -405,6 +457,8 @@ gimp_dock_remove_book (GimpDock *dock,
dockbook->dock = NULL;
dock->dockbooks = g_list_remove (dock->dockbooks, dockbook);
g_object_ref (dockbook);
if (old_length == 1)
{
GtkWidget *separator;
......@@ -448,10 +502,9 @@ gimp_dock_remove_book (GimpDock *dock,
g_object_unref (G_OBJECT (other_book));
}
if ((old_length == 1) && (dock->destroy_if_empty))
{
gtk_widget_destroy (GTK_WIDGET (dock));
}
g_signal_emit (G_OBJECT (dock), dock_signals[BOOK_REMOVED], 0, dockbook);
g_object_unref (dockbook);
}
static gboolean
......
......@@ -42,7 +42,6 @@ struct _GimpDock
GimpDialogFactory *dialog_factory;
GimpContext *context;
gboolean destroy_if_empty;
GtkWidget *main_vbox;
GtkWidget *vbox;
......@@ -53,6 +52,11 @@ struct _GimpDock
struct _GimpDockClass
{
GtkWindowClass parent_class;
void (* book_added) (GimpDock *dock,
GimpDockbook *dockbook);
void (* book_removed) (GimpDock *dock,
GimpDockbook *dockbook);
};
......@@ -60,8 +64,7 @@ GType gimp_dock_get_type (void) G_GNUC_CONST;
gboolean gimp_dock_construct (GimpDock *dock,
GimpDialogFactory *dialog_factory,
GimpContext *context,
gboolean destroy_if_empty);
GimpContext *context);
void gimp_dock_add (GimpDock *dock,
GimpDockable *dockable,
......
......@@ -264,7 +264,7 @@ gimp_image_dock_new (GimpDialogFactory *dialog_factory,
context = gimp_context_new (dialog_factory->context->gimp,
"Dock Context", NULL);
gimp_dock_construct (GIMP_DOCK (image_dock), dialog_factory, context, TRUE);
gimp_dock_construct (GIMP_DOCK (image_dock), dialog_factory, context);
gimp_context_define_properties (context,
GIMP_CONTEXT_ALL_PROPS_MASK &
......
......@@ -264,7 +264,7 @@ gimp_image_dock_new (GimpDialogFactory *dialog_factory,
context = gimp_context_new (dialog_factory->context->gimp,
"Dock Context", NULL);
gimp_dock_construct (GIMP_DOCK (image_dock), dialog_factory, context, TRUE);
gimp_dock_construct (GIMP_DOCK (image_dock), dialog_factory, context);
gimp_context_define_properties (context,
GIMP_CONTEXT_ALL_PROPS_MASK &
......
......@@ -66,6 +66,11 @@ static void gimp_toolbox_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gimp_toolbox_style_set (GtkWidget *widget,
GtkStyle *previous_style);
static void gimp_toolbox_book_added (GimpDock *dock,
GimpDockbook *dockbook);
static void gimp_toolbox_book_removed (GimpDock *dock,
GimpDockbook *dockbook);
static void gimp_toolbox_set_geometry (GimpToolbox *toolbox);
static void toolbox_create_tools (GimpToolbox *toolbox,
GimpContext *context);
......@@ -79,14 +84,14 @@ static void toolbox_tool_changed (GimpContext *context,
gpointer data);
static void toolbox_tool_button_toggled (GtkWidget *widget,
gpointer data);
GimpToolInfo *tool_info);
static gboolean toolbox_tool_button_press (GtkWidget *widget,
GdkEventButton *bevent,
GimpToolbox *toolbox);
static gboolean toolbox_check_device (GtkWidget *widget,
GdkEvent *event,
gpointer data);
Gimp *gimp);
static void toolbox_drop_drawable (GtkWidget *widget,
GimpViewable *viewable,
......@@ -136,8 +141,10 @@ static void
gimp_toolbox_class_init (GimpToolboxClass *klass)
{
GtkWidgetClass *widget_class;
GimpDockClass *dock_class;
widget_class = GTK_WIDGET_CLASS (klass);
dock_class = GIMP_DOCK_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
......@@ -145,6 +152,9 @@ gimp_toolbox_class_init (GimpToolboxClass *klass)
widget_class->size_allocate = gimp_toolbox_size_allocate;
widget_class->style_set = gimp_toolbox_style_set;
dock_class->book_added = gimp_toolbox_book_added;
dock_class->book_removed = gimp_toolbox_book_removed;
gtk_widget_class_install_style_property
(widget_class,
g_param_spec_enum ("tool_icon_size",
......@@ -331,6 +341,35 @@ gimp_toolbox_style_set (GtkWidget *widget,
}
}
gimp_toolbox_set_geometry (GIMP_TOOLBOX (widget));
}
static void
gimp_toolbox_book_added (GimpDock *dock,
GimpDockbook *dockbook)
{
if (g_list_length (dock->dockbooks) == 1)
gimp_toolbox_set_geometry (GIMP_TOOLBOX (dock));
}
static void
gimp_toolbox_book_removed (GimpDock *dock,
GimpDockbook *dockbook)
{
if (dock->dockbooks == NULL &&
! (GTK_OBJECT_FLAGS (dock) & GTK_IN_DESTRUCTION))
gimp_toolbox_set_geometry (GIMP_TOOLBOX (dock));
}
static void
gimp_toolbox_set_geometry (GimpToolbox *toolbox)
{
Gimp *gimp;
GimpToolInfo *tool_info;
GtkWidget *tool_button;
gimp = GIMP_DOCK (toolbox)->context->gimp;
tool_info = (GimpToolInfo *)
gimp_container_get_child_by_name (gimp->tool_info_list,
"gimp-rect-select-tool");
......@@ -338,7 +377,6 @@ gimp_toolbox_style_set (GtkWidget *widget,
if (tool_button)
{
GimpToolbox *toolbox;
GtkWidget *main_vbox;
GtkRequisition menubar_requisition;
GtkRequisition button_requisition;
......@@ -349,8 +387,7 @@ gimp_toolbox_style_set (GtkWidget *widget,
gint separator_height;
GdkGeometry geometry;
toolbox = GIMP_TOOLBOX (widget);
main_vbox = GIMP_DOCK (widget)->main_vbox;
main_vbox = GIMP_DOCK (toolbox)->main_vbox;
gtk_widget_size_request (toolbox->menu_bar, &menubar_requisition);
gtk_widget_size_request (tool_button, &button_requisition);
......@@ -361,7 +398,7 @@ gimp_toolbox_style_set (GtkWidget *widget,
spacing = gtk_box_get_spacing (GTK_BOX (main_vbox));
gtk_widget_style_get (widget,
gtk_widget_style_get (GTK_WIDGET (toolbox),
"separator_height", &separator_height,
NULL);
......@@ -375,9 +412,10 @@ gimp_toolbox_style_set (GtkWidget *widget,
MAX (color_requisition.height,
indicator_requisition.height));
geometry.width_inc = button_requisition.width;
geometry.height_inc = button_requisition.height;
geometry.height_inc = (GIMP_DOCK (toolbox)->dockbooks ?
1 : button_requisition.height);
gtk_window_set_geometry_hints (GTK_WINDOW (widget),
gtk_window_set_geometry_hints (GTK_WINDOW (toolbox),
NULL,
&geometry,
GDK_HINT_MIN_SIZE | GDK_HINT_RESIZE_INC);
......@@ -399,7 +437,7 @@ gimp_toolbox_new (GimpDialogFactory *dialog_factory,
toolbox = g_object_new (GIMP_TYPE_TOOLBOX, NULL);
gimp_dock_construct (GIMP_DOCK (toolbox), dialog_factory, context, FALSE);
gimp_dock_construct (GIMP_DOCK (toolbox), dialog_factory, context);
/* We need to know when the current device changes, so we can update
* the correct tool - to do this we connect to motion events.
......@@ -751,14 +789,10 @@ toolbox_tool_changed (GimpContext *context,
}
static void
toolbox_tool_button_toggled (GtkWidget *widget,
gpointer data)
toolbox_tool_button_toggled (GtkWidget *widget,
GimpToolInfo *tool_info)
{
GimpToolInfo *tool_info;
tool_info = GIMP_TOOL_INFO (data);
if ((tool_info) && GTK_TOGGLE_BUTTON (widget)->active)
if (GTK_TOGGLE_BUTTON (widget)->active)
gimp_context_set_tool (gimp_get_user_context (tool_info->gimp), tool_info);
}
......@@ -780,9 +814,9 @@ toolbox_tool_button_press (GtkWidget *widget,
static gboolean
toolbox_check_device (GtkWidget *widget,
GdkEvent *event,
gpointer data)
Gimp *gimp)
{
gimp_devices_check_change (GIMP (data), event);
gimp_devices_check_change (gimp, event);
return FALSE;
}
......@@ -804,9 +838,9 @@ toolbox_drop_drawable (GtkWidget *widget,
drawable = GIMP_DRAWABLE (viewable);
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
width = gimp_drawable_width (drawable);
width = gimp_drawable_width (drawable);
height = gimp_drawable_height (drawable);
bytes = gimp_drawable_bytes (drawable);
bytes = gimp_drawable_bytes (drawable);
type = GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (drawable));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment