Commit 37a3bfe3 authored by Sebastien Granjoux's avatar Sebastien Granjoux

Remove public members from GdlDockItem

parent b4d4687c
......@@ -268,7 +268,6 @@ gdl_dock_bar_item_clicked (GtkWidget *button,
g_assert (dockbar != NULL);
g_object_set_data (G_OBJECT (item), "GdlDockBar", NULL);
GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_ICONIFIED);
gdl_dock_item_show_item (item);
}
......@@ -379,10 +378,10 @@ update_dock_items (GdlDockBar *dockbar, gboolean full_update)
GdlDockItem *item = GDL_DOCK_ITEM (l->data);
if (g_slist_index (dockbar->priv->items, item) != -1 &&
!GDL_DOCK_ITEM_ICONIFIED (item))
!gdl_dock_item_is_iconified (item))
gdl_dock_bar_remove_item (dockbar, item);
else if (g_slist_index (dockbar->priv->items, item) == -1 &&
GDL_DOCK_ITEM_ICONIFIED (item) &&
gdl_dock_item_is_iconified (item) &&
!gdl_dock_item_is_placeholder (item))
gdl_dock_bar_add_item (dockbar, item);
}
......@@ -392,7 +391,7 @@ update_dock_items (GdlDockBar *dockbar, gboolean full_update)
if (g_slist_index (dockbar->priv->items, item) != -1)
gdl_dock_bar_remove_item (dockbar, item);
if (GDL_DOCK_ITEM_ICONIFIED (item) &&
if (gdl_dock_item_is_iconified (item) &&
!gdl_dock_item_is_placeholder (item))
gdl_dock_bar_add_item (dockbar, item);
}
......
This diff is collapsed.
......@@ -79,6 +79,7 @@ typedef enum {
} GdlDockItemBehavior;
#ifndef GDL_DISABLE_DEPRECATED
/**
* GdlDockItemFlags:
* @GDL_DOCK_IN_DRAG: item is in a drag operation
......@@ -88,6 +89,7 @@ typedef enum {
*
* Status flag of a GdlDockItem. Don't use unless you derive a widget from GdlDockItem
*
* Deprecated: 3.6: Use your own private data instead.
**/
typedef enum {
GDL_DOCK_IN_DRAG = 1 << GDL_DOCK_OBJECT_FLAGS_SHIFT,
......@@ -95,6 +97,7 @@ typedef enum {
GDL_DOCK_ICONIFIED = 1 << (GDL_DOCK_OBJECT_FLAGS_SHIFT + 2),
GDL_DOCK_USER_ACTION = 1 << (GDL_DOCK_OBJECT_FLAGS_SHIFT + 3)
} GdlDockItemFlags;
#endif
typedef struct _GdlDockItem GdlDockItem;
typedef struct _GdlDockItemPrivate GdlDockItemPrivate;
......@@ -103,16 +106,8 @@ typedef struct _GdlDockItemClassPrivate GdlDockItemClassPrivate;
struct _GdlDockItem {
GdlDockObject object;
GtkWidget *child;
GdlDockItemBehavior behavior;
GtkOrientation orientation;
guint resize : 1;
gint dragoff_x, dragoff_y; /* these need to be
accesible from
outside */
/* < private> */
GdlDockItemPrivate *priv;
};
......@@ -121,8 +116,6 @@ struct _GdlDockItemClass {
GdlDockItemClassPrivate *priv;
gboolean has_grip;
/* virtuals */
void (* set_orientation) (GdlDockItem *item,
GtkOrientation orientation);
......@@ -148,8 +141,10 @@ struct _GdlDockItemClass {
* Deprecated: 3.6: Use GDL_DOCK_OBJECT_FLAGS instead
*/
#define GDL_DOCK_ITEM_FLAGS(item) (GDL_DOCK_OBJECT (item)->flags)
#endif
#ifndef GDL_DISABLE_DEPRECATED
/**
* GDL_DOCK_ITEM_SET_FLAGS:
* @item: A #GdlDockObject
......@@ -161,7 +156,9 @@ struct _GdlDockItemClass {
*/
#define GDL_DOCK_ITEM_SET_FLAGS(item,flag) \
G_STMT_START { (GDL_DOCK_OBJECT_FLAGS (item) |= (flag)); } G_STMT_END
#endif
#ifndef GDL_DISABLE_DEPRECATED
/**
* GDL_DOCK_ITEM_UNSET_FLAGS:
* @item: A #GdlDockObject
......@@ -173,47 +170,62 @@ struct _GdlDockItemClass {
*/
#define GDL_DOCK_ITEM_UNSET_FLAGS(item,flag) \
G_STMT_START { (GDL_DOCK_OBJECT_FLAGS (item) &= ~(flag)); } G_STMT_END
#endif
#ifndef GDL_DISABLE_DEPRECATED
/**
* GDL_DOCK_ITEM_IN_DRAG:
* @item: A #GdlDockObject
*
* Evaluates to %TRUE if the user is dragging the item.
*
* Deprecated: 3.6: Use a private flag instead
*/
#define GDL_DOCK_ITEM_IN_DRAG(item) \
((GDL_DOCK_OBJECT_FLAGS (item) & GDL_DOCK_IN_DRAG) != 0)
#endif
#ifndef GDL_DISABLE_DEPRECATED
/**
* GDL_DOCK_ITEM_IN_PREDRAG:
* @item: A #GdlDockObject
*
* Evaluates to %TRUE if the user has clicked on the item but hasn't made a big
* enough move to start the drag operation.
*
* Deprecated: 3.6: Use a private flag instead
*/
#define GDL_DOCK_ITEM_IN_PREDRAG(item) \
((GDL_DOCK_OBJECT_FLAGS (item) & GDL_DOCK_IN_PREDRAG) != 0)
#endif
#ifndef GDL_DISABLE_DEPRECATED
/**
* GDL_DOCK_ITEM_ICONIFIED:
* @item: A #GdlDockObject
*
* Evaluates to %TRUE if the item is iconified, appearing only as a button in
* the dock bar.
*
* Deprecated: 3.6: Use GDL_DOCK_OBJECT_UNSET_FLAGS instead
*/
#define GDL_DOCK_ITEM_ICONIFIED(item) \
((GDL_DOCK_OBJECT_FLAGS (item) & GDL_DOCK_ICONIFIED) != 0)
#endif
#ifndef GDL_DISABLE_DEPRECATED
/**
* GDL_DOCK_ITEM_USER_ACTION:
* @item: A #GdlDockObject
*
* Evaluates to %TRUE if the user currently use the item, by example dragging
* division of a #GdlDockPaned object.
*
* Deprecated: 3.6: Use a private flag instead
*/
#define GDL_DOCK_ITEM_USER_ACTION(item) \
((GDL_DOCK_OBJECT_FLAGS (item) & GDL_DOCK_USER_ACTION) != 0)
#endif
/**
* GDL_DOCK_ITEM_NOT_LOCKED:
......@@ -221,16 +233,20 @@ struct _GdlDockItemClass {
*
* Evaluates to %TRUE the item can be moved, closed, or iconified.
*/
#define GDL_DOCK_ITEM_NOT_LOCKED(item) !((item)->behavior & GDL_DOCK_ITEM_BEH_LOCKED)
#define GDL_DOCK_ITEM_NOT_LOCKED(item) ((gdl_dock_item_get_behavior_flags(item) & GDL_DOCK_ITEM_BEH_LOCKED) == 0)
#ifndef GDL_DISABLE_DEPRECATED
/**
* GDL_DOCK_ITEM_NO_GRIP:
* @item: A #GdlDockObject
*
* Evaluates to %TRUE the item has not handle, so it cannot be moved.
*
* Deprecated: 3.6: Use !GDL_DOCK_ITEM_HAS_GRIP instead
*/
#define GDL_DOCK_ITEM_NO_GRIP(item) ((item)->behavior & GDL_DOCK_ITEM_BEH_NO_GRIP)
#define GDL_DOCK_ITEM_NO_GRIP(item) ((gdl_dock_item_get_behavior_flags(item) & GDL_DOCK_ITEM_BEH_NO_GRIP) != 0)
#endif
/**
* GDL_DOCK_ITEM_HAS_GRIP:
......@@ -238,8 +254,7 @@ struct _GdlDockItemClass {
*
* Evaluates to %TRUE the item has a handle, so it can be moved.
*/
#define GDL_DOCK_ITEM_HAS_GRIP(item) ((GDL_DOCK_ITEM_GET_CLASS (item)->has_grip)&& \
! GDL_DOCK_ITEM_NO_GRIP (item))
#define GDL_DOCK_ITEM_HAS_GRIP(item) ((gdl_dock_item_get_behavior_flags (item) & GDL_DOCK_ITEM_BEH_NO_GRIP) == 0)
/**
* GDL_DOCK_ITEM_CANT_CLOSE:
......@@ -247,9 +262,7 @@ struct _GdlDockItemClass {
*
* Evaluates to %TRUE the item cannot be closed.
*/
#define GDL_DOCK_ITEM_CANT_CLOSE(item) \
((((item)->behavior & GDL_DOCK_ITEM_BEH_CANT_CLOSE) != 0)|| \
! GDL_DOCK_ITEM_NOT_LOCKED(item))
#define GDL_DOCK_ITEM_CANT_CLOSE(item) ((gdl_dock_item_get_behavior_flags(item) & GDL_DOCK_ITEM_BEH_CANT_CLOSE) != 0)
/**
* GDL_DOCK_ITEM_CANT_ICONIFY:
......@@ -257,71 +270,89 @@ struct _GdlDockItemClass {
*
* Evaluates to %TRUE the item cannot be iconifyed.
*/
#define GDL_DOCK_ITEM_CANT_ICONIFY(item) \
((((item)->behavior & GDL_DOCK_ITEM_BEH_CANT_ICONIFY) != 0)|| \
! GDL_DOCK_ITEM_NOT_LOCKED(item))
#define GDL_DOCK_ITEM_CANT_ICONIFY(item) ((gdl_dock_item_get_behavior_flags(item) & GDL_DOCK_ITEM_BEH_CANT_ICONIFY) != 0)
/* public interface */
GtkWidget *gdl_dock_item_new (const gchar *name,
const gchar *long_name,
GdlDockItemBehavior behavior);
GtkWidget *gdl_dock_item_new_with_stock (const gchar *name,
const gchar *long_name,
const gchar *stock_id,
GdlDockItemBehavior behavior);
GtkWidget *gdl_dock_item_new_with_pixbuf_icon (const gchar *name,
const gchar *long_name,
const GdkPixbuf *pixbuf_icon,
GdlDockItemBehavior behavior);
GType gdl_dock_item_get_type (void);
void gdl_dock_item_dock_to (GdlDockItem *item,
GdlDockItem *target,
GdlDockPlacement position,
gint docking_param);
void gdl_dock_item_set_orientation (GdlDockItem *item,
GtkOrientation orientation);
GtkWidget *gdl_dock_item_get_tablabel (GdlDockItem *item);
void gdl_dock_item_set_tablabel (GdlDockItem *item,
GtkWidget *tablabel);
GtkWidget *gdl_dock_item_get_grip (GdlDockItem *item);
void gdl_dock_item_hide_grip (GdlDockItem *item);
void gdl_dock_item_show_grip (GdlDockItem *item);
void gdl_dock_item_notify_selected (GdlDockItem *item);
void gdl_dock_item_notify_deselected (GdlDockItem *item);
GtkWidget *gdl_dock_item_new (const gchar *name,
const gchar *long_name,
GdlDockItemBehavior behavior);
GtkWidget *gdl_dock_item_new_with_stock (const gchar *name,
const gchar *long_name,
const gchar *stock_id,
GdlDockItemBehavior behavior);
GtkWidget *gdl_dock_item_new_with_pixbuf_icon (const gchar *name,
const gchar *long_name,
const GdkPixbuf *pixbuf_icon,
GdlDockItemBehavior behavior);
GType gdl_dock_item_get_type (void);
void gdl_dock_item_dock_to (GdlDockItem *item,
GdlDockItem *target,
GdlDockPlacement position,
gint docking_param);
void gdl_dock_item_set_orientation (GdlDockItem *item,
GtkOrientation orientation);
GtkOrientation gdl_dock_item_get_orientation (GdlDockItem *item);
void gdl_dock_item_set_behavior_flags (GdlDockItem *item,
GdlDockItemBehavior behavior,
gboolean clear);
void gdl_dock_item_unset_behavior_flags (GdlDockItem *item,
GdlDockItemBehavior behavior);
GdlDockItemBehavior gdl_dock_item_get_behavior_flags (GdlDockItem *item);
GtkWidget *gdl_dock_item_get_tablabel (GdlDockItem *item);
void gdl_dock_item_set_tablabel (GdlDockItem *item,
GtkWidget *tablabel);
GtkWidget *gdl_dock_item_get_grip (GdlDockItem *item);
void gdl_dock_item_hide_grip (GdlDockItem *item);
void gdl_dock_item_show_grip (GdlDockItem *item);
void gdl_dock_item_notify_selected (GdlDockItem *item);
void gdl_dock_item_notify_deselected (GdlDockItem *item);
/* bind and unbind items to a dock */
void gdl_dock_item_bind (GdlDockItem *item,
GtkWidget *dock);
void gdl_dock_item_bind (GdlDockItem *item,
GtkWidget *dock);
void gdl_dock_item_unbind (GdlDockItem *item);
void gdl_dock_item_hide_item (GdlDockItem *item);
void gdl_dock_item_iconify_item (GdlDockItem *item);
void gdl_dock_item_show_item (GdlDockItem *item);
void gdl_dock_item_unbind (GdlDockItem *item);
void gdl_dock_item_lock (GdlDockItem *item);
void gdl_dock_item_hide_item (GdlDockItem *item);
void gdl_dock_item_unlock (GdlDockItem *item);
void gdl_dock_item_iconify_item (GdlDockItem *item);
void gdl_dock_item_set_default_position (GdlDockItem *item,
GdlDockObject *reference);
void gdl_dock_item_show_item (GdlDockItem *item);
void gdl_dock_item_preferred_size (GdlDockItem *item,
GtkRequisition *req);
void gdl_dock_item_get_drag_area (GdlDockItem *item,
GdkRectangle *rect);
void gdl_dock_item_lock (GdlDockItem *item);
gboolean gdl_dock_item_or_child_has_focus (GdlDockItem *item);
void gdl_dock_item_unlock (GdlDockItem *item);
gboolean gdl_dock_item_is_placeholder (GdlDockItem *item);
void gdl_dock_item_set_default_position (GdlDockItem *item,
GdlDockObject *reference);
gboolean gdl_dock_item_is_closed (GdlDockItem *item);
void gdl_dock_item_preferred_size (GdlDockItem *item,
GtkRequisition *req);
gboolean gdl_dock_item_is_iconified (GdlDockItem *item);
gboolean gdl_dock_item_or_child_has_focus (GdlDockItem *item);
void gdl_dock_item_set_child (GdlDockItem *item,
GtkWidget *child);
GtkWidget* gdl_dock_item_get_child (GdlDockItem *item);
gboolean gdl_dock_item_is_placeholder (GdlDockItem *item);
void gdl_dock_item_class_set_has_grip (GdlDockItemClass *item_class,
gboolean has_grip);
gboolean gdl_dock_item_is_closed (GdlDockItem *item);
G_END_DECLS
......
......@@ -601,10 +601,9 @@ gdl_dock_master_drag_motion (GdlDockItem *item,
if (!may_dock) {
GtkRequisition req;
/* Special case for GdlDockItems : they must respect the flags */
if(GDL_IS_DOCK_ITEM(item)
&& GDL_DOCK_ITEM(item)->behavior & GDL_DOCK_ITEM_BEH_NEVER_FLOATING)
&& gdl_dock_item_get_behavior_flags (GDL_DOCK_ITEM(item)) & GDL_DOCK_ITEM_BEH_NEVER_FLOATING)
return;
dock = NULL;
......@@ -612,12 +611,9 @@ gdl_dock_master_drag_motion (GdlDockItem *item,
gdl_dock_object_get_toplevel (request->applicant));
my_request.position = GDL_DOCK_FLOATING;
gdl_dock_item_preferred_size (GDL_DOCK_ITEM (request->applicant), &req);
my_request.rect.width = req.width;
my_request.rect.height = req.height;
my_request.rect.x = root_x - GDL_DOCK_ITEM (request->applicant)->dragoff_x;
my_request.rect.y = root_y - GDL_DOCK_ITEM (request->applicant)->dragoff_y;
gdl_dock_item_get_drag_area (GDL_DOCK_ITEM (request->applicant), &my_request.rect);
my_request.rect.x = root_x - my_request.rect.x;
my_request.rect.y = root_y - my_request.rect.y;
/* setup extra docking information */
if (G_IS_VALUE (&my_request.extra))
......@@ -631,7 +627,7 @@ gdl_dock_master_drag_motion (GdlDockItem *item,
/* it could be inserted in another floating dock */
/* so check for the flag at this moment */
else if(GDL_IS_DOCK_ITEM(item)
&& GDL_DOCK_ITEM(item)->behavior & GDL_DOCK_ITEM_BEH_NEVER_FLOATING
&& gdl_dock_item_get_behavior_flags (GDL_DOCK_ITEM(item)) & GDL_DOCK_ITEM_BEH_NEVER_FLOATING
&& dock != GDL_DOCK(master->priv->controller))
return;
......@@ -886,9 +882,9 @@ gdl_dock_master_add (GdlDockMaster *master,
/* If the item is notebook, set the switcher style */
if (GDL_IS_DOCK_NOTEBOOK (object) &&
GDL_IS_SWITCHER (GDL_DOCK_ITEM (object)->child))
GDL_IS_SWITCHER (gdl_dock_item_get_child (GDL_DOCK_ITEM (object))))
{
g_object_set (GDL_DOCK_ITEM (object)->child, "switcher-style",
g_object_set (gdl_dock_item_get_child (GDL_DOCK_ITEM (object)), "switcher-style",
master->priv->switcher_style, NULL);
}
......@@ -1098,7 +1094,7 @@ set_switcher_style_foreach (GtkWidget *obj, gpointer user_data)
if (GDL_IS_DOCK_NOTEBOOK (obj)) {
GtkWidget *child = GDL_DOCK_ITEM (obj)->child;
GtkWidget *child = gdl_dock_item_get_child (GDL_DOCK_ITEM (obj));
if (GDL_IS_SWITCHER (child)) {
g_object_set (child, "switcher-style", style, NULL);
......
......@@ -148,7 +148,7 @@ gdl_dock_notebook_class_init (GdlDockNotebookClass *klass)
object_class->present = gdl_dock_notebook_present;
object_class->reorder = gdl_dock_notebook_reorder;
item_class->has_grip = FALSE;
gdl_dock_item_class_set_has_grip (item_class, FALSE);
item_class->set_orientation = gdl_dock_notebook_set_orientation;
g_object_class_install_property (
......@@ -194,6 +194,7 @@ static void
gdl_dock_notebook_init (GdlDockNotebook *notebook)
{
GdlDockItem *item = GDL_DOCK_ITEM (notebook);
GtkWidget *child;
notebook->priv = G_TYPE_INSTANCE_GET_PRIVATE (notebook,
GDL_TYPE_DOCK_NOTEBOOK,
......@@ -201,19 +202,19 @@ gdl_dock_notebook_init (GdlDockNotebook *notebook)
notebook->priv->user_action = FALSE;
/* create the container notebook */
item->child = gdl_switcher_new ();
gtk_widget_set_parent (item->child, GTK_WIDGET (notebook));
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (item->child), GTK_POS_BOTTOM);
g_signal_connect (item->child, "switch-page",
child = gdl_switcher_new ();
gdl_dock_item_set_child (item, child);
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (child), GTK_POS_BOTTOM);
g_signal_connect (child, "switch-page",
(GCallback) gdl_dock_notebook_switch_page_cb, (gpointer) item);
g_signal_connect (item->child, "notify::page",
g_signal_connect (child, "notify::page",
(GCallback) gdl_dock_notebook_notify_cb, (gpointer) item);
g_signal_connect (item->child, "button-press-event",
g_signal_connect (child, "button-press-event",
(GCallback) gdl_dock_notebook_button_cb, (gpointer) item);
g_signal_connect (item->child, "button-release-event",
g_signal_connect (child, "button-release-event",
(GCallback) gdl_dock_notebook_button_cb, (gpointer) item);
gtk_notebook_set_scrollable (GTK_NOTEBOOK (item->child), TRUE);
gtk_widget_show (item->child);
gtk_notebook_set_scrollable (GTK_NOTEBOOK (child), TRUE);
gtk_widget_show (child);
}
static void
......@@ -223,11 +224,13 @@ gdl_dock_notebook_set_property (GObject *object,
GParamSpec *pspec)
{
GdlDockItem *item = GDL_DOCK_ITEM (object);
GtkWidget *child;
switch (prop_id) {
case PROP_PAGE:
if (item->child && GTK_IS_NOTEBOOK (item->child)) {
gtk_notebook_set_current_page (GTK_NOTEBOOK (item->child),
child = gdl_dock_item_get_child (item);
if (child && GTK_IS_NOTEBOOK (child)) {
gtk_notebook_set_current_page (GTK_NOTEBOOK (child),
g_value_get_int (value));
}
......@@ -245,12 +248,14 @@ gdl_dock_notebook_get_property (GObject *object,
GParamSpec *pspec)
{
GdlDockItem *item = GDL_DOCK_ITEM (object);
GtkWidget *child;
switch (prop_id) {
case PROP_PAGE:
if (item->child && GTK_IS_NOTEBOOK (item->child)) {
child = gdl_dock_item_get_child (item);
if (child && GTK_IS_NOTEBOOK (child)) {
g_value_set_int (value, gtk_notebook_get_current_page
(GTK_NOTEBOOK (item->child)));
(GTK_NOTEBOOK (child)));
}
break;
......@@ -271,10 +276,7 @@ gdl_dock_notebook_destroy (GtkWidget *object)
GTK_WIDGET_CLASS (gdl_dock_notebook_parent_class)->destroy (object);
/* after that we can remove the GtkNotebook */
if (item->child) {
gtk_widget_unparent (item->child);
item->child = NULL;
};
gdl_dock_item_set_child (item, NULL);
}
static void
......@@ -326,6 +328,7 @@ gdl_dock_notebook_forall (GtkContainer *container,
gpointer callback_data)
{
GdlDockItem *item;
GtkWidget *child;
g_return_if_fail (container != NULL);
g_return_if_fail (GDL_IS_DOCK_NOTEBOOK (container));
......@@ -338,8 +341,9 @@ gdl_dock_notebook_forall (GtkContainer *container,
}
else {
item = GDL_DOCK_ITEM (container);
if (item->child)
gtk_container_foreach (GTK_CONTAINER (item->child), callback, callback_data);
child = gdl_dock_item_get_child (GDL_DOCK_ITEM (container));
if (child)
gtk_container_foreach (GTK_CONTAINER (child), callback, callback_data);
}
}
......@@ -412,7 +416,7 @@ gdl_dock_notebook_dock (GdlDockObject *object,
if (other_data && G_VALUE_HOLDS (other_data, G_TYPE_INT))
position = g_value_get_int (other_data);
position = gdl_switcher_insert_page (GDL_SWITCHER (item->child),
position = gdl_switcher_insert_page (GDL_SWITCHER (gdl_dock_item_get_child (item)),
GTK_WIDGET (requestor), label,
long_name, long_name,
stock_id, pixbuf_icon, position);
......@@ -421,7 +425,7 @@ gdl_dock_notebook_dock (GdlDockObject *object,
/* Set current page to the newly docked widget. set current page
* really doesn't work if the page widget is not shown
*/
gtk_notebook_set_current_page (GTK_NOTEBOOK (item->child),
gtk_notebook_set_current_page (GTK_NOTEBOOK (gdl_dock_item_get_child (item)),
position);
}
g_free (long_name);
......@@ -436,11 +440,13 @@ static void
gdl_dock_notebook_set_orientation (GdlDockItem *item,
GtkOrientation orientation)
{
if (item->child && GTK_IS_NOTEBOOK (item->child)) {
GtkWidget *child = gdl_dock_item_get_child (item);
if (child && GTK_IS_NOTEBOOK (child)) {
if (orientation == GTK_ORIENTATION_HORIZONTAL)
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (item->child), GTK_POS_TOP);
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (child), GTK_POS_TOP);
else
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (item->child), GTK_POS_LEFT);
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (child), GTK_POS_LEFT);
}
GDL_DOCK_ITEM_CLASS (gdl_dock_notebook_parent_class)->set_orientation (item, orientation);
......@@ -454,10 +460,10 @@ gdl_dock_notebook_child_placement (GdlDockObject *object,
GdlDockItem *item = GDL_DOCK_ITEM (object);
GdlDockPlacement pos = GDL_DOCK_NONE;
if (item->child) {
if (gdl_dock_item_get_child (item)) {
GList *children, *l;
children = gtk_container_get_children (GTK_CONTAINER (item->child));
children = gtk_container_get_children (GTK_CONTAINER (gdl_dock_item_get_child (item)));
for (l = children; l; l = l->next) {
if (l->data == (gpointer) child) {
pos = GDL_DOCK_CENTER;
......@@ -480,13 +486,13 @@ static void
gdl_dock_notebook_present (GdlDockObject *object,
GdlDockObject *child)
{
GdlDockItem *item = GDL_DOCK_ITEM (object);
GtkWidget *notebook = gdl_dock_item_get_child (GDL_DOCK_ITEM (object));
int i;
i = gtk_notebook_page_num (GTK_NOTEBOOK (item->child),
i = gtk_notebook_page_num (GTK_NOTEBOOK (notebook),
GTK_WIDGET (child));
if (i >= 0)
gtk_notebook_set_current_page (GTK_NOTEBOOK (item->child), i);
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), i);
GDL_DOCK_OBJECT_CLASS (gdl_dock_notebook_parent_class)->present (object, child);
}
......@@ -497,12 +503,12 @@ gdl_dock_notebook_reorder (GdlDockObject *object,
GdlDockPlacement new_position,
GValue *other_data)
{
GdlDockItem *item = GDL_DOCK_ITEM (object);
GtkWidget *child = gdl_dock_item_get_child (GDL_DOCK_ITEM (object));
gint current_position, new_pos = -1;
gboolean handled = FALSE;
if (item->child && new_position == GDL_DOCK_CENTER) {
current_position = gtk_notebook_page_num (GTK_NOTEBOOK (item->child),
if (child && new_position == GDL_DOCK_CENTER) {
current_position = gtk_notebook_page_num (GTK_NOTEBOOK (child),
GTK_WIDGET (requestor));
if (current_position >= 0) {
handled = TRUE;
......@@ -510,7 +516,7 @@ gdl_dock_notebook_reorder (GdlDockObject *object,
if (other_data && G_VALUE_HOLDS (other_data, G_TYPE_INT))
new_pos = g_value_get_int (other_data);
gtk_notebook_reorder_child (GTK_NOTEBOOK (item->child),
gtk_notebook_reorder_child (GTK_NOTEBOOK (child),
GTK_WIDGET (requestor),
new_pos);
}
......
......@@ -138,7 +138,7 @@ gdl_dock_paned_class_init (GdlDockPanedClass *klass)
object_class->dock = gdl_dock_paned_dock;
object_class->child_placement = gdl_dock_paned_child_placement;
item_class->has_grip = FALSE;
gdl_dock_item_class_set_has_grip (item_class, FALSE);
item_class->set_orientation = gdl_dock_paned_set_orientation;
g_object_class_install_property (
......@@ -212,25 +212,23 @@ gdl_dock_paned_create_child (GdlDockPaned *paned,
GtkOrientation orientation)
{
GdlDockItem *item;
GtkWidget *child;
item = GDL_DOCK_ITEM (paned);
if (item->child)
gtk_widget_unparent (GTK_WIDGET (item->child));
/* create the container paned */
item->child = gtk_paned_new (orientation);
child = gtk_paned_new (orientation);
gdl_dock_item_set_child (item, child);
/* get notification for propagation */
g_signal_connect (item->child, "notify::position",
g_signal_connect (child, "notify::position",
(GCallback) gdl_dock_paned_notify_cb, (gpointer) item);
g_signal_connect (item->child, "button-press-event",
g_signal_connect (child, "button-press-event",
(GCallback) gdl_dock_paned_button_cb, (gpointer) item);
g_signal_connect (item->child, "button-release-event",
g_signal_connect (child, "button-release-event",
(GCallback) gdl_dock_paned_button_cb, (gpointer) item);
gtk_widget_set_parent (item->child, GTK_WIDGET (item));
gtk_widget_show (item->child);
gtk_widget_show (child);
}
static GObject *
......@@ -246,9 +244,9 @@ gdl_dock_paned_constructor (GType type,
if (g_object) {
GdlDockItem *item = GDL_DOCK_ITEM (g_object);
if (!item->child)
if (!gdl_dock_item_get_child (item))
gdl_dock_paned_create_child (GDL_DOCK_PANED (g_object),
item->orientation);
gdl_dock_item_get_orientation (item));
/* otherwise, the orientation was set as a construction
parameter and the child is already created */
}
......@@ -263,11 +261,13 @@ gdl_dock_paned_set_property (GObject *object,
GParamSpec *pspec)
{
GdlDockItem *item = GDL_DOCK_ITEM (object);
GtkWidget *child;
switch (prop_id) {
case PROP_POSITION:
if (item->child && GTK_IS_PANED (item->child))
gtk_paned_set_position (GTK_PANED (item->child),
child = gdl_dock_item_get_child (item);
if (child && GTK_IS_PANED (child))
gtk_paned_set_position (GTK_PANED (child),
g_value_get_uint (value));
break;
default:
......@@ -283,12 +283,14 @@ gdl_dock_paned_get_property (GObject *object,
GParamSpec *pspec)
{
GdlDockItem *item = GDL_DOCK_ITEM (object);
GtkWidget *child;
switch (prop_id) {
case PROP_POSITION:
if (item->child && GTK_IS_PANED (item->child))
child = gdl_dock_item_get_child (item);
if (child && GTK_IS_PANED (child))
g_value_set_uint (value,
gtk_paned_get_position (GTK_PANED (item->child)));
gtk_paned_get_position (GTK_PANED (child)));
else
g_value_set_uint (value, 0);
break;
......@@ -309,10 +311,7 @@ gdl_dock_paned_destroy (GtkWidget *object)
/* after that we can remove the GtkNotebook */
if (item->child) {
gtk_widget_unparent (item->child);
item->child = NULL;
};
gdl_dock_item_set_child (item, NULL);
}
static void
......@@ -329,18 +328,18 @@ gdl_dock_paned_add (GtkContainer *container,
g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
item = GDL_DOCK_ITEM (container);
g_return_if_fail (item->child != NULL);
g_return_if_fail (gdl_dock_item_get_child (item) != NULL);
paned = GTK_PANED (item->child);
paned = GTK_PANED (gdl_dock_item_get_child (item));
child1 = gtk_paned_get_child1 (paned);
child2 = gtk_paned_get_child2 (paned);
g_return_if_fail (!child1 || !child2);
if (!child1)
pos = item->orientation == GTK_ORIENTATION_HORIZONTAL ?
pos = gdl_dock_item_get_orientation (item) == GTK_ORIENTATION_HORIZONTAL ?
GDL_DOCK_LEFT : GDL_DOCK_TOP;
else if (!child2)
pos = item->orientation == GTK_ORIENTATION_HORIZONTAL ?
pos = gdl_dock_item_get_orientation (item) == GTK_ORIENTATION_HORIZONTAL ?
GDL_DOCK_RIGHT : GDL_DOCK_BOTTOM;
if (pos != GDL_DOCK_NONE)
......@@ -355,7 +354,7 @@ gdl_dock_paned_forall (GtkContainer *container,
GtkCallback callback,
gpointer callback_data)
{
GdlDockItem *item;
GtkWidget *child;
g_return_if_fail (container != NULL);
g_return_if_fail (GDL_IS_DOCK_PANED (container));
......@@ -367,18 +366,18 @@ gdl_dock_paned_forall (GtkContainer *container,
(container, include_internals, callback, callback_data);
}
else {
item = GDL_DOCK_ITEM (container);
if (item->child)
gtk_container_foreach (GTK_CONTAINER (item->child), callback, callback_data);
child = gdl_dock_item_get_child (GDL_DOCK_ITEM (container));
if (child)
gtk_container_foreach (GTK_CONTAINER (child), callback, callback_data);
}
}
static GType
gdl_dock_paned_child_type (GtkContainer *container)
{
GdlDockItem *item = GDL_DOCK_ITEM (container);
GtkWidget *child = gdl_dock_item_get_child (GDL_DOCK_ITEM (container));