/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
*
* Author: Gustavo Gir�ldez <gustavo.giraldez@gmx.net>
* Naba Kumar <naba@gnome.org>
*
* Based on GnomeDockItem/BonoboDockItem. Original copyright notice follows.
*
* Copyright (C) 1998 Ettore Perazzoli
* Copyright (C) 1998 Elliot Lee
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
* All rights reserved.
*
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gdl-i18n.h"
#include <string.h>
#include <gdk/gdkkeysyms.h>
#include "gdl-dock.h"
#include "gdl-dock-item.h"
#include "gdl-dock-item-grip.h"
#include "gdl-dock-notebook.h"
#include "gdl-dock-paned.h"
#include "gdl-dock-tablabel.h"
#include "gdl-dock-placeholder.h"
#include "gdl-dock-master.h"
#include "libgdltypebuiltins.h"
#include "libgdlmarshal.h"
/* ----- Private prototypes ----- */
GParamSpec *pspec);
GParamSpec *pspec);
GdkEventKey *event);
gint x,
gint y,
GValue *other_data);
GdlDockItem *item);
GdlDockItem *item);
GdlDockItem *item);
/* ----- Class variables and definitions ----- */
enum {
};
enum {
};
struct _GdlDockItemPrivate {
};
/* FIXME: implement the rest of the behaviors */
/* ----- Private functions ----- */
static void
{
"move_focus_child", 1,
"move_focus_child", 1,
}
static void
{
"move_focus_child", 1,
"move_focus_child", 1,
"move_focus_child", 1,
"move_focus_child", 1,
}
static void
{
/* 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).
*/
_("Orientation of the docking item"),
/* --- end of registration */
_("If set, the dock item can be resized when "
"docked in a GtkPanel widget"),
TRUE,
_("General behavior for the dock item (i.e. "
"whether it can float, if it's locked, etc.)"),
_("If set, the dock item cannot be dragged around "
"and it doesn't show a grip"),
_("Preferred width for the dock item"),
_("Preferred height for the dock item"),
/* signals */
/**
* GdlDockItem::dock-drag-begin:
* @item: The dock item which is being dragged.
*
* Signals that the dock item has begun to be dragged.
**/
g_signal_new ("dock-drag-begin",
NULL, /* accumulator */
NULL, /* accu_data */
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.
**/
g_signal_new ("dock-drag-motion",
NULL, /* accumulator */
NULL, /* accu_data */
2,
/**
* 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.
**/
g_signal_new ("dock_drag_end",
NULL, /* accumulator */
NULL, /* accu_data */
1,
/**
* GdlDockItem::selected:
*
* Signals that this dock has been selected from a switcher.
*/
g_signal_new ("selected",
0,
NULL,
NULL,
0);
g_signal_new ("move_focus_child",
NULL, /* accumulator */
NULL, /* accu_data */
1,
/* key bindings */
if (!style_initialized)
{
"style \"gdl-dock-item-default\" {\n"
"xthickness = 0\n"
"ythickness = 0\n"
"}\n"
"class \"GdlDockItem\" "
"style : gtk \"gdl-dock-item-default\"\n");
}
}
static void
{
}
static void
{
}
static void
{
}
static GObject *
{
if (g_object) {
if (GDL_DOCK_ITEM_HAS_GRIP (item)) {
}
else {
}
icon = gtk_image_new ();
if (stock_id)
label);
icon);
}
return g_object;
}
static void
{
switch (prop_id) {
case PROP_ORIENTATION:
break;
case PROP_RESIZE:
break;
case PROP_BEHAVIOR:
{
if (GDL_DOCK_OBJECT_GET_MASTER (item))
"layout-changed");
}
break;
}
case PROP_LOCKED:
{
if (g_value_get_boolean (value))
else
if (GDL_DOCK_OBJECT_GET_MASTER (item))
"layout-changed");
}
break;
}
case PROP_PREFERRED_WIDTH:
break;
case PROP_PREFERRED_HEIGHT:
break;
default:
break;
}
}
static void
{
switch (prop_id) {
case PROP_ORIENTATION:
break;
case PROP_RESIZE:
break;
case PROP_BEHAVIOR:
break;
case PROP_LOCKED:
break;
case PROP_PREFERRED_WIDTH:
break;
case PROP_PREFERRED_HEIGHT:
break;
default:
break;
}
}
static void
{
};
};
}
}
}
}
static void
{
if (GDL_IS_DOCK_OBJECT (widget)) {
g_warning (_("You can't add a dock object (%p of type %s) inside a %s. "
"Use a GdlDock or some other compound dock object."),
return;
}
g_warning (_("Attempting to add a widget with type %s to a %s, "
"but it can only contain one widget at a time; "
"it already contains a widget of type %s"),
return;
}
}
static void
{
if (grip_was_visible)
return;
}
if (GDL_DOCK_ITEM_IN_DRAG (item)) {
}
if (was_visible)
}
static void
{
}
static GType
{
return GTK_TYPE_WIDGET;
else
return G_TYPE_NONE;
}
static void
{
}
}
static void
{
/* If our child is not visible, we still request its size, since
we won't have any useful hint for our size otherwise. */
else {
child_requisition.width = 0;
child_requisition.height = 0;
}
if (GDL_DOCK_ITEM_GRIP_SHOWN (item)) {
} else {
requisition->width = 0;
}
} else
requisition->height = 0;
} else {
if (GDL_DOCK_ITEM_GRIP_SHOWN (item)) {
} else {
requisition->height = 0;
}
} else
requisition->width = 0;
}
//gtk_widget_size_request (widget, requisition);
}
static void
{
/* Once size is allocated, preferred size is no longer necessary */
if (gtk_widget_get_realized (widget))
allocation->x,
allocation->y,
allocation->height);
if (GDL_DOCK_ITEM_GRIP_SHOWN (item)) {
} else {
}
}
/* Allocation can't be negative */
if (child_allocation.width < 0)
child_allocation.width = 0;
if (child_allocation.height < 0)
child_allocation.height = 0;
}
}
static void
{
}
static void
{
}
static void
{
/* widget window */
attributes.x = allocation.x;
attributes.y = allocation.y;
}
static void
{
if (gtk_widget_get_realized (widget) &&
{
if (gtk_widget_is_drawable (widget))
}
}
static void
{
"dockitem",
0, 0, -1, -1);
#if !defined(GDK_WINDOWING_QUARTZ)
#endif
}
static gint
{
if (gtk_widget_is_drawable (widget) &&
{
}
return FALSE;
}
static void
{
}
static gint
{
return FALSE;
/* Check if user clicked on the drag handle. */
switch (item->orientation) {
break;
case GTK_ORIENTATION_VERTICAL:
break;
default:
break;
}
/* Left mousebutton click on dockitem. */
if (!gdl_dock_item_or_child_has_focus (item))
/* Set in_drag flag, grab pointer and call begin drag operation. */
if (in_handle) {
cursor);
};
if (GDL_DOCK_ITEM_IN_DRAG (item)) {
/* User dropped widget somewhere. */
}
else if (GDL_DOCK_ITEM_IN_PREDRAG (item)) {
}
/* we check the window since if the item was redocked it's
been unrealized and maybe it's not realized again yet */
cursor);
}
}
return event_handled;
}
static gint
{
return FALSE;
if (GDL_DOCK_ITEM_IN_PREDRAG (item)) {
event->x,
event->y)) {
}
}
if (!GDL_DOCK_ITEM_IN_DRAG (item))
return FALSE;
return TRUE;
}
static gboolean
{
if (GDL_DOCK_ITEM_IN_DRAG (widget)) {
}
}
if (event_handled)
return TRUE;
else
}
static gboolean
gint x,
gint y,
{
/* we get (x,y) in our allocation coordinates system */
/* Get item's allocation. */
/* Get coordinates relative to our window. */
/* Location is inside. */
/* this are for calculating the extra docking parameter */
/* Calculate location in terms of the available space (0-100%). */
/* Determine dock location. */
if (rx < SPLIT_RATIO) {
}
}
}
}
else
/* Reset rectangle coordinates to entire item. */
/* Calculate docking indicator rectangle size for new locations. Only
do this when we're not over the item's current location. */
case GDL_DOCK_TOP:
return FALSE;
break;
case GDL_DOCK_BOTTOM:
return FALSE;
break;
case GDL_DOCK_LEFT:
return FALSE;
break;
case GDL_DOCK_RIGHT:
return FALSE;
break;
case GDL_DOCK_CENTER:
return FALSE;
break;
default:
break;
}
}
/* adjust returned coordinates so they are have the same
origin as our window */
/* Set possible target location and return TRUE. */
/* fill-in other dock information */
}
return TRUE;
}
else /* No docking possible at this location. */
return FALSE;
}
static void
{
if (GDL_IS_DOCK_ITEM (parent))
else
{
}
/* If preferred size is not set on the requestor (perhaps a new item),
* then estimate and set it. The default value (either 0 or 1 pixels) is
* not any good.
*/
switch (position) {
case GDL_DOCK_TOP:
case GDL_DOCK_BOTTOM:
{
}
{
}
break;
case GDL_DOCK_LEFT:
case GDL_DOCK_RIGHT:
{
}
{
}
break;
case GDL_DOCK_CENTER:
{
}
{
}
break;
default:
{
g_warning (_("Unsupported docking strategy %s in dock object of type %s"),
return;
}
}
switch (position) {
case GDL_DOCK_TOP:
case GDL_DOCK_BOTTOM:
/* get a paned style dock object */
"orientation", GTK_ORIENTATION_VERTICAL,
NULL);
if (parent)
break;
case GDL_DOCK_LEFT:
case GDL_DOCK_RIGHT:
"orientation", GTK_ORIENTATION_HORIZONTAL,
NULL);
if(parent)
break;
case GDL_DOCK_CENTER:
/* If the parent is already a DockNotebook, we don't need
to create a new one. */
if (!GDL_IS_DOCK_NOTEBOOK (parent))
{
NULL);
}
break;
default:
{
g_warning (_("Unsupported docking strategy %s in dock object of type %s"),
return;
}
}
/* freeze the parent so it doesn't reduce automatically */
if (parent)
if (new_parent)
{
/* ref ourselves since we could be destroyed when detached */
/* freeze the new parent, so reduce won't get called before it's
actually added to our parent */
/* bind the new parent to our master, so the following adds work */
/* add the objects */
if (add_ourselves_first) {
} else {
}
/* add the new parent to the parent */
if (parent)
/* show automatic object */
{
}
/* use extra docking parameter */
NULL);
}
}
else
{
/* If the parent is already a DockNotebook, we don't need
to create a new one. */
}
{
/* Activate the page we just added */
}
if (parent)
}
static void
{
}
static void
{
/* Create popup menu and attach it to the dock item */
GTK_WIDGET (item),
/* UnLock menuitem */
mitem);
} else {
/* Hide menuitem. */
/* Lock menuitem */
}
}
/* Show popup menu. */
}
static void
{
/* grab the pointer so we receive all mouse events */
/* grab the keyboard & pointer */
}
static void
{
/* Release pointer & keyboard. */
}
}
static void
{
if (!GDL_DOCK_ITEM_NOT_LOCKED (item))
return;
case 1:
/* set dragoff_{x,y} as we the user clicked on the middle of the
drag handle */
switch (item->orientation) {
/*item->dragoff_x = item->_priv->grip_size / 2;*/
break;
case GTK_ORIENTATION_VERTICAL:
/*item->dragoff_x = GTK_WIDGET (data)->allocation.width / 2;*/
break;
};
break;
case 3:
break;
default:
break;
};
}
static void
{
}
static void
{
}
static void
{
}
static void
{
if (GDL_DOCK_ITEM_GRIP_SHOWN (item) &&
}
if (cursor)
}
static void
{
}
/* ----- 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.
**/
{
"name", name,
"long-name", long_name,
"behavior", behavior,
NULL));
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.
**/
{
"name", name,
"long-name", long_name,
"stock-id", stock_id,
"behavior", behavior,
NULL));
return GTK_WIDGET (item);
}
const GdkPixbuf *pixbuf_icon,
{
"name", name,
"long-name", long_name,
"pixbuf-icon", pixbuf_icon,
"behavior", behavior,
NULL));
return GTK_WIDGET (item);
}
/* 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
{
g_return_if_fail ((item->behavior & GDL_DOCK_ITEM_BEH_NEVER_FLOATING) == 0 || position != GDL_DOCK_FLOATING);
return;
}
/* FIXME: save previous docking position for later
re-docking... does this make sense now? */
/* Create new floating dock for widget. */
} else
}
/**
* 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
{
/* push the property down the hierarchy if our child supports it */
"orientation", orientation,
NULL);
};
}
}
/**
* 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.
**/
{
}
/**
* 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
{
{
}
/* disconnect and unref the previous tablabel */
0, 0, NULL,
}
}
if (tablabel) {
if (GDL_IS_DOCK_TABLABEL (tablabel)) {
/* connect to tablabel signal */
}
}
}
/**
* 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.
**/
{
}
/**
* gdl_dock_item_hide_grip:
* @item: The dock item to hide the grip of.
*
* This function hides the dock item's grip widget.
**/
void
{
};
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_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
{
}
/* 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
{
}
/* 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_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
{
if (!GDL_DOCK_OBJECT_ATTACHED (item))
return;
/* if the object is manual, create a new placeholder to be able to
restore the position later */
if (!GDL_DOCK_OBJECT_AUTOMATIC (item)) {
{
"floating", &isFloating,
"width", &width,
"height",&height,
"floatx",&x,
"floaty",&y,
NULL);
} else {
}
"sticky", FALSE,
"host", item,
"width", width,
"height", height,
"floating", isFloating,
"floatx", x,
"floaty", y,
NULL));
}
/* hide our children first, so they can also set placeholders */
NULL);
/* detach the item recursively */
}
/**
* 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_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
{
"width", &width,
"height", &height,
"floating",&isFloating,
"floatx", &x,
"floaty", &y,
NULL);
if (isFloating) {
} else {
GTK_WIDGET (item));
}
g_warning("Object %s has no default position and flag GDL_DOCK_ITEM_BEH_NEVER_FLOATING is set.\n",
} else if (toplevel) {
} 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_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_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_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
{
}
if (GDL_IS_DOCK_PLACEHOLDER (reference)) {
} else {
"sticky", TRUE,
"host", reference,
NULL));
}
}
}
/**
* 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
{
if (!req)
return;
}
{
item_child && GTK_IS_CONTAINER (item_child) && gtk_container_get_focus_child (GTK_CONTAINER (item_child));
return item_or_child_has_focus;
}
static void
{
"horizontal" : "vertical");
}
static void
{
else
}