summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlex Valavanis <valavanisalex@gmail.com>2016-07-27 16:21:52 +0000
committerAlex Valavanis <valavanisalex@gmail.com>2016-07-27 16:21:52 +0000
commit3078d10fcf276c0d36975bfd48ef064b46f60b3d (patch)
tree3a17c6c1a9e3c6cce3e315932ea278b3cdd23af5 /src
parentOrder some headers (diff)
downloadinkscape-3078d10fcf276c0d36975bfd48ef064b46f60b3d.tar.gz
inkscape-3078d10fcf276c0d36975bfd48ef064b46f60b3d.zip
Disable GTK+ 2 support and delete internal copy of GDL
Fixed bugs: - https://launchpad.net/bugs/1424830 - https://launchpad.net/bugs/1606558 (bzr r15023.2.1)
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt6
-rw-r--r--src/Makefile.am11
-rw-r--r--src/libgdl/CMakeLists.txt50
-rw-r--r--src/libgdl/Makefile_insert92
-rw-r--r--src/libgdl/README.gdl-dock184
-rw-r--r--src/libgdl/gdl-dock-bar.c1049
-rw-r--r--src/libgdl/gdl-dock-bar.h74
-rw-r--r--src/libgdl/gdl-dock-item-button-image.c166
-rw-r--r--src/libgdl/gdl-dock-item-button-image.h70
-rw-r--r--src/libgdl/gdl-dock-item-grip.c809
-rw-r--r--src/libgdl/gdl-dock-item-grip.h77
-rw-r--r--src/libgdl/gdl-dock-item.c2401
-rw-r--r--src/libgdl/gdl-dock-item.h223
-rw-r--r--src/libgdl/gdl-dock-master.c1011
-rw-r--r--src/libgdl/gdl-dock-master.h106
-rw-r--r--src/libgdl/gdl-dock-notebook.c530
-rw-r--r--src/libgdl/gdl-dock-notebook.h59
-rw-r--r--src/libgdl/gdl-dock-object.c1027
-rw-r--r--src/libgdl/gdl-dock-object.h225
-rw-r--r--src/libgdl/gdl-dock-paned.c678
-rw-r--r--src/libgdl/gdl-dock-paned.h64
-rw-r--r--src/libgdl/gdl-dock-placeholder.c827
-rw-r--r--src/libgdl/gdl-dock-placeholder.h69
-rw-r--r--src/libgdl/gdl-dock-tablabel.c632
-rw-r--r--src/libgdl/gdl-dock-tablabel.h74
-rw-r--r--src/libgdl/gdl-dock.c1365
-rw-r--r--src/libgdl/gdl-dock.h99
-rw-r--r--src/libgdl/gdl-i18n.c43
-rw-r--r--src/libgdl/gdl-i18n.h72
-rw-r--r--src/libgdl/gdl-switcher.c1031
-rw-r--r--src/libgdl/gdl-switcher.h67
-rw-r--r--src/libgdl/gdl-win32.c42
-rw-r--r--src/libgdl/gdl-win32.h21
-rw-r--r--src/libgdl/gdl.h32
-rw-r--r--src/libgdl/libgdlmarshal.c173
-rw-r--r--src/libgdl/libgdlmarshal.h48
-rw-r--r--src/libgdl/libgdlmarshal.list7
-rw-r--r--src/libgdl/libgdltypebuiltins.c162
-rw-r--r--src/libgdl/libgdltypebuiltins.h38
-rw-r--r--src/libgdl/makefile.in17
-rw-r--r--src/widgets/CMakeLists.txt7
-rw-r--r--src/widgets/Makefile_insert8
42 files changed, 4 insertions, 13742 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d4ba9b1f0..41e7a7967 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -467,7 +467,6 @@ add_subdirectory(libavoid)
add_subdirectory(libcola)
add_subdirectory(libcroco)
add_subdirectory(inkgc)
-add_subdirectory(libgdl)
add_subdirectory(libuemf)
add_subdirectory(libvpsc)
add_subdirectory(livarot)
@@ -540,11 +539,6 @@ set(INKSCAPE_TARGET_LIBS
${INKSCAPE_LIBS}
)
-if (NOT "${WITH_EXT_GDL}")
- # Insert it at the beginning of the list as the windows build fails otherwise
- list (INSERT INKSCAPE_TARGET_LIBS 0 "gdl_LIB")
-endif()
-
# Link the inkscape_base library against all external dependencies
target_link_libraries(inkscape_base ${INKSCAPE_TARGET_LIBS})
diff --git a/src/Makefile.am b/src/Makefile.am
index 087a727de..6e1dabdbd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -16,16 +16,9 @@ bin_PROGRAMS = inkscape inkview
# Libraries which should be compiled by "make" but not installed.
# Use this only for libraries that are really standalone, rather than for
# source tree subdirectories.
-
-if !WITH_EXT_GDL
-internal_GDL = libgdl/libgdl.a
-endif
-
-
noinst_LIBRARIES = \
libcroco/libcroco.a \
libavoid/libavoid.a \
- $(internal_GDL) \
libuemf/libuemf.a \
libcola/libcola.a \
inkgc/libinkgc.a \
@@ -51,7 +44,6 @@ all_libs = \
$(LIBVISIO_LIBS) \
$(LIBCDR_LIBS) \
$(DBUS_LIBS) \
- $(GDL_LIBS) \
$(IMAGEMAGICK_LIBS) \
$(X11_LIBS)
@@ -82,7 +74,6 @@ AM_CPPFLAGS = \
$(LIBVISIO_CFLAGS) \
$(LIBCDR_CFLAGS) \
$(DBUS_CFLAGS) \
- $(GDL_CFLAGS) \
$(XFT_CFLAGS) \
$(LCMS_CFLAGS) \
$(POPPLER_CFLAGS) \
@@ -122,7 +113,6 @@ include helper/Makefile_insert
include io/Makefile_insert
include libcroco/Makefile_insert
include inkgc/Makefile_insert
-include libgdl/Makefile_insert
include libnrtype/Makefile_insert
include libavoid/Makefile_insert
include livarot/Makefile_insert
@@ -160,7 +150,6 @@ EXTRA_DIST += \
io/makefile.in \
libavoid/makefile.in \
libcroco/makefile.in \
- libgdl/makefile.in \
libnrtype/makefile.in \
libuemf/makefile.in \
livarot/makefile.in \
diff --git a/src/libgdl/CMakeLists.txt b/src/libgdl/CMakeLists.txt
deleted file mode 100644
index a452320f7..000000000
--- a/src/libgdl/CMakeLists.txt
+++ /dev/null
@@ -1,50 +0,0 @@
-if (NOT "${WITH_EXT_GDL}")
-
- set(libgdl_SRC
- gdl-dock-bar.c
- gdl-dock-item-button-image.c
- gdl-dock-item-grip.c
- gdl-dock-item.c
- gdl-dock-master.c
- gdl-dock-notebook.c
- gdl-dock-object.c
- gdl-dock-paned.c
- gdl-dock-placeholder.c
- gdl-dock-tablabel.c
- gdl-dock.c
- gdl-i18n.c
- gdl-switcher.c
- libgdlmarshal.c
- libgdltypebuiltins.c
-
-
- # -------
- # Headers
- gdl-dock-bar.h
- gdl-dock-item-button-image.h
- gdl-dock-item-grip.h
- gdl-dock-item.h
- gdl-dock-master.h
- gdl-dock-notebook.h
- gdl-dock-object.h
- gdl-dock-paned.h
- gdl-dock-placeholder.h
- gdl-dock-tablabel.h
- gdl-dock.h
- gdl-i18n.h
- gdl-switcher.h
- gdl.h
- libgdlmarshal.h
- libgdltypebuiltins.h
- )
-
- if(WIN32)
- list(APPEND libgdl_SRC
- gdl-win32.c
- gdl-win32.h
- )
- endif()
-
- add_inkscape_lib(gdl_LIB "${libgdl_SRC}")
-
-endif()
diff --git a/src/libgdl/Makefile_insert b/src/libgdl/Makefile_insert
deleted file mode 100644
index e4cab95fc..000000000
--- a/src/libgdl/Makefile_insert
+++ /dev/null
@@ -1,92 +0,0 @@
-## Makefile.am fragment sourced by src/Makefile.am.
-
-if WITH_EXT_GDL
-
-EXTRA_DIST += \
- libgdl/gdl-dock-object.h \
- libgdl/gdl-dock-master.h \
- libgdl/gdl-dock.h \
- libgdl/gdl-dock-item.h \
- libgdl/gdl-dock-notebook.h \
- libgdl/gdl-dock-paned.h \
- libgdl/gdl-dock-tablabel.h \
- libgdl/gdl-dock-placeholder.h \
- libgdl/gdl-dock-bar.h \
- libgdl/gdl-i18n.h \
- libgdl/gdl-i18n.c \
- libgdl/gdl-dock-object.c \
- libgdl/gdl-dock-master.c \
- libgdl/gdl-dock.c \
- libgdl/gdl-dock-item.c \
- libgdl/gdl-dock-item-button-image.c \
- libgdl/gdl-dock-item-button-image.h \
- libgdl/gdl-dock-item-grip.h \
- libgdl/gdl-dock-item-grip.c \
- libgdl/gdl-dock-notebook.c \
- libgdl/gdl-dock-paned.c \
- libgdl/gdl-dock-tablabel.c \
- libgdl/gdl-dock-placeholder.c \
- libgdl/gdl-dock-bar.c \
- libgdl/gdl-switcher.h \
- libgdl/gdl-switcher.c \
- libgdl/gdl-win32.h \
- libgdl/gdl-win32.c \
- libgdl/libgdltypebuiltins.h \
- libgdl/libgdltypebuiltins.c \
- libgdl/libgdlmarshal.h \
- libgdl/libgdlmarshal.c \
- libgdl/gdl.h
-
-else # WITH_EXT_GDL
-
-libgdl/all: libgdl/libgdl.a
-
-libgdl/clean:
- rm -f libgdl/libgdl.a $(libgdl_gdl_a_OBJECTS)
-
-# Suppress some non-critical warnings for libgdl. We will drop our forked copy
-# of GDL once we upgrade to Gtk+ 3 so it's more important to minimise the number
-# of changes we make to GDL than to fix these minor issues in trunk.
-
-if CC_WNO_UNUSED_BUT_SET_VARIABLE_SUPPORTED
-libgdl_libgdl_a_CFLAGS = -Wno-unused-parameter -Wno-sign-compare -Wno-unused-variable -Wno-unused-but-set-variable -Wno-missing-field-initializers $(AM_CFLAGS)
-else
-libgdl_libgdl_a_CFLAGS = -Wno-unused-parameter -Wno-sign-compare -Wno-unused-variable -Wno-missing-field-initializers $(AM_CFLAGS)
-endif
-
-libgdl_libgdl_a_SOURCES = \
- libgdl/gdl-dock-object.h \
- libgdl/gdl-dock-master.h \
- libgdl/gdl-dock.h \
- libgdl/gdl-dock-item.h \
- libgdl/gdl-dock-notebook.h \
- libgdl/gdl-dock-paned.h \
- libgdl/gdl-dock-tablabel.h \
- libgdl/gdl-dock-placeholder.h \
- libgdl/gdl-dock-bar.h \
- libgdl/gdl-i18n.h \
- libgdl/gdl-i18n.c \
- libgdl/gdl-dock-object.c \
- libgdl/gdl-dock-master.c \
- libgdl/gdl-dock.c \
- libgdl/gdl-dock-item.c \
- libgdl/gdl-dock-item-button-image.c \
- libgdl/gdl-dock-item-button-image.h \
- libgdl/gdl-dock-item-grip.h \
- libgdl/gdl-dock-item-grip.c \
- libgdl/gdl-dock-notebook.c \
- libgdl/gdl-dock-paned.c \
- libgdl/gdl-dock-tablabel.c \
- libgdl/gdl-dock-placeholder.c \
- libgdl/gdl-dock-bar.c \
- libgdl/gdl-switcher.h \
- libgdl/gdl-switcher.c \
- libgdl/gdl-win32.h \
- libgdl/gdl-win32.c \
- libgdl/libgdltypebuiltins.h \
- libgdl/libgdltypebuiltins.c \
- libgdl/libgdlmarshal.h \
- libgdl/libgdlmarshal.c \
- libgdl/gdl.h
-
-endif
diff --git a/src/libgdl/README.gdl-dock b/src/libgdl/README.gdl-dock
deleted file mode 100644
index 113926dbe..000000000
--- a/src/libgdl/README.gdl-dock
+++ /dev/null
@@ -1,184 +0,0 @@
-This file is meant to contain a little documentation about the GdlDock
-and related widgets. It's incomplete and probably a bit out of date.
-And it probably belongs to a doc/ subdirectory.
-
-Please send comments to the devtools list (gnome-devtools@gnome.org)
-and report bugs to bugzilla (bugzilla.gnome.org). Also check the todo
-list at the end of this document.
-
-Have fun,
-Gustavo
-
-
-Overview
---------
-
-The GdlDock is a hierarchical based docking widget. It is composed of
-widgets derived from the abstract class GdlDockObject which defines
-the basic interface for docking widgets on top of others.
-
-The toplevel entries for docks are GdlDock widgets, which in turn hold
-a tree of GdlDockItem widgets. For the toplevel docks to be able to
-interact with each other (when the user drags items from one place to
-another) they're all kept in a user-invisible and automatic object
-called the master. To participate in docking operations every
-GdlDockObject must have the same master (the binding to the master is
-done automatically). The master also keeps track of the manual items
-(mostly those created with gdl_dock_*_new functions) which are in the
-dock.
-
-Layout loading/saving service is provided by a separate object called
-GdlDockLayout. Currently it stores information in XML format, but
-another backend could be easily written. To keep the external XML
-file in sync with the dock, monitor the "dirty" property of the layout
-object and call gdl_dock_layout_save_to_file when this changes to
-TRUE. No other action is required (the layout_changed is monitored by
-the layout object for you now).
-
-
-GdlDockObject
-=============
-
-A DockObject has:
-
-- a master, which manages all the objects in a dock ring ("master"
- property, construct only).
-
-- a name. If the object is manual the name can be used to recall the
- object from any other object in the ring ("name" property).
-
-- a long, descriptive name ("long-name" property).
-
-A DockObject can be:
-
-- automatic or manual. If it's automatic it means the lifecycle of
- the object is entirely managed by the dock master. If it's manual
- in general means the user specified such object, and so it's not to
- be destroyed automatically at any time.
-
-- frozen. In this case any call to reduce on the object has no
- immediate effect. When the object is later thawn, any pending
- reduce calls are made (maybe leading to the destruction of the
- object).
-
-- attached or detached. In general for dock items, being attached
- will mean the item has its widget->parent set. For docks it will
- mean they belong to some dock master's ring. In general, automatic
- objects which are detached will be destroyed (unless frozen).
-
-- bound to a master or free. In order to participate in dock
- operations, each dock object must be bound to a dock master (which
- is a separate, non-gui object). In general, bindings are treated
- automatically by the object, and this is entirely true for automatic
- objects. For manual objects, the master holds an additional
- reference and has structures to store and recall them by nick names.
- Normally, a manual object will only be destroyed when it's unbound
- from the master.
-
-- simple or compound. This actually depends on the subclass of the
- dock object. The difference is made so we can put restrictions in
- how the objects are docked on top of another (e.g. you can't dock a
- compound object inside a notebook). If you look at the whole
- docking layout as a tree, simple objects are the leaves, while all
- the interior nodes are compound.
-
-- reduced. This is only meaningful for compound objects. If the
- number of contained items has decreased to one the compound type
- object is no longer necessary to hold the child. In this case the
- child is reattached to the object's parent. If the number of
- contained items has reached zero, the object is detached and reduce
- is called on its parent. For toplevel docks, the object is only
- detached if it's automatic. In any case, the future of the object
- itself depends on whether it's automatic or manual.
-
-- requested to possibly dock another object. Depending on the
- type's behavior, the object can accept or reject this request. If
- it accepts it, it should fill in some additional information
- regarding how it will host the peer object.
-
-- asked to dock another object. Depending on the object's internal
- structure and behavior two options can be taken: to dock the object
- directly (e.g. a notebook docking another object); or to create an
- automatic compound object which will be attached in place of the
- actual object, and will host both the original object and the
- requestor (e.g. a simple item docking another simple item, which
- should create a paned/notebook). The type of the new object will be
- decided by the original objet based on the docking position.
-
-
-DETACHING: the action by which an object is unparented. The object is
-then ready to be docked in some other place. Newly created objects
-are always detached, except for toplevels (which are created attached
-by default). An automatic object which is detached gets destroyed
-afterwards, since its ref count drops to zero. Floating automatic
-toplevels never reach a zero ref count when detached, since the
-GtkWindow always keeps a reference to it (and the GtkWindow has a user
-reference). That's why floating automatic toplevels are destroyed
-when reduced.
-
-REDUCING: for compound objects, when the number of contained children
-drops to one or zero, the container is no longer necessary. In this
-case, the object is detached, and any remaining child is reattached to
-the object's former parent. The limit for toplevels is one for
-automatic objects and zero for manual (i.e. they can even be empty).
-For simple (not compound) objects reducing doesn't make sense.
-
-UNBINDING: to participate in a dock ring, every object must be bound
-to a master. The master connects to dock item signals and keeps a
-list of bound toplevels. Additionally, a reference is kept for manual
-objects (this is so the user doesn't need to keep track of them, but
-can perform operations like hiding and such).
-
-
-
-GdlDock
-=======
-
-- Properties:
-
- "floating" (gboolean, construct-only): whether the dock is floating in
- its own window or not.
-
- "default-title" (gchar, read-write): title for new floating docks.
- This property is proxied to the master, which truly holds it.
-
-The title for the floating docks is: the user supplied title
-(GdlDockObject's long_name property) if it's set, the default title
-(from the master) or an automatically generated title.
-
-
-- Signals:
-
- "layout-changed": emitted when the user changed the layout of the
- dock somehow.
-
-
-TODO LIST
-=========
-
-- Functionality for the item grip: provide a11y
-
-- Implement notebook tab reordering
-
-- Implement dock bands for toolbars and menus.
-
-- A dock-related thing is to build resizable toolbars (something like
- the ones Windows have, where the buttons are reflowed according to
- the space available).
-
-- Redesign paneds so they can hold more than two items and resize all
- of them at once by using the handle (see if gimpdock does that).
-
-- Find a way to allow the merging of menu items to the item's popup
- menu. Also, there should be a way for the master to insert some
- menu items.
-
-- Bonobo UI synchronizer.
-
-- Item behavoirs: implement the ones missing and maybe think more of
- them (e.g. positions where it's possible to dock the item, etc.)
-
-- Make a nicer dragbar for the items, with buttons for undocking,
- closing, hidding, etc. (See sodipodi, kdevelop)
-
-
diff --git a/src/libgdl/gdl-dock-bar.c b/src/libgdl/gdl-dock-bar.c
deleted file mode 100644
index c1fe21872..000000000
--- a/src/libgdl/gdl-dock-bar.c
+++ /dev/null
@@ -1,1049 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * This file is part of the GNOME Devtools Libraries.
- *
- * Copyright (C) 2003 Jeroen Zwartepoorte <jeroen@xs4all.nl>
- *
- * This library is free software; you can redistribute it and/or
- * 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-dock.h"
-#include "gdl-dock-master.h"
-#include "gdl-dock-bar.h"
-#include "libgdltypebuiltins.h"
-
-enum {
- PROP_0,
- PROP_MASTER,
- PROP_DOCKBAR_STYLE
-};
-
-/* ----- Private prototypes ----- */
-
-static void gdl_dock_bar_class_init (GdlDockBarClass *klass);
-
-static void gdl_dock_bar_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void gdl_dock_bar_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-
-static void gdl_dock_bar_destroy (GtkObject *object);
-
-static void gdl_dock_bar_attach (GdlDockBar *dockbar,
- GdlDockMaster *master);
-static void gdl_dock_bar_remove_item (GdlDockBar *dockbar,
- GdlDockItem *item);
-
-/* ----- Class variables and definitions ----- */
-
-struct _GdlDockBarPrivate {
- GdlDockMaster *master;
- GSList *items;
- GtkOrientation orientation;
- GdlDockBarStyle dockbar_style;
-};
-
-/* ----- Private functions ----- */
-
-G_DEFINE_TYPE (GdlDockBar, gdl_dock_bar, GTK_TYPE_BOX)
-
-static void gdl_dock_bar_size_request (GtkWidget *widget,
- GtkRequisition *requisition );
-static void gdl_dock_bar_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation );
-static void gdl_dock_bar_size_vrequest (GtkWidget *widget,
- GtkRequisition *requisition );
-static void gdl_dock_bar_size_vallocate (GtkWidget *widget,
- GtkAllocation *allocation );
-static void gdl_dock_bar_size_hrequest (GtkWidget *widget,
- GtkRequisition *requisition );
-static void gdl_dock_bar_size_hallocate (GtkWidget *widget,
- GtkAllocation *allocation );
-static void update_dock_items (GdlDockBar *dockbar, gboolean full_update);
-
-void
-gdl_dock_bar_class_init (GdlDockBarClass *klass)
-{
- GObjectClass *g_object_class;
- GtkObjectClass *gtk_object_class;
- GtkWidgetClass *widget_class;
-
- g_object_class = G_OBJECT_CLASS (klass);
- gtk_object_class = GTK_OBJECT_CLASS (klass);
-
- g_object_class->get_property = gdl_dock_bar_get_property;
- g_object_class->set_property = gdl_dock_bar_set_property;
-
- gtk_object_class->destroy = gdl_dock_bar_destroy;
-
- g_object_class_install_property (
- g_object_class, PROP_MASTER,
- g_param_spec_object ("master", _("Master"),
- _("GdlDockMaster object which the dockbar widget "
- "is attached to"),
- GDL_TYPE_DOCK_MASTER,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- g_object_class, PROP_DOCKBAR_STYLE,
- g_param_spec_enum ("dockbar-style", _("Dockbar style"),
- _("Dockbar style to show items on it"),
- GDL_TYPE_DOCK_BAR_STYLE,
- GDL_DOCK_BAR_BOTH,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- widget_class = GTK_WIDGET_CLASS (klass);
- widget_class->size_request = gdl_dock_bar_size_request;
- widget_class->size_allocate = gdl_dock_bar_size_allocate;
-}
-
-static void
-gdl_dock_bar_init (GdlDockBar *dockbar)
-{
- dockbar->_priv = g_new0 (GdlDockBarPrivate, 1);
- dockbar->_priv->master = NULL;
- dockbar->_priv->items = NULL;
- dockbar->_priv->orientation = GTK_ORIENTATION_VERTICAL;
- dockbar->_priv->dockbar_style = GDL_DOCK_BAR_BOTH;
-}
-
-static void
-gdl_dock_bar_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GdlDockBar *dockbar = GDL_DOCK_BAR (object);
-
- switch (prop_id) {
- case PROP_MASTER:
- g_value_set_object (value, dockbar->_priv->master);
- break;
- case PROP_DOCKBAR_STYLE:
- g_value_set_enum (value, dockbar->_priv->dockbar_style);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- };
-}
-
-static void
-gdl_dock_bar_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GdlDockBar *dockbar = GDL_DOCK_BAR (object);
-
- switch (prop_id) {
- case PROP_MASTER:
- gdl_dock_bar_attach (dockbar, g_value_get_object (value));
- break;
- case PROP_DOCKBAR_STYLE:
- dockbar->_priv->dockbar_style = g_value_get_enum (value);
- update_dock_items (dockbar, TRUE);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- };
-}
-
-static void
-on_dock_item_foreach_disconnect (GdlDockItem *item, GdlDockBar *dock_bar)
-{
- g_signal_handlers_disconnect_by_func (item, gdl_dock_bar_remove_item,
- dock_bar);
-}
-
-static void
-gdl_dock_bar_destroy (GtkObject *object)
-{
- GdlDockBar *dockbar = GDL_DOCK_BAR (object);
-
- if (dockbar->_priv) {
- GdlDockBarPrivate *priv = dockbar->_priv;
-
- if (priv->items) {
- g_slist_foreach (priv->items,
- (GFunc) on_dock_item_foreach_disconnect,
- object);
- g_slist_free (priv->items);
- }
-
- if (priv->master) {
- g_signal_handlers_disconnect_matched (priv->master,
- G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, dockbar);
- g_object_unref (priv->master);
- priv->master = NULL;
- }
-
- dockbar->_priv = NULL;
-
- g_free (priv);
- }
-
- GTK_OBJECT_CLASS (gdl_dock_bar_parent_class)->destroy (object);
-}
-
-static void
-gdl_dock_bar_remove_item (GdlDockBar *dockbar,
- GdlDockItem *item)
-{
- GdlDockBarPrivate *priv;
- GtkWidget *button;
-
- g_return_if_fail (GDL_IS_DOCK_BAR (dockbar));
- g_return_if_fail (GDL_IS_DOCK_ITEM (item));
-
- priv = dockbar->_priv;
-
- if (g_slist_index (priv->items, item) == -1) {
- g_warning ("Item has not been added to the dockbar");
- return;
- }
-
- priv->items = g_slist_remove (priv->items, item);
-
- button = g_object_get_data (G_OBJECT (item), "GdlDockBarButton");
- g_assert (button != NULL);
- gtk_container_remove (GTK_CONTAINER (dockbar), button);
- g_object_set_data (G_OBJECT (item), "GdlDockBarButton", NULL);
- g_signal_handlers_disconnect_by_func (item,
- G_CALLBACK (gdl_dock_bar_remove_item),
- dockbar);
-}
-
-static void
-gdl_dock_bar_item_clicked (GtkWidget *button,
- GdlDockItem *item)
-{
- GdlDockBar *dockbar;
- GdlDockObject *controller;
-
- g_return_if_fail (item != NULL);
-
- dockbar = g_object_get_data (G_OBJECT (item), "GdlDockBar");
- g_assert (dockbar != NULL);
- g_object_set_data (G_OBJECT (item), "GdlDockBar", NULL);
-
- controller = gdl_dock_master_get_controller (GDL_DOCK_OBJECT_GET_MASTER (item));
-
- GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_ICONIFIED);
- gdl_dock_item_show_item (item);
- gdl_dock_bar_remove_item (dockbar, item);
- gtk_widget_queue_resize (GTK_WIDGET (controller));
-}
-
-static void
-gdl_dock_bar_add_item (GdlDockBar *dockbar,
- GdlDockItem *item)
-{
- GdlDockBarPrivate *priv;
- GtkWidget *button;
- gchar *stock_id;
- gchar *name;
- GdkPixbuf *pixbuf_icon;
- GtkWidget *image, *box, *label;
-
- g_return_if_fail (GDL_IS_DOCK_BAR (dockbar));
- g_return_if_fail (GDL_IS_DOCK_ITEM (item));
-
- priv = dockbar->_priv;
-
- if (g_slist_index (priv->items, item) != -1) {
- g_warning ("Item has already been added to the dockbar");
- return;
- }
-
- priv->items = g_slist_append (priv->items, item);
-
- /* Create a button for the item. */
- button = gtk_button_new ();
- gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
-
- if (dockbar->_priv->orientation == GTK_ORIENTATION_HORIZONTAL)
- box = gtk_hbox_new (FALSE, 0);
- else
- box = gtk_vbox_new (FALSE, 0);
-
- g_object_get (item, "stock-id", &stock_id, "pixbuf-icon", &pixbuf_icon,
- "long-name", &name, NULL);
-
- if (dockbar->_priv->dockbar_style == GDL_DOCK_BAR_TEXT ||
- dockbar->_priv->dockbar_style == GDL_DOCK_BAR_BOTH) {
- label = gtk_label_new (name);
- if (dockbar->_priv->orientation == GTK_ORIENTATION_VERTICAL)
- gtk_label_set_angle (GTK_LABEL (label), 90);
- gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
- }
-
- /* FIXME: For now AUTO behaves same as BOTH */
-
- if (dockbar->_priv->dockbar_style == GDL_DOCK_BAR_ICONS ||
- dockbar->_priv->dockbar_style == GDL_DOCK_BAR_BOTH ||
- dockbar->_priv->dockbar_style == GDL_DOCK_BAR_AUTO) {
- if (stock_id) {
- image = gtk_image_new_from_stock (stock_id,
- GTK_ICON_SIZE_SMALL_TOOLBAR);
- g_free (stock_id);
- } else if (pixbuf_icon) {
- image = gtk_image_new_from_pixbuf (pixbuf_icon);
- } else {
- image = gtk_image_new_from_stock ("gtk-new",
- GTK_ICON_SIZE_SMALL_TOOLBAR);
- }
- gtk_box_pack_start (GTK_BOX (box), image, TRUE, TRUE, 0);
- }
-
- gtk_container_add (GTK_CONTAINER (button), box);
- gtk_box_pack_start (GTK_BOX (dockbar), button, FALSE, FALSE, 0);
-
- gtk_widget_set_tooltip_text (button, name);
- g_free (name);
-
- g_object_set_data (G_OBJECT (item), "GdlDockBar", dockbar);
- g_object_set_data (G_OBJECT (item), "GdlDockBarButton", button);
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (gdl_dock_bar_item_clicked), item);
-
- gtk_widget_show_all (button);
-
- /* Set up destroy notify */
- g_signal_connect_swapped (item, "destroy",
- G_CALLBACK (gdl_dock_bar_remove_item),
- dockbar);
-}
-
-static void
-build_list (GdlDockObject *object, GList **list)
-{
- /* add only items, not toplevels */
- if (GDL_IS_DOCK_ITEM (object))
- *list = g_list_prepend (*list, object);
-}
-
-static void
-update_dock_items (GdlDockBar *dockbar, gboolean full_update)
-{
- GdlDockMaster *master;
- GList *items, *l;
-
- g_return_if_fail (dockbar != NULL);
-
- if (!dockbar->_priv->master)
- return;
-
- master = dockbar->_priv->master;
-
- /* build items list */
- items = NULL;
- gdl_dock_master_foreach (master, (GFunc) build_list, &items);
-
- if (!full_update) {
- for (l = items; l != NULL; l = l->next) {
- GdlDockItem *item = GDL_DOCK_ITEM (l->data);
-
- if (g_slist_index (dockbar->_priv->items, item) != -1 &&
- !GDL_DOCK_ITEM_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_bar_add_item (dockbar, item);
- }
- } else {
- for (l = items; l != NULL; l = l->next) {
- GdlDockItem *item = GDL_DOCK_ITEM (l->data);
-
- if (g_slist_index (dockbar->_priv->items, item) != -1)
- gdl_dock_bar_remove_item (dockbar, item);
- if (GDL_DOCK_ITEM_ICONIFIED (item))
- gdl_dock_bar_add_item (dockbar, item);
- }
- }
- g_list_free (items);
-}
-
-static void
-gdl_dock_bar_layout_changed_cb (GdlDockMaster *master,
- GdlDockBar *dockbar)
-{
- update_dock_items (dockbar, FALSE);
-}
-
-static void
-gdl_dock_bar_attach (GdlDockBar *dockbar,
- GdlDockMaster *master)
-{
- g_return_if_fail (dockbar != NULL);
- g_return_if_fail (master == NULL || GDL_IS_DOCK_MASTER (master));
-
- if (dockbar->_priv->master) {
- g_signal_handlers_disconnect_matched (dockbar->_priv->master,
- G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, dockbar);
- g_object_unref (dockbar->_priv->master);
- }
-
- dockbar->_priv->master = master;
- if (dockbar->_priv->master) {
- g_object_ref (dockbar->_priv->master);
- g_signal_connect (dockbar->_priv->master, "layout-changed",
- G_CALLBACK (gdl_dock_bar_layout_changed_cb),
- dockbar);
- }
-
- update_dock_items (dockbar, FALSE);
-}
-
-static void gdl_dock_bar_size_request (GtkWidget *widget,
- GtkRequisition *requisition )
-{
- GdlDockBar *dockbar;
-
- dockbar = GDL_DOCK_BAR (widget);
-
- /* default to vertical for unknown values */
- switch (dockbar->_priv->orientation) {
- case GTK_ORIENTATION_HORIZONTAL:
- gdl_dock_bar_size_hrequest (widget, requisition);
- break;
- case GTK_ORIENTATION_VERTICAL:
- default:
- gdl_dock_bar_size_vrequest (widget, requisition);
- break;
- }
-}
-
-static void gdl_dock_bar_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation )
-{
- GdlDockBar *dockbar;
-
- dockbar = GDL_DOCK_BAR (widget);
-
- /* default to vertical for unknown values */
- switch (dockbar->_priv->orientation) {
- case GTK_ORIENTATION_HORIZONTAL:
- gdl_dock_bar_size_hallocate (widget, allocation);
- break;
- case GTK_ORIENTATION_VERTICAL:
- default:
- gdl_dock_bar_size_vallocate (widget, allocation);
- break;
- }
-}
-
-static void gdl_dock_bar_size_vrequest (GtkWidget *widget,
- GtkRequisition *requisition )
-{
- GtkBox *box;
- GtkRequisition child_requisition;
- GList *child;
- gint nvis_children;
- gint height;
- guint border_width;
-
- box = GTK_BOX (widget);
- requisition->width = 0;
- requisition->height = 0;
- nvis_children = 0;
-
-
- for (child = gtk_container_get_children (GTK_CONTAINER (box));
- child != NULL; child = g_list_next (child))
- {
- if (gtk_widget_get_visible (GTK_WIDGET (child->data)))
- {
- guint padding;
- gboolean expand;
- gboolean fill;
- GtkPackType pack_type;
-
- gtk_widget_size_request (GTK_WIDGET (child->data), &child_requisition);
-
- gtk_box_query_child_packing (box,
- child->data,
- &expand,
- &fill,
- &padding,
- &pack_type);
-
- if (gtk_box_get_homogeneous (box))
- {
- height = child_requisition.height + padding * 2;
- requisition->height = MAX (requisition->height, height);
- }
- else
- {
- requisition->height += child_requisition.height + padding * 2;
- }
-
- requisition->width = MAX (requisition->width, child_requisition.width);
-
- nvis_children += 1;
- }
- }
-
- if (nvis_children > 0)
- {
- if (gtk_box_get_homogeneous (box))
- requisition->height *= nvis_children;
- requisition->height += (nvis_children - 1) * gtk_box_get_spacing (box);
- }
-
- border_width = gtk_container_get_border_width (GTK_CONTAINER (box));
- requisition->width += border_width * 2;
- requisition->height += border_width * 2;
-
-}
-
-static void gdl_dock_bar_size_vallocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- GtkBox *box;
- GList *child;
- GtkAllocation child_allocation;
- gint nvis_children;
- gint nexpand_children;
- gint child_height;
- gint height;
- gint extra;
- gint y;
- guint border_width;
- GtkRequisition requisition;
-
- box = GTK_BOX (widget);
- gtk_widget_set_allocation (widget, allocation);
-
- gtk_widget_get_requisition (widget, &requisition);
-
- nvis_children = 0;
- nexpand_children = 0;
-
- for (child = gtk_container_get_children (GTK_CONTAINER (box));
- child != NULL; child = g_list_next (child))
- {
- guint padding;
- gboolean expand;
- gboolean fill;
- GtkPackType pack_type;
-
- gtk_box_query_child_packing (box,
- child->data,
- &expand,
- &fill,
- &padding,
- &pack_type);
- if (gtk_widget_get_visible (GTK_WIDGET(child->data)))
- {
- nvis_children += 1;
- if (expand)
- nexpand_children += 1;
- }
- }
-
- border_width = gtk_container_get_border_width (GTK_CONTAINER (box));
-
- if (nvis_children > 0)
- {
- if (gtk_box_get_homogeneous (box))
- {
- height = (allocation->height -
- border_width * 2 -
- (nvis_children - 1) * gtk_box_get_spacing (box));
- extra = height / nvis_children;
- }
- else if (nexpand_children > 0)
- {
- height = (gint) allocation->height - (gint) requisition.height;
- extra = height / nexpand_children;
- }
- else
- {
- height = 0;
- extra = 0;
- }
-
- y = allocation->y + border_width;
- child_allocation.x = allocation->x + border_width;
- child_allocation.width = MAX (1, (gint) allocation->width - (gint) border_width * 2);
-
- for (child = gtk_container_get_children (GTK_CONTAINER (box));
- child != NULL; child = g_list_next (child))
- {
- guint padding;
- gboolean expand;
- gboolean fill;
- GtkPackType pack_type;
-
- gtk_box_query_child_packing (box,
- child->data,
- &expand,
- &fill,
- &padding,
- &pack_type);
-
- if ((pack_type == GTK_PACK_START) && gtk_widget_get_visible (GTK_WIDGET (child->data)))
- {
- if (gtk_box_get_homogeneous (box))
- {
- if (nvis_children == 1)
- child_height = height;
- else
- child_height = extra;
-
- nvis_children -= 1;
- height -= extra;
- }
- else
- {
- GtkRequisition child_requisition;
-
- gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition);
- child_height = child_requisition.height + padding * 2;
-
- if (expand)
- {
- if (nexpand_children == 1)
- child_height += height;
- else
- child_height += extra;
-
- nexpand_children -= 1;
- height -= extra;
- }
- }
-
- if (fill)
- {
- child_allocation.height = MAX (1, child_height - padding * 2);
- child_allocation.y = y + padding;
- }
- else
- {
- GtkRequisition child_requisition;
-
- gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition);
- child_allocation.height = child_requisition.height;
- child_allocation.y = y + (child_height - child_allocation.height) / 2;
- }
-
- gtk_widget_size_allocate (GTK_WIDGET (child->data), &child_allocation);
-
- y += child_height + gtk_box_get_spacing (box);
- }
- }
-
- y = allocation->y + allocation->height - border_width;
-
- for (child = gtk_container_get_children (GTK_CONTAINER (box));
- child != NULL; child = g_list_next (child))
- {
- guint padding;
- gboolean expand;
- gboolean fill;
- GtkPackType pack_type;
-
- gtk_box_query_child_packing (box,
- child->data,
- &expand,
- &fill,
- &padding,
- &pack_type);
-
- if ((pack_type == GTK_PACK_END) && gtk_widget_get_visible (GTK_WIDGET (child->data)))
- {
- GtkRequisition child_requisition;
- gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition);
-
- if (gtk_box_get_homogeneous (box))
- {
- if (nvis_children == 1)
- child_height = height;
- else
- child_height = extra;
-
- nvis_children -= 1;
- height -= extra;
- }
- else
- {
- child_height = child_requisition.height + padding * 2;
-
- if (expand)
- {
- if (nexpand_children == 1)
- child_height += height;
- else
- child_height += extra;
-
- nexpand_children -= 1;
- height -= extra;
- }
- }
-
- if (fill)
- {
- child_allocation.height = MAX (1, child_height - padding * 2);
- child_allocation.y = y + padding - child_height;
- }
- else
- {
- child_allocation.height = child_requisition.height;
- child_allocation.y = y + (child_height - child_allocation.height) / 2 - child_height;
- }
-
- gtk_widget_size_allocate (GTK_WIDGET (child->data), &child_allocation);
-
- y -= (child_height + gtk_box_get_spacing (box));
- }
- }
- }
-}
-
-static void gdl_dock_bar_size_hrequest (GtkWidget *widget,
- GtkRequisition *requisition )
-{
- GtkBox *box;
- GList *child;
- gint nvis_children;
- gint width;
- guint border_width;
-
- box = GTK_BOX (widget);
- requisition->width = 0;
- requisition->height = 0;
- nvis_children = 0;
-
- for (child = gtk_container_get_children (GTK_CONTAINER (box));
- child != NULL; child = g_list_next (child))
- {
- guint padding;
- gboolean expand;
- gboolean fill;
- GtkPackType pack_type;
-
- gtk_box_query_child_packing (box,
- child->data,
- &expand,
- &fill,
- &padding,
- &pack_type);
-
-
- if (gtk_widget_get_visible (GTK_WIDGET (child->data)))
- {
- GtkRequisition child_requisition;
-
- gtk_widget_size_request (GTK_WIDGET (child->data), &child_requisition);
-
- if (gtk_box_get_homogeneous (box))
- {
- width = child_requisition.width + padding * 2;
- requisition->width = MAX (requisition->width, width);
- }
- else
- {
- requisition->width += child_requisition.width + padding * 2;
- }
-
- requisition->height = MAX (requisition->height, child_requisition.height);
-
- nvis_children += 1;
- }
- }
-
- if (nvis_children > 0)
- {
- if (gtk_box_get_homogeneous (box))
- requisition->width *= nvis_children;
- requisition->width += (nvis_children - 1) * gtk_box_get_spacing (box);
- }
-
- border_width = gtk_container_get_border_width (GTK_CONTAINER (box));
- requisition->width += border_width * 2;
- requisition->height += border_width * 2;
-}
-
-static void gdl_dock_bar_size_hallocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- GtkBox *box;
- GList *child;
- GtkAllocation child_allocation;
- gint nvis_children;
- gint nexpand_children;
- gint child_width;
- gint width;
- gint extra;
- gint x;
- guint border_width;
- GtkTextDirection direction;
- GtkRequisition requisition;
-
- box = GTK_BOX (widget);
- gtk_widget_set_allocation (widget, allocation);
- gtk_widget_get_requisition (widget, &requisition);
-
- direction = gtk_widget_get_direction (widget);
-
- nvis_children = 0;
- nexpand_children = 0;
-
- for (child = gtk_container_get_children (GTK_CONTAINER (box));
- child != NULL; child = g_list_next (child))
- {
- guint padding;
- gboolean expand;
- gboolean fill;
- GtkPackType pack_type;
-
- gtk_box_query_child_packing (box,
- child->data,
- &expand,
- &fill,
- &padding,
- &pack_type);
-
- if (gtk_widget_get_visible (GTK_WIDGET (child->data)))
- {
- nvis_children += 1;
- if (expand)
- nexpand_children += 1;
- }
- }
-
- border_width = gtk_container_get_border_width (GTK_CONTAINER (box));
-
- if (nvis_children > 0)
- {
- if (gtk_box_get_homogeneous (box))
- {
- width = (allocation->width -
- border_width * 2 -
- (nvis_children - 1) * gtk_box_get_spacing (box));
- extra = width / nvis_children;
- }
- else if (nexpand_children > 0)
- {
- width = (gint) allocation->width - (gint) requisition.width;
- extra = width / nexpand_children;
- }
- else
- {
- width = 0;
- extra = 0;
- }
-
- x = allocation->x + border_width;
- child_allocation.y = allocation->y + border_width;
- child_allocation.height = MAX (1, (gint) allocation->height - (gint) border_width * 2);
-
- for (child = gtk_container_get_children (GTK_CONTAINER (box));
- child != NULL; child = g_list_next (child))
- {
- guint padding;
- gboolean expand;
- gboolean fill;
- GtkPackType pack_type;
-
- gtk_box_query_child_packing (box,
- child->data,
- &expand,
- &fill,
- &padding,
- &pack_type);
-
- if ((pack_type == GTK_PACK_START) && gtk_widget_get_visible (GTK_WIDGET (child->data)))
- {
- if (gtk_box_get_homogeneous (box))
- {
- if (nvis_children == 1)
- child_width = width;
- else
- child_width = extra;
-
- nvis_children -= 1;
- width -= extra;
- }
- else
- {
- GtkRequisition child_requisition;
-
- gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition);
-
- child_width = child_requisition.width + padding * 2;
-
- if (expand)
- {
- if (nexpand_children == 1)
- child_width += width;
- else
- child_width += extra;
-
- nexpand_children -= 1;
- width -= extra;
- }
- }
-
- if (fill)
- {
- child_allocation.width = MAX (1, child_width - padding * 2);
- child_allocation.x = x + padding;
- }
- else
- {
- GtkRequisition child_requisition;
-
- gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition);
- child_allocation.width = child_requisition.width;
- child_allocation.x = x + (child_width - child_allocation.width) / 2;
- }
-
- if (direction == GTK_TEXT_DIR_RTL)
- child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width;
-
- gtk_widget_size_allocate (GTK_WIDGET (child->data), &child_allocation);
-
- x += child_width + gtk_box_get_spacing (box);
- }
- }
-
- x = allocation->x + allocation->width - border_width;
-
- for (child = gtk_container_get_children (GTK_CONTAINER (box));
- child != NULL; child = g_list_next (child))
- {
- guint padding;
- gboolean expand;
- gboolean fill;
- GtkPackType pack_type;
-
- gtk_box_query_child_packing (box,
- child->data,
- &expand,
- &fill,
- &padding,
- &pack_type);
-
- if ((pack_type == GTK_PACK_END) && gtk_widget_get_visible (GTK_WIDGET (child->data)))
- {
- GtkRequisition child_requisition;
- gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition);
-
- if (gtk_box_get_homogeneous (box))
- {
- if (nvis_children == 1)
- child_width = width;
- else
- child_width = extra;
-
- nvis_children -= 1;
- width -= extra;
- }
- else
- {
- child_width = child_requisition.width + padding * 2;
-
- if (expand)
- {
- if (nexpand_children == 1)
- child_width += width;
- else
- child_width += extra;
-
- nexpand_children -= 1;
- width -= extra;
- }
- }
-
- if (fill)
- {
- child_allocation.width = MAX (1, child_width - padding * 2);
- child_allocation.x = x + padding - child_width;
- }
- else
- {
- child_allocation.width = child_requisition.width;
- child_allocation.x = x + (child_width - child_allocation.width) / 2 - child_width;
- }
-
- if (direction == GTK_TEXT_DIR_RTL)
- child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width;
-
- gtk_widget_size_allocate (GTK_WIDGET (child->data), &child_allocation);
-
- x -= (child_width + gtk_box_get_spacing (box));
- }
- }
- }
-}
-
-GtkWidget *
-gdl_dock_bar_new (GdlDock *dock)
-{
- GdlDockMaster *master = NULL;
-
- /* get the master of the given dock */
- if (dock)
- master = GDL_DOCK_OBJECT_GET_MASTER (dock);
-
- return g_object_new (GDL_TYPE_DOCK_BAR,
- "master", master, NULL);
-}
-
-GtkOrientation gdl_dock_bar_get_orientation (GdlDockBar *dockbar)
-{
- g_return_val_if_fail (GDL_IS_DOCK_BAR (dockbar),
- GTK_ORIENTATION_VERTICAL);
-
- return dockbar->_priv->orientation;
-}
-
-void gdl_dock_bar_set_orientation (GdlDockBar *dockbar,
- GtkOrientation orientation)
-{
- g_return_if_fail (GDL_IS_DOCK_BAR (dockbar));
-
- dockbar->_priv->orientation = orientation;
-
- gtk_widget_queue_resize (GTK_WIDGET (dockbar));
-}
-
-void gdl_dock_bar_set_style(GdlDockBar* dockbar,
- GdlDockBarStyle style)
-{
- g_object_set(G_OBJECT(dockbar), "dockbar-style", style, NULL);
-}
-
-GdlDockBarStyle gdl_dock_bar_get_style(GdlDockBar* dockbar)
-{
- GdlDockBarStyle style;
- g_object_get(G_OBJECT(dockbar), "dockbar-style", &style, NULL);
- return style;
-}
diff --git a/src/libgdl/gdl-dock-bar.h b/src/libgdl/gdl-dock-bar.h
deleted file mode 100644
index ca6da1d26..000000000
--- a/src/libgdl/gdl-dock-bar.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * This file is part of the GNOME Devtools Libraries.
- *
- * Copyright (C) 2003 Jeroen Zwartepoorte <jeroen@xs4all.nl>
- *
- * This library is free software; you can redistribute it and/or
- * 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
- */
-
-#ifndef __GDL_DOCK_BAR_H__
-#define __GDL_DOCK_BAR_H__
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-/* standard macros */
-#define GDL_TYPE_DOCK_BAR (gdl_dock_bar_get_type ())
-#define GDL_DOCK_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_BAR, GdlDockBar))
-#define GDL_DOCK_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_BAR, GdlDockBarClass))
-#define GDL_IS_DOCK_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_BAR))
-#define GDL_IS_DOCK_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_BAR))
-#define GDL_DOCK_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_BAR, GdlDockBarClass))
-
-/* data types & structures */
-typedef struct _GdlDockBar GdlDockBar;
-typedef struct _GdlDockBarClass GdlDockBarClass;
-typedef struct _GdlDockBarPrivate GdlDockBarPrivate;
-
-typedef enum {
- GDL_DOCK_BAR_ICONS,
- GDL_DOCK_BAR_TEXT,
- GDL_DOCK_BAR_BOTH,
- GDL_DOCK_BAR_AUTO
-} GdlDockBarStyle;
-
-struct _GdlDockBar {
- GtkBox parent;
-
- GdlDock *dock;
-
- GdlDockBarPrivate *_priv;
-};
-
-struct _GdlDockBarClass {
- GtkVBoxClass parent_class;
-};
-
-GType gdl_dock_bar_get_type (void);
-
-GtkWidget *gdl_dock_bar_new (GdlDock *dock);
-
-GtkOrientation gdl_dock_bar_get_orientation (GdlDockBar *dockbar);
-void gdl_dock_bar_set_orientation (GdlDockBar *dockbar,
- GtkOrientation orientation);
-void gdl_dock_bar_set_style (GdlDockBar *dockbar,
- GdlDockBarStyle style);
-GdlDockBarStyle gdl_dock_bar_get_style (GdlDockBar *dockbar);
-
-G_END_DECLS
-
-#endif /* __GDL_DOCK_BAR_H__ */
diff --git a/src/libgdl/gdl-dock-item-button-image.c b/src/libgdl/gdl-dock-item-button-image.c
deleted file mode 100644
index 77cfe5d6c..000000000
--- a/src/libgdl/gdl-dock-item-button-image.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * gdl-dock-item-button-image.c
- *
- * Author: Joel Holdsworth <joel@airwebreathe.org.uk>
- *
- * This library is free software; you can redistribute it and/or
- * 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.
- */
-
-#include "gdl-dock-item-button-image.h"
-
-#include <math.h>
-
-#define ICON_SIZE 12
-
-G_DEFINE_TYPE (GdlDockItemButtonImage,
- gdl_dock_item_button_image,
- GTK_TYPE_WIDGET);
-
-static gint
-gdl_dock_item_button_image_expose (GtkWidget *widget,
- GdkEventExpose *event)
-{
- GdlDockItemButtonImage *button_image;
- GtkStyle *style;
- GdkColor *color;
-
- g_return_val_if_fail (widget != NULL, 0);
- button_image = GDL_DOCK_ITEM_BUTTON_IMAGE (widget);
-
- cairo_t *cr = gdk_cairo_create (event->window);
- cairo_translate (cr, event->area.x, event->area.y);
-
- /* Set up the pen */
- cairo_set_line_width(cr, 1.0);
-
- style = gtk_widget_get_style (widget);
- g_return_val_if_fail (style != NULL, 0);
- color = &style->fg[GTK_STATE_NORMAL];
- cairo_set_source_rgba(cr, color->red / 65535.0,
- color->green / 65535.0, color->blue / 65535.0, 0.55);
-
- /* Draw the icon border */
- cairo_move_to (cr, 10.5, 2.5);
- cairo_arc (cr, 10.5, 4.5, 2, -0.5 * M_PI, 0);
- cairo_line_to (cr, 12.5, 10.5);
- cairo_arc (cr, 10.5, 10.5, 2, 0, 0.5 * M_PI);
- cairo_line_to (cr, 4.5, 12.5);
- cairo_arc (cr, 4.5, 10.5, 2, 0.5 * M_PI, M_PI);
- cairo_line_to (cr, 2.5, 4.5);
- cairo_arc (cr, 4.5, 4.5, 2, M_PI, 1.5 * M_PI);
- cairo_close_path (cr);
-
- cairo_stroke (cr);
-
- /* Draw the icon */
- cairo_new_path (cr);
-
- switch(button_image->image_type) {
- case GDL_DOCK_ITEM_BUTTON_IMAGE_CLOSE:
- cairo_move_to (cr, 4.0, 5.5);
- cairo_line_to (cr, 4.0, 5.5);
- cairo_line_to (cr, 6.0, 7.5);
- cairo_line_to (cr, 4.0, 9.5);
- cairo_line_to (cr, 5.5, 11.0);
- cairo_line_to (cr, 7.5, 9.0);
- cairo_line_to (cr, 9.5, 11.0);
- cairo_line_to (cr, 11.0, 9.5);
- cairo_line_to (cr, 9.0, 7.5);
- cairo_line_to (cr, 11.0, 5.5);
- cairo_line_to (cr, 9.5, 4.0);
- cairo_line_to (cr, 7.5, 6.0);
- cairo_line_to (cr, 5.5, 4.0);
- cairo_close_path (cr);
- break;
-
- case GDL_DOCK_ITEM_BUTTON_IMAGE_ICONIFY:
- if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) {
- cairo_move_to (cr, 4.5, 7.5);
- cairo_line_to (cr, 10.0, 4.75);
- cairo_line_to (cr, 10.0, 10.25);
- cairo_close_path (cr);
- } else {
- cairo_move_to (cr, 10.5, 7.5);
- cairo_line_to (cr, 5, 4.75);
- cairo_line_to (cr, 5, 10.25);
- cairo_close_path (cr);
- }
- break;
-
- default:
- break;
- }
-
- cairo_fill (cr);
-
- /* Finish up */
- cairo_destroy (cr);
-
- return 0;
-}
-
-static void
-gdl_dock_item_button_image_init (
- GdlDockItemButtonImage *button_image)
-{
- gtk_widget_set_has_window (GTK_WIDGET (button_image), FALSE);
-}
-
-static void
-gdl_dock_item_button_image_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- g_return_if_fail (GDL_IS_DOCK_ITEM_BUTTON_IMAGE (widget));
- g_return_if_fail (requisition != NULL);
-
- requisition->width = ICON_SIZE;
- requisition->height = ICON_SIZE;
-}
-
-static void
-gdl_dock_item_button_image_class_init (
- GdlDockItemButtonImageClass *klass)
-{
- //GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- //GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
- widget_class->expose_event =
- gdl_dock_item_button_image_expose;
- widget_class->size_request =
- gdl_dock_item_button_image_size_request;
-}
-
-/* ----- Public interface ----- */
-
-/**
- * gdl_dock_item_button_image_new:
- * @image_type: Specifies what type of image the widget should
- * display
- *
- * Creates a new GDL dock button image object.
- * Returns: The newly created dock item button image widget.
- **/
-GtkWidget*
-gdl_dock_item_button_image_new (GdlDockItemButtonImageType image_type)
-{
- GdlDockItemButtonImage *button_image = g_object_new (
- GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE, NULL);
- button_image->image_type = image_type;
-
- return GTK_WIDGET (button_image);
-}
diff --git a/src/libgdl/gdl-dock-item-button-image.h b/src/libgdl/gdl-dock-item-button-image.h
deleted file mode 100644
index ce0c6faaf..000000000
--- a/src/libgdl/gdl-dock-item-button-image.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * gdl-dock-item-button-image.h
- *
- * Author: Joel Holdsworth <joel@airwebreathe.org.uk>
- *
- * This library is free software; you can redistribute it and/or
- * 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.
- */
-
-#ifndef _GDL_DOCK_ITEM_BUTTON_IMAGE_H_
-#define _GDL_DOCK_ITEM_BUTTON_IMAGE_H_
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-/* Standard Macros */
-#define GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE \
- (gdl_dock_item_button_image_get_type())
-#define GDL_DOCK_ITEM_BUTTON_IMAGE(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE, GdlDockItemButtonImage))
-#define GDL_DOCK_ITEM_BUTTON_IMAGE_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE, GdlDockItemButtonImageClass))
-#define GDL_IS_DOCK_ITEM_BUTTON_IMAGE(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE))
-#define GDL_IS_DOCK_ITEM_BUTTON_IMAGE_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE))
-#define GDL_DOCK_ITEM_BUTTON_IMAGE_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE, GdlDockItemButtonImageClass))
-
-/* Data Types & Structures */
-typedef enum {
- GDL_DOCK_ITEM_BUTTON_IMAGE_CLOSE,
- GDL_DOCK_ITEM_BUTTON_IMAGE_ICONIFY
-} GdlDockItemButtonImageType;
-
-typedef struct _GdlDockItemButtonImage GdlDockItemButtonImage;
-typedef struct _GdlDockItemButtonImageClass GdlDockItemButtonImageClass;
-
-struct _GdlDockItemButtonImage {
- GtkWidget parent;
-
- GdlDockItemButtonImageType image_type;
-};
-
-struct _GdlDockItemButtonImageClass {
- GtkWidgetClass parent_class;
-};
-
-/* Data Public Functions */
-GType gdl_dock_item_button_image_get_type (void);
-GtkWidget *gdl_dock_item_button_image_new (
- GdlDockItemButtonImageType image_type);
-
-G_END_DECLS
-
-#endif /* _GDL_DOCK_ITEM_BUTTON_IMAGE_H_ */
diff --git a/src/libgdl/gdl-dock-item-grip.c b/src/libgdl/gdl-dock-item-grip.c
deleted file mode 100644
index 9b3810c20..000000000
--- a/src/libgdl/gdl-dock-item-grip.c
+++ /dev/null
@@ -1,809 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 8 -*- */
-/*
- * gdl-dock-item-grip.c
- *
- * Author: Michael Meeks Copyright (C) 2002 Sun Microsystems, Inc.
- *
- * Based on BonoboDockItemGrip. 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.
- *
- * This library is free software; you can redistribute it and/or
- * 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 <glib-object.h>
-#include <gtk/gtk.h>
-#include "gdl-dock-item.h"
-#include "gdl-dock-item-grip.h"
-#include "gdl-dock-item-button-image.h"
-#include "gdl-switcher.h"
-
-#define ALIGN_BORDER 5
-#define DRAG_HANDLE_SIZE 10
-
-enum {
- PROP_0,
- PROP_ITEM
-};
-
-struct _GdlDockItemGripPrivate {
- GtkWidget *label;
-
- GtkWidget *close_button;
- GtkWidget *iconify_button;
-
- gboolean handle_shown;
-};
-
-G_DEFINE_TYPE (GdlDockItemGrip, gdl_dock_item_grip, GTK_TYPE_CONTAINER);
-
-GtkWidget*
-gdl_dock_item_create_label_widget(GdlDockItemGrip *grip)
-{
- GtkHBox *label_box;
- GtkImage *image;
- GtkLabel *label;
- gchar *stock_id = NULL;
- gchar *title = NULL;
- GdkPixbuf *pixbuf;
-
- label_box = (GtkHBox*)gtk_hbox_new (FALSE, 0);
-
- g_object_get (G_OBJECT (grip->item), "stock-id", &stock_id, NULL);
- g_object_get (G_OBJECT (grip->item), "pixbuf-icon", &pixbuf, NULL);
- if(stock_id) {
- image = GTK_IMAGE(gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU));
-
- gtk_widget_show (GTK_WIDGET(image));
- gtk_box_pack_start(GTK_BOX(label_box), GTK_WIDGET(image), FALSE, TRUE, 0);
-
- g_free (stock_id);
- }
- else if (pixbuf) {
- image = GTK_IMAGE(gtk_image_new_from_pixbuf (pixbuf));
-
- gtk_widget_show (GTK_WIDGET(image));
- gtk_box_pack_start(GTK_BOX(label_box), GTK_WIDGET(image), FALSE, TRUE, 0);
- }
-
- g_object_get (G_OBJECT (grip->item), "long-name", &title, NULL);
- if (title) {
- label = GTK_LABEL(gtk_label_new(title));
- gtk_label_set_ellipsize(label, PANGO_ELLIPSIZE_END);
- gtk_label_set_justify(label, GTK_JUSTIFY_LEFT);
- gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
- gtk_widget_show (GTK_WIDGET(label));
-
- if (gtk_widget_get_direction (GTK_WIDGET(grip)) == GTK_TEXT_DIR_RTL) {
- gtk_box_pack_end(GTK_BOX(label_box), GTK_WIDGET(label), TRUE, TRUE, 1);
- } else {
- gtk_box_pack_start(GTK_BOX(label_box), GTK_WIDGET(label), TRUE, TRUE, 1);
- }
-
- g_free(title);
- }
-
- return GTK_WIDGET(label_box);
-}
-
-static gint
-gdl_dock_item_grip_expose (GtkWidget *widget,
- GdkEventExpose *event)
-{
- GdlDockItemGrip *grip;
- GtkAllocation allocation;
- GdkRectangle handle_area;
- GdkRectangle expose_area;
-
- grip = GDL_DOCK_ITEM_GRIP (widget);
-
- if(grip->_priv->handle_shown) {
-
- gtk_widget_get_allocation (widget, &allocation);
-
- if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) {
- handle_area.x = allocation.x;
- handle_area.y = allocation.y;
- handle_area.width = DRAG_HANDLE_SIZE;
- handle_area.height = allocation.height;
- } else {
- handle_area.x = allocation.x + allocation.width - DRAG_HANDLE_SIZE;
- handle_area.y = allocation.y;
- handle_area.width = DRAG_HANDLE_SIZE;
- handle_area.height = allocation.height;
- }
-
- if (gdk_rectangle_intersect (&handle_area, &event->area, &expose_area)) {
-
- gtk_paint_handle (gtk_widget_get_style (widget),
- gtk_widget_get_window (widget),
- gtk_widget_get_state (widget),
- GTK_SHADOW_NONE, &expose_area, widget,
- "handlebox", handle_area.x, handle_area.y,
- handle_area.width, handle_area.height,
- GTK_ORIENTATION_VERTICAL);
-
- }
-
- }
-
-/* see bug #950556: may contribute to regression with GTK2/Quartz */
-#if !defined(GDK_WINDOWING_QUARTZ)
- if (gdl_dock_item_or_child_has_focus(grip->item)) {
-
- gtk_paint_focus (gtk_widget_get_style (widget),
- gtk_widget_get_window (widget),
- gtk_widget_get_state (widget),
- &event->area, widget,
- NULL, 0, 0, -1, -1);
- }
-#endif //GDK_WINDOWING_QUARTZ
-
- return GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->expose_event (widget, event);
-}
-
-static void
-gdl_dock_item_grip_item_notify (GObject *master,
- GParamSpec *pspec,
- gpointer data)
-{
- GdlDockItemGrip *grip;
- gboolean cursor;
-
- grip = GDL_DOCK_ITEM_GRIP (data);
-
- if ((strcmp (pspec->name, "stock-id") == 0) ||
- (strcmp (pspec->name, "long-name") == 0)) {
-
- gdl_dock_item_grip_set_label (grip,
- gdl_dock_item_create_label_widget(grip));
-
- } else if (strcmp (pspec->name, "behavior") == 0) {
- cursor = FALSE;
- if (grip->_priv->close_button) {
- if (GDL_DOCK_ITEM_CANT_CLOSE (grip->item)) {
- gtk_widget_hide (GTK_WIDGET (grip->_priv->close_button));
- } else {
- gtk_widget_show (GTK_WIDGET (grip->_priv->close_button));
- cursor = TRUE;
- }
- }
- if (grip->_priv->iconify_button) {
- if (GDL_DOCK_ITEM_CANT_ICONIFY (grip->item)) {
- gtk_widget_hide (GTK_WIDGET (grip->_priv->iconify_button));
- } else {
- gtk_widget_show (GTK_WIDGET (grip->_priv->iconify_button));
- cursor = TRUE;
- }
- }
- if (grip->title_window && !cursor)
- gdk_window_set_cursor (grip->title_window, NULL);
-
- }
-}
-
-static void
-gdl_dock_item_grip_destroy (GtkObject *object)
-{
- GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP (object);
-
- if (grip->_priv) {
- GdlDockItemGripPrivate *priv = grip->_priv;
-
- if (priv->label) {
- gtk_widget_unparent(grip->_priv->label);
- priv->label = NULL;
- }
-
- if (grip->item)
- g_signal_handlers_disconnect_by_func (grip->item,
- gdl_dock_item_grip_item_notify,
- grip);
- grip->item = NULL;
-
- grip->_priv = NULL;
- g_free (priv);
- }
-
- GTK_OBJECT_CLASS (gdl_dock_item_grip_parent_class)->destroy (object);
-}
-
-static void
-gdl_dock_item_grip_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GdlDockItemGrip *grip;
-
- g_return_if_fail (GDL_IS_DOCK_ITEM_GRIP (object));
-
- grip = GDL_DOCK_ITEM_GRIP (object);
-
- switch (prop_id) {
- case PROP_ITEM:
- grip->item = g_value_get_object (value);
- if (grip->item) {
- g_signal_connect (grip->item, "notify::long-name",
- G_CALLBACK (gdl_dock_item_grip_item_notify),
- grip);
- g_signal_connect (grip->item, "notify::stock-id",
- G_CALLBACK (gdl_dock_item_grip_item_notify),
- grip);
- g_signal_connect (grip->item, "notify::behavior",
- G_CALLBACK (gdl_dock_item_grip_item_notify),
- grip);
-
- if (!GDL_DOCK_ITEM_CANT_CLOSE (grip->item) && grip->_priv->close_button)
- gtk_widget_show (grip->_priv->close_button);
- if (!GDL_DOCK_ITEM_CANT_ICONIFY (grip->item) && grip->_priv->iconify_button)
- gtk_widget_show (grip->_priv->iconify_button);
- }
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gdl_dock_item_grip_close_clicked (GtkWidget *widget,
- GdlDockItemGrip *grip)
-{
- (void)widget;
- g_return_if_fail (grip->item != NULL);
-
- gdl_dock_item_hide_item (grip->item);
-}
-
-static void
-gdl_dock_item_grip_fix_iconify_button (GdlDockItemGrip *grip)
-{
- GtkWidget *iconify_button = grip->_priv->iconify_button;
- GdkWindow *window = NULL;
- GdkEvent *event = NULL;
-
- GdkModifierType modifiers;
- gint x = 0, y = 0;
- gboolean ev_ret;
-
- g_return_if_fail (gtk_widget_get_realized (iconify_button));
-
- window = gtk_widget_get_parent_window (iconify_button);
- event = gdk_event_new (GDK_LEAVE_NOTIFY);
-
- g_assert (GDK_IS_WINDOW (window));
- gdk_window_get_pointer (window, &x, &y, &modifiers);
-
- event->crossing.window = g_object_ref (window);
- event->crossing.send_event = FALSE;
- event->crossing.subwindow = g_object_ref (window);
- event->crossing.time = GDK_CURRENT_TIME;
- event->crossing.x = x;
- event->crossing.y = y;
- event->crossing.x_root = event->crossing.y_root = 0;
- event->crossing.mode = GDK_CROSSING_STATE_CHANGED;
- event->crossing.detail = GDK_NOTIFY_NONLINEAR;
- event->crossing.focus = FALSE;
- event->crossing.state = modifiers;
-
- //GTK_BUTTON (iconify_button)->in_button = FALSE;
- g_signal_emit_by_name (iconify_button, "leave-notify-event",
- event, &ev_ret, 0);
-
- gdk_event_free (event);
-}
-
-static void
-gdl_dock_item_grip_iconify_clicked (GtkWidget *widget,
- GdlDockItemGrip *grip)
-{
- GtkWidget *parent;
-
- g_return_if_fail (grip->item != NULL);
-
- /* Workaround to unhighlight the iconify button. */
- gdl_dock_item_grip_fix_iconify_button (grip);
-
- parent = gtk_widget_get_parent (GTK_WIDGET (grip->item));
- if (GDL_IS_SWITCHER (parent))
- {
- /* Note: We can not use gtk_container_foreach (parent) here because
- * during iconificatoin, the internal children changes in parent.
- * Instead we keep a list of items to iconify and iconify them
- * one by one.
- */
- GList *node;
- GList *items =
- gtk_container_get_children (GTK_CONTAINER (parent));
- for (node = items; node != NULL; node = node->next)
- {
- GdlDockItem *item = GDL_DOCK_ITEM (node->data);
- if (!GDL_DOCK_ITEM_CANT_ICONIFY (item))
- gdl_dock_item_iconify_item (item);
- }
- g_list_free (items);
- }
- else
- {
- gdl_dock_item_iconify_item (grip->item);
- }
-}
-
-static void
-gdl_dock_item_grip_init (GdlDockItemGrip *grip)
-{
- GtkWidget *image;
-
- gtk_widget_set_has_window (GTK_WIDGET (grip), FALSE);
-
- grip->_priv = g_new0 (GdlDockItemGripPrivate, 1);
- grip->_priv->label = NULL;
- grip->_priv->handle_shown = FALSE;
-
- /* create the close button */
- gtk_widget_push_composite_child ();
- grip->_priv->close_button = gtk_button_new ();
- gtk_widget_pop_composite_child ();
-
- gtk_widget_set_can_focus (grip->_priv->close_button, FALSE);
- gtk_widget_set_parent (grip->_priv->close_button, GTK_WIDGET (grip));
- gtk_button_set_relief (GTK_BUTTON (grip->_priv->close_button), GTK_RELIEF_NONE);
- gtk_widget_show (grip->_priv->close_button);
-
- image = gdl_dock_item_button_image_new(GDL_DOCK_ITEM_BUTTON_IMAGE_CLOSE);
- gtk_container_add (GTK_CONTAINER (grip->_priv->close_button), image);
- gtk_widget_show (image);
-
- g_signal_connect (G_OBJECT (grip->_priv->close_button), "clicked",
- G_CALLBACK (gdl_dock_item_grip_close_clicked), grip);
-
- /* create the iconify button */
- gtk_widget_push_composite_child ();
- grip->_priv->iconify_button = gtk_button_new ();
- gtk_widget_pop_composite_child ();
-
- gtk_widget_set_can_focus (grip->_priv->iconify_button, FALSE);
- gtk_widget_set_parent (grip->_priv->iconify_button, GTK_WIDGET (grip));
- gtk_button_set_relief (GTK_BUTTON (grip->_priv->iconify_button), GTK_RELIEF_NONE);
- gtk_widget_show (grip->_priv->iconify_button);
-
- image = gdl_dock_item_button_image_new(GDL_DOCK_ITEM_BUTTON_IMAGE_ICONIFY);
- gtk_container_add (GTK_CONTAINER (grip->_priv->iconify_button), image);
- gtk_widget_show (image);
-
- g_signal_connect (G_OBJECT (grip->_priv->iconify_button), "clicked",
- G_CALLBACK (gdl_dock_item_grip_iconify_clicked), grip);
-
- /* set tooltips on the buttons */
- gtk_widget_set_tooltip_text (grip->_priv->iconify_button,
- _("Iconify this dock"));
- gtk_widget_set_tooltip_text (grip->_priv->close_button,
- _("Close this dock"));
-}
-
-static void
-gdl_dock_item_grip_realize (GtkWidget *widget)
-{
- GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP (widget);
-
- GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->realize (widget);
-
- g_return_if_fail (grip->_priv != NULL);
-
- if (!grip->title_window) {
- GtkAllocation allocation;
- GdkWindowAttr attributes;
- GdkCursor *cursor;
-
- g_return_if_fail (grip->_priv->label != NULL);
-
- gtk_widget_get_allocation (grip->_priv->label, &allocation);
-
- attributes.x = allocation.x;
- attributes.y = allocation.y;
- attributes.width = allocation.width;
- attributes.height = allocation.height;
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.event_mask = GDK_ALL_EVENTS_MASK;
-
- grip->title_window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, (GDK_WA_X | GDK_WA_Y));
-
- gdk_window_set_user_data (grip->title_window, grip);
-
- /* Unref the ref from parent realize for NO_WINDOW */
- g_object_unref (gtk_widget_get_window (widget));
-
- /* Need to ref widget->window, because parent unrealize unrefs it */
- gtk_widget_set_window (widget, g_object_ref (grip->title_window));
- gtk_widget_set_has_window (widget, TRUE);
-
- /* Unset the background so as to make the colour match the parent window */
- gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, NULL);
-
- if (GDL_DOCK_ITEM_CANT_CLOSE (grip->item) &&
- GDL_DOCK_ITEM_CANT_ICONIFY (grip->item))
- cursor = NULL;
- else
- cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
- GDK_HAND2);
- gdk_window_set_cursor (grip->title_window, cursor);
- if (cursor)
- gdk_cursor_unref (cursor);
- }
-}
-
-static void
-gdl_dock_item_grip_unrealize (GtkWidget *widget)
-{
- GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP (widget);
-
- if (grip->title_window) {
- gtk_widget_set_has_window (widget, FALSE);
- gdk_window_set_user_data (grip->title_window, NULL);
- gdk_window_destroy (grip->title_window);
- grip->title_window = NULL;
- }
-
- GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->unrealize (widget);
-}
-
-static void
-gdl_dock_item_grip_map (GtkWidget *widget)
-{
- GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP (widget);
-
- GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->map (widget);
-
- if (grip->title_window)
- gdk_window_show (grip->title_window);
-}
-
-static void
-gdl_dock_item_grip_unmap (GtkWidget *widget)
-{
- GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP (widget);
-
- if (grip->title_window)
- gdk_window_hide (grip->title_window);
-
- GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->unmap (widget);
-}
-
-static void
-gdl_dock_item_grip_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- GtkRequisition child_requisition;
- GdlDockItemGrip *grip;
- gint layout_height = 0;
- guint border_width;
-
- g_return_if_fail (GDL_IS_DOCK_ITEM_GRIP (widget));
- g_return_if_fail (requisition != NULL);
-
- border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- grip = GDL_DOCK_ITEM_GRIP (widget);
-
- requisition->width = border_width * 2/* + ALIGN_BORDER*/;
- requisition->height = border_width * 2;
-
- if(grip->_priv->handle_shown)
- requisition->width += DRAG_HANDLE_SIZE;
-
- gtk_widget_size_request (grip->_priv->close_button, &child_requisition);
- layout_height = MAX (layout_height, child_requisition.height);
- if (gtk_widget_get_visible (grip->_priv->close_button)) {
- requisition->width += child_requisition.width;
- }
-
- gtk_widget_size_request (grip->_priv->iconify_button, &child_requisition);
- layout_height = MAX (layout_height, child_requisition.height);
- if (gtk_widget_get_visible (grip->_priv->iconify_button)) {
- requisition->width += child_requisition.width;
- }
-
- gtk_widget_size_request (grip->_priv->label, &child_requisition);
- requisition->width += child_requisition.width;
- layout_height = MAX (layout_height, child_requisition.height);
-
- requisition->height += layout_height;
-}
-
-static void
-gdl_dock_item_grip_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- GdlDockItemGrip *grip;
- GtkRequisition close_requisition = { 0, 0 };
- GtkRequisition iconify_requisition = { 0, 0 };
- GtkAllocation child_allocation;
- guint border_width;
-
- g_return_if_fail (GDL_IS_DOCK_ITEM_GRIP (widget));
- g_return_if_fail (allocation != NULL);
-
- grip = GDL_DOCK_ITEM_GRIP (widget);
- border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
-
- GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->size_allocate (widget, allocation);
-
- gtk_widget_size_request (grip->_priv->close_button,
- &close_requisition);
- gtk_widget_size_request (grip->_priv->iconify_button,
- &iconify_requisition);
-
- /* Calculate the Minimum Width where buttons will fit */
- int min_width = close_requisition.width + iconify_requisition.width
- + border_width * 2;
- if(grip->_priv->handle_shown)
- min_width += DRAG_HANDLE_SIZE;
- const gboolean space_for_buttons = (allocation->width >= min_width);
-
- /* Set up the rolling child_allocation rectangle */
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- child_allocation.x = border_width/* + ALIGN_BORDER*/;
- else
- child_allocation.x = allocation->width - border_width;
- child_allocation.y = border_width;
-
- /* Layout Close Button */
- if (gtk_widget_get_visible (grip->_priv->close_button)) {
-
- if(space_for_buttons) {
- if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL)
- child_allocation.x -= close_requisition.width;
-
- child_allocation.width = close_requisition.width;
- child_allocation.height = close_requisition.height;
- } else {
- child_allocation.width = 0;
- }
-
- gtk_widget_size_allocate (grip->_priv->close_button, &child_allocation);
-
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- child_allocation.x += close_requisition.width;
- }
-
- /* Layout Iconify Button */
- if (gtk_widget_get_visible (grip->_priv->iconify_button)) {
-
- if(space_for_buttons) {
- if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL)
- child_allocation.x -= iconify_requisition.width;
-
- child_allocation.width = iconify_requisition.width;
- child_allocation.height = iconify_requisition.height;
- } else {
- child_allocation.width = 0;
- }
-
- gtk_widget_size_allocate (grip->_priv->iconify_button, &child_allocation);
-
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- child_allocation.x += iconify_requisition.width;
- }
-
- /* Layout the Grip Handle*/
- if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) {
- child_allocation.width = child_allocation.x;
- child_allocation.x = border_width/* + ALIGN_BORDER*/;
-
- if(grip->_priv->handle_shown) {
- child_allocation.x += DRAG_HANDLE_SIZE;
- child_allocation.width -= DRAG_HANDLE_SIZE;
- }
-
- } else {
- child_allocation.width = allocation->width -
- (child_allocation.x - allocation->x)/* - ALIGN_BORDER*/;
-
- if(grip->_priv->handle_shown)
- child_allocation.width -= DRAG_HANDLE_SIZE;
- }
-
- if(child_allocation.width < 0)
- child_allocation.width = 0;
-
- child_allocation.y = border_width;
- child_allocation.height = allocation->height - border_width * 2;
- if(grip->_priv->label) {
- gtk_widget_size_allocate (grip->_priv->label, &child_allocation);
- }
-
- if (grip->title_window) {
- gdk_window_move_resize (grip->title_window,
- allocation->x,
- allocation->y,
- allocation->width,
- allocation->height);
- }
-}
-
-static void
-gdl_dock_item_grip_add (GtkContainer *container,
- GtkWidget *widget)
-{
- g_warning ("gtk_container_add not implemented for GdlDockItemGrip");
-}
-
-static void
-gdl_dock_item_grip_remove (GtkContainer *container,
- GtkWidget *widget)
-{
- gdl_dock_item_grip_set_label (GDL_DOCK_ITEM_GRIP (container), NULL);
-}
-
-static void
-gdl_dock_item_grip_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data)
-{
- GdlDockItemGrip *grip;
-
- g_return_if_fail (GDL_IS_DOCK_ITEM_GRIP (container));
- grip = GDL_DOCK_ITEM_GRIP (container);
-
- if (grip->_priv) {
- if(grip->_priv->label) {
- (* callback) (grip->_priv->label, callback_data);
- }
-
- if (include_internals) {
- (* callback) (grip->_priv->close_button, callback_data);
- (* callback) (grip->_priv->iconify_button, callback_data);
- }
- }
-}
-
-static GType
-gdl_dock_item_grip_child_type (GtkContainer *container)
-{
- return G_TYPE_NONE;
-}
-
-static void
-gdl_dock_item_grip_class_init (GdlDockItemGripClass *klass)
-{
- GObjectClass *gobject_class;
- GtkObjectClass *gtk_object_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
-
- gobject_class = G_OBJECT_CLASS (klass);
- gtk_object_class = GTK_OBJECT_CLASS (klass);
- widget_class = GTK_WIDGET_CLASS (klass);
- container_class = GTK_CONTAINER_CLASS (klass);
-
- gobject_class->set_property = gdl_dock_item_grip_set_property;
-
- gtk_object_class->destroy = gdl_dock_item_grip_destroy;
-
- widget_class->expose_event = gdl_dock_item_grip_expose;
- widget_class->realize = gdl_dock_item_grip_realize;
- widget_class->unrealize = gdl_dock_item_grip_unrealize;
- widget_class->map = gdl_dock_item_grip_map;
- widget_class->unmap = gdl_dock_item_grip_unmap;
- widget_class->size_request = gdl_dock_item_grip_size_request;
- widget_class->size_allocate = gdl_dock_item_grip_size_allocate;
-
- container_class->add = gdl_dock_item_grip_add;
- container_class->remove = gdl_dock_item_grip_remove;
- container_class->forall = gdl_dock_item_grip_forall;
- container_class->child_type = gdl_dock_item_grip_child_type;
-
- g_object_class_install_property (
- gobject_class, PROP_ITEM,
- g_param_spec_object ("item", _("Controlling dock item"),
- _("Dockitem which 'owns' this grip"),
- GDL_TYPE_DOCK_ITEM,
- G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
-}
-
-static void
-gdl_dock_item_grip_showhide_handle (GdlDockItemGrip *grip)
-{
- gtk_widget_queue_resize (GTK_WIDGET (grip));
-}
-
-/* ----- Public interface ----- */
-
-/**
- * gdl_dock_item_grip_new:
- * @item: The dock item that will "own" this grip widget.
- *
- * Creates a new GDL dock item grip object.
- * Returns: The newly created dock item grip widget.
- **/
-GtkWidget *
-gdl_dock_item_grip_new (GdlDockItem *item)
-{
- GdlDockItemGrip *grip = g_object_new (GDL_TYPE_DOCK_ITEM_GRIP, "item", item,
- NULL);
-
- return GTK_WIDGET (grip);
-}
-
-/**
- * gdl_dock_item_grip_set_label:
- * @grip: The grip that will get it's label widget set.
- * @label: The widget that will become the label.
- *
- * Replaces the current label widget with another widget.
- **/
-void
-gdl_dock_item_grip_set_label (GdlDockItemGrip *grip,
- GtkWidget *label)
-{
- g_return_if_fail (grip != NULL);
-
- if (grip->_priv->label) {
- gtk_widget_unparent(grip->_priv->label);
- g_object_unref (grip->_priv->label);
- grip->_priv->label = NULL;
- }
-
- if (label) {
- g_object_ref (label);
- gtk_widget_set_parent (label, GTK_WIDGET (grip));
- gtk_widget_show (label);
- grip->_priv->label = label;
- }
-}
-/**
- * gdl_dock_item_grip_hide_handle:
- * @grip: The dock item grip to hide the handle of.
- *
- * This function hides the dock item's grip widget handle hatching.
- **/
-void
-gdl_dock_item_grip_hide_handle (GdlDockItemGrip *grip)
-{
- g_return_if_fail (grip != NULL);
- if (grip->_priv->handle_shown) {
- grip->_priv->handle_shown = FALSE;
- gdl_dock_item_grip_showhide_handle (grip);
- };
-}
-
-/**
- * gdl_dock_item_grip_show_handle:
- * @grip: The dock item grip to show the handle of.
- *
- * This function shows the dock item's grip widget handle hatching.
- **/
-void
-gdl_dock_item_grip_show_handle (GdlDockItemGrip *grip)
-{
- g_return_if_fail (grip != NULL);
- if (!grip->_priv->handle_shown) {
- grip->_priv->handle_shown = TRUE;
- gdl_dock_item_grip_showhide_handle (grip);
- };
-}
diff --git a/src/libgdl/gdl-dock-item-grip.h b/src/libgdl/gdl-dock-item-grip.h
deleted file mode 100644
index a44ef91fb..000000000
--- a/src/libgdl/gdl-dock-item-grip.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 8 -*- */
-/*
- * gdl-dock-item-grip.h
- *
- * Author: Michael Meeks Copyright (C) 2002 Sun Microsystems, Inc.
- *
- * Based on BonoboDockItemGrip. 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.
- *
- * This library is free software; you can redistribute it and/or
- * 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.
- */
-
-#ifndef _GDL_DOCK_ITEM_GRIP_H_
-#define _GDL_DOCK_ITEM_GRIP_H_
-
-#include <gtk/gtk.h>
-#include "libgdl/gdl-dock-item.h"
-
-G_BEGIN_DECLS
-
-#define GDL_TYPE_DOCK_ITEM_GRIP (gdl_dock_item_grip_get_type())
-#define GDL_DOCK_ITEM_GRIP(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_ITEM_GRIP, GdlDockItemGrip))
-#define GDL_DOCK_ITEM_GRIP_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_ITEM_GRIP, GdlDockItemGripClass))
-#define GDL_IS_DOCK_ITEM_GRIP(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_ITEM_GRIP))
-#define GDL_IS_DOCK_ITEM_GRIP_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_ITEM_GRIP))
-#define GDL_DOCK_ITEM_GRIP_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), GDL_TYPE_DOCK_ITEM_GRIP, GdlDockItemGripClass))
-
-typedef struct _GdlDockItemGrip GdlDockItemGrip;
-typedef struct _GdlDockItemGripClass GdlDockItemGripClass;
-typedef struct _GdlDockItemGripPrivate GdlDockItemGripPrivate;
-
-struct _GdlDockItemGrip {
- GtkContainer parent;
-
- GdlDockItem *item;
-
- GdkWindow *title_window;
-
- GdlDockItemGripPrivate *_priv;
-};
-
-struct _GdlDockItemGripClass {
- GtkContainerClass parent_class;
-};
-
-GType gdl_dock_item_grip_get_type (void);
-GtkWidget *gdl_dock_item_grip_new (GdlDockItem *item);
-void gdl_dock_item_grip_set_label (GdlDockItemGrip *grip,
- GtkWidget *label);
-void gdl_dock_item_grip_hide_handle (GdlDockItemGrip *grip);
-void gdl_dock_item_grip_show_handle (GdlDockItemGrip *grip);
-
-G_END_DECLS
-
-#endif /* _GDL_DOCK_ITEM_GRIP_H_ */
diff --git a/src/libgdl/gdl-dock-item.c b/src/libgdl/gdl-dock-item.c
deleted file mode 100644
index af630e681..000000000
--- a/src/libgdl/gdl-dock-item.c
+++ /dev/null
@@ -1,2401 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * gdl-dock-item.c
- *
- * 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.
- *
- * This library is free software; you can redistribute it and/or
- * 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"
-
-#define NEW_DOCK_ITEM_RATIO 0.3
-
-/* ----- Private prototypes ----- */
-
-static void gdl_dock_item_class_init (GdlDockItemClass *class);
-
-static GObject *gdl_dock_item_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_param);
-
-static void gdl_dock_item_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gdl_dock_item_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static void gdl_dock_item_destroy (GtkObject *object);
-
-static void gdl_dock_item_add (GtkContainer *container,
- GtkWidget *widget);
-static void gdl_dock_item_remove (GtkContainer *container,
- GtkWidget *widget);
-static void gdl_dock_item_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-static GType gdl_dock_item_child_type (GtkContainer *container);
-
-static void gdl_dock_item_set_focus_child (GtkContainer *container,
- GtkWidget *widget);
-
-static void gdl_dock_item_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void gdl_dock_item_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static void gdl_dock_item_map (GtkWidget *widget);
-static void gdl_dock_item_unmap (GtkWidget *widget);
-static void gdl_dock_item_realize (GtkWidget *widget);
-static void gdl_dock_item_style_set (GtkWidget *widget,
- GtkStyle *previous_style);
-static gint gdl_dock_item_expose (GtkWidget *widget,
- GdkEventExpose *event);
-
-static void gdl_dock_item_move_focus_child (GdlDockItem *item,
- GtkDirectionType dir);
-
-static gint gdl_dock_item_button_changed (GtkWidget *widget,
- GdkEventButton *event);
-static gint gdl_dock_item_motion (GtkWidget *widget,
- GdkEventMotion *event);
-static gboolean gdl_dock_item_key_press (GtkWidget *widget,
- GdkEventKey *event);
-
-static gboolean gdl_dock_item_dock_request (GdlDockObject *object,
- gint x,
- gint y,
- GdlDockRequest *request);
-static void gdl_dock_item_dock (GdlDockObject *object,
- GdlDockObject *requestor,
- GdlDockPlacement position,
- GValue *other_data);
-
-static void gdl_dock_item_popup_menu (GdlDockItem *item,
- guint button,
- guint32 time);
-static void gdl_dock_item_drag_start (GdlDockItem *item);
-static void gdl_dock_item_drag_end (GdlDockItem *item,
- gboolean cancel);
-
-static void gdl_dock_item_tab_button (GtkWidget *widget,
- GdkEventButton *event,
- gpointer data);
-
-static void gdl_dock_item_hide_cb (GtkWidget *widget,
- GdlDockItem *item);
-
-static void gdl_dock_item_lock_cb (GtkWidget *widget,
- GdlDockItem *item);
-
-static void gdl_dock_item_unlock_cb (GtkWidget *widget,
- GdlDockItem *item);
-
-static void gdl_dock_item_showhide_grip (GdlDockItem *item);
-
-static void gdl_dock_item_real_set_orientation (GdlDockItem *item,
- GtkOrientation orientation);
-
-static void gdl_dock_param_export_gtk_orientation (const GValue *src,
- GValue *dst);
-static void gdl_dock_param_import_gtk_orientation (const GValue *src,
- GValue *dst);
-
-
-
-/* ----- Class variables and definitions ----- */
-
-enum {
- PROP_0,
- PROP_ORIENTATION,
- PROP_RESIZE,
- PROP_BEHAVIOR,
- PROP_LOCKED,
- PROP_PREFERRED_WIDTH,
- PROP_PREFERRED_HEIGHT
-};
-
-enum {
- DOCK_DRAG_BEGIN,
- DOCK_DRAG_MOTION,
- DOCK_DRAG_END,
- SELECTED,
- MOVE_FOCUS_CHILD,
- LAST_SIGNAL
-};
-
-static guint gdl_dock_item_signals [LAST_SIGNAL] = { 0 };
-
-#define GDL_DOCK_ITEM_GRIP_SHOWN(item) \
- (GDL_DOCK_ITEM_HAS_GRIP (item))
-
-struct _GdlDockItemPrivate {
- GtkWidget *menu;
-
- gboolean grip_shown;
- GtkWidget *grip;
- guint grip_size;
-
- GtkWidget *tab_label;
- gboolean intern_tab_label;
- guint notify_label;
- guint notify_stock_id;
-
- gint preferred_width;
- gint preferred_height;
-
- GdlDockPlaceholder *ph;
-
- gint start_x, start_y;
-};
-
-/* FIXME: implement the rest of the behaviors */
-
-#define SPLIT_RATIO 0.4
-
-
-/* ----- Private functions ----- */
-
-G_DEFINE_TYPE (GdlDockItem, gdl_dock_item, GDL_TYPE_DOCK_OBJECT);
-
-static void
-add_tab_bindings (GtkBindingSet *binding_set,
- GdkModifierType modifiers,
- GtkDirectionType direction)
-{
- gtk_binding_entry_add_signal (binding_set, GDK_KEY_Tab, modifiers,
- "move_focus_child", 1,
- GTK_TYPE_DIRECTION_TYPE, direction);
- gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Tab, modifiers,
- "move_focus_child", 1,
- GTK_TYPE_DIRECTION_TYPE, direction);
-}
-
-static void
-add_arrow_bindings (GtkBindingSet *binding_set,
- guint keysym,
- GtkDirectionType direction)
-{
- guint keypad_keysym = keysym - GDK_KEY_Left + GDK_KEY_KP_Left;
-
- gtk_binding_entry_add_signal (binding_set, keysym, 0,
- "move_focus_child", 1,
- GTK_TYPE_DIRECTION_TYPE, direction);
- gtk_binding_entry_add_signal (binding_set, keysym, GDK_CONTROL_MASK,
- "move_focus_child", 1,
- GTK_TYPE_DIRECTION_TYPE, direction);
- gtk_binding_entry_add_signal (binding_set, keysym, GDK_CONTROL_MASK,
- "move_focus_child", 1,
- GTK_TYPE_DIRECTION_TYPE, direction);
- gtk_binding_entry_add_signal (binding_set, keypad_keysym, GDK_CONTROL_MASK,
- "move_focus_child", 1,
- GTK_TYPE_DIRECTION_TYPE, direction);
-}
-
-static void
-gdl_dock_item_class_init (GdlDockItemClass *klass)
-{
- static gboolean style_initialized = FALSE;
-
- GObjectClass *g_object_class;
- GtkObjectClass *gtk_object_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
- GdlDockObjectClass *object_class;
- GtkBindingSet *binding_set;
-
- g_object_class = G_OBJECT_CLASS (klass);
- gtk_object_class = GTK_OBJECT_CLASS (klass);
- widget_class = GTK_WIDGET_CLASS (klass);
- container_class = GTK_CONTAINER_CLASS (klass);
- object_class = GDL_DOCK_OBJECT_CLASS (klass);
-
- g_object_class->constructor = gdl_dock_item_constructor;
- g_object_class->set_property = gdl_dock_item_set_property;
- g_object_class->get_property = gdl_dock_item_get_property;
-
- gtk_object_class->destroy = gdl_dock_item_destroy;
-
- widget_class->realize = gdl_dock_item_realize;
- widget_class->map = gdl_dock_item_map;
- widget_class->unmap = gdl_dock_item_unmap;
- widget_class->size_request = gdl_dock_item_size_request;
- widget_class->size_allocate = gdl_dock_item_size_allocate;
- widget_class->style_set = gdl_dock_item_style_set;
- widget_class->expose_event = gdl_dock_item_expose;
- widget_class->button_press_event = gdl_dock_item_button_changed;
- widget_class->button_release_event = gdl_dock_item_button_changed;
- widget_class->motion_notify_event = gdl_dock_item_motion;
- widget_class->key_press_event = gdl_dock_item_key_press;
-
- container_class->add = gdl_dock_item_add;
- container_class->remove = gdl_dock_item_remove;
- container_class->forall = gdl_dock_item_forall;
- container_class->child_type = gdl_dock_item_child_type;
- container_class->set_focus_child = gdl_dock_item_set_focus_child;
-
- object_class->is_compound = FALSE;
-
- object_class->dock_request = gdl_dock_item_dock_request;
- object_class->dock = gdl_dock_item_dock;
-
- /* 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).
- */
- g_object_class_install_property (
- g_object_class, PROP_ORIENTATION,
- g_param_spec_enum ("orientation", _("Orientation"),
- _("Orientation of the docking item"),
- GTK_TYPE_ORIENTATION,
- GTK_ORIENTATION_VERTICAL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
- GDL_DOCK_PARAM_EXPORT));
-
- /* --- register exporter/importer for GTK_ORIENTATION */
- g_value_register_transform_func (GTK_TYPE_ORIENTATION, GDL_TYPE_DOCK_PARAM,
- gdl_dock_param_export_gtk_orientation);
- g_value_register_transform_func (GDL_TYPE_DOCK_PARAM, GTK_TYPE_ORIENTATION,
- gdl_dock_param_import_gtk_orientation);
- /* --- end of registration */
-
- g_object_class_install_property (
- g_object_class, PROP_RESIZE,
- g_param_spec_boolean ("resize", _("Resizable"),
- _("If set, the dock item can be resized when "
- "docked in a GtkPanel widget"),
- TRUE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- g_object_class, PROP_BEHAVIOR,
- g_param_spec_flags ("behavior", _("Item behavior"),
- _("General behavior for the dock item (i.e. "
- "whether it can float, if it's locked, etc.)"),
- GDL_TYPE_DOCK_ITEM_BEHAVIOR,
- GDL_DOCK_ITEM_BEH_NORMAL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- g_object_class, PROP_LOCKED,
- g_param_spec_boolean ("locked", _("Locked"),
- _("If set, the dock item cannot be dragged around "
- "and it doesn't show a grip"),
- FALSE,
- G_PARAM_READWRITE |
- GDL_DOCK_PARAM_EXPORT));
-
- g_object_class_install_property (
- g_object_class, PROP_PREFERRED_WIDTH,
- g_param_spec_int ("preferred-width", _("Preferred width"),
- _("Preferred width for the dock item"),
- -1, G_MAXINT, -1,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- g_object_class, PROP_PREFERRED_HEIGHT,
- g_param_spec_int ("preferred-height", _("Preferred height"),
- _("Preferred height for the dock item"),
- -1, G_MAXINT, -1,
- G_PARAM_READWRITE));
-
- /* signals */
-
- /**
- * GdlDockItem::dock-drag-begin:
- * @item: The dock item which is being dragged.
- *
- * Signals that the dock item has begun to be dragged.
- **/
- gdl_dock_item_signals [DOCK_DRAG_BEGIN] =
- g_signal_new ("dock-drag-begin",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdlDockItemClass, dock_drag_begin),
- NULL, /* accumulator */
- NULL, /* accu_data */
- gdl_marshal_VOID__VOID,
- G_TYPE_NONE,
- 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.
- **/
- gdl_dock_item_signals [DOCK_DRAG_MOTION] =
- g_signal_new ("dock-drag-motion",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdlDockItemClass, dock_drag_motion),
- NULL, /* accumulator */
- NULL, /* accu_data */
- gdl_marshal_VOID__INT_INT,
- G_TYPE_NONE,
- 2,
- G_TYPE_INT,
- G_TYPE_INT);
-
- /**
- * 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.
- **/
- gdl_dock_item_signals [DOCK_DRAG_END] =
- g_signal_new ("dock_drag_end",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdlDockItemClass, dock_drag_end),
- NULL, /* accumulator */
- NULL, /* accu_data */
- gdl_marshal_VOID__BOOLEAN,
- G_TYPE_NONE,
- 1,
- G_TYPE_BOOLEAN);
-
- /**
- * GdlDockItem::selected:
- *
- * Signals that this dock has been selected from a switcher.
- */
- gdl_dock_item_signals [SELECTED] =
- g_signal_new ("selected",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- 0,
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- gdl_dock_item_signals [MOVE_FOCUS_CHILD] =
- g_signal_new ("move_focus_child",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (GdlDockItemClass, move_focus_child),
- NULL, /* accumulator */
- NULL, /* accu_data */
- gdl_marshal_VOID__ENUM,
- G_TYPE_NONE,
- 1,
- GTK_TYPE_DIRECTION_TYPE);
-
-
- /* key bindings */
-
- binding_set = gtk_binding_set_by_class (klass);
-
- add_arrow_bindings (binding_set, GDK_KEY_Up, GTK_DIR_UP);
- add_arrow_bindings (binding_set, GDK_KEY_Down, GTK_DIR_DOWN);
- add_arrow_bindings (binding_set, GDK_KEY_Left, GTK_DIR_LEFT);
- add_arrow_bindings (binding_set, GDK_KEY_Right, GTK_DIR_RIGHT);
-
- add_tab_bindings (binding_set, 0, GTK_DIR_TAB_FORWARD);
- add_tab_bindings (binding_set, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD);
- add_tab_bindings (binding_set, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
- add_tab_bindings (binding_set, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
-
- klass->has_grip = TRUE;
- klass->dock_drag_begin = NULL;
- klass->dock_drag_motion = NULL;
- klass->dock_drag_end = NULL;
- klass->move_focus_child = gdl_dock_item_move_focus_child;
- klass->set_orientation = gdl_dock_item_real_set_orientation;
-
- if (!style_initialized)
- {
- style_initialized = TRUE;
- gtk_rc_parse_string (
- "style \"gdl-dock-item-default\" {\n"
- "xthickness = 0\n"
- "ythickness = 0\n"
- "}\n"
- "class \"GdlDockItem\" "
- "style : gtk \"gdl-dock-item-default\"\n");
- }
-}
-
-static void
-gdl_dock_item_init (GdlDockItem *item)
-{
- gtk_widget_set_has_window (GTK_WIDGET (item), TRUE);
- gtk_widget_set_can_focus (GTK_WIDGET (item), TRUE);
-
- item->child = NULL;
-
- item->orientation = GTK_ORIENTATION_VERTICAL;
- item->behavior = GDL_DOCK_ITEM_BEH_NORMAL;
-
- item->resize = TRUE;
-
- item->dragoff_x = item->dragoff_y = 0;
-
- item->_priv = g_new0 (GdlDockItemPrivate, 1);
- item->_priv->menu = NULL;
-
- item->_priv->preferred_width = item->_priv->preferred_height = -1;
- item->_priv->tab_label = NULL;
- item->_priv->intern_tab_label = FALSE;
-
- item->_priv->ph = NULL;
-}
-
-static void
-on_long_name_changed (GObject* item,
- GParamSpec* spec,
- gpointer user_data)
-{
- gchar* long_name;
- g_object_get (item, "long-name", &long_name, NULL);
- gtk_label_set_label (GTK_LABEL (user_data), long_name);
- g_free(long_name);
-}
-
-static void
-on_stock_id_changed (GObject* item,
- GParamSpec* spec,
- gpointer user_data)
-{
- gchar* stock_id;
- g_object_get (item, "stock_id", &stock_id, NULL);
- gtk_image_set_from_stock (GTK_IMAGE (user_data), stock_id, GTK_ICON_SIZE_MENU);
- g_free(stock_id);
-}
-
-static GObject *
-gdl_dock_item_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_param)
-{
- GObject *g_object;
-
- g_object = G_OBJECT_CLASS (gdl_dock_item_parent_class)-> constructor (type,
- n_construct_properties,
- construct_param);
- if (g_object) {
- GdlDockItem *item = GDL_DOCK_ITEM (g_object);
- GtkWidget *hbox;
- GtkWidget *label;
- GtkWidget *icon;
- gchar* long_name;
- gchar* stock_id;
-
- if (GDL_DOCK_ITEM_HAS_GRIP (item)) {
- item->_priv->grip_shown = TRUE;
- item->_priv->grip = gdl_dock_item_grip_new (item);
- gtk_widget_set_parent (item->_priv->grip, GTK_WIDGET (item));
- gtk_widget_show (item->_priv->grip);
- }
- else {
- item->_priv->grip_shown = FALSE;
- }
-
- g_object_get (g_object, "long-name", &long_name, "stock-id", &stock_id, NULL);
-
- hbox = gtk_hbox_new (FALSE, 5);
- label = gtk_label_new (long_name);
- icon = gtk_image_new ();
- if (stock_id)
- gtk_image_set_from_stock (GTK_IMAGE (icon), stock_id,
- GTK_ICON_SIZE_MENU);
- gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
-
- item->_priv->notify_label =
- g_signal_connect (item, "notify::long-name", G_CALLBACK (on_long_name_changed),
- label);
- item->_priv->notify_stock_id =
- g_signal_connect (item, "notify::stock-id", G_CALLBACK (on_stock_id_changed),
- icon);
-
- gtk_widget_show_all (hbox);
-
- gdl_dock_item_set_tablabel (item, hbox);
- item->_priv->intern_tab_label = TRUE;
-
- g_free (long_name);
- g_free (stock_id);
- }
-
- return g_object;
-}
-
-static void
-gdl_dock_item_set_property (GObject *g_object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GdlDockItem *item = GDL_DOCK_ITEM (g_object);
-
- switch (prop_id) {
- case PROP_ORIENTATION:
- gdl_dock_item_set_orientation (item, g_value_get_enum (value));
- break;
- case PROP_RESIZE:
- item->resize = g_value_get_boolean (value);
- gtk_widget_queue_resize (GTK_WIDGET (item));
- break;
- case PROP_BEHAVIOR:
- {
- GdlDockItemBehavior old_beh = item->behavior;
- item->behavior = g_value_get_flags (value);
-
- if ((old_beh ^ item->behavior) & GDL_DOCK_ITEM_BEH_LOCKED) {
- if (GDL_DOCK_OBJECT_GET_MASTER (item))
- g_signal_emit_by_name (GDL_DOCK_OBJECT_GET_MASTER (item),
- "layout-changed");
- g_object_notify (g_object, "locked");
- gdl_dock_item_showhide_grip (item);
- }
-
- break;
- }
- case PROP_LOCKED:
- {
- GdlDockItemBehavior old_beh = item->behavior;
-
- if (g_value_get_boolean (value))
- item->behavior |= GDL_DOCK_ITEM_BEH_LOCKED;
- else
- item->behavior &= ~GDL_DOCK_ITEM_BEH_LOCKED;
-
- if (old_beh ^ item->behavior) {
- gdl_dock_item_showhide_grip (item);
- g_object_notify (g_object, "behavior");
-
- if (GDL_DOCK_OBJECT_GET_MASTER (item))
- g_signal_emit_by_name (GDL_DOCK_OBJECT_GET_MASTER (item),
- "layout-changed");
- }
- break;
- }
- case PROP_PREFERRED_WIDTH:
- item->_priv->preferred_width = g_value_get_int (value);
- break;
- case PROP_PREFERRED_HEIGHT:
- item->_priv->preferred_height = g_value_get_int (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (g_object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gdl_dock_item_get_property (GObject *g_object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GdlDockItem *item = GDL_DOCK_ITEM (g_object);
-
- switch (prop_id) {
- case PROP_ORIENTATION:
- g_value_set_enum (value, item->orientation);
- break;
- case PROP_RESIZE:
- g_value_set_boolean (value, item->resize);
- break;
- case PROP_BEHAVIOR:
- g_value_set_flags (value, item->behavior);
- break;
- case PROP_LOCKED:
- g_value_set_boolean (value, !GDL_DOCK_ITEM_NOT_LOCKED (item));
- break;
- case PROP_PREFERRED_WIDTH:
- g_value_set_int (value, item->_priv->preferred_width);
- break;
- case PROP_PREFERRED_HEIGHT:
- g_value_set_int (value, item->_priv->preferred_height);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (g_object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gdl_dock_item_destroy (GtkObject *object)
-{
- GdlDockItem *item = GDL_DOCK_ITEM (object);
-
- if (item->_priv) {
- GdlDockItemPrivate *priv = item->_priv;
-
- if (priv->tab_label) {
- gdl_dock_item_set_tablabel (item, NULL);
- };
- if (priv->menu) {
- gtk_menu_detach (GTK_MENU (priv->menu));
- priv->menu = NULL;
- };
- if (priv->grip) {
- gtk_container_remove (GTK_CONTAINER (item), priv->grip);
- priv->grip = NULL;
- }
- if (priv->ph) {
- g_object_unref (priv->ph);
- priv->ph = NULL;
- }
-
- item->_priv = NULL;
- g_free (priv);
- }
-
- GTK_OBJECT_CLASS (gdl_dock_item_parent_class)->destroy (object);
-}
-
-static void
-gdl_dock_item_add (GtkContainer *container,
- GtkWidget *widget)
-{
- GdlDockItem *item;
-
- g_return_if_fail (GDL_IS_DOCK_ITEM (container));
-
- item = GDL_DOCK_ITEM (container);
- 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."),
- widget, G_OBJECT_TYPE_NAME (widget), G_OBJECT_TYPE_NAME (item));
- return;
- }
-
- if (item->child != NULL) {
- 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"),
- G_OBJECT_TYPE_NAME (widget),
- G_OBJECT_TYPE_NAME (item),
- G_OBJECT_TYPE_NAME (item->child));
- return;
- }
-
- gtk_widget_set_parent (widget, GTK_WIDGET (item));
- item->child = widget;
-}
-
-static void
-gdl_dock_item_remove (GtkContainer *container,
- GtkWidget *widget)
-{
- GdlDockItem *item;
- gboolean was_visible;
-
- g_return_if_fail (GDL_IS_DOCK_ITEM (container));
-
- item = GDL_DOCK_ITEM (container);
- if (item->_priv && widget == item->_priv->grip) {
- gboolean grip_was_visible = gtk_widget_get_visible (widget);
- gtk_widget_unparent (widget);
- item->_priv->grip = NULL;
- if (grip_was_visible)
- gtk_widget_queue_resize (GTK_WIDGET (item));
- return;
- }
-
- if (GDL_DOCK_ITEM_IN_DRAG (item)) {
- gdl_dock_item_drag_end (item, TRUE);
- }
-
- g_return_if_fail (item->child == widget);
-
- was_visible = gtk_widget_get_visible (widget);
-
- gtk_widget_unparent (widget);
- item->child = NULL;
-
- if (was_visible)
- gtk_widget_queue_resize (GTK_WIDGET (container));
-}
-
-static void
-gdl_dock_item_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data)
-{
- GdlDockItem *item = (GdlDockItem *) container;
-
- g_return_if_fail (callback != NULL);
-
- if (include_internals && item->_priv->grip)
- (* callback) (item->_priv->grip, callback_data);
-
- if (item->child)
- (* callback) (item->child, callback_data);
-}
-
-static GType
-gdl_dock_item_child_type (GtkContainer *container)
-{
- g_return_val_if_fail (GDL_IS_DOCK_ITEM (container), G_TYPE_NONE);
-
- if (!GDL_DOCK_ITEM (container)->child)
- return GTK_TYPE_WIDGET;
- else
- return G_TYPE_NONE;
-}
-
-static void
-gdl_dock_item_set_focus_child (GtkContainer *container,
- GtkWidget *child)
-{
- g_return_if_fail (GDL_IS_DOCK_ITEM (container));
-
- if (GTK_CONTAINER_CLASS (gdl_dock_item_parent_class)->set_focus_child) {
- (* GTK_CONTAINER_CLASS (gdl_dock_item_parent_class)->set_focus_child) (container, child);
- }
-
- gdl_dock_item_showhide_grip (GDL_DOCK_ITEM (container));
-}
-
-static void
-gdl_dock_item_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- GdlDockItem *item;
- GtkRequisition child_requisition;
- GtkRequisition grip_requisition;
- GtkStyle *style;
- guint border_width;
-
- g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
- g_return_if_fail (requisition != NULL);
-
- item = GDL_DOCK_ITEM (widget);
-
- /* If our child is not visible, we still request its size, since
- we won't have any useful hint for our size otherwise. */
- if (item->child)
- gtk_widget_size_request (item->child, &child_requisition);
- else {
- child_requisition.width = 0;
- child_requisition.height = 0;
- }
-
- if (item->orientation == GTK_ORIENTATION_HORIZONTAL) {
- if (GDL_DOCK_ITEM_GRIP_SHOWN (item)) {
- gtk_widget_size_request (item->_priv->grip, &grip_requisition);
- requisition->width = grip_requisition.width;
- } else {
- requisition->width = 0;
- }
-
- if (item->child) {
- requisition->width += child_requisition.width;
- requisition->height = child_requisition.height;
- } else
- requisition->height = 0;
- } else {
- if (GDL_DOCK_ITEM_GRIP_SHOWN (item)) {
- gtk_widget_size_request (item->_priv->grip, &grip_requisition);
- requisition->height = grip_requisition.height;
- } else {
- requisition->height = 0;
- }
-
- if (item->child) {
- requisition->width = child_requisition.width;
- requisition->height += child_requisition.height;
- } else
- requisition->width = 0;
- }
-
- border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- style = gtk_widget_get_style (widget);
-
- requisition->width += (border_width + style->xthickness) * 2;
- requisition->height += (border_width + style->ythickness) * 2;
-
- //gtk_widget_size_request (widget, requisition);
-}
-
-static void
-gdl_dock_item_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- GdlDockItem *item;
-
- g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
- g_return_if_fail (allocation != NULL);
-
- item = GDL_DOCK_ITEM (widget);
-
- gtk_widget_set_allocation (widget, allocation);
-
- /* Once size is allocated, preferred size is no longer necessary */
- item->_priv->preferred_height = -1;
- item->_priv->preferred_width = -1;
-
- if (gtk_widget_get_realized (widget))
- gdk_window_move_resize (gtk_widget_get_window (widget),
- allocation->x,
- allocation->y,
- allocation->width,
- allocation->height);
-
- if (item->child && gtk_widget_get_visible (item->child)) {
- GtkAllocation child_allocation;
- GtkStyle *style;
- guint border_width;
-
- border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- style = gtk_widget_get_style (widget);
-
- child_allocation.x = border_width + style->xthickness;
- child_allocation.y = border_width + style->ythickness;
- child_allocation.width = allocation->width
- - 2 * (border_width + style->xthickness);
- child_allocation.height = allocation->height
- - 2 * (border_width + style->ythickness);
-
- if (GDL_DOCK_ITEM_GRIP_SHOWN (item)) {
- GtkAllocation grip_alloc = child_allocation;
- GtkRequisition grip_req;
-
- gtk_widget_size_request (item->_priv->grip, &grip_req);
-
- if (item->orientation == GTK_ORIENTATION_HORIZONTAL) {
- child_allocation.x += grip_req.width;
- child_allocation.width -= grip_req.width;
- grip_alloc.width = grip_req.width;
- } else {
- child_allocation.y += grip_req.height;
- child_allocation.height -= grip_req.height;
- grip_alloc.height = grip_req.height;
- }
- if (item->_priv->grip)
- gtk_widget_size_allocate (item->_priv->grip, &grip_alloc);
- }
- /* Allocation can't be negative */
- if (child_allocation.width < 0)
- child_allocation.width = 0;
- if (child_allocation.height < 0)
- child_allocation.height = 0;
- gtk_widget_size_allocate (item->child, &child_allocation);
- }
-}
-
-static void
-gdl_dock_item_map (GtkWidget *widget)
-{
- GdlDockItem *item;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
-
- gtk_widget_set_mapped (widget, TRUE);
-
- item = GDL_DOCK_ITEM (widget);
-
- gdk_window_show (gtk_widget_get_window (widget));
-
- if (item->child
- && gtk_widget_get_visible (item->child)
- && !gtk_widget_get_mapped (item->child))
- gtk_widget_map (item->child);
-
- if (item->_priv->grip
- && gtk_widget_get_visible (GTK_WIDGET (item->_priv->grip))
- && !gtk_widget_get_mapped (GTK_WIDGET (item->_priv->grip)))
- gtk_widget_map (item->_priv->grip);
-}
-
-static void
-gdl_dock_item_unmap (GtkWidget *widget)
-{
- GdlDockItem *item;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
-
- gtk_widget_set_mapped (widget, FALSE);
-
- item = GDL_DOCK_ITEM (widget);
-
- gdk_window_hide (gtk_widget_get_window (widget));
-
- if (item->_priv->grip)
- gtk_widget_unmap (item->_priv->grip);
-}
-
-static void
-gdl_dock_item_realize (GtkWidget *widget)
-{
- GdlDockItem *item;
- GtkAllocation allocation;
- GdkWindow *window;
- GdkWindowAttr attributes;
- gint attributes_mask;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
-
- item = GDL_DOCK_ITEM (widget);
-
- gtk_widget_set_realized (widget, TRUE);
-
- /* widget window */
- gtk_widget_get_allocation (widget, &allocation);
- attributes.x = allocation.x;
- attributes.y = allocation.y;
- attributes.width = allocation.width;
- attributes.height = allocation.height;
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.event_mask = (gtk_widget_get_events (widget) |
- GDK_EXPOSURE_MASK |
- GDK_BUTTON1_MOTION_MASK |
- GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK);
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gtk_widget_set_window (widget, window);
- gdk_window_set_user_data (window, widget);
-
- gtk_widget_style_attach (widget);
- gtk_style_set_background (gtk_widget_get_style (widget), window,
- gtk_widget_get_state (GTK_WIDGET (item)));
- gdk_window_set_back_pixmap (window, NULL, TRUE);
-
- if (item->child)
- gtk_widget_set_parent_window (item->child, window);
-
- if (item->_priv->grip)
- gtk_widget_set_parent_window (item->_priv->grip, window);
-}
-
-static void
-gdl_dock_item_style_set (GtkWidget *widget,
- GtkStyle *previous_style)
-{
- GdkWindow *window;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
-
- if (gtk_widget_get_realized (widget) &&
- gtk_widget_get_has_window (widget))
- {
- window = gtk_widget_get_window (widget);
- gtk_style_set_background (gtk_widget_get_style (widget),
- window,
- gtk_widget_get_state (widget));
- if (gtk_widget_is_drawable (widget))
- gdk_window_clear (window);
- }
-}
-
-static void
-gdl_dock_item_paint (GtkWidget *widget,
- GdkEventExpose *event)
-{
- GdlDockItem *item;
-
- item = GDL_DOCK_ITEM (widget);
-
- gtk_paint_box (gtk_widget_get_style (widget),
- gtk_widget_get_window (widget),
- gtk_widget_get_state (widget),
- GTK_SHADOW_NONE,
- &event->area, widget,
- "dockitem",
- 0, 0, -1, -1);
-
-/* see bug #950556: avoid regression with GTK2/Quartz */
-#if !defined(GDK_WINDOWING_QUARTZ)
- if (GTK_IS_WIDGET(item->_priv->grip))
- gtk_widget_queue_draw (GTK_WIDGET(item->_priv->grip));
-#endif
-}
-
-static gint
-gdl_dock_item_expose (GtkWidget *widget,
- GdkEventExpose *event)
-{
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GDL_IS_DOCK_ITEM (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- if (gtk_widget_is_drawable (widget) &&
- event->window == gtk_widget_get_window (widget))
- {
- gdl_dock_item_paint (widget, event);
- GTK_WIDGET_CLASS (gdl_dock_item_parent_class)->expose_event (widget,event);
- }
-
- return FALSE;
-}
-
-static void
-gdl_dock_item_move_focus_child (GdlDockItem *item,
- GtkDirectionType dir)
-{
- g_return_if_fail (GDL_IS_DOCK_ITEM (item));
- gtk_widget_child_focus (GTK_WIDGET (item->child), dir);
-}
-
-#define EVENT_IN_GRIP_EVENT_WINDOW(ev,gr) \
- ((gr) != NULL && (ev)->window == GDL_DOCK_ITEM_GRIP (gr)->title_window)
-
-#define EVENT_IN_TABLABEL_EVENT_WINDOW(ev,tl) \
- ((tl) != NULL && (ev)->window == GDL_DOCK_TABLABEL (tl)->event_window)
-
-static gint
-gdl_dock_item_button_changed (GtkWidget *widget,
- GdkEventButton *event)
-{
- GdlDockItem *item;
- GtkAllocation allocation;
- GdkCursor *cursor;
- gboolean locked;
- gboolean event_handled;
- gboolean in_handle;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GDL_IS_DOCK_ITEM (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- item = GDL_DOCK_ITEM (widget);
-
- if (!EVENT_IN_GRIP_EVENT_WINDOW (event, item->_priv->grip))
- return FALSE;
-
- locked = !GDL_DOCK_ITEM_NOT_LOCKED (item);
-
- event_handled = FALSE;
-
- gtk_widget_get_allocation (item->_priv->grip, &allocation);
-
- /* Check if user clicked on the drag handle. */
- switch (item->orientation) {
- case GTK_ORIENTATION_HORIZONTAL:
- in_handle = event->x < allocation.width;
- break;
- case GTK_ORIENTATION_VERTICAL:
- in_handle = event->y < allocation.height;
- break;
- default:
- in_handle = FALSE;
- break;
- }
-
- /* Left mousebutton click on dockitem. */
- if (!locked && event->button == 1 && event->type == GDK_BUTTON_PRESS) {
-
- if (!gdl_dock_item_or_child_has_focus (item))
- gtk_widget_grab_focus (GTK_WIDGET (item));
-
- /* Set in_drag flag, grab pointer and call begin drag operation. */
- if (in_handle) {
- item->_priv->start_x = event->x;
- item->_priv->start_y = event->y;
-
- GDL_DOCK_ITEM_SET_FLAGS (item, GDL_DOCK_IN_PREDRAG);
-
- cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
- GDK_FLEUR);
- gdk_window_set_cursor (GDL_DOCK_ITEM_GRIP (item->_priv->grip)->title_window,
- cursor);
- gdk_cursor_unref (cursor);
-
- event_handled = TRUE;
- };
-
- } else if (!locked &&event->type == GDK_BUTTON_RELEASE && event->button == 1) {
- if (GDL_DOCK_ITEM_IN_DRAG (item)) {
- /* User dropped widget somewhere. */
- gdl_dock_item_drag_end (item, FALSE);
- gtk_widget_grab_focus (GTK_WIDGET (item));
- event_handled = TRUE;
- }
- else if (GDL_DOCK_ITEM_IN_PREDRAG (item)) {
- GDL_DOCK_ITEM_UNSET_FLAGS (item, GDL_DOCK_IN_PREDRAG);
- event_handled = TRUE;
- }
-
- /* we check the window since if the item was redocked it's
- been unrealized and maybe it's not realized again yet */
- if (GDL_DOCK_ITEM_GRIP (item->_priv->grip)->title_window) {
- cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
- GDK_HAND2);
- gdk_window_set_cursor (GDL_DOCK_ITEM_GRIP (item->_priv->grip)->title_window,
- cursor);
- gdk_cursor_unref (cursor);
- }
-
- } else if (event->button == 3 && event->type == GDK_BUTTON_PRESS && in_handle) {
- gdl_dock_item_popup_menu (item, event->button, event->time);
- event_handled = TRUE;
- }
-
- return event_handled;
-}
-
-static gint
-gdl_dock_item_motion (GtkWidget *widget,
- GdkEventMotion *event)
-{
- GdlDockItem *item;
- gint new_x, new_y;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GDL_IS_DOCK_ITEM (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- item = GDL_DOCK_ITEM (widget);
-
- if (!EVENT_IN_GRIP_EVENT_WINDOW (event, item->_priv->grip))
- return FALSE;
-
- if (GDL_DOCK_ITEM_IN_PREDRAG (item)) {
- if (gtk_drag_check_threshold (widget,
- item->_priv->start_x,
- item->_priv->start_y,
- event->x,
- event->y)) {
- GDL_DOCK_ITEM_UNSET_FLAGS (item, GDL_DOCK_IN_PREDRAG);
- item->dragoff_x = item->_priv->start_x;
- item->dragoff_y = item->_priv->start_y;
-
- gdl_dock_item_drag_start (item);
- }
- }
-
- if (!GDL_DOCK_ITEM_IN_DRAG (item))
- return FALSE;
-
- new_x = event->x_root;
- new_y = event->y_root;
-
- g_signal_emit (item, gdl_dock_item_signals [DOCK_DRAG_MOTION],
- 0, new_x, new_y);
-
- return TRUE;
-}
-
-static gboolean
-gdl_dock_item_key_press (GtkWidget *widget,
- GdkEventKey *event)
-{
- gboolean event_handled = FALSE;
-
- if (GDL_DOCK_ITEM_IN_DRAG (widget)) {
- if (event->keyval == GDK_Escape) {
- gdl_dock_item_drag_end (GDL_DOCK_ITEM (widget), TRUE);
- event_handled = TRUE;
- }
- }
-
- if (event_handled)
- return TRUE;
- else
- return GTK_WIDGET_CLASS (gdl_dock_item_parent_class)->key_press_event (widget, event);
-}
-
-static gboolean
-gdl_dock_item_dock_request (GdlDockObject *object,
- gint x,
- gint y,
- GdlDockRequest *request)
-{
- GtkAllocation alloc;
- gint rel_x, rel_y;
-
- /* we get (x,y) in our allocation coordinates system */
-
- /* Get item's allocation. */
- gtk_widget_get_allocation (GTK_WIDGET (object), &alloc);
-
- /* Get coordinates relative to our window. */
- rel_x = x - alloc.x;
- rel_y = y - alloc.y;
-
- /* Location is inside. */
- if (rel_x > 0 && rel_x < alloc.width &&
- rel_y > 0 && rel_y < alloc.height) {
- float rx, ry;
- GtkRequisition my, other;
- gint divider = -1;
-
- /* this are for calculating the extra docking parameter */
- gdl_dock_item_preferred_size (GDL_DOCK_ITEM (request->applicant), &other);
- gdl_dock_item_preferred_size (GDL_DOCK_ITEM (object), &my);
-
- /* Calculate location in terms of the available space (0-100%). */
- rx = (float) rel_x / alloc.width;
- ry = (float) rel_y / alloc.height;
-
- /* Determine dock location. */
- if (rx < SPLIT_RATIO) {
- request->position = GDL_DOCK_LEFT;
- divider = other.width;
- }
- else if (rx > (1 - SPLIT_RATIO)) {
- request->position = GDL_DOCK_RIGHT;
- rx = 1 - rx;
- divider = MAX (0, my.width - other.width);
- }
- else if (ry < SPLIT_RATIO && ry < rx) {
- request->position = GDL_DOCK_TOP;
- divider = other.height;
- }
- else if (ry > (1 - SPLIT_RATIO) && (1 - ry) < rx) {
- request->position = GDL_DOCK_BOTTOM;
- divider = MAX (0, my.height - other.height);
- }
- else
- request->position = GDL_DOCK_CENTER;
-
- /* Reset rectangle coordinates to entire item. */
- request->rect.x = 0;
- request->rect.y = 0;
- request->rect.width = alloc.width;
- request->rect.height = alloc.height;
-
- GdlDockItemBehavior behavior = GDL_DOCK_ITEM(object)->behavior;
-
- /* Calculate docking indicator rectangle size for new locations. Only
- do this when we're not over the item's current location. */
- if (request->applicant != object) {
- switch (request->position) {
- case GDL_DOCK_TOP:
- if (behavior & GDL_DOCK_ITEM_BEH_CANT_DOCK_TOP)
- return FALSE;
- request->rect.height *= SPLIT_RATIO;
- break;
- case GDL_DOCK_BOTTOM:
- if (behavior & GDL_DOCK_ITEM_BEH_CANT_DOCK_BOTTOM)
- return FALSE;
- request->rect.y += request->rect.height * (1 - SPLIT_RATIO);
- request->rect.height *= SPLIT_RATIO;
- break;
- case GDL_DOCK_LEFT:
- if (behavior & GDL_DOCK_ITEM_BEH_CANT_DOCK_LEFT)
- return FALSE;
- request->rect.width *= SPLIT_RATIO;
- break;
- case GDL_DOCK_RIGHT:
- if (behavior & GDL_DOCK_ITEM_BEH_CANT_DOCK_RIGHT)
- return FALSE;
- request->rect.x += request->rect.width * (1 - SPLIT_RATIO);
- request->rect.width *= SPLIT_RATIO;
- break;
- case GDL_DOCK_CENTER:
- if (behavior & GDL_DOCK_ITEM_BEH_CANT_DOCK_CENTER)
- return FALSE;
- request->rect.x = request->rect.width * SPLIT_RATIO/2;
- request->rect.y = request->rect.height * SPLIT_RATIO/2;
- request->rect.width = (request->rect.width *
- (1 - SPLIT_RATIO/2)) - request->rect.x;
- request->rect.height = (request->rect.height *
- (1 - SPLIT_RATIO/2)) - request->rect.y;
- break;
- default:
- break;
- }
- }
-
- /* adjust returned coordinates so they are have the same
- origin as our window */
- request->rect.x += alloc.x;
- request->rect.y += alloc.y;
-
- /* Set possible target location and return TRUE. */
- request->target = object;
-
- /* fill-in other dock information */
- if (request->position != GDL_DOCK_CENTER && divider >= 0) {
- if (G_IS_VALUE (&request->extra))
- g_value_unset (&request->extra);
- g_value_init (&request->extra, G_TYPE_UINT);
- g_value_set_uint (&request->extra, (guint) divider);
- }
-
- return TRUE;
- }
- else /* No docking possible at this location. */
- return FALSE;
-}
-
-static void
-gdl_dock_item_dock (GdlDockObject *object,
- GdlDockObject *requestor,
- GdlDockPlacement position,
- GValue *other_data)
-{
- GdlDockObject *new_parent = NULL;
- GdlDockObject *parent, *requestor_parent;
- GtkAllocation allocation;
- gboolean add_ourselves_first = FALSE;
-
- guint available_space=0;
- gint pref_size=-1;
- guint splitpos=0;
- GtkRequisition req, object_req, parent_req;
-
- parent = gdl_dock_object_get_parent_object (object);
- gdl_dock_item_preferred_size (GDL_DOCK_ITEM (requestor), &req);
- gdl_dock_item_preferred_size (GDL_DOCK_ITEM (object), &object_req);
- if (GDL_IS_DOCK_ITEM (parent))
- gdl_dock_item_preferred_size (GDL_DOCK_ITEM (parent), &parent_req);
- else
- {
- gtk_widget_get_allocation (GTK_WIDGET (parent), &allocation);
- parent_req.height = allocation.height;
- parent_req.width = allocation.width;
- }
-
- /* 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:
- if (req.width < 2)
- {
- req.width = object_req.width;
- g_object_set (requestor, "preferred-width", req.width, NULL);
- }
- if (req.height < 2)
- {
- req.height = NEW_DOCK_ITEM_RATIO * object_req.height;
- g_object_set (requestor, "preferred-height", req.height, NULL);
- }
- if (req.width > 1)
- g_object_set (object, "preferred-width", req.width, NULL);
- if (req.height > 1)
- g_object_set (object, "preferred-height",
- object_req.height - req.height, NULL);
- break;
- case GDL_DOCK_LEFT:
- case GDL_DOCK_RIGHT:
- if (req.height < 2)
- {
- req.height = object_req.height;
- g_object_set (requestor, "preferred-height", req.height, NULL);
- }
- if (req.width < 2)
- {
- req.width = NEW_DOCK_ITEM_RATIO * object_req.width;
- g_object_set (requestor, "preferred-width", req.width, NULL);
- }
- if (req.height > 1)
- g_object_set (object, "preferred-height", req.height, NULL);
- if (req.width > 1)
- g_object_set (object, "preferred-width",
- object_req.width - req.width, NULL);
- break;
- case GDL_DOCK_CENTER:
- if (req.height < 2)
- {
- req.height = object_req.height;
- g_object_set (requestor, "preferred-height", req.height, NULL);
- }
- if (req.width < 2)
- {
- req.width = object_req.width;
- g_object_set (requestor, "preferred-width", req.width, NULL);
- }
- if (req.height > 1)
- g_object_set (object, "preferred-height", req.height, NULL);
- if (req.width > 1)
- g_object_set (object, "preferred-width", req.width, NULL);
- break;
- default:
- {
- GEnumClass *enum_class = G_ENUM_CLASS (g_type_class_ref (GDL_TYPE_DOCK_PLACEMENT));
- GEnumValue *enum_value = g_enum_get_value (enum_class, position);
- const gchar *name = enum_value ? enum_value->value_name : NULL;
-
- g_warning (_("Unsupported docking strategy %s in dock object of type %s"),
- name, G_OBJECT_TYPE_NAME (object));
- g_type_class_unref (enum_class);
- return;
- }
- }
- switch (position) {
- case GDL_DOCK_TOP:
- case GDL_DOCK_BOTTOM:
- /* get a paned style dock object */
- new_parent = g_object_new (gdl_dock_object_type_from_nick ("paned"),
- "orientation", GTK_ORIENTATION_VERTICAL,
- "preferred-width", object_req.width,
- "preferred-height", object_req.height,
- NULL);
- add_ourselves_first = (position == GDL_DOCK_BOTTOM);
- if (parent)
- available_space = parent_req.height;
- pref_size = req.height;
- break;
- case GDL_DOCK_LEFT:
- case GDL_DOCK_RIGHT:
- new_parent = g_object_new (gdl_dock_object_type_from_nick ("paned"),
- "orientation", GTK_ORIENTATION_HORIZONTAL,
- "preferred-width", object_req.width,
- "preferred-height", object_req.height,
- NULL);
- add_ourselves_first = (position == GDL_DOCK_RIGHT);
- if(parent)
- available_space = parent_req.width;
- pref_size = req.width;
- 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))
- {
- new_parent = g_object_new (gdl_dock_object_type_from_nick ("notebook"),
- "preferred-width", object_req.width,
- "preferred-height", object_req.height,
- NULL);
- add_ourselves_first = TRUE;
- }
- break;
- default:
- {
- GEnumClass *enum_class = G_ENUM_CLASS (g_type_class_ref (GDL_TYPE_DOCK_PLACEMENT));
- GEnumValue *enum_value = g_enum_get_value (enum_class, position);
- const gchar *name = enum_value ? enum_value->value_name : NULL;
-
- g_warning (_("Unsupported docking strategy %s in dock object of type %s"),
- name, G_OBJECT_TYPE_NAME (object));
- g_type_class_unref (enum_class);
- return;
- }
- }
-
- /* freeze the parent so it doesn't reduce automatically */
- if (parent)
- gdl_dock_object_freeze (parent);
-
-
- if (new_parent)
- {
- /* ref ourselves since we could be destroyed when detached */
- g_object_ref (object);
- GDL_DOCK_OBJECT_SET_FLAGS (object, GDL_DOCK_IN_REFLOW);
- gdl_dock_object_detach (object, FALSE);
-
- /* freeze the new parent, so reduce won't get called before it's
- actually added to our parent */
- gdl_dock_object_freeze (new_parent);
-
- /* bind the new parent to our master, so the following adds work */
- gdl_dock_object_bind (new_parent, G_OBJECT (GDL_DOCK_OBJECT_GET_MASTER (object)));
-
- /* add the objects */
- if (add_ourselves_first) {
- gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (object));
- gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (requestor));
- splitpos = available_space - pref_size;
- } else {
- gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (requestor));
- gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (object));
- splitpos = pref_size;
- }
-
- /* add the new parent to the parent */
- if (parent)
- gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (new_parent));
-
- /* show automatic object */
- if (gtk_widget_get_visible (GTK_WIDGET (object)))
- {
- gtk_widget_show (GTK_WIDGET (new_parent));
- GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_IN_REFLOW);
- }
- gdl_dock_object_thaw (new_parent);
-
- /* use extra docking parameter */
- if (position != GDL_DOCK_CENTER && other_data &&
- G_VALUE_HOLDS (other_data, G_TYPE_UINT)) {
-
- g_object_set (G_OBJECT (new_parent),
- "position", g_value_get_uint (other_data),
- NULL);
- } else if (splitpos > 0 && splitpos < available_space) {
- g_object_set (G_OBJECT (new_parent), "position", splitpos, NULL);
- }
-
- g_object_unref (object);
- }
- else
- {
- /* If the parent is already a DockNotebook, we don't need
- to create a new one. */
- gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (requestor));
- }
-
- requestor_parent = gdl_dock_object_get_parent_object (requestor);
- if (GDL_IS_DOCK_NOTEBOOK (requestor_parent))
- {
- /* Activate the page we just added */
- GdlDockItem* notebook = GDL_DOCK_ITEM (gdl_dock_object_get_parent_object (requestor));
- gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook->child),
- gtk_notebook_page_num (GTK_NOTEBOOK (notebook->child), GTK_WIDGET (requestor)));
- }
-
- if (parent)
- gdl_dock_object_thaw (parent);
-}
-
-static void
-gdl_dock_item_detach_menu (GtkWidget *widget,
- GtkMenu *menu)
-{
- GdlDockItem *item;
-
- item = GDL_DOCK_ITEM (widget);
- item->_priv->menu = NULL;
-}
-
-static void
-gdl_dock_item_popup_menu (GdlDockItem *item,
- guint button,
- guint32 time)
-{
- GtkWidget *mitem;
-
- if (!item->_priv->menu) {
- /* Create popup menu and attach it to the dock item */
- item->_priv->menu = gtk_menu_new ();
- gtk_menu_attach_to_widget (GTK_MENU (item->_priv->menu),
- GTK_WIDGET (item),
- gdl_dock_item_detach_menu);
-
- if (item->behavior & GDL_DOCK_ITEM_BEH_LOCKED) {
- /* UnLock menuitem */
- mitem = gtk_menu_item_new_with_label (_("UnLock"));
- gtk_menu_shell_append (GTK_MENU_SHELL (item->_priv->menu),
- mitem);
- g_signal_connect (mitem, "activate",
- G_CALLBACK (gdl_dock_item_unlock_cb), item);
- } else {
- /* Hide menuitem. */
- mitem = gtk_menu_item_new_with_label (_("Hide"));
- gtk_menu_shell_append (GTK_MENU_SHELL (item->_priv->menu), mitem);
- g_signal_connect (mitem, "activate",
- G_CALLBACK (gdl_dock_item_hide_cb), item);
- /* Lock menuitem */
- mitem = gtk_menu_item_new_with_label (_("Lock"));
- gtk_menu_shell_append (GTK_MENU_SHELL (item->_priv->menu), mitem);
- g_signal_connect (mitem, "activate",
- G_CALLBACK (gdl_dock_item_lock_cb), item);
- }
- }
-
- /* Show popup menu. */
- gtk_widget_show_all (item->_priv->menu);
- gtk_menu_popup (GTK_MENU (item->_priv->menu), NULL, NULL, NULL, NULL,
- button, time);
-}
-
-static void
-gdl_dock_item_drag_start (GdlDockItem *item)
-{
- GdkCursor *fleur;
-
- if (!gtk_widget_get_realized (GTK_WIDGET (item)))
- gtk_widget_realize (GTK_WIDGET (item));
-
- GDL_DOCK_ITEM_SET_FLAGS (item, GDL_DOCK_IN_DRAG);
-
- /* grab the pointer so we receive all mouse events */
- fleur = gdk_cursor_new (GDK_FLEUR);
-
- /* grab the keyboard & pointer */
- gtk_grab_add (GTK_WIDGET (item));
-
- gdk_cursor_unref (fleur);
-
- g_signal_emit (item, gdl_dock_item_signals [DOCK_DRAG_BEGIN], 0);
-}
-
-static void
-gdl_dock_item_drag_end (GdlDockItem *item,
- gboolean cancel)
-{
- /* Release pointer & keyboard. */
- GtkWidget *widget = gtk_grab_get_current ();
- if (widget == NULL) {
- widget = GTK_WIDGET (item);
- }
- gtk_grab_remove (widget);
-
- g_signal_emit (item, gdl_dock_item_signals [DOCK_DRAG_END], 0, cancel);
-
- GDL_DOCK_ITEM_UNSET_FLAGS (item, GDL_DOCK_IN_DRAG);
-}
-
-static void
-gdl_dock_item_tab_button (GtkWidget *widget,
- GdkEventButton *event,
- gpointer data)
-{
- GdlDockItem *item;
- GtkAllocation allocation;
-
- item = GDL_DOCK_ITEM (data);
-
- if (!GDL_DOCK_ITEM_NOT_LOCKED (item))
- return;
-
- switch (event->button) {
- case 1:
- /* set dragoff_{x,y} as we the user clicked on the middle of the
- drag handle */
- switch (item->orientation) {
- case GTK_ORIENTATION_HORIZONTAL:
- gtk_widget_get_allocation (GTK_WIDGET (data), &allocation);
- /*item->dragoff_x = item->_priv->grip_size / 2;*/
- item->dragoff_y = allocation.height / 2;
- break;
- case GTK_ORIENTATION_VERTICAL:
- /*item->dragoff_x = GTK_WIDGET (data)->allocation.width / 2;*/
- item->dragoff_y = item->_priv->grip_size / 2;
- break;
- };
- gdl_dock_item_drag_start (item);
- break;
-
- case 3:
- gdl_dock_item_popup_menu (item, event->button, event->time);
- break;
-
- default:
- break;
- };
-}
-
-static void
-gdl_dock_item_hide_cb (GtkWidget *widget,
- GdlDockItem *item)
-{
- GdlDockMaster *master;
-
- g_return_if_fail (item != NULL);
-
- master = GDL_DOCK_OBJECT_GET_MASTER (item);
- gdl_dock_item_hide_item (item);
-}
-
-static void
-gdl_dock_item_lock_cb (GtkWidget *widget,
- GdlDockItem *item)
-{
- g_return_if_fail (item != NULL);
-
- gdl_dock_item_lock (item);
-}
-
-static void
-gdl_dock_item_unlock_cb (GtkWidget *widget,
- GdlDockItem *item)
-{
- g_return_if_fail (item != NULL);
-
- gdl_dock_item_unlock (item);
-}
-
-static void
-gdl_dock_item_showhide_grip (GdlDockItem *item)
-{
- GdkDisplay *display;
- GdkCursor *cursor;
-
- gdl_dock_item_detach_menu (GTK_WIDGET (item), NULL);
- display = gtk_widget_get_display (GTK_WIDGET (item));
- cursor = NULL;
-
- if (item->_priv->grip) {
- if (GDL_DOCK_ITEM_GRIP_SHOWN (item) &&
- GDL_DOCK_ITEM_NOT_LOCKED(item))
- cursor = gdk_cursor_new_for_display (display, GDK_HAND2);
- }
- if (item->_priv->grip && GDL_DOCK_ITEM_GRIP (item->_priv->grip)->title_window)
- gdk_window_set_cursor (GDL_DOCK_ITEM_GRIP (item->_priv->grip)->title_window, cursor);
-
- if (cursor)
- gdk_cursor_unref (cursor);
-
- gtk_widget_queue_resize (GTK_WIDGET (item));
-}
-
-static void
-gdl_dock_item_real_set_orientation (GdlDockItem *item,
- GtkOrientation orientation)
-{
- item->orientation = orientation;
-
- if (gtk_widget_is_drawable (GTK_WIDGET (item)))
- gtk_widget_queue_draw (GTK_WIDGET (item));
- gtk_widget_queue_resize (GTK_WIDGET (item));
-}
-
-
-/* ----- 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.
- **/
-GtkWidget *
-gdl_dock_item_new (const gchar *name,
- const gchar *long_name,
- GdlDockItemBehavior behavior)
-{
- GdlDockItem *item;
-
- item = GDL_DOCK_ITEM (g_object_new (GDL_TYPE_DOCK_ITEM,
- "name", name,
- "long-name", long_name,
- "behavior", behavior,
- NULL));
- GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_AUTOMATIC);
-
- 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.
- **/
-GtkWidget *
-gdl_dock_item_new_with_stock (const gchar *name,
- const gchar *long_name,
- const gchar *stock_id,
- GdlDockItemBehavior behavior)
-{
- GdlDockItem *item;
-
- item = GDL_DOCK_ITEM (g_object_new (GDL_TYPE_DOCK_ITEM,
- "name", name,
- "long-name", long_name,
- "stock-id", stock_id,
- "behavior", behavior,
- NULL));
- GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_AUTOMATIC);
-
- return GTK_WIDGET (item);
-}
-
-GtkWidget *
-gdl_dock_item_new_with_pixbuf_icon (const gchar *name,
- const gchar *long_name,
- const GdkPixbuf *pixbuf_icon,
- GdlDockItemBehavior behavior)
-{
- GdlDockItem *item;
-
- item = GDL_DOCK_ITEM (g_object_new (GDL_TYPE_DOCK_ITEM,
- "name", name,
- "long-name", long_name,
- "pixbuf-icon", pixbuf_icon,
- "behavior", behavior,
- NULL));
-
- GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_AUTOMATIC);
- gdl_dock_item_set_tablabel (item, gtk_label_new (long_name));
-
- 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
-gdl_dock_item_dock_to (GdlDockItem *item,
- GdlDockItem *target,
- GdlDockPlacement position,
- gint docking_param)
-{
- 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;
- }
-
- controller = gdl_dock_master_get_controller (GDL_DOCK_OBJECT_GET_MASTER (item));
-
- /* FIXME: save previous docking position for later
- re-docking... does this make sense now? */
-
- /* Create new floating dock for widget. */
- item->dragoff_x = item->dragoff_y = 0;
- gdl_dock_add_floating_item (GDL_DOCK (controller),
- item, 0, 0, -1, -1);
-
- } else
- gdl_dock_object_dock (GDL_DOCK_OBJECT (target),
- GDL_DOCK_OBJECT (item),
- position, NULL);
-}
-
-/**
- * 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
-gdl_dock_item_set_orientation (GdlDockItem *item,
- GtkOrientation orientation)
-{
- GParamSpec *pspec;
-
- g_return_if_fail (item != NULL);
-
- if (item->orientation != orientation) {
- /* push the property down the hierarchy if our child supports it */
- if (item->child != NULL) {
- pspec = g_object_class_find_property (
- G_OBJECT_GET_CLASS (item->child), "orientation");
- if (pspec && pspec->value_type == GTK_TYPE_ORIENTATION)
- g_object_set (G_OBJECT (item->child),
- "orientation", orientation,
- NULL);
- };
- if (GDL_DOCK_ITEM_GET_CLASS (item)->set_orientation)
- GDL_DOCK_ITEM_GET_CLASS (item)->set_orientation (item, orientation);
- g_object_notify (G_OBJECT (item), "orientation");
- }
-}
-
-/**
- * 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.
- **/
-GtkWidget *
-gdl_dock_item_get_tablabel (GdlDockItem *item)
-{
- g_return_val_if_fail (item != NULL, NULL);
- g_return_val_if_fail (GDL_IS_DOCK_ITEM (item), NULL);
-
- return item->_priv->tab_label;
-}
-
-/**
- * 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
-gdl_dock_item_set_tablabel (GdlDockItem *item,
- GtkWidget *tablabel)
-{
- g_return_if_fail (item != NULL);
-
- if (item->_priv->intern_tab_label)
- {
- item->_priv->intern_tab_label = FALSE;
- g_signal_handler_disconnect (item, item->_priv->notify_label);
- g_signal_handler_disconnect (item, item->_priv->notify_stock_id);
- }
-
- if (item->_priv->tab_label) {
- /* disconnect and unref the previous tablabel */
- if (GDL_IS_DOCK_TABLABEL (item->_priv->tab_label)) {
- g_signal_handlers_disconnect_matched (item->_priv->tab_label,
- G_SIGNAL_MATCH_DATA,
- 0, 0, NULL,
- NULL, item);
- g_object_set (item->_priv->tab_label, "item", NULL, NULL);
- }
- g_object_unref (item->_priv->tab_label);
- item->_priv->tab_label = NULL;
- }
-
- if (tablabel) {
- g_object_ref_sink (G_OBJECT (tablabel));
- item->_priv->tab_label = tablabel;
- if (GDL_IS_DOCK_TABLABEL (tablabel)) {
- g_object_set (tablabel, "item", item, NULL);
- /* connect to tablabel signal */
- g_signal_connect (tablabel, "button_pressed_handle",
- G_CALLBACK (gdl_dock_item_tab_button), item);
- }
- }
-}
-
-/**
- * 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.
- **/
-GtkWidget *
-gdl_dock_item_get_grip(GdlDockItem *item)
-{
- g_return_val_if_fail (item != NULL, NULL);
- g_return_val_if_fail (GDL_IS_DOCK_ITEM (item), NULL);
-
- return item->_priv->grip;
-}
-
-/**
- * gdl_dock_item_hide_grip:
- * @item: The dock item to hide the grip of.
- *
- * This function hides the dock item's grip widget.
- **/
-void
-gdl_dock_item_hide_grip (GdlDockItem *item)
-{
- g_return_if_fail (item != NULL);
- if (item->_priv->grip_shown) {
- item->_priv->grip_shown = FALSE;
- gdl_dock_item_showhide_grip (item);
- };
- 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_show_grip (GdlDockItem *item)
-{
- g_return_if_fail (item != NULL);
- if (!item->_priv->grip_shown) {
- item->_priv->grip_shown = TRUE;
- gdl_dock_item_showhide_grip (item);
- };
-}
-
-/**
- * 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
-gdl_dock_item_notify_selected (GdlDockItem *item)
-{
- g_signal_emit (item, gdl_dock_item_signals [SELECTED], 0);
-}
-
-/* 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
-gdl_dock_item_bind (GdlDockItem *item,
- GtkWidget *dock)
-{
- g_return_if_fail (item != NULL);
- g_return_if_fail (dock == NULL || GDL_IS_DOCK (dock));
-
- gdl_dock_object_bind (GDL_DOCK_OBJECT (item),
- G_OBJECT (GDL_DOCK_OBJECT_GET_MASTER (dock)));
-}
-
-/* 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_unbind (GdlDockItem *item)
-{
- g_return_if_fail (item != NULL);
-
- gdl_dock_object_unbind (GDL_DOCK_OBJECT (item));
-}
-
-/**
- * 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
-gdl_dock_item_hide_item (GdlDockItem *item)
-{
- GtkAllocation allocation;
-
- g_return_if_fail (item != NULL);
-
- if (!GDL_DOCK_OBJECT_ATTACHED (item))
- /* already hidden/detached */
- return;
-
- /* if the object is manual, create a new placeholder to be able to
- restore the position later */
- if (!GDL_DOCK_OBJECT_AUTOMATIC (item)) {
- if (item->_priv->ph)
- g_object_unref (item->_priv->ph);
-
- gboolean isFloating = FALSE;
- gint width=0, height=0, x=0, y = 0;
-
- if (GDL_IS_DOCK (gdl_dock_object_get_parent_object (GDL_DOCK_OBJECT (item))))
- {
- GdlDock* 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);
- } else {
- gtk_widget_get_allocation (GTK_WIDGET (item), &allocation);
- item->_priv->preferred_width = allocation.width;
- item->_priv->preferred_height = allocation.height;
- }
- item->_priv->ph = GDL_DOCK_PLACEHOLDER (
- g_object_new (GDL_TYPE_DOCK_PLACEHOLDER,
- "sticky", FALSE,
- "host", item,
- "width", width,
- "height", height,
- "floating", isFloating,
- "floatx", x,
- "floaty", y,
- NULL));
- g_object_ref_sink (item->_priv->ph);
- }
-
- gdl_dock_object_freeze (GDL_DOCK_OBJECT (item));
-
- /* hide our children first, so they can also set placeholders */
- if (gdl_dock_object_is_compound (GDL_DOCK_OBJECT (item)))
- gtk_container_foreach (GTK_CONTAINER (item),
- (GtkCallback) gdl_dock_item_hide_item,
- NULL);
-
- /* detach the item recursively */
- gdl_dock_object_detach (GDL_DOCK_OBJECT (item), TRUE);
-
- gtk_widget_hide (GTK_WIDGET (item));
-
- gdl_dock_object_thaw (GDL_DOCK_OBJECT (item));
-}
-
-/**
- * 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_iconify_item (GdlDockItem *item)
-{
- g_return_if_fail (item != NULL);
-
- GDL_DOCK_OBJECT_SET_FLAGS (item, GDL_DOCK_ICONIFIED);
- gdl_dock_item_hide_item (item);
-}
-
-/**
- * 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
-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) {
- gboolean isFloating=FALSE;
- gint width = 0, height = 0, x= 0, 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;
-
- 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));
-}
-
-/**
- * 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_lock (GdlDockItem *item)
-{
- g_object_set (item, "locked", TRUE, NULL);
-}
-
-/**
- * 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_unlock (GdlDockItem *item)
-{
- g_object_set (item, "locked", FALSE, NULL);
-}
-
-/**
- * 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
-gdl_dock_item_set_default_position (GdlDockItem *item,
- GdlDockObject *reference)
-{
- g_return_if_fail (item != NULL);
-
- if (item->_priv->ph) {
- g_object_unref (item->_priv->ph);
- item->_priv->ph = NULL;
- }
-
- if (reference && GDL_DOCK_OBJECT_ATTACHED (reference)) {
- if (GDL_IS_DOCK_PLACEHOLDER (reference)) {
- g_object_ref_sink (reference);
- item->_priv->ph = GDL_DOCK_PLACEHOLDER (reference);
- } else {
- item->_priv->ph = GDL_DOCK_PLACEHOLDER (
- g_object_new (GDL_TYPE_DOCK_PLACEHOLDER,
- "sticky", TRUE,
- "host", reference,
- NULL));
- g_object_ref_sink (item->_priv->ph);
- }
- }
-}
-
-/**
- * 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
-gdl_dock_item_preferred_size (GdlDockItem *item,
- GtkRequisition *req)
-{
- GtkAllocation allocation;
-
- if (!req)
- return;
-
- gtk_widget_get_allocation (GTK_WIDGET (item), &allocation);
-
- req->width = MAX (item->_priv->preferred_width, allocation.width);
- req->height = MAX (item->_priv->preferred_height, allocation.height);
-}
-
-
-gboolean
-gdl_dock_item_or_child_has_focus (GdlDockItem *item)
-{
- GtkWidget *item_child;
- gboolean item_or_child_has_focus;
-
- g_return_val_if_fail (GDL_IS_DOCK_ITEM (item), FALSE);
-
- for (item_child = gtk_container_get_focus_child (GTK_CONTAINER (item));
- item_child && GTK_IS_CONTAINER (item_child) && gtk_container_get_focus_child (GTK_CONTAINER (item_child));
- item_child = gtk_container_get_focus_child (GTK_CONTAINER (item_child))) ;
-
- item_or_child_has_focus =
- (gtk_widget_has_focus (GTK_WIDGET (item)) ||
- (GTK_IS_WIDGET (item_child) && gtk_widget_has_focus (item_child)));
-
- return item_or_child_has_focus;
-}
-
-
-/* ----- gtk orientation type exporter/importer ----- */
-
-static void
-gdl_dock_param_export_gtk_orientation (const GValue *src,
- GValue *dst)
-{
- dst->data [0].v_pointer =
- g_strdup_printf ("%s", (src->data [0].v_int == GTK_ORIENTATION_HORIZONTAL) ?
- "horizontal" : "vertical");
-}
-
-static void
-gdl_dock_param_import_gtk_orientation (const GValue *src,
- GValue *dst)
-{
- if (!strcmp (src->data [0].v_pointer, "horizontal"))
- dst->data [0].v_int = GTK_ORIENTATION_HORIZONTAL;
- else
- dst->data [0].v_int = GTK_ORIENTATION_VERTICAL;
-}
-
diff --git a/src/libgdl/gdl-dock-item.h b/src/libgdl/gdl-dock-item.h
deleted file mode 100644
index b9378f783..000000000
--- a/src/libgdl/gdl-dock-item.h
+++ /dev/null
@@ -1,223 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * gdl-dock-item.h
- *
- * Author: Gustavo Giráldez <gustavo.giraldez@gmx.net>
- *
- * 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.
- *
- * This library is free software; you can redistribute it and/or
- * 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.
- */
-
-#ifndef __GDL_DOCK_ITEM_H__
-#define __GDL_DOCK_ITEM_H__
-
-#include "libgdl/gdl-dock-object.h"
-
-G_BEGIN_DECLS
-
-/* standard macros */
-#define GDL_TYPE_DOCK_ITEM (gdl_dock_item_get_type ())
-#define GDL_DOCK_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_ITEM, GdlDockItem))
-#define GDL_DOCK_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_ITEM, GdlDockItemClass))
-#define GDL_IS_DOCK_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_ITEM))
-#define GDL_IS_DOCK_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_ITEM))
-#define GDL_DOCK_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_ITEM, GdlDockItemClass))
-
-/**
- * GdlDockItemBehavior:
- * @GDL_DOCK_ITEM_BEH_NORMAL: Normal dock item
- * @GDL_DOCK_ITEM_BEH_NEVER_FLOATING: item cannot be undocked
- * @GDL_DOCK_ITEM_BEH_NEVER_VERTICAL: item cannot be docked vertically
- * @GDL_DOCK_ITEM_BEH_NEVER_HORIZONTAL: item cannot be docked horizontally
- * @GDL_DOCK_ITEM_BEH_LOCKED: item is locked, it cannot be moved around
- * @GDL_DOCK_ITEM_BEH_CANT_DOCK_TOP: item cannot be docked at top
- * @GDL_DOCK_ITEM_BEH_CANT_DOCK_BOTTOM: item cannot be docked at bottom
- * @GDL_DOCK_ITEM_BEH_CANT_DOCK_LEFT: item cannot be docked left
- * @GDL_DOCK_ITEM_BEH_CANT_DOCK_RIGHT: item cannot be docked right
- * @GDL_DOCK_ITEM_BEH_CANT_DOCK_CENTER: item cannot be docked at center
- * @GDL_DOCK_ITEM_BEH_CANT_CLOSE: item cannot be closed
- * @GDL_DOCK_ITEM_BEH_CANT_ICONIFY: item cannot be iconified
- * @GDL_DOCK_ITEM_BEH_NO_GRIP: item doesn't have a grip
- *
- * Described the behaviour of a doc item. The item can have multiple flags set.
- *
- **/
-
-typedef enum {
- GDL_DOCK_ITEM_BEH_NORMAL = 0,
- GDL_DOCK_ITEM_BEH_NEVER_FLOATING = 1 << 0,
- GDL_DOCK_ITEM_BEH_NEVER_VERTICAL = 1 << 1,
- GDL_DOCK_ITEM_BEH_NEVER_HORIZONTAL = 1 << 2,
- GDL_DOCK_ITEM_BEH_LOCKED = 1 << 3,
- GDL_DOCK_ITEM_BEH_CANT_DOCK_TOP = 1 << 4,
- GDL_DOCK_ITEM_BEH_CANT_DOCK_BOTTOM = 1 << 5,
- GDL_DOCK_ITEM_BEH_CANT_DOCK_LEFT = 1 << 6,
- GDL_DOCK_ITEM_BEH_CANT_DOCK_RIGHT = 1 << 7,
- GDL_DOCK_ITEM_BEH_CANT_DOCK_CENTER = 1 << 8,
- GDL_DOCK_ITEM_BEH_CANT_CLOSE = 1 << 9,
- GDL_DOCK_ITEM_BEH_CANT_ICONIFY = 1 << 10,
- GDL_DOCK_ITEM_BEH_NO_GRIP = 1 << 11
-} GdlDockItemBehavior;
-
-
-/**
- * GdlDockItemFlags:
- * @GDL_DOCK_IN_DRAG: item is in a drag operation
- * @GDL_DOCK_IN_PREDRAG: item is in a predrag operation
- * @GDL_DOCK_ICONIFIED: item is iconified
- * @GDL_DOCK_USER_ACTION: indicates the user has started an action on the dock item
- *
- * Status flag of a GdlDockItem. Don't use unless you derive a widget from GdlDockItem
- *
- **/
-typedef enum {
- GDL_DOCK_IN_DRAG = 1 << GDL_DOCK_OBJECT_FLAGS_SHIFT,
- GDL_DOCK_IN_PREDRAG = 1 << (GDL_DOCK_OBJECT_FLAGS_SHIFT + 1),
- GDL_DOCK_ICONIFIED = 1 << (GDL_DOCK_OBJECT_FLAGS_SHIFT + 2),
- GDL_DOCK_USER_ACTION = 1 << (GDL_DOCK_OBJECT_FLAGS_SHIFT + 3)
-} GdlDockItemFlags;
-
-typedef struct _GdlDockItem GdlDockItem;
-typedef struct _GdlDockItemClass GdlDockItemClass;
-typedef struct _GdlDockItemPrivate GdlDockItemPrivate;
-
-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 */
- GdlDockItemPrivate *_priv;
-};
-
-struct _GdlDockItemClass {
- GdlDockObjectClass parent_class;
-
- gboolean has_grip;
-
- /* virtuals */
- void (* dock_drag_begin) (GdlDockItem *item);
- void (* dock_drag_motion) (GdlDockItem *item,
- gint x,
- gint y);
- void (* dock_drag_end) (GdlDockItem *item,
- gboolean cancelled);
- void (* move_focus_child) (GdlDockItem *item,
- GtkDirectionType direction);
- void (* set_orientation) (GdlDockItem *item,
- GtkOrientation orientation);
-};
-
-#define GDL_DOCK_ITEM_FLAGS(item) (GDL_DOCK_OBJECT (item)->flags)
-#define GDL_DOCK_ITEM_IN_DRAG(item) \
- ((GDL_DOCK_ITEM_FLAGS (item) & GDL_DOCK_IN_DRAG) != 0)
-#define GDL_DOCK_ITEM_IN_PREDRAG(item) \
- ((GDL_DOCK_ITEM_FLAGS (item) & GDL_DOCK_IN_PREDRAG) != 0)
-#define GDL_DOCK_ITEM_ICONIFIED(item) \
- ((GDL_DOCK_ITEM_FLAGS (item) & GDL_DOCK_ICONIFIED) != 0)
-#define GDL_DOCK_ITEM_USER_ACTION(item) \
- ((GDL_DOCK_ITEM_FLAGS (item) & GDL_DOCK_USER_ACTION) != 0)
-#define GDL_DOCK_ITEM_NOT_LOCKED(item) !((item)->behavior & GDL_DOCK_ITEM_BEH_LOCKED)
-#define GDL_DOCK_ITEM_NO_GRIP(item) ((item)->behavior & GDL_DOCK_ITEM_BEH_NO_GRIP)
-
-#define GDL_DOCK_ITEM_SET_FLAGS(item,flag) \
- G_STMT_START { (GDL_DOCK_ITEM_FLAGS (item) |= (flag)); } G_STMT_END
-#define GDL_DOCK_ITEM_UNSET_FLAGS(item,flag) \
- G_STMT_START { (GDL_DOCK_ITEM_FLAGS (item) &= ~(flag)); } G_STMT_END
-
-#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_CANT_CLOSE(item) \
- ((((item)->behavior & GDL_DOCK_ITEM_BEH_CANT_CLOSE) != 0)|| \
- ! GDL_DOCK_ITEM_NOT_LOCKED(item))
-
-#define GDL_DOCK_ITEM_CANT_ICONIFY(item) \
- ((((item)->behavior & GDL_DOCK_ITEM_BEH_CANT_ICONIFY) != 0)|| \
- ! GDL_DOCK_ITEM_NOT_LOCKED(item))
-
-/* 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);
-
-/* bind and unbind items to a 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_lock (GdlDockItem *item);
-
-void gdl_dock_item_unlock (GdlDockItem *item);
-
-void gdl_dock_item_set_default_position (GdlDockItem *item,
- GdlDockObject *reference);
-
-void gdl_dock_item_preferred_size (GdlDockItem *item,
- GtkRequisition *req);
-
-gboolean gdl_dock_item_or_child_has_focus (GdlDockItem *item);
-
-G_END_DECLS
-
-#endif
diff --git a/src/libgdl/gdl-dock-master.c b/src/libgdl/gdl-dock-master.c
deleted file mode 100644
index 294614c7e..000000000
--- a/src/libgdl/gdl-dock-master.c
+++ /dev/null
@@ -1,1011 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * gdl-dock-master.c - Object which manages a dock ring
- *
- * This file is part of the GNOME Devtools Libraries.
- *
- * Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net>
- *
- * This library is free software; you can redistribute it and/or
- * 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 "gdl-dock-master.h"
-#include "gdl-dock.h"
-#include "gdl-dock-item.h"
-#include "gdl-dock-notebook.h"
-#include "gdl-switcher.h"
-#include "libgdlmarshal.h"
-#include "libgdltypebuiltins.h"
-#ifdef WIN32
-#include "gdl-win32.h"
-#endif
-
-/* ----- Private prototypes ----- */
-
-static void gdl_dock_master_class_init (GdlDockMasterClass *klass);
-
-static void gdl_dock_master_dispose (GObject *g_object);
-static void gdl_dock_master_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gdl_dock_master_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static void _gdl_dock_master_remove (GdlDockObject *object,
- GdlDockMaster *master);
-
-static void gdl_dock_master_drag_begin (GdlDockItem *item,
- gpointer data);
-static void gdl_dock_master_drag_end (GdlDockItem *item,
- gboolean cancelled,
- gpointer data);
-static void gdl_dock_master_drag_motion (GdlDockItem *item,
- gint x,
- gint y,
- gpointer data);
-
-static void _gdl_dock_master_foreach (gpointer key,
- gpointer value,
- gpointer user_data);
-
-static void gdl_dock_master_xor_rect (GdlDockMaster *master);
-
-static void gdl_dock_master_layout_changed (GdlDockMaster *master);
-
-static void gdl_dock_master_set_switcher_style (GdlDockMaster *master,
- GdlSwitcherStyle switcher_style);
-
-/* ----- Private data types and variables ----- */
-
-enum {
- PROP_0,
- PROP_DEFAULT_TITLE,
- PROP_LOCKED,
- PROP_SWITCHER_STYLE
-};
-
-enum {
- LAYOUT_CHANGED,
- LAST_SIGNAL
-};
-
-struct _GdlDockMasterPrivate {
- gint number; /* for naming nameless manual objects */
- gchar *default_title;
-
- GdkGC *root_xor_gc;
- gboolean rect_drawn;
- GdlDock *rect_owner;
-
- GdlDockRequest *drag_request;
-
- /* source id for the idle handler to emit a layout_changed signal */
- guint idle_layout_changed_id;
-
- /* hashes to quickly calculate the overall locked status: i.e.
- * if size(unlocked_items) == 0 then locked = 1
- * else if size(locked_items) == 0 then locked = 0
- * else locked = -1
- */
- GHashTable *locked_items;
- GHashTable *unlocked_items;
-
- GdlSwitcherStyle switcher_style;
-};
-
-#define COMPUTE_LOCKED(master) \
- (g_hash_table_size ((master)->_priv->unlocked_items) == 0 ? 1 : \
- (g_hash_table_size ((master)->_priv->locked_items) == 0 ? 0 : -1))
-
-static guint master_signals [LAST_SIGNAL] = { 0 };
-
-
-/* ----- Private interface ----- */
-
-G_DEFINE_TYPE (GdlDockMaster, gdl_dock_master, G_TYPE_OBJECT);
-
-static void
-gdl_dock_master_class_init (GdlDockMasterClass *klass)
-{
- GObjectClass *g_object_class;
-
- g_object_class = G_OBJECT_CLASS (klass);
-
- g_object_class->dispose = gdl_dock_master_dispose;
- g_object_class->set_property = gdl_dock_master_set_property;
- g_object_class->get_property = gdl_dock_master_get_property;
-
- g_object_class_install_property (
- g_object_class, PROP_DEFAULT_TITLE,
- g_param_spec_string ("default-title", _("Default title"),
- _("Default title for newly created floating docks"),
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- g_object_class, PROP_LOCKED,
- g_param_spec_int ("locked", _("Locked"),
- _("If is set to 1, all the dock items bound to the master "
- "are locked; if it's 0, all are unlocked; -1 indicates "
- "inconsistency among the items"),
- -1, 1, 0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- g_object_class, PROP_SWITCHER_STYLE,
- g_param_spec_enum ("switcher-style", _("Switcher Style"),
- _("Switcher buttons style"),
- GDL_TYPE_SWITCHER_STYLE,
- GDL_SWITCHER_STYLE_BOTH,
- G_PARAM_READWRITE));
-
- master_signals [LAYOUT_CHANGED] =
- g_signal_new ("layout-changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdlDockMasterClass, layout_changed),
- NULL, /* accumulator */
- NULL, /* accu_data */
- gdl_marshal_VOID__VOID,
- G_TYPE_NONE, /* return type */
- 0);
-
- klass->layout_changed = gdl_dock_master_layout_changed;
-}
-
-static void
-gdl_dock_master_init (GdlDockMaster *master)
-{
- master->dock_objects = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, NULL);
- master->toplevel_docks = NULL;
- master->controller = NULL;
- master->dock_number = 1;
-
- master->_priv = g_new0 (GdlDockMasterPrivate, 1);
- master->_priv->number = 1;
- master->_priv->switcher_style = GDL_SWITCHER_STYLE_BOTH;
- master->_priv->locked_items = g_hash_table_new (g_direct_hash, g_direct_equal);
- master->_priv->unlocked_items = g_hash_table_new (g_direct_hash, g_direct_equal);
-}
-
-static void
-_gdl_dock_master_remove (GdlDockObject *object,
- GdlDockMaster *master)
-{
- g_return_if_fail (master != NULL && object != NULL);
-
- if (GDL_IS_DOCK (object)) {
- GList *found_link;
-
- found_link = g_list_find (master->toplevel_docks, object);
- if (found_link)
- master->toplevel_docks = g_list_delete_link (master->toplevel_docks,
- found_link);
- if (object == master->controller) {
- GList *last;
- GdlDockObject *new_controller = NULL;
-
- /* now find some other non-automatic toplevel to use as a
- new controller. start from the last dock, since it's
- probably a non-floating and manual */
- last = g_list_last (master->toplevel_docks);
- while (last) {
- if (!GDL_DOCK_OBJECT_AUTOMATIC (last->data)) {
- new_controller = GDL_DOCK_OBJECT (last->data);
- break;
- }
- last = last->prev;
- };
-
- if (new_controller) {
- /* the new controller gets the ref (implicitly of course) */
- master->controller = new_controller;
- } else {
- master->controller = NULL;
- /* no controller, no master */
- g_object_unref (master);
- }
- }
- }
- /* disconnect dock object signals */
- g_signal_handlers_disconnect_matched (object, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, master);
-
- /* unref the object from the hash if it's there */
- if (object->name) {
- GdlDockObject *found_object;
- found_object = g_hash_table_lookup (master->dock_objects, object->name);
- if (found_object == object) {
- g_hash_table_remove (master->dock_objects, object->name);
- g_object_unref (object);
- }
- }
-}
-
-static void
-ht_foreach_build_slist (gpointer key,
- gpointer value,
- GSList **slist)
-{
- *slist = g_slist_prepend (*slist, value);
-}
-
-static void
-gdl_dock_master_dispose (GObject *g_object)
-{
- GdlDockMaster *master;
-
- g_return_if_fail (GDL_IS_DOCK_MASTER (g_object));
-
- master = GDL_DOCK_MASTER (g_object);
-
- if (master->toplevel_docks) {
- g_list_foreach (master->toplevel_docks,
- (GFunc) gdl_dock_object_unbind, NULL);
- g_list_free (master->toplevel_docks);
- master->toplevel_docks = NULL;
- }
-
- if (master->dock_objects) {
- GSList *alive_docks = NULL;
- g_hash_table_foreach (master->dock_objects,
- (GHFunc) ht_foreach_build_slist, &alive_docks);
- while (alive_docks) {
- gdl_dock_object_unbind (GDL_DOCK_OBJECT (alive_docks->data));
- alive_docks = g_slist_delete_link (alive_docks, alive_docks);
- }
-
- g_hash_table_destroy (master->dock_objects);
- master->dock_objects = NULL;
- }
-
- if (master->_priv) {
- if (master->_priv->idle_layout_changed_id)
- g_source_remove (master->_priv->idle_layout_changed_id);
-
- if (master->_priv->root_xor_gc) {
- g_object_unref (master->_priv->root_xor_gc);
- master->_priv->root_xor_gc = NULL;
- }
- if (master->_priv->drag_request) {
- if (G_IS_VALUE (&master->_priv->drag_request->extra))
- g_value_unset (&master->_priv->drag_request->extra);
- g_free (master->_priv->drag_request);
- master->_priv->drag_request = NULL;
- }
- g_free (master->_priv->default_title);
- master->_priv->default_title = NULL;
-
- g_hash_table_destroy (master->_priv->locked_items);
- master->_priv->locked_items = NULL;
- g_hash_table_destroy (master->_priv->unlocked_items);
- master->_priv->unlocked_items = NULL;
-
- g_free (master->_priv);
- master->_priv = NULL;
- }
-
- G_OBJECT_CLASS (gdl_dock_master_parent_class)->dispose (g_object);
-}
-
-static void
-foreach_lock_unlock (GdlDockItem *item,
- gboolean locked)
-{
- if (!GDL_IS_DOCK_ITEM (item))
- return;
-
- g_object_set (item, "locked", locked, NULL);
- if (gdl_dock_object_is_compound (GDL_DOCK_OBJECT (item)))
- gtk_container_foreach (GTK_CONTAINER (item),
- (GtkCallback) foreach_lock_unlock,
- GINT_TO_POINTER (locked));
-}
-
-static void
-gdl_dock_master_lock_unlock (GdlDockMaster *master,
- gboolean locked)
-{
- GList *l;
-
- for (l = master->toplevel_docks; l; l = l->next) {
- GdlDock *dock = GDL_DOCK (l->data);
- if (dock->root)
- foreach_lock_unlock (GDL_DOCK_ITEM (dock->root), locked);
- }
-
- /* just to be sure hidden items are set too */
- gdl_dock_master_foreach (master,
- (GFunc) foreach_lock_unlock,
- GINT_TO_POINTER (locked));
-}
-
-static void
-gdl_dock_master_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GdlDockMaster *master = GDL_DOCK_MASTER (object);
-
- switch (prop_id) {
- case PROP_DEFAULT_TITLE:
- g_free (master->_priv->default_title);
- master->_priv->default_title = g_value_dup_string (value);
- break;
- case PROP_LOCKED:
- if (g_value_get_int (value) >= 0)
- gdl_dock_master_lock_unlock (master, (g_value_get_int (value) > 0));
- break;
- case PROP_SWITCHER_STYLE:
- gdl_dock_master_set_switcher_style (master, g_value_get_enum (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gdl_dock_master_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GdlDockMaster *master = GDL_DOCK_MASTER (object);
-
- switch (prop_id) {
- case PROP_DEFAULT_TITLE:
- g_value_set_string (value, master->_priv->default_title);
- break;
- case PROP_LOCKED:
- g_value_set_int (value, COMPUTE_LOCKED (master));
- break;
- case PROP_SWITCHER_STYLE:
- g_value_set_enum (value, master->_priv->switcher_style);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gdl_dock_master_drag_begin (GdlDockItem *item,
- gpointer data)
-{
- GdlDockMaster *master;
- GdlDockRequest *request;
-
- g_return_if_fail (data != NULL);
- g_return_if_fail (item != NULL);
-
- master = GDL_DOCK_MASTER (data);
-
- if (!master->_priv->drag_request)
- master->_priv->drag_request = g_new0 (GdlDockRequest, 1);
-
- request = master->_priv->drag_request;
-
- /* Set the target to itself so it won't go floating with just a click. */
- request->applicant = GDL_DOCK_OBJECT (item);
- request->target = GDL_DOCK_OBJECT (item);
- request->position = GDL_DOCK_FLOATING;
- if (G_IS_VALUE (&request->extra))
- g_value_unset (&request->extra);
-
- master->_priv->rect_drawn = FALSE;
- master->_priv->rect_owner = NULL;
-}
-
-static void
-gdl_dock_master_drag_end (GdlDockItem *item,
- gboolean cancelled,
- gpointer data)
-{
- GdlDockMaster *master;
- GdlDockRequest *request;
-
- g_return_if_fail (data != NULL);
- g_return_if_fail (item != NULL);
-
- master = GDL_DOCK_MASTER (data);
- request = master->_priv->drag_request;
-
- g_return_if_fail (GDL_DOCK_OBJECT (item) == request->applicant);
-
- /* Erase previously drawn rectangle */
- if (master->_priv->rect_drawn)
- gdl_dock_master_xor_rect (master);
-
- /* cancel conditions */
- if (cancelled || request->applicant == request->target)
- return;
-
- /* dock object to the requested position */
- gdl_dock_object_dock (request->target,
- request->applicant,
- request->position,
- &request->extra);
-
- g_signal_emit (master, master_signals [LAYOUT_CHANGED], 0);
-}
-
-static void
-gdl_dock_master_drag_motion (GdlDockItem *item,
- gint root_x,
- gint root_y,
- gpointer data)
-{
- GdlDockMaster *master;
- GdlDockRequest my_request, *request;
- GdkWindow *window;
- GdkWindow *widget_window;
- gint win_x, win_y;
- gint x, y;
- GdlDock *dock = NULL;
- gboolean may_dock = FALSE;
-
- g_return_if_fail (item != NULL && data != NULL);
-
- master = GDL_DOCK_MASTER (data);
- request = master->_priv->drag_request;
-
- g_return_if_fail (GDL_DOCK_OBJECT (item) == request->applicant);
-
- my_request = *request;
-
- /* first look under the pointer */
- window = gdk_window_at_pointer (&win_x, &win_y);
- if (window) {
- GtkWidget *widget;
- /* ok, now get the widget who owns that window and see if we can
- get to a GdlDock by walking up the hierarchy */
- gdk_window_get_user_data (window, (gpointer) &widget);
- if (GTK_IS_WIDGET (widget)) {
- while (widget && (!GDL_IS_DOCK (widget) ||
- GDL_DOCK_OBJECT_GET_MASTER (widget) != master))
- widget = gtk_widget_get_parent (widget);
- if (widget) {
- gint win_w, win_h;
-
- widget_window = gtk_widget_get_window (widget);
-
- /* verify that the pointer is still in that dock
- (the user could have moved it) */
- gdk_window_get_geometry (widget_window,
- NULL, NULL, &win_w, &win_h, NULL);
- gdk_window_get_origin (widget_window, &win_x, &win_y);
- if (root_x >= win_x && root_x < win_x + win_w &&
- root_y >= win_y && root_y < win_y + win_h)
- dock = GDL_DOCK (widget);
- }
- }
- }
-
- if (dock) {
- GdkWindow *dock_window = gtk_widget_get_window (GTK_WIDGET (dock));
-
- /* translate root coordinates into dock object coordinates
- (i.e. widget coordinates) */
- gdk_window_get_origin (dock_window, &win_x, &win_y);
- x = root_x - win_x;
- y = root_y - win_y;
- may_dock = gdl_dock_object_dock_request (GDL_DOCK_OBJECT (dock),
- x, y, &my_request);
- }
- 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) {
- GdkWindow *dock_window;
- dock = GDL_DOCK (l->data);
- dock_window = gtk_widget_get_window (GTK_WIDGET (dock));
- /* translate root coordinates into dock object coordinates
- (i.e. widget coordinates) */
- gdk_window_get_origin (dock_window, &win_x, &win_y);
- x = root_x - win_x;
- y = root_y - win_y;
- may_dock = gdl_dock_object_dock_request (GDL_DOCK_OBJECT (dock),
- x, y, &my_request);
- if (may_dock)
- 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));
- 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;
-
- /* setup extra docking information */
- if (G_IS_VALUE (&my_request.extra))
- g_value_unset (&my_request.extra);
-
- 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))
- return;
-
- if (!(my_request.rect.x == request->rect.x &&
- my_request.rect.y == request->rect.y &&
- my_request.rect.width == request->rect.width &&
- my_request.rect.height == request->rect.height &&
- dock == master->_priv->rect_owner)) {
-
- /* erase the previous rectangle */
- if (master->_priv->rect_drawn)
- gdl_dock_master_xor_rect (master);
- }
-
- /* set the new values */
- *request = my_request;
- master->_priv->rect_owner = dock;
-
- /* draw the previous rectangle */
- if (~master->_priv->rect_drawn)
- gdl_dock_master_xor_rect (master);
-}
-
-static void
-_gdl_dock_master_foreach (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- struct {
- GFunc function;
- gpointer user_data;
- } *data = user_data;
-
- (* data->function) (GTK_WIDGET (value), data->user_data);
-}
-
-static void
-gdl_dock_master_xor_rect (GdlDockMaster *master)
-{
- gint8 dash_list [2];
- GdkWindow *window;
- GdkRectangle *rect;
-
- if (!master->_priv || !master->_priv->drag_request)
- return;
-
- master->_priv->rect_drawn = ~master->_priv->rect_drawn;
-
- if (master->_priv->rect_owner) {
- gdl_dock_xor_rect (master->_priv->rect_owner,
- &master->_priv->drag_request->rect);
- return;
- }
-
- rect = &master->_priv->drag_request->rect;
- window = gdk_get_default_root_window ();
-
- if (!master->_priv->root_xor_gc) {
- GdkGCValues values;
-
- values.function = GDK_INVERT;
- values.subwindow_mode = GDK_INCLUDE_INFERIORS;
- master->_priv->root_xor_gc = gdk_gc_new_with_values (
- window, &values, GDK_GC_FUNCTION | GDK_GC_SUBWINDOW);
- };
-
-#ifdef WIN32
- GdkLineStyle lineStyle = GDK_LINE_ON_OFF_DASH;
- if (is_os_vista())
- {
- // On Vista the dash-line is increadibly slow to draw, it takes several minutes to draw the tracking lines
- // With GDK_LINE_SOLID it is parts of a second
- // No performance issue on WinXP
- lineStyle = GDK_LINE_SOLID;
- }
-#else
- GdkLineStyle lineStyle = GDK_LINE_ON_OFF_DASH;
-#endif
- gdk_gc_set_line_attributes (master->_priv->root_xor_gc, 1,
- lineStyle,
- GDK_CAP_NOT_LAST,
- GDK_JOIN_BEVEL);
-
- dash_list[0] = 1;
- dash_list[1] = 1;
- gdk_gc_set_dashes (master->_priv->root_xor_gc, 1, dash_list, 2);
-
- gdk_draw_rectangle (window, master->_priv->root_xor_gc, 0,
- rect->x, rect->y,
- rect->width, rect->height);
-
- gdk_gc_set_dashes (master->_priv->root_xor_gc, 0, dash_list, 2);
-
- gdk_draw_rectangle (window, master->_priv->root_xor_gc, 0,
- rect->x + 1, rect->y + 1,
- rect->width - 2, rect->height - 2);
-}
-
-static void
-gdl_dock_master_layout_changed (GdlDockMaster *master)
-{
- g_return_if_fail (GDL_IS_DOCK_MASTER (master));
-
- /* emit "layout-changed" on the controller to notify the user who
- * normally shouldn't have access to us */
- if (master->controller)
- g_signal_emit_by_name (master->controller, "layout-changed");
-
- /* remove the idle handler if there is one */
- if (master->_priv->idle_layout_changed_id) {
- g_source_remove (master->_priv->idle_layout_changed_id);
- master->_priv->idle_layout_changed_id = 0;
- }
-}
-
-static gboolean
-idle_emit_layout_changed (gpointer user_data)
-{
- GdlDockMaster *master = user_data;
-
- g_return_val_if_fail (master && GDL_IS_DOCK_MASTER (master), FALSE);
-
- master->_priv->idle_layout_changed_id = 0;
- g_signal_emit (master, master_signals [LAYOUT_CHANGED], 0);
-
- return FALSE;
-}
-
-static void
-item_dock_cb (GdlDockObject *object,
- GdlDockObject *requestor,
- GdlDockPlacement position,
- GValue *other_data,
- gpointer user_data)
-{
- GdlDockMaster *master = user_data;
-
- g_return_if_fail (requestor && GDL_IS_DOCK_OBJECT (requestor));
- g_return_if_fail (master && GDL_IS_DOCK_MASTER (master));
-
- /* here we are in fact interested in the requestor, since it's
- * assumed that object will not change its visibility... for the
- * requestor, however, could mean that it's being shown */
- if (!GDL_DOCK_OBJECT_IN_REFLOW (requestor) &&
- !GDL_DOCK_OBJECT_AUTOMATIC (requestor)) {
- if (!master->_priv->idle_layout_changed_id)
- master->_priv->idle_layout_changed_id =
- g_idle_add (idle_emit_layout_changed, master);
- }
-}
-
-static void
-item_detach_cb (GdlDockObject *object,
- gboolean recursive,
- gpointer user_data)
-{
- GdlDockMaster *master = user_data;
-
- g_return_if_fail (object && GDL_IS_DOCK_OBJECT (object));
- g_return_if_fail (master && GDL_IS_DOCK_MASTER (master));
-
- if (!GDL_DOCK_OBJECT_IN_REFLOW (object) &&
- !GDL_DOCK_OBJECT_AUTOMATIC (object)) {
- if (!master->_priv->idle_layout_changed_id)
- master->_priv->idle_layout_changed_id =
- g_idle_add (idle_emit_layout_changed, master);
- }
-}
-
-static void
-item_notify_cb (GdlDockObject *object,
- GParamSpec *pspec,
- gpointer user_data)
-{
- GdlDockMaster *master = user_data;
- gint locked = COMPUTE_LOCKED (master);
- gboolean item_locked;
-
- g_object_get (object, "locked", &item_locked, NULL);
-
- if (item_locked) {
- g_hash_table_remove (master->_priv->unlocked_items, object);
- g_hash_table_insert (master->_priv->locked_items, object, NULL);
- } else {
- g_hash_table_remove (master->_priv->locked_items, object);
- g_hash_table_insert (master->_priv->unlocked_items, object, NULL);
- }
-
- if (COMPUTE_LOCKED (master) != locked)
- g_object_notify (G_OBJECT (master), "locked");
-}
-
-/* ----- Public interface ----- */
-
-void
-gdl_dock_master_add (GdlDockMaster *master,
- GdlDockObject *object)
-{
- g_return_if_fail (master != NULL && object != NULL);
-
- if (!GDL_DOCK_OBJECT_AUTOMATIC (object)) {
- GdlDockObject *found_object;
-
- /* create a name for the object if it doesn't have one */
- if (!object->name)
- /* directly set the name, since it's a construction only
- property */
- object->name = g_strdup_printf ("__dock_%u", master->_priv->number++);
-
- /* add the object to our hash list */
- if ((found_object = g_hash_table_lookup (master->dock_objects, object->name))) {
- g_warning (_("master %p: unable to add object %p[%s] to the hash. "
- "There already is an item with that name (%p)."),
- master, object, object->name, found_object);
- }
- else {
- g_object_ref_sink (object);
- g_hash_table_insert (master->dock_objects, g_strdup (object->name), object);
- }
- }
-
- if (GDL_IS_DOCK (object)) {
- gboolean floating;
-
- /* if this is the first toplevel we are adding, name it controller */
- if (!master->toplevel_docks)
- /* the dock should already have the ref */
- master->controller = object;
-
- /* add dock to the toplevel list */
- g_object_get (object, "floating", &floating, NULL);
- if (floating)
- master->toplevel_docks = g_list_prepend (master->toplevel_docks, object);
- else
- master->toplevel_docks = g_list_append (master->toplevel_docks, object);
-
- /* we are interested in the dock request this toplevel
- * receives to update the layout */
- g_signal_connect (object, "dock",
- G_CALLBACK (item_dock_cb), master);
-
- }
- else if (GDL_IS_DOCK_ITEM (object)) {
- /* we need to connect the item's signals */
- g_signal_connect (object, "dock_drag_begin",
- G_CALLBACK (gdl_dock_master_drag_begin), master);
- g_signal_connect (object, "dock_drag_motion",
- G_CALLBACK (gdl_dock_master_drag_motion), master);
- g_signal_connect (object, "dock_drag_end",
- G_CALLBACK (gdl_dock_master_drag_end), master);
- g_signal_connect (object, "dock",
- G_CALLBACK (item_dock_cb), master);
- g_signal_connect (object, "detach",
- G_CALLBACK (item_detach_cb), master);
-
- /* register to "locked" notification if the item has a grip,
- * and add the item to the corresponding hash */
- if (GDL_DOCK_ITEM_HAS_GRIP (GDL_DOCK_ITEM (object))) {
- g_signal_connect (object, "notify::locked",
- G_CALLBACK (item_notify_cb), master);
- item_notify_cb (object, NULL, master);
- }
-
- /* If the item is notebook, set the switcher style */
- if (GDL_IS_DOCK_NOTEBOOK (object) &&
- GDL_IS_SWITCHER (GDL_DOCK_ITEM (object)->child))
- {
- g_object_set (GDL_DOCK_ITEM (object)->child, "switcher-style",
- master->_priv->switcher_style, NULL);
- }
-
- /* post a layout_changed emission if the item is not automatic
- * (since it should be added to the items model) */
- if (!GDL_DOCK_OBJECT_AUTOMATIC (object)) {
- if (!master->_priv->idle_layout_changed_id)
- master->_priv->idle_layout_changed_id =
- g_idle_add (idle_emit_layout_changed, master);
- }
- }
-}
-
-void
-gdl_dock_master_remove (GdlDockMaster *master,
- GdlDockObject *object)
-{
- g_return_if_fail (master != NULL && object != NULL);
-
- /* remove from locked/unlocked hashes and property change if
- * that's the case */
- if (GDL_IS_DOCK_ITEM (object) && GDL_DOCK_ITEM_HAS_GRIP (GDL_DOCK_ITEM (object))) {
- gint locked = COMPUTE_LOCKED (master);
- if (g_hash_table_remove (master->_priv->locked_items, object) ||
- g_hash_table_remove (master->_priv->unlocked_items, object)) {
- if (COMPUTE_LOCKED (master) != locked)
- g_object_notify (G_OBJECT (master), "locked");
- }
- }
-
- /* ref the master, since removing the controller could cause master disposal */
- g_object_ref (master);
-
- /* all the interesting stuff happens in _gdl_dock_master_remove */
- _gdl_dock_master_remove (object, master);
-
- /* post a layout_changed emission if the item is not automatic
- * (since it should be removed from the items model) */
- if (!GDL_DOCK_OBJECT_AUTOMATIC (object)) {
- if (!master->_priv->idle_layout_changed_id)
- master->_priv->idle_layout_changed_id =
- g_idle_add (idle_emit_layout_changed, master);
- }
-
- /* balance ref count */
- g_object_unref (master);
-}
-
-void
-gdl_dock_master_foreach (GdlDockMaster *master,
- GFunc function,
- gpointer user_data)
-{
- struct {
- GFunc function;
- gpointer user_data;
- } data;
-
- g_return_if_fail (master != NULL && function != NULL);
-
- data.function = function;
- data.user_data = user_data;
- g_hash_table_foreach (master->dock_objects, _gdl_dock_master_foreach, &data);
-}
-
-void
-gdl_dock_master_foreach_toplevel (GdlDockMaster *master,
- gboolean include_controller,
- GFunc function,
- gpointer user_data)
-{
- GList *l;
-
- g_return_if_fail (master != NULL && function != NULL);
-
- for (l = master->toplevel_docks; l; ) {
- GdlDockObject *object = GDL_DOCK_OBJECT (l->data);
- l = l->next;
- if (object != master->controller || include_controller)
- (* function) (GTK_WIDGET (object), user_data);
- }
-}
-
-GdlDockObject *
-gdl_dock_master_get_object (GdlDockMaster *master,
- const gchar *nick_name)
-{
- gpointer *found;
-
- g_return_val_if_fail (master != NULL, NULL);
-
- if (!nick_name)
- return NULL;
-
- found = g_hash_table_lookup (master->dock_objects, nick_name);
-
- return found ? GDL_DOCK_OBJECT (found) : NULL;
-}
-
-GdlDockObject *
-gdl_dock_master_get_controller (GdlDockMaster *master)
-{
- g_return_val_if_fail (master != NULL, NULL);
-
- return master->controller;
-}
-
-void
-gdl_dock_master_set_controller (GdlDockMaster *master,
- GdlDockObject *new_controller)
-{
- g_return_if_fail (master != NULL);
-
- if (new_controller) {
- if (GDL_DOCK_OBJECT_AUTOMATIC (new_controller))
- g_warning (_("The new dock controller %p is automatic. Only manual "
- "dock objects should be named controller."), new_controller);
-
- /* check that the controller is in the toplevel list */
- if (!g_list_find (master->toplevel_docks, new_controller))
- gdl_dock_master_add (master, new_controller);
- master->controller = new_controller;
-
- } else {
- master->controller = NULL;
- /* no controller, no master */
- g_object_unref (master);
- }
-}
-
-static void
-set_switcher_style_foreach (GtkWidget *obj, gpointer user_data)
-{
- GdlSwitcherStyle style = GPOINTER_TO_INT (user_data);
-
- if (!GDL_IS_DOCK_ITEM (obj))
- return;
-
- if (GDL_IS_DOCK_NOTEBOOK (obj)) {
-
- GtkWidget *child = GDL_DOCK_ITEM (obj)->child;
- if (GDL_IS_SWITCHER (child)) {
-
- g_object_set (child, "switcher-style", style, NULL);
- }
- } else if (gdl_dock_object_is_compound (GDL_DOCK_OBJECT (obj))) {
-
- gtk_container_foreach (GTK_CONTAINER (obj),
- set_switcher_style_foreach,
- user_data);
- }
-}
-
-static void
-gdl_dock_master_set_switcher_style (GdlDockMaster *master,
- GdlSwitcherStyle switcher_style)
-{
- GList *l;
- g_return_if_fail (GDL_IS_DOCK_MASTER (master));
-
- master->_priv->switcher_style = switcher_style;
- for (l = master->toplevel_docks; l; l = l->next) {
- GdlDock *dock = GDL_DOCK (l->data);
- if (dock->root)
- set_switcher_style_foreach (GTK_WIDGET (dock->root),
- GINT_TO_POINTER (switcher_style));
- }
-
- /* just to be sure hidden items are set too */
- gdl_dock_master_foreach (master, (GFunc) set_switcher_style_foreach,
- GINT_TO_POINTER (switcher_style));
-}
diff --git a/src/libgdl/gdl-dock-master.h b/src/libgdl/gdl-dock-master.h
deleted file mode 100644
index 266ca7ee4..000000000
--- a/src/libgdl/gdl-dock-master.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * gdl-dock-master.h - Object which manages a dock ring
- *
- * This file is part of the GNOME Devtools Libraries.
- *
- * Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net>
- *
- * This library is free software; you can redistribute it and/or
- * 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
- */
-
-#ifndef __GDL_DOCK_MASTER_H__
-#define __GDL_DOCK_MASTER_H__
-
-#include <glib-object.h>
-#include <gtk/gtk.h>
-#include "libgdl/gdl-dock-object.h"
-
-
-G_BEGIN_DECLS
-
-/* standard macros */
-#define GDL_TYPE_DOCK_MASTER (gdl_dock_master_get_type ())
-#define GDL_DOCK_MASTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_MASTER, GdlDockMaster))
-#define GDL_DOCK_MASTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_MASTER, GdlDockMasterClass))
-#define GDL_IS_DOCK_MASTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_MASTER))
-#define GDL_IS_DOCK_MASTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_MASTER))
-#define GDL_DOCK_MASTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_MASTER, GdlDockMasterClass))
-
-/* data types & structures */
-typedef struct _GdlDockMaster GdlDockMaster;
-typedef struct _GdlDockMasterClass GdlDockMasterClass;
-typedef struct _GdlDockMasterPrivate GdlDockMasterPrivate;
-
-typedef enum {
- GDL_SWITCHER_STYLE_TEXT,
- GDL_SWITCHER_STYLE_ICON,
- GDL_SWITCHER_STYLE_BOTH,
- GDL_SWITCHER_STYLE_TOOLBAR,
- GDL_SWITCHER_STYLE_TABS,
- GDL_SWITCHER_STYLE_NONE
-} GdlSwitcherStyle;
-
-struct _GdlDockMaster {
- GObject object;
-
- GHashTable *dock_objects;
- GList *toplevel_docks;
- GdlDockObject *controller; /* GUI root object */
-
- gint dock_number; /* for toplevel dock numbering */
-
- GdlDockMasterPrivate *_priv;
-};
-
-struct _GdlDockMasterClass {
- GObjectClass parent_class;
-
- void (* layout_changed) (GdlDockMaster *master);
-};
-
-/* additional macros */
-
-#define GDL_DOCK_OBJECT_GET_MASTER(object) \
- (GDL_DOCK_OBJECT (object)->master ? \
- GDL_DOCK_MASTER (GDL_DOCK_OBJECT (object)->master) : NULL)
-
-/* public interface */
-
-GType gdl_dock_master_get_type (void);
-
-void gdl_dock_master_add (GdlDockMaster *master,
- GdlDockObject *object);
-void gdl_dock_master_remove (GdlDockMaster *master,
- GdlDockObject *object);
-void gdl_dock_master_foreach (GdlDockMaster *master,
- GFunc function,
- gpointer user_data);
-
-void gdl_dock_master_foreach_toplevel (GdlDockMaster *master,
- gboolean include_controller,
- GFunc function,
- gpointer user_data);
-
-GdlDockObject *gdl_dock_master_get_object (GdlDockMaster *master,
- const gchar *nick_name);
-
-GdlDockObject *gdl_dock_master_get_controller (GdlDockMaster *master);
-void gdl_dock_master_set_controller (GdlDockMaster *master,
- GdlDockObject *new_controller);
-
-G_END_DECLS
-
-#endif /* __GDL_DOCK_MASTER_H__ */
diff --git a/src/libgdl/gdl-dock-notebook.c b/src/libgdl/gdl-dock-notebook.c
deleted file mode 100644
index 0ffaac902..000000000
--- a/src/libgdl/gdl-dock-notebook.c
+++ /dev/null
@@ -1,530 +0,0 @@
-/* -*- 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>
- *
- * This library is free software; you can redistribute it and/or
- * 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 "gdl-switcher.h"
-
-#include "gdl-dock-notebook.h"
-#include "gdl-dock-tablabel.h"
-
-
-/* Private prototypes */
-
-static void gdl_dock_notebook_class_init (GdlDockNotebookClass *klass);
-static void gdl_dock_notebook_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gdl_dock_notebook_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static void gdl_dock_notebook_destroy (GtkObject *object);
-
-static void gdl_dock_notebook_add (GtkContainer *container,
- GtkWidget *widget);
-static void gdl_dock_notebook_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-static GType gdl_dock_notebook_child_type (GtkContainer *container);
-
-static void gdl_dock_notebook_dock (GdlDockObject *object,
- GdlDockObject *requestor,
- GdlDockPlacement position,
- GValue *other_data);
-
-static void gdl_dock_notebook_switch_page_cb (GtkNotebook *nb,
- GtkWidget *page,
- gint page_num,
- gpointer data);
-
-static void gdl_dock_notebook_set_orientation (GdlDockItem *item,
- GtkOrientation orientation);
-
-static gboolean gdl_dock_notebook_child_placement (GdlDockObject *object,
- GdlDockObject *child,
- GdlDockPlacement *placement);
-
-static void gdl_dock_notebook_present (GdlDockObject *object,
- GdlDockObject *child);
-
-static gboolean gdl_dock_notebook_reorder (GdlDockObject *object,
- GdlDockObject *requestor,
- GdlDockPlacement new_position,
- GValue *other_data);
-
-
-/* Class variables and definitions */
-
-enum {
- PROP_0,
- PROP_PAGE
-};
-
-
-/* ----- Private functions ----- */
-
-G_DEFINE_TYPE (GdlDockNotebook, gdl_dock_notebook, GDL_TYPE_DOCK_ITEM);
-
-static void
-gdl_dock_notebook_class_init (GdlDockNotebookClass *klass)
-{
- static gboolean style_initialized = FALSE;
-
- GObjectClass *g_object_class;
- GtkObjectClass *gtk_object_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
- GdlDockObjectClass *object_class;
- GdlDockItemClass *item_class;
-
- g_object_class = G_OBJECT_CLASS (klass);
- gtk_object_class = GTK_OBJECT_CLASS (klass);
- widget_class = GTK_WIDGET_CLASS (klass);
- container_class = GTK_CONTAINER_CLASS (klass);
- object_class = GDL_DOCK_OBJECT_CLASS (klass);
- item_class = GDL_DOCK_ITEM_CLASS (klass);
-
- g_object_class->set_property = gdl_dock_notebook_set_property;
- g_object_class->get_property = gdl_dock_notebook_get_property;
-
- gtk_object_class->destroy = gdl_dock_notebook_destroy;
-
- container_class->add = gdl_dock_notebook_add;
- container_class->forall = gdl_dock_notebook_forall;
- container_class->child_type = gdl_dock_notebook_child_type;
-
- object_class->is_compound = TRUE;
- object_class->dock = gdl_dock_notebook_dock;
- object_class->child_placement = gdl_dock_notebook_child_placement;
- object_class->present = gdl_dock_notebook_present;
- object_class->reorder = gdl_dock_notebook_reorder;
-
- item_class->has_grip = FALSE;
- item_class->set_orientation = gdl_dock_notebook_set_orientation;
-
- g_object_class_install_property (
- g_object_class, PROP_PAGE,
- g_param_spec_int ("page", _("Page"),
- _("The index of the current page"),
- 0, G_MAXINT,
- 0,
- G_PARAM_READWRITE |
- GDL_DOCK_PARAM_EXPORT | GDL_DOCK_PARAM_AFTER));
-
- if (!style_initialized) {
- style_initialized = TRUE;
-
- gtk_rc_parse_string (
- "style \"gdl-dock-notebook-default\" {\n"
- "xthickness = 2\n"
- "ythickness = 2\n"
- "}\n"
- "widget_class \"*.GtkNotebook.GdlDockItem\" "
- "style : gtk \"gdl-dock-notebook-default\"\n");
- }
-}
-
-static void
-gdl_dock_notebook_notify_cb (GObject *g_object,
- GParamSpec *pspec,
- gpointer user_data)
-{
- g_return_if_fail (user_data != NULL && GDL_IS_DOCK_NOTEBOOK (user_data));
-
- /* chain the notify signal */
- g_object_notify (G_OBJECT (user_data), pspec->name);
-}
-
-static gboolean
-gdl_dock_notebook_button_cb (GtkWidget *widget,
- GdkEventButton *event,
- gpointer user_data)
-{
- if (event->type == GDK_BUTTON_PRESS)
- GDL_DOCK_ITEM_SET_FLAGS (user_data, GDL_DOCK_USER_ACTION);
- else
- GDL_DOCK_ITEM_UNSET_FLAGS (user_data, GDL_DOCK_USER_ACTION);
-
- return FALSE;
-}
-
-static void
-gdl_dock_notebook_init (GdlDockNotebook *notebook)
-{
- GdlDockItem *item;
-
- item = GDL_DOCK_ITEM (notebook);
-
- /* 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",
- (GCallback) gdl_dock_notebook_switch_page_cb, (gpointer) item);
- g_signal_connect (item->child, "notify::page",
- (GCallback) gdl_dock_notebook_notify_cb, (gpointer) item);
- g_signal_connect (item->child, "button-press-event",
- (GCallback) gdl_dock_notebook_button_cb, (gpointer) item);
- g_signal_connect (item->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);
-}
-
-static void
-gdl_dock_notebook_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GdlDockItem *item = GDL_DOCK_ITEM (object);
-
- switch (prop_id) {
- case PROP_PAGE:
- if (item->child && GTK_IS_NOTEBOOK (item->child)) {
- gtk_notebook_set_current_page (GTK_NOTEBOOK (item->child),
- g_value_get_int (value));
- }
-
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gdl_dock_notebook_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GdlDockItem *item = GDL_DOCK_ITEM (object);
-
- switch (prop_id) {
- case PROP_PAGE:
- if (item->child && GTK_IS_NOTEBOOK (item->child)) {
- g_value_set_int (value, gtk_notebook_get_current_page
- (GTK_NOTEBOOK (item->child)));
- }
-
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-
-static void
-gdl_dock_notebook_destroy (GtkObject *object)
-{
- GdlDockItem *item = GDL_DOCK_ITEM (object);
-
- /* we need to call the virtual first, since in GdlDockDestroy our
- children dock objects are detached */
- GTK_OBJECT_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;
- };
-}
-
-static void
-gdl_dock_notebook_switch_page_cb (GtkNotebook *nb,
- GtkWidget *page,
- gint page_num,
- gpointer data)
-{
- GdlDockNotebook *notebook;
- GtkWidget *tablabel;
- GdlDockItem *item;
-
- notebook = GDL_DOCK_NOTEBOOK (data);
-
- /* deactivate old tablabel */
- if (gtk_notebook_get_current_page (nb)) {
- tablabel = gtk_notebook_get_tab_label (
- nb, gtk_notebook_get_nth_page (
- nb, gtk_notebook_get_current_page (nb)));
- if (tablabel && GDL_IS_DOCK_TABLABEL (tablabel))
- gdl_dock_tablabel_deactivate (GDL_DOCK_TABLABEL (tablabel));
- };
-
- /* activate new label */
- tablabel = gtk_notebook_get_tab_label (
- nb, page);
- if (tablabel && GDL_IS_DOCK_TABLABEL (tablabel))
- gdl_dock_tablabel_activate (GDL_DOCK_TABLABEL (tablabel));
-
- if (GDL_DOCK_ITEM_USER_ACTION (notebook) &&
- GDL_DOCK_OBJECT (notebook)->master)
- g_signal_emit_by_name (GDL_DOCK_OBJECT (notebook)->master,
- "layout-changed");
-
- /* Signal that a new dock item has been selected */
- item = GDL_DOCK_ITEM (page);
- gdl_dock_item_notify_selected (item);
-}
-
-static void
-gdl_dock_notebook_add (GtkContainer *container,
- GtkWidget *widget)
-{
- g_return_if_fail (container != NULL && widget != NULL);
- g_return_if_fail (GDL_IS_DOCK_NOTEBOOK (container));
- g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
-
- gdl_dock_object_dock (GDL_DOCK_OBJECT (container),
- GDL_DOCK_OBJECT (widget),
- GDL_DOCK_CENTER,
- NULL);
-}
-
-static void
-gdl_dock_notebook_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data)
-{
- GdlDockItem *item;
-
- g_return_if_fail (container != NULL);
- g_return_if_fail (GDL_IS_DOCK_NOTEBOOK (container));
- g_return_if_fail (callback != NULL);
-
- if (include_internals) {
- /* use GdlDockItem's forall */
- GTK_CONTAINER_CLASS (gdl_dock_notebook_parent_class)->forall
- (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);
- }
-}
-
-static GType
-gdl_dock_notebook_child_type (GtkContainer *container)
-{
- return GDL_TYPE_DOCK_ITEM;
-}
-
-static void
-gdl_dock_notebook_dock_child (GdlDockObject *requestor,
- gpointer user_data)
-{
- struct {
- GdlDockObject *object;
- GdlDockPlacement position;
- GValue *other_data;
- } *data = user_data;
-
- gdl_dock_object_dock (data->object, requestor, data->position, data->other_data);
-}
-
-static void
-gdl_dock_notebook_dock (GdlDockObject *object,
- GdlDockObject *requestor,
- GdlDockPlacement position,
- GValue *other_data)
-{
- g_return_if_fail (GDL_IS_DOCK_NOTEBOOK (object));
- g_return_if_fail (GDL_IS_DOCK_ITEM (requestor));
-
- /* we only add support for GDL_DOCK_CENTER docking strategy here... for the rest
- use our parent class' method */
- if (position == GDL_DOCK_CENTER) {
- /* we can only dock simple (not compound) items */
- if (gdl_dock_object_is_compound (requestor)) {
- struct {
- GdlDockObject *object;
- GdlDockPlacement position;
- GValue *other_data;
- } data;
-
- gdl_dock_object_freeze (requestor);
-
- data.object = object;
- data.position = position;
- data.other_data = other_data;
-
- gtk_container_foreach (GTK_CONTAINER (requestor),
- (GtkCallback) gdl_dock_notebook_dock_child, &data);
-
- gdl_dock_object_thaw (requestor);
- }
- else {
- GdlDockItem *item = GDL_DOCK_ITEM (object);
- GdlDockItem *requestor_item = GDL_DOCK_ITEM (requestor);
- gchar *long_name, *stock_id;
- GdkPixbuf *pixbuf_icon;
- GtkWidget *label;
- gint position = -1;
-
- g_object_get (requestor_item, "long-name", &long_name,
- "stock-id", &stock_id, "pixbuf-icon", &pixbuf_icon, NULL);
- label = gdl_dock_item_get_tablabel (requestor_item);
- if (!label) {
- label = gtk_label_new (long_name);
- gdl_dock_item_set_tablabel (requestor_item, label);
- }
-#if 0
- if (GDL_IS_DOCK_TABLABEL (label)) {
- gdl_dock_tablabel_deactivate (GDL_DOCK_TABLABEL (label));
- /* hide the item grip, as we will use the tablabel's */
- gdl_dock_item_hide_grip (requestor_item);
- }
-#endif
-
- 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),
- GTK_WIDGET (requestor), label,
- long_name, long_name,
- stock_id, pixbuf_icon, position);
-
- GDL_DOCK_OBJECT_SET_FLAGS (requestor, GDL_DOCK_ATTACHED);
-
- /* Set current page to the newly docked widget. set current page
- * really doesn't work if the page widget is not shown
- */
- gtk_widget_show (GTK_WIDGET (requestor));
- gtk_notebook_set_current_page (GTK_NOTEBOOK (item->child),
- position);
- g_free (long_name);
- g_free (stock_id);
- }
- }
- else
- GDL_DOCK_OBJECT_CLASS (gdl_dock_notebook_parent_class)->dock (object, requestor, position, other_data);
-}
-
-static void
-gdl_dock_notebook_set_orientation (GdlDockItem *item,
- GtkOrientation orientation)
-{
- if (item->child && GTK_IS_NOTEBOOK (item->child)) {
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_notebook_set_tab_pos (GTK_NOTEBOOK (item->child), GTK_POS_TOP);
- else
- gtk_notebook_set_tab_pos (GTK_NOTEBOOK (item->child), GTK_POS_LEFT);
- }
-
- GDL_DOCK_ITEM_CLASS (gdl_dock_notebook_parent_class)->set_orientation (item, orientation);
-}
-
-static gboolean
-gdl_dock_notebook_child_placement (GdlDockObject *object,
- GdlDockObject *child,
- GdlDockPlacement *placement)
-{
- GdlDockItem *item = GDL_DOCK_ITEM (object);
- GdlDockPlacement pos = GDL_DOCK_NONE;
-
- if (item->child) {
- GList *children, *l;
-
- children = gtk_container_get_children (GTK_CONTAINER (item->child));
- for (l = children; l; l = l->next) {
- if (l->data == (gpointer) child) {
- pos = GDL_DOCK_CENTER;
- break;
- }
- }
- g_list_free (children);
- }
-
- if (pos != GDL_DOCK_NONE) {
- if (placement)
- *placement = pos;
- return TRUE;
- }
- else
- return FALSE;
-}
-
-static void
-gdl_dock_notebook_present (GdlDockObject *object,
- GdlDockObject *child)
-{
- GdlDockItem *item = GDL_DOCK_ITEM (object);
- int i;
-
- i = gtk_notebook_page_num (GTK_NOTEBOOK (item->child),
- GTK_WIDGET (child));
- if (i >= 0)
- gtk_notebook_set_current_page (GTK_NOTEBOOK (item->child), i);
-
- GDL_DOCK_OBJECT_CLASS (gdl_dock_notebook_parent_class)->present (object, child);
-}
-
-static gboolean
-gdl_dock_notebook_reorder (GdlDockObject *object,
- GdlDockObject *requestor,
- GdlDockPlacement new_position,
- GValue *other_data)
-{
- GdlDockItem *item = 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),
- GTK_WIDGET (requestor));
- if (current_position >= 0) {
- handled = TRUE;
-
- 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_WIDGET (requestor),
- new_pos);
- }
- }
- return handled;
-}
-
-/* ----- Public interface ----- */
-
-GtkWidget *
-gdl_dock_notebook_new (void)
-{
- GdlDockNotebook *notebook;
-
- notebook = GDL_DOCK_NOTEBOOK (g_object_new (GDL_TYPE_DOCK_NOTEBOOK, NULL));
- GDL_DOCK_OBJECT_UNSET_FLAGS (notebook, GDL_DOCK_AUTOMATIC);
-
- return GTK_WIDGET (notebook);
-}
-
diff --git a/src/libgdl/gdl-dock-notebook.h b/src/libgdl/gdl-dock-notebook.h
deleted file mode 100644
index 063f53642..000000000
--- a/src/libgdl/gdl-dock-notebook.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* -*- 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>
- *
- * This library is free software; you can redistribute it and/or
- * 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
- */
-
-#ifndef __GDL_DOCK_NOTEBOOK_H__
-#define __GDL_DOCK_NOTEBOOK_H__
-
-#include "libgdl/gdl-dock-item.h"
-
-G_BEGIN_DECLS
-
-/* standard macros */
-#define GDL_TYPE_DOCK_NOTEBOOK (gdl_dock_notebook_get_type ())
-#define GDL_DOCK_NOTEBOOK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_NOTEBOOK, GdlDockNotebook))
-#define GDL_DOCK_NOTEBOOK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_NOTEBOOK, GdlDockNotebookClass))
-#define GDL_IS_DOCK_NOTEBOOK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_NOTEBOOK))
-#define GDL_IS_DOCK_NOTEBOOK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_NOTEBOOK))
-#define GDL_DOCK_NOTEBOOK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_NOTEBOOK, GdlDockNotebookClass))
-
-/* data types & structures */
-typedef struct _GdlDockNotebook GdlDockNotebook;
-typedef struct _GdlDockNotebookClass GdlDockNotebookClass;
-
-struct _GdlDockNotebook {
- GdlDockItem item;
-};
-
-struct _GdlDockNotebookClass {
- GdlDockItemClass parent_class;
-};
-
-
-/* public interface */
-
-GtkWidget *gdl_dock_notebook_new (void);
-
-GType gdl_dock_notebook_get_type (void);
-
-G_END_DECLS
-
-#endif
-
diff --git a/src/libgdl/gdl-dock-object.c b/src/libgdl/gdl-dock-object.c
deleted file mode 100644
index 4092ecc9f..000000000
--- a/src/libgdl/gdl-dock-object.c
+++ /dev/null
@@ -1,1027 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * gdl-dock-object.c - Abstract base class for all dock related objects
- *
- * This file is part of the GNOME Devtools Libraries.
- *
- * Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net>
- *
- * This library is free software; you can redistribute it and/or
- * 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-dock-object.h"
-#include "gdl-dock-master.h"
-#include "libgdltypebuiltins.h"
-#include "libgdlmarshal.h"
-
-/* for later use by the registry */
-#include "gdl-dock.h"
-#include "gdl-dock-item.h"
-#include "gdl-dock-paned.h"
-#include "gdl-dock-notebook.h"
-#include "gdl-dock-placeholder.h"
-
-
-/* ----- Private prototypes ----- */
-
-static void gdl_dock_object_class_init (GdlDockObjectClass *klass);
-
-static void gdl_dock_object_set_property (GObject *g_object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gdl_dock_object_get_property (GObject *g_object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void gdl_dock_object_finalize (GObject *g_object);
-
-static void gdl_dock_object_destroy (GtkObject *gtk_object);
-
-static void gdl_dock_object_show (GtkWidget *widget);
-static void gdl_dock_object_hide (GtkWidget *widget);
-
-static void gdl_dock_object_real_detach (GdlDockObject *object,
- gboolean recursive);
-static void gdl_dock_object_real_reduce (GdlDockObject *object);
-static void gdl_dock_object_dock_unimplemented (GdlDockObject *object,
- GdlDockObject *requestor,
- GdlDockPlacement position,
- GValue *other_data);
-static void gdl_dock_object_real_present (GdlDockObject *object,
- GdlDockObject *child);
-
-
-/* ----- Private data types and variables ----- */
-
-enum {
- PROP_0,
- PROP_NAME,
- PROP_LONG_NAME,
- PROP_STOCK_ID,
- PROP_PIXBUF_ICON,
- PROP_MASTER,
- PROP_EXPORT_PROPERTIES
-};
-
-enum {
- DETACH,
- DOCK,
- LAST_SIGNAL
-};
-
-static guint gdl_dock_object_signals [LAST_SIGNAL] = { 0 };
-
-struct DockRegisterItem {
- gchar* nick;
- gpointer type;
-};
-
-static GArray *dock_register = NULL;
-
-/* ----- Private interface ----- */
-
-G_DEFINE_TYPE (GdlDockObject, gdl_dock_object, GTK_TYPE_CONTAINER);
-
-static void
-gdl_dock_object_class_init (GdlDockObjectClass *klass)
-{
- GObjectClass *g_object_class;
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
-
- g_object_class = G_OBJECT_CLASS (klass);
- object_class = GTK_OBJECT_CLASS (klass);
- widget_class = GTK_WIDGET_CLASS (klass);
- container_class = GTK_CONTAINER_CLASS (klass);
-
- g_object_class->set_property = gdl_dock_object_set_property;
- g_object_class->get_property = gdl_dock_object_get_property;
- g_object_class->finalize = gdl_dock_object_finalize;
-
- g_object_class_install_property (
- g_object_class, PROP_NAME,
- g_param_spec_string (GDL_DOCK_NAME_PROPERTY, _("Name"),
- _("Unique name for identifying the dock object"),
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
- GDL_DOCK_PARAM_EXPORT));
-
- g_object_class_install_property (
- g_object_class, PROP_LONG_NAME,
- g_param_spec_string ("long-name", _("Long name"),
- _("Human readable name for the dock object"),
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (
- g_object_class, PROP_STOCK_ID,
- g_param_spec_string ("stock-id", _("Stock Icon"),
- _("Stock icon for the dock object"),
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (
- g_object_class, PROP_PIXBUF_ICON,
- g_param_spec_pointer ("pixbuf-icon", _("Pixbuf Icon"),
- _("Pixbuf icon for the dock object"),
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- g_object_class, PROP_MASTER,
- g_param_spec_object ("master", _("Dock master"),
- _("Dock master this dock object is bound to"),
- GDL_TYPE_DOCK_MASTER,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- object_class->destroy = gdl_dock_object_destroy;
-
- widget_class->show = gdl_dock_object_show;
- widget_class->hide = gdl_dock_object_hide;
-
- klass->is_compound = TRUE;
-
- klass->detach = gdl_dock_object_real_detach;
- klass->reduce = gdl_dock_object_real_reduce;
- klass->dock_request = NULL;
- klass->dock = gdl_dock_object_dock_unimplemented;
- klass->reorder = NULL;
- klass->present = gdl_dock_object_real_present;
- klass->child_placement = NULL;
-
- gdl_dock_object_signals [DETACH] =
- g_signal_new ("detach",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdlDockObjectClass, detach),
- NULL,
- NULL,
- gdl_marshal_VOID__BOOLEAN,
- G_TYPE_NONE,
- 1,
- G_TYPE_BOOLEAN);
-
- gdl_dock_object_signals [DOCK] =
- g_signal_new ("dock",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdlDockObjectClass, dock),
- NULL,
- NULL,
- gdl_marshal_VOID__OBJECT_ENUM_BOXED,
- G_TYPE_NONE,
- 3,
- GDL_TYPE_DOCK_OBJECT,
- GDL_TYPE_DOCK_PLACEMENT,
- G_TYPE_VALUE);
-}
-
-static void
-gdl_dock_object_init (GdlDockObject *object)
-{
- object->flags = GDL_DOCK_AUTOMATIC;
- object->freeze_count = 0;
-}
-
-static void
-gdl_dock_object_set_property (GObject *g_object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GdlDockObject *object = GDL_DOCK_OBJECT (g_object);
-
- switch (prop_id) {
- case PROP_NAME:
- g_free (object->name);
- object->name = g_value_dup_string (value);
- break;
- case PROP_LONG_NAME:
- g_free (object->long_name);
- object->long_name = g_value_dup_string (value);
- break;
- case PROP_STOCK_ID:
- g_free (object->stock_id);
- object->stock_id = g_value_dup_string (value);
- break;
- case PROP_PIXBUF_ICON:
- object->pixbuf_icon = g_value_get_pointer (value);
- break;
- case PROP_MASTER:
- if (g_value_get_object (value))
- gdl_dock_object_bind (object, g_value_get_object (value));
- else
- gdl_dock_object_unbind (object);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gdl_dock_object_get_property (GObject *g_object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GdlDockObject *object = GDL_DOCK_OBJECT (g_object);
-
- switch (prop_id) {
- case PROP_NAME:
- g_value_set_string (value, object->name);
- break;
- case PROP_LONG_NAME:
- g_value_set_string (value, object->long_name);
- break;
- case PROP_STOCK_ID:
- g_value_set_string (value, object->stock_id);
- break;
- case PROP_PIXBUF_ICON:
- g_value_set_pointer (value, object->pixbuf_icon);
- break;
- case PROP_MASTER:
- g_value_set_object (value, object->master);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gdl_dock_object_finalize (GObject *g_object)
-{
- GdlDockObject *object;
-
- g_return_if_fail (g_object != NULL && GDL_IS_DOCK_OBJECT (g_object));
-
- object = GDL_DOCK_OBJECT (g_object);
-
- g_free (object->name);
- object->name = NULL;
- g_free (object->long_name);
- object->long_name = NULL;
- g_free (object->stock_id);
- object->stock_id = NULL;
- object->pixbuf_icon = NULL;
-
- G_OBJECT_CLASS (gdl_dock_object_parent_class)->finalize (g_object);
-}
-
-static void
-gdl_dock_object_foreach_detach (GdlDockObject *object,
- gpointer user_data)
-{
- gdl_dock_object_detach (object, TRUE);
-}
-
-static void
-gdl_dock_object_destroy (GtkObject *gtk_object)
-{
- GdlDockObject *object;
-
- g_return_if_fail (GDL_IS_DOCK_OBJECT (gtk_object));
-
- object = GDL_DOCK_OBJECT (gtk_object);
- if (gdl_dock_object_is_compound (object)) {
- /* detach our dock object children if we have some, and even
- if we are not attached, so they can get notification */
- gdl_dock_object_freeze (object);
- gtk_container_foreach (GTK_CONTAINER (object),
- (GtkCallback) gdl_dock_object_foreach_detach,
- NULL);
- object->reduce_pending = FALSE;
- gdl_dock_object_thaw (object);
- }
- if (GDL_DOCK_OBJECT_ATTACHED (object)) {
- /* detach ourselves */
- gdl_dock_object_detach (object, FALSE);
- }
-
- /* finally unbind us */
- if (object->master)
- gdl_dock_object_unbind (object);
-
- GTK_OBJECT_CLASS(gdl_dock_object_parent_class)->destroy (gtk_object);
-}
-
-static void
-gdl_dock_object_foreach_automatic (GdlDockObject *object,
- gpointer user_data)
-{
- void (* function) (GtkWidget *) = user_data;
-
- if (GDL_DOCK_OBJECT_AUTOMATIC (object))
- (* function) (GTK_WIDGET (object));
-}
-
-static void
-gdl_dock_object_show (GtkWidget *widget)
-{
- if (gdl_dock_object_is_compound (GDL_DOCK_OBJECT (widget))) {
- gtk_container_foreach (GTK_CONTAINER (widget),
- (GtkCallback) gdl_dock_object_foreach_automatic,
- gtk_widget_show);
- }
- GTK_WIDGET_CLASS (gdl_dock_object_parent_class)->show (widget);
-}
-
-static void
-gdl_dock_object_hide (GtkWidget *widget)
-{
- if (gdl_dock_object_is_compound (GDL_DOCK_OBJECT (widget))) {
- gtk_container_foreach (GTK_CONTAINER (widget),
- (GtkCallback) gdl_dock_object_foreach_automatic,
- gtk_widget_hide);
- }
- GTK_WIDGET_CLASS (gdl_dock_object_parent_class)->hide (widget);
-}
-
-static void
-gdl_dock_object_real_detach (GdlDockObject *object,
- gboolean recursive)
-{
- GdlDockObject *parent;
- GtkWidget *widget;
-
- g_return_if_fail (object != NULL);
-
- /* detach children */
- if (recursive && gdl_dock_object_is_compound (object)) {
- gtk_container_foreach (GTK_CONTAINER (object),
- (GtkCallback) gdl_dock_object_detach,
- GINT_TO_POINTER (recursive));
- }
-
- /* detach the object itself */
- GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_ATTACHED);
- parent = gdl_dock_object_get_parent_object (object);
- widget = GTK_WIDGET (object);
- if (gtk_widget_get_parent (widget))
- gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (GTK_WIDGET (widget))), widget);
- if (parent)
- gdl_dock_object_reduce (parent);
-}
-
-static void
-gdl_dock_object_real_reduce (GdlDockObject *object)
-{
- GdlDockObject *parent;
- GList *children;
-
- g_return_if_fail (object != NULL);
-
- if (!gdl_dock_object_is_compound (object))
- return;
-
- parent = gdl_dock_object_get_parent_object (object);
- children = gtk_container_get_children (GTK_CONTAINER (object));
- if (g_list_length (children) <= 1) {
- GList *l;
- GList *dchildren = NULL;
-
- /* detach ourselves and then re-attach our children to our
- current parent. if we are not currently attached, the
- children are detached */
- if (parent)
- gdl_dock_object_freeze (parent);
- gdl_dock_object_freeze (object);
- /* Detach the children before detaching this object, since in this
- * way the children can have access to the whole object hierarchy.
- * Set the InDetach flag now, so the children know that this object
- * is going to be detached. */
-
-
- GDL_DOCK_OBJECT_SET_FLAGS (object, GDL_DOCK_IN_DETACH);
-
- for (l = children; l; l = l->next) {
- GdlDockObject *child;
-
- if (!GDL_IS_DOCK_OBJECT (l->data))
- continue;
-
- child = GDL_DOCK_OBJECT (l->data);
-
- g_object_ref (child);
- gdl_dock_object_detach (child, FALSE);
- GDL_DOCK_OBJECT_SET_FLAGS (child, GDL_DOCK_IN_REFLOW);
- if (parent)
- dchildren = g_list_append (dchildren, child);
- GDL_DOCK_OBJECT_UNSET_FLAGS (child, GDL_DOCK_IN_REFLOW);
- }
- /* Now it can be detached */
- gdl_dock_object_detach (object, FALSE);
-
- /* After detaching the reduced object, we can add the
- children (the only child in fact) to the new parent */
- for (l = dchildren; l; l = l->next) {
- gtk_container_add (GTK_CONTAINER (parent), l->data);
- g_object_unref (l->data);
- }
- g_list_free (dchildren);
-
-
- /* sink the widget, so any automatic floating widget is destroyed */
- g_object_ref_sink (object);
- /* don't reenter */
- object->reduce_pending = FALSE;
- gdl_dock_object_thaw (object);
- if (parent)
- gdl_dock_object_thaw (parent);
- }
- g_list_free (children);
-}
-
-static void
-gdl_dock_object_dock_unimplemented (GdlDockObject *object,
- GdlDockObject *requestor,
- GdlDockPlacement position,
- GValue *other_data)
-{
- g_warning (_("Call to gdl_dock_object_dock in a dock object %p "
- "(object type is %s) which hasn't implemented this method"),
- object, G_OBJECT_TYPE_NAME (object));
-}
-
-static void
-gdl_dock_object_real_present (GdlDockObject *object,
- GdlDockObject *child)
-{
- gtk_widget_show (GTK_WIDGET (object));
-}
-
-
-/* ----- Public interface ----- */
-
-gboolean
-gdl_dock_object_is_compound (GdlDockObject *object)
-{
- GdlDockObjectClass *klass;
-
- g_return_val_if_fail (object != NULL, FALSE);
- g_return_val_if_fail (GDL_IS_DOCK_OBJECT (object), FALSE);
-
- klass = GDL_DOCK_OBJECT_GET_CLASS (object);
- return klass->is_compound;
-}
-
-void
-gdl_dock_object_detach (GdlDockObject *object,
- gboolean recursive)
-{
- g_return_if_fail (object != NULL);
-
- if (!GDL_IS_DOCK_OBJECT (object))
- return;
-
- if (!GDL_DOCK_OBJECT_ATTACHED (object))
- return;
-
- /* freeze the object to avoid reducing while detaching children */
- gdl_dock_object_freeze (object);
- GDL_DOCK_OBJECT_SET_FLAGS (object, GDL_DOCK_IN_DETACH);
- g_signal_emit (object, gdl_dock_object_signals [DETACH], 0, recursive);
- GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_IN_DETACH);
- gdl_dock_object_thaw (object);
-}
-
-GdlDockObject *
-gdl_dock_object_get_parent_object (GdlDockObject *object)
-{
- GtkWidget *parent;
-
- g_return_val_if_fail (object != NULL, NULL);
-
- parent = gtk_widget_get_parent (GTK_WIDGET (object));
- while (parent && !GDL_IS_DOCK_OBJECT (parent)) {
- parent = gtk_widget_get_parent (parent);
- }
-
- return parent ? GDL_DOCK_OBJECT (parent) : NULL;
-}
-
-void
-gdl_dock_object_freeze (GdlDockObject *object)
-{
- g_return_if_fail (object != NULL);
-
- if (object->freeze_count == 0) {
- g_object_ref (object); /* dock objects shouldn't be
- destroyed if they are frozen */
- }
- object->freeze_count++;
-}
-
-void
-gdl_dock_object_thaw (GdlDockObject *object)
-{
- g_return_if_fail (object != NULL);
- g_return_if_fail (object->freeze_count > 0);
-
- object->freeze_count--;
- if (object->freeze_count == 0) {
- if (object->reduce_pending) {
- object->reduce_pending = FALSE;
- gdl_dock_object_reduce (object);
- }
- g_object_unref (object);
- }
-}
-
-void
-gdl_dock_object_reduce (GdlDockObject *object)
-{
- g_return_if_fail (object != NULL);
-
- if (GDL_DOCK_OBJECT_FROZEN (object)) {
- object->reduce_pending = TRUE;
- return;
- }
-
- if (GDL_DOCK_OBJECT_GET_CLASS (object)->reduce)
- GDL_DOCK_OBJECT_GET_CLASS (object)->reduce (object);
-}
-
-gboolean
-gdl_dock_object_dock_request (GdlDockObject *object,
- gint x,
- gint y,
- GdlDockRequest *request)
-{
- g_return_val_if_fail (object != NULL && request != NULL, FALSE);
-
- if (GDL_DOCK_OBJECT_GET_CLASS (object)->dock_request)
- return GDL_DOCK_OBJECT_GET_CLASS (object)->dock_request (object, x, y, request);
- else
- return FALSE;
-}
-
-/**
- * gdl_dock_object_dock:
- * @object:
- * @requestor:
- * @position:
- * @other_data: (allow-none):
- **/
-void
-gdl_dock_object_dock (GdlDockObject *object,
- GdlDockObject *requestor,
- GdlDockPlacement position,
- GValue *other_data)
-{
- GdlDockObject *parent;
-
- g_return_if_fail (object != NULL && requestor != NULL);
-
- if (object == requestor)
- return;
-
- if (!object->master)
- g_warning (_("Dock operation requested in a non-bound object %p. "
- "The application might crash"), object);
-
- if (!gdl_dock_object_is_bound (requestor))
- gdl_dock_object_bind (requestor, object->master);
-
- if (requestor->master != object->master) {
- g_warning (_("Cannot dock %p to %p because they belong to different masters"),
- requestor, object);
- return;
- }
-
- /* first, see if we can optimize things by reordering */
- if (position != GDL_DOCK_NONE) {
- parent = gdl_dock_object_get_parent_object (object);
- if (gdl_dock_object_reorder (object, requestor, position, other_data) ||
- (parent && gdl_dock_object_reorder (parent, requestor, position, other_data)))
- return;
- }
-
- /* freeze the object, since under some conditions it might be destroyed when
- detaching the requestor */
- gdl_dock_object_freeze (object);
-
- /* detach the requestor before docking */
- g_object_ref (requestor);
- if (GDL_DOCK_OBJECT_ATTACHED (requestor))
- gdl_dock_object_detach (requestor, FALSE);
-
- if (position != GDL_DOCK_NONE)
- g_signal_emit (object, gdl_dock_object_signals [DOCK], 0,
- requestor, position, other_data);
-
- g_object_unref (requestor);
- gdl_dock_object_thaw (object);
-}
-
-void
-gdl_dock_object_bind (GdlDockObject *object,
- GObject *master)
-{
- g_return_if_fail (object != NULL && master != NULL);
- g_return_if_fail (GDL_IS_DOCK_MASTER (master));
-
- if (object->master == master)
- /* nothing to do here */
- return;
-
- if (object->master) {
- g_warning (_("Attempt to bind to %p an already bound dock object %p "
- "(current master: %p)"), master, object, object->master);
- return;
- }
-
- gdl_dock_master_add (GDL_DOCK_MASTER (master), object);
- object->master = master;
- g_object_add_weak_pointer (master, (gpointer *) &object->master);
-
- g_object_notify (G_OBJECT (object), "master");
-}
-
-void
-gdl_dock_object_unbind (GdlDockObject *object)
-{
- g_return_if_fail (object != NULL);
-
- g_object_ref (object);
-
- /* detach the object first */
- if (GDL_DOCK_OBJECT_ATTACHED (object))
- gdl_dock_object_detach (object, TRUE);
-
- if (object->master) {
- GObject *master = object->master;
- g_object_remove_weak_pointer (master, (gpointer *) &object->master);
- object->master = NULL;
- gdl_dock_master_remove (GDL_DOCK_MASTER (master), object);
- g_object_notify (G_OBJECT (object), "master");
- }
- g_object_unref (object);
-}
-
-gboolean
-gdl_dock_object_is_bound (GdlDockObject *object)
-{
- g_return_val_if_fail (object != NULL, FALSE);
- return (object->master != NULL);
-}
-
-gboolean
-gdl_dock_object_reorder (GdlDockObject *object,
- GdlDockObject *child,
- GdlDockPlacement new_position,
- GValue *other_data)
-{
- g_return_val_if_fail (object != NULL && child != NULL, FALSE);
-
- if (GDL_DOCK_OBJECT_GET_CLASS (object)->reorder)
- return GDL_DOCK_OBJECT_GET_CLASS (object)->reorder (object, child, new_position, other_data);
- else
- return FALSE;
-}
-
-void
-gdl_dock_object_present (GdlDockObject *object,
- GdlDockObject *child)
-{
- GdlDockObject *parent;
-
- g_return_if_fail (object != NULL && GDL_IS_DOCK_OBJECT (object));
-
- parent = gdl_dock_object_get_parent_object (object);
- if (parent)
- /* chain the call to our parent */
- gdl_dock_object_present (parent, object);
-
- if (GDL_DOCK_OBJECT_GET_CLASS (object)->present)
- GDL_DOCK_OBJECT_GET_CLASS (object)->present (object, child);
-}
-
-/**
- * gdl_dock_object_child_placement:
- * @object: the dock object we are asking for child placement
- * @child: the child of the @object we want the placement for
- * @placement: where to return the placement information
- *
- * This function returns information about placement of a child dock
- * object inside another dock object. The function returns %TRUE if
- * @child is effectively a child of @object. @placement should
- * normally be initially setup to %GDL_DOCK_NONE. If it's set to some
- * other value, this function will not touch the stored value if the
- * specified placement is "compatible" with the actual placement of
- * the child.
- *
- * @placement can be %NULL, in which case the function simply tells if
- * @child is attached to @object.
- *
- * Returns: %TRUE if @child is a child of @object.
- */
-gboolean
-gdl_dock_object_child_placement (GdlDockObject *object,
- GdlDockObject *child,
- GdlDockPlacement *placement)
-{
- g_return_val_if_fail (object != NULL && child != NULL, FALSE);
-
- /* simple case */
- if (!gdl_dock_object_is_compound (object))
- return FALSE;
-
- if (GDL_DOCK_OBJECT_GET_CLASS (object)->child_placement)
- return GDL_DOCK_OBJECT_GET_CLASS (object)->child_placement (object, child, placement);
- else
- return FALSE;
-}
-
-
-/* ----- dock param type functions start here ------ */
-
-static void
-gdl_dock_param_export_int (const GValue *src,
- GValue *dst)
-{
- dst->data [0].v_pointer = g_strdup_printf ("%d", src->data [0].v_int);
-}
-
-static void
-gdl_dock_param_export_uint (const GValue *src,
- GValue *dst)
-{
- dst->data [0].v_pointer = g_strdup_printf ("%u", src->data [0].v_uint);
-}
-
-static void
-gdl_dock_param_export_string (const GValue *src,
- GValue *dst)
-{
- dst->data [0].v_pointer = g_strdup (src->data [0].v_pointer);
-}
-
-static void
-gdl_dock_param_export_bool (const GValue *src,
- GValue *dst)
-{
- dst->data [0].v_pointer = g_strdup_printf ("%s", src->data [0].v_int ? "yes" : "no");
-}
-
-static void
-gdl_dock_param_export_placement (const GValue *src,
- GValue *dst)
-{
- switch (src->data [0].v_int) {
- case GDL_DOCK_NONE:
- dst->data [0].v_pointer = g_strdup ("");
- break;
- case GDL_DOCK_TOP:
- dst->data [0].v_pointer = g_strdup ("top");
- break;
- case GDL_DOCK_BOTTOM:
- dst->data [0].v_pointer = g_strdup ("bottom");
- break;
- case GDL_DOCK_LEFT:
- dst->data [0].v_pointer = g_strdup ("left");
- break;
- case GDL_DOCK_RIGHT:
- dst->data [0].v_pointer = g_strdup ("right");
- break;
- case GDL_DOCK_CENTER:
- dst->data [0].v_pointer = g_strdup ("center");
- break;
- case GDL_DOCK_FLOATING:
- dst->data [0].v_pointer = g_strdup ("floating");
- break;
- }
-}
-
-static void
-gdl_dock_param_import_int (const GValue *src,
- GValue *dst)
-{
- dst->data [0].v_int = atoi (src->data [0].v_pointer);
-}
-
-static void
-gdl_dock_param_import_uint (const GValue *src,
- GValue *dst)
-{
- dst->data [0].v_uint = (guint) atoi (src->data [0].v_pointer);
-}
-
-static void
-gdl_dock_param_import_string (const GValue *src,
- GValue *dst)
-{
- dst->data [0].v_pointer = g_strdup (src->data [0].v_pointer);
-}
-
-static void
-gdl_dock_param_import_bool (const GValue *src,
- GValue *dst)
-{
- dst->data [0].v_int = !strcmp (src->data [0].v_pointer, "yes");
-}
-
-static void
-gdl_dock_param_import_placement (const GValue *src,
- GValue *dst)
-{
- if (!strcmp (src->data [0].v_pointer, "top"))
- dst->data [0].v_int = GDL_DOCK_TOP;
- else if (!strcmp (src->data [0].v_pointer, "bottom"))
- dst->data [0].v_int = GDL_DOCK_BOTTOM;
- else if (!strcmp (src->data [0].v_pointer, "center"))
- dst->data [0].v_int = GDL_DOCK_CENTER;
- else if (!strcmp (src->data [0].v_pointer, "left"))
- dst->data [0].v_int = GDL_DOCK_LEFT;
- else if (!strcmp (src->data [0].v_pointer, "right"))
- dst->data [0].v_int = GDL_DOCK_RIGHT;
- else if (!strcmp (src->data [0].v_pointer, "floating"))
- dst->data [0].v_int = GDL_DOCK_FLOATING;
- else
- dst->data [0].v_int = GDL_DOCK_NONE;
-}
-
-GType
-gdl_dock_param_get_type (void)
-{
- static GType our_type = 0;
-
- if (our_type == 0) {
- GTypeInfo tinfo = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- our_type = g_type_register_static (G_TYPE_STRING, "GdlDockParam", &tinfo, 0);
-
- /* register known transform functions */
- /* exporters */
- g_value_register_transform_func (G_TYPE_INT, our_type, gdl_dock_param_export_int);
- g_value_register_transform_func (G_TYPE_UINT, our_type, gdl_dock_param_export_uint);
- g_value_register_transform_func (G_TYPE_STRING, our_type, gdl_dock_param_export_string);
- g_value_register_transform_func (G_TYPE_BOOLEAN, our_type, gdl_dock_param_export_bool);
- g_value_register_transform_func (GDL_TYPE_DOCK_PLACEMENT, our_type, gdl_dock_param_export_placement);
- /* importers */
- g_value_register_transform_func (our_type, G_TYPE_INT, gdl_dock_param_import_int);
- g_value_register_transform_func (our_type, G_TYPE_UINT, gdl_dock_param_import_uint);
- g_value_register_transform_func (our_type, G_TYPE_STRING, gdl_dock_param_import_string);
- g_value_register_transform_func (our_type, G_TYPE_BOOLEAN, gdl_dock_param_import_bool);
- g_value_register_transform_func (our_type, GDL_TYPE_DOCK_PLACEMENT, gdl_dock_param_import_placement);
- }
-
- return our_type;
-}
-
-/* -------------- nick <-> type conversion functions --------------- */
-
-static void
-gdl_dock_object_register_init (void)
-{
- const size_t n_default = 5;
- guint i = 0;
- struct DockRegisterItem default_items[n_default];
-
- if (dock_register)
- return;
-
- dock_register
- = g_array_new (FALSE, FALSE, sizeof (struct DockRegisterItem));
-
- /* add known types */
- default_items[0].nick = "dock";
- default_items[0].type = (gpointer) GDL_TYPE_DOCK;
- default_items[1].nick = "item";
- default_items[1].type = (gpointer) GDL_TYPE_DOCK_ITEM;
- default_items[2].nick = "paned";
- default_items[2].type = (gpointer) GDL_TYPE_DOCK_PANED;
- default_items[3].nick = "notebook";
- default_items[3].type = (gpointer) GDL_TYPE_DOCK_NOTEBOOK;
- default_items[4].nick = "placeholder";
- default_items[4].type = (gpointer) GDL_TYPE_DOCK_PLACEHOLDER;
-
- for (i = 0; i < n_default; i++)
- g_array_append_val (dock_register, default_items[i]);
-}
-
-/**
- * gdl_dock_object_nick_from_type:
- * @type: The type for which to find the nickname
- *
- * Finds the nickname for a given type
- *
- * Returns: If the object has a nickname, then it is returned.
- * Otherwise, the type name.
- */
-const gchar *
-gdl_dock_object_nick_from_type (GType type)
-{
- gchar *nick = NULL;
- guint i = 0;
-
- if (!dock_register)
- gdl_dock_object_register_init ();
-
- for (i=0; i < dock_register->len; i++) {
- struct DockRegisterItem item
- = g_array_index (dock_register, struct DockRegisterItem, i);
-
- if (g_direct_equal (item.type, (gpointer) type))
- nick = g_strdup (item.nick);
- }
-
- return nick ? nick : g_type_name (type);
-}
-
-/**
- * gdl_dock_object_type_from_nick:
- * @nick: The nickname for the object type
- *
- * Finds the object type assigned to a given nickname.
- *
- * Returns: If the nickname has previously been assigned, then the corresponding
- * object type is returned. Otherwise, %G_TYPE_NONE.
- */
-GType
-gdl_dock_object_type_from_nick (const gchar *nick)
-{
- GType type = G_TYPE_NONE;
- gboolean nick_is_in_register = FALSE;
- guint i = 0;
-
- if (!dock_register)
- gdl_dock_object_register_init ();
-
- for (i = 0; i < dock_register->len; i++) {
- struct DockRegisterItem item
- = g_array_index (dock_register, struct DockRegisterItem, i);
-
- if (!g_strcmp0 (nick, item.nick)) {
- nick_is_in_register = TRUE;
- type = (GType) item.type;
- }
- }
- if (!nick_is_in_register) {
- /* try searching in the glib type system */
- type = g_type_from_name (nick);
- }
-
- return type;
-}
-
-/**
- * gdl_dock_object_set_type_for_nick:
- * @nick: The nickname for the object type
- * @type: The object type
- *
- * Assigns an object type to a given nickname. If the nickname already exists,
- * then it reassigns it to a new object type.
- *
- * Returns: If the nick was previously assigned, the old type is returned.
- * Otherwise, %G_TYPE_NONE.
- */
-GType
-gdl_dock_object_set_type_for_nick (const gchar *nick,
- GType type)
-{
- GType old_type = G_TYPE_NONE;
- guint i = 0;
- struct DockRegisterItem new_item;
- new_item.nick = g_strdup(nick);
- new_item.type = (gpointer) type;
-
- if (!dock_register)
- gdl_dock_object_register_init ();
-
- g_return_val_if_fail (g_type_is_a (type, GDL_TYPE_DOCK_OBJECT), G_TYPE_NONE);
-
- for (i = 0; i < dock_register->len; i++) {
- struct DockRegisterItem item
- = g_array_index (dock_register, struct DockRegisterItem, i);
-
- if (!g_strcmp0 (nick, item.nick)) {
- old_type = (GType) item.type;
- g_array_insert_val (dock_register, i, new_item);
- }
- }
-
- return old_type;
-}
-
diff --git a/src/libgdl/gdl-dock-object.h b/src/libgdl/gdl-dock-object.h
deleted file mode 100644
index f8b192f35..000000000
--- a/src/libgdl/gdl-dock-object.h
+++ /dev/null
@@ -1,225 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * gdl-dock-object.h - Abstract base class for all dock related objects
- *
- * This file is part of the GNOME Devtools Libraries.
- *
- * Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net>
- *
- * This library is free software; you can redistribute it and/or
- * 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
- */
-
-#ifndef __GDL_DOCK_OBJECT_H__
-#define __GDL_DOCK_OBJECT_H__
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-/* standard macros */
-#define GDL_TYPE_DOCK_OBJECT (gdl_dock_object_get_type ())
-#define GDL_DOCK_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_OBJECT, GdlDockObject))
-#define GDL_DOCK_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_OBJECT, GdlDockObjectClass))
-#define GDL_IS_DOCK_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_OBJECT))
-#define GDL_IS_DOCK_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_OBJECT))
-#define GDL_DOCK_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_OBJECT, GdlDockObjectClass))
-
-/* data types & structures */
-typedef enum {
- /* the parameter is to be exported for later layout rebuilding */
- GDL_DOCK_PARAM_EXPORT = 1 << G_PARAM_USER_SHIFT,
- /* the parameter must be set after adding the children objects */
- GDL_DOCK_PARAM_AFTER = 1 << (G_PARAM_USER_SHIFT + 1)
-} GdlDockParamFlags;
-
-#define GDL_DOCK_NAME_PROPERTY "name"
-#define GDL_DOCK_MASTER_PROPERTY "master"
-
-typedef enum {
- GDL_DOCK_AUTOMATIC = 1 << 0,
- GDL_DOCK_ATTACHED = 1 << 1,
- GDL_DOCK_IN_REFLOW = 1 << 2,
- GDL_DOCK_IN_DETACH = 1 << 3
-} GdlDockObjectFlags;
-
-#define GDL_DOCK_OBJECT_FLAGS_SHIFT 8
-
-typedef enum {
- GDL_DOCK_NONE = 0,
- GDL_DOCK_TOP,
- GDL_DOCK_BOTTOM,
- GDL_DOCK_RIGHT,
- GDL_DOCK_LEFT,
- GDL_DOCK_CENTER,
- GDL_DOCK_FLOATING
-} GdlDockPlacement;
-
-typedef struct _GdlDockObject GdlDockObject;
-typedef struct _GdlDockObjectClass GdlDockObjectClass;
-typedef struct _GdlDockRequest GdlDockRequest;
-
-struct _GdlDockRequest {
- GdlDockObject *applicant;
- GdlDockObject *target;
- GdlDockPlacement position;
- GdkRectangle rect;
- GValue extra;
-};
-
-struct _GdlDockObject {
- GtkContainer container;
-
- GdlDockObjectFlags flags;
- gint freeze_count;
-
- GObject *master;
- gchar *name;
- gchar *long_name;
- gchar *stock_id;
- GdkPixbuf *pixbuf_icon;
-
- gboolean reduce_pending;
-};
-
-struct _GdlDockObjectClass {
- GtkContainerClass parent_class;
-
- gboolean is_compound;
-
- void (* detach) (GdlDockObject *object,
- gboolean recursive);
- void (* reduce) (GdlDockObject *object);
-
- gboolean (* dock_request) (GdlDockObject *object,
- gint x,
- gint y,
- GdlDockRequest *request);
-
- void (* dock) (GdlDockObject *object,
- GdlDockObject *requestor,
- GdlDockPlacement position,
- GValue *other_data);
-
- gboolean (* reorder) (GdlDockObject *object,
- GdlDockObject *child,
- GdlDockPlacement new_position,
- GValue *other_data);
-
- void (* present) (GdlDockObject *object,
- GdlDockObject *child);
-
- gboolean (* child_placement) (GdlDockObject *object,
- GdlDockObject *child,
- GdlDockPlacement *placement);
-};
-
-/* additional macros */
-#define GDL_DOCK_OBJECT_FLAGS(obj) (GDL_DOCK_OBJECT (obj)->flags)
-#define GDL_DOCK_OBJECT_AUTOMATIC(obj) \
- ((GDL_DOCK_OBJECT_FLAGS (obj) & GDL_DOCK_AUTOMATIC) != 0)
-#define GDL_DOCK_OBJECT_ATTACHED(obj) \
- ((GDL_DOCK_OBJECT_FLAGS (obj) & GDL_DOCK_ATTACHED) != 0)
-#define GDL_DOCK_OBJECT_IN_REFLOW(obj) \
- ((GDL_DOCK_OBJECT_FLAGS (obj) & GDL_DOCK_IN_REFLOW) != 0)
-#define GDL_DOCK_OBJECT_IN_DETACH(obj) \
- ((GDL_DOCK_OBJECT_FLAGS (obj) & GDL_DOCK_IN_DETACH) != 0)
-
-#define GDL_DOCK_OBJECT_SET_FLAGS(obj,flag) \
- G_STMT_START { (GDL_DOCK_OBJECT_FLAGS (obj) |= (flag)); } G_STMT_END
-#define GDL_DOCK_OBJECT_UNSET_FLAGS(obj,flag) \
- G_STMT_START { (GDL_DOCK_OBJECT_FLAGS (obj) &= ~(flag)); } G_STMT_END
-
-#define GDL_DOCK_OBJECT_FROZEN(obj) (GDL_DOCK_OBJECT (obj)->freeze_count > 0)
-
-
-/* public interface */
-
-GType gdl_dock_object_get_type (void);
-
-gboolean gdl_dock_object_is_compound (GdlDockObject *object);
-
-void gdl_dock_object_detach (GdlDockObject *object,
- gboolean recursive);
-
-GdlDockObject *gdl_dock_object_get_parent_object (GdlDockObject *object);
-
-void gdl_dock_object_freeze (GdlDockObject *object);
-void gdl_dock_object_thaw (GdlDockObject *object);
-
-void gdl_dock_object_reduce (GdlDockObject *object);
-
-gboolean gdl_dock_object_dock_request (GdlDockObject *object,
- gint x,
- gint y,
- GdlDockRequest *request);
-void gdl_dock_object_dock (GdlDockObject *object,
- GdlDockObject *requestor,
- GdlDockPlacement position,
- GValue *other_data);
-
-void gdl_dock_object_bind (GdlDockObject *object,
- GObject *master);
-void gdl_dock_object_unbind (GdlDockObject *object);
-gboolean gdl_dock_object_is_bound (GdlDockObject *object);
-
-gboolean gdl_dock_object_reorder (GdlDockObject *object,
- GdlDockObject *child,
- GdlDockPlacement new_position,
- GValue *other_data);
-
-void gdl_dock_object_present (GdlDockObject *object,
- GdlDockObject *child);
-
-gboolean gdl_dock_object_child_placement (GdlDockObject *object,
- GdlDockObject *child,
- GdlDockPlacement *placement);
-
-/* other types */
-
-/* this type derives from G_TYPE_STRING and is meant to be the basic
- type for serializing object parameters which are exported
- (i.e. those that are needed for layout rebuilding) */
-#define GDL_TYPE_DOCK_PARAM (gdl_dock_param_get_type ())
-
-GType gdl_dock_param_get_type (void);
-
-/* functions for setting/retrieving nick names for serializing GdlDockObject types */
-const gchar *gdl_dock_object_nick_from_type (GType type);
-GType gdl_dock_object_type_from_nick (const gchar *nick);
-GType gdl_dock_object_set_type_for_nick (const gchar *nick,
- GType type);
-
-
-/* helper macros */
-#define GDL_TRACE_OBJECT(object, format, args...) \
- G_STMT_START { \
- g_log (G_LOG_DOMAIN, \
- G_LOG_LEVEL_DEBUG, \
- "%s:%d (%s) %s [%p %d%s:%d]: " format, \
- __FILE__, \
- __LINE__, \
- __PRETTY_FUNCTION__, \
- G_OBJECT_TYPE_NAME (object), object, \
- G_OBJECT (object)->ref_count, \
- (GTK_IS_OBJECT (object) && g_object_is_floating (object)) ? "(float)" : "", \
- GDL_IS_DOCK_OBJECT (object) ? GDL_DOCK_OBJECT (object)->freeze_count : -1, \
- ##args); } G_STMT_END
-
-
-
-G_END_DECLS
-
-#endif /* __GDL_DOCK_OBJECT_H__ */
-
diff --git a/src/libgdl/gdl-dock-paned.c b/src/libgdl/gdl-dock-paned.c
deleted file mode 100644
index 5b4561ef3..000000000
--- a/src/libgdl/gdl-dock-paned.c
+++ /dev/null
@@ -1,678 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * gdl-dock-paned.h
- *
- * This file is part of the GNOME Devtools Libraries.
- *
- * Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net>
- *
- * This library is free software; you can redistribute it and/or
- * 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 <string.h>
-#include <gtk/gtk.h>
-
-#include "gdl-dock-paned.h"
-
-
-/* Private prototypes */
-
-static void gdl_dock_paned_class_init (GdlDockPanedClass *klass);
-static void gdl_dock_paned_init (GdlDockPaned *paned);
-static GObject *gdl_dock_paned_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_param);
-static void gdl_dock_paned_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gdl_dock_paned_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static void gdl_dock_paned_destroy (GtkObject *object);
-
-static void gdl_dock_paned_add (GtkContainer *container,
- GtkWidget *widget);
-static void gdl_dock_paned_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-static GType gdl_dock_paned_child_type (GtkContainer *container);
-
-static gboolean gdl_dock_paned_dock_request (GdlDockObject *object,
- gint x,
- gint y,
- GdlDockRequest *request);
-static void gdl_dock_paned_dock (GdlDockObject *object,
- GdlDockObject *requestor,
- GdlDockPlacement position,
- GValue *other_data);
-
-static void gdl_dock_paned_set_orientation (GdlDockItem *item,
- GtkOrientation orientation);
-
-static gboolean gdl_dock_paned_child_placement (GdlDockObject *object,
- GdlDockObject *child,
- GdlDockPlacement *placement);
-
-
-/* ----- Class variables and definitions ----- */
-
-#define SPLIT_RATIO 0.3
-
-enum {
- PROP_0,
- PROP_POSITION
-};
-
-
-/* ----- Private functions ----- */
-
-G_DEFINE_TYPE (GdlDockPaned, gdl_dock_paned, GDL_TYPE_DOCK_ITEM);
-
-static void
-gdl_dock_paned_class_init (GdlDockPanedClass *klass)
-{
- GObjectClass *g_object_class;
- GtkObjectClass *gtk_object_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
- GdlDockObjectClass *object_class;
- GdlDockItemClass *item_class;
-
- g_object_class = G_OBJECT_CLASS (klass);
- gtk_object_class = GTK_OBJECT_CLASS (klass);
- widget_class = GTK_WIDGET_CLASS (klass);
- container_class = GTK_CONTAINER_CLASS (klass);
- object_class = GDL_DOCK_OBJECT_CLASS (klass);
- item_class = GDL_DOCK_ITEM_CLASS (klass);
-
- g_object_class->set_property = gdl_dock_paned_set_property;
- g_object_class->get_property = gdl_dock_paned_get_property;
- g_object_class->constructor = gdl_dock_paned_constructor;
-
- gtk_object_class->destroy = gdl_dock_paned_destroy;
-
- container_class->add = gdl_dock_paned_add;
- container_class->forall = gdl_dock_paned_forall;
- container_class->child_type = gdl_dock_paned_child_type;
-
- object_class->is_compound = TRUE;
-
- object_class->dock_request = gdl_dock_paned_dock_request;
- object_class->dock = gdl_dock_paned_dock;
- object_class->child_placement = gdl_dock_paned_child_placement;
-
- item_class->has_grip = FALSE;
- item_class->set_orientation = gdl_dock_paned_set_orientation;
-
- g_object_class_install_property (
- g_object_class, PROP_POSITION,
- g_param_spec_uint ("position", _("Position"),
- _("Position of the divider in pixels"),
- 0, G_MAXINT, 0,
- G_PARAM_READWRITE |
- GDL_DOCK_PARAM_EXPORT | GDL_DOCK_PARAM_AFTER));
-}
-
-static void
-gdl_dock_paned_init (GdlDockPaned *paned)
-{
- paned->position_changed = FALSE;
-}
-
-static void
-gdl_dock_paned_notify_cb (GObject *g_object,
- GParamSpec *pspec,
- gpointer user_data)
-{
- GdlDockPaned *paned;
-
- g_return_if_fail (user_data != NULL && GDL_IS_DOCK_PANED (user_data));
-
- /* chain the notification to the GdlDockPaned */
- g_object_notify (G_OBJECT (user_data), pspec->name);
-
- paned = GDL_DOCK_PANED (user_data);
-
- if (GDL_DOCK_ITEM_USER_ACTION (user_data) && !strcmp (pspec->name, "position"))
- paned->position_changed = TRUE;
-}
-
-static gboolean
-gdl_dock_paned_button_cb (GtkWidget *widget,
- GdkEventButton *event,
- gpointer user_data)
-{
- GdlDockPaned *paned;
-
- g_return_val_if_fail (user_data != NULL && GDL_IS_DOCK_PANED (user_data), FALSE);
-
- paned = GDL_DOCK_PANED (user_data);
- if (event->button == 1) {
- if (event->type == GDK_BUTTON_PRESS)
- GDL_DOCK_ITEM_SET_FLAGS (user_data, GDL_DOCK_USER_ACTION);
- else {
- GDL_DOCK_ITEM_UNSET_FLAGS (user_data, GDL_DOCK_USER_ACTION);
- if (paned->position_changed) {
- /* emit pending layout changed signal to track separator position */
- if (GDL_DOCK_OBJECT (paned)->master)
- g_signal_emit_by_name (GDL_DOCK_OBJECT (paned)->master, "layout-changed");
- paned->position_changed = FALSE;
- }
- }
- }
-
- return FALSE;
-}
-
-static void
-gdl_dock_paned_create_child (GdlDockPaned *paned,
- GtkOrientation orientation)
-{
- GdlDockItem *item;
-
- item = GDL_DOCK_ITEM (paned);
-
- if (item->child)
- gtk_widget_unparent (GTK_WIDGET (item->child));
-
- /* create the container paned */
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- item->child = gtk_hpaned_new ();
- else
- item->child = gtk_vpaned_new ();
-
- /* get notification for propagation */
- g_signal_connect (item->child, "notify::position",
- (GCallback) gdl_dock_paned_notify_cb, (gpointer) item);
- g_signal_connect (item->child, "button-press-event",
- (GCallback) gdl_dock_paned_button_cb, (gpointer) item);
- g_signal_connect (item->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);
-}
-
-static GObject *
-gdl_dock_paned_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_param)
-{
- GObject *g_object;
-
- g_object = G_OBJECT_CLASS (gdl_dock_paned_parent_class)-> constructor (type,
- n_construct_properties,
- construct_param);
- if (g_object) {
- GdlDockItem *item = GDL_DOCK_ITEM (g_object);
-
- if (!item->child)
- gdl_dock_paned_create_child (GDL_DOCK_PANED (g_object),
- item->orientation);
- /* otherwise, the orientation was set as a construction
- parameter and the child is already created */
- }
-
- return g_object;
-}
-
-static void
-gdl_dock_paned_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GdlDockItem *item = GDL_DOCK_ITEM (object);
-
- switch (prop_id) {
- case PROP_POSITION:
- if (item->child && GTK_IS_PANED (item->child))
- gtk_paned_set_position (GTK_PANED (item->child),
- g_value_get_uint (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gdl_dock_paned_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GdlDockItem *item = GDL_DOCK_ITEM (object);
-
- switch (prop_id) {
- case PROP_POSITION:
- if (item->child && GTK_IS_PANED (item->child))
- g_value_set_uint (value,
- gtk_paned_get_position (GTK_PANED (item->child)));
- else
- g_value_set_uint (value, 0);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gdl_dock_paned_destroy (GtkObject *object)
-{
- GdlDockItem *item = GDL_DOCK_ITEM (object);
-
- /* we need to call the virtual first, since in GdlDockDestroy our
- children dock objects are detached */
- GTK_OBJECT_CLASS (gdl_dock_paned_parent_class)->destroy (object);
-
- /* after that we can remove the GtkNotebook */
- if (item->child) {
- gtk_widget_unparent (item->child);
- item->child = NULL;
- };
-}
-
-static void
-gdl_dock_paned_add (GtkContainer *container,
- GtkWidget *widget)
-{
- GdlDockItem *item;
- GdlDockPlacement pos = GDL_DOCK_NONE;
- GtkPaned *paned;
- GtkWidget *child1, *child2;
-
- g_return_if_fail (container != NULL && widget != NULL);
- g_return_if_fail (GDL_IS_DOCK_PANED (container));
- g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
-
- item = GDL_DOCK_ITEM (container);
- g_return_if_fail (item->child != NULL);
-
- paned = GTK_PANED (item->child);
- 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 ?
- GDL_DOCK_LEFT : GDL_DOCK_TOP;
- else if (!child2)
- pos = item->orientation == GTK_ORIENTATION_HORIZONTAL ?
- GDL_DOCK_RIGHT : GDL_DOCK_BOTTOM;
-
- if (pos != GDL_DOCK_NONE)
- gdl_dock_object_dock (GDL_DOCK_OBJECT (container),
- GDL_DOCK_OBJECT (widget),
- pos, NULL);
-}
-
-static void
-gdl_dock_paned_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data)
-{
- GdlDockItem *item;
-
- g_return_if_fail (container != NULL);
- g_return_if_fail (GDL_IS_DOCK_PANED (container));
- g_return_if_fail (callback != NULL);
-
- if (include_internals) {
- /* use GdlDockItem's forall */
- GTK_CONTAINER_CLASS (gdl_dock_paned_parent_class)->forall
- (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);
- }
-}
-
-static GType
-gdl_dock_paned_child_type (GtkContainer *container)
-{
- GdlDockItem *item = GDL_DOCK_ITEM (container);
-
- if (gtk_container_child_type (GTK_CONTAINER (item->child)) == G_TYPE_NONE)
- return G_TYPE_NONE;
- else
- return GDL_TYPE_DOCK_ITEM;
-}
-
-static void
-gdl_dock_paned_request_foreach (GdlDockObject *object,
- gpointer user_data)
-{
- struct {
- gint x, y;
- GdlDockRequest *request;
- gboolean may_dock;
- } *data = user_data;
-
- GdlDockRequest my_request;
- gboolean may_dock;
-
- my_request = *data->request;
- may_dock = gdl_dock_object_dock_request (object, data->x, data->y, &my_request);
- if (may_dock) {
- data->may_dock = TRUE;
- *data->request = my_request;
- }
-}
-
-static gboolean
-gdl_dock_paned_dock_request (GdlDockObject *object,
- gint x,
- gint y,
- GdlDockRequest *request)
-{
- GdlDockItem *item;
- guint bw;
- gint rel_x, rel_y;
- GtkAllocation alloc;
- gboolean may_dock = FALSE;
- GdlDockRequest my_request;
-
- g_return_val_if_fail (GDL_IS_DOCK_ITEM (object), FALSE);
-
- /* we get (x,y) in our allocation coordinates system */
-
- item = GDL_DOCK_ITEM (object);
-
- /* Get item's allocation. */
- gtk_widget_get_allocation (GTK_WIDGET (object), &alloc);
- bw = gtk_container_get_border_width (GTK_CONTAINER (object));
-
- /* Get coordinates relative to our window. */
- rel_x = x - alloc.x;
- rel_y = y - alloc.y;
-
- if (request)
- my_request = *request;
-
- /* Check if coordinates are inside the widget. */
- if (rel_x > 0 && rel_x < alloc.width &&
- rel_y > 0 && rel_y < alloc.height) {
- GtkRequisition my, other;
- gint divider = -1;
-
- gdl_dock_item_preferred_size (GDL_DOCK_ITEM (my_request.applicant), &other);
- gdl_dock_item_preferred_size (GDL_DOCK_ITEM (object), &my);
-
- /* It's inside our area. */
- may_dock = TRUE;
-
- /* Set docking indicator rectangle to the widget size. */
- my_request.rect.x = bw;
- my_request.rect.y = bw;
- my_request.rect.width = alloc.width - 2*bw;
- my_request.rect.height = alloc.height - 2*bw;
-
- my_request.target = object;
-
- /* See if it's in the border_width band. */
- if (rel_x < (gint)bw) {
- my_request.position = GDL_DOCK_LEFT;
- my_request.rect.width *= SPLIT_RATIO;
- divider = other.width;
- } else if (rel_x > alloc.width - (gint)bw) {
- my_request.position = GDL_DOCK_RIGHT;
- my_request.rect.x += my_request.rect.width * (1 - SPLIT_RATIO);
- my_request.rect.width *= SPLIT_RATIO;
- divider = MAX (0, my.width - other.width);
- } else if (rel_y < (gint)bw) {
- my_request.position = GDL_DOCK_TOP;
- my_request.rect.height *= SPLIT_RATIO;
- divider = other.height;
- } else if (rel_y > alloc.height - (gint)bw) {
- my_request.position = GDL_DOCK_BOTTOM;
- my_request.rect.y += my_request.rect.height * (1 - SPLIT_RATIO);
- my_request.rect.height *= SPLIT_RATIO;
- divider = MAX (0, my.height - other.height);
-
- } else { /* Otherwise try our children. */
- struct {
- gint x, y;
- GdlDockRequest *request;
- gboolean may_dock;
- } data;
-
- /* give them coordinates in their allocation system... the
- GtkPaned has no window, so our children allocation
- coordinates are our window coordinates */
- data.x = rel_x;
- data.y = rel_y;
- data.request = &my_request;
- data.may_dock = FALSE;
-
- gtk_container_foreach (GTK_CONTAINER (object),
- (GtkCallback) gdl_dock_paned_request_foreach,
- &data);
-
- may_dock = data.may_dock;
- if (!may_dock) {
- /* the pointer is on the handle, so snap to top/bottom
- or left/right */
- may_dock = TRUE;
- if (item->orientation == GTK_ORIENTATION_HORIZONTAL) {
- if (rel_y < alloc.height / 2) {
- my_request.position = GDL_DOCK_TOP;
- my_request.rect.height *= SPLIT_RATIO;
- divider = other.height;
- } else {
- my_request.position = GDL_DOCK_BOTTOM;
- my_request.rect.y += my_request.rect.height * (1 - SPLIT_RATIO);
- my_request.rect.height *= SPLIT_RATIO;
- divider = MAX (0, my.height - other.height);
- }
- } else {
- if (rel_x < alloc.width / 2) {
- my_request.position = GDL_DOCK_LEFT;
- my_request.rect.width *= SPLIT_RATIO;
- divider = other.width;
- } else {
- my_request.position = GDL_DOCK_RIGHT;
- my_request.rect.x += my_request.rect.width * (1 - SPLIT_RATIO);
- my_request.rect.width *= SPLIT_RATIO;
- divider = MAX (0, my.width - other.width);
- }
- }
- }
- }
-
- if (divider >= 0 && my_request.position != GDL_DOCK_CENTER) {
- if (G_IS_VALUE (&my_request.extra))
- g_value_unset (&my_request.extra);
- g_value_init (&my_request.extra, G_TYPE_UINT);
- g_value_set_uint (&my_request.extra, (guint) divider);
- }
-
- if (may_dock) {
- /* adjust returned coordinates so they are relative to
- our allocation */
- my_request.rect.x += alloc.x;
- my_request.rect.y += alloc.y;
- }
- }
-
- if (may_dock && request)
- *request = my_request;
-
- return may_dock;
-}
-
-static void
-gdl_dock_paned_dock (GdlDockObject *object,
- GdlDockObject *requestor,
- GdlDockPlacement position,
- GValue *other_data)
-{
- GtkPaned *paned;
- GtkWidget *child1, *child2;
- gboolean done = FALSE;
- gboolean hresize = FALSE;
- gboolean wresize = FALSE;
- gint temp = 0;
-
- g_return_if_fail (GDL_IS_DOCK_PANED (object));
- g_return_if_fail (GDL_DOCK_ITEM (object)->child != NULL);
-
- paned = GTK_PANED (GDL_DOCK_ITEM (object)->child);
-
- if (GDL_IS_DOCK_ITEM (requestor)) {
- g_object_get (G_OBJECT (requestor), "preferred_height", &temp, NULL);
- if (temp == -2)
- hresize = TRUE;
- temp = 0;
- g_object_get (G_OBJECT (requestor), "preferred_width", &temp, NULL);
- if (temp == -2)
- wresize = TRUE;
- }
-
- child1 = gtk_paned_get_child1 (paned);
- child2 = gtk_paned_get_child2 (paned);
-
- /* see if we can dock the item in our paned */
- switch (GDL_DOCK_ITEM (object)->orientation) {
- case GTK_ORIENTATION_HORIZONTAL:
- if (!child1 && position == GDL_DOCK_LEFT) {
- gtk_paned_pack1 (paned, GTK_WIDGET (requestor), FALSE, FALSE);
- done = TRUE;
- } else if (!child2 && position == GDL_DOCK_RIGHT) {
- gtk_paned_pack2 (paned, GTK_WIDGET (requestor), TRUE, FALSE);
- done = TRUE;
- }
- break;
- case GTK_ORIENTATION_VERTICAL:
- if (!child1 && position == GDL_DOCK_TOP) {
- gtk_paned_pack1 (paned, GTK_WIDGET (requestor), hresize, FALSE);
- done = TRUE;
- } else if (!child2 && position == GDL_DOCK_BOTTOM) {
- gtk_paned_pack2 (paned, GTK_WIDGET (requestor), hresize, FALSE);
- done = TRUE;
- }
- break;
- default:
- break;
- }
-
- if (!done) {
- /* this will create another paned and reparent us there */
- GDL_DOCK_OBJECT_CLASS (gdl_dock_paned_parent_class)->dock (object, requestor, position,
- other_data);
- }
- else {
- gdl_dock_item_show_grip (GDL_DOCK_ITEM (requestor));
- gtk_widget_show (GTK_WIDGET (requestor));
- GDL_DOCK_OBJECT_SET_FLAGS (requestor, GDL_DOCK_ATTACHED);
- }
-}
-
-static void
-gdl_dock_paned_set_orientation (GdlDockItem *item,
- GtkOrientation orientation)
-{
- GtkPaned *old_paned = NULL, *new_paned;
- GtkWidget *child1, *child2;
-
- g_return_if_fail (GDL_IS_DOCK_PANED (item));
-
- if (item->child) {
- old_paned = GTK_PANED (item->child);
- g_object_ref (old_paned);
- gtk_widget_unparent (GTK_WIDGET (old_paned));
- item->child = NULL;
- }
-
- gdl_dock_paned_create_child (GDL_DOCK_PANED (item), orientation);
-
- if (old_paned) {
- new_paned = GTK_PANED (item->child);
- child1 = gtk_paned_get_child1 (old_paned);
- child2 = gtk_paned_get_child2 (old_paned);
-
- if (child1) {
- g_object_ref (child1);
- gtk_container_remove (GTK_CONTAINER (old_paned), child1);
- gtk_paned_pack1 (new_paned, child1, TRUE, FALSE);
- g_object_unref (child1);
- }
- if (child2) {
- g_object_ref (child2);
- gtk_container_remove (GTK_CONTAINER (old_paned), child2);
- gtk_paned_pack1 (new_paned, child2, TRUE, FALSE);
- g_object_unref (child2);
- }
- }
-
- GDL_DOCK_ITEM_CLASS (gdl_dock_paned_parent_class)->set_orientation (item, orientation);
-}
-
-static gboolean
-gdl_dock_paned_child_placement (GdlDockObject *object,
- GdlDockObject *child,
- GdlDockPlacement *placement)
-{
- GdlDockItem *item = GDL_DOCK_ITEM (object);
- GtkPaned *paned;
- GdlDockPlacement pos = GDL_DOCK_NONE;
-
- if (item->child) {
- paned = GTK_PANED (item->child);
- if (GTK_WIDGET (child) == gtk_paned_get_child1 (paned))
- pos = item->orientation == GTK_ORIENTATION_HORIZONTAL ?
- GDL_DOCK_LEFT : GDL_DOCK_TOP;
- else if (GTK_WIDGET (child) == gtk_paned_get_child2 (paned))
- pos = item->orientation == GTK_ORIENTATION_HORIZONTAL ?
- GDL_DOCK_RIGHT : GDL_DOCK_BOTTOM;
- }
-
- if (pos != GDL_DOCK_NONE) {
- if (placement)
- *placement = pos;
- return TRUE;
- }
- else
- return FALSE;
-}
-
-
-/* ----- Public interface ----- */
-
-GtkWidget *
-gdl_dock_paned_new (GtkOrientation orientation)
-{
- GdlDockPaned *paned;
-
- paned = GDL_DOCK_PANED (g_object_new (GDL_TYPE_DOCK_PANED,
- "orientation", orientation, NULL));
- GDL_DOCK_OBJECT_UNSET_FLAGS (paned, GDL_DOCK_AUTOMATIC);
-
- return GTK_WIDGET (paned);
-}
-
diff --git a/src/libgdl/gdl-dock-paned.h b/src/libgdl/gdl-dock-paned.h
deleted file mode 100644
index 2b4a40700..000000000
--- a/src/libgdl/gdl-dock-paned.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * gdl-dock-paned.h
- *
- * This file is part of the GNOME Devtools Libraries.
- *
- * Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net>
- *
- * This library is free software; you can redistribute it and/or
- * 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
- */
-
-#ifndef __GDL_DOCK_PANED_H__
-#define __GDL_DOCK_PANED_H__
-
-#include "libgdl/gdl-dock-item.h"
-
-G_BEGIN_DECLS
-
-/* standard macros */
-#define GDL_TYPE_DOCK_PANED (gdl_dock_paned_get_type ())
-#define GDL_DOCK_PANED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_PANED, GdlDockPaned))
-#define GDL_DOCK_PANED_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_PANED, GdlDockPanedClass))
-#define GDL_IS_DOCK_PANED(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_PANED))
-#define GDL_IS_DOCK_PANED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_PANED))
-#define GDL_DOCK_PANED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDL_TYE_DOCK_PANED, GdlDockPanedClass))
-
-/* data types & structures */
-typedef struct _GdlDockPaned GdlDockPaned;
-typedef struct _GdlDockPanedClass GdlDockPanedClass;
-
-struct _GdlDockPaned {
- GdlDockItem dock_item;
-
- gboolean position_changed;
-};
-
-struct _GdlDockPanedClass {
- GdlDockItemClass parent_class;
-};
-
-
-/* public interface */
-
-GType gdl_dock_paned_get_type (void);
-
-GtkWidget *gdl_dock_paned_new (GtkOrientation orientation);
-
-
-G_END_DECLS
-
-#endif /* __GDL_DOCK_PANED_H__ */
-
diff --git a/src/libgdl/gdl-dock-placeholder.c b/src/libgdl/gdl-dock-placeholder.c
deleted file mode 100644
index 8cde7a51d..000000000
--- a/src/libgdl/gdl-dock-placeholder.c
+++ /dev/null
@@ -1,827 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * gdl-dock-placeholder.c - Placeholders for docking items
- *
- * This file is part of the GNOME Devtools Libraries.
- *
- * Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net>
- *
- * This library is free software; you can redistribute it and/or
- * 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 "gdl-dock-placeholder.h"
-#include "gdl-dock-item.h"
-#include "gdl-dock-paned.h"
-#include "gdl-dock-master.h"
-#include "libgdltypebuiltins.h"
-
-
-#undef PLACEHOLDER_DEBUG
-
-/* ----- Private prototypes ----- */
-
-static void gdl_dock_placeholder_class_init (GdlDockPlaceholderClass *klass);
-
-static void gdl_dock_placeholder_set_property (GObject *g_object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gdl_dock_placeholder_get_property (GObject *g_object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static void gdl_dock_placeholder_destroy (GtkObject *object);
-
-static void gdl_dock_placeholder_add (GtkContainer *container,
- GtkWidget *widget);
-
-static void gdl_dock_placeholder_detach (GdlDockObject *object,
- gboolean recursive);
-static void gdl_dock_placeholder_reduce (GdlDockObject *object);
-static void gdl_dock_placeholder_dock (GdlDockObject *object,
- GdlDockObject *requestor,
- GdlDockPlacement position,
- GValue *other_data);
-
-static void gdl_dock_placeholder_weak_notify (gpointer data,
- GObject *old_object);
-
-static void disconnect_host (GdlDockPlaceholder *ph);
-static void connect_host (GdlDockPlaceholder *ph,
- GdlDockObject *new_host);
-static void do_excursion (GdlDockPlaceholder *ph);
-
-static void gdl_dock_placeholder_present (GdlDockObject *object,
- GdlDockObject *child);
-
-static void detach_cb (GdlDockObject *object,
- gboolean recursive,
- gpointer user_data);
-
-/* ----- Private variables and data structures ----- */
-
-enum {
- PROP_0,
- PROP_STICKY,
- PROP_HOST,
- PROP_NEXT_PLACEMENT,
- PROP_WIDTH,
- PROP_HEIGHT,
- PROP_FLOATING,
- PROP_FLOAT_X,
- PROP_FLOAT_Y
-};
-
-struct _GdlDockPlaceholderPrivate {
- /* current object this placeholder is pinned to */
- GdlDockObject *host;
- gboolean sticky;
-
- /* when the placeholder is moved up the hierarchy, this stack
- keeps track of the necessary dock positions needed to get the
- placeholder to the original position */
- GSList *placement_stack;
-
- /* Width and height of the attachments */
- gint width;
- gint height;
-
- /* connected signal handlers */
- guint host_detach_handler;
- guint host_dock_handler;
-
- /* Window Coordinates if Dock was floating */
- gboolean floating;
- gint floatx;
- gint floaty;
-};
-
-
-/* ----- Private interface ----- */
-
-G_DEFINE_TYPE (GdlDockPlaceholder, gdl_dock_placeholder, GDL_TYPE_DOCK_OBJECT);
-
-static void
-gdl_dock_placeholder_class_init (GdlDockPlaceholderClass *klass)
-{
- GObjectClass *g_object_class;
- GtkObjectClass *gtk_object_class;
- GtkContainerClass *container_class;
- GdlDockObjectClass *object_class;
-
- g_object_class = G_OBJECT_CLASS (klass);
- gtk_object_class = GTK_OBJECT_CLASS (klass);
- container_class = GTK_CONTAINER_CLASS (klass);
- object_class = GDL_DOCK_OBJECT_CLASS (klass);
-
- g_object_class->get_property = gdl_dock_placeholder_get_property;
- g_object_class->set_property = gdl_dock_placeholder_set_property;
-
- 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));
-
- g_object_class_install_property (
- 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));
-
- /* 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));
-
- 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));
-
- 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));
- 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 for 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 for 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;
-
- object_class->is_compound = FALSE;
- object_class->detach = gdl_dock_placeholder_detach;
- object_class->reduce = gdl_dock_placeholder_reduce;
- object_class->dock = gdl_dock_placeholder_dock;
- object_class->present = gdl_dock_placeholder_present;
-}
-
-static void
-gdl_dock_placeholder_init (GdlDockPlaceholder *ph)
-{
- gtk_widget_set_has_window (GTK_WIDGET (ph), FALSE);
- gtk_widget_set_can_focus (GTK_WIDGET (ph), FALSE);
-
- ph->_priv = g_new0 (GdlDockPlaceholderPrivate, 1);
-}
-
-static void
-gdl_dock_placeholder_set_property (GObject *g_object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GdlDockPlaceholder *ph = GDL_DOCK_PLACEHOLDER (g_object);
-
- switch (prop_id) {
- case PROP_STICKY:
- if (ph->_priv)
- ph->_priv->sticky = g_value_get_boolean (value);
- break;
- case PROP_HOST:
- gdl_dock_placeholder_attach (ph, g_value_get_object (value));
- break;
- case PROP_NEXT_PLACEMENT:
- if (ph->_priv) {
- ph->_priv->placement_stack =
- g_slist_prepend (ph->_priv->placement_stack,
- GINT_TO_POINTER (g_value_get_enum (value)));
- }
- break;
- case PROP_WIDTH:
- ph->_priv->width = g_value_get_int (value);
- break;
- 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;
- }
-}
-
-static void
-gdl_dock_placeholder_get_property (GObject *g_object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GdlDockPlaceholder *ph = GDL_DOCK_PLACEHOLDER (g_object);
-
- switch (prop_id) {
- case PROP_STICKY:
- if (ph->_priv)
- g_value_set_boolean (value, ph->_priv->sticky);
- else
- g_value_set_boolean (value, FALSE);
- break;
- case PROP_HOST:
- if (ph->_priv)
- g_value_set_object (value, ph->_priv->host);
- else
- g_value_set_object (value, NULL);
- break;
- case PROP_NEXT_PLACEMENT:
- if (ph->_priv && ph->_priv->placement_stack)
- g_value_set_enum (value, (GdlDockPlacement) ph->_priv->placement_stack->data);
- else
- g_value_set_enum (value, GDL_DOCK_CENTER);
- break;
- case PROP_WIDTH:
- g_value_set_int (value, ph->_priv->width);
- 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);
- break;
- }
-}
-
-static void
-gdl_dock_placeholder_destroy (GtkObject *object)
-{
- GdlDockPlaceholder *ph = GDL_DOCK_PLACEHOLDER (object);
-
- if (ph->_priv) {
- if (ph->_priv->host)
- gdl_dock_placeholder_detach (GDL_DOCK_OBJECT (object), FALSE);
- g_free (ph->_priv);
- ph->_priv = NULL;
- }
-
- GTK_OBJECT_CLASS (gdl_dock_placeholder_parent_class)->destroy (object);
-}
-
-static void
-gdl_dock_placeholder_add (GtkContainer *container,
- GtkWidget *widget)
-{
- GdlDockPlaceholder *ph;
- GdlDockPlacement pos = GDL_DOCK_CENTER; /* default position */
-
- g_return_if_fail (GDL_IS_DOCK_PLACEHOLDER (container));
- g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
-
- ph = GDL_DOCK_PLACEHOLDER (container);
- if (ph->_priv->placement_stack)
- pos = (GdlDockPlacement) ph->_priv->placement_stack->data;
-
- gdl_dock_object_dock (GDL_DOCK_OBJECT (ph), GDL_DOCK_OBJECT (widget),
- pos, NULL);
-}
-
-static void
-gdl_dock_placeholder_detach (GdlDockObject *object,
- gboolean recursive)
-{
- GdlDockPlaceholder *ph = GDL_DOCK_PLACEHOLDER (object);
-
- /* disconnect handlers */
- disconnect_host (ph);
-
- /* free the placement stack */
- g_slist_free (ph->_priv->placement_stack);
- ph->_priv->placement_stack = NULL;
-
- GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_ATTACHED);
-}
-
-static void
-gdl_dock_placeholder_reduce (GdlDockObject *object)
-{
- /* placeholders are not reduced */
- return;
-}
-
-static void
-find_biggest_dock_item (GtkContainer *container, GtkWidget **biggest_child,
- gint *biggest_child_area)
-{
- GList *children, *child;
- GtkAllocation allocation;
-
- children = gtk_container_get_children (GTK_CONTAINER (container));
- child = children;
- while (child) {
- gint area;
- GtkWidget *child_widget;
-
- child_widget = GTK_WIDGET (child->data);
-
- if (gdl_dock_object_is_compound (GDL_DOCK_OBJECT(child_widget))) {
- find_biggest_dock_item (GTK_CONTAINER (child_widget),
- biggest_child, biggest_child_area);
- child = g_list_next (child);
- continue;
- }
- gtk_widget_get_allocation (child_widget, &allocation);
- area = allocation.width * allocation.height;
-
- if (area > *biggest_child_area) {
- *biggest_child_area = area;
- *biggest_child = child_widget;
- }
- child = g_list_next (child);
- }
-}
-
-static void
-attempt_to_dock_on_host (GdlDockPlaceholder *ph, GdlDockObject *host,
- GdlDockObject *requestor, GdlDockPlacement placement,
- gpointer other_data)
-{
- GdlDockObject *parent;
- GtkAllocation allocation;
- gint host_width;
- gint host_height;
-
- gtk_widget_get_allocation (GTK_WIDGET (host), &allocation);
- host_width = allocation.width;
- host_height = allocation.height;
-
- if (placement != GDL_DOCK_CENTER || !GDL_IS_DOCK_PANED (host)) {
- /* we simply act as a proxy for our host */
- gdl_dock_object_dock (host, requestor,
- placement, other_data);
- } else {
- /* If the requested pos is center, we have to make sure that it
- * does not colapses existing paned items. Find the larget item
- * which is not a paned item to dock to.
- */
- GtkWidget *biggest_child = NULL;
- gint biggest_child_area = 0;
-
- find_biggest_dock_item (GTK_CONTAINER (host), &biggest_child,
- &biggest_child_area);
-
- if (biggest_child) {
- /* we simply act as a proxy for our host */
- gdl_dock_object_dock (GDL_DOCK_OBJECT (biggest_child), requestor,
- placement, other_data);
- } else {
- g_warning ("No suitable child found! Should not be here!");
- /* we simply act as a proxy for our host */
- gdl_dock_object_dock (GDL_DOCK_OBJECT (host), requestor,
- placement, other_data);
- }
- }
-
- parent = gdl_dock_object_get_parent_object (requestor);
-
- /* Restore dock item's dimention */
- switch (placement) {
- case GDL_DOCK_LEFT:
- if (ph->_priv->width > 0) {
- g_object_set (G_OBJECT (parent), "position",
- ph->_priv->width, NULL);
- }
- break;
- case GDL_DOCK_RIGHT:
- if (ph->_priv->width > 0) {
- gint complementary_width = host_width - ph->_priv->width;
-
- if (complementary_width > 0)
- g_object_set (G_OBJECT (parent), "position",
- complementary_width, NULL);
- }
- break;
- case GDL_DOCK_TOP:
- if (ph->_priv->height > 0) {
- g_object_set (G_OBJECT (parent), "position",
- ph->_priv->height, NULL);
- }
- break;
- case GDL_DOCK_BOTTOM:
- if (ph->_priv->height > 0) {
- gint complementary_height = host_height - ph->_priv->height;
-
- if (complementary_height > 0)
- g_object_set (G_OBJECT (parent), "position",
- complementary_height, NULL);
- }
- break;
- default:
- /* nothing */
- break;
- }
-}
-
-static void
-gdl_dock_placeholder_dock (GdlDockObject *object,
- GdlDockObject *requestor,
- GdlDockPlacement position,
- GValue *other_data)
-{
- GdlDockPlaceholder *ph = GDL_DOCK_PLACEHOLDER (object);
-
- if (ph->_priv->host) {
- attempt_to_dock_on_host (ph, ph->_priv->host, requestor,
- position, other_data);
- }
- else {
- GdlDockObject *toplevel;
-
- if (!gdl_dock_object_is_bound (GDL_DOCK_OBJECT (ph))) {
- g_warning ("%s", _("Attempt to dock a dock object to an unbound placeholder"));
- return;
- }
-
- /* dock the item as a floating of the controller */
- toplevel = gdl_dock_master_get_controller (GDL_DOCK_OBJECT_GET_MASTER (ph));
- gdl_dock_object_dock (toplevel, requestor,
- GDL_DOCK_FLOATING, NULL);
- }
-}
-
-#ifdef PLACEHOLDER_DEBUG
-static void
-print_placement_stack (GdlDockPlaceholder *ph)
-{
- GSList *s = ph->_priv->placement_stack;
- GEnumClass *enum_class = G_ENUM_CLASS (g_type_class_ref (GDL_TYPE_DOCK_PLACEMENT));
- GEnumValue *enum_value;
- gchar *name;
- GString *message;
-
- message = g_string_new (NULL);
- g_string_printf (message, "[%p] host: %p (%s), stack: ",
- ph, ph->_priv->host, G_OBJECT_TYPE_NAME (ph->_priv->host));
- for (; s; s = s->next) {
- enum_value = g_enum_get_value (enum_class, (GdlDockPlacement) s->data);
- name = enum_value ? enum_value->value_name : NULL;
- g_string_append_printf (message, "%s, ", name);
- }
- g_message ("%s", message->str);
-
- g_string_free (message, TRUE);
- g_type_class_unref (enum_class);
-}
-#endif
-
-static void
-gdl_dock_placeholder_present (GdlDockObject *object,
- GdlDockObject *child)
-{
- /* do nothing */
- return;
-}
-
-/* ----- Public interface ----- */
-
-GtkWidget *
-gdl_dock_placeholder_new (const gchar *name,
- GdlDockObject *object,
- GdlDockPlacement position,
- gboolean sticky)
-{
- GdlDockPlaceholder *ph;
-
- ph = GDL_DOCK_PLACEHOLDER (g_object_new (GDL_TYPE_DOCK_PLACEHOLDER,
- "name", name,
- "sticky", sticky,
- "next-placement", position,
- "host", object,
- NULL));
- GDL_DOCK_OBJECT_UNSET_FLAGS (ph, GDL_DOCK_AUTOMATIC);
-
- return GTK_WIDGET (ph);
-}
-
-static void
-gdl_dock_placeholder_weak_notify (gpointer data,
- GObject *old_object)
-{
- GdlDockPlaceholder *ph;
-
- g_return_if_fail (data != NULL && GDL_IS_DOCK_PLACEHOLDER (data));
-
- ph = GDL_DOCK_PLACEHOLDER (data);
-
-#ifdef PLACEHOLDER_DEBUG
- g_message ("The placeholder just lost its host, ph = %p", ph);
-#endif
-
- /* we shouldn't get here, so perform an emergency detach. instead
- we should have gotten a detach signal from our host */
- ph->_priv->host = NULL;
-
- /* We didn't get a detach signal from the host. Detach from the
- supposedly dead host (consequently attaching to the controller) */
-
- detach_cb (NULL, TRUE, data);
-#if 0
- /* free the placement stack */
- g_slist_free (ph->_priv->placement_stack);
- ph->_priv->placement_stack = NULL;
- GDL_DOCK_OBJECT_UNSET_FLAGS (ph, GDL_DOCK_ATTACHED);
-#endif
-}
-
-static void
-detach_cb (GdlDockObject *object,
- gboolean recursive,
- gpointer user_data)
-{
- GdlDockPlaceholder *ph;
- GdlDockObject *new_host, *obj;
-
- g_return_if_fail (user_data != NULL && GDL_IS_DOCK_PLACEHOLDER (user_data));
-
- /* we go up in the hierarchy and we store the hinted placement in
- * the placement stack so we can rebuild the docking layout later
- * when we get the host's dock signal. */
-
- ph = GDL_DOCK_PLACEHOLDER (user_data);
- obj = ph->_priv->host;
- if (obj != object) {
- g_warning (_("Got a detach signal from an object (%p) who is not "
- "our host %p"), object, ph->_priv->host);
- return;
- }
-
- /* skip sticky objects */
- if (ph->_priv->sticky)
- return;
-
- if (obj)
- /* go up in the hierarchy */
- new_host = gdl_dock_object_get_parent_object (obj);
- else
- /* Detaching from the dead host */
- new_host = NULL;
-
- while (new_host) {
- GdlDockPlacement pos = GDL_DOCK_NONE;
-
- /* get placement hint from the new host */
- if (gdl_dock_object_child_placement (new_host, obj, &pos)) {
- ph->_priv->placement_stack = g_slist_prepend (
- ph->_priv->placement_stack, (gpointer) pos);
- }
- else {
- g_warning (_("Something weird happened while getting the child "
- "placement for %p from parent %p"), obj, new_host);
- }
-
- if (!GDL_DOCK_OBJECT_IN_DETACH (new_host))
- /* we found a "stable" dock object */
- break;
-
- obj = new_host;
- new_host = gdl_dock_object_get_parent_object (obj);
- }
-
- /* disconnect host */
- disconnect_host (ph);
-
- if (!new_host) {
-#ifdef PLACEHOLDER_DEBUG
- g_message ("Detaching from the toplevel. Assignaing to controller");
-#endif
- /* the toplevel was detached: we attach ourselves to the
- controller with an initial placement of floating */
- new_host = gdl_dock_master_get_controller (GDL_DOCK_OBJECT_GET_MASTER (ph));
-
- /*
- ph->_priv->placement_stack = g_slist_prepend (
- ph->_priv->placement_stack, (gpointer) GDL_DOCK_FLOATING);
- */
- }
- if (new_host)
- connect_host (ph, new_host);
-
-#ifdef PLACEHOLDER_DEBUG
- print_placement_stack (ph);
-#endif
-}
-
-/**
- * do_excursion:
- * @ph: placeholder object
- *
- * Tries to shrink the placement stack by examining the host's
- * children and see if any of them matches the placement which is at
- * the top of the stack. If this is the case, it tries again with the
- * new host.
- **/
-static void
-do_excursion (GdlDockPlaceholder *ph)
-{
- if (ph->_priv->host &&
- !ph->_priv->sticky &&
- ph->_priv->placement_stack &&
- gdl_dock_object_is_compound (ph->_priv->host)) {
-
- GdlDockPlacement pos, stack_pos =
- (GdlDockPlacement) ph->_priv->placement_stack->data;
- GList *children, *l;
- GdlDockObject *host = ph->_priv->host;
-
- children = gtk_container_get_children (GTK_CONTAINER (host));
- for (l = children; l; l = l->next) {
- pos = stack_pos;
- gdl_dock_object_child_placement (GDL_DOCK_OBJECT (host),
- GDL_DOCK_OBJECT (l->data),
- &pos);
- if (pos == stack_pos) {
- /* remove the stack position */
- ph->_priv->placement_stack =
- g_slist_remove_link (ph->_priv->placement_stack,
- ph->_priv->placement_stack);
-
- /* connect to the new host */
- disconnect_host (ph);
- connect_host (ph, GDL_DOCK_OBJECT (l->data));
-
- /* recurse... */
- if (!GDL_DOCK_OBJECT_IN_REFLOW (l->data))
- do_excursion (ph);
-
- break;
- }
- }
- g_list_free (children);
- }
-}
-
-static void
-dock_cb (GdlDockObject *object,
- GdlDockObject *requestor,
- GdlDockPlacement position,
- GValue *other_data,
- gpointer user_data)
-{
- GdlDockPlacement pos = GDL_DOCK_NONE;
- GdlDockPlaceholder *ph;
-
- g_return_if_fail (user_data != NULL && GDL_IS_DOCK_PLACEHOLDER (user_data));
- ph = GDL_DOCK_PLACEHOLDER (user_data);
- g_return_if_fail (ph->_priv->host == object);
-
- /* see if the given position is compatible for the stack's top
- element */
- if (!ph->_priv->sticky && ph->_priv->placement_stack) {
- pos = (GdlDockPlacement) ph->_priv->placement_stack->data;
- if (gdl_dock_object_child_placement (object, requestor, &pos)) {
- if (pos == (GdlDockPlacement) ph->_priv->placement_stack->data) {
- /* the position is compatible: excurse down */
- do_excursion (ph);
- }
- }
- }
-#ifdef PLACEHOLDER_DEBUG
- print_placement_stack (ph);
-#endif
-}
-
-static void
-disconnect_host (GdlDockPlaceholder *ph)
-{
- if (!ph->_priv->host)
- return;
-
- if (ph->_priv->host_detach_handler)
- g_signal_handler_disconnect (ph->_priv->host, ph->_priv->host_detach_handler);
- if (ph->_priv->host_dock_handler)
- g_signal_handler_disconnect (ph->_priv->host, ph->_priv->host_dock_handler);
- ph->_priv->host_detach_handler = 0;
- ph->_priv->host_dock_handler = 0;
-
- /* remove weak ref to object */
- g_object_weak_unref (G_OBJECT (ph->_priv->host),
- gdl_dock_placeholder_weak_notify, ph);
- ph->_priv->host = NULL;
-
-#ifdef PLACEHOLDER_DEBUG
- g_message ("Host just disconnected!, ph = %p", ph);
-#endif
-}
-
-static void
-connect_host (GdlDockPlaceholder *ph,
- GdlDockObject *new_host)
-{
- if (ph->_priv->host)
- disconnect_host (ph);
-
- ph->_priv->host = new_host;
- g_object_weak_ref (G_OBJECT (ph->_priv->host),
- gdl_dock_placeholder_weak_notify, ph);
-
- ph->_priv->host_detach_handler =
- g_signal_connect (ph->_priv->host,
- "detach",
- (GCallback) detach_cb,
- (gpointer) ph);
-
- ph->_priv->host_dock_handler =
- g_signal_connect (ph->_priv->host,
- "dock",
- (GCallback) dock_cb,
- (gpointer) ph);
-
-#ifdef PLACEHOLDER_DEBUG
- g_message ("Host just connected!, ph = %p", ph);
-#endif
-}
-
-void
-gdl_dock_placeholder_attach (GdlDockPlaceholder *ph,
- GdlDockObject *object)
-{
- g_return_if_fail (ph != NULL && GDL_IS_DOCK_PLACEHOLDER (ph));
- g_return_if_fail (ph->_priv != NULL);
- g_return_if_fail (object != NULL);
-
- /* object binding */
- if (!gdl_dock_object_is_bound (GDL_DOCK_OBJECT (ph)))
- gdl_dock_object_bind (GDL_DOCK_OBJECT (ph), object->master);
-
- g_return_if_fail (GDL_DOCK_OBJECT (ph)->master == object->master);
-
- gdl_dock_object_freeze (GDL_DOCK_OBJECT (ph));
-
- /* detach from previous host first */
- if (ph->_priv->host)
- gdl_dock_object_detach (GDL_DOCK_OBJECT (ph), FALSE);
-
- connect_host (ph, object);
-
- GDL_DOCK_OBJECT_SET_FLAGS (ph, GDL_DOCK_ATTACHED);
-
- gdl_dock_object_thaw (GDL_DOCK_OBJECT (ph));
-}
diff --git a/src/libgdl/gdl-dock-placeholder.h b/src/libgdl/gdl-dock-placeholder.h
deleted file mode 100644
index c7e57e204..000000000
--- a/src/libgdl/gdl-dock-placeholder.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * gdl-dock-placeholder.h - Placeholders for docking items
- *
- * This file is part of the GNOME Devtools Libraries.
- *
- * Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net>
- *
- * This library is free software; you can redistribute it and/or
- * 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
- */
-
-#ifndef __GDL_DOCK_PLACEHOLDER_H__
-#define __GDL_DOCK_PLACEHOLDER_H__
-
-#include "libgdl/gdl-dock-object.h"
-
-G_BEGIN_DECLS
-
-/* standard macros */
-#define GDL_TYPE_DOCK_PLACEHOLDER (gdl_dock_placeholder_get_type ())
-#define GDL_DOCK_PLACEHOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_PLACEHOLDER, GdlDockPlaceholder))
-#define GDL_DOCK_PLACEHOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_PLACEHOLDER, GdlDockPlaceholderClass))
-#define GDL_IS_DOCK_PLACEHOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_PLACEHOLDER))
-#define GDL_IS_DOCK_PLACEHOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_PLACEHOLDER))
-#define GDL_DOCK_PLACEHOLDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_PLACEHOLDER, GdlDockPlaceholderClass))
-
-/* data types & structures */
-typedef struct _GdlDockPlaceholder GdlDockPlaceholder;
-typedef struct _GdlDockPlaceholderClass GdlDockPlaceholderClass;
-typedef struct _GdlDockPlaceholderPrivate GdlDockPlaceholderPrivate;
-
-struct _GdlDockPlaceholder {
- GdlDockObject object;
-
- GdlDockPlaceholderPrivate *_priv;
-};
-
-struct _GdlDockPlaceholderClass {
- GdlDockObjectClass parent_class;
-};
-
-/* public interface */
-
-GType gdl_dock_placeholder_get_type (void);
-
-GtkWidget *gdl_dock_placeholder_new (const gchar *name,
- GdlDockObject *object,
- GdlDockPlacement position,
- gboolean sticky);
-
-void gdl_dock_placeholder_attach (GdlDockPlaceholder *ph,
- GdlDockObject *object);
-
-
-G_END_DECLS
-
-#endif /* __GDL_DOCK_PLACEHOLDER_H__ */
diff --git a/src/libgdl/gdl-dock-tablabel.c b/src/libgdl/gdl-dock-tablabel.c
deleted file mode 100644
index 441db3438..000000000
--- a/src/libgdl/gdl-dock-tablabel.c
+++ /dev/null
@@ -1,632 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * gdl-dock-tablabel.c
- *
- * This file is part of the GNOME Devtools Libraries.
- *
- * Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net>
- *
- * This library is free software; you can redistribute it and/or
- * 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 <gtk/gtk.h>
-
-#include "gdl-dock-tablabel.h"
-#include "gdl-dock-item.h"
-#include "libgdlmarshal.h"
-
-
-/* ----- Private prototypes ----- */
-
-static void gdl_dock_tablabel_class_init (GdlDockTablabelClass *klass);
-
-static void gdl_dock_tablabel_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gdl_dock_tablabel_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static void gdl_dock_tablabel_item_notify (GObject *master,
- GParamSpec *pspec,
- gpointer data);
-
-static void gdl_dock_tablabel_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void gdl_dock_tablabel_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-
-static void gdl_dock_tablabel_paint (GtkWidget *widget,
- GdkEventExpose *event);
-static gint gdl_dock_tablabel_expose (GtkWidget *widget,
- GdkEventExpose *event);
-
-static gboolean gdl_dock_tablabel_button_event (GtkWidget *widget,
- GdkEventButton *event);
-static gboolean gdl_dock_tablabel_motion_event (GtkWidget *widget,
- GdkEventMotion *event);
-
-static void gdl_dock_tablabel_realize (GtkWidget *widget);
-static void gdl_dock_tablabel_unrealize (GtkWidget *widget);
-static void gdl_dock_tablabel_map (GtkWidget *widget);
-static void gdl_dock_tablabel_unmap (GtkWidget *widget);
-
-/* ----- Private data types and variables ----- */
-
-#define DEFAULT_DRAG_HANDLE_SIZE 10
-#define HANDLE_RATIO 1.0
-
-enum {
- BUTTON_PRESSED_HANDLE,
- LAST_SIGNAL
-};
-
-enum {
- PROP_0,
- PROP_ITEM
-};
-
-
-static guint dock_tablabel_signals [LAST_SIGNAL] = { 0 };
-
-
-/* ----- Private interface ----- */
-
-G_DEFINE_TYPE (GdlDockTablabel, gdl_dock_tablabel, GTK_TYPE_BIN);
-
-static void
-gdl_dock_tablabel_class_init (GdlDockTablabelClass *klass)
-{
- GObjectClass *g_object_class;
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
-
- g_object_class = G_OBJECT_CLASS (klass);
- object_class = GTK_OBJECT_CLASS (klass);
- widget_class = GTK_WIDGET_CLASS (klass);
- container_class = GTK_CONTAINER_CLASS (klass);
-
- g_object_class->set_property = gdl_dock_tablabel_set_property;
- g_object_class->get_property = gdl_dock_tablabel_get_property;
-
- widget_class->size_request = gdl_dock_tablabel_size_request;
- widget_class->size_allocate = gdl_dock_tablabel_size_allocate;
- widget_class->expose_event = gdl_dock_tablabel_expose;
- widget_class->button_press_event = gdl_dock_tablabel_button_event;
- widget_class->button_release_event = gdl_dock_tablabel_button_event;
- widget_class->motion_notify_event = gdl_dock_tablabel_motion_event;
- widget_class->realize = gdl_dock_tablabel_realize;
- widget_class->unrealize = gdl_dock_tablabel_unrealize;
- widget_class->map = gdl_dock_tablabel_map;
- widget_class->unmap = gdl_dock_tablabel_unmap;
-
- g_object_class_install_property (
- g_object_class, PROP_ITEM,
- g_param_spec_object ("item", _("Controlling dock item"),
- _("Dockitem which 'owns' this tablabel"),
- GDL_TYPE_DOCK_ITEM,
- G_PARAM_READWRITE));
-
- dock_tablabel_signals [BUTTON_PRESSED_HANDLE] =
- g_signal_new ("button_pressed_handle",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdlDockTablabelClass,
- button_pressed_handle),
- NULL, NULL,
- gdl_marshal_VOID__BOXED,
- G_TYPE_NONE,
- 1,
- GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
-
- klass->button_pressed_handle = NULL;
-}
-
-static void
-gdl_dock_tablabel_init (GdlDockTablabel *tablabel)
-{
- GtkWidget *widget;
- GtkWidget *label_widget;
-
- widget = GTK_WIDGET (tablabel);
-
- tablabel->drag_handle_size = DEFAULT_DRAG_HANDLE_SIZE;
- tablabel->item = NULL;
-
- label_widget = gtk_label_new ("Dock item");
- gtk_container_add (GTK_CONTAINER (tablabel), label_widget);
- gtk_widget_show (label_widget);
-
- tablabel->active = FALSE;
- gtk_widget_set_state (GTK_WIDGET (tablabel), GTK_STATE_ACTIVE);
-}
-
-static void
-gdl_dock_tablabel_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GdlDockTablabel *tablabel;
- GtkBin *bin;
-
- tablabel = GDL_DOCK_TABLABEL (object);
-
- switch (prop_id) {
- case PROP_ITEM:
- if (tablabel->item) {
- g_object_remove_weak_pointer (G_OBJECT (tablabel->item),
- (gpointer *) &tablabel->item);
- g_signal_handlers_disconnect_by_func (
- tablabel->item, gdl_dock_tablabel_item_notify, tablabel);
- };
-
- tablabel->item = g_value_get_object (value);
- if (tablabel->item) {
- gboolean locked;
- gchar *long_name;
-
- g_object_add_weak_pointer (G_OBJECT (tablabel->item),
- (gpointer *) &tablabel->item);
-
- g_signal_connect (tablabel->item, "notify::locked",
- G_CALLBACK (gdl_dock_tablabel_item_notify),
- tablabel);
- g_signal_connect (tablabel->item, "notify::long_name",
- G_CALLBACK (gdl_dock_tablabel_item_notify),
- tablabel);
- g_signal_connect (tablabel->item, "notify::grip_size",
- G_CALLBACK (gdl_dock_tablabel_item_notify),
- tablabel);
-
- g_object_get (tablabel->item,
- "locked", &locked,
- "long-name", &long_name,
- "grip-size", &tablabel->drag_handle_size,
- NULL);
-
- if (locked)
- tablabel->drag_handle_size = 0;
-
- bin = GTK_BIN (tablabel);
- if (gtk_bin_get_child (bin) && g_object_class_find_property (
- G_OBJECT_GET_CLASS (gtk_bin_get_child (bin)), "label"))
- g_object_set (gtk_bin_get_child (bin), "label", long_name, NULL);
- g_free (long_name);
- };
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gdl_dock_tablabel_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GdlDockTablabel *tablabel;
-
- tablabel = GDL_DOCK_TABLABEL (object);
-
- switch (prop_id) {
- case PROP_ITEM:
- g_value_set_object (value, tablabel->item);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gdl_dock_tablabel_item_notify (GObject *master,
- GParamSpec *pspec,
- gpointer data)
-{
- GdlDockTablabel *tablabel = GDL_DOCK_TABLABEL (data);
- gboolean locked;
- gchar *label;
- GtkBin *bin;
-
- g_object_get (master,
- "locked", &locked,
- "grip-size", &tablabel->drag_handle_size,
- "long-name", &label,
- NULL);
-
- if (locked)
- tablabel->drag_handle_size = 0;
-
- bin = GTK_BIN (tablabel);
- if (gtk_bin_get_child (bin) && g_object_class_find_property (
- G_OBJECT_GET_CLASS (gtk_bin_get_child (bin)), "label"))
- g_object_set (gtk_bin_get_child (bin), "label", label, NULL);
- g_free (label);
-
- gtk_widget_queue_resize (GTK_WIDGET (tablabel));
-}
-
-static void
-gdl_dock_tablabel_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- GtkBin *bin;
- GtkRequisition child_req;
- GdlDockTablabel *tablabel;
- guint border_width;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GDL_IS_DOCK_TABLABEL (widget));
- g_return_if_fail (requisition != NULL);
-
- tablabel = GDL_DOCK_TABLABEL (widget);
- bin = GTK_BIN (widget);
-
- requisition->width = tablabel->drag_handle_size;
- requisition->height = 0;
-
- if (gtk_bin_get_child (bin))
- gtk_widget_size_request (gtk_bin_get_child (bin), &child_req);
- else
- child_req.width = child_req.height = 0;
-
- requisition->width += child_req.width;
- requisition->height += child_req.height;
-
- border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
-
- requisition->width += border_width * 2;
- requisition->height += border_width * 2;
-
- //gtk_widget_size_request (widget, requisition);
-}
-
-static void
-gdl_dock_tablabel_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- GtkBin *bin;
- GtkAllocation widget_allocation;
- GdlDockTablabel *tablabel;
- gint border_width;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GDL_IS_DOCK_TABLABEL (widget));
- g_return_if_fail (allocation != NULL);
-
- bin = GTK_BIN (widget);
- tablabel = GDL_DOCK_TABLABEL (widget);
-
- border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
-
- gtk_widget_set_allocation (widget, allocation);
-
- if (gtk_widget_get_realized (widget))
- gdk_window_move_resize (tablabel->event_window,
- allocation->x,
- allocation->y,
- allocation->width,
- allocation->height);
-
- if (gtk_bin_get_child (bin) && gtk_widget_get_visible (gtk_bin_get_child (bin))) {
- GtkAllocation child_allocation;
-
- gtk_widget_get_allocation (widget, &widget_allocation);
- child_allocation.x = widget_allocation.x + border_width;
- child_allocation.y = widget_allocation.y + border_width;
-
- allocation->width = MAX (1, (int) allocation->width -
- (int) tablabel->drag_handle_size);
- child_allocation.x += tablabel->drag_handle_size;
-
- child_allocation.width =
- MAX (1, (int) allocation->width - 2 * border_width);
- child_allocation.height =
- MAX (1, (int) allocation->height - 2 * border_width);
-
- gtk_widget_size_allocate (gtk_bin_get_child (bin), &child_allocation);
- }
-}
-
-static void
-gdl_dock_tablabel_paint (GtkWidget *widget,
- GdkEventExpose *event)
-{
- GdkRectangle dest, rect;
- GtkBin *bin;
- GtkAllocation widget_allocation;
- GdlDockTablabel *tablabel;
- gint border_width;
-
- bin = GTK_BIN (widget);
- tablabel = GDL_DOCK_TABLABEL (widget);
- border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
-
- gtk_widget_get_allocation (widget, &widget_allocation);
- rect.x = widget_allocation.x + border_width;
- rect.y = widget_allocation.y + border_width;
- rect.width = tablabel->drag_handle_size * HANDLE_RATIO;
- rect.height = widget_allocation.height - 2*border_width;
-
- if (gdk_rectangle_intersect (&event->area, &rect, &dest)) {
- gtk_paint_handle (gtk_widget_get_style (widget), gtk_widget_get_window (widget),
- tablabel->active ? GTK_STATE_NORMAL : GTK_STATE_ACTIVE,
- GTK_SHADOW_NONE,
- &dest, widget, "dock-tablabel",
- rect.x, rect.y, rect.width, rect.height,
- GTK_ORIENTATION_VERTICAL);
- };
-}
-
-static gint
-gdl_dock_tablabel_expose (GtkWidget *widget,
- GdkEventExpose *event)
-{
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GDL_IS_DOCK_TABLABEL (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- if (gtk_widget_get_visible (widget) && gtk_widget_get_mapped (widget)) {
- GTK_WIDGET_CLASS (gdl_dock_tablabel_parent_class)->expose_event (widget,event);
- gdl_dock_tablabel_paint (widget, event);
- };
-
- return FALSE;
-}
-
-static gboolean
-gdl_dock_tablabel_button_event (GtkWidget *widget,
- GdkEventButton *event)
-{
- GdlDockTablabel *tablabel;
- GtkAllocation widget_allocation;
- gboolean event_handled;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GDL_IS_DOCK_TABLABEL (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- tablabel = GDL_DOCK_TABLABEL (widget);
-
- event_handled = FALSE;
-
- if (event->window != tablabel->event_window)
- return FALSE;
-
- switch (event->type) {
- case GDK_BUTTON_PRESS:
- if (tablabel->active) {
- gboolean in_handle;
- gint rel_x, rel_y;
- guint border_width;
- GtkBin *bin;
-
- bin = GTK_BIN (widget);
- border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
-
- rel_x = event->x - border_width;
- rel_y = event->y - border_width;
-
- /* Check if user clicked on the drag handle. */
- in_handle = (rel_x < tablabel->drag_handle_size * HANDLE_RATIO) &&
- (rel_x > 0);
-
- if (event->button == 1) {
- tablabel->pre_drag = TRUE;
- tablabel->drag_start_event = *event;
- }
- else {
- g_signal_emit (widget,
- dock_tablabel_signals [BUTTON_PRESSED_HANDLE],
- 0,
- event);
- }
-
- event_handled = TRUE;
- }
- break;
-
- case GDK_BUTTON_RELEASE:
- tablabel->pre_drag = FALSE;
- break;
-
- default:
- break;
- }
-
- if (!event_handled) {
- /* propagate the event to the parent's gdkwindow */
- GdkEventButton e;
-
- e = *event;
- e.window = gtk_widget_get_parent_window (widget);
- gtk_widget_get_allocation (widget, &widget_allocation);
- e.x += widget_allocation.x;
- e.y += widget_allocation.y;
-
- gdk_event_put ((GdkEvent *) &e);
- };
-
- return event_handled;
-}
-
-static gboolean
-gdl_dock_tablabel_motion_event (GtkWidget *widget,
- GdkEventMotion *event)
-{
- GdlDockTablabel *tablabel;
- GtkAllocation widget_allocation;
- gboolean event_handled;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (GDL_IS_DOCK_TABLABEL (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- tablabel = GDL_DOCK_TABLABEL (widget);
-
- event_handled = FALSE;
-
- if (event->window != tablabel->event_window)
- return FALSE;
-
- if (tablabel->pre_drag) {
- if (gtk_drag_check_threshold (widget,
- tablabel->drag_start_event.x,
- tablabel->drag_start_event.y,
- event->x,
- event->y)) {
- tablabel->pre_drag = FALSE;
- g_signal_emit (widget,
- dock_tablabel_signals [BUTTON_PRESSED_HANDLE],
- 0,
- &tablabel->drag_start_event);
- event_handled = TRUE;
- }
- }
-
- if (!event_handled) {
- /* propagate the event to the parent's gdkwindow */
- GdkEventMotion e;
-
- e = *event;
- e.window = gtk_widget_get_parent_window (widget);
- gtk_widget_get_allocation (widget, &widget_allocation);
- e.x += widget_allocation.x;
- e.y += widget_allocation.y;
-
- gdk_event_put ((GdkEvent *) &e);
- };
-
- return event_handled;
-}
-
-static void
-gdl_dock_tablabel_realize (GtkWidget *widget)
-{
- GdlDockTablabel *tablabel;
- GdkWindowAttr attributes;
- GtkAllocation widget_allocation;
- int attributes_mask;
-
- tablabel = GDL_DOCK_TABLABEL (widget);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- gtk_widget_get_allocation (widget, &widget_allocation);
- attributes.x = widget_allocation.x;
- attributes.y = widget_allocation.y;
- attributes.width = widget_allocation.width;
- attributes.height = widget_allocation.height;
- attributes.wclass = GDK_INPUT_ONLY;
- attributes.event_mask = gtk_widget_get_events (widget);
- attributes.event_mask |= (GDK_EXPOSURE_MASK |
- GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_ENTER_NOTIFY_MASK |
- GDK_POINTER_MOTION_MASK |
- GDK_LEAVE_NOTIFY_MASK);
- attributes_mask = GDK_WA_X | GDK_WA_Y;
-
- gtk_widget_set_window (widget, gtk_widget_get_parent_window (widget));
- g_object_ref (gtk_widget_get_window (widget));
-
- tablabel->event_window =
- gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (tablabel->event_window, widget);
-
- gtk_widget_set_style (widget, gtk_style_attach (gtk_widget_get_style (widget),
- gtk_widget_get_window (widget)));
-
- gtk_widget_set_realized (widget, TRUE);
-}
-
-static void
-gdl_dock_tablabel_unrealize (GtkWidget *widget)
-{
- GdlDockTablabel *tablabel = GDL_DOCK_TABLABEL (widget);
-
- if (tablabel->event_window) {
- gdk_window_set_user_data (tablabel->event_window, NULL);
- gdk_window_destroy (tablabel->event_window);
- tablabel->event_window = NULL;
- }
-
- GTK_WIDGET_CLASS (gdl_dock_tablabel_parent_class)->unrealize (widget);
-}
-
-static void
-gdl_dock_tablabel_map (GtkWidget *widget)
-{
- GdlDockTablabel *tablabel = GDL_DOCK_TABLABEL (widget);
-
- GTK_WIDGET_CLASS (gdl_dock_tablabel_parent_class)->map (widget);
-
- gdk_window_show (tablabel->event_window);
-}
-
-static void
-gdl_dock_tablabel_unmap (GtkWidget *widget)
-{
- GdlDockTablabel *tablabel = GDL_DOCK_TABLABEL (widget);
-
- gdk_window_hide (tablabel->event_window);
-
- GTK_WIDGET_CLASS (gdl_dock_tablabel_parent_class)->unmap (widget);
-}
-
-/* ----- Public interface ----- */
-
-GtkWidget *
-gdl_dock_tablabel_new (GdlDockItem *item)
-{
- GdlDockTablabel *tablabel;
-
- tablabel = GDL_DOCK_TABLABEL (g_object_new (GDL_TYPE_DOCK_TABLABEL,
- "item", item,
- NULL));
-
- return GTK_WIDGET (tablabel);
-}
-
-void
-gdl_dock_tablabel_activate (GdlDockTablabel *tablabel)
-{
- g_return_if_fail (tablabel != NULL);
-
- tablabel->active = TRUE;
- gtk_widget_set_state (GTK_WIDGET (tablabel), GTK_STATE_NORMAL);
-}
-
-void
-gdl_dock_tablabel_deactivate (GdlDockTablabel *tablabel)
-{
- g_return_if_fail (tablabel != NULL);
-
- tablabel->active = FALSE;
- /* yeah, i know it contradictive */
- gtk_widget_set_state (GTK_WIDGET (tablabel), GTK_STATE_ACTIVE);
-}
diff --git a/src/libgdl/gdl-dock-tablabel.h b/src/libgdl/gdl-dock-tablabel.h
deleted file mode 100644
index b78c1c5c7..000000000
--- a/src/libgdl/gdl-dock-tablabel.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * gdl-dock-tablabel.h
- *
- * This file is part of the GNOME Devtools Libraries.
- *
- * Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net>
- *
- * This library is free software; you can redistribute it and/or
- * 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
- */
-
-#ifndef __GDL_DOCK_TABLABEL_H__
-#define __GDL_DOCK_TABLABEL_H__
-
-#include <gtk/gtk.h>
-#include "libgdl/gdl-dock-item.h"
-
-
-G_BEGIN_DECLS
-
-/* standard macros */
-#define GDL_TYPE_DOCK_TABLABEL (gdl_dock_tablabel_get_type ())
-#define GDL_DOCK_TABLABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_TABLABEL, GdlDockTablabel))
-#define GDL_DOCK_TABLABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_TABLABEL, GdlDockTablabelClass))
-#define GDL_IS_DOCK_TABLABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_TABLABEL))
-#define GDL_IS_DOCK_TABLABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_TABLABEL))
-#define GDL_DOCK_TABLABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_TABLABEL, GdlDockTablabelClass))
-
-/* data types & structures */
-typedef struct _GdlDockTablabel GdlDockTablabel;
-typedef struct _GdlDockTablabelClass GdlDockTablabelClass;
-
-struct _GdlDockTablabel {
- GtkBin parent;
-
- guint drag_handle_size;
- GtkWidget *item;
- GdkWindow *event_window;
- gboolean active;
-
- GdkEventButton drag_start_event;
- gboolean pre_drag;
-};
-
-struct _GdlDockTablabelClass {
- GtkBinClass parent_class;
-
- void (*button_pressed_handle) (GdlDockTablabel *tablabel,
- GdkEventButton *event);
-};
-
-/* public interface */
-
-GtkWidget *gdl_dock_tablabel_new (GdlDockItem *item);
-GType gdl_dock_tablabel_get_type (void);
-
-void gdl_dock_tablabel_activate (GdlDockTablabel *tablabel);
-void gdl_dock_tablabel_deactivate (GdlDockTablabel *tablabel);
-
-G_END_DECLS
-
-#endif
diff --git a/src/libgdl/gdl-dock.c b/src/libgdl/gdl-dock.c
deleted file mode 100644
index c87468e5c..000000000
--- a/src/libgdl/gdl-dock.c
+++ /dev/null
@@ -1,1365 +0,0 @@
-/* -*- Mode: C; tab-width: 4; 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>
- *
- * This library is free software; you can redistribute it and/or
- * 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-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"
-
-#ifndef __FUNCTION__
-#define __FUNCTION__ __func__
-#endif
-
-/* ----- Private prototypes ----- */
-
-static void gdl_dock_class_init (GdlDockClass *class);
-
-static GObject *gdl_dock_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_param);
-static void gdl_dock_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gdl_dock_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void gdl_dock_notify_cb (GObject *object,
- GParamSpec *pspec,
- gpointer user_data);
-
-static void gdl_dock_set_title (GdlDock *dock);
-
-static void gdl_dock_destroy (GtkObject *object);
-
-static void gdl_dock_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void gdl_dock_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static void gdl_dock_map (GtkWidget *widget);
-static void gdl_dock_unmap (GtkWidget *widget);
-static void gdl_dock_show (GtkWidget *widget);
-static void gdl_dock_hide (GtkWidget *widget);
-
-static void gdl_dock_add (GtkContainer *container,
- GtkWidget *widget);
-static void gdl_dock_remove (GtkContainer *container,
- GtkWidget *widget);
-static void gdl_dock_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-static GType gdl_dock_child_type (GtkContainer *container);
-
-static void gdl_dock_detach (GdlDockObject *object,
- gboolean recursive);
-static void gdl_dock_reduce (GdlDockObject *object);
-static gboolean gdl_dock_dock_request (GdlDockObject *object,
- gint x,
- gint y,
- GdlDockRequest *request);
-static void gdl_dock_dock (GdlDockObject *object,
- GdlDockObject *requestor,
- GdlDockPlacement position,
- GValue *other_data);
-static gboolean gdl_dock_reorder (GdlDockObject *object,
- GdlDockObject *requestor,
- GdlDockPlacement new_position,
- GValue *other_data);
-
-static gboolean gdl_dock_floating_window_delete_event_cb (GtkWidget *widget);
-
-static gboolean gdl_dock_child_placement (GdlDockObject *object,
- GdlDockObject *child,
- GdlDockPlacement *placement);
-
-static void gdl_dock_present (GdlDockObject *object,
- GdlDockObject *child);
-
-
-/* ----- Class variables and definitions ----- */
-
-struct _GdlDockPrivate
-{
- /* for floating docks */
- gboolean floating;
- GtkWidget *window;
- gboolean auto_title;
-
- gint float_x;
- gint float_y;
- gint width;
- gint height;
-
- /* auxiliary fields */
- GdkGC *xor_gc;
-};
-
-enum {
- LAYOUT_CHANGED,
- LAST_SIGNAL
-};
-
-enum {
- PROP_0,
- PROP_FLOATING,
- PROP_DEFAULT_TITLE,
- PROP_WIDTH,
- PROP_HEIGHT,
- PROP_FLOAT_X,
- PROP_FLOAT_Y
-};
-
-static guint dock_signals [LAST_SIGNAL] = { 0 };
-
-#define SPLIT_RATIO 0.3
-
-
-/* ----- Private functions ----- */
-
-G_DEFINE_TYPE (GdlDock, gdl_dock, GDL_TYPE_DOCK_OBJECT);
-
-static void
-gdl_dock_class_init (GdlDockClass *klass)
-{
- GObjectClass *g_object_class;
- GtkObjectClass *gtk_object_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
- GdlDockObjectClass *object_class;
-
- g_object_class = G_OBJECT_CLASS (klass);
- gtk_object_class = GTK_OBJECT_CLASS (klass);
- widget_class = GTK_WIDGET_CLASS (klass);
- container_class = GTK_CONTAINER_CLASS (klass);
- object_class = GDL_DOCK_OBJECT_CLASS (klass);
-
- g_object_class->constructor = gdl_dock_constructor;
- g_object_class->set_property = gdl_dock_set_property;
- g_object_class->get_property = gdl_dock_get_property;
-
- /* properties */
-
- g_object_class_install_property (
- g_object_class, PROP_FLOATING,
- g_param_spec_boolean ("floating", _("Floating"),
- _("Whether the dock is floating in its own window"),
- FALSE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
- GDL_DOCK_PARAM_EXPORT));
-
- g_object_class_install_property (
- g_object_class, PROP_DEFAULT_TITLE,
- g_param_spec_string ("default-title", _("Default title"),
- _("Default title for the newly created floating docks"),
- NULL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (
- g_object_class, PROP_WIDTH,
- g_param_spec_int ("width", _("Width"),
- _("Width for the dock when it's of floating type"),
- -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 dock when it's of floating type"),
- -1, G_MAXINT, -1,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
- GDL_DOCK_PARAM_EXPORT));
-
- g_object_class_install_property (
- g_object_class, PROP_FLOAT_X,
- g_param_spec_int ("floatx", _("Float X"),
- _("X coordinate for a floating dock"),
- G_MININT, G_MAXINT, 0,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
- GDL_DOCK_PARAM_EXPORT));
-
- g_object_class_install_property (
- g_object_class, PROP_FLOAT_Y,
- g_param_spec_int ("floaty", _("Float Y"),
- _("Y coordinate for a floating dock"),
- G_MININT, G_MAXINT, 0,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
- GDL_DOCK_PARAM_EXPORT));
-
- gtk_object_class->destroy = gdl_dock_destroy;
-
- widget_class->size_request = gdl_dock_size_request;
- widget_class->size_allocate = gdl_dock_size_allocate;
- widget_class->map = gdl_dock_map;
- widget_class->unmap = gdl_dock_unmap;
- widget_class->show = gdl_dock_show;
- widget_class->hide = gdl_dock_hide;
-
- container_class->add = gdl_dock_add;
- container_class->remove = gdl_dock_remove;
- container_class->forall = gdl_dock_forall;
- container_class->child_type = gdl_dock_child_type;
-
- object_class->is_compound = TRUE;
-
- object_class->detach = gdl_dock_detach;
- object_class->reduce = gdl_dock_reduce;
- object_class->dock_request = gdl_dock_dock_request;
- object_class->dock = gdl_dock_dock;
- object_class->reorder = gdl_dock_reorder;
- object_class->child_placement = gdl_dock_child_placement;
- object_class->present = gdl_dock_present;
-
- /* signals */
-
- dock_signals [LAYOUT_CHANGED] =
- g_signal_new ("layout-changed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdlDockClass, layout_changed),
- NULL, /* accumulator */
- NULL, /* accu_data */
- gdl_marshal_VOID__VOID,
- G_TYPE_NONE, /* return type */
- 0);
-
- klass->layout_changed = NULL;
-}
-
-static void
-gdl_dock_init (GdlDock *dock)
-{
- gtk_widget_set_has_window (GTK_WIDGET (dock), FALSE);
-
- dock->root = NULL;
- dock->_priv = g_new0 (GdlDockPrivate, 1);
- dock->_priv->width = -1;
- dock->_priv->height = -1;
-}
-
-static gboolean
-gdl_dock_floating_configure_event_cb (GtkWidget *widget,
- GdkEventConfigure *event,
- gpointer user_data)
-{
- GdlDock *dock;
-
- g_return_val_if_fail (user_data != NULL && GDL_IS_DOCK (user_data), TRUE);
-
- dock = GDL_DOCK (user_data);
- dock->_priv->float_x = event->x;
- dock->_priv->float_y = event->y;
- dock->_priv->width = event->width;
- dock->_priv->height = event->height;
-
- return FALSE;
-}
-
-static GObject *
-gdl_dock_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_param)
-{
- GObject *g_object;
-
- g_object = G_OBJECT_CLASS (gdl_dock_parent_class)-> constructor (type,
- n_construct_properties,
- construct_param);
- if (g_object) {
- GdlDock *dock = GDL_DOCK (g_object);
- GdlDockMaster *master;
-
- /* create a master for the dock if none was provided in the construction */
- master = GDL_DOCK_OBJECT_GET_MASTER (GDL_DOCK_OBJECT (dock));
- if (!master) {
- GDL_DOCK_OBJECT_UNSET_FLAGS (dock, GDL_DOCK_AUTOMATIC);
- master = g_object_new (GDL_TYPE_DOCK_MASTER, NULL);
- /* the controller owns the master ref */
- gdl_dock_object_bind (GDL_DOCK_OBJECT (dock), G_OBJECT (master));
- }
-
- if (dock->_priv->floating) {
- /* create floating window for this dock */
- dock->_priv->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_object_set_data (G_OBJECT (dock->_priv->window), "dock", dock);
-
- /* set position and default size */
- gtk_window_set_position (GTK_WINDOW (dock->_priv->window),
- GTK_WIN_POS_MOUSE);
- gtk_window_set_default_size (GTK_WINDOW (dock->_priv->window),
- dock->_priv->width,
- dock->_priv->height);
- gtk_window_set_type_hint (GTK_WINDOW (dock->_priv->window),
- GDK_WINDOW_TYPE_HINT_NORMAL);
-
- gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dock->_priv->window),
- TRUE);
-
- /* metacity ignores this */
- gtk_window_move (GTK_WINDOW (dock->_priv->window),
- dock->_priv->float_x,
- dock->_priv->float_y);
-
- /* connect to the configure event so we can track down window geometry */
- g_signal_connect (dock->_priv->window, "configure_event",
- (GCallback) gdl_dock_floating_configure_event_cb,
- dock);
-
- /* set the title and connect to the long_name notify queue
- so we can reset the title when this prop changes */
- gdl_dock_set_title (dock);
- g_signal_connect (dock, "notify::long-name",
- (GCallback) gdl_dock_notify_cb, NULL);
-
- gtk_container_add (GTK_CONTAINER (dock->_priv->window), GTK_WIDGET (dock));
-
- g_signal_connect (dock->_priv->window, "delete_event",
- G_CALLBACK (gdl_dock_floating_window_delete_event_cb),
- NULL);
- }
- GDL_DOCK_OBJECT_SET_FLAGS (dock, GDL_DOCK_ATTACHED);
- }
-
- return g_object;
-}
-
-static void
-gdl_dock_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GdlDock *dock = GDL_DOCK (object);
-
- switch (prop_id) {
- case PROP_FLOATING:
- dock->_priv->floating = g_value_get_boolean (value);
- break;
- case PROP_DEFAULT_TITLE:
- if (GDL_DOCK_OBJECT (object)->master)
- g_object_set (GDL_DOCK_OBJECT (object)->master,
- "default-title", g_value_get_string (value),
- NULL);
- break;
- case PROP_WIDTH:
- dock->_priv->width = g_value_get_int (value);
- break;
- case PROP_HEIGHT:
- dock->_priv->height = g_value_get_int (value);
- break;
- case PROP_FLOAT_X:
- dock->_priv->float_x = g_value_get_int (value);
- break;
- case PROP_FLOAT_Y:
- dock->_priv->float_y = g_value_get_int (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-
- switch (prop_id) {
- case PROP_WIDTH:
- case PROP_HEIGHT:
- case PROP_FLOAT_X:
- case PROP_FLOAT_Y:
- if (dock->_priv->floating && dock->_priv->window) {
- gtk_window_resize (GTK_WINDOW (dock->_priv->window),
- dock->_priv->width,
- dock->_priv->height);
- }
- break;
- }
-}
-
-static void
-gdl_dock_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GdlDock *dock = GDL_DOCK (object);
-
- switch (prop_id) {
- case PROP_FLOATING:
- g_value_set_boolean (value, dock->_priv->floating);
- break;
- case PROP_DEFAULT_TITLE:
- if (GDL_DOCK_OBJECT (object)->master) {
- gchar *default_title;
- g_object_get (GDL_DOCK_OBJECT (object)->master,
- "default-title", &default_title,
- NULL);
-#if GLIB_CHECK_VERSION(2,3,0)
- g_value_take_string (value, default_title);
-#else
- g_value_set_string_take_ownership (value, default_title);
-#endif
- }
- else
- g_value_set_string (value, NULL);
- break;
- case PROP_WIDTH:
- g_value_set_int (value, dock->_priv->width);
- break;
- case PROP_HEIGHT:
- g_value_set_int (value, dock->_priv->height);
- break;
- case PROP_FLOAT_X:
- g_value_set_int (value, dock->_priv->float_x);
- break;
- case PROP_FLOAT_Y:
- g_value_set_int (value, dock->_priv->float_y);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gdl_dock_set_title (GdlDock *dock)
-{
- GdlDockObject *object = GDL_DOCK_OBJECT (dock);
- gchar *title = NULL;
-
- if (!dock->_priv->window)
- return;
-
- if (!dock->_priv->auto_title && object->long_name) {
- title = object->long_name;
- }
- else if (object->master) {
- g_object_get (object->master, "default-title", &title, NULL);
- }
-
- if (!title && dock->root) {
- g_object_get (dock->root, "long-name", &title, NULL);
- }
-
- if (!title) {
- /* set a default title in the long_name */
- dock->_priv->auto_title = TRUE;
- title = g_strdup_printf (
- _("Dock #%d"), GDL_DOCK_MASTER (object->master)->dock_number++);
- }
-
- gtk_window_set_title (GTK_WINDOW (dock->_priv->window), title);
-
- g_free (title);
-}
-
-static void
-gdl_dock_notify_cb (GObject *object,
- GParamSpec *pspec,
- gpointer user_data)
-{
- GdlDock *dock;
- gchar* long_name;
-
- g_return_if_fail (object != NULL || GDL_IS_DOCK (object));
-
- g_object_get (object, "long-name", &long_name, NULL);
-
- if (long_name)
- {
- dock = GDL_DOCK (object);
- dock->_priv->auto_title = FALSE;
- gdl_dock_set_title (dock);
- }
- g_free (long_name);
-}
-
-static void
-gdl_dock_destroy (GtkObject *object)
-{
- GdlDock *dock = GDL_DOCK (object);
-
- if (dock->_priv) {
- GdlDockPrivate *priv = dock->_priv;
- dock->_priv = NULL;
-
- if (priv->window) {
- gtk_widget_destroy (priv->window);
- priv->floating = FALSE;
- priv->window = NULL;
- }
-
- /* destroy the xor gc */
- if (priv->xor_gc) {
- g_object_unref (priv->xor_gc);
- priv->xor_gc = NULL;
- }
-
- g_free (priv);
- }
-
- GTK_OBJECT_CLASS (gdl_dock_parent_class)->destroy (object);
-}
-
-static void
-gdl_dock_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- GdlDock *dock;
- GtkContainer *container;
- guint border_width;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GDL_IS_DOCK (widget));
-
- dock = GDL_DOCK (widget);
- container = GTK_CONTAINER (widget);
- border_width = gtk_container_get_border_width (container);
-
- /* make request to root */
- if (dock->root && gtk_widget_get_visible (GTK_WIDGET (dock->root)))
- gtk_widget_size_request (GTK_WIDGET (dock->root), requisition);
- else {
- requisition->width = 0;
- requisition->height = 0;
- };
-
- requisition->width += 2 * border_width;
- requisition->height += 2 * border_width;
-
- //gtk_widget_size_request (widget, requisition);
-}
-
-static void
-gdl_dock_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- GdlDock *dock;
- GtkContainer *container;
- guint border_width;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GDL_IS_DOCK (widget));
-
- dock = GDL_DOCK (widget);
- container = GTK_CONTAINER (widget);
- border_width = gtk_container_get_border_width (container);
-
- gtk_widget_set_allocation (widget, allocation);
-
- /* reduce allocation by border width */
- allocation->x += border_width;
- allocation->y += border_width;
- allocation->width = MAX (1, allocation->width - 2 * border_width);
- allocation->height = MAX (1, allocation->height - 2 * border_width);
-
- if (dock->root && gtk_widget_get_visible (GTK_WIDGET (dock->root)))
- gtk_widget_size_allocate (GTK_WIDGET (dock->root), allocation);
-}
-
-static void
-gdl_dock_map (GtkWidget *widget)
-{
- GtkWidget *child;
- GdlDock *dock;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GDL_IS_DOCK (widget));
-
- dock = GDL_DOCK (widget);
-
- GTK_WIDGET_CLASS (gdl_dock_parent_class)->map (widget);
-
- if (dock->root) {
- child = GTK_WIDGET (dock->root);
- if (gtk_widget_get_visible (child) && !gtk_widget_get_mapped (child))
- gtk_widget_map (child);
- }
-}
-
-static void
-gdl_dock_unmap (GtkWidget *widget)
-{
- GtkWidget *child;
- GdlDock *dock;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GDL_IS_DOCK (widget));
-
- dock = GDL_DOCK (widget);
-
- GTK_WIDGET_CLASS (gdl_dock_parent_class)->unmap (widget);
-
- if (dock->root) {
- child = GTK_WIDGET (dock->root);
- if (gtk_widget_get_visible (child) && gtk_widget_get_mapped (child))
- gtk_widget_unmap (child);
- }
-
- if (dock->_priv->window)
- gtk_widget_unmap (dock->_priv->window);
-}
-
-static void
-gdl_dock_foreach_automatic (GdlDockObject *object,
- gpointer user_data)
-{
- void (* function) (GtkWidget *) = user_data;
-
- if (GDL_DOCK_OBJECT_AUTOMATIC (object))
- (* function) (GTK_WIDGET (object));
-}
-
-static void
-gdl_dock_show (GtkWidget *widget)
-{
- GdlDock *dock;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GDL_IS_DOCK (widget));
-
- GTK_WIDGET_CLASS (gdl_dock_parent_class)->show (widget);
-
- dock = GDL_DOCK (widget);
- if (dock->_priv->floating && dock->_priv->window)
- gtk_widget_show (dock->_priv->window);
-
- if (GDL_DOCK_IS_CONTROLLER (dock)) {
- gdl_dock_master_foreach_toplevel (GDL_DOCK_OBJECT_GET_MASTER (dock),
- FALSE, (GFunc) gdl_dock_foreach_automatic,
- gtk_widget_show);
- }
-}
-
-static void
-gdl_dock_hide (GtkWidget *widget)
-{
- GdlDock *dock;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GDL_IS_DOCK (widget));
-
- GTK_WIDGET_CLASS (gdl_dock_parent_class)->hide (widget);
-
- dock = GDL_DOCK (widget);
- if (dock->_priv->floating && dock->_priv->window)
- gtk_widget_hide (dock->_priv->window);
-
- if (GDL_DOCK_IS_CONTROLLER (dock)) {
- gdl_dock_master_foreach_toplevel (GDL_DOCK_OBJECT_GET_MASTER (dock),
- FALSE, (GFunc) gdl_dock_foreach_automatic,
- gtk_widget_hide);
- }
-}
-
-static void
-gdl_dock_add (GtkContainer *container,
- GtkWidget *widget)
-{
- g_return_if_fail (container != NULL);
- g_return_if_fail (GDL_IS_DOCK (container));
- g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
-
- gdl_dock_add_item (GDL_DOCK (container),
- GDL_DOCK_ITEM (widget),
- GDL_DOCK_TOP); /* default position */
-}
-
-static void
-gdl_dock_remove (GtkContainer *container,
- GtkWidget *widget)
-{
- GdlDock *dock;
- gboolean was_visible;
-
- g_return_if_fail (container != NULL);
- g_return_if_fail (widget != NULL);
-
- dock = GDL_DOCK (container);
- was_visible = gtk_widget_get_visible (widget);
-
- if (GTK_WIDGET (dock->root) == widget) {
- dock->root = NULL;
- GDL_DOCK_OBJECT_UNSET_FLAGS (widget, GDL_DOCK_ATTACHED);
- gtk_widget_unparent (widget);
-
- if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container)))
- gtk_widget_queue_resize (GTK_WIDGET (dock));
- }
-}
-
-static void
-gdl_dock_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data)
-{
- GdlDock *dock;
-
- g_return_if_fail (container != NULL);
- g_return_if_fail (GDL_IS_DOCK (container));
- g_return_if_fail (callback != NULL);
-
- dock = GDL_DOCK (container);
-
- if (dock->root)
- (*callback) (GTK_WIDGET (dock->root), callback_data);
-}
-
-static GType
-gdl_dock_child_type (GtkContainer *container)
-{
- return GDL_TYPE_DOCK_ITEM;
-}
-
-static void
-gdl_dock_detach (GdlDockObject *object,
- gboolean recursive)
-{
- GdlDock *dock = GDL_DOCK (object);
-
- /* detach children */
- if (recursive && dock->root) {
- gdl_dock_object_detach (dock->root, recursive);
- }
- GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_ATTACHED);
-}
-
-static void
-gdl_dock_reduce (GdlDockObject *object)
-{
- GdlDock *dock = GDL_DOCK (object);
- GtkWidget *parent;
-
- if (dock->root)
- return;
-
- if (GDL_DOCK_OBJECT_AUTOMATIC (dock)) {
- gtk_widget_destroy (GTK_WIDGET (dock));
-
- } else if (!GDL_DOCK_OBJECT_ATTACHED (dock)) {
- /* if the user explicitly detached the object */
- if (dock->_priv->floating)
- gtk_widget_hide (GTK_WIDGET (dock));
- else {
- GtkWidget *widget = GTK_WIDGET (object);
- parent = gtk_widget_get_parent (widget);
- if (parent)
- gtk_container_remove (GTK_CONTAINER (parent), widget);
- }
- }
-}
-
-static gboolean
-gdl_dock_dock_request (GdlDockObject *object,
- gint x,
- gint y,
- GdlDockRequest *request)
-{
- GdlDock *dock;
- guint bw;
- gint rel_x, rel_y;
- GtkAllocation alloc;
- gboolean may_dock = FALSE;
- GdlDockRequest my_request;
-
- g_return_val_if_fail (GDL_IS_DOCK (object), FALSE);
-
- /* we get (x,y) in our allocation coordinates system */
-
- dock = GDL_DOCK (object);
-
- /* Get dock size. */
- gtk_widget_get_allocation (GTK_WIDGET (dock), &alloc);
- bw = gtk_container_get_border_width (GTK_CONTAINER (dock));
-
- /* Get coordinates relative to our allocation area. */
- rel_x = x - alloc.x;
- rel_y = y - alloc.y;
-
- if (request)
- my_request = *request;
-
- /* Check if coordinates are in GdlDock widget. */
- if (rel_x > 0 && rel_x < alloc.width &&
- rel_y > 0 && rel_y < alloc.height) {
-
- /* It's inside our area. */
- may_dock = TRUE;
-
- /* Set docking indicator rectangle to the GdlDock size. */
- my_request.rect.x = alloc.x + bw;
- my_request.rect.y = alloc.y + bw;
- my_request.rect.width = alloc.width - 2*bw;
- my_request.rect.height = alloc.height - 2*bw;
-
- /* If GdlDock has no root item yet, set the dock itself as
- possible target. */
- if (!dock->root) {
- my_request.position = GDL_DOCK_TOP;
- my_request.target = object;
- } else {
- my_request.target = dock->root;
-
- /* See if it's in the border_width band. */
- if (rel_x < (gint)bw) {
- my_request.position = GDL_DOCK_LEFT;
- my_request.rect.width *= SPLIT_RATIO;
- } else if (rel_x > alloc.width - (gint)bw) {
- my_request.position = GDL_DOCK_RIGHT;
- my_request.rect.x += my_request.rect.width * (1 - SPLIT_RATIO);
- my_request.rect.width *= SPLIT_RATIO;
- } else if (rel_y < (gint)bw) {
- my_request.position = GDL_DOCK_TOP;
- my_request.rect.height *= SPLIT_RATIO;
- } else if (rel_y > alloc.height - (gint)bw) {
- my_request.position = GDL_DOCK_BOTTOM;
- my_request.rect.y += my_request.rect.height * (1 - SPLIT_RATIO);
- my_request.rect.height *= SPLIT_RATIO;
- } else {
- /* Otherwise try our children. */
- /* give them allocation coordinates (we are a
- GTK_NO_WINDOW) widget */
- may_dock = gdl_dock_object_dock_request (GDL_DOCK_OBJECT (dock->root),
- x, y, &my_request);
- }
- }
- }
-
- if (may_dock && request)
- *request = my_request;
-
- return may_dock;
-}
-
-static void
-gdl_dock_dock (GdlDockObject *object,
- GdlDockObject *requestor,
- GdlDockPlacement position,
- GValue *user_data)
-{
- GdlDock *dock;
-
- g_return_if_fail (GDL_IS_DOCK (object));
- /* only dock items allowed at this time */
- g_return_if_fail (GDL_IS_DOCK_ITEM (requestor));
-
- dock = GDL_DOCK (object);
-
- if (position == GDL_DOCK_FLOATING) {
- GdlDockItem *item = GDL_DOCK_ITEM (requestor);
- gint x, y, width, height;
-
- if (user_data && G_VALUE_HOLDS (user_data, GDK_TYPE_RECTANGLE)) {
- GdkRectangle *rect;
-
- rect = g_value_get_boxed (user_data);
- x = rect->x;
- y = rect->y;
- width = rect->width;
- height = rect->height;
- }
- else {
- x = y = 0;
- width = height = -1;
- }
-
- gdl_dock_add_floating_item (dock, item,
- x, y, width, height);
- }
- else if (dock->root) {
- /* This is somewhat a special case since we know which item to
- pass the request on because we only have on child */
- gdl_dock_object_dock (dock->root, requestor, position, NULL);
- gdl_dock_set_title (dock);
-
- }
- else { /* Item about to be added is root item. */
- GtkWidget *widget = GTK_WIDGET (requestor);
-
- dock->root = requestor;
- GDL_DOCK_OBJECT_SET_FLAGS (requestor, GDL_DOCK_ATTACHED);
- gtk_widget_set_parent (widget, GTK_WIDGET (dock));
-
- gdl_dock_item_show_grip (GDL_DOCK_ITEM (requestor));
-
- /* Realize the item (create its corresponding GdkWindow) when
- GdlDock has been realized. */
- if (gtk_widget_get_realized (GTK_WIDGET (dock)))
- gtk_widget_realize (widget);
-
- /* 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. */
- if (gtk_widget_get_visible (GTK_WIDGET (dock)) &&
- gtk_widget_get_visible (widget)) {
- if (gtk_widget_get_mapped (GTK_WIDGET (dock)))
- gtk_widget_map (widget);
-
- /* Make the widget resize. */
- gtk_widget_queue_resize (widget);
- }
- gdl_dock_set_title (dock);
- }
-}
-
-static gboolean
-gdl_dock_floating_window_delete_event_cb (GtkWidget *widget)
-{
- GdlDock *dock;
-
- g_return_val_if_fail (GTK_IS_WINDOW (widget), FALSE);
-
- dock = GDL_DOCK (g_object_get_data (G_OBJECT (widget), "dock"));
- if (dock->root) {
- /* this will call reduce on ourselves, hiding the window if appropiate */
- gdl_dock_item_hide_item (GDL_DOCK_ITEM (dock->root));
- }
-
- return TRUE;
-}
-
-static void
-_gdl_dock_foreach_build_list (GdlDockObject *object,
- gpointer user_data)
-{
- GList **l = (GList **) user_data;
-
- if (GDL_IS_DOCK_ITEM (object))
- *l = g_list_prepend (*l, object);
-}
-
-static gboolean
-gdl_dock_reorder (GdlDockObject *object,
- GdlDockObject *requestor,
- GdlDockPlacement new_position,
- GValue *other_data)
-{
- GdlDock *dock = GDL_DOCK (object);
- gboolean handled = FALSE;
-
- if (dock->_priv->floating &&
- new_position == GDL_DOCK_FLOATING &&
- dock->root == requestor) {
-
- if (other_data && G_VALUE_HOLDS (other_data, GDK_TYPE_RECTANGLE)) {
- GdkRectangle *rect;
-
- rect = g_value_get_boxed (other_data);
- gtk_window_move (GTK_WINDOW (dock->_priv->window),
- rect->x,
- rect->y);
- handled = TRUE;
- }
- }
-
- return handled;
-}
-
-static gboolean
-gdl_dock_child_placement (GdlDockObject *object,
- GdlDockObject *child,
- GdlDockPlacement *placement)
-{
- GdlDock *dock = GDL_DOCK (object);
- gboolean retval = TRUE;
-
- if (dock->root == child) {
- if (placement) {
- if (*placement == GDL_DOCK_NONE || *placement == GDL_DOCK_FLOATING)
- *placement = GDL_DOCK_TOP;
- }
- } else
- retval = FALSE;
-
- return retval;
-}
-
-static void
-gdl_dock_present (GdlDockObject *object,
- GdlDockObject *child)
-{
- GdlDock *dock = GDL_DOCK (object);
-
- if (dock->_priv->floating)
- gtk_window_present (GTK_WINDOW (dock->_priv->window));
-}
-
-
-/* ----- Public interface ----- */
-
-GtkWidget *
-gdl_dock_new (void)
-{
- GObject *dock;
-
- dock = g_object_new (GDL_TYPE_DOCK, NULL);
- GDL_DOCK_OBJECT_UNSET_FLAGS (dock, GDL_DOCK_AUTOMATIC);
-
- return GTK_WIDGET (dock);
-}
-
-GtkWidget *
-gdl_dock_new_from (GdlDock *original,
- gboolean floating)
-{
- GObject *new_dock;
-
- g_return_val_if_fail (original != NULL, NULL);
-
- new_dock = g_object_new (GDL_TYPE_DOCK,
- "master", GDL_DOCK_OBJECT_GET_MASTER (original),
- "floating", floating,
- NULL);
- GDL_DOCK_OBJECT_UNSET_FLAGS (new_dock, GDL_DOCK_AUTOMATIC);
-
- 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
-gdl_dock_refine_placement (GdlDock *dock, GdlDockItem *dock_item,
- GdlDockPlacement placement)
-{
- GtkAllocation allocation;
- GtkRequisition object_size;
-
- gdl_dock_item_preferred_size (dock_item, &object_size);
- gtk_widget_get_allocation (GTK_WIDGET (dock), &allocation);
-
- g_return_val_if_fail (allocation.width > 0, placement);
- g_return_val_if_fail (allocation.height > 0, placement);
- g_return_val_if_fail (object_size.width > 0, placement);
- g_return_val_if_fail (object_size.height > 0, placement);
-
- if (placement == GDL_DOCK_LEFT || placement == GDL_DOCK_RIGHT) {
- /* Check if dock_object touches center in terms of width */
- if (allocation.width/2 > object_size.width) {
- return GDL_DOCK_CENTER;
- }
- } else if (placement == GDL_DOCK_TOP || placement == GDL_DOCK_BOTTOM) {
- /* Check if dock_object touches center in terms of height */
- if (allocation.height/2 > object_size.height) {
- return GDL_DOCK_CENTER;
- }
- }
- return placement;
-}
-
-/* Determines the larger item of the two based on the placement:
- * for left/right placement, height determines it.
- * for top/bottom placement, width determines it.
- * for center placement, area determines it.
- */
-static GdlDockItem*
-gdl_dock_select_larger_item (GdlDockItem *dock_item_1,
- GdlDockItem *dock_item_2,
- GdlDockPlacement placement,
- gint level /* for debugging */)
-{
- GtkRequisition size_1, size_2;
-
- g_return_val_if_fail (dock_item_1 != NULL, dock_item_2);
- g_return_val_if_fail (dock_item_2 != NULL, dock_item_1);
-
- gdl_dock_item_preferred_size (dock_item_1, &size_1);
- gdl_dock_item_preferred_size (dock_item_2, &size_2);
-
- g_return_val_if_fail (size_1.width > 0, dock_item_2);
- g_return_val_if_fail (size_1.height > 0, dock_item_2);
- g_return_val_if_fail (size_2.width > 0, dock_item_1);
- g_return_val_if_fail (size_2.height > 0, dock_item_1);
-
- if (placement == GDL_DOCK_LEFT || placement == GDL_DOCK_RIGHT)
- {
- /* For left/right placement, height is what matters */
- return (size_1.height >= size_2.height?
- dock_item_1 : dock_item_2);
- } else if (placement == GDL_DOCK_TOP || placement == GDL_DOCK_BOTTOM)
- {
- /* For top/bottom placement, width is what matters */
- return (size_1.width >= size_2.width?
- dock_item_1 : dock_item_2);
- } else if (placement == GDL_DOCK_CENTER) {
- /* For center place, area is what matters */
- return ((size_1.width * size_1.height)
- >= (size_2.width * size_2.height)?
- dock_item_1 : dock_item_2);
- } else if (placement == GDL_DOCK_NONE) {
- return dock_item_1;
- } else {
- g_warning ("Should not reach here: %s:%d", __FUNCTION__, __LINE__);
- }
- 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
- * largest item on/around the placement side (for side placements) and to
- * find the largest item for center placement. In most situations, this is
- * what user wants and the heuristic should be therefore sufficient.
- */
-static GdlDockItem*
-gdl_dock_find_best_placement_item (GdlDockItem *dock_item,
- GdlDockPlacement placement,
- gint level /* for debugging */)
-{
- GdlDockItem *ret_item = NULL;
-
- if (GDL_IS_DOCK_PANED (dock_item))
- {
- GtkOrientation orientation;
- GdlDockItem *dock_item_1, *dock_item_2;
- GList* children;
-
- children = gtk_container_get_children (GTK_CONTAINER (dock_item));
-
- g_assert (g_list_length (children) == 2);
-
- g_object_get (dock_item, "orientation", &orientation, NULL);
- if ((orientation == GTK_ORIENTATION_HORIZONTAL &&
- placement == GDL_DOCK_LEFT) ||
- (orientation == GTK_ORIENTATION_VERTICAL &&
- placement == GDL_DOCK_TOP)) {
- /* Return left or top pane widget */
- ret_item =
- gdl_dock_find_best_placement_item (GDL_DOCK_ITEM
- (children->data),
- placement, level + 1);
- } else if ((orientation == GTK_ORIENTATION_HORIZONTAL &&
- placement == GDL_DOCK_RIGHT) ||
- (orientation == GTK_ORIENTATION_VERTICAL &&
- placement == GDL_DOCK_BOTTOM)) {
- /* Return right or top pane widget */
- ret_item =
- gdl_dock_find_best_placement_item (GDL_DOCK_ITEM
- (children->next->data),
- placement, level + 1);
- } else {
- /* Evaluate which of the two sides is bigger */
- dock_item_1 =
- gdl_dock_find_best_placement_item (GDL_DOCK_ITEM
- (children->data),
- placement, level + 1);
- dock_item_2 =
- gdl_dock_find_best_placement_item (GDL_DOCK_ITEM
- (children->next->data),
- placement, level + 1);
- ret_item = gdl_dock_select_larger_item (dock_item_1,
- dock_item_2,
- placement, level);
- }
- g_list_free (children);
- }
- else if (GDL_IS_DOCK_ITEM (dock_item))
- {
- ret_item = dock_item;
- }
- else
- {
- /* should not be here */
- g_warning ("Should not reach here: %s:%d", __FUNCTION__, __LINE__);
- }
- return ret_item;
-}
-
-void
-gdl_dock_add_item (GdlDock *dock,
- GdlDockItem *item,
- GdlDockPlacement placement)
-{
- g_return_if_fail (dock != NULL);
- g_return_if_fail (item != NULL);
-
- if (placement == GDL_DOCK_FLOATING)
- /* Add the item to a new floating dock */
- gdl_dock_add_floating_item (dock, item, 0, 0, -1, -1);
-
- else {
- GdlDockItem *best_dock_item;
- /* Non-floating item. */
- if (dock->root) {
- GdlDockPlacement local_placement;
-
- best_dock_item =
- gdl_dock_find_best_placement_item (GDL_DOCK_ITEM (dock->root),
- placement, 0);
- local_placement = gdl_dock_refine_placement (dock, best_dock_item,
- placement);
- gdl_dock_object_dock (GDL_DOCK_OBJECT (best_dock_item),
- GDL_DOCK_OBJECT (item),
- local_placement, NULL);
- } else {
- gdl_dock_object_dock (GDL_DOCK_OBJECT (dock),
- GDL_DOCK_OBJECT (item),
- placement, NULL);
- }
- }
-}
-
-void
-gdl_dock_add_floating_item (GdlDock *dock,
- GdlDockItem *item,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- GdlDock *new_dock;
-
- g_return_if_fail (dock != NULL);
- g_return_if_fail (item != NULL);
-
- new_dock = GDL_DOCK (g_object_new (GDL_TYPE_DOCK,
- "master", GDL_DOCK_OBJECT_GET_MASTER (dock),
- "floating", TRUE,
- "width", width,
- "height", height,
- "floatx", x,
- "floaty", y,
- NULL));
-
- if (gtk_widget_get_visible (GTK_WIDGET (dock))) {
- gtk_widget_show (GTK_WIDGET (new_dock));
- if (gtk_widget_get_mapped (GTK_WIDGET (dock)))
- gtk_widget_map (GTK_WIDGET (new_dock));
-
- /* Make the widget resize. */
- gtk_widget_queue_resize (GTK_WIDGET (new_dock));
- }
-
- gdl_dock_add_item (GDL_DOCK (new_dock), item, GDL_DOCK_TOP);
-}
-
-GdlDockItem *
-gdl_dock_get_item_by_name (GdlDock *dock,
- const gchar *name)
-{
- GdlDockObject *found;
-
- g_return_val_if_fail (dock != NULL && name != NULL, NULL);
-
- /* proxy the call to our master */
- found = gdl_dock_master_get_object (GDL_DOCK_OBJECT_GET_MASTER (dock), name);
-
- return (found && GDL_IS_DOCK_ITEM (found)) ? GDL_DOCK_ITEM (found) : NULL;
-}
-
-GdlDockPlaceholder *
-gdl_dock_get_placeholder_by_name (GdlDock *dock,
- const gchar *name)
-{
- GdlDockObject *found;
-
- g_return_val_if_fail (dock != NULL && name != NULL, NULL);
-
- /* proxy the call to our master */
- found = gdl_dock_master_get_object (GDL_DOCK_OBJECT_GET_MASTER (dock), name);
-
- return (found && GDL_IS_DOCK_PLACEHOLDER (found)) ?
- GDL_DOCK_PLACEHOLDER (found) : NULL;
-}
-
-GList *
-gdl_dock_get_named_items (GdlDock *dock)
-{
- GList *list = NULL;
-
- g_return_val_if_fail (dock != NULL, NULL);
-
- gdl_dock_master_foreach (GDL_DOCK_OBJECT_GET_MASTER (dock),
- (GFunc) _gdl_dock_foreach_build_list, &list);
-
- return list;
-}
-
-GdlDock *
-gdl_dock_object_get_toplevel (GdlDockObject *object)
-{
- GdlDockObject *parent = object;
-
- g_return_val_if_fail (object != NULL, NULL);
-
- while (parent && !GDL_IS_DOCK (parent))
- parent = gdl_dock_object_get_parent_object (parent);
-
- return parent ? GDL_DOCK (parent) : NULL;
-}
-
-void
-gdl_dock_xor_rect (GdlDock *dock,
- GdkRectangle *rect)
-{
- GtkWidget *widget;
- GdkWindow *window;
- gint8 dash_list [2];
-
- widget = GTK_WIDGET (dock);
-
- if (!dock->_priv->xor_gc) {
- if (gtk_widget_get_realized (widget)) {
- GdkGCValues values;
-
- values.function = GDK_INVERT;
- values.subwindow_mode = GDK_INCLUDE_INFERIORS;
- dock->_priv->xor_gc = gdk_gc_new_with_values
- (gtk_widget_get_window (widget), &values, GDK_GC_FUNCTION | GDK_GC_SUBWINDOW);
- } else
- return;
- };
-
- gdk_gc_set_line_attributes (dock->_priv->xor_gc, 1,
- GDK_LINE_ON_OFF_DASH,
- GDK_CAP_NOT_LAST,
- GDK_JOIN_BEVEL);
-
- window = gtk_widget_get_window (widget);
-
- dash_list [0] = 1;
- dash_list [1] = 1;
-
- gdk_gc_set_dashes (dock->_priv->xor_gc, 1, dash_list, 2);
-
- gdk_draw_rectangle (window, dock->_priv->xor_gc, FALSE,
- rect->x, rect->y,
- rect->width, rect->height);
-
- gdk_gc_set_dashes (dock->_priv->xor_gc, 0, dash_list, 2);
-
- gdk_draw_rectangle (window, dock->_priv->xor_gc, FALSE,
- rect->x + 1, rect->y + 1,
- rect->width - 2, rect->height - 2);
-}
diff --git a/src/libgdl/gdl-dock.h b/src/libgdl/gdl-dock.h
deleted file mode 100644
index 2259d395d..000000000
--- a/src/libgdl/gdl-dock.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* -*- 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>
- *
- * This library is free software; you can redistribute it and/or
- * 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
- */
-
-#ifndef __GDL_DOCK_H__
-#define __GDL_DOCK_H__
-
-#include <gtk/gtk.h>
-#include "libgdl/gdl-dock-object.h"
-#include "libgdl/gdl-dock-item.h"
-#include "libgdl/gdl-dock-placeholder.h"
-
-G_BEGIN_DECLS
-
-/* standard macros */
-#define GDL_TYPE_DOCK (gdl_dock_get_type ())
-#define GDL_DOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK, GdlDock))
-#define GDL_DOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK, GdlDockClass))
-#define GDL_IS_DOCK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK))
-#define GDL_IS_DOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK))
-#define GDL_DOCK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK, GdlDockClass))
-
-/* data types & structures */
-typedef struct _GdlDock GdlDock;
-typedef struct _GdlDockClass GdlDockClass;
-typedef struct _GdlDockPrivate GdlDockPrivate;
-
-struct _GdlDock {
- GdlDockObject object;
-
- GdlDockObject *root;
-
- GdlDockPrivate *_priv;
-};
-
-struct _GdlDockClass {
- GdlDockObjectClass parent_class;
-
- void (* layout_changed) (GdlDock *dock); /* proxy signal for the master */
-};
-
-/* additional macros */
-#define GDL_DOCK_IS_CONTROLLER(dock) \
- (gdl_dock_master_get_controller (GDL_DOCK_OBJECT_GET_MASTER (dock)) == \
- GDL_DOCK_OBJECT (dock))
-
-/* public interface */
-
-GtkWidget *gdl_dock_new (void);
-
-GtkWidget *gdl_dock_new_from (GdlDock *original,
- gboolean floating);
-
-GType gdl_dock_get_type (void);
-
-void gdl_dock_add_item (GdlDock *dock,
- GdlDockItem *item,
- GdlDockPlacement place);
-
-void gdl_dock_add_floating_item (GdlDock *dock,
- GdlDockItem *item,
- gint x,
- gint y,
- gint width,
- gint height);
-
-GdlDockItem *gdl_dock_get_item_by_name (GdlDock *dock,
- const gchar *name);
-
-GdlDockPlaceholder *gdl_dock_get_placeholder_by_name (GdlDock *dock,
- const gchar *name);
-
-GList *gdl_dock_get_named_items (GdlDock *dock);
-
-GdlDock *gdl_dock_object_get_toplevel (GdlDockObject *object);
-
-void gdl_dock_xor_rect (GdlDock *dock,
- GdkRectangle *rect);
-
-G_END_DECLS
-
-#endif
diff --git a/src/libgdl/gdl-i18n.c b/src/libgdl/gdl-i18n.c
deleted file mode 100644
index 5f92b66c7..000000000
--- a/src/libgdl/gdl-i18n.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
- * All rights reserved.
- *
- * This file is part of the Gnome Devtools Library.
- *
- * The Gnome Devtools Library is free software; you can redistribute
- * it and/or 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.
- *
- * The Gnome Devtools 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 the Gnome Library; see the file COPYING.LIB. 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"
-
-char *
-gdl_gettext (const char *msgid)
-{
- static gboolean initialized = FALSE;
-
- if (!initialized) {
-/* bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); */
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- initialized = TRUE;
- }
-
- return dgettext (GETTEXT_PACKAGE, msgid);
-}
-
-
diff --git a/src/libgdl/gdl-i18n.h b/src/libgdl/gdl-i18n.h
deleted file mode 100644
index 1582e957d..000000000
--- a/src/libgdl/gdl-i18n.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
- * All rights reserved.
- *
- * This file is part of the Gnome Devtools Library.
- *
- * The Gnome Devtools Library is free software; you can redistribute
- * it and/or 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.
- *
- * The Gnome Devtools 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 the Gnome Library; see the file COPYING.LIB. If not,
- * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-/*
- @NOTATION@
- */
-
-/*
- * Handles all of the internationalization configuration options.
- * Author: Tom Tromey <tromey@creche.cygnus.com>
- */
-
-#ifndef __GDL_18N_H__
-#define __GDL_18N_H__ 1
-
-#include <glib.h>
-
-
-G_BEGIN_DECLS
-
-#ifdef ENABLE_NLS
-# include <libintl.h>
-# undef _
-# define _(String) gdl_gettext (String)
-# ifdef gettext_noop
-# define N_(String) gettext_noop (String)
-# else
-# define N_(String) (String)
-# endif
-#else
-/* Stubs that do something close enough. */
-# undef textdomain
-# define textdomain(String) (String)
-# undef gettext
-# define gettext(String) (String)
-# undef dgettext
-# define dgettext(Domain,Message) (Message)
-# undef dcgettext
-# define dcgettext(Domain,Message,Type) (Message)
-# undef bindtextdomain
-# define bindtextdomain(Domain,Directory) (Domain)
-# undef bind_textdomain_codeset
-# define bind_textdomain_codeset(Domain,CodeSet) (Domain)
-# undef _
-# define _(String) (String)
-# undef N_
-# define N_(String) (String)
-#endif
-
-char *gdl_gettext (const char *msgid);
-
-G_END_DECLS
-
-#endif /* __GDL_I18N_H__ */
diff --git a/src/libgdl/gdl-switcher.c b/src/libgdl/gdl-switcher.c
deleted file mode 100644
index 53a4b1989..000000000
--- a/src/libgdl/gdl-switcher.c
+++ /dev/null
@@ -1,1031 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 8 -*- */
-/* gdl-switcher.c
- *
- * Copyright (C) 2003 Ettore Perazzoli,
- * 2007 Naba Kumar
- *
- * This library is free software; you can redistribute it and/or
- * 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.
- *
- *
- * Copied and adapted from ESidebar.[ch] from evolution
- *
- * Authors: Ettore Perazzoli <ettore@ximian.com>
- * Naba Kumar <naba@gnome.org>
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "gdl-i18n.h"
-#include "gdl-switcher.h"
-#include "libgdlmarshal.h"
-#include "libgdltypebuiltins.h"
-
-#include <gtk/gtk.h>
-
-static void gdl_switcher_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gdl_switcher_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static void gdl_switcher_add_button (GdlSwitcher *switcher,
- const gchar *label,
- const gchar *tooltips,
- const gchar *stock_id,
- GdkPixbuf *pixbuf_icon,
- gint switcher_id,
- GtkWidget *page);
-/* static void gdl_switcher_remove_button (GdlSwitcher *switcher, gint switcher_id); */
-static void gdl_switcher_select_page (GdlSwitcher *switcher, gint switcher_id);
-static void gdl_switcher_select_button (GdlSwitcher *switcher, gint switcher_id);
-static void gdl_switcher_set_show_buttons (GdlSwitcher *switcher, gboolean show);
-static void gdl_switcher_set_style (GdlSwitcher *switcher,
- GdlSwitcherStyle switcher_style);
-static GdlSwitcherStyle gdl_switcher_get_style (GdlSwitcher *switcher);
-
-enum {
- PROP_0,
- PROP_SWITCHER_STYLE
-};
-
-typedef struct {
- GtkWidget *button_widget;
- GtkWidget *label;
- GtkWidget *icon;
- GtkWidget *arrow;
- GtkWidget *hbox;
- GtkWidget *page;
- int id;
-} Button;
-
-struct _GdlSwitcherPrivate {
- GdlSwitcherStyle switcher_style;
- GdlSwitcherStyle toolbar_style;
-
- gboolean show;
- GSList *buttons;
-
- guint style_changed_id;
- gint buttons_height_request;
- gboolean in_toggle;
-};
-
-G_DEFINE_TYPE (GdlSwitcher, gdl_switcher, GTK_TYPE_NOTEBOOK)
-
-#define INTERNAL_MODE(switcher) (switcher->priv->switcher_style == \
- GDL_SWITCHER_STYLE_TOOLBAR ? switcher->priv->toolbar_style : \
- switcher->priv->switcher_style)
-
-#define H_PADDING 2
-#define V_PADDING 2
-
-/* Utility functions. */
-
-static void
-gdl_switcher_long_name_changed (GObject* object,
- GParamSpec* spec,
- gpointer user_data)
-{
- Button* button = user_data;
- gchar* label;
-
- g_object_get (object, "long-name", &label, NULL);
- gtk_label_set_text (GTK_LABEL (button->label), label);
- g_free (label);
-}
-
-static void
-gdl_switcher_stock_id_changed (GObject* object,
- GParamSpec* spec,
- gpointer user_data)
-{
- Button* button = user_data;
- gchar* id;
-
- g_object_get (object, "stock-id", &id, NULL);
- gtk_image_set_from_stock (GTK_IMAGE(button->icon), id, GTK_ICON_SIZE_MENU);
- g_free (id);
-}
-
-
-static Button *
-button_new (GtkWidget *button_widget, GtkWidget *label, GtkWidget *icon,
- GtkWidget *arrow, GtkWidget *hbox, int id, GtkWidget *page)
-{
- Button *button = g_new (Button, 1);
-
- button->button_widget = button_widget;
- button->label = label;
- button->icon = icon;
- button->arrow = arrow;
- button->hbox = hbox;
- button->id = id;
- button->page = page;
-
- g_signal_connect (page, "notify::long-name", G_CALLBACK (gdl_switcher_long_name_changed),
- button);
- g_signal_connect (page, "notify::stock-id", G_CALLBACK (gdl_switcher_stock_id_changed),
- button);
-
- g_object_ref (button_widget);
- g_object_ref (label);
- g_object_ref (icon);
- g_object_ref (arrow);
- g_object_ref (hbox);
-
- return button;
-}
-
-static void
-button_free (Button *button)
-{
- g_signal_handlers_disconnect_by_func (button->page,
- gdl_switcher_long_name_changed,
- button);
- g_signal_handlers_disconnect_by_func (button->page,
- gdl_switcher_stock_id_changed,
- button);
-
- g_object_unref (button->button_widget);
- g_object_unref (button->label);
- g_object_unref (button->icon);
- g_object_unref (button->hbox);
- g_free (button);
-}
-
-static gint
-gdl_switcher_get_page_id (GtkWidget *widget)
-{
- static gint switcher_id_count = 0;
- gint switcher_id;
- switcher_id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget),
- "__switcher_id"));
- if (switcher_id <= 0) {
- switcher_id = ++switcher_id_count;
- g_object_set_data (G_OBJECT (widget), "__switcher_id",
- GINT_TO_POINTER (switcher_id));
- }
- return switcher_id;
-}
-
-static void
-update_buttons (GdlSwitcher *switcher, int new_selected_id)
-{
- GSList *p;
-
- switcher->priv->in_toggle = TRUE;
-
- for (p = switcher->priv->buttons; p != NULL; p = p->next) {
- Button *button = p->data;
-
- if (button->id == new_selected_id) {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (button->button_widget), TRUE);
- gtk_widget_set_sensitive (button->arrow, TRUE);
- } else {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (button->button_widget), FALSE);
- gtk_widget_set_sensitive (button->arrow, FALSE);
- }
- }
-
- switcher->priv->in_toggle = FALSE;
-}
-
-/* Callbacks. */
-
-static void
-button_toggled_callback (GtkToggleButton *toggle_button,
- GdlSwitcher *switcher)
-{
- int id = 0;
- gboolean is_active = FALSE;
- GSList *p;
-
- if (switcher->priv->in_toggle)
- return;
-
- switcher->priv->in_toggle = TRUE;
-
- if (gtk_toggle_button_get_active (toggle_button))
- is_active = TRUE;
-
- for (p = switcher->priv->buttons; p != NULL; p = p->next) {
- Button *button = p->data;
-
- if (button->button_widget != GTK_WIDGET (toggle_button)) {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (button->button_widget), FALSE);
- gtk_widget_set_sensitive (button->arrow, FALSE);
- } else {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
- (button->button_widget), TRUE);
- gtk_widget_set_sensitive (button->arrow, TRUE);
- id = button->id;
- }
- }
-
- switcher->priv->in_toggle = FALSE;
-
- if (is_active)
- {
- gdl_switcher_select_page (switcher, id);
- }
-}
-
-/* Returns -1 if layout didn't happen because a resize request was queued */
-static int
-layout_buttons (GdlSwitcher *switcher)
-{
- GtkRequisition client_requisition = {0,0};
- GtkAllocation allocation;
- GdlSwitcherStyle switcher_style;
- gboolean icons_only;
- int num_btns = g_slist_length (switcher->priv->buttons);
- unsigned int btns_per_row;
- GSList **rows, *p;
- Button *button;
- int row_number;
- int max_btn_width = 0, max_btn_height = 0;
- int optimal_layout_width = 0;
- int row_last;
- int x, y;
- int i;
- int rows_count;
- int last_buttons_height;
-
- gtk_widget_get_allocation (GTK_WIDGET (switcher), &allocation);
-
- last_buttons_height = switcher->priv->buttons_height_request;
-
- GTK_WIDGET_CLASS (gdl_switcher_parent_class)->size_request (GTK_WIDGET (switcher), &client_requisition);
-
- y = allocation.y + allocation.height - V_PADDING - 1;
-
- if (num_btns == 0)
- return y;
-
- switcher_style = INTERNAL_MODE (switcher);
- icons_only = (switcher_style == GDL_SWITCHER_STYLE_ICON);
-
- /* Figure out the max width and height */
- optimal_layout_width = H_PADDING;
- for (p = switcher->priv->buttons; p != NULL; p = p->next) {
- GtkRequisition requisition;
-
- button = p->data;
- gtk_widget_size_request (GTK_WIDGET (button->button_widget),
- &requisition);
- optimal_layout_width += requisition.width + H_PADDING;
- max_btn_height = MAX (max_btn_height, requisition.height);
- max_btn_width = MAX (max_btn_width, requisition.width);
- }
-
- /* Figure out how many rows and columns we'll use. */
- btns_per_row = allocation.width / (max_btn_width + H_PADDING);
- /* Use at least one column */
- if (btns_per_row == 0) btns_per_row = 1;
-
- /* If all the buttons could fit in the single row, have it so */
- if (allocation.width >= optimal_layout_width)
- {
- btns_per_row = num_btns;
- }
- if (!icons_only) {
- /* If using text buttons, we want to try to have a
- * completely filled-in grid, but if we can't, we want
- * the odd row to have just a single button.
- */
- while (num_btns % btns_per_row > 1)
- btns_per_row--;
- }
-
- rows_count = num_btns / btns_per_row;
- if (num_btns % btns_per_row != 0)
- rows_count++;
-
- /* Assign buttons to rows */
- rows = g_new0 (GSList *, rows_count);
-
- if (!icons_only && num_btns % btns_per_row != 0) {
- button = switcher->priv->buttons->data;
- rows [0] = g_slist_append (rows [0], button->button_widget);
-
- p = switcher->priv->buttons->next;
- row_number = p ? 1 : 0;
- } else {
- p = switcher->priv->buttons;
- row_number = 0;
- }
-
- for (; p != NULL; p = p->next) {
- button = p->data;
-
- if (g_slist_length (rows [row_number]) == btns_per_row)
- row_number ++;
-
- rows [row_number] = g_slist_append (rows [row_number],
- button->button_widget);
- }
-
- row_last = row_number;
-
- /* If there are more than 1 row of buttons, save the current height
- * requirement for subsequent size requests.
- */
- if (row_last > 0)
- {
- switcher->priv->buttons_height_request =
- (row_last + 1) * (max_btn_height + V_PADDING) + 1;
- } else { /* Otherwize clear it */
- if (last_buttons_height >= 0) {
-
- switcher->priv->buttons_height_request = -1;
- }
- }
-
- /* If it turns out that we now require smaller height for the buttons
- * than it was last time, make a resize request to ensure our
- * size requisition is properly communicated to the parent (otherwise
- * parent tend to keep assuming the older size).
- */
- if (last_buttons_height > switcher->priv->buttons_height_request)
- {
- gtk_widget_queue_resize (GTK_WIDGET (switcher));
- y = -1; // set return value
- }
- else
- {
- /* Layout the buttons. */
- for (i = row_last; i >= 0; i --) {
- int len, extra_width;
-
- y -= max_btn_height;
-
- /* Check for possible size over flow (taking into account client
- * requisition
- */
- if (y < (allocation.y + client_requisition.height)) {
- /* We have an overflow: Insufficient allocation */
- if (last_buttons_height < switcher->priv->buttons_height_request) {
- /* Request for a new resize */
- gtk_widget_queue_resize (GTK_WIDGET (switcher));
- y = -1; // set return value
- goto exit;
- }
- }
- x = H_PADDING + allocation.x;
- len = g_slist_length (rows[i]);
- if (switcher_style == GDL_SWITCHER_STYLE_TEXT ||
- switcher_style == GDL_SWITCHER_STYLE_BOTH)
- extra_width = (allocation.width - (len * max_btn_width )
- - (len * H_PADDING)) / len;
- else
- extra_width = 0;
- for (p = rows [i]; p != NULL; p = p->next) {
- GtkAllocation child_allocation;
-
- child_allocation.x = x;
- child_allocation.y = y;
- if (rows_count == 1 && row_number == 0)
- {
- GtkRequisition child_requisition;
- gtk_widget_size_request (GTK_WIDGET (p->data),
- &child_requisition);
- child_allocation.width = child_requisition.width;
- }
- else
- {
- child_allocation.width = max_btn_width + extra_width;
- }
- child_allocation.height = max_btn_height;
-
- gtk_widget_size_allocate (GTK_WIDGET (p->data), &child_allocation);
-
- x += child_allocation.width + H_PADDING;
- }
-
- y -= V_PADDING;
- }
- }
-
- exit:
- for (i = 0; i <= row_last; i ++) {
- g_slist_free (rows [i]);
- }
- g_free (rows);
-
- return y;
-}
-
-static void
-do_layout (GdlSwitcher *switcher)
-{
- GtkAllocation allocation;
- GtkAllocation child_allocation;
- int y;
-
- gtk_widget_get_allocation (GTK_WIDGET (switcher), &allocation);
-
- if (switcher->priv->show) {
- y = layout_buttons (switcher);
- if (y < 0) /* Layout did not happen and a resize was requested */
- return;
- }
- else
- y = allocation.y + allocation.height;
-
- /* Place the parent widget. */
- child_allocation.x = allocation.x;
- child_allocation.y = allocation.y;
- child_allocation.width = allocation.width;
- child_allocation.height = y - allocation.y;
-
- GTK_WIDGET_CLASS (gdl_switcher_parent_class)->size_allocate (GTK_WIDGET (switcher), &child_allocation);
-}
-
-/* GtkContainer methods. */
-
-static void
-gdl_switcher_forall (GtkContainer *container, gboolean include_internals,
- GtkCallback callback, void *callback_data)
-{
- GdlSwitcher *switcher =
- GDL_SWITCHER (container);
- GSList *p;
-
- GTK_CONTAINER_CLASS (gdl_switcher_parent_class)->forall (GTK_CONTAINER (switcher),
- include_internals,
- callback, callback_data);
- if (include_internals) {
- for (p = switcher->priv->buttons; p != NULL; p = p->next) {
- GtkWidget *widget = ((Button *) p->data)->button_widget;
- (* callback) (widget, callback_data);
- }
- }
-}
-
-static void
-gdl_switcher_remove (GtkContainer *container, GtkWidget *widget)
-{
- gint switcher_id;
- GdlSwitcher *switcher =
- GDL_SWITCHER (container);
- GSList *p;
-
- switcher_id = gdl_switcher_get_page_id (widget);
- for (p = switcher->priv->buttons; p != NULL; p = p->next) {
- Button *b = (Button *) p->data;
-
- if (b->id == switcher_id) {
- gtk_widget_unparent (b->button_widget);
- switcher->priv->buttons =
- g_slist_remove_link (switcher->priv->buttons, p);
- button_free (b);
- gtk_widget_queue_resize (GTK_WIDGET (switcher));
- break;
- }
- }
- GTK_CONTAINER_CLASS (gdl_switcher_parent_class)->remove (GTK_CONTAINER (switcher), widget);
-}
-
-/* GtkWidget methods. */
-
-static void
-gdl_switcher_size_request (GtkWidget *widget, GtkRequisition *requisition)
-{
- GdlSwitcher *switcher = GDL_SWITCHER (widget);
- GSList *p;
- gint button_height = 0;
-
- GTK_WIDGET_CLASS (gdl_switcher_parent_class)->size_request (GTK_WIDGET (switcher), requisition);
-
- if (!switcher->priv->show)
- return;
-
- for (p = switcher->priv->buttons; p != NULL; p = p->next) {
- gint button_width;
- Button *button = p->data;
- GtkRequisition button_requisition;
-
- gtk_widget_size_request (button->button_widget, &button_requisition);
- button_width = button_requisition.width + 2 * H_PADDING;
- requisition->width = MAX (requisition->width, button_width);
- button_height = MAX (button_height,
- button_requisition.height + 2 * V_PADDING);
- }
-
- if (switcher->priv->buttons_height_request > 0) {
- requisition->height += switcher->priv->buttons_height_request;
- } else {
- requisition->height += button_height + V_PADDING;
- }
-}
-
-static void
-gdl_switcher_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
-{
- gtk_widget_set_allocation (widget, allocation);
- do_layout (GDL_SWITCHER (widget));
-}
-
-static gint
-gdl_switcher_expose (GtkWidget *widget, GdkEventExpose *event)
-{
- GSList *p;
- GdlSwitcher *switcher = GDL_SWITCHER (widget);
- if (switcher->priv->show) {
- for (p = switcher->priv->buttons; p != NULL; p = p->next) {
- GtkWidget *button = ((Button *) p->data)->button_widget;
- gtk_container_propagate_expose (GTK_CONTAINER (widget),
- button, event);
- }
- }
- return GTK_WIDGET_CLASS (gdl_switcher_parent_class)->expose_event (widget, event);
-}
-
-static void
-gdl_switcher_map (GtkWidget *widget)
-{
- GSList *p;
- GdlSwitcher *switcher = GDL_SWITCHER (widget);
-
- if (switcher->priv->show) {
- for (p = switcher->priv->buttons; p != NULL; p = p->next) {
- GtkWidget *button = ((Button *) p->data)->button_widget;
- gtk_widget_map (button);
- }
- }
- GTK_WIDGET_CLASS (gdl_switcher_parent_class)->map (widget);
-}
-
-/* GObject methods. */
-
-static void
-gdl_switcher_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GdlSwitcher *switcher = GDL_SWITCHER (object);
-
- switch (prop_id) {
- case PROP_SWITCHER_STYLE:
- gdl_switcher_set_style (switcher, g_value_get_enum (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gdl_switcher_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GdlSwitcher *switcher = GDL_SWITCHER (object);
-
- switch (prop_id) {
- case PROP_SWITCHER_STYLE:
- g_value_set_enum (value, gdl_switcher_get_style (switcher));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gdl_switcher_dispose (GObject *object)
-{
- GdlSwitcherPrivate *priv = GDL_SWITCHER (object)->priv;
-
-#if HAVE_GNOME
- GConfClient *gconf_client = gconf_client_get_default ();
-
- if (priv->style_changed_id) {
- gconf_client_notify_remove (gconf_client, priv->style_changed_id);
- priv->style_changed_id = 0;
- }
- g_object_unref (gconf_client);
-#endif
-
- g_slist_foreach (priv->buttons, (GFunc) button_free, NULL);
- g_slist_free (priv->buttons);
- priv->buttons = NULL;
-
- G_OBJECT_CLASS (gdl_switcher_parent_class)->dispose (object);
-}
-
-static void
-gdl_switcher_finalize (GObject *object)
-{
- GdlSwitcherPrivate *priv = GDL_SWITCHER (object)->priv;
-
- g_free (priv);
-
- G_OBJECT_CLASS (gdl_switcher_parent_class)->finalize (object);
-}
-
-/* Signal handlers */
-
-static void
-gdl_switcher_notify_cb (GObject *g_object, GParamSpec *pspec,
- GdlSwitcher *switcher)
-{
-}
-
-static void
-gdl_switcher_switch_page_cb (GtkNotebook *nb, GtkWidget *page_widget,
- gint page_num, GdlSwitcher *switcher)
-{
- gint switcher_id;
-
- /* Change switcher button */
- switcher_id = gdl_switcher_get_page_id (page_widget);
- gdl_switcher_select_button (GDL_SWITCHER (switcher), switcher_id);
-}
-
-static void
-gdl_switcher_page_added_cb (GtkNotebook *nb, GtkWidget *page,
- gint page_num, GdlSwitcher *switcher)
-{
- gint switcher_id;
-
- (void)nb;
- (void)page_num;
- switcher_id = gdl_switcher_get_page_id (page);
-
- gdl_switcher_add_button (GDL_SWITCHER (switcher), NULL, NULL, NULL, NULL,
- switcher_id, page);
- gdl_switcher_select_button (GDL_SWITCHER (switcher), switcher_id);
-}
-
-static void
-gdl_switcher_select_page (GdlSwitcher *switcher, gint id)
-{
- GList *children, *node;
- children = gtk_container_get_children (GTK_CONTAINER (switcher));
- node = children;
- while (node)
- {
- gint switcher_id;
- switcher_id = gdl_switcher_get_page_id (GTK_WIDGET (node->data));
- if (switcher_id == id)
- {
- gint page_num;
- page_num = gtk_notebook_page_num (GTK_NOTEBOOK (switcher),
- GTK_WIDGET (node->data));
- g_signal_handlers_block_by_func (switcher,
- gdl_switcher_switch_page_cb,
- switcher);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (switcher), page_num);
- g_signal_handlers_unblock_by_func (switcher,
- gdl_switcher_switch_page_cb,
- switcher);
- break;
- }
- node = g_list_next (node);
- }
- g_list_free (children);
-}
-
-/* Initialization. */
-
-static void
-gdl_switcher_class_init (GdlSwitcherClass *klass)
-{
- GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- container_class->forall = gdl_switcher_forall;
- container_class->remove = gdl_switcher_remove;
-
- widget_class->size_request = gdl_switcher_size_request;
- widget_class->size_allocate = gdl_switcher_size_allocate;
- widget_class->expose_event = gdl_switcher_expose;
- widget_class->map = gdl_switcher_map;
-
- object_class->dispose = gdl_switcher_dispose;
- object_class->finalize = gdl_switcher_finalize;
- object_class->set_property = gdl_switcher_set_property;
- object_class->get_property = gdl_switcher_get_property;
-
- g_object_class_install_property (
- object_class, PROP_SWITCHER_STYLE,
- g_param_spec_enum ("switcher-style", _("Switcher Style"),
- _("Switcher buttons style"),
- GDL_TYPE_SWITCHER_STYLE,
- GDL_SWITCHER_STYLE_BOTH,
- G_PARAM_READWRITE));
-
- gtk_rc_parse_string ("style \"gdl-button-style\"\n"
- "{\n"
- "GtkWidget::focus-padding = 1\n"
- "GtkWidget::focus-line-width = 1\n"
- "xthickness = 0\n"
- "ythickness = 0\n"
- "}\n"
- "widget \"*.gdl-button\" style \"gdl-button-style\"");
-}
-
-static void
-gdl_switcher_init (GdlSwitcher *switcher)
-{
- GdlSwitcherPrivate *priv;
-
- gtk_widget_set_has_window (GTK_WIDGET (switcher), FALSE);
-
- priv = g_new0 (GdlSwitcherPrivate, 1);
- switcher->priv = priv;
-
- priv->show = TRUE;
- priv->buttons_height_request = -1;
-
- gtk_notebook_set_tab_pos (GTK_NOTEBOOK (switcher), GTK_POS_BOTTOM);
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), FALSE);
- gtk_notebook_set_show_border (GTK_NOTEBOOK (switcher), FALSE);
- gdl_switcher_set_style (switcher, GDL_SWITCHER_STYLE_BOTH);
-
- /* notebook signals */
- g_signal_connect (switcher, "switch-page",
- G_CALLBACK (gdl_switcher_switch_page_cb), switcher);
- g_signal_connect (switcher, "page-added",
- G_CALLBACK (gdl_switcher_page_added_cb), switcher);
- g_signal_connect (switcher, "notify::show-tabs",
- G_CALLBACK (gdl_switcher_notify_cb), switcher);
-}
-
-GtkWidget *
-gdl_switcher_new (void)
-{
- GdlSwitcher *switcher = g_object_new (gdl_switcher_get_type (), NULL);
- return GTK_WIDGET (switcher);
-}
-
-static void
-gdl_switcher_add_button (GdlSwitcher *switcher, const gchar *label,
- const gchar *tooltips, const gchar *stock_id,
- GdkPixbuf *pixbuf_icon,
- gint switcher_id, GtkWidget* page)
-{
- GtkWidget *button_widget;
- GtkWidget *hbox;
- GtkWidget *icon_widget;
- GtkWidget *label_widget;
- GtkWidget *arrow;
-
- button_widget = gtk_toggle_button_new ();
- gtk_widget_set_name (button_widget, "gdl-button");
- gtk_button_set_relief (GTK_BUTTON(button_widget), GTK_RELIEF_HALF);
- if (switcher->priv->show)
- gtk_widget_show (button_widget);
- g_signal_connect (button_widget, "toggled",
- G_CALLBACK (button_toggled_callback),
- switcher);
- hbox = gtk_hbox_new (FALSE, 3);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 0);
- gtk_container_add (GTK_CONTAINER (button_widget), hbox);
- gtk_widget_show (hbox);
-
- if (stock_id) {
- icon_widget = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
- } else if (pixbuf_icon) {
- icon_widget = gtk_image_new_from_pixbuf (pixbuf_icon);
- } else {
- icon_widget = gtk_image_new_from_stock (GTK_STOCK_NEW, GTK_ICON_SIZE_MENU);
- }
-
- gtk_widget_show (icon_widget);
-
- if (!label) {
- gchar *text = g_strdup_printf ("Item %d", switcher_id);
- label_widget = gtk_label_new (text);
- g_free (text);
- } else {
- label_widget = gtk_label_new (label);
- }
- gtk_misc_set_alignment (GTK_MISC (label_widget), 0.0, 0.5);
- gtk_widget_show (label_widget);
-
-
- gtk_widget_set_tooltip_text (button_widget,
- tooltips);
-
- switch (INTERNAL_MODE (switcher)) {
- case GDL_SWITCHER_STYLE_TEXT:
- gtk_box_pack_start (GTK_BOX (hbox), label_widget, TRUE, TRUE, 0);
- break;
- case GDL_SWITCHER_STYLE_ICON:
- gtk_box_pack_start (GTK_BOX (hbox), icon_widget, TRUE, TRUE, 0);
- break;
- case GDL_SWITCHER_STYLE_BOTH:
- default:
- gtk_box_pack_start (GTK_BOX (hbox), icon_widget, FALSE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), label_widget, TRUE, TRUE, 0);
- break;
- }
- arrow = gtk_arrow_new (GTK_ARROW_UP, GTK_SHADOW_NONE);
- gtk_widget_show (arrow);
- gtk_box_pack_start (GTK_BOX (hbox), arrow, FALSE, FALSE, 0);
-
- switcher->priv->buttons =
- g_slist_append (switcher->priv->buttons,
- button_new (button_widget, label_widget,
- icon_widget,
- arrow, hbox, switcher_id, page));
-
- gtk_widget_set_parent (button_widget, GTK_WIDGET (switcher));
- gtk_widget_queue_resize (GTK_WIDGET (switcher));
-}
-
-#if 0
-static void
-gdl_switcher_remove_button (GdlSwitcher *switcher, gint switcher_id)
-{
- GSList *p;
-
- for (p = switcher->priv->buttons; p != NULL; p = p->next) {
- Button *button = p->data;
-
- if (button->id == switcher_id)
- {
- gtk_container_remove (GTK_CONTAINER (switcher),
- button->button_widget);
- break;
- }
- }
- gtk_widget_queue_resize (GTK_WIDGET (switcher));
-}
-#endif
-
-static void
-gdl_switcher_select_button (GdlSwitcher *switcher, gint switcher_id)
-{
- update_buttons (switcher, switcher_id);
-
- /* Select the notebook page associated with this button */
- gdl_switcher_select_page (switcher, switcher_id);
-}
-
-
-gint
-gdl_switcher_insert_page (GdlSwitcher *switcher, GtkWidget *page,
- GtkWidget *tab_widget, const gchar *label,
- const gchar *tooltips, const gchar *stock_id,
- GdkPixbuf *pixbuf_icon, gint position)
-{
- gint ret_position;
- gint switcher_id;
- g_signal_handlers_block_by_func (switcher,
- gdl_switcher_page_added_cb,
- switcher);
-
- if (!tab_widget) {
- tab_widget = gtk_label_new (label);
- gtk_widget_show (tab_widget);
- }
- switcher_id = gdl_switcher_get_page_id (page);
- gdl_switcher_add_button (switcher, label, tooltips, stock_id, pixbuf_icon, switcher_id, page);
-
- ret_position = gtk_notebook_insert_page (GTK_NOTEBOOK (switcher), page,
- tab_widget, position);
- g_signal_handlers_unblock_by_func (switcher,
- gdl_switcher_page_added_cb,
- switcher);
-
- return ret_position;
-}
-
-static void
-set_switcher_style_toolbar (GdlSwitcher *switcher,
- GdlSwitcherStyle switcher_style)
-{
- GSList *p;
-
- if (switcher_style == GDL_SWITCHER_STYLE_NONE
- || switcher_style == GDL_SWITCHER_STYLE_TABS)
- return;
-
- if (switcher_style == GDL_SWITCHER_STYLE_TOOLBAR)
- switcher_style = GDL_SWITCHER_STYLE_BOTH;
-
- if (switcher_style == INTERNAL_MODE (switcher))
- return;
-
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), FALSE);
-
- for (p = switcher->priv->buttons; p != NULL; p = p->next) {
- Button *button = p->data;
-
- gtk_container_remove (GTK_CONTAINER (button->hbox), button->arrow);
-
- if (gtk_widget_get_parent (button->icon))
- gtk_container_remove (GTK_CONTAINER (button->hbox), button->icon);
- if (gtk_widget_get_parent (button->label))
- gtk_container_remove (GTK_CONTAINER (button->hbox), button->label);
-
- switch (switcher_style) {
- case GDL_SWITCHER_STYLE_TEXT:
- gtk_box_pack_start (GTK_BOX (button->hbox), button->label,
- TRUE, TRUE, 0);
- gtk_widget_show (button->label);
- break;
-
- case GDL_SWITCHER_STYLE_ICON:
- gtk_box_pack_start (GTK_BOX (button->hbox), button->icon,
- TRUE, TRUE, 0);
- gtk_widget_show (button->icon);
- break;
-
- case GDL_SWITCHER_STYLE_BOTH:
- gtk_box_pack_start (GTK_BOX (button->hbox), button->icon,
- FALSE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (button->hbox), button->label,
- TRUE, TRUE, 0);
- gtk_widget_show (button->icon);
- gtk_widget_show (button->label);
- break;
-
- default:
- break;
- }
-
- gtk_box_pack_start (GTK_BOX (button->hbox), button->arrow,
- FALSE, FALSE, 0);
- }
-
- gdl_switcher_set_show_buttons (switcher, TRUE);
-}
-
-static void
-gdl_switcher_set_style (GdlSwitcher *switcher, GdlSwitcherStyle switcher_style)
-{
- if (switcher->priv->switcher_style == switcher_style)
- return;
-
- if (switcher_style == GDL_SWITCHER_STYLE_NONE) {
- gdl_switcher_set_show_buttons (switcher, FALSE);
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), FALSE);
- }
- else if (switcher_style == GDL_SWITCHER_STYLE_TABS) {
- gdl_switcher_set_show_buttons (switcher, FALSE);
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), TRUE);
- }
- else
- set_switcher_style_toolbar (switcher, switcher_style);
-
- gtk_widget_queue_resize (GTK_WIDGET (switcher));
- switcher->priv->switcher_style = switcher_style;
-}
-
-static void
-gdl_switcher_set_show_buttons (GdlSwitcher *switcher, gboolean show)
-{
- GSList *p;
-
- if (switcher->priv->show == show)
- return;
-
- for (p = switcher->priv->buttons; p != NULL; p = p->next) {
- Button *button = p->data;
-
- if (show)
- gtk_widget_show (button->button_widget);
- else
- gtk_widget_hide (button->button_widget);
- }
-
- switcher->priv->show = show;
-
- gtk_widget_queue_resize (GTK_WIDGET (switcher));
-}
-
-static GdlSwitcherStyle
-gdl_switcher_get_style (GdlSwitcher *switcher)
-{
- if (!switcher->priv->show)
- return GDL_SWITCHER_STYLE_TABS;
- return switcher->priv->switcher_style;
-}
diff --git a/src/libgdl/gdl-switcher.h b/src/libgdl/gdl-switcher.h
deleted file mode 100644
index 0caf3a0aa..000000000
--- a/src/libgdl/gdl-switcher.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 8 -*- */
-/* gdl-switcher.h
- *
- * Copyright (C) 2003 Ettore Perazzoli
- * 2007 Naba Kumar
- *
-* This library is free software; you can redistribute it and/or
- * 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.
- *
- *
- * Authors: Ettore Perazzoli <ettore@ximian.com>
- * Naba Kumar <naba@gnome.org>
- */
-
-#ifndef _GDL_SWITCHER_H_
-#define _GDL_SWITCHER_H_
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-#define GDL_TYPE_SWITCHER (gdl_switcher_get_type ())
-#define GDL_SWITCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_SWITCHER, GdlSwitcher))
-#define GDL_SWITCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_SWITCHER, GdlSwitcherClass))
-#define GDL_IS_SWITCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_SWITCHER))
-#define GDL_IS_SWITCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GDL_TYPE_SWITCHER))
-
-typedef struct _GdlSwitcher GdlSwitcher;
-typedef struct _GdlSwitcherPrivate GdlSwitcherPrivate;
-typedef struct _GdlSwitcherClass GdlSwitcherClass;
-
-struct _GdlSwitcher {
- GtkNotebook parent;
-
- GdlSwitcherPrivate *priv;
-};
-
-struct _GdlSwitcherClass {
- GtkNotebookClass parent_class;
-};
-
-GType gdl_switcher_get_type (void);
-GtkWidget *gdl_switcher_new (void);
-
-gint gdl_switcher_insert_page (GdlSwitcher *switcher,
- GtkWidget *page,
- GtkWidget *tab_widget,
- const gchar *label,
- const gchar *tooltips,
- const gchar *stock_id,
- GdkPixbuf *pixbuf_icon,
- gint position);
-G_END_DECLS
-
-#endif /* _GDL_SWITCHER_H_ */
diff --git a/src/libgdl/gdl-win32.c b/src/libgdl/gdl-win32.c
deleted file mode 100644
index f23036ed6..000000000
--- a/src/libgdl/gdl-win32.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Windows stuff
- *
- * Author:
- * Albin Sunnanbo
- * Based on code by Lauris Kaplinski <lauris@kaplinski.com> (/src/extension/internal/win32.cpp)
- *
- * This code is in public domain
- */
-#ifdef WIN32
-
-#include "gdl-win32.h"
-#include <windows.h>
-
-/* Platform detection */
-gboolean
-is_os_vista()
-{
- static gboolean initialized = FALSE;
- static gboolean is_vista = FALSE;
- static OSVERSIONINFOA osver;
-
- if ( !initialized )
- {
- BOOL result;
-
- initialized = TRUE;
-
- memset (&osver, 0, sizeof(OSVERSIONINFOA));
- osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
- result = GetVersionExA (&osver);
- if (result)
- {
- if (osver.dwMajorVersion == WIN32_MAJORVERSION_VISTA)
- is_vista = TRUE;
- }
- }
-
- return is_vista;
-}
-
-#endif
diff --git a/src/libgdl/gdl-win32.h b/src/libgdl/gdl-win32.h
deleted file mode 100644
index 90c0cbafa..000000000
--- a/src/libgdl/gdl-win32.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Windows stuff
- *
- * Author:
- * Albin Sunnanbo
- *
- * This code is in public domain
- */
-#ifndef __INKSCAPE_GDL_WIN32_H__
-#define __INKSCAPE_GDL_WIN32_H__
-#ifdef WIN32
-
-#include <gdk/gdk.h>
-
-#define WIN32_MAJORVERSION_VISTA 0x0006
-
-/* Platform detection */
-gboolean is_os_vista();
-
-#endif // ifdef WIN32
-#endif /* __INKSCAPE_GDL_WIN32_H__ */
diff --git a/src/libgdl/gdl.h b/src/libgdl/gdl.h
deleted file mode 100644
index 235c5e3eb..000000000
--- a/src/libgdl/gdl.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * This file is part of the GNOME Devtools Libraries.
- *
- * Copyright (C) 1999-2000 Dave Camp <dave@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * 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
- */
-
-#ifndef __GDL_H__
-#define __GDL_H__
-
-#include "libgdl/gdl-dock-object.h"
-#include "libgdl/gdl-dock-master.h"
-#include "libgdl/gdl-dock.h"
-#include "libgdl/gdl-dock-item.h"
-#include "libgdl/gdl-dock-item-grip.h"
-#include "libgdl/gdl-dock-bar.h"
-
-#endif
diff --git a/src/libgdl/libgdlmarshal.c b/src/libgdl/libgdlmarshal.c
deleted file mode 100644
index a2a9fe220..000000000
--- a/src/libgdl/libgdlmarshal.c
+++ /dev/null
@@ -1,173 +0,0 @@
-#include "libgdlmarshal.h"
-
-#include <glib-object.h>
-
-
-#ifdef G_ENABLE_DEBUG
-#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
-#define g_marshal_value_peek_char(v) g_value_get_char (v)
-#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
-#define g_marshal_value_peek_int(v) g_value_get_int (v)
-#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
-#define g_marshal_value_peek_long(v) g_value_get_long (v)
-#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
-#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
-#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
-#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
-#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
-#define g_marshal_value_peek_float(v) g_value_get_float (v)
-#define g_marshal_value_peek_double(v) g_value_get_double (v)
-#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
-#define g_marshal_value_peek_param(v) g_value_get_param (v)
-#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
-#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
-#define g_marshal_value_peek_object(v) g_value_get_object (v)
-#define g_marshal_value_peek_variant(v) g_value_get_variant (v)
-#else /* !G_ENABLE_DEBUG */
-/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
- * Do not access GValues directly in your code. Instead, use the
- * g_value_get_*() functions
- */
-#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
-#define g_marshal_value_peek_char(v) (v)->data[0].v_int
-#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
-#define g_marshal_value_peek_int(v) (v)->data[0].v_int
-#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
-#define g_marshal_value_peek_long(v) (v)->data[0].v_long
-#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
-#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
-#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
-#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
-#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
-#define g_marshal_value_peek_float(v) (v)->data[0].v_float
-#define g_marshal_value_peek_double(v) (v)->data[0].v_double
-#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
-#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
-#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
-#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
-#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
-#define g_marshal_value_peek_variant(v) (v)->data[0].v_pointer
-#endif /* !G_ENABLE_DEBUG */
-
-
-/* VOID:VOID (./libgdlmarshal.list:1) */
-
-/* VOID:ENUM (./libgdlmarshal.list:2) */
-
-/* VOID:INT,INT (./libgdlmarshal.list:3) */
-void
-gdl_marshal_VOID__INT_INT (GClosure *closure,
- GValue *return_value G_GNUC_UNUSED,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint G_GNUC_UNUSED,
- gpointer marshal_data)
-{
- typedef void (*GMarshalFunc_VOID__INT_INT) (gpointer data1,
- gint arg_1,
- gint arg_2,
- gpointer data2);
- register GMarshalFunc_VOID__INT_INT callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
-
- g_return_if_fail (n_param_values == 3);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
- callback = (GMarshalFunc_VOID__INT_INT) (marshal_data ? marshal_data : cc->callback);
-
- callback (data1,
- g_marshal_value_peek_int (param_values + 1),
- g_marshal_value_peek_int (param_values + 2),
- data2);
-}
-
-/* VOID:UINT,UINT (./libgdlmarshal.list:4) */
-void
-gdl_marshal_VOID__UINT_UINT (GClosure *closure,
- GValue *return_value G_GNUC_UNUSED,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint G_GNUC_UNUSED,
- gpointer marshal_data)
-{
- typedef void (*GMarshalFunc_VOID__UINT_UINT) (gpointer data1,
- guint arg_1,
- guint arg_2,
- gpointer data2);
- register GMarshalFunc_VOID__UINT_UINT callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
-
- g_return_if_fail (n_param_values == 3);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
- callback = (GMarshalFunc_VOID__UINT_UINT) (marshal_data ? marshal_data : cc->callback);
-
- callback (data1,
- g_marshal_value_peek_uint (param_values + 1),
- g_marshal_value_peek_uint (param_values + 2),
- data2);
-}
-
-/* VOID:BOOLEAN (./libgdlmarshal.list:5) */
-
-/* VOID:OBJECT,ENUM,BOXED (./libgdlmarshal.list:6) */
-void
-gdl_marshal_VOID__OBJECT_ENUM_BOXED (GClosure *closure,
- GValue *return_value G_GNUC_UNUSED,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint G_GNUC_UNUSED,
- gpointer marshal_data)
-{
- typedef void (*GMarshalFunc_VOID__OBJECT_ENUM_BOXED) (gpointer data1,
- gpointer arg_1,
- gint arg_2,
- gpointer arg_3,
- gpointer data2);
- register GMarshalFunc_VOID__OBJECT_ENUM_BOXED callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
-
- g_return_if_fail (n_param_values == 4);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
- callback = (GMarshalFunc_VOID__OBJECT_ENUM_BOXED) (marshal_data ? marshal_data : cc->callback);
-
- callback (data1,
- g_marshal_value_peek_object (param_values + 1),
- g_marshal_value_peek_enum (param_values + 2),
- g_marshal_value_peek_boxed (param_values + 3),
- data2);
-}
-
-/* VOID:BOXED (./libgdlmarshal.list:7) */
-
diff --git a/src/libgdl/libgdlmarshal.h b/src/libgdl/libgdlmarshal.h
deleted file mode 100644
index 2d6bc800f..000000000
--- a/src/libgdl/libgdlmarshal.h
+++ /dev/null
@@ -1,48 +0,0 @@
-
-#ifndef __gdl_marshal_MARSHAL_H__
-#define __gdl_marshal_MARSHAL_H__
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-/* VOID:VOID (./libgdlmarshal.list:1) */
-#define gdl_marshal_VOID__VOID g_cclosure_marshal_VOID__VOID
-
-/* VOID:ENUM (./libgdlmarshal.list:2) */
-#define gdl_marshal_VOID__ENUM g_cclosure_marshal_VOID__ENUM
-
-/* VOID:INT,INT (./libgdlmarshal.list:3) */
-extern void gdl_marshal_VOID__INT_INT (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-
-/* VOID:UINT,UINT (./libgdlmarshal.list:4) */
-extern void gdl_marshal_VOID__UINT_UINT (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-
-/* VOID:BOOLEAN (./libgdlmarshal.list:5) */
-#define gdl_marshal_VOID__BOOLEAN g_cclosure_marshal_VOID__BOOLEAN
-
-/* VOID:OBJECT,ENUM,BOXED (./libgdlmarshal.list:6) */
-extern void gdl_marshal_VOID__OBJECT_ENUM_BOXED (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-
-/* VOID:BOXED (./libgdlmarshal.list:7) */
-#define gdl_marshal_VOID__BOXED g_cclosure_marshal_VOID__BOXED
-
-G_END_DECLS
-
-#endif /* __gdl_marshal_MARSHAL_H__ */
-
diff --git a/src/libgdl/libgdlmarshal.list b/src/libgdl/libgdlmarshal.list
deleted file mode 100644
index 750989abc..000000000
--- a/src/libgdl/libgdlmarshal.list
+++ /dev/null
@@ -1,7 +0,0 @@
-VOID:VOID
-VOID:ENUM
-VOID:INT,INT
-VOID:UINT,UINT
-VOID:BOOLEAN
-VOID:OBJECT,ENUM,BOXED
-VOID:BOXED
diff --git a/src/libgdl/libgdltypebuiltins.c b/src/libgdl/libgdltypebuiltins.c
deleted file mode 100644
index b347fe6f5..000000000
--- a/src/libgdl/libgdltypebuiltins.c
+++ /dev/null
@@ -1,162 +0,0 @@
-
-
-
-#include <glib-object.h>
-#include "libgdltypebuiltins.h"
-
-
-/* enumerations from "gdl-dock-object.h" */
-static const GFlagsValue _gdl_dock_param_flags_values[] = {
- { GDL_DOCK_PARAM_EXPORT, "GDL_DOCK_PARAM_EXPORT", "export" },
- { GDL_DOCK_PARAM_AFTER, "GDL_DOCK_PARAM_AFTER", "after" },
- { 0, NULL, NULL }
-};
-
-GType
-gdl_dock_param_flags_get_type (void)
-{
- static GType type = 0;
-
- if (!type)
- type = g_flags_register_static ("GdlDockParamFlags", _gdl_dock_param_flags_values);
-
- return type;
-}
-
-static const GFlagsValue _gdl_dock_object_flags_values[] = {
- { GDL_DOCK_AUTOMATIC, "GDL_DOCK_AUTOMATIC", "automatic" },
- { GDL_DOCK_ATTACHED, "GDL_DOCK_ATTACHED", "attached" },
- { GDL_DOCK_IN_REFLOW, "GDL_DOCK_IN_REFLOW", "in-reflow" },
- { GDL_DOCK_IN_DETACH, "GDL_DOCK_IN_DETACH", "in-detach" },
- { 0, NULL, NULL }
-};
-
-GType
-gdl_dock_object_flags_get_type (void)
-{
- static GType type = 0;
-
- if (!type)
- type = g_flags_register_static ("GdlDockObjectFlags", _gdl_dock_object_flags_values);
-
- return type;
-}
-
-static const GEnumValue _gdl_dock_placement_values[] = {
- { GDL_DOCK_NONE, "GDL_DOCK_NONE", "none" },
- { GDL_DOCK_TOP, "GDL_DOCK_TOP", "top" },
- { GDL_DOCK_BOTTOM, "GDL_DOCK_BOTTOM", "bottom" },
- { GDL_DOCK_RIGHT, "GDL_DOCK_RIGHT", "right" },
- { GDL_DOCK_LEFT, "GDL_DOCK_LEFT", "left" },
- { GDL_DOCK_CENTER, "GDL_DOCK_CENTER", "center" },
- { GDL_DOCK_FLOATING, "GDL_DOCK_FLOATING", "floating" },
- { 0, NULL, NULL }
-};
-
-GType
-gdl_dock_placement_get_type (void)
-{
- static GType type = 0;
-
- if (!type)
- type = g_enum_register_static ("GdlDockPlacement", _gdl_dock_placement_values);
-
- return type;
-}
-
-
-/* enumerations from "gdl-dock-master.h" */
-static const GEnumValue _gdl_switcher_style_values[] = {
- { GDL_SWITCHER_STYLE_TEXT, "GDL_SWITCHER_STYLE_TEXT", "text" },
- { GDL_SWITCHER_STYLE_ICON, "GDL_SWITCHER_STYLE_ICON", "icon" },
- { GDL_SWITCHER_STYLE_BOTH, "GDL_SWITCHER_STYLE_BOTH", "both" },
- { GDL_SWITCHER_STYLE_TOOLBAR, "GDL_SWITCHER_STYLE_TOOLBAR", "toolbar" },
- { GDL_SWITCHER_STYLE_TABS, "GDL_SWITCHER_STYLE_TABS", "tabs" },
- { GDL_SWITCHER_STYLE_NONE, "GDL_SWITCHER_STYLE_NONE", "none" },
- { 0, NULL, NULL }
-};
-
-GType
-gdl_switcher_style_get_type (void)
-{
- static GType type = 0;
-
- if (!type)
- type = g_enum_register_static ("GdlSwitcherStyle", _gdl_switcher_style_values);
-
- return type;
-}
-
-
-/* enumerations from "gdl-dock-item.h" */
-static const GFlagsValue _gdl_dock_item_behavior_values[] = {
- { GDL_DOCK_ITEM_BEH_NORMAL, "GDL_DOCK_ITEM_BEH_NORMAL", "normal" },
- { GDL_DOCK_ITEM_BEH_NEVER_FLOATING, "GDL_DOCK_ITEM_BEH_NEVER_FLOATING", "never-floating" },
- { GDL_DOCK_ITEM_BEH_NEVER_VERTICAL, "GDL_DOCK_ITEM_BEH_NEVER_VERTICAL", "never-vertical" },
- { GDL_DOCK_ITEM_BEH_NEVER_HORIZONTAL, "GDL_DOCK_ITEM_BEH_NEVER_HORIZONTAL", "never-horizontal" },
- { GDL_DOCK_ITEM_BEH_LOCKED, "GDL_DOCK_ITEM_BEH_LOCKED", "locked" },
- { GDL_DOCK_ITEM_BEH_CANT_DOCK_TOP, "GDL_DOCK_ITEM_BEH_CANT_DOCK_TOP", "cant-dock-top" },
- { GDL_DOCK_ITEM_BEH_CANT_DOCK_BOTTOM, "GDL_DOCK_ITEM_BEH_CANT_DOCK_BOTTOM", "cant-dock-bottom" },
- { GDL_DOCK_ITEM_BEH_CANT_DOCK_LEFT, "GDL_DOCK_ITEM_BEH_CANT_DOCK_LEFT", "cant-dock-left" },
- { GDL_DOCK_ITEM_BEH_CANT_DOCK_RIGHT, "GDL_DOCK_ITEM_BEH_CANT_DOCK_RIGHT", "cant-dock-right" },
- { GDL_DOCK_ITEM_BEH_CANT_DOCK_CENTER, "GDL_DOCK_ITEM_BEH_CANT_DOCK_CENTER", "cant-dock-center" },
- { GDL_DOCK_ITEM_BEH_CANT_CLOSE, "GDL_DOCK_ITEM_BEH_CANT_CLOSE", "cant-close" },
- { GDL_DOCK_ITEM_BEH_CANT_ICONIFY, "GDL_DOCK_ITEM_BEH_CANT_ICONIFY", "cant-iconify" },
- { GDL_DOCK_ITEM_BEH_NO_GRIP, "GDL_DOCK_ITEM_BEH_NO_GRIP", "no-grip" },
- { 0, NULL, NULL }
-};
-
-GType
-gdl_dock_item_behavior_get_type (void)
-{
- static GType type = 0;
-
- if (!type)
- type = g_flags_register_static ("GdlDockItemBehavior", _gdl_dock_item_behavior_values);
-
- return type;
-}
-
-static const GFlagsValue _gdl_dock_item_flags_values[] = {
- { GDL_DOCK_IN_DRAG, "GDL_DOCK_IN_DRAG", "in-drag" },
- { GDL_DOCK_IN_PREDRAG, "GDL_DOCK_IN_PREDRAG", "in-predrag" },
- { GDL_DOCK_ICONIFIED, "GDL_DOCK_ICONIFIED", "iconified" },
- { GDL_DOCK_USER_ACTION, "GDL_DOCK_USER_ACTION", "user-action" },
- { 0, NULL, NULL }
-};
-
-GType
-gdl_dock_item_flags_get_type (void)
-{
- static GType type = 0;
-
- if (!type)
- type = g_flags_register_static ("GdlDockItemFlags", _gdl_dock_item_flags_values);
-
- return type;
-}
-
-
-/* enumerations from "gdl-dock-bar.h" */
-static const GEnumValue _gdl_dock_bar_style_values[] = {
- { GDL_DOCK_BAR_ICONS, "GDL_DOCK_BAR_ICONS", "icons" },
- { GDL_DOCK_BAR_TEXT, "GDL_DOCK_BAR_TEXT", "text" },
- { GDL_DOCK_BAR_BOTH, "GDL_DOCK_BAR_BOTH", "both" },
- { GDL_DOCK_BAR_AUTO, "GDL_DOCK_BAR_AUTO", "auto" },
- { 0, NULL, NULL }
-};
-
-GType
-gdl_dock_bar_style_get_type (void)
-{
- static GType type = 0;
-
- if (!type)
- type = g_enum_register_static ("GdlDockBarStyle", _gdl_dock_bar_style_values);
-
- return type;
-}
-
-
-
-
diff --git a/src/libgdl/libgdltypebuiltins.h b/src/libgdl/libgdltypebuiltins.h
deleted file mode 100644
index 19eac4989..000000000
--- a/src/libgdl/libgdltypebuiltins.h
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-#ifndef __LIBGDLTYPEBUILTINS_H__
-#define __LIBGDLTYPEBUILTINS_H__ 1
-
-#include "libgdl/gdl.h"
-
-G_BEGIN_DECLS
-
-
-/* --- gdl-dock-object.h --- */
-#define GDL_TYPE_DOCK_PARAM_FLAGS gdl_dock_param_flags_get_type()
-GType gdl_dock_param_flags_get_type (void);
-#define GDL_TYPE_DOCK_OBJECT_FLAGS gdl_dock_object_flags_get_type()
-GType gdl_dock_object_flags_get_type (void);
-#define GDL_TYPE_DOCK_PLACEMENT gdl_dock_placement_get_type()
-GType gdl_dock_placement_get_type (void);
-
-/* --- gdl-dock-master.h --- */
-#define GDL_TYPE_SWITCHER_STYLE gdl_switcher_style_get_type()
-GType gdl_switcher_style_get_type (void);
-
-/* --- gdl-dock-item.h --- */
-#define GDL_TYPE_DOCK_ITEM_BEHAVIOR gdl_dock_item_behavior_get_type()
-GType gdl_dock_item_behavior_get_type (void);
-#define GDL_TYPE_DOCK_ITEM_FLAGS gdl_dock_item_flags_get_type()
-GType gdl_dock_item_flags_get_type (void);
-
-/* --- gdl-dock-bar.h --- */
-#define GDL_TYPE_DOCK_BAR_STYLE gdl_dock_bar_style_get_type()
-GType gdl_dock_bar_style_get_type (void);
-G_END_DECLS
-
-#endif /* __LIBGDLTYPEBUILTINS_H__ */
-
-
-
diff --git a/src/libgdl/makefile.in b/src/libgdl/makefile.in
deleted file mode 100644
index 9dc8cb2ca..000000000
--- a/src/libgdl/makefile.in
+++ /dev/null
@@ -1,17 +0,0 @@
-# Convenience stub makefile to call the real Makefile.
-
-@SET_MAKE@
-
-OBJEXT = @OBJEXT@
-
-# Explicit so that it's the default rule.
-all:
- cd .. && $(MAKE) libgdl/all
-
-clean %.a %.$(OBJEXT):
- cd .. && $(MAKE) libgdl/$@
-
-.PHONY: all clean
-
-.SUFFIXES:
-.SUFFIXES: .a .$(OBJEXT)
diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt
index 225afe317..ba71b39f4 100644
--- a/src/widgets/CMakeLists.txt
+++ b/src/widgets/CMakeLists.txt
@@ -33,6 +33,7 @@ set(widgets_SRC
gradient-toolbar.cpp
gradient-vector.cpp
icon.cpp
+ image-menu-item.c
ink-action.cpp
ink-comboboxentry-action.cpp
paint-selector.cpp
@@ -88,6 +89,7 @@ set(widgets_SRC
gradient-toolbar.h
gradient-vector.h
icon.h
+ image-menu-item.h
ink-action.h
ink-comboboxentry-action.h
paint-selector.h
@@ -108,11 +110,6 @@ set(widgets_SRC
widget-sizes.h
)
-if(${WITH_GTK3_EXPERIMENTAL})
- set(image_menu_item_SRC image-menu-item.h image-menu-item.c)
- add_inkscape_source("${image_menu_item_SRC}")
-endif()
-
# add_inkscape_lib(widgets_LIB "${widgets_SRC}")
add_inkscape_source("${widgets_SRC}")
diff --git a/src/widgets/Makefile_insert b/src/widgets/Makefile_insert
index c9f04de14..8f10e1d56 100644
--- a/src/widgets/Makefile_insert
+++ b/src/widgets/Makefile_insert
@@ -1,11 +1,5 @@
## Makefile.am fragment sourced by src/Makefile.am.
-if WITH_GTKMM_3_0
-ink_common_sources += \
- widgets/image-menu-item.c \
- widgets/image-menu-item.h
-endif
-
ink_common_sources += \
widgets/arc-toolbar.cpp \
widgets/arc-toolbar.h \
@@ -50,6 +44,8 @@ ink_common_sources += \
widgets/gradient-vector.h \
widgets/icon.cpp \
widgets/icon.h \
+ widgets/image-menu-item.c \
+ widgets/image-menu-item.h \
widgets/ink-action.cpp \
widgets/ink-action.h \
widgets/ink-comboboxentry-action.cpp \