gdl-dock-item.c revision 3e05ca21da918c890f1c46c8d09eeaeb4099abbc
/* -*- 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-tools.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"
#define NEW_DOCK_ITEM_RATIO 0.3
/* ----- 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 {
};
#define GDL_DOCK_ITEM_GRIP_SHOWN(item) \
struct _GdlDockItemPrivate {
};
/* FIXME: implement the rest of the behaviors */
#define SPLIT_RATIO 0.4
/* ----- 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 */
_("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 */
g_signal_new ("dock-drag-begin",
NULL, /* accumulator */
NULL, /* accu_data */
0);
g_signal_new ("dock-drag-motion",
NULL, /* accumulator */
NULL, /* accu_data */
2,
g_signal_new ("dock_drag_end",
NULL, /* accumulator */
NULL, /* accu_data */
1,
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 GObject *
{
(type,
NULL);
if (g_object) {
if (GDL_DOCK_ITEM_HAS_GRIP (item)) {
}
else {
}
}
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;
}
}
static void
{
/* Once size is allocated, preferred size is no longer necessary */
if (gtk_widget_get_realized (widget))
widget->allocation.x,
widget->allocation.y,
int border_width;
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 */
}
static void
{
(void)previous_style;
if (gtk_widget_is_drawable (widget))
}
}
static void
{
"dockitem",
0, 0, -1, -1);
}
static gint
{
}
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
FALSE);
}
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)
/* ref ourselves since we could be destroyed when detached */
if (new_parent)
{
}
/* 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 */
{
}
else // If the parent is already a DockNotebook, we don't need
// to create a new one.
/* use extra docking parameter */
NULL);
}
{
/* Activate the page we just added */
}
if (parent)
}
static void
{
(void)menu;
}
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
{
(void)widget;
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
{
(void)widget;
}
static void
{
(void)widget;
}
static void
{
(void)widget;
}
static void
{
if (GDL_DOCK_ITEM_GRIP_SHOWN (item) &&
}
if (cursor)
}
static void
{
}
/* ----- Public interface ----- */
{
"name", name,
"long-name", long_name,
"behavior", behavior,
NULL));
return GTK_WIDGET (item);
}
{
"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) */
void
{
(void)docking_param;
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
}
void
{
/* push the property down the hierarchy if our child supports it */
"orientation", orientation,
NULL);
};
}
}
{
}
void
{
/* disconnect and unref the previous tablabel */
0, 0, NULL,
}
}
if (tablabel) {
if (GDL_IS_DOCK_TABLABEL (tablabel)) {
/* connect to tablabel signal */
}
}
}
void
{
};
g_warning ("Grips always show unless GDL_DOCK_ITEM_BEH_NO_GRIP is set\n" );
}
void
{
};
}
/* convenient function (and to preserve source compat) */
void
{
}
/* convenient function (and to preserve source compat) */
void
{
}
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 */
}
void
{
}
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",
}
void
{
}
void
{
}
void
{
}
if (GDL_IS_DOCK_PLACEHOLDER (reference)) {
} else {
"sticky", TRUE,
"host", reference,
NULL));
}
}
}
void
{
if (!req)
return;
}
{
return item_or_child_has_focus;
}
static void
{
"horizontal" : "vertical");
}
static void
{
else
}