Commit 32269737 authored by Fredrik Axelsson's avatar Fredrik Axelsson Committed by Johannes Schmid

reviewed by: Johannes Schmid <jhs@cvs.gnome.org>

2006-07-08  Fredrik Axelsson <fraxbe@gmail.com>

	reviewed by: Johannes Schmid <jhs@cvs.gnome.org>

	* gdl/gdl-dock-item.c:
	* gdl/gdl-dock-master.c:
	* gdl/gdl-dock-placeholder.c:

	Make Gdl able to restore "floating" docks
parent 0e5343ca
2006-07-08 Fredrik Axelsson <fraxbe@gmail.com>
reviewed by: Johannes Schmid <jhs@cvs.gnome.org>
* gdl/gdl-dock-item.c:
* gdl/gdl-dock-master.c:
* gdl/gdl-dock-placeholder.c:
Make Gdl able to restore "floating" docks
2006-06-13 Johannes Schmid <jhs@cvs.gnome.org>
* configure.in: Fixed configure script (#344678)
......
......@@ -1466,10 +1466,11 @@ gdl_dock_item_dock_to (GdlDockItem *item,
g_return_if_fail (item != NULL);
g_return_if_fail (item != target);
g_return_if_fail (target != NULL || position == GDL_DOCK_FLOATING);
g_return_if_fail ((item->behavior & GDL_DOCK_ITEM_BEH_NEVER_FLOATING) == 0 || position != GDL_DOCK_FLOATING);
if (position == GDL_DOCK_FLOATING || !target) {
GdlDockObject *controller;
if (!gdl_dock_object_is_bound (GDL_DOCK_OBJECT (item))) {
g_warning (_("Attempt to bind an unbound item %p"), item);
return;
......@@ -1611,15 +1612,32 @@ gdl_dock_item_hide_item (GdlDockItem *item)
restore the position later */
if (!GDL_DOCK_OBJECT_AUTOMATIC (item)) {
if (item->_priv->ph)
g_object_unref (item->_priv->ph);
g_object_unref (item->_priv->ph);
gboolean isFloating = FALSE;
gint width, height, x, y = 0;
GdlDock* dock=NULL;
if (dock = GDL_DOCK (gdl_dock_object_get_parent_object (GDL_DOCK_OBJECT (item)))){
g_object_get (dock,
"floating", &isFloating,
"width", &width,
"height",&height,
"floatx",&x,
"floaty",&y,
NULL);
}
item->_priv->ph = GDL_DOCK_PLACEHOLDER (
g_object_new (GDL_TYPE_DOCK_PLACEHOLDER,
"sticky", FALSE,
"host", item,
"width", GTK_WIDGET (item)->allocation.width,
"height", GTK_WIDGET (item)->allocation.height,
NULL));
"width", width,
"height", height,
"floating", isFloating,
"floatx", x,
"floaty", y,
NULL));
g_object_ref (item->_priv->ph);
gtk_object_sink (GTK_OBJECT (item->_priv->ph));
}
......@@ -1655,20 +1673,48 @@ gdl_dock_item_show_item (GdlDockItem *item)
g_return_if_fail (item != NULL);
GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_ICONIFIED);
if (item->_priv->ph) {
gtk_container_add (GTK_CONTAINER (item->_priv->ph), GTK_WIDGET (item));
gboolean isFloating=FALSE;
gint width,height,x,y=0;
g_object_get (G_OBJECT(item->_priv->ph),
"width", &width,
"height", &height,
"floating",&isFloating,
"floatx", &x,
"floaty", &y,
NULL);
if (isFloating) {
GdlDockObject *controller = gdl_dock_master_get_controller (GDL_DOCK_OBJECT_GET_MASTER (item));
gdl_dock_add_floating_item (GDL_DOCK (controller),
item, x, y, width, height);
}else{
gtk_container_add (GTK_CONTAINER (item->_priv->ph), GTK_WIDGET (item));
}
g_object_unref (item->_priv->ph);
item->_priv->ph = NULL;
}
else if (gdl_dock_object_is_bound (GDL_DOCK_OBJECT (item))) {
GdlDockObject *toplevel = gdl_dock_master_get_controller (
GDL_DOCK_OBJECT_GET_MASTER (item));
if (toplevel) {
GdlDockObject *toplevel;
toplevel = gdl_dock_master_get_controller (
GDL_DOCK_OBJECT_GET_MASTER (item));
if (item->behavior & GDL_DOCK_ITEM_BEH_NEVER_FLOATING) {
g_warning("Object %s has no default position and flag GDL_DOCK_ITEM_BEH_NEVER_FLOATING is set.\n",
GDL_DOCK_OBJECT(item)->name);
}
else if(toplevel) {
gdl_dock_object_dock (toplevel, GDL_DOCK_OBJECT (item),
GDL_DOCK_FLOATING, NULL);
}
else
g_warning("There is no toplevel window. GdlDockItem %s cannot be shown.\n", GDL_DOCK_OBJECT(item)->name);
}
else
g_warning("GdlDockItem %s is not bound. It cannot be shown.\n", GDL_DOCK_OBJECT(item)->name);
gtk_widget_show (GTK_WIDGET (item));
}
......
......@@ -490,7 +490,7 @@ gdl_dock_master_drag_motion (GdlDockItem *item,
}
else {
GList *l;
/* try to dock the item in all the docks in the ring in turn */
for (l = master->toplevel_docks; l; l = l->next) {
dock = GDL_DOCK (l->data);
......@@ -505,10 +505,15 @@ gdl_dock_master_drag_motion (GdlDockItem *item,
break;
}
}
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)
return;
dock = NULL;
my_request.target = GDL_DOCK_OBJECT (
gdl_dock_object_get_toplevel (request->applicant));
......@@ -527,7 +532,15 @@ gdl_dock_master_drag_motion (GdlDockItem *item,
g_value_init (&my_request.extra, GDK_TYPE_RECTANGLE);
g_value_set_boxed (&my_request.extra, &my_request.rect);
};
}
/* if we want to enforce GDL_DOCK_ITEM_BEH_NEVER_FLOATING */
/* the item must remain attached to the controller, otherwise */
/* 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
&& dock != GDL_DOCK(master->controller))
if (!(my_request.rect.x == request->rect.x &&
my_request.rect.y == request->rect.y &&
......
......@@ -86,7 +86,10 @@ enum {
PROP_HOST,
PROP_NEXT_PLACEMENT,
PROP_WIDTH,
PROP_HEIGHT
PROP_HEIGHT,
PROP_FLOATING,
PROP_FLOAT_X,
PROP_FLOAT_Y
};
struct _GdlDockPlaceholderPrivate {
......@@ -106,6 +109,11 @@ struct _GdlDockPlaceholderPrivate {
/* connected signal handlers */
guint host_detach_handler;
guint host_dock_handler;
/* Window Coordinates if Dock was floating */
gboolean floating;
gint floatx;
gint floaty;
};
......@@ -133,45 +141,67 @@ gdl_dock_placeholder_class_init (GdlDockPlaceholderClass *klass)
g_object_class_install_property (
g_object_class, PROP_STICKY,
g_param_spec_boolean ("sticky", _("Sticky"),
_("Whether the placeholder will stick to its host or "
"move up the hierarchy when the host is redocked"),
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
_("Whether the placeholder will stick to its host or "
"move up the hierarchy when the host is redocked"),
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (
g_object_class, PROP_HOST,
g_object_class, PROP_HOST,
g_param_spec_object ("host", _("Host"),
_("The dock object this placeholder is attached to"),
GDL_TYPE_DOCK_OBJECT,
G_PARAM_READWRITE));
_("The dock object this placeholder is attached to"),
GDL_TYPE_DOCK_OBJECT,
G_PARAM_READWRITE));
/* this will return the top of the placement stack */
g_object_class_install_property (
g_object_class, PROP_NEXT_PLACEMENT,
g_param_spec_enum ("next_placement", _("Next placement"),
_("The position an item will be docked to our host if a "
"request is made to dock to us"),
GDL_TYPE_DOCK_PLACEMENT,
GDL_DOCK_CENTER,
G_PARAM_READWRITE |
GDL_DOCK_PARAM_EXPORT | GDL_DOCK_PARAM_AFTER));
_("The position an item will be docked to our host if a "
"request is made to dock to us"),
GDL_TYPE_DOCK_PLACEMENT,
GDL_DOCK_CENTER,
G_PARAM_READWRITE |
GDL_DOCK_PARAM_EXPORT | GDL_DOCK_PARAM_AFTER));
g_object_class_install_property (
g_object_class, PROP_WIDTH,
g_param_spec_int ("width", _("Width"),
_("Width for the widget when it's attached to the placeholder"),
-1, G_MAXINT, -1,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
GDL_DOCK_PARAM_EXPORT));
_("Width for the widget when it's attached to the placeholder"),
-1, G_MAXINT, -1,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
GDL_DOCK_PARAM_EXPORT));
g_object_class_install_property (
g_object_class, PROP_HEIGHT,
g_param_spec_int ("height", _("Height"),
_("Height for the widget when it's attached to the placeholder"),
-1, G_MAXINT, -1,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
GDL_DOCK_PARAM_EXPORT));
_("Height for the widget when it's attached to the placeholder"),
-1, G_MAXINT, -1,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
GDL_DOCK_PARAM_EXPORT));
g_object_class_install_property (
g_object_class, PROP_FLOATING,
g_param_spec_boolean ("floating", _("Floating Toplevel"),
_("Whether the placeholder is standing in for a "
"floating toplevel dock"),
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (
g_object_class, PROP_FLOAT_X,
g_param_spec_int ("floatx", _("X-Coordinate"),
_("X-Coordinate fow dock when floating"),
-1, G_MAXINT, -1,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
GDL_DOCK_PARAM_EXPORT));
g_object_class_install_property (
g_object_class, PROP_FLOAT_Y,
g_param_spec_int ("floaty", _("Y-Coordinate"),
_("Y-Coordinate fow dock when floating"),
-1, G_MAXINT, -1,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
GDL_DOCK_PARAM_EXPORT));
gtk_object_class->destroy = gdl_dock_placeholder_destroy;
container_class->add = gdl_dock_placeholder_add;
......@@ -209,8 +239,8 @@ gdl_dock_placeholder_set_property (GObject *g_object,
break;
case PROP_NEXT_PLACEMENT:
if (ph->_priv) {
ph->_priv->placement_stack =
g_slist_prepend (ph->_priv->placement_stack,
ph->_priv->placement_stack =
g_slist_prepend (ph->_priv->placement_stack,
GINT_TO_POINTER (g_value_get_enum (value)));
}
break;
......@@ -220,9 +250,18 @@ gdl_dock_placeholder_set_property (GObject *g_object,
case PROP_HEIGHT:
ph->_priv->height = g_value_get_int (value);
break;
case PROP_FLOATING:
ph->_priv->floating = g_value_get_boolean (value);
break;
case PROP_FLOAT_X:
ph->_priv->floatx = g_value_get_int (value);
break;
case PROP_FLOAT_Y:
ph->_priv->floaty = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (g_object, prop_id, pspec);
break;
G_OBJECT_WARN_INVALID_PROPERTY_ID (g_object, prop_id, pspec);
break;
}
}
......@@ -258,6 +297,15 @@ gdl_dock_placeholder_get_property (GObject *g_object,
break;
case PROP_HEIGHT:
g_value_set_int (value, ph->_priv->height);
break;
case PROP_FLOATING:
g_value_set_boolean (value, ph->_priv->floating);
break;
case PROP_FLOAT_X:
g_value_set_int (value, ph->_priv->floatx);
break;
case PROP_FLOAT_Y:
g_value_set_int (value, ph->_priv->floaty);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (g_object, prop_id, pspec);
......@@ -487,8 +535,8 @@ gdl_dock_placeholder_present (GdlDockObject *object,
return;
}
/* ----- Public interface ----- */
/* ----- Public interface ----- */
GtkWidget *
gdl_dock_placeholder_new (gchar *name,
GdlDockObject *object,
......
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