gdl-dock.c revision a5bc35f91521f6359cd213789c372ef5c550ace2
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* This file is part of the GNOME Devtools Libraries.
*
* Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net>
* 2007 Naba Kumar <naba@gnome.org>
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gdl-i18n.h"
#include <stdlib.h>
#include <string.h>
#include "gdl-tools.h"
#include "gdl-dock.h"
#include "gdl-dock-master.h"
#include "gdl-dock-paned.h"
#include "gdl-dock-notebook.h"
#include "gdl-dock-placeholder.h"
#include "libgdlmarshal.h"
/* ----- Private prototypes ----- */
GParamSpec *pspec);
GParamSpec *pspec);
gint x,
gint y,
GValue *other_data);
GValue *other_data);
/* ----- Class variables and definitions ----- */
struct _GdlDockPrivate
{
/* for floating docks */
/* auxiliary fields */
};
enum {
};
enum {
};
#define SPLIT_RATIO 0.3
/* ----- Private functions ----- */
static void
{
/* properties */
_("Whether the dock is floating in its own window"),
_("Default title for the newly created floating docks"),
NULL,
_("Width for the dock when it's of floating type"),
_("Height for the dock when it's of floating type"),
_("X coordinate for a floating dock"),
_("Y coordinate for a floating dock"),
/* signals */
g_signal_new ("layout-changed",
NULL, /* accumulator */
NULL, /* accu_data */
G_TYPE_NONE, /* return type */
0);
}
static void
{
}
static gboolean
{
(void)widget;
return FALSE;
}
static GObject *
{
(type,
NULL);
if (g_object) {
/* create a master for the dock if none was provided in the construction */
if (!master) {
/* the controller owns the master ref */
}
/* create floating window for this dock */
/* set position and default size */
TRUE);
/* metacity ignores this */
/* connect to the configure event so we can track down window geometry */
dock);
/* set the title and connect to the long_name notify queue
so we can reset the title when this prop changes */
NULL);
}
}
return g_object;
}
static void
{
switch (prop_id) {
case PROP_FLOATING:
break;
case PROP_DEFAULT_TITLE:
NULL);
break;
case PROP_WIDTH:
break;
case PROP_HEIGHT:
break;
case PROP_FLOAT_X:
break;
case PROP_FLOAT_Y:
break;
default:
break;
}
switch (prop_id) {
case PROP_WIDTH:
case PROP_HEIGHT:
case PROP_FLOAT_X:
case PROP_FLOAT_Y:
}
break;
}
}
static void
{
switch (prop_id) {
case PROP_FLOATING:
break;
case PROP_DEFAULT_TITLE:
"default-title", &default_title,
NULL);
#else
#endif
}
else
break;
case PROP_WIDTH:
break;
case PROP_HEIGHT:
break;
case PROP_FLOAT_X:
break;
case PROP_FLOAT_Y:
break;
default:
break;
}
}
static void
{
return;
}
}
}
if (!title) {
/* set a default title in the long_name */
title = g_strdup_printf (
}
}
static void
{
(void)pspec;
(void)user_data;
if (long_name)
{
}
}
static void
{
}
/* destroy the xor gc */
}
}
}
static void
{
/* make request to root */
else {
requisition->width = 0;
requisition->height = 0;
};
}
static void
{
/* reduce allocation by border width */
allocation->x += border_width;
allocation->y += border_width;
}
static void
{
}
}
static void
{
}
}
static void
{
if (GDL_DOCK_OBJECT_AUTOMATIC (object))
}
static void
{
if (GDL_DOCK_IS_CONTROLLER (dock)) {
}
}
static void
{
if (GDL_DOCK_IS_CONTROLLER (dock)) {
}
}
static void
{
GDL_DOCK_TOP); /* default position */
}
static void
{
}
}
static void
{
(void)include_internals;
}
static GType
{
(void)container;
return GDL_TYPE_DOCK_ITEM;
}
static void
{
/* detach children */
}
}
static void
{
return;
if (GDL_DOCK_OBJECT_AUTOMATIC (dock)) {
} else if (!GDL_DOCK_OBJECT_ATTACHED (dock)) {
/* if the user explicitly detached the object */
else {
}
}
}
static gboolean
gint x,
gint y,
{
/* we get (x,y) in our allocation coordinates system */
/* Get dock size. */
/* Get coordinates relative to our allocation area. */
if (request)
my_request = *request;
/* Check if coordinates are in GdlDock widget. */
/* It's inside our area. */
/* Set docking indicator rectangle to the GdlDock size. */
/* If GdlDock has no root item yet, set the dock itself as
possible target. */
} else {
/* See if it's in the border_width band. */
} else {
/* Otherwise try our children. */
/* give them allocation coordinates (we are a
GTK_NO_WINDOW) widget */
x, y, &my_request);
}
}
}
*request = my_request;
return may_dock;
}
static void
{
/* only dock items allowed at this time */
if (position == GDL_DOCK_FLOATING) {
x = rect->x;
y = rect->y;
}
else {
x = y = 0;
}
}
/* This is somewhat a special case since we know which item to
pass the request on because we only have on child */
}
else { /* Item about to be added is root item. */
/* Realize the item (create its corresponding GdkWindow) when
GdlDock has been realized. */
/* Map the widget if it's visible and the parent is visible and has
been mapped. This is done to make sure that the GdkWindow is
visible. */
/* Make the widget resize. */
}
}
}
static gboolean
{
/* this will call reduce on ourselves, hiding the window if appropiate */
}
return TRUE;
}
static void
{
if (GDL_IS_DOCK_ITEM (object))
*l = g_list_prepend (*l, object);
}
static gboolean
{
rect->x,
rect->y);
}
}
return handled;
}
static gboolean
{
if (placement) {
}
} else
return retval;
}
static void
{
(void)child;
}
}
/* ----- Public interface ----- */
gdl_dock_new (void)
{
return GTK_WIDGET (dock);
}
{
"floating", floating,
NULL);
return GTK_WIDGET (new_dock);
}
/* Depending on where the dock item (where new item will be docked) locates
* in the dock, we might need to change the docking placement. If the
* item is does not touches the center of dock, the new-item-to-dock would
* require a center dock on this item.
*/
static GdlDockPlacement
{
/* Check if dock_object touches center in terms of width */
return GDL_DOCK_TOP;
}
}
return placement;
}
/* Determines the larger item of the two based on the placement:
* for center placement, area determines it.
*/
static GdlDockItem*
{
(void)level;
{
{
} else if (placement == GDL_DOCK_CENTER) {
/* For center place, area is what matters */
} else if (placement == GDL_DOCK_NONE) {
return dock_item_1;
} else {
}
return dock_item_1;
}
/* Determines the best dock item to dock a new item with the given placement.
* It traverses the dock tree and (based on the placement) tries to find
* the best located item wrt to the placement. The approach is to find the
* find the largest item for center placement. In most situations, this is
* what user wants and the heuristic should be therefore sufficient.
*/
static GdlDockItem*
{
if (GDL_IS_DOCK_PANED (dock_item))
{
if ((orientation == GTK_ORIENTATION_HORIZONTAL &&
placement == GDL_DOCK_LEFT) ||
placement == GDL_DOCK_TOP)) {
/* Return left or top pane widget */
ret_item =
} else if ((orientation == GTK_ORIENTATION_HORIZONTAL &&
placement == GDL_DOCK_RIGHT) ||
placement == GDL_DOCK_BOTTOM)) {
/* Return right or top pane widget */
ret_item =
} else {
/* Evaluate which of the two sides is bigger */
}
}
else if (GDL_IS_DOCK_ITEM (dock_item))
{
}
else
{
/* should not be here */
}
return ret_item;
}
void
{
if (placement == GDL_DOCK_FLOATING)
/* Add the item to a new floating dock */
else {
/* Non-floating item. */
/* GtkRequisition preferred_size; */
placement, 0);
} else {
}
}
}
void
gint x,
gint y,
{
"floating", TRUE,
"width", width,
"height", height,
"floatx", x,
"floaty", y,
NULL));
/* Make the widget resize. */
}
}
{
/* proxy the call to our master */
}
{
/* proxy the call to our master */
}
GList *
{
return list;
}
GdlDock *
{
}
void
{
if (gtk_widget_get_realized (widget)) {
} else
return;
};
dash_list [0] = 1;
}