summaryrefslogtreecommitdiffstats
path: root/src/libgdl/gdl-dock-item.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libgdl/gdl-dock-item.c')
-rw-r--r--src/libgdl/gdl-dock-item.c702
1 files changed, 522 insertions, 180 deletions
diff --git a/src/libgdl/gdl-dock-item.c b/src/libgdl/gdl-dock-item.c
index 01a777bad..50be88583 100644
--- a/src/libgdl/gdl-dock-item.c
+++ b/src/libgdl/gdl-dock-item.c
@@ -37,7 +37,6 @@
#include <string.h>
#include <gdk/gdkkeysyms.h>
-#include "gdl-tools.h"
#include "gdl-dock.h"
#include "gdl-dock-item.h"
#include "gdl-dock-item-grip.h"
@@ -54,7 +53,6 @@
/* ----- Private prototypes ----- */
static void gdl_dock_item_class_init (GdlDockItemClass *class);
-static void gdl_dock_item_instance_init (GdlDockItem *item);
static GObject *gdl_dock_item_constructor (GType type,
guint n_construct_properties,
@@ -79,11 +77,10 @@ static void gdl_dock_item_forall (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
gpointer callback_data);
-static GtkType gdl_dock_item_child_type (GtkContainer *container);
+static GType gdl_dock_item_child_type (GtkContainer *container);
static void gdl_dock_item_set_focus_child (GtkContainer *container,
- GtkWidget *widget,
- gpointer callback_data);
+ GtkWidget *widget);
static void gdl_dock_item_size_request (GtkWidget *widget,
GtkRequisition *requisition);
@@ -164,6 +161,7 @@ enum {
DOCK_DRAG_BEGIN,
DOCK_DRAG_MOTION,
DOCK_DRAG_END,
+ SELECTED,
MOVE_FOCUS_CHILD,
LAST_SIGNAL
};
@@ -181,12 +179,15 @@ struct _GdlDockItemPrivate {
guint grip_size;
GtkWidget *tab_label;
+ gboolean intern_tab_label;
+ guint notify_label;
+ guint notify_stock_id;
gint preferred_width;
gint preferred_height;
GdlDockPlaceholder *ph;
-
+
gint start_x, start_y;
};
@@ -197,7 +198,7 @@ struct _GdlDockItemPrivate {
/* ----- Private functions ----- */
-GDL_CLASS_BOILERPLATE (GdlDockItem, gdl_dock_item, GdlDockObject, GDL_TYPE_DOCK_OBJECT);
+G_DEFINE_TYPE (GdlDockItem, gdl_dock_item, GDL_TYPE_DOCK_OBJECT);
static void
add_tab_bindings (GtkBindingSet *binding_set,
@@ -282,6 +283,16 @@ gdl_dock_item_class_init (GdlDockItemClass *klass)
/* properties */
+ /**
+ * GdlDockItem:orientation:
+ *
+ * The orientation of the docking item. If the orientation is set to
+ * #GTK_ORIENTATION_VERTICAL, the grip widget will be shown along
+ * the top of the edge of item (if it is not hidden). If the
+ * orientation is set to #GTK_ORIENTATION_HORIZONTAL, the grip
+ * widget will be shown down the left edge of the item (even if the
+ * widget text direction is set to RTL).
+ */
g_object_class_install_property (
g_object_class, PROP_ORIENTATION,
g_param_spec_enum ("orientation", _("Orientation"),
@@ -302,7 +313,7 @@ gdl_dock_item_class_init (GdlDockItemClass *klass)
g_object_class, PROP_RESIZE,
g_param_spec_boolean ("resize", _("Resizable"),
_("If set, the dock item can be resized when "
- "docked in a panel"),
+ "docked in a GtkPanel widget"),
TRUE,
G_PARAM_READWRITE));
@@ -340,6 +351,12 @@ gdl_dock_item_class_init (GdlDockItemClass *klass)
/* signals */
+ /**
+ * GdlDockItem::dock-drag-begin:
+ * @item: The dock item which is being dragged.
+ *
+ * Signals that the dock item has begun to be dragged.
+ **/
gdl_dock_item_signals [DOCK_DRAG_BEGIN] =
g_signal_new ("dock-drag-begin",
G_TYPE_FROM_CLASS (klass),
@@ -350,7 +367,15 @@ gdl_dock_item_class_init (GdlDockItemClass *klass)
gdl_marshal_VOID__VOID,
G_TYPE_NONE,
0);
-
+
+ /**
+ * GdlDockItem::dock-drag-motion:
+ * @item: The dock item which is being dragged.
+ * @x: The x-position that the dock item has been dragged to.
+ * @y: The y-position that the dock item has been dragged to.
+ *
+ * Signals that a dock item dragging motion event has occured.
+ **/
gdl_dock_item_signals [DOCK_DRAG_MOTION] =
g_signal_new ("dock-drag-motion",
G_TYPE_FROM_CLASS (klass),
@@ -364,6 +389,14 @@ gdl_dock_item_class_init (GdlDockItemClass *klass)
G_TYPE_INT,
G_TYPE_INT);
+ /**
+ * GdlDockItem::dock-drag-end:
+ * @item: The dock item which is no longer being dragged.
+ * @cancel: This value is set to TRUE if the drag was cancelled by
+ * the user. #cancel is set to FALSE if the drag was accepted.
+ *
+ * Signals that the dock item dragging has ended.
+ **/
gdl_dock_item_signals [DOCK_DRAG_END] =
g_signal_new ("dock_drag_end",
G_TYPE_FROM_CLASS (klass),
@@ -376,6 +409,22 @@ gdl_dock_item_class_init (GdlDockItemClass *klass)
1,
G_TYPE_BOOLEAN);
+ /**
+ * GdlDockItem::selected:
+ *
+ * Signals that this dock has been selected from a switcher.
+ */
+ gdl_dock_item_signals [SELECTED] =
+ g_signal_new ("selected",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
gdl_dock_item_signals [MOVE_FOCUS_CHILD] =
g_signal_new ("move_focus_child",
G_TYPE_FROM_CLASS (klass),
@@ -424,10 +473,10 @@ gdl_dock_item_class_init (GdlDockItemClass *klass)
}
static void
-gdl_dock_item_instance_init (GdlDockItem *item)
+gdl_dock_item_init (GdlDockItem *item)
{
- GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET (item), GTK_NO_WINDOW);
- GTK_WIDGET_SET_FLAGS (GTK_WIDGET (item), GTK_CAN_FOCUS);
+ gtk_widget_set_has_window (GTK_WIDGET (item), TRUE);
+ gtk_widget_set_can_focus (GTK_WIDGET (item), TRUE);
item->child = NULL;
@@ -443,10 +492,33 @@ gdl_dock_item_instance_init (GdlDockItem *item)
item->_priv->preferred_width = item->_priv->preferred_height = -1;
item->_priv->tab_label = NULL;
+ item->_priv->intern_tab_label = FALSE;
item->_priv->ph = NULL;
}
+static void
+on_long_name_changed (GObject* item,
+ GParamSpec* spec,
+ gpointer user_data)
+{
+ gchar* long_name;
+ g_object_get (item, "long-name", &long_name, NULL);
+ gtk_label_set_label (GTK_LABEL (user_data), long_name);
+ g_free(long_name);
+}
+
+static void
+on_stock_id_changed (GObject* item,
+ GParamSpec* spec,
+ gpointer user_data)
+{
+ gchar* stock_id;
+ g_object_get (item, "stock_id", &stock_id, NULL);
+ gtk_image_set_from_stock (GTK_IMAGE (user_data), stock_id, GTK_ICON_SIZE_MENU);
+ g_free(stock_id);
+}
+
static GObject *
gdl_dock_item_constructor (GType type,
guint n_construct_properties,
@@ -454,14 +526,16 @@ gdl_dock_item_constructor (GType type,
{
GObject *g_object;
- g_object = GDL_CALL_PARENT_WITH_DEFAULT (G_OBJECT_CLASS,
- constructor,
- (type,
- n_construct_properties,
- construct_param),
- NULL);
+ g_object = G_OBJECT_CLASS (gdl_dock_item_parent_class)-> constructor (type,
+ n_construct_properties,
+ construct_param);
if (g_object) {
GdlDockItem *item = GDL_DOCK_ITEM (g_object);
+ GtkWidget *hbox;
+ GtkWidget *label;
+ GtkWidget *icon;
+ gchar* long_name;
+ gchar* stock_id;
if (GDL_DOCK_ITEM_HAS_GRIP (item)) {
item->_priv->grip_shown = TRUE;
@@ -472,6 +546,32 @@ gdl_dock_item_constructor (GType type,
else {
item->_priv->grip_shown = FALSE;
}
+
+ g_object_get (g_object, "long-name", &long_name, "stock-id", &stock_id, NULL);
+
+ hbox = gtk_hbox_new (FALSE, 5);
+ label = gtk_label_new (long_name);
+ icon = gtk_image_new ();
+ if (stock_id)
+ gtk_image_set_from_stock (GTK_IMAGE (icon), stock_id,
+ GTK_ICON_SIZE_MENU);
+ gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ item->_priv->notify_label =
+ g_signal_connect (item, "notify::long-name", G_CALLBACK (on_long_name_changed),
+ label);
+ item->_priv->notify_stock_id =
+ g_signal_connect (item, "notify::stock-id", G_CALLBACK (on_stock_id_changed),
+ icon);
+
+ gtk_widget_show_all (hbox);
+
+ gdl_dock_item_set_tablabel (item, hbox);
+ item->_priv->intern_tab_label = TRUE;
+
+ g_free (long_name);
+ g_free (stock_id);
}
return g_object;
@@ -600,7 +700,7 @@ gdl_dock_item_destroy (GtkObject *object)
g_free (priv);
}
- GDL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
+ GTK_OBJECT_CLASS (gdl_dock_item_parent_class)->destroy (object);
}
static void
@@ -644,7 +744,7 @@ gdl_dock_item_remove (GtkContainer *container,
item = GDL_DOCK_ITEM (container);
if (item->_priv && widget == item->_priv->grip) {
- gboolean grip_was_visible = GTK_WIDGET_VISIBLE (widget);
+ gboolean grip_was_visible = gtk_widget_get_visible (widget);
gtk_widget_unparent (widget);
item->_priv->grip = NULL;
if (grip_was_visible)
@@ -658,7 +758,7 @@ gdl_dock_item_remove (GtkContainer *container,
g_return_if_fail (item->child == widget);
- was_visible = GTK_WIDGET_VISIBLE (widget);
+ was_visible = gtk_widget_get_visible (widget);
gtk_widget_unparent (widget);
item->child = NULL;
@@ -684,7 +784,7 @@ gdl_dock_item_forall (GtkContainer *container,
(* callback) (item->child, callback_data);
}
-static GtkType
+static GType
gdl_dock_item_child_type (GtkContainer *container)
{
g_return_val_if_fail (GDL_IS_DOCK_ITEM (container), G_TYPE_NONE);
@@ -697,13 +797,13 @@ gdl_dock_item_child_type (GtkContainer *container)
static void
gdl_dock_item_set_focus_child (GtkContainer *container,
- GtkWidget *child,
- gpointer callback_data)
+ GtkWidget *child)
{
g_return_if_fail (GDL_IS_DOCK_ITEM (container));
- if (GTK_CONTAINER_CLASS (parent_class)->set_focus_child)
- (* GTK_CONTAINER_CLASS (parent_class)->set_focus_child) (container, child);
+ if (GTK_CONTAINER_CLASS (gdl_dock_item_parent_class)->set_focus_child) {
+ (* GTK_CONTAINER_CLASS (gdl_dock_item_parent_class)->set_focus_child) (container, child);
+ }
gdl_dock_item_showhide_grip (GDL_DOCK_ITEM (container));
}
@@ -712,9 +812,11 @@ static void
gdl_dock_item_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
+ GdlDockItem *item;
GtkRequisition child_requisition;
GtkRequisition grip_requisition;
- GdlDockItem *item;
+ GtkStyle *style;
+ guint border_width;
g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
g_return_if_fail (requisition != NULL);
@@ -758,10 +860,13 @@ gdl_dock_item_size_request (GtkWidget *widget,
requisition->width = 0;
}
- requisition->width += (GTK_CONTAINER (widget)->border_width + widget->style->xthickness) * 2;
- requisition->height += (GTK_CONTAINER (widget)->border_width + widget->style->ythickness) * 2;
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+ style = gtk_widget_get_style (widget);
- widget->requisition = *requisition;
+ requisition->width += (border_width + style->xthickness) * 2;
+ requisition->height += (border_width + style->ythickness) * 2;
+
+ //gtk_widget_size_request (widget, requisition);
}
static void
@@ -775,31 +880,33 @@ gdl_dock_item_size_allocate (GtkWidget *widget,
item = GDL_DOCK_ITEM (widget);
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
/* Once size is allocated, preferred size is no longer necessary */
item->_priv->preferred_height = -1;
item->_priv->preferred_width = -1;
- if (GTK_WIDGET_REALIZED (widget))
- gdk_window_move_resize (widget->window,
- widget->allocation.x,
- widget->allocation.y,
- widget->allocation.width,
- widget->allocation.height);
-
- if (item->child && GTK_WIDGET_VISIBLE (item->child)) {
+ if (gtk_widget_get_realized (widget))
+ gdk_window_move_resize (gtk_widget_get_window (widget),
+ allocation->x,
+ allocation->y,
+ allocation->width,
+ allocation->height);
+
+ if (item->child && gtk_widget_get_visible (item->child)) {
GtkAllocation child_allocation;
- int border_width;
+ GtkStyle *style;
+ guint border_width;
- border_width = GTK_CONTAINER (widget)->border_width;
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+ style = gtk_widget_get_style (widget);
- child_allocation.x = border_width + widget->style->xthickness;
- child_allocation.y = border_width + widget->style->ythickness;
+ child_allocation.x = border_width + style->xthickness;
+ child_allocation.y = border_width + style->ythickness;
child_allocation.width = allocation->width
- - 2 * (border_width + widget->style->xthickness);
+ - 2 * (border_width + style->xthickness);
child_allocation.height = allocation->height
- - 2 * (border_width + widget->style->ythickness);
+ - 2 * (border_width + style->ythickness);
if (GDL_DOCK_ITEM_GRIP_SHOWN (item)) {
GtkAllocation grip_alloc = child_allocation;
@@ -836,20 +943,20 @@ gdl_dock_item_map (GtkWidget *widget)
g_return_if_fail (widget != NULL);
g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
- GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
+ gtk_widget_set_mapped (widget, TRUE);
item = GDL_DOCK_ITEM (widget);
- gdk_window_show (widget->window);
+ gdk_window_show (gtk_widget_get_window (widget));
if (item->child
- && GTK_WIDGET_VISIBLE (item->child)
- && !GTK_WIDGET_MAPPED (item->child))
+ && gtk_widget_get_visible (item->child)
+ && !gtk_widget_get_mapped (item->child))
gtk_widget_map (item->child);
if (item->_priv->grip
- && GTK_WIDGET_VISIBLE (item->_priv->grip)
- && !GTK_WIDGET_MAPPED (item->_priv->grip))
+ && gtk_widget_get_visible (GTK_WIDGET (item->_priv->grip))
+ && !gtk_widget_get_mapped (GTK_WIDGET (item->_priv->grip)))
gtk_widget_map (item->_priv->grip);
}
@@ -861,11 +968,11 @@ gdl_dock_item_unmap (GtkWidget *widget)
g_return_if_fail (widget != NULL);
g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
+ gtk_widget_set_mapped (widget, FALSE);
item = GDL_DOCK_ITEM (widget);
- gdk_window_hide (widget->window);
+ gdk_window_hide (gtk_widget_get_window (widget));
if (item->_priv->grip)
gtk_widget_unmap (item->_priv->grip);
@@ -874,22 +981,25 @@ gdl_dock_item_unmap (GtkWidget *widget)
static void
gdl_dock_item_realize (GtkWidget *widget)
{
+ GdlDockItem *item;
+ GtkAllocation allocation;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
- GdlDockItem *item;
g_return_if_fail (widget != NULL);
g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
item = GDL_DOCK_ITEM (widget);
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+ gtk_widget_set_realized (widget, TRUE);
/* widget window */
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ gtk_widget_get_allocation (widget, &allocation);
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
@@ -900,34 +1010,42 @@ gdl_dock_item_realize (GtkWidget *widget)
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK);
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, widget->window,
- GTK_WIDGET_STATE (item));
- gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
+ gdk_window_set_user_data (window, widget);
+
+ gtk_widget_style_attach (widget);
+ gtk_style_set_background (gtk_widget_get_style (widget), window,
+ gtk_widget_get_state (GTK_WIDGET (item)));
+ gdk_window_set_back_pixmap (window, NULL, TRUE);
if (item->child)
- gtk_widget_set_parent_window (item->child, widget->window);
-
+ gtk_widget_set_parent_window (item->child, window);
+
if (item->_priv->grip)
- gtk_widget_set_parent_window (item->_priv->grip, widget->window);
+ gtk_widget_set_parent_window (item->_priv->grip, window);
}
static void
gdl_dock_item_style_set (GtkWidget *widget,
GtkStyle *previous_style)
{
+ GdkWindow *window;
+ (void)previous_style;
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
- if (GTK_WIDGET_REALIZED (widget) && !GTK_WIDGET_NO_WINDOW (widget)) {
- gtk_style_set_background (widget->style, widget->window,
- widget->state);
- if (GTK_WIDGET_DRAWABLE (widget))
- gdk_window_clear (widget->window);
+ if (gtk_widget_get_realized (widget) &&
+ gtk_widget_get_has_window (widget))
+ {
+ window = gtk_widget_get_window (widget);
+ gtk_style_set_background (gtk_widget_get_style (widget),
+ window,
+ gtk_widget_get_state (widget));
+ if (gtk_widget_is_drawable (widget))
+ gdk_window_clear (window);
}
}
@@ -939,9 +1057,9 @@ gdl_dock_item_paint (GtkWidget *widget,
item = GDL_DOCK_ITEM (widget);
- gtk_paint_box (widget->style,
- widget->window,
- GTK_WIDGET_STATE (widget),
+ gtk_paint_box (gtk_widget_get_style (widget),
+ gtk_widget_get_window (widget),
+ gtk_widget_get_state (widget),
GTK_SHADOW_NONE,
&event->area, widget,
"dockitem",
@@ -956,9 +1074,11 @@ gdl_dock_item_expose (GtkWidget *widget,
g_return_val_if_fail (GDL_IS_DOCK_ITEM (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
- if (GTK_WIDGET_DRAWABLE (widget) && event->window == widget->window) {
+ if (gtk_widget_is_drawable (widget) &&
+ event->window == gtk_widget_get_window (widget))
+ {
gdl_dock_item_paint (widget, event);
- GDL_CALL_PARENT_GBOOLEAN(GTK_WIDGET_CLASS, expose_event, (widget,event));
+ GTK_WIDGET_CLASS (gdl_dock_item_parent_class)->expose_event (widget,event);
}
return FALSE;
@@ -983,10 +1103,11 @@ gdl_dock_item_button_changed (GtkWidget *widget,
GdkEventButton *event)
{
GdlDockItem *item;
+ GtkAllocation allocation;
+ GdkCursor *cursor;
gboolean locked;
gboolean event_handled;
gboolean in_handle;
- GdkCursor *cursor;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GDL_IS_DOCK_ITEM (widget), FALSE);
@@ -1001,13 +1122,15 @@ gdl_dock_item_button_changed (GtkWidget *widget,
event_handled = FALSE;
+ gtk_widget_get_allocation (item->_priv->grip, &allocation);
+
/* Check if user clicked on the drag handle. */
switch (item->orientation) {
case GTK_ORIENTATION_HORIZONTAL:
- in_handle = event->x < item->_priv->grip->allocation.width;
+ in_handle = event->x < allocation.width;
break;
case GTK_ORIENTATION_VERTICAL:
- in_handle = event->y < item->_priv->grip->allocation.height;
+ in_handle = event->y < allocation.height;
break;
default:
in_handle = FALSE;
@@ -1123,10 +1246,7 @@ gdl_dock_item_key_press (GtkWidget *widget,
if (event_handled)
return TRUE;
else
- return GDL_CALL_PARENT_WITH_DEFAULT (GTK_WIDGET_CLASS,
- key_press_event,
- (widget, event),
- FALSE);
+ return GTK_WIDGET_CLASS (gdl_dock_item_parent_class)->key_press_event (widget, event);
}
static gboolean
@@ -1135,21 +1255,21 @@ gdl_dock_item_dock_request (GdlDockObject *object,
gint y,
GdlDockRequest *request)
{
- GtkAllocation *alloc;
+ GtkAllocation alloc;
gint rel_x, rel_y;
/* we get (x,y) in our allocation coordinates system */
/* Get item's allocation. */
- alloc = &(GTK_WIDGET (object)->allocation);
+ gtk_widget_get_allocation (GTK_WIDGET (object), &alloc);
/* Get coordinates relative to our window. */
- rel_x = x - alloc->x;
- rel_y = y - alloc->y;
+ rel_x = x - alloc.x;
+ rel_y = y - alloc.y;
/* Location is inside. */
- if (rel_x > 0 && rel_x < alloc->width &&
- rel_y > 0 && rel_y < alloc->height) {
+ if (rel_x > 0 && rel_x < alloc.width &&
+ rel_y > 0 && rel_y < alloc.height) {
float rx, ry;
GtkRequisition my, other;
gint divider = -1;
@@ -1159,8 +1279,8 @@ gdl_dock_item_dock_request (GdlDockObject *object,
gdl_dock_item_preferred_size (GDL_DOCK_ITEM (object), &my);
/* Calculate location in terms of the available space (0-100%). */
- rx = (float) rel_x / alloc->width;
- ry = (float) rel_y / alloc->height;
+ rx = (float) rel_x / alloc.width;
+ ry = (float) rel_y / alloc.height;
/* Determine dock location. */
if (rx < SPLIT_RATIO) {
@@ -1186,8 +1306,8 @@ gdl_dock_item_dock_request (GdlDockObject *object,
/* Reset rectangle coordinates to entire item. */
request->rect.x = 0;
request->rect.y = 0;
- request->rect.width = alloc->width;
- request->rect.height = alloc->height;
+ request->rect.width = alloc.width;
+ request->rect.height = alloc.height;
GdlDockItemBehavior behavior = GDL_DOCK_ITEM(object)->behavior;
@@ -1234,8 +1354,8 @@ gdl_dock_item_dock_request (GdlDockObject *object,
/* adjust returned coordinates so they are have the same
origin as our window */
- request->rect.x += alloc->x;
- request->rect.y += alloc->y;
+ request->rect.x += alloc.x;
+ request->rect.y += alloc.y;
/* Set possible target location and return TRUE. */
request->target = object;
@@ -1260,8 +1380,10 @@ gdl_dock_item_dock (GdlDockObject *object,
GdlDockPlacement position,
GValue *other_data)
{
- GdlDockObject *new_parent, *parent;
- gboolean add_ourselves_first;
+ GdlDockObject *new_parent = NULL;
+ GdlDockObject *parent, *requestor_parent;
+ GtkAllocation allocation;
+ gboolean add_ourselves_first = FALSE;
guint available_space=0;
gint pref_size=-1;
@@ -1275,8 +1397,9 @@ gdl_dock_item_dock (GdlDockObject *object,
gdl_dock_item_preferred_size (GDL_DOCK_ITEM (parent), &parent_req);
else
{
- parent_req.height = GTK_WIDGET (parent)->allocation.height;
- parent_req.width = GTK_WIDGET (parent)->allocation.width;
+ gtk_widget_get_allocation (GTK_WIDGET (parent), &allocation);
+ parent_req.height = allocation.height;
+ parent_req.width = allocation.width;
}
/* If preferred size is not set on the requestor (perhaps a new item),
@@ -1375,11 +1498,16 @@ gdl_dock_item_dock (GdlDockObject *object,
pref_size = req.width;
break;
case GDL_DOCK_CENTER:
- new_parent = g_object_new (gdl_dock_object_type_from_nick ("notebook"),
- "preferred-width", object_req.width,
- "preferred-height", object_req.height,
- NULL);
- add_ourselves_first = TRUE;
+ /* If the parent is already a DockNotebook, we don't need
+ to create a new one. */
+ if (!GDL_IS_DOCK_NOTEBOOK (parent))
+ {
+ new_parent = g_object_new (gdl_dock_object_type_from_nick ("notebook"),
+ "preferred-width", object_req.width,
+ "preferred-height", object_req.height,
+ NULL);
+ add_ourselves_first = TRUE;
+ }
break;
default:
{
@@ -1398,52 +1526,73 @@ gdl_dock_item_dock (GdlDockObject *object,
if (parent)
gdl_dock_object_freeze (parent);
- /* ref ourselves since we could be destroyed when detached */
- g_object_ref (object);
- GDL_DOCK_OBJECT_SET_FLAGS (object, GDL_DOCK_IN_REFLOW);
- gdl_dock_object_detach (object, FALSE);
-
- /* freeze the new parent, so reduce won't get called before it's
- actually added to our parent */
- gdl_dock_object_freeze (new_parent);
- /* bind the new parent to our master, so the following adds work */
- gdl_dock_object_bind (new_parent, G_OBJECT (GDL_DOCK_OBJECT_GET_MASTER (object)));
+ if (new_parent)
+ {
+ /* ref ourselves since we could be destroyed when detached */
+ g_object_ref (object);
+ GDL_DOCK_OBJECT_SET_FLAGS (object, GDL_DOCK_IN_REFLOW);
+ gdl_dock_object_detach (object, FALSE);
+
+ /* freeze the new parent, so reduce won't get called before it's
+ actually added to our parent */
+ gdl_dock_object_freeze (new_parent);
- /* add the objects */
- if (add_ourselves_first) {
- gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (object));
- gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (requestor));
- splitpos = available_space - pref_size;
- } else {
- gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (requestor));
- gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (object));
- splitpos = pref_size;
- }
+ /* bind the new parent to our master, so the following adds work */
+ gdl_dock_object_bind (new_parent, G_OBJECT (GDL_DOCK_OBJECT_GET_MASTER (object)));
+
+ /* add the objects */
+ if (add_ourselves_first) {
+ gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (object));
+ gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (requestor));
+ splitpos = available_space - pref_size;
+ } else {
+ gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (requestor));
+ gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (object));
+ splitpos = pref_size;
+ }
- /* add the new parent to the parent */
- if (parent)
- gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (new_parent));
+ /* add the new parent to the parent */
+ if (parent)
+ gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (new_parent));
- /* show automatic object */
- if (GTK_WIDGET_VISIBLE (object))
- gtk_widget_show (GTK_WIDGET (new_parent));
-
- /* use extra docking parameter */
- if (position != GDL_DOCK_CENTER && other_data &&
- G_VALUE_HOLDS (other_data, G_TYPE_UINT)) {
+ /* show automatic object */
+ if (gtk_widget_get_visible (GTK_WIDGET (object)))
+ {
+ gtk_widget_show (GTK_WIDGET (new_parent));
+ GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_IN_REFLOW);
+ }
+ gdl_dock_object_thaw (new_parent);
+
+ /* use extra docking parameter */
+ if (position != GDL_DOCK_CENTER && other_data &&
+ G_VALUE_HOLDS (other_data, G_TYPE_UINT)) {
- g_object_set (G_OBJECT (new_parent),
- "position", g_value_get_uint (other_data),
- NULL);
- } else if (splitpos > 0 && splitpos < available_space) {
- g_object_set (G_OBJECT (new_parent), "position", splitpos, NULL);
+ g_object_set (G_OBJECT (new_parent),
+ "position", g_value_get_uint (other_data),
+ NULL);
+ } else if (splitpos > 0 && splitpos < available_space) {
+ g_object_set (G_OBJECT (new_parent), "position", splitpos, NULL);
+ }
+
+ g_object_unref (object);
+ }
+ else
+ {
+ /* If the parent is already a DockNotebook, we don't need
+ to create a new one. */
+ gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (requestor));
}
- GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_IN_REFLOW);
- g_object_unref (object);
-
- gdl_dock_object_thaw (new_parent);
+ requestor_parent = gdl_dock_object_get_parent_object (requestor);
+ if (GDL_IS_DOCK_NOTEBOOK (requestor_parent))
+ {
+ /* Activate the page we just added */
+ GdlDockItem* notebook = GDL_DOCK_ITEM (gdl_dock_object_get_parent_object (requestor));
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook->child),
+ gtk_notebook_page_num (GTK_NOTEBOOK (notebook->child), GTK_WIDGET (requestor)));
+ }
+
if (parent)
gdl_dock_object_thaw (parent);
@@ -1454,9 +1603,10 @@ static void
gdl_dock_item_detach_menu (GtkWidget *widget,
GtkMenu *menu)
{
- GdlDockItem *item;
-
- item = GDL_DOCK_ITEM (widget);
+ GdlDockItem *item = GDL_DOCK_ITEM(widget);
+
+ (void)menu;
+
item->_priv->menu = NULL;
}
@@ -1506,7 +1656,7 @@ gdl_dock_item_drag_start (GdlDockItem *item)
{
GdkCursor *fleur;
- if (!GTK_WIDGET_REALIZED (item))
+ if (!gtk_widget_get_realized (GTK_WIDGET (item)))
gtk_widget_realize (GTK_WIDGET (item));
GDL_DOCK_ITEM_SET_FLAGS (item, GDL_DOCK_IN_DRAG);
@@ -1540,11 +1690,15 @@ gdl_dock_item_tab_button (GtkWidget *widget,
gpointer data)
{
GdlDockItem *item;
+ GtkAllocation allocation;
+
+ item = GDL_DOCK_ITEM(data);
- item = GDL_DOCK_ITEM (data);
+ (void)widget;
- if (!GDL_DOCK_ITEM_NOT_LOCKED (item))
+ if (!GDL_DOCK_ITEM_NOT_LOCKED (item)) {
return;
+ }
switch (event->button) {
case 1:
@@ -1552,8 +1706,9 @@ gdl_dock_item_tab_button (GtkWidget *widget,
drag handle */
switch (item->orientation) {
case GTK_ORIENTATION_HORIZONTAL:
+ gtk_widget_get_allocation (GTK_WIDGET (data), &allocation);
/*item->dragoff_x = item->_priv->grip_size / 2;*/
- item->dragoff_y = GTK_WIDGET (data)->allocation.height / 2;
+ item->dragoff_y = allocation.height / 2;
break;
case GTK_ORIENTATION_VERTICAL:
/*item->dragoff_x = GTK_WIDGET (data)->allocation.width / 2;*/
@@ -1576,11 +1731,10 @@ static void
gdl_dock_item_hide_cb (GtkWidget *widget,
GdlDockItem *item)
{
- GdlDockMaster *master;
-
+ (void)widget;
+
g_return_if_fail (item != NULL);
- master = GDL_DOCK_OBJECT_GET_MASTER (item);
gdl_dock_item_hide_item (item);
}
@@ -1590,6 +1744,8 @@ gdl_dock_item_lock_cb (GtkWidget *widget,
{
g_return_if_fail (item != NULL);
+ (void)widget;
+
gdl_dock_item_lock (item);
}
@@ -1599,6 +1755,8 @@ gdl_dock_item_unlock_cb (GtkWidget *widget,
{
g_return_if_fail (item != NULL);
+ (void)widget;
+
gdl_dock_item_unlock (item);
}
@@ -1632,7 +1790,7 @@ gdl_dock_item_real_set_orientation (GdlDockItem *item,
{
item->orientation = orientation;
- if (GTK_WIDGET_DRAWABLE (item))
+ if (gtk_widget_is_drawable (GTK_WIDGET (item)))
gtk_widget_queue_draw (GTK_WIDGET (item));
gtk_widget_queue_resize (GTK_WIDGET (item));
}
@@ -1640,6 +1798,17 @@ gdl_dock_item_real_set_orientation (GdlDockItem *item,
/* ----- Public interface ----- */
+/**
+ * gdl_dock_item_new:
+ * @name: Unique name for identifying the dock object.
+ * @long_name: Human readable name for the dock object.
+ * @behavior: General behavior for the dock item (i.e. whether it can
+ * float, if it's locked, etc.), as specified by
+ * #GdlDockItemBehavior flags.
+ *
+ * Creates a new dock item widget.
+ * Returns: The newly created dock item grip widget.
+ **/
GtkWidget *
gdl_dock_item_new (const gchar *name,
const gchar *long_name,
@@ -1653,10 +1822,22 @@ gdl_dock_item_new (const gchar *name,
"behavior", behavior,
NULL));
GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_AUTOMATIC);
- gdl_dock_item_set_tablabel (item, gtk_label_new (long_name));
+
return GTK_WIDGET (item);
}
+/**
+ * gdl_dock_item_new_with_stock:
+ * @name: Unique name for identifying the dock object.
+ * @long_name: Human readable name for the dock object.
+ * @stock_id: Stock icon for the dock object.
+ * @behavior: General behavior for the dock item (i.e. whether it can
+ * float, if it's locked, etc.), as specified by
+ * #GdlDockItemBehavior flags.
+ *
+ * Creates a new dock item grip widget with a given stock id.
+ * Returns: The newly created dock item grip widget.
+ **/
GtkWidget *
gdl_dock_item_new_with_stock (const gchar *name,
const gchar *long_name,
@@ -1672,8 +1853,7 @@ gdl_dock_item_new_with_stock (const gchar *name,
"behavior", behavior,
NULL));
GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_AUTOMATIC);
- gdl_dock_item_set_tablabel (item, gtk_label_new (long_name));
-
+
return GTK_WIDGET (item);
}
@@ -1699,12 +1879,23 @@ gdl_dock_item_new_with_pixbuf_icon (const gchar *name,
}
/* convenient function (and to preserve source compat) */
+/**
+ * gdl_dock_item_dock_to:
+ * @item: The dock item that will be relocated to the dock position.
+ * @target: (allow-none): The dock item that will be used as the point of reference.
+ * @position: The position to dock #item, relative to #target.
+ * @docking_param: This value is unused, and will be ignored.
+ *
+ * Relocates a dock item to a new location relative to another dock item.
+ **/
void
gdl_dock_item_dock_to (GdlDockItem *item,
GdlDockItem *target,
GdlDockPlacement position,
gint docking_param)
{
+ (void)docking_param;
+
g_return_if_fail (item != NULL);
g_return_if_fail (item != target);
g_return_if_fail (target != NULL || position == GDL_DOCK_FLOATING);
@@ -1734,6 +1925,18 @@ gdl_dock_item_dock_to (GdlDockItem *item,
position, NULL);
}
+/**
+ * gdl_dock_item_set_orientation:
+ * @item: The dock item which will get it's orientation set.
+ * @orientation: The orientation to set the item to. If the orientation
+ * is set to #GTK_ORIENTATION_VERTICAL, the grip widget will be shown
+ * along the top of the edge of item (if it is not hidden). If the
+ * orientation is set to #GTK_ORIENTATION_HORIZONTAL, the grip widget
+ * will be shown down the left edge of the item (even if the widget
+ * text direction is set to RTL).
+ *
+ * This function sets the layout of the dock item.
+ **/
void
gdl_dock_item_set_orientation (GdlDockItem *item,
GtkOrientation orientation)
@@ -1752,12 +1955,22 @@ gdl_dock_item_set_orientation (GdlDockItem *item,
"orientation", orientation,
NULL);
};
-
- GDL_CALL_VIRTUAL (item, GDL_DOCK_ITEM_GET_CLASS, set_orientation, (item, orientation));
+ if (GDL_DOCK_ITEM_GET_CLASS (item)->set_orientation)
+ GDL_DOCK_ITEM_GET_CLASS (item)->set_orientation (item, orientation);
g_object_notify (G_OBJECT (item), "orientation");
}
}
+/**
+ * gdl_dock_item_get_tablabel:
+ * @item: The dock item from which to get the tab label widget.
+ *
+ * Gets the current tab label widget. Note that this label widget is
+ * only visible when the "switcher-style" property of the #GdlDockMaster
+ * is set to #GDL_SWITCHER_STYLE_TABS
+ *
+ * Returns: Returns the tab label widget.
+ **/
GtkWidget *
gdl_dock_item_get_tablabel (GdlDockItem *item)
{
@@ -1767,12 +1980,28 @@ gdl_dock_item_get_tablabel (GdlDockItem *item)
return item->_priv->tab_label;
}
+/**
+ * gdl_dock_item_set_tablabel:
+ * @item: The dock item which will get it's tab label widget set.
+ * @tablabel: The widget that will become the tab label.
+ *
+ * Replaces the current tab label widget with another widget. Note that
+ * this label widget is only visible when the "switcher-style" property
+ * of the #GdlDockMaster is set to #GDL_SWITCHER_STYLE_TABS
+ **/
void
gdl_dock_item_set_tablabel (GdlDockItem *item,
GtkWidget *tablabel)
{
g_return_if_fail (item != NULL);
+ if (item->_priv->intern_tab_label)
+ {
+ item->_priv->intern_tab_label = FALSE;
+ g_signal_handler_disconnect (item, item->_priv->notify_label);
+ g_signal_handler_disconnect (item, item->_priv->notify_stock_id);
+ }
+
if (item->_priv->tab_label) {
/* disconnect and unref the previous tablabel */
if (GDL_IS_DOCK_TABLABEL (item->_priv->tab_label)) {
@@ -1782,13 +2011,12 @@ gdl_dock_item_set_tablabel (GdlDockItem *item,
NULL, item);
g_object_set (item->_priv->tab_label, "item", NULL, NULL);
}
- gtk_widget_unref (item->_priv->tab_label);
+ g_object_unref (item->_priv->tab_label);
item->_priv->tab_label = NULL;
}
if (tablabel) {
- gtk_widget_ref (tablabel);
- gtk_object_sink (GTK_OBJECT (tablabel));
+ g_object_ref_sink (G_OBJECT (tablabel));
item->_priv->tab_label = tablabel;
if (GDL_IS_DOCK_TABLABEL (tablabel)) {
g_object_set (tablabel, "item", item, NULL);
@@ -1799,6 +2027,29 @@ gdl_dock_item_set_tablabel (GdlDockItem *item,
}
}
+/**
+ * gdl_dock_item_get_grip:
+ * @item: The dock item from which to to get the grip of.
+ *
+ * This function returns the dock item's grip label widget.
+ *
+ * Returns: Returns the current label widget.
+ **/
+GtkWidget *
+gdl_dock_item_get_grip(GdlDockItem *item)
+{
+ g_return_val_if_fail (item != NULL, NULL);
+ g_return_val_if_fail (GDL_IS_DOCK_ITEM (item), NULL);
+
+ return item->_priv->grip;
+}
+
+/**
+ * gdl_dock_item_hide_grip:
+ * @item: The dock item to hide the grip of.
+ *
+ * This function hides the dock item's grip widget.
+ **/
void
gdl_dock_item_hide_grip (GdlDockItem *item)
{
@@ -1810,6 +2061,12 @@ gdl_dock_item_hide_grip (GdlDockItem *item)
g_warning ("Grips always show unless GDL_DOCK_ITEM_BEH_NO_GRIP is set\n" );
}
+/**
+ * gdl_dock_item_show_grip:
+ * @item: The dock item to show the grip of.
+ *
+ * This function shows the dock item's grip widget.
+ **/
void
gdl_dock_item_show_grip (GdlDockItem *item)
{
@@ -1820,7 +2077,28 @@ gdl_dock_item_show_grip (GdlDockItem *item)
};
}
+/**
+ * gdl_dock_item_notify_selected:
+ * @item: the dock item to emit a selected signal on.
+ *
+ * This function emits the selected signal. It is to be used by #GdlSwitcher
+ * to let clients know that this item has been switched to.
+ **/
+void
+gdl_dock_item_notify_selected (GdlDockItem *item)
+{
+ g_signal_emit (item, gdl_dock_item_signals [SELECTED], 0);
+}
+
/* convenient function (and to preserve source compat) */
+/**
+ * gdl_dock_item_bind:
+ * @item: The item to bind.
+ * @dock: The #GdlDock widget to bind it to. Note that this widget must
+ * be a type of #GdlDock.
+ *
+ * Binds this dock item to a new dock master.
+ **/
void
gdl_dock_item_bind (GdlDockItem *item,
GtkWidget *dock)
@@ -1833,6 +2111,12 @@ gdl_dock_item_bind (GdlDockItem *item,
}
/* convenient function (and to preserve source compat) */
+/**
+ * gdl_dock_item_unbind:
+ * @item: The item to unbind.
+ *
+ * Unbinds this dock item from it's dock master.
+ **/
void
gdl_dock_item_unbind (GdlDockItem *item)
{
@@ -1841,9 +2125,20 @@ gdl_dock_item_unbind (GdlDockItem *item)
gdl_dock_object_unbind (GDL_DOCK_OBJECT (item));
}
+/**
+ * gdl_dock_item_hide_item:
+ * @item: The dock item to hide.
+ *
+ * This function hides the dock item. When dock items are hidden they
+ * are completely removed from the layout.
+ *
+ * The dock item close button causes the panel to be hidden.
+ **/
void
gdl_dock_item_hide_item (GdlDockItem *item)
{
+ GtkAllocation allocation;
+
g_return_if_fail (item != NULL);
if (!GDL_DOCK_OBJECT_ATTACHED (item))
@@ -1870,8 +2165,9 @@ gdl_dock_item_hide_item (GdlDockItem *item)
"floaty",&y,
NULL);
} else {
- item->_priv->preferred_width=GTK_WIDGET (item)->allocation.width;
- item->_priv->preferred_height=GTK_WIDGET (item)->allocation.height;
+ gtk_widget_get_allocation (GTK_WIDGET (item), &allocation);
+ item->_priv->preferred_width = allocation.width;
+ item->_priv->preferred_height = allocation.height;
}
item->_priv->ph = GDL_DOCK_PLACEHOLDER (
g_object_new (GDL_TYPE_DOCK_PLACEHOLDER,
@@ -1883,8 +2179,7 @@ gdl_dock_item_hide_item (GdlDockItem *item)
"floatx", x,
"floaty", y,
NULL));
- g_object_ref (item->_priv->ph);
- gtk_object_sink (GTK_OBJECT (item->_priv->ph));
+ g_object_ref_sink (item->_priv->ph);
}
gdl_dock_object_freeze (GDL_DOCK_OBJECT (item));
@@ -1903,6 +2198,15 @@ gdl_dock_item_hide_item (GdlDockItem *item)
gdl_dock_object_thaw (GDL_DOCK_OBJECT (item));
}
+/**
+ * gdl_dock_item_iconify_item:
+ * @item: The dock item to iconify.
+ *
+ * This function iconifies the dock item. When dock items are iconified
+ * they are hidden, and appear only as icons in dock bars.
+ *
+ * The dock item iconify button causes the panel to be iconified.
+ **/
void
gdl_dock_item_iconify_item (GdlDockItem *item)
{
@@ -1912,6 +2216,13 @@ gdl_dock_item_iconify_item (GdlDockItem *item)
gdl_dock_item_hide_item (item);
}
+/**
+ * gdl_dock_item_show_item:
+ * @item: The dock item to show.
+ *
+ * This function shows the dock item. When dock items are shown, they
+ * are displayed in their normal layout position.
+ **/
void
gdl_dock_item_show_item (GdlDockItem *item)
{
@@ -1963,18 +2274,41 @@ gdl_dock_item_show_item (GdlDockItem *item)
gtk_widget_show (GTK_WIDGET (item));
}
+/**
+ * gdl_dock_item_lock:
+ * @item: The dock item to lock.
+ *
+ * This function locks the dock item. When locked the dock item cannot
+ * be dragged around and it doesn't show a grip.
+ **/
void
gdl_dock_item_lock (GdlDockItem *item)
{
g_object_set (item, "locked", TRUE, NULL);
}
+/**
+ * gdl_dock_item_unlock:
+ * @item: The dock item to unlock.
+ *
+ * This function unlocks the dock item. When unlocked the dock item can
+ * be dragged around and can show a grip.
+ **/
void
gdl_dock_item_unlock (GdlDockItem *item)
{
g_object_set (item, "locked", FALSE, NULL);
}
+/**
+ * gdl_dock_item_set_default_position:
+ * @item: The dock item
+ * @reference: The GdlDockObject which is the default dock for @item
+ *
+ * This method has only an effect when you add you dock_item with
+ * GDL_DOCK_ITEM_BEH_NEVER_FLOATING. In this case you have to assign
+ * it a default position.
+ **/
void
gdl_dock_item_set_default_position (GdlDockItem *item,
GdlDockObject *reference)
@@ -1988,8 +2322,7 @@ gdl_dock_item_set_default_position (GdlDockItem *item,
if (reference && GDL_DOCK_OBJECT_ATTACHED (reference)) {
if (GDL_IS_DOCK_PLACEHOLDER (reference)) {
- g_object_ref (reference);
- gtk_object_sink (GTK_OBJECT (reference));
+ g_object_ref_sink (reference);
item->_priv->ph = GDL_DOCK_PLACEHOLDER (reference);
} else {
item->_priv->ph = GDL_DOCK_PLACEHOLDER (
@@ -1997,23 +2330,32 @@ gdl_dock_item_set_default_position (GdlDockItem *item,
"sticky", TRUE,
"host", reference,
NULL));
- g_object_ref (item->_priv->ph);
- gtk_object_sink (GTK_OBJECT (item->_priv->ph));
+ g_object_ref_sink (item->_priv->ph);
}
}
}
+/**
+ * gdl_dock_item_preferred_size:
+ * @item: The dock item to get the preferred size of.
+ * @req: A pointer to a #GtkRequisition into which the preferred size
+ * will be written.
+ *
+ * Gets the preferred size of the dock item in pixels.
+ **/
void
gdl_dock_item_preferred_size (GdlDockItem *item,
GtkRequisition *req)
{
+ GtkAllocation allocation;
+
if (!req)
return;
- req->width = MAX (item->_priv->preferred_width,
- GTK_WIDGET (item)->allocation.width);
- req->height = MAX (item->_priv->preferred_height,
- GTK_WIDGET (item)->allocation.height);
+ gtk_widget_get_allocation (GTK_WIDGET (item), &allocation);
+
+ req->width = MAX (item->_priv->preferred_width, allocation.width);
+ req->height = MAX (item->_priv->preferred_height, allocation.height);
}
@@ -2030,8 +2372,8 @@ gdl_dock_item_or_child_has_focus (GdlDockItem *item)
item_child = GTK_CONTAINER (item_child)->focus_child) ;
item_or_child_has_focus =
- (GTK_WIDGET_HAS_FOCUS (GTK_WIDGET (item)) ||
- (GTK_IS_WIDGET (item_child) && GTK_WIDGET_HAS_FOCUS (item_child)));
+ (gtk_widget_has_focus (GTK_WIDGET (item)) ||
+ (GTK_IS_WIDGET (item_child) && gtk_widget_has_focus (item_child)));
return item_or_child_has_focus;
}