d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b *
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * This file is part of the GNOME Devtools Libraries.
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b *
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * Copyright (C) 2003 Jeroen Zwartepoorte <jeroen@xs4all.nl>
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b *
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * This library is free software; you can redistribute it and/or
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * modify it under the terms of the GNU Lesser General Public
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * License as published by the Free Software Foundation; either
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * version 2.1 of the License, or (at your option) any later version.
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b *
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * This library is distributed in the hope that it will be useful,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * but WITHOUT ANY WARRANTY; without even the implied warranty of
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * Lesser General Public License for more details.
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b *
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * You should have received a copy of the GNU Lesser General Public
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * License along with this library; if not, write to the Free Software
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#ifdef HAVE_CONFIG_H
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#include <config.h>
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#endif
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#include "gdl-i18n.h"
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#include <stdlib.h>
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#include <string.h>
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#include "gdl-dock.h"
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#include "gdl-dock-master.h"
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#include "gdl-dock-bar.h"
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#include "libgdltypebuiltins.h"
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_benum {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b PROP_0,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b PROP_MASTER,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b PROP_DOCKBAR_STYLE
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b};
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b/* ----- Private prototypes ----- */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void gdl_dock_bar_class_init (GdlDockBarClass *klass);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void gdl_dock_bar_get_property (GObject *object,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b guint prop_id,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GValue *value,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GParamSpec *pspec);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void gdl_dock_bar_set_property (GObject *object,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b guint prop_id,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b const GValue *value,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GParamSpec *pspec);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void gdl_dock_bar_destroy (GtkObject *object);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void gdl_dock_bar_attach (GdlDockBar *dockbar,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlDockMaster *master);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void gdl_dock_bar_remove_item (GdlDockBar *dockbar,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlDockItem *item);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b/* ----- Class variables and definitions ----- */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstruct _GdlDockBarPrivate {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlDockMaster *master;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GSList *items;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkOrientation orientation;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlDockBarStyle dockbar_style;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b};
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b/* ----- Private functions ----- */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex ValavanisG_DEFINE_TYPE (GdlDockBar, gdl_dock_bar, GTK_TYPE_BOX)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void gdl_dock_bar_size_request (GtkWidget *widget,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkRequisition *requisition );
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void gdl_dock_bar_size_allocate (GtkWidget *widget,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkAllocation *allocation );
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void gdl_dock_bar_size_vrequest (GtkWidget *widget,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkRequisition *requisition );
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void gdl_dock_bar_size_vallocate (GtkWidget *widget,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkAllocation *allocation );
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void gdl_dock_bar_size_hrequest (GtkWidget *widget,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkRequisition *requisition );
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void gdl_dock_bar_size_hallocate (GtkWidget *widget,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkAllocation *allocation );
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void update_dock_items (GdlDockBar *dockbar, gboolean full_update);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bvoid
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_dock_bar_class_init (GdlDockBarClass *klass)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GObjectClass *g_object_class;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkObjectClass *gtk_object_class;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkWidgetClass *widget_class;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_class = G_OBJECT_CLASS (klass);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_object_class = GTK_OBJECT_CLASS (klass);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_class->get_property = gdl_dock_bar_get_property;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_class->set_property = gdl_dock_bar_set_property;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_object_class->destroy = gdl_dock_bar_destroy;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_class_install_property (
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_class, PROP_MASTER,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_param_spec_object ("master", _("Master"),
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b _("GdlDockMaster object which the dockbar widget "
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b "is attached to"),
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GDL_TYPE_DOCK_MASTER,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b G_PARAM_READWRITE));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_class_install_property (
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_class, PROP_DOCKBAR_STYLE,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_param_spec_enum ("dockbar-style", _("Dockbar style"),
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b _("Dockbar style to show items on it"),
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GDL_TYPE_DOCK_BAR_STYLE,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GDL_DOCK_BAR_BOTH,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b widget_class = GTK_WIDGET_CLASS (klass);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b widget_class->size_request = gdl_dock_bar_size_request;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b widget_class->size_allocate = gdl_dock_bar_size_allocate;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanisgdl_dock_bar_init (GdlDockBar *dockbar)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b dockbar->_priv = g_new0 (GdlDockBarPrivate, 1);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b dockbar->_priv->master = NULL;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b dockbar->_priv->items = NULL;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b dockbar->_priv->orientation = GTK_ORIENTATION_VERTICAL;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b dockbar->_priv->dockbar_style = GDL_DOCK_BAR_BOTH;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_dock_bar_get_property (GObject *object,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b guint prop_id,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GValue *value,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GParamSpec *pspec)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlDockBar *dockbar = GDL_DOCK_BAR (object);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switch (prop_id) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b case PROP_MASTER:
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_value_set_object (value, dockbar->_priv->master);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b break;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b case PROP_DOCKBAR_STYLE:
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_value_set_enum (value, dockbar->_priv->dockbar_style);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b break;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b default:
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b };
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_dock_bar_set_property (GObject *object,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b guint prop_id,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b const GValue *value,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GParamSpec *pspec)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlDockBar *dockbar = GDL_DOCK_BAR (object);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switch (prop_id) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b case PROP_MASTER:
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gdl_dock_bar_attach (dockbar, g_value_get_object (value));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b break;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b case PROP_DOCKBAR_STYLE:
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b dockbar->_priv->dockbar_style = g_value_get_enum (value);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b update_dock_items (dockbar, TRUE);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b break;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b default:
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b };
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bon_dock_item_foreach_disconnect (GdlDockItem *item, GdlDockBar *dock_bar)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_signal_handlers_disconnect_by_func (item, gdl_dock_bar_remove_item,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b dock_bar);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_dock_bar_destroy (GtkObject *object)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlDockBar *dockbar = GDL_DOCK_BAR (object);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (dockbar->_priv) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlDockBarPrivate *priv = dockbar->_priv;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (priv->items) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_slist_foreach (priv->items,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b (GFunc) on_dock_item_foreach_disconnect,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b object);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_slist_free (priv->items);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (priv->master) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_signal_handlers_disconnect_matched (priv->master,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b G_SIGNAL_MATCH_DATA,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b 0, 0, NULL, NULL, dockbar);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_unref (priv->master);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b priv->master = NULL;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b dockbar->_priv = NULL;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_free (priv);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis GTK_OBJECT_CLASS (gdl_dock_bar_parent_class)->destroy (object);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_dock_bar_remove_item (GdlDockBar *dockbar,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlDockItem *item)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlDockBarPrivate *priv;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkWidget *button;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_return_if_fail (GDL_IS_DOCK_BAR (dockbar));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_return_if_fail (GDL_IS_DOCK_ITEM (item));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b priv = dockbar->_priv;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (g_slist_index (priv->items, item) == -1) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_warning ("Item has not been added to the dockbar");
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b priv->items = g_slist_remove (priv->items, item);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b button = g_object_get_data (G_OBJECT (item), "GdlDockBarButton");
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_assert (button != NULL);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_container_remove (GTK_CONTAINER (dockbar), button);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_set_data (G_OBJECT (item), "GdlDockBarButton", NULL);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_signal_handlers_disconnect_by_func (item,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b G_CALLBACK (gdl_dock_bar_remove_item),
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b dockbar);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_dock_bar_item_clicked (GtkWidget *button,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlDockItem *item)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlDockBar *dockbar;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlDockObject *controller;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_return_if_fail (item != NULL);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b dockbar = g_object_get_data (G_OBJECT (item), "GdlDockBar");
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_assert (dockbar != NULL);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_set_data (G_OBJECT (item), "GdlDockBar", NULL);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b controller = gdl_dock_master_get_controller (GDL_DOCK_OBJECT_GET_MASTER (item));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_ICONIFIED);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gdl_dock_item_show_item (item);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gdl_dock_bar_remove_item (dockbar, item);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_queue_resize (GTK_WIDGET (controller));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_dock_bar_add_item (GdlDockBar *dockbar,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlDockItem *item)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlDockBarPrivate *priv;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkWidget *button;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gchar *stock_id;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gchar *name;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdkPixbuf *pixbuf_icon;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkWidget *image, *box, *label;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_return_if_fail (GDL_IS_DOCK_BAR (dockbar));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_return_if_fail (GDL_IS_DOCK_ITEM (item));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b priv = dockbar->_priv;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (g_slist_index (priv->items, item) != -1) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_warning ("Item has already been added to the dockbar");
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b priv->items = g_slist_append (priv->items, item);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b /* Create a button for the item. */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b button = gtk_button_new ();
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (dockbar->_priv->orientation == GTK_ORIENTATION_HORIZONTAL)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b box = gtk_hbox_new (FALSE, 0);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b else
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b box = gtk_vbox_new (FALSE, 0);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_get (item, "stock-id", &stock_id, "pixbuf-icon", &pixbuf_icon,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b "long-name", &name, NULL);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (dockbar->_priv->dockbar_style == GDL_DOCK_BAR_TEXT ||
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b dockbar->_priv->dockbar_style == GDL_DOCK_BAR_BOTH) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b label = gtk_label_new (name);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (dockbar->_priv->orientation == GTK_ORIENTATION_VERTICAL)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_label_set_angle (GTK_LABEL (label), 90);
8f68941caf80aff5c249f79af65bd7c39523a2b1Alex Valavanis gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b /* FIXME: For now AUTO behaves same as BOTH */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (dockbar->_priv->dockbar_style == GDL_DOCK_BAR_ICONS ||
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b dockbar->_priv->dockbar_style == GDL_DOCK_BAR_BOTH ||
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b dockbar->_priv->dockbar_style == GDL_DOCK_BAR_AUTO) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (stock_id) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b image = gtk_image_new_from_stock (stock_id,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GTK_ICON_SIZE_SMALL_TOOLBAR);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_free (stock_id);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b } else if (pixbuf_icon) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b image = gtk_image_new_from_pixbuf (pixbuf_icon);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b } else {
b1df91db4199c275af4f20d8204a4a686eca123aMartin Owens image = gtk_image_new_from_stock ("gtk-new",
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GTK_ICON_SIZE_SMALL_TOOLBAR);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
8f68941caf80aff5c249f79af65bd7c39523a2b1Alex Valavanis gtk_box_pack_start (GTK_BOX (box), image, TRUE, TRUE, 0);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_container_add (GTK_CONTAINER (button), box);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_box_pack_start (GTK_BOX (dockbar), button, FALSE, FALSE, 0);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
b25122b8f1c7572aeef3abac486346c2d33a8404Alex Valavanis gtk_widget_set_tooltip_text (button, name);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_free (name);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_set_data (G_OBJECT (item), "GdlDockBar", dockbar);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_set_data (G_OBJECT (item), "GdlDockBarButton", button);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_signal_connect (G_OBJECT (button), "clicked",
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b G_CALLBACK (gdl_dock_bar_item_clicked), item);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_show_all (button);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b /* Set up destroy notify */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_signal_connect_swapped (item, "destroy",
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b G_CALLBACK (gdl_dock_bar_remove_item),
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b dockbar);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bbuild_list (GdlDockObject *object, GList **list)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b /* add only items, not toplevels */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (GDL_IS_DOCK_ITEM (object))
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b *list = g_list_prepend (*list, object);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bupdate_dock_items (GdlDockBar *dockbar, gboolean full_update)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlDockMaster *master;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GList *items, *l;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_return_if_fail (dockbar != NULL);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (!dockbar->_priv->master)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b master = dockbar->_priv->master;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b /* build items list */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b items = NULL;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gdl_dock_master_foreach (master, (GFunc) build_list, &items);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (!full_update) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b for (l = items; l != NULL; l = l->next) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlDockItem *item = GDL_DOCK_ITEM (l->data);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (g_slist_index (dockbar->_priv->items, item) != -1 &&
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b !GDL_DOCK_ITEM_ICONIFIED (item))
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gdl_dock_bar_remove_item (dockbar, item);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b else if (g_slist_index (dockbar->_priv->items, item) == -1 &&
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GDL_DOCK_ITEM_ICONIFIED (item))
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gdl_dock_bar_add_item (dockbar, item);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b } else {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b for (l = items; l != NULL; l = l->next) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlDockItem *item = GDL_DOCK_ITEM (l->data);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (g_slist_index (dockbar->_priv->items, item) != -1)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gdl_dock_bar_remove_item (dockbar, item);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (GDL_DOCK_ITEM_ICONIFIED (item))
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gdl_dock_bar_add_item (dockbar, item);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_list_free (items);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_dock_bar_layout_changed_cb (GdlDockMaster *master,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlDockBar *dockbar)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b update_dock_items (dockbar, FALSE);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_dock_bar_attach (GdlDockBar *dockbar,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlDockMaster *master)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_return_if_fail (dockbar != NULL);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_return_if_fail (master == NULL || GDL_IS_DOCK_MASTER (master));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (dockbar->_priv->master) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_signal_handlers_disconnect_matched (dockbar->_priv->master,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b G_SIGNAL_MATCH_DATA,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b 0, 0, NULL, NULL, dockbar);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_unref (dockbar->_priv->master);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b dockbar->_priv->master = master;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (dockbar->_priv->master) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_ref (dockbar->_priv->master);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_signal_connect (dockbar->_priv->master, "layout-changed",
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b G_CALLBACK (gdl_dock_bar_layout_changed_cb),
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b dockbar);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b update_dock_items (dockbar, FALSE);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void gdl_dock_bar_size_request (GtkWidget *widget,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkRequisition *requisition )
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlDockBar *dockbar;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b dockbar = GDL_DOCK_BAR (widget);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b /* default to vertical for unknown values */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switch (dockbar->_priv->orientation) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b case GTK_ORIENTATION_HORIZONTAL:
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gdl_dock_bar_size_hrequest (widget, requisition);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b break;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b case GTK_ORIENTATION_VERTICAL:
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b default:
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gdl_dock_bar_size_vrequest (widget, requisition);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b break;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void gdl_dock_bar_size_allocate (GtkWidget *widget,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkAllocation *allocation )
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlDockBar *dockbar;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b dockbar = GDL_DOCK_BAR (widget);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b /* default to vertical for unknown values */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switch (dockbar->_priv->orientation) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b case GTK_ORIENTATION_HORIZONTAL:
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gdl_dock_bar_size_hallocate (widget, allocation);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b break;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b case GTK_ORIENTATION_VERTICAL:
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b default:
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gdl_dock_bar_size_vallocate (widget, allocation);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b break;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void gdl_dock_bar_size_vrequest (GtkWidget *widget,
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis GtkRequisition *requisition )
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis GtkBox *box;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis GtkRequisition child_requisition;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis GList *child;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis gint nvis_children;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis gint height;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis guint border_width;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis box = GTK_BOX (widget);
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis requisition->width = 0;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis requisition->height = 0;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis nvis_children = 0;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis for (child = gtk_container_get_children (GTK_CONTAINER (box));
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child != NULL; child = g_list_next (child))
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis if (gtk_widget_get_visible (GTK_WIDGET (child->data)))
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis guint padding;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gboolean expand;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gboolean fill;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis GtkPackType pack_type;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gtk_widget_size_request (GTK_WIDGET (child->data), &child_requisition);
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gtk_box_query_child_packing (box,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child->data,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &expand,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &fill,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &padding,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &pack_type);
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis if (gtk_box_get_homogeneous (box))
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis height = child_requisition.height + padding * 2;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis requisition->height = MAX (requisition->height, height);
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis else
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis requisition->height += child_requisition.height + padding * 2;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis requisition->width = MAX (requisition->width, child_requisition.width);
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis nvis_children += 1;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis if (nvis_children > 0)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis if (gtk_box_get_homogeneous (box))
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis requisition->height *= nvis_children;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis requisition->height += (nvis_children - 1) * gtk_box_get_spacing (box);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis border_width = gtk_container_get_border_width (GTK_CONTAINER (box));
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis requisition->width += border_width * 2;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis requisition->height += border_width * 2;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void gdl_dock_bar_size_vallocate (GtkWidget *widget,
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis GtkAllocation *allocation)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis GtkBox *box;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis GList *child;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis GtkAllocation child_allocation;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis gint nvis_children;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis gint nexpand_children;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis gint child_height;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis gint height;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis gint extra;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis gint y;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis guint border_width;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis GtkRequisition requisition;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis box = GTK_BOX (widget);
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis gtk_widget_set_allocation (widget, allocation);
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis gtk_widget_get_requisition (widget, &requisition);
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis nvis_children = 0;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis nexpand_children = 0;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis for (child = gtk_container_get_children (GTK_CONTAINER (box));
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child != NULL; child = g_list_next (child))
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis guint padding;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gboolean expand;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gboolean fill;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis GtkPackType pack_type;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gtk_box_query_child_packing (box,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child->data,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &expand,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &fill,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &padding,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &pack_type);
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis if (gtk_widget_get_visible (GTK_WIDGET(child->data)))
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis nvis_children += 1;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis if (expand)
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis nexpand_children += 1;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis border_width = gtk_container_get_border_width (GTK_CONTAINER (box));
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis if (nvis_children > 0)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis if (gtk_box_get_homogeneous (box))
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis height = (allocation->height -
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis border_width * 2 -
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis (nvis_children - 1) * gtk_box_get_spacing (box));
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis extra = height / nvis_children;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis else if (nexpand_children > 0)
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis height = (gint) allocation->height - (gint) requisition.height;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis extra = height / nexpand_children;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis else
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis height = 0;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis extra = 0;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis y = allocation->y + border_width;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_allocation.x = allocation->x + border_width;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_allocation.width = MAX (1, (gint) allocation->width - (gint) border_width * 2);
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis for (child = gtk_container_get_children (GTK_CONTAINER (box));
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child != NULL; child = g_list_next (child))
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis guint padding;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gboolean expand;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gboolean fill;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis GtkPackType pack_type;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gtk_box_query_child_packing (box,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child->data,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &expand,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &fill,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &padding,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &pack_type);
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis if ((pack_type == GTK_PACK_START) && gtk_widget_get_visible (GTK_WIDGET (child->data)))
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis if (gtk_box_get_homogeneous (box))
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis if (nvis_children == 1)
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_height = height;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis else
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_height = extra;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis nvis_children -= 1;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis height -= extra;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis else
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis GtkRequisition child_requisition;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition);
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child_height = child_requisition.height + padding * 2;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis if (expand)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis if (nexpand_children == 1)
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_height += height;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis else
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_height += extra;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis nexpand_children -= 1;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis height -= extra;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis if (fill)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child_allocation.height = MAX (1, child_height - padding * 2);
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child_allocation.y = y + padding;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis else
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis GtkRequisition child_requisition;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition);
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_allocation.height = child_requisition.height;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_allocation.y = y + (child_height - child_allocation.height) / 2;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gtk_widget_size_allocate (GTK_WIDGET (child->data), &child_allocation);
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis y += child_height + gtk_box_get_spacing (box);
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis y = allocation->y + allocation->height - border_width;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis for (child = gtk_container_get_children (GTK_CONTAINER (box));
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child != NULL; child = g_list_next (child))
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis guint padding;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gboolean expand;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gboolean fill;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis GtkPackType pack_type;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gtk_box_query_child_packing (box,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child->data,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &expand,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &fill,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &padding,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &pack_type);
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis if ((pack_type == GTK_PACK_END) && gtk_widget_get_visible (GTK_WIDGET (child->data)))
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis GtkRequisition child_requisition;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition);
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis if (gtk_box_get_homogeneous (box))
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis if (nvis_children == 1)
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_height = height;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis else
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_height = extra;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis nvis_children -= 1;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis height -= extra;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis else
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child_height = child_requisition.height + padding * 2;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis if (expand)
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis if (nexpand_children == 1)
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_height += height;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis else
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_height += extra;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis nexpand_children -= 1;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis height -= extra;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis if (fill)
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child_allocation.height = MAX (1, child_height - padding * 2);
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child_allocation.y = y + padding - child_height;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis else
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_allocation.height = child_requisition.height;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_allocation.y = y + (child_height - child_allocation.height) / 2 - child_height;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gtk_widget_size_allocate (GTK_WIDGET (child->data), &child_allocation);
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis y -= (child_height + gtk_box_get_spacing (box));
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void gdl_dock_bar_size_hrequest (GtkWidget *widget,
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis GtkRequisition *requisition )
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis GtkBox *box;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis GList *child;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis gint nvis_children;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis gint width;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis guint border_width;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis box = GTK_BOX (widget);
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis requisition->width = 0;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis requisition->height = 0;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis nvis_children = 0;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis for (child = gtk_container_get_children (GTK_CONTAINER (box));
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child != NULL; child = g_list_next (child))
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis guint padding;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gboolean expand;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gboolean fill;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis GtkPackType pack_type;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gtk_box_query_child_packing (box,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child->data,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &expand,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &fill,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &padding,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &pack_type);
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis if (gtk_widget_get_visible (GTK_WIDGET (child->data)))
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis GtkRequisition child_requisition;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gtk_widget_size_request (GTK_WIDGET (child->data), &child_requisition);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis if (gtk_box_get_homogeneous (box))
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis width = child_requisition.width + padding * 2;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis requisition->width = MAX (requisition->width, width);
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis else
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis requisition->width += child_requisition.width + padding * 2;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis requisition->height = MAX (requisition->height, child_requisition.height);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis nvis_children += 1;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis if (nvis_children > 0)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis if (gtk_box_get_homogeneous (box))
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis requisition->width *= nvis_children;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis requisition->width += (nvis_children - 1) * gtk_box_get_spacing (box);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis border_width = gtk_container_get_border_width (GTK_CONTAINER (box));
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis requisition->width += border_width * 2;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis requisition->height += border_width * 2;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void gdl_dock_bar_size_hallocate (GtkWidget *widget,
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis GtkAllocation *allocation)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis GtkBox *box;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis GList *child;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis GtkAllocation child_allocation;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis gint nvis_children;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis gint nexpand_children;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis gint child_width;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis gint width;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis gint extra;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis gint x;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis guint border_width;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis GtkTextDirection direction;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis GtkRequisition requisition;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis box = GTK_BOX (widget);
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis gtk_widget_set_allocation (widget, allocation);
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis gtk_widget_get_requisition (widget, &requisition);
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis direction = gtk_widget_get_direction (widget);
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis nvis_children = 0;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis nexpand_children = 0;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis for (child = gtk_container_get_children (GTK_CONTAINER (box));
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child != NULL; child = g_list_next (child))
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis guint padding;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gboolean expand;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gboolean fill;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis GtkPackType pack_type;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gtk_box_query_child_packing (box,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child->data,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &expand,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &fill,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &padding,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &pack_type);
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis if (gtk_widget_get_visible (GTK_WIDGET (child->data)))
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis nvis_children += 1;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis if (expand)
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis nexpand_children += 1;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis border_width = gtk_container_get_border_width (GTK_CONTAINER (box));
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis if (nvis_children > 0)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis if (gtk_box_get_homogeneous (box))
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis width = (allocation->width -
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis border_width * 2 -
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis (nvis_children - 1) * gtk_box_get_spacing (box));
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis extra = width / nvis_children;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis else if (nexpand_children > 0)
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis width = (gint) allocation->width - (gint) requisition.width;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis extra = width / nexpand_children;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis else
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis width = 0;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis extra = 0;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis x = allocation->x + border_width;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_allocation.y = allocation->y + border_width;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_allocation.height = MAX (1, (gint) allocation->height - (gint) border_width * 2);
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis for (child = gtk_container_get_children (GTK_CONTAINER (box));
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child != NULL; child = g_list_next (child))
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis guint padding;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gboolean expand;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gboolean fill;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis GtkPackType pack_type;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gtk_box_query_child_packing (box,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child->data,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &expand,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &fill,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &padding,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &pack_type);
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis if ((pack_type == GTK_PACK_START) && gtk_widget_get_visible (GTK_WIDGET (child->data)))
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis if (gtk_box_get_homogeneous (box))
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis if (nvis_children == 1)
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_width = width;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis else
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_width = extra;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis nvis_children -= 1;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis width -= extra;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis else
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis GtkRequisition child_requisition;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition);
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child_width = child_requisition.width + padding * 2;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis if (expand)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis if (nexpand_children == 1)
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_width += width;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis else
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_width += extra;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis nexpand_children -= 1;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis width -= extra;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis if (fill)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child_allocation.width = MAX (1, child_width - padding * 2);
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child_allocation.x = x + padding;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis else
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis GtkRequisition child_requisition;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition);
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_allocation.width = child_requisition.width;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_allocation.x = x + (child_width - child_allocation.width) / 2;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis if (direction == GTK_TEXT_DIR_RTL)
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gtk_widget_size_allocate (GTK_WIDGET (child->data), &child_allocation);
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis x += child_width + gtk_box_get_spacing (box);
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis x = allocation->x + allocation->width - border_width;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis for (child = gtk_container_get_children (GTK_CONTAINER (box));
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child != NULL; child = g_list_next (child))
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis guint padding;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gboolean expand;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gboolean fill;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis GtkPackType pack_type;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gtk_box_query_child_packing (box,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child->data,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &expand,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &fill,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &padding,
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis &pack_type);
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis if ((pack_type == GTK_PACK_END) && gtk_widget_get_visible (GTK_WIDGET (child->data)))
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis GtkRequisition child_requisition;
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition);
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis if (gtk_box_get_homogeneous (box))
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis if (nvis_children == 1)
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_width = width;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis else
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_width = extra;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis nvis_children -= 1;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis width -= extra;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis else
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child_width = child_requisition.width + padding * 2;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis if (expand)
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis if (nexpand_children == 1)
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_width += width;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis else
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_width += extra;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis nexpand_children -= 1;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis width -= extra;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis if (fill)
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child_allocation.width = MAX (1, child_width - padding * 2);
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis child_allocation.x = x + padding - child_width;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis else
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis {
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_allocation.width = child_requisition.width;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_allocation.x = x + (child_width - child_allocation.width) / 2 - child_width;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis if (direction == GTK_TEXT_DIR_RTL)
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width;
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
25587daccfe04cdc288082cbd6195326c0166f32Alex Valavanis gtk_widget_size_allocate (GTK_WIDGET (child->data), &child_allocation);
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis x -= (child_width + gtk_box_get_spacing (box));
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
d19de0ff8b0793e74e98429ded50868ce7e9f75cAlex Valavanis }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bGtkWidget *
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_dock_bar_new (GdlDock *dock)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlDockMaster *master = NULL;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b /* get the master of the given dock */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (dock)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b master = GDL_DOCK_OBJECT_GET_MASTER (dock);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return g_object_new (GDL_TYPE_DOCK_BAR,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b "master", master, NULL);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bGtkOrientation gdl_dock_bar_get_orientation (GdlDockBar *dockbar)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_return_val_if_fail (GDL_IS_DOCK_BAR (dockbar),
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GTK_ORIENTATION_VERTICAL);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return dockbar->_priv->orientation;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bvoid gdl_dock_bar_set_orientation (GdlDockBar *dockbar,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkOrientation orientation)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_return_if_fail (GDL_IS_DOCK_BAR (dockbar));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b dockbar->_priv->orientation = orientation;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_queue_resize (GTK_WIDGET (dockbar));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bvoid gdl_dock_bar_set_style(GdlDockBar* dockbar,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlDockBarStyle style)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_set(G_OBJECT(dockbar), "dockbar-style", style, NULL);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bGdlDockBarStyle gdl_dock_bar_get_style(GdlDockBar* dockbar)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlDockBarStyle style;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_get(G_OBJECT(dockbar), "dockbar-style", &style, NULL);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return style;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}