summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--gladeui/Makefile.am6
-rw-r--r--gladeui/glade-palette-box.c474
-rw-r--r--gladeui/glade-palette-box.h70
-rw-r--r--gladeui/glade-palette-expander.c675
-rw-r--r--gladeui/glade-palette-expander.h84
-rw-r--r--gladeui/glade-palette-item.c494
-rw-r--r--gladeui/glade-palette-item.h85
-rw-r--r--gladeui/glade-palette.c305
-rw-r--r--gladeui/glade-palette.h3
-rw-r--r--plugins/gtk+/glade-gtk.c4
-rw-r--r--plugins/gtk+/glade-model-data.c1
12 files changed, 172 insertions, 2038 deletions
diff --git a/ChangeLog b/ChangeLog
index a8fdde86..ce039de5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-03-25 Tristan Van Berkom <tvb@gnome.org>
+
+ * gladeui/Makefile.am, gladeui/glade-palette.c:
+ - Removed glade-palette-box.[ch], glade-palette-expander.[ch] and glade-palette-item.[ch].
+ - Integrated GtkToolPalette as the internal implementation of Glade's palette (bug 613956).
+
+ * plugins/gtk+/glade-gtk.c: Fix some remaining crashes from the GSEAL() stuff (GtkBoxChild
+ invalid type dereferencing).
+
2010-03-25 Federico Mena Quintero <federico@novell.com>
* plugins/gtk+/gtk+.xml.in: bgo#594231 - Fix the orientation of
diff --git a/gladeui/Makefile.am b/gladeui/Makefile.am
index 6dff1501..1c217aa8 100644
--- a/gladeui/Makefile.am
+++ b/gladeui/Makefile.am
@@ -26,9 +26,6 @@ libgladeui_1_la_SOURCES = \
glade-inspector.c \
glade-xml-utils.c \
glade-palette.c \
- glade-palette-item.c \
- glade-palette-box.c \
- glade-palette-expander.c \
glade-design-layout.c \
glade-design-view.c \
glade-named-icon-chooser-dialog.c \
@@ -55,9 +52,6 @@ libgladeui_1_la_SOURCES = \
glade-app.c \
glade-fixed.c \
glade-base-editor.c \
- glade-palette-item.h \
- glade-palette-box.h \
- glade-palette-expander.h \
glade-popup.h \
glade-marshallers.h \
glade-accumulators.h \
diff --git a/gladeui/glade-palette-box.c b/gladeui/glade-palette-box.c
deleted file mode 100644
index 74e5f6f2..00000000
--- a/gladeui/glade-palette-box.c
+++ /dev/null
@@ -1,474 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * glade-palette-box.c
- *
- * Copyright (C) 2007 Vincent Geddes.
- *
- * Author: Vincent Geddes <vincent.geddes@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- */
-
-#include <config.h>
-
-#include "glade-palette-box.h"
-
-#define GLADE_PALETTE_BOX_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object),\
- GLADE_TYPE_PALETTE_BOX, \
- GladePaletteBoxPrivate))
-
-enum
-{
- PROP_0
-};
-
-enum
-{
- CHILD_PROP_0,
- CHILD_PROP_POSITION
-};
-
-struct _GladePaletteBoxPrivate
-{
- GList *children;
-
-};
-
-typedef struct
-{
- GtkWidget *widget;
-} GladePaletteBoxChild;
-
-static void glade_palette_box_add (GtkContainer *container, GtkWidget *widget);
-
-static void glade_palette_box_remove (GtkContainer *container, GtkWidget *widget);
-
-static GType glade_palette_box_child_type (GtkContainer *container);
-
-static void glade_palette_box_size_request (GtkWidget *widget, GtkRequisition *requisition);
-
-static void glade_palette_box_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
-
-static void glade_palette_box_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-
-static void glade_palette_box_set_child_property (GtkContainer *container,
- GtkWidget *child,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-
-static void glade_palette_box_get_child_property (GtkContainer *container,
- GtkWidget *child,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-
-
-G_DEFINE_TYPE (GladePaletteBox, glade_palette_box, GTK_TYPE_CONTAINER);
-
-
-static void
-glade_palette_box_class_init (GladePaletteBoxClass *klass)
-{
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
-
- container_class = GTK_CONTAINER_CLASS (klass);
- widget_class = GTK_WIDGET_CLASS (klass);
-
- widget_class->size_request = glade_palette_box_size_request;
- widget_class->size_allocate = glade_palette_box_size_allocate;
-
- container_class->add = glade_palette_box_add;
- container_class->remove = glade_palette_box_remove;
- container_class->forall = glade_palette_box_forall;
- container_class->child_type = glade_palette_box_child_type;
- container_class->set_child_property = glade_palette_box_set_child_property;
- container_class->get_child_property = glade_palette_box_get_child_property;
-
- gtk_container_class_install_child_property (container_class,
- CHILD_PROP_POSITION,
- g_param_spec_int ("position",
- "Position",
- "The index of the child in the parent",
- -1, G_MAXINT, 0,
- G_PARAM_READWRITE));
-
- g_type_class_add_private (klass, sizeof (GladePaletteBoxPrivate));
-}
-
-static void
-glade_palette_box_init (GladePaletteBox *box)
-{
- gtk_widget_set_has_window (GTK_WIDGET (box), FALSE);
- gtk_widget_set_redraw_on_allocate (GTK_WIDGET (box), FALSE);
-
- box->priv = GLADE_PALETTE_BOX_GET_PRIVATE (box);
-
- box->priv->children = NULL;
-}
-
-static void
-glade_palette_box_set_child_property (GtkContainer *container,
- GtkWidget *child,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
-
- switch (property_id)
- {
- case CHILD_PROP_POSITION:
- glade_palette_box_reorder_child (GLADE_PALETTE_BOX (container),
- child,
- g_value_get_int (value));
- break;
- default:
- GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
- break;
- }
-}
-
-static void
-glade_palette_box_get_child_property (GtkContainer *container,
- GtkWidget *child,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GList *list;
- guint i;
-
- switch (property_id)
- {
- case CHILD_PROP_POSITION:
- i = 0;
- for (list = GLADE_PALETTE_BOX_GET_PRIVATE (container)->children; list; list = list->next)
- {
- GladePaletteBoxChild *child_entry;
-
- child_entry = list->data;
- if (child_entry->widget == child)
- break;
- i++;
- }
- g_value_set_int (value, list ? i : -1);
- break;
- default:
- GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
- break;
- }
-}
-
-/* do some badass mathematics */
-static gint
-calculate_children_width_allocation (GtkWidget *widget,
- GtkAllocation *allocation,
- GtkRequisition *child_requisition,
- gint nvis_children)
-{
- gint w; /* container width */
- gint cw; /* children width request */
- gint tmp = 0;
-
- g_assert (child_requisition->width >= 0);
-
- w = allocation->width - gtk_container_get_border_width (GTK_CONTAINER (widget));
- cw = child_requisition->width;
-
- if ((nvis_children * cw) < w )
- return cw;
-
- if ((tmp = w - w % cw) == 0)
- return child_requisition->width;
- else
- return w / (tmp / cw);
-}
-
-static void
-glade_palette_box_size_request (GtkWidget *widget, GtkRequisition *requisition)
-{
- GladePaletteBox *box;
- GladePaletteBoxChild *child;
- GtkRequisition child_requisition;
- GList *l;
- gint nvis_children = 0;
- guint border_width = 0;
-
- box = GLADE_PALETTE_BOX (widget);
-
- requisition->width = 0;
- requisition->height = 0;
- child_requisition.width = 0;
- child_requisition.height = 0;
-
- for (l = box->priv->children; l; l = l->next)
- {
- child = (GladePaletteBoxChild *) (l->data);
-
- if (gtk_widget_get_visible (child->widget))
- {
- GtkRequisition requisition;
- gtk_widget_size_request (child->widget, &requisition);
-
- child_requisition.width = MAX (child_requisition.width, requisition.width);
-
- nvis_children += 1;
- }
- }
-
- if (nvis_children > 0)
- {
- requisition->width += child_requisition.width;
- requisition->height += child_requisition.height;
- }
-
- border_width = gtk_container_get_border_width (GTK_CONTAINER (box));
- requisition->width += border_width * 2;
- requisition->height += border_width * 2;
-}
-
-static void
-glade_palette_box_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
-{
- GladePaletteBox *box;
- GladePaletteBoxChild *child;
- GList *l;
- GtkRequisition child_requisition;
- GtkAllocation child_allocation;
- gint nvis_children = 0;
- gint x, y;
- gint rows = 1;
- gint children_width;
- guint border_width;
-
- box = GLADE_PALETTE_BOX (widget);
- gtk_widget_set_allocation (widget, allocation);
-
- child_requisition.width = 0;
- child_requisition.height = 0;
-
- /* Retrieve maximum requisition from children */
- for (l = box->priv->children; l; l = l->next)
- {
- child = (GladePaletteBoxChild *) (l->data);
-
- if (gtk_widget_get_visible (child->widget))
- {
- GtkRequisition requisition;
-
- gtk_widget_get_child_requisition (child->widget, &requisition);
-
- child_requisition.width = MAX (child_requisition.width, requisition.width);
- child_requisition.height = MAX (child_requisition.height, requisition.height);
-
- nvis_children += 1;
- }
- }
-
- if (nvis_children <= 0)
- return;
-
- border_width = gtk_container_get_border_width (GTK_CONTAINER (box));
- x = allocation->x + border_width;
- y = allocation->y + border_width;
-
- children_width = calculate_children_width_allocation (widget, allocation,
- &child_requisition,
- nvis_children);
-
- /* Allocate real estate to children */
- for (l = box->priv->children; l; l = l->next)
- {
- gint horizontal_space_remaining;
-
- child = (GladePaletteBoxChild *) (l->data);
-
- if (gtk_widget_get_visible (child->widget))
- {
- child_allocation.x = x;
- child_allocation.y = y;
- child_allocation.width = children_width;
- child_allocation.height = child_requisition.height;
- guint border_width;
-
- gtk_widget_size_allocate (child->widget, &child_allocation);
-
- x += child_allocation.width;
-
- border_width = gtk_container_get_border_width (GTK_CONTAINER (box));
- /* calculate horizontal space remaining */
- horizontal_space_remaining = x
- - allocation->x
- + border_width
- + children_width;
-
- /* jump to next row */
- if ((horizontal_space_remaining > allocation->width) && l->next )
- {
- x = allocation->x + border_width;
- y += child_allocation.height;
- rows++;
- }
- }
- }
-
- /* force minimum height */
- gtk_widget_set_size_request (widget, -1, rows * child_allocation.height);
-}
-
-static void
-glade_palette_box_add (GtkContainer *container, GtkWidget *widget)
-{
- GladePaletteBox *box;
- GladePaletteBoxChild *child;
-
- g_return_if_fail (GLADE_IS_PALETTE_BOX (container));
- g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (gtk_widget_get_parent (widget) == NULL);
-
- box = GLADE_PALETTE_BOX (container);
-
- child = g_slice_new (GladePaletteBoxChild);
- child->widget = widget;
- box->priv->children = g_list_append (box->priv->children, child);
-
- gtk_widget_set_parent (widget, GTK_WIDGET (box));
-
-}
-
-static void
-glade_palette_box_remove (GtkContainer *container, GtkWidget *widget)
-{
- GladePaletteBox *box;
- GladePaletteBoxChild *child;
- GList *children;
-
- g_return_if_fail (GLADE_IS_PALETTE_BOX (container));
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- box = GLADE_PALETTE_BOX (container);
-
- children = box->priv->children;
- while (children != NULL)
- {
- child = children->data;
- children = g_list_next (children);
-
- if (child->widget == widget)
- {
- gboolean was_visible;
-
- was_visible = gtk_widget_get_visible (widget);
-
- gtk_widget_unparent (widget);
-
- box->priv->children = g_list_remove (box->priv->children, child);
-
- g_slice_free (GladePaletteBoxChild, child);
-
- if (was_visible)
- gtk_widget_queue_resize (GTK_WIDGET (container));
- break;
- }
-
- }
-
-}
-
-static void
-glade_palette_box_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data)
-{
- GladePaletteBox *box;
- GladePaletteBoxChild *child;
- GList *children;
-
- g_return_if_fail (callback != NULL);
-
- box = GLADE_PALETTE_BOX (container);
-
- children = box->priv->children;
- while (children != NULL)
- {
- child = children->data;
- children = g_list_next (children);
-
- (* callback) (child->widget, callback_data);
- }
-}
-
-void
-glade_palette_box_reorder_child (GladePaletteBox *box,
- GtkWidget *child,
- gint position)
-{
- GList *old_link;
- GList *new_link;
- GladePaletteBoxChild *child_info = NULL;
- gint old_position;
-
- g_return_if_fail (GLADE_IS_PALETTE_BOX (box));
- g_return_if_fail (GTK_IS_WIDGET (child));
-
- old_link = box->priv->children;
- old_position = 0;
- while (old_link)
- {
- child_info = old_link->data;
- if (child_info->widget == child)
- break;
-
- old_link = old_link->next;
- old_position++;
- }
-
- g_return_if_fail (old_link != NULL);
-
- if (position == old_position)
- return;
-
- box->priv->children = g_list_delete_link (box->priv->children, old_link);
-
- if (position < 0)
- new_link = NULL;
- else
- new_link = g_list_nth (box->priv->children, position);
-
- box->priv->children = g_list_insert_before (box->priv->children, new_link, child_info);
-
- gtk_widget_child_notify (child, "position");
- if (gtk_widget_get_visible (child) && gtk_widget_get_visible (GTK_WIDGET (box)))
- gtk_widget_queue_resize (child);
-}
-
-static GType
-glade_palette_box_child_type (GtkContainer *container)
-{
- return GTK_TYPE_WIDGET;
-}
-
-GtkWidget*
-glade_palette_box_new (void)
-{
- return g_object_new (GLADE_TYPE_PALETTE_BOX, NULL);
-}
diff --git a/gladeui/glade-palette-box.h b/gladeui/glade-palette-box.h
deleted file mode 100644
index 8ed2d46d..00000000
--- a/gladeui/glade-palette-box.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * glade-palette-box.h
- *
- * Copyright (C) 2007 Vincent Geddes.
- *
- * Author: Vincent Geddes <vincent.geddes@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- */
-
-#ifndef __GLADE_PALETTE_BOX_H__
-#define __GLADE_PALETTE_BOX_H__
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-#define GLADE_TYPE_PALETTE_BOX (glade_palette_box_get_type ())
-#define GLADE_PALETTE_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_PALETTE_BOX, GladePaletteBox))
-#define GLADE_PALETTE_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_PALETTE_BOX, GladePaletteBoxClass))
-#define GLADE_IS_PALETTE_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_PALETTE_BOX))
-#define GLADE_IS_PALETTE_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_PALETTE_BOX))
-#define GLADE_PALETTE_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_PALETTE_BOX, GladePaletteBoxClass))
-
-typedef struct _GladePaletteBox GladePaletteBox;
-typedef struct _GladePaletteBoxPrivate GladePaletteBoxPrivate;
-typedef struct _GladePaletteBoxClass GladePaletteBoxClass;
-
-struct _GladePaletteBox
-{
- GtkContainer parent_instance;
-
- GladePaletteBoxPrivate *priv;
-};
-
-struct _GladePaletteBoxClass
-{
- GtkContainerClass parent_class;
-};
-
-
-
-
-GType glade_palette_box_get_type (void) G_GNUC_CONST;
-
-GtkWidget *glade_palette_box_new (void);
-
-void glade_palette_box_reorder_child (GladePaletteBox *box,
- GtkWidget *child,
- gint position);
-
-
-G_END_DECLS
-
-#endif /* __GLADE_PALETTE_BOX_H__ */
diff --git a/gladeui/glade-palette-expander.c b/gladeui/glade-palette-expander.c
deleted file mode 100644
index 3fa42c3c..00000000
--- a/gladeui/glade-palette-expander.c
+++ /dev/null
@@ -1,675 +0,0 @@
-/*
- * glade-palette-expander.c - A container which can hide its child
- *
- * Copyright (C) 2007 Vincent Geddes
- *
- * Author: Vincent Geddes <vincent.geddes@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include <config.h>
-
-#include "glade-palette-expander.h"
-
-#include <gtk/gtk.h>
-
-#define GLADE_PALETTE_EXPANDER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
- GLADE_TYPE_PALETTE_EXPANDER, \
- GladePaletteExpanderPrivate))
-
-enum
-{
- PROP_0,
- PROP_EXPANDED,
- PROP_LABEL,
- PROP_SPACING,
- PROP_USE_MARKUP
-};
-
-struct _GladePaletteExpanderPrivate
-{
- GtkWidget *button;
- GtkWidget *arrow;
- GtkWidget *label;
-
- gboolean expanded;
- gboolean use_markup;
- gboolean button_down;
- guint spacing;
- guint expand_timer_handle;
-
-};
-
-static void glade_palette_expander_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void glade_palette_expander_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void glade_palette_expander_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void glade_palette_expander_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static void glade_palette_expander_map (GtkWidget *widget);
-static void glade_palette_expander_unmap (GtkWidget *widget);
-static void glade_palette_expander_add (GtkContainer *container,
- GtkWidget *widget);
-static void glade_palette_expander_remove (GtkContainer *container,
- GtkWidget *widget);
-static void glade_palette_expander_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-static void button_clicked (GtkButton *button,
- GladePaletteExpander *expander);
-
-
-static gboolean button_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time,
- GladePaletteExpander *expander);
-
-static void button_drag_leave (GtkWidget *widget,
- GdkDragContext *context,
- guint time,
- GladePaletteExpander *expander);
-
-static void glade_palette_expander_activate (GladePaletteExpander *expander);
-void glade_palette_expander_set_expanded (GladePaletteExpander *expander,
- gboolean expanded);
-gboolean glade_palette_expander_get_expanded (GladePaletteExpander *expander);
-void glade_palette_expander_set_label (GladePaletteExpander *expander,
- const gchar *label);
-const gchar *glade_palette_expander_get_label (GladePaletteExpander *expander);
-void glade_palette_expander_set_spacing (GladePaletteExpander *expander,
- guint spacing);
-guint glade_palette_expander_get_spacing (GladePaletteExpander *expander);
-
-
-G_DEFINE_TYPE (GladePaletteExpander, glade_palette_expander, GTK_TYPE_BIN);
-
-static void
-glade_palette_expander_class_init (GladePaletteExpanderClass *klass)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
-
- object_class = G_OBJECT_CLASS (klass);
- widget_class = GTK_WIDGET_CLASS (klass);
- container_class = GTK_CONTAINER_CLASS (klass);
-
- object_class->set_property = glade_palette_expander_set_property;
- object_class->get_property = glade_palette_expander_get_property;
-
- container_class->add = glade_palette_expander_add;
- container_class->remove = glade_palette_expander_remove;
- container_class->forall = glade_palette_expander_forall;
-
- widget_class->size_request = glade_palette_expander_size_request;
- widget_class->size_allocate = glade_palette_expander_size_allocate;
- widget_class->map = glade_palette_expander_map;
- widget_class->unmap = glade_palette_expander_unmap;
-
- klass->activate = glade_palette_expander_activate;
-
- g_object_class_install_property (object_class,
- PROP_EXPANDED,
- g_param_spec_boolean ("expanded",
- "Expanded",
- "Whether the expander has been opened to "
- "reveal the child widget",
- FALSE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (object_class,
- PROP_LABEL,
- g_param_spec_string ("label",
- "Label",
- "Text of the expander's label",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (object_class,
- PROP_SPACING,
- g_param_spec_uint ("spacing",
- "Spacing",
- "Space to put between the expander and the child widget",
- 0,
- G_MAXUINT,
- 0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_USE_MARKUP,
- g_param_spec_boolean ("use-markup",
- "Use Markup",
- "The text of the label includes Pango XML markup"
- "reveal the child widget",
- FALSE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- widget_class->activate_signal =
- g_signal_new ("activate",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (GladePaletteExpanderClass, activate),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- g_type_class_add_private (klass, sizeof (GladePaletteExpanderPrivate));
-}
-
-static void
-glade_palette_expander_init (GladePaletteExpander *expander)
-{
- GladePaletteExpanderPrivate *priv;
- GtkWidget *hbox;
- GtkWidget *alignment;
-
- expander->priv = priv = GLADE_PALETTE_EXPANDER_GET_PRIVATE (expander);
-
- gtk_widget_set_has_window (GTK_WIDGET (expander), FALSE);
-
- priv->spacing = 0;
- priv->expanded = FALSE;
- priv->use_markup = FALSE;
- priv->button_down = FALSE;
-
- gtk_widget_push_composite_child ();
-
- priv->button = gtk_button_new ();
- gtk_button_set_focus_on_click (GTK_BUTTON (priv->button), FALSE);
- priv->arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
- priv->label = gtk_label_new (NULL);
- gtk_label_set_ellipsize (GTK_LABEL (priv->label), PANGO_ELLIPSIZE_END);
- gtk_misc_set_alignment (GTK_MISC (priv->label), 0.0, 0.5);
-
- alignment = gtk_alignment_new (0.0, 0.5, 1, 1);
-
- hbox = gtk_hbox_new (FALSE, 3);
-
- gtk_container_add (GTK_CONTAINER (alignment), hbox);
- gtk_container_add (GTK_CONTAINER (priv->button), alignment);
- gtk_box_pack_start (GTK_BOX (hbox), priv->arrow, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), priv->label, TRUE, TRUE, 0);
-
- gtk_widget_set_parent (priv->button, GTK_WIDGET (expander));
-
- gtk_widget_pop_composite_child ();
-
- g_signal_connect (priv->button, "clicked",
- G_CALLBACK (button_clicked),
- expander);
-
- g_signal_connect (priv->button, "drag-motion",
- G_CALLBACK (button_drag_motion),
- expander);
-
- g_signal_connect (priv->button, "drag-leave",
- G_CALLBACK (button_drag_leave),
- expander);
-
- gtk_widget_show_all (priv->button);
-
- gtk_drag_dest_set (GTK_WIDGET (priv->button), 0, NULL, 0, 0);
- gtk_drag_dest_set_track_motion (GTK_WIDGET (priv->button), TRUE);
-}
-
-static void
-glade_palette_expander_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GladePaletteExpander *expander = GLADE_PALETTE_EXPANDER (object);
-
- switch (prop_id)
- {
- case PROP_EXPANDED:
- glade_palette_expander_set_expanded (expander, g_value_get_boolean (value));
- break;
- case PROP_LABEL:
- glade_palette_expander_set_label (expander, g_value_get_string (value));
- break;
- case PROP_SPACING:
- glade_palette_expander_set_spacing (expander, g_value_get_int (value));
- break;
- case PROP_USE_MARKUP:
- glade_palette_expander_set_use_markup (expander, g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-glade_palette_expander_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GladePaletteExpander *expander = GLADE_PALETTE_EXPANDER (object);
-
- switch (prop_id)
- {
- case PROP_EXPANDED:
- g_value_set_boolean (value, glade_palette_expander_get_expanded (expander));
- break;
- case PROP_LABEL:
- g_value_set_string (value, glade_palette_expander_get_label (expander));
- break;
- case PROP_SPACING:
- g_value_set_int (value, glade_palette_expander_get_spacing (expander));
- break;
- case PROP_USE_MARKUP:
- g_value_set_boolean (value, glade_palette_expander_get_use_markup (expander));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-glade_palette_expander_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- GladePaletteExpanderPrivate *priv;
- GladePaletteExpander *expander;
- GtkBin *bin;
- GtkWidget *child;
- guint border_width;
-
- bin = GTK_BIN (widget);
- expander = GLADE_PALETTE_EXPANDER (widget);
- priv = expander->priv;
-
- border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
-
- requisition->width = 0;
- requisition->height = 0;
-
-
- if (gtk_widget_get_visible (priv->button))
- {
- GtkRequisition button_requisition;
-
- gtk_widget_size_request (priv->button, &button_requisition);
-
- requisition->width += button_requisition.width;
- requisition->height += button_requisition.height;
- }
-
- child = gtk_bin_get_child (bin);
- if (child && gtk_widget_get_child_visible (child))
- {
- GtkRequisition child_requisition;
-
- gtk_widget_size_request (child, &child_requisition);
-
- requisition->width = MAX (requisition->width, child_requisition.width);
- requisition->height += child_requisition.height + priv->spacing;
- }
-
- requisition->width += 2 * border_width;
- requisition->height += 2 * border_width;
-}
-
-static void
-glade_palette_expander_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- GladePaletteExpanderPrivate *priv;
- GladePaletteExpander *expander;
- GtkBin *bin;
- GtkWidget *child;
- GtkRequisition child_requisition;
- gboolean child_visible = FALSE;
- guint border_width;
- gint button_height;
-
- expander = GLADE_PALETTE_EXPANDER (widget);
- bin = GTK_BIN (widget);
- priv = expander->priv;
-
- border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
-
- child_requisition.width = 0;
- child_requisition.height = 0;
-
- child = gtk_bin_get_child (bin);
- if (child && gtk_widget_get_child_visible (child))
- {
- child_visible = TRUE;
- gtk_widget_get_child_requisition (child, &child_requisition);
- }
-
- gtk_widget_set_allocation (widget, allocation);
-
- if (gtk_widget_get_visible (priv->button))
- {
- GtkAllocation button_allocation;
- GtkRequisition button_requisition;
-
- gtk_widget_get_child_requisition (priv->button, &button_requisition);
-
- button_allocation.x = allocation->x + border_width;
- button_allocation.y = allocation->y + border_width;
-
- button_allocation.width = MAX (allocation->width - 2 * border_width, 1);
-
- button_allocation.height = MIN (button_requisition.height,
- allocation->height - 2 * border_width
- - (child_visible ? priv->spacing : 0));
-
- button_allocation.height = MAX (button_allocation.height, 1);
-
- gtk_widget_size_allocate (priv->button, &button_allocation);
-
- button_height = button_allocation.height;
- }
- else
- {
- button_height = 0;
- }
-
- if (child_visible)
- {
- GtkAllocation child_allocation;
-
- child_allocation.x = allocation->x + border_width;
- child_allocation.y = allocation->y + border_width + button_height + priv->spacing;
-
- child_allocation.width = MAX (allocation->width - 2 * border_width, 1);
-
- child_allocation.height = allocation->height - button_height -
- 2 * border_width - priv->spacing;
- child_allocation.height = MAX (child_allocation.height, 1);
-
- gtk_widget_size_allocate (child, &child_allocation);
- }
-}
-
-static void
-glade_palette_expander_map (GtkWidget *widget)
-{
- GladePaletteExpanderPrivate *priv = GLADE_PALETTE_EXPANDER (widget)->priv;
-
- gtk_widget_map (priv->button);
-
- GTK_WIDGET_CLASS (glade_palette_expander_parent_class)->map (widget);
-}
-
-static void
-glade_palette_expander_unmap (GtkWidget *widget)
-{
- GladePaletteExpanderPrivate *priv = GLADE_PALETTE_EXPANDER (widget)->priv;
-
- GTK_WIDGET_CLASS (glade_palette_expander_parent_class)->unmap (widget);
-
- gtk_widget_unmap (priv->button);
-}
-
-static void
-glade_palette_expander_add (GtkContainer *container,
- GtkWidget *widget)
-{
- GTK_CONTAINER_CLASS (glade_palette_expander_parent_class)->add (container, widget);
-
- gtk_widget_set_child_visible (widget, GLADE_PALETTE_EXPANDER (container)->priv->expanded);
- gtk_widget_queue_resize (GTK_WIDGET (container));
-}
-
-static void
-glade_palette_expander_remove (GtkContainer *container,
- GtkWidget *widget)
-{
- GladePaletteExpander *expander = GLADE_PALETTE_EXPANDER (container);
-
- if (expander->priv->button == widget)
- {
- gtk_widget_unparent (expander->priv->button);
- expander->priv->button = NULL;
-
- if (gtk_widget_get_visible (GTK_WIDGET (expander)))
- gtk_widget_queue_resize (GTK_WIDGET (expander));
-
- g_object_notify (G_OBJECT (expander), "label");
- }
- else
- {
- GTK_CONTAINER_CLASS (glade_palette_expander_parent_class)->remove (container, widget);
- }
-
-}
-
-static void
-glade_palette_expander_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data)
-{
- GtkBin *bin = GTK_BIN (container);
- GtkWidget *child;
- GladePaletteExpanderPrivate *priv = GLADE_PALETTE_EXPANDER_GET_PRIVATE (container);
-
- child = gtk_bin_get_child (bin);
- if (child)
- (* callback) (child, callback_data);
-
- if (priv->button)
- (* callback) (priv->button, callback_data);
-}
-
-static gboolean
-expand_timeout (gpointer data)
-{
- GladePaletteExpander *expander = (GladePaletteExpander *) (data);
- GladePaletteExpanderPrivate *priv = expander->priv;
-
- GDK_THREADS_ENTER ();
-
- priv->expand_timer_handle = 0;
- glade_palette_expander_set_expanded (expander, TRUE);
-
- GDK_THREADS_LEAVE ();
-
- return FALSE;
-}
-
-static gboolean
-button_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time,
- GladePaletteExpander *expander)
-{
- GladePaletteExpanderPrivate *priv = expander->priv;
-
- if (!priv->expanded && !priv->expand_timer_handle)
- {
- GtkSettings *settings;
- guint timeout;
-
- settings = gtk_widget_get_settings (widget);
- g_object_get (settings, "gtk-timeout-expand", &timeout, NULL);
-
- priv->expand_timer_handle = g_timeout_add (timeout,
- (GSourceFunc) expand_timeout,
- expander);
- }
-
- return TRUE;
-}
-
-static void
-button_drag_leave (GtkWidget *widget,
- GdkDragContext *context,
- guint time,
- GladePaletteExpander *expander)
-{
- GladePaletteExpanderPrivate *priv = expander->priv;
-
- if (priv->expand_timer_handle)
- {
- g_source_remove (priv->expand_timer_handle);
- priv->expand_timer_handle = 0;
- }
-}
-
-static void
-button_clicked (GtkButton *button,
- GladePaletteExpander *expander)
-{
- gtk_widget_activate (GTK_WIDGET (expander));
-}
-
-static void
-glade_palette_expander_activate (GladePaletteExpander *expander)
-{
- glade_palette_expander_set_expanded (expander, !expander->priv->expanded);
-}
-
-void
-glade_palette_expander_set_expanded (GladePaletteExpander *expander, gboolean expanded)
-{
- GladePaletteExpanderPrivate *priv;
- GtkWidget *child;
-
- g_return_if_fail (GLADE_IS_PALETTE_EXPANDER (expander));
-
- priv = expander->priv;
-
- expanded = expanded != FALSE;
-
- if (priv->expanded != expanded)
- {
- priv->expanded = expanded;
-
- child = gtk_bin_get_child (GTK_BIN (expander));
- if (child)
- {
- gtk_widget_set_child_visible (child, priv->expanded);
- gtk_widget_queue_resize (GTK_WIDGET (expander));
- }
-
- gtk_arrow_set (GTK_ARROW (priv->arrow),
- priv->expanded ? GTK_ARROW_DOWN : GTK_ARROW_RIGHT,
- GTK_SHADOW_NONE);
-
- g_object_notify (G_OBJECT (expander), "expanded");
- }
-}
-
-gboolean
-glade_palette_expander_get_expanded (GladePaletteExpander *expander)
-{
- g_return_val_if_fail (GLADE_IS_PALETTE_EXPANDER (expander), FALSE);
-
- return expander->priv->expanded;
-}
-
-void
-glade_palette_expander_set_label (GladePaletteExpander *expander, const gchar *label)
-{
- GladePaletteExpanderPrivate *priv;
- g_return_if_fail (GLADE_IS_PALETTE_EXPANDER (expander));
-
- priv = GLADE_PALETTE_EXPANDER_GET_PRIVATE (expander);
-
- gtk_label_set_label (GTK_LABEL (priv->label), label);
- g_object_notify (G_OBJECT (expander), "label");
-}
-
-const gchar *
-glade_palette_expander_get_label (GladePaletteExpander *expander)
-{
- g_return_val_if_fail (GLADE_IS_PALETTE_EXPANDER (expander), NULL);
-
- return gtk_label_get_label (GTK_LABEL (expander->priv->label));
-}
-
-void
-glade_palette_expander_set_spacing (GladePaletteExpander *expander,
- guint spacing)
-{
- g_return_if_fail (GLADE_IS_PALETTE_EXPANDER (expander));
-
- if (expander->priv->spacing != spacing)
- {
- expander->priv->spacing = spacing;
-
- gtk_widget_queue_resize (GTK_WIDGET (expander));
-
- g_object_notify (G_OBJECT (expander), "spacing");
- }
-}
-
-guint
-glade_palette_expander_get_spacing (GladePaletteExpander *expander)
-{
- g_return_val_if_fail (GLADE_IS_PALETTE_EXPANDER (expander), 0);
-
- return expander->priv->spacing;
-}
-
-void
-glade_palette_expander_set_use_markup (GladePaletteExpander *expander,
- gboolean use_markup)
-{
- GladePaletteExpanderPrivate *priv;
-
- g_return_if_fail (GLADE_IS_PALETTE_EXPANDER (expander));
-
- priv = expander->priv;
-
- use_markup = use_markup != FALSE;
-
- if (priv->use_markup != use_markup)
- {
- priv->use_markup = use_markup;
-
- gtk_label_set_use_markup (GTK_LABEL (priv->label), use_markup);
-
- g_object_notify (G_OBJECT (expander), "use-markup");
- }
-}
-
-gboolean
-glade_palette_expander_get_use_markup (GladePaletteExpander *expander)
-{
- g_return_val_if_fail (GLADE_IS_PALETTE_EXPANDER (expander), FALSE);
-
- return expander->priv->use_markup;
-}
-
-GtkWidget *
-glade_palette_expander_new (const gchar *label)
-{
- return g_object_new (GLADE_TYPE_PALETTE_EXPANDER,
- "label", label,
- NULL);
-}
-
diff --git a/gladeui/glade-palette-expander.h b/gladeui/glade-palette-expander.h
deleted file mode 100644
index 9d26e09d..00000000
--- a/gladeui/glade-palette-expander.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * glade-palette-expander.h - A container which can hide its child
- *
- * Copyright (C) 2007 Vincent Geddes
- *
- * Author: Vincent Geddes <vincent.geddes@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef __GLADE_PALETTE_EXPANDER_H__
-#define __GLADE_PALETTE_EXPANDER_H__
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-#define GLADE_TYPE_PALETTE_EXPANDER (glade_palette_expander_get_type ())
-#define GLADE_PALETTE_EXPANDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_PALETTE_EXPANDER, GladePaletteExpander))
-#define GLADE_PALETTE_EXPANDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_PALETTE_EXPANDER, GladePaletteExpanderClass))
-#define GLADE_IS_PALETTE_EXPANDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_PALETTE_EXPANDER))
-#define GLADE_IS_PALETTE_EXPANDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_PALETTE_EXPANDER))
-#define GLADE_PALETTE_EXPANDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_PALETTE_EXPANDER, GladePaletteExpanderClass))
-
-typedef struct _GladePaletteExpander GladePaletteExpander;
-typedef struct _GladePaletteExpanderPrivate GladePaletteExpanderPrivate;
-typedef struct _GladePaletteExpanderClass GladePaletteExpanderClass;
-
-struct _GladePaletteExpander
-{
- GtkBin parent_instance;
-
- GladePaletteExpanderPrivate *priv;
-};
-
-struct _GladePaletteExpanderClass
-{
- GtkBinClass parent_class;
-
- void (* activate) (GladePaletteExpander *expander);
-};
-
-
-GType glade_palette_expander_get_type (void) G_GNUC_CONST;
-
-GtkWidget *glade_palette_expander_new (const gchar *label);
-
-void glade_palette_expander_set_expanded (GladePaletteExpander *expander,
- gboolean expanded);
-
-gboolean glade_palette_expander_get_expanded (GladePaletteExpander *expander);
-
-void glade_palette_expander_set_spacing (GladePaletteExpander *expander,
- guint spacing);
-
-guint glade_palette_expander_get_spacing (GladePaletteExpander *expander);
-
-void glade_palette_expander_set_label (GladePaletteExpander *expander,
- const gchar *label);
-
-const gchar *glade_palette_expander_get_label (GladePaletteExpander *expander);
-
-void glade_palette_expander_set_use_markup (GladePaletteExpander *expander,
- gboolean use_markup);
-
-gboolean glade_palette_expander_get_use_markup (GladePaletteExpander *expander);
-
-
-G_END_DECLS
-
-#endif /* __GLADE_PALETTE_EXPANDER_H__ */
diff --git a/gladeui/glade-palette-item.c b/gladeui/glade-palette-item.c
deleted file mode 100644
index 56e21ca6..00000000
--- a/gladeui/glade-palette-item.c
+++ /dev/null
@@ -1,494 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * glade-palette-item.c
- *
- * Copyright (C) 2007 Vincent Geddes
- *
- * Authors: Vincent Geddes <vgeddes@metroweb.co.za>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- */
-
-#include "config.h"
-
-#include <gtk/gtk.h>
-
-#include "glade.h"
-#include "glade-palette-item.h"
-#include "glade-popup.h"
-
-#define GLADE_PALETTE_ITEM_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object),\
- GLADE_TYPE_PALETTE_ITEM, \
- GladePaletteItemPrivate))
-
-
-struct _GladePaletteItemPrivate
-{
- GtkWidget *alignment; /* The contents of the button */
- GtkWidget *hbox;
- GtkWidget *icon;
- GtkWidget *label;
-
- GladeItemAppearance appearance; /* The appearance of the button */
-
- gboolean use_small_icon;
-
- GladeWidgetAdaptor *adaptor; /* The widget class adaptor associated
- * with this item
- */
-};
-
-enum
-{
- PROP_0,
- PROP_ADAPTOR,
- PROP_APPEARANCE,
- PROP_USE_SMALL_ICON
-};
-
-
-G_DEFINE_TYPE(GladePaletteItem, glade_palette_item, GTK_TYPE_TOGGLE_BUTTON)
-
-static void
-glade_palette_item_update_appearance (GladePaletteItem *item)
-{
- GladePaletteItemPrivate *priv;
- GtkWidget *child;
- GList *l;
-
- g_return_if_fail (GLADE_IS_PALETTE_ITEM (item));
- priv = GLADE_PALETTE_ITEM_GET_PRIVATE (item);
-
- child = gtk_bin_get_child (GTK_BIN (item));
-
- if (GTK_IS_WIDGET (child))
- gtk_container_remove (GTK_CONTAINER (item), child);
-
- for (l = gtk_container_get_children (GTK_CONTAINER (priv->hbox)); l; l=l->next)
- gtk_container_remove (GTK_CONTAINER (priv->hbox), GTK_WIDGET (l->data));
-
- if (priv->appearance == GLADE_ITEM_ICON_AND_LABEL)
- {
- gtk_box_pack_start (GTK_BOX (priv->hbox), priv->icon, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (priv->hbox), priv->label, FALSE, FALSE, 0);
- gtk_container_add (GTK_CONTAINER (item), priv->alignment);
- }
- else if (priv->appearance == GLADE_ITEM_ICON_ONLY)
- {
-
- gtk_container_add (GTK_CONTAINER (item), priv->icon);
- gtk_misc_set_alignment (GTK_MISC (priv->icon), 0.5, 0.5);
-
- }
- else if (priv->appearance == GLADE_ITEM_LABEL_ONLY)
- {
- gtk_container_add (GTK_CONTAINER (item), priv->label);
- gtk_misc_set_alignment (GTK_MISC (priv->label), 0.0, 0.5);
- }
- else
- g_return_if_reached ();
-}
-
-
-/**
- * glade_palette_item_set_appearance:
- * @palette: A #GladePaletteItem.
- * @appearance: The appearance of the item.
- *
- * Sets the appearance of the item.
- */
-void
-glade_palette_item_set_appearance (GladePaletteItem *item, GladeItemAppearance appearance)
-{
- GladePaletteItemPrivate *priv;
- g_return_if_fail (GLADE_IS_PALETTE_ITEM (item));
- priv = GLADE_PALETTE_ITEM_GET_PRIVATE (item);
-
-
- if (priv->appearance != appearance)
- {
- priv->appearance = appearance;
-
- glade_palette_item_update_appearance (item);
-
- g_object_notify (G_OBJECT (item), "appearance");
- }
-}
-
-#if 0
-/* XXX Code doesnt work well, think they are not transperent ? */
-static GdkPixbuf *
-render_deprecated_pixbuf (GladeWidgetAdaptor *adaptor,
- gint size)
-{
-
- GdkPixbuf *widget_icon, *deprecated_icon;
-
- if ((widget_icon =
- gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
- adaptor->icon_name, size,
- GTK_ICON_LOOKUP_USE_BUILTIN, NULL)) != NULL)
- {
- if ((deprecated_icon =
- gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
- "media-record", size,
- GTK_ICON_LOOKUP_USE_BUILTIN, NULL)) != NULL)
- {
- g_print ("rendering deprecated\n");
- gdk_pixbuf_composite (deprecated_icon, widget_icon,
- 0, 0,
- gdk_pixbuf_get_width (widget_icon),
- gdk_pixbuf_get_height (widget_icon),
- 0.0, 0.0, 1.0, 1.0, GDK_INTERP_HYPER, 0);
-
- g_object_unref (G_OBJECT (deprecated_icon));
- }
- }
- return widget_icon;
-}
-#endif
-
-void
-glade_palette_item_refresh (GladePaletteItem *item)
-{
- GladePaletteItemPrivate *priv;
- GladeProject *project;
- GladeSupportMask support;
- gint size;
- gchar *warning, *text;
-
- priv = GLADE_PALETTE_ITEM_GET_PRIVATE (item);
-
- size = priv->use_small_icon ? GTK_ICON_SIZE_MENU : GTK_ICON_SIZE_BUTTON;
-
- if ((project = glade_app_check_get_project ()) &&
- (warning =
- glade_project_verify_widget_adaptor (project, priv->adaptor, &support)) != NULL)
- {
- /* set sensitivity */
- gtk_widget_set_sensitive (GTK_WIDGET (item),
- !(support & (GLADE_SUPPORT_LIBGLADE_UNSUPPORTED |
- GLADE_SUPPORT_LIBGLADE_ONLY |
- GLADE_SUPPORT_MISMATCH)));
-
- if (support & GLADE_SUPPORT_DEPRECATED)
- /* XXX Todo, draw a cross overlaying the widget icon */
- gtk_image_set_from_stock (GTK_IMAGE (priv->icon),
- GTK_STOCK_DIALOG_WARNING,
- size);
- else
- gtk_image_set_from_icon_name (GTK_IMAGE (priv->icon),
- priv->adaptor->icon_name,
- size);
- /* prepend widget title */
- text = g_strdup_printf ("%s: %s", priv->adaptor->title, warning);
- gtk_widget_set_tooltip_text (priv->icon, text);
- g_free (text);
- g_free (warning);
- }
- else
- {
- gtk_widget_set_tooltip_text (GTK_WIDGET (item), priv->adaptor->title);
- gtk_widget_set_sensitive (GTK_WIDGET (item), TRUE);
- gtk_image_set_from_icon_name (GTK_IMAGE (priv->icon),
- priv->adaptor->icon_name,
- size);
- }
-}
-
-void
-glade_palette_item_set_use_small_icon (GladePaletteItem *item, gboolean use_small_icon)
-{
- GladePaletteItemPrivate *priv;
-
- g_return_if_fail (GLADE_IS_PALETTE_ITEM (item));
- priv = GLADE_PALETTE_ITEM_GET_PRIVATE (item);
-
- if (priv->use_small_icon != use_small_icon)
- {
- priv->use_small_icon = use_small_icon;
-
- glade_palette_item_refresh (item);
-
- g_object_notify (G_OBJECT (item), "use-small-icon");
- }
-}
-
-static void
-glade_palette_set_adaptor (GladePaletteItem *item, GladeWidgetAdaptor *adaptor)
-{
- GladePaletteItemPrivate *priv;
-
- priv = GLADE_PALETTE_ITEM_GET_PRIVATE (item);
-
- priv->adaptor = adaptor;
-
- gtk_label_set_text (GTK_LABEL (priv->label), adaptor->title);
-
- glade_palette_item_refresh (item);
-}
-
-static void
-glade_palette_item_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GladePaletteItem *item;
- GladePaletteItemPrivate *priv;
-
- item = GLADE_PALETTE_ITEM (object);
-
- g_return_if_fail (GLADE_IS_PALETTE_ITEM (item));
-
- priv = GLADE_PALETTE_ITEM_GET_PRIVATE (item);
-
- switch (prop_id)
- {
- case PROP_ADAPTOR:
- glade_palette_set_adaptor (item, g_value_get_object (value));
- break;
- case PROP_APPEARANCE:
- glade_palette_item_set_appearance (item, g_value_get_enum (value));
- break;
- case PROP_USE_SMALL_ICON:
- glade_palette_item_set_use_small_icon (item, g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-glade_palette_item_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GladePaletteItem *item = GLADE_PALETTE_ITEM (object);
- GladePaletteItemPrivate *priv = GLADE_PALETTE_ITEM_GET_PRIVATE (item);
-
- switch (prop_id)
- {
- case PROP_ADAPTOR:
- g_value_set_pointer (value, (gpointer) priv->adaptor);
- break;
- case PROP_APPEARANCE:
- g_value_set_enum (value, priv->appearance);
- break;
- case PROP_USE_SMALL_ICON:
- g_value_set_boolean (value, priv->use_small_icon);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-glade_palette_item_dispose (GObject *object)
-{
- GladePaletteItem *item;
- GladePaletteItemPrivate *priv;
-
- item = GLADE_PALETTE_ITEM (object);
- priv = GLADE_PALETTE_ITEM_GET_PRIVATE (item);
-/*
- if (priv->alignment)
- {
- g_object_unref (priv->alignment);
- priv->alignment = NULL;
- }
- if (priv->hbox)
- {
- g_object_unref (priv->hbox);
- priv->hbox = NULL;
- }
- if (priv->icon)
- {
- g_object_unref (priv->icon);
- priv->icon = NULL;
- }
- if (priv->label)
- {
- g_object_unref (priv->label);
- priv->label = NULL;
- }
-*/
- G_OBJECT_CLASS (glade_palette_item_parent_class)->dispose (object);
-}
-
-static gboolean
-glade_palette_item_button_press (GtkWidget *widget,
- GdkEventButton *event)
-{
- if (glade_popup_is_popup_event (event))
- {
- GladePaletteItemPrivate *priv = GLADE_PALETTE_ITEM_GET_PRIVATE (widget);
-
- glade_popup_palette_pop (priv->adaptor, event);
- return TRUE;
- }
-
- return GTK_WIDGET_CLASS (glade_palette_item_parent_class)->button_press_event (widget, event);
-}
-
-static void
-glade_palette_item_class_init (GladePaletteItemClass *klass)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- object_class = G_OBJECT_CLASS (klass);
- widget_class = GTK_WIDGET_CLASS (klass);
-
- object_class->get_property = glade_palette_item_get_property;
- object_class->set_property = glade_palette_item_set_property;
- object_class->dispose = glade_palette_item_dispose;
-
- widget_class->button_press_event = glade_palette_item_button_press;
-
- g_object_class_install_property (object_class,
- PROP_ADAPTOR,
- g_param_spec_object ("adaptor",
- "Adaptor",
- "The widget adaptor associated with this item",
- GLADE_TYPE_WIDGET_ADAPTOR,
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE ));
-
- g_object_class_install_property (object_class,
- PROP_APPEARANCE,
- g_param_spec_enum ("appearance",
- "Appearance",
- "The appearance of the item",
- GLADE_TYPE_ITEM_APPEARANCE,
- GLADE_ITEM_ICON_ONLY,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_APPEARANCE,
- g_param_spec_boolean ("use-small-icon",
- "Use Small Icon",
- "Whether to use small icon",
- FALSE,
- G_PARAM_READWRITE));
-
- g_type_class_add_private (klass, sizeof (GladePaletteItemPrivate));
-}
-
-
-static void
-glade_palette_item_init (GladePaletteItem *item)
-{
- GladePaletteItemPrivate *priv;
-
- priv = item->priv = GLADE_PALETTE_ITEM_GET_PRIVATE (item);
-
- priv->label = NULL;
- priv->adaptor = NULL;
- priv->use_small_icon = FALSE;
- priv->appearance = 0;
-
- priv->alignment = gtk_alignment_new (0.0, 0.5, 0.5, 0.5);
- g_object_ref_sink (priv->alignment);
- gtk_widget_show (GTK_WIDGET (priv->alignment));
-
- priv->hbox = gtk_hbox_new (FALSE, 6);
- g_object_ref_sink (priv->hbox);
- gtk_widget_show (GTK_WIDGET (priv->hbox));
-
- priv->icon = gtk_image_new ();
- g_object_ref_sink (priv->icon);
- gtk_widget_show (GTK_WIDGET (priv->icon));
-
- priv->label = gtk_label_new (NULL);
- g_object_ref_sink (priv->label);
- gtk_widget_show (GTK_WIDGET (priv->label));
-
- gtk_container_add (GTK_CONTAINER (priv->alignment), priv->hbox);
-
- gtk_button_set_relief (GTK_BUTTON (item), GTK_RELIEF_NONE);
- gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (item), FALSE);
-}
-
-/**
- * glade_palette_item_new:
- * @adaptor: A #GladeWidgetAdaptor
- * @group: The group to add this item to.
- * @appearance: The appearance of the item
- *
- * Returns: A #GtkWidget
- */
-GtkWidget*
-glade_palette_item_new (GladeWidgetAdaptor *adaptor)
-{
- GladePaletteItem *item;
-
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
-
- item = g_object_new (GLADE_TYPE_PALETTE_ITEM,
- "adaptor", adaptor,
- "appearance", GLADE_ITEM_ICON_ONLY,
- NULL);
-
- return GTK_WIDGET (item);
-}
-
-/**
- * glade_palette_item_get_appearance:
- * @palette: A #GladePaletteItem
- *
- * Returns: the appearance of the item.
- */
-GladeItemAppearance
-glade_palette_item_get_appearance (GladePaletteItem *item)
-{
- GladePaletteItemPrivate *priv;
-
- g_return_val_if_fail (GLADE_IS_PALETTE_ITEM (item), FALSE);
- priv = GLADE_PALETTE_ITEM_GET_PRIVATE (item);
-
- return priv->appearance;
-}
-
-gboolean
-glade_palette_item_get_use_small_icon (GladePaletteItem *item)
-{
- GladePaletteItemPrivate *priv;
-
- g_return_val_if_fail (GLADE_IS_PALETTE_ITEM (item), FALSE);
- priv = GLADE_PALETTE_ITEM_GET_PRIVATE (item);
-
- return priv->use_small_icon;
-}
-
-/**
- * glade_palette_item_get_adaptor:
- * @palette: A #GladePaletteItem
- *
- * Returns: the #GladeWidgetClass associated with this item.
- */
-GladeWidgetAdaptor *
-glade_palette_item_get_adaptor (GladePaletteItem *item)
-{
- GladePaletteItemPrivate *priv;
- g_return_val_if_fail (GLADE_IS_PALETTE_ITEM (item), NULL);
- priv = GLADE_PALETTE_ITEM_GET_PRIVATE (item);
-
- return priv->adaptor;
-}
diff --git a/gladeui/glade-palette-item.h b/gladeui/glade-palette-item.h
deleted file mode 100644
index 5d06057b..00000000
--- a/gladeui/glade-palette-item.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * glade-palette-item.h
- *
- * Copyright (C) 2006 Vincent Geddes
- *
- * Authors:
- * Vincent Geddes <vgeddes@gnome.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- */
-
-#ifndef __GLADE_PALETTE_ITEM_H__
-#define __GLADE_PALETTE_ITEM_H__
-
-#include <gladeui/glade.h>
-#include <gladeui/glade-palette.h>
-#include <gladeui/glade-widget-adaptor.h>
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-#define GLADE_TYPE_PALETTE_ITEM (glade_palette_item_get_type ())
-#define GLADE_PALETTE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_PALETTE_ITEM, GladePaletteItem))
-#define GLADE_PALETTE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_PALETTE_ITEM, GladePaletteItemClass))
-#define GLADE_IS_PALETTE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_PALETTE_ITEM))
-#define GLADE_IS_PALETTE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_PALETTE_ITEM))
-#define GLADE_PALETTE_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_PALETTE_ITEM, GladePaletteItemClass))
-
-
-typedef struct _GladePaletteItem GladePaletteItem;
-typedef struct _GladePaletteItemPrivate GladePaletteItemPrivate;
-typedef struct _GladePaletteItemClass GladePaletteItemClass;
-
-struct _GladePaletteItem
-{
- GtkToggleButton parent_instance;
-
- GladePaletteItemPrivate *priv;
-
-};
-
-struct _GladePaletteItemClass
-{
- GtkToggleButtonClass parent_class;
-
-
-};
-
-GType glade_palette_item_get_type (void) G_GNUC_CONST;
-
-GtkWidget *glade_palette_item_new (GladeWidgetAdaptor *adaptor);
-
-GladeWidgetAdaptor *glade_palette_item_get_adaptor (GladePaletteItem *item);
-
-GladeItemAppearance glade_palette_item_get_appearance (GladePaletteItem *item);
-
-void glade_palette_item_set_appearance (GladePaletteItem *item,
- GladeItemAppearance appearance);
-
-gboolean glade_palette_item_get_use_small_icon (GladePaletteItem *item);
-
-void glade_palette_item_set_use_small_icon (GladePaletteItem *item,
- gboolean use_small_icon);
-
-void glade_palette_item_refresh (GladePaletteItem *item);
-
-G_END_DECLS
-
-#endif /* __GLADE_PALETTE_ITEM_H__ */
diff --git a/gladeui/glade-palette.c b/gladeui/glade-palette.c
index aff2287e..f5b6a748 100644
--- a/gladeui/glade-palette.c
+++ b/gladeui/glade-palette.c
@@ -41,13 +41,11 @@
#include "glade.h"
#include "glade-app.h"
#include "glade-palette.h"
-#include "glade-palette-item.h"
-#include "glade-palette-box.h"
-#include "glade-palette-expander.h"
#include "glade-catalog.h"
#include "glade-project.h"
#include "glade-widget.h"
#include "glade-widget-adaptor.h"
+#include "glade-popup.h"
#include <glib/gi18n-lib.h>
#include <gdk/gdk.h>
@@ -64,24 +62,18 @@ struct _GladePalettePrivate
GtkWidget *selector_button;
GtkWidget *create_root_button;
- GtkWidget *tray; /* Where all the item groups are contained */
-
- GladePaletteItem *current_item; /* The currently selected item */
-
- GSList *sections; /* List of GladePaletteExpanders */
-
- GtkSizeGroup *size_group; /* All items have the same dimensions */
+ GtkWidget *toolpalette;
+ GtkWidget *current_item;
GladeItemAppearance item_appearance;
-
- gboolean use_small_item_icons;
-
- gboolean sticky_selection_mode; /* whether sticky_selection mode has been enabled */
+ gboolean use_small_item_icons;
+ gboolean sticky_selection_mode; /* whether sticky_selection mode has been enabled */
};
enum
{
TOGGLED,
+ REFRESH,
LAST_SIGNAL
};
@@ -111,7 +103,7 @@ selector_button_toggled_cb (GtkToggleButton *button, GladePalette *palette)
{
glade_palette_deselect_current_item (palette, FALSE);
}
- else if (glade_palette_get_current_item (palette) == FALSE)
+ else if (glade_palette_get_current_item (palette) == NULL)
{
gtk_toggle_button_set_active (button, TRUE);
}
@@ -124,7 +116,7 @@ glade_palette_set_catalogs (GladePalette *palette, GList *catalogs)
GList *l;
g_return_if_fail (GLADE_IS_PALETTE (palette));
- priv = GLADE_PALETTE_GET_PRIVATE (palette);
+ priv = palette->priv;
priv->catalogs = catalogs;
@@ -141,9 +133,6 @@ glade_palette_set_catalogs (GladePalette *palette, GList *catalogs)
}
}
- gtk_widget_show_all (priv->tray);
-
- g_object_unref (priv->size_group);
}
/**
@@ -158,7 +147,7 @@ glade_palette_set_item_appearance (GladePalette *palette, GladeItemAppearance it
{
GladePalettePrivate *priv;
g_return_if_fail (GLADE_IS_PALETTE (palette));
- priv = GLADE_PALETTE_GET_PRIVATE (palette);
+ priv = palette->priv;
if (priv->item_appearance != item_appearance)
{
@@ -182,7 +171,7 @@ glade_palette_set_use_small_item_icons (GladePalette *palette, gboolean use_smal
{
GladePalettePrivate *priv;
g_return_if_fail (GLADE_IS_PALETTE (palette));
- priv = GLADE_PALETTE_GET_PRIVATE (palette);
+ priv = palette->priv;
if (priv->use_small_item_icons != use_small_item_icons)
{
@@ -208,7 +197,7 @@ glade_palette_set_show_selector_button (GladePalette *palette, gboolean show_sel
{
GladePalettePrivate *priv;
g_return_if_fail (GLADE_IS_PALETTE (palette));
- priv = GLADE_PALETTE_GET_PRIVATE (palette);
+ priv = palette->priv;
if (gtk_widget_get_visible (priv->selector_hbox) != show_selector_button)
{
@@ -267,12 +256,17 @@ glade_palette_get_property (GObject *object,
GParamSpec *pspec)
{
GladePalette *palette = GLADE_PALETTE (object);
- GladePalettePrivate *priv = GLADE_PALETTE_GET_PRIVATE (palette);
+ GladePalettePrivate *priv = palette->priv;
switch (prop_id)
{
case PROP_CURRENT_ITEM:
- g_value_set_pointer (value, (gpointer) glade_palette_item_get_adaptor (priv->current_item));
+ if (priv->current_item)
+ g_value_set_pointer (value, g_object_get_data
+ (G_OBJECT (priv->current_item), "glade-widget-adaptor"));
+ else
+ g_value_set_pointer (value, NULL);
+
break;
case PROP_USE_SMALL_ITEM_ICONS:
g_value_set_boolean (value, priv->use_small_item_icons);
@@ -297,15 +291,9 @@ glade_palette_dispose (GObject *object)
{
GladePalettePrivate *priv;
- priv = GLADE_PALETTE_GET_PRIVATE (object);
+ priv = GLADE_PALETTE (object)->priv;
priv->catalogs = NULL;
-
- if (priv->tray)
- {
- g_object_unref (priv->tray);
- priv->tray = NULL;
- }
G_OBJECT_CLASS (glade_palette_parent_class)->dispose (object);
}
@@ -315,9 +303,7 @@ glade_palette_finalize (GObject *object)
{
GladePalettePrivate *priv;
- priv = GLADE_PALETTE_GET_PRIVATE (object);
-
- g_slist_free (priv->sections);
+ priv = GLADE_PALETTE (object)->priv;
G_OBJECT_CLASS (glade_palette_parent_class)->finalize (object);
}
@@ -376,6 +362,16 @@ glade_palette_class_init (GladePaletteClass *klass)
G_TYPE_NONE,
0);
+ glade_palette_signals[REFRESH] =
+ g_signal_new ("refresh",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladePaletteClass, refresh),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
g_object_class_install_property (object_class,
PROP_ITEM_APPEARANCE,
g_param_spec_enum ("item-appearance",
@@ -439,8 +435,9 @@ glade_palette_on_button_toggled (GtkWidget *button, GladePalette *palette)
gboolean is_root_active;
g_return_if_fail (GLADE_IS_PALETTE (palette));
- g_return_if_fail (GTK_IS_TOGGLE_BUTTON (button));
- priv = GLADE_PALETTE_GET_PRIVATE (palette);
+ g_return_if_fail (GTK_IS_TOGGLE_TOOL_BUTTON (button) ||
+ GTK_IS_TOGGLE_BUTTON (button));
+ priv = palette->priv;
is_root_active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->create_root_button));
@@ -450,12 +447,14 @@ glade_palette_on_button_toggled (GtkWidget *button, GladePalette *palette)
glade_palette_create_root_widget (palette, adaptor);
return;
}
-
- if (!GLADE_IS_PALETTE_ITEM (button))
- return;
+
+ g_return_if_fail (GTK_IS_TOGGLE_TOOL_BUTTON (button));
+
+ adaptor = g_object_get_data (G_OBJECT (button), "glade-widget-adaptor");
+ if (!adaptor) return;
/* if we are toggling currently active item into non-active state */
- if (priv->current_item == GLADE_PALETTE_ITEM (button))
+ if (priv->current_item == button)
{
priv->current_item = NULL;
g_object_notify (G_OBJECT (palette), "current-item");
@@ -472,17 +471,16 @@ glade_palette_on_button_toggled (GtkWidget *button, GladePalette *palette)
}
/* now we are interested only in buttons which toggle from inactive to active */
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
+ if (!gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (button)))
return;
- if (priv->current_item && (GLADE_PALETTE_ITEM (button) != priv->current_item))
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->current_item), FALSE);
+ if (priv->current_item && (button != priv->current_item))
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (priv->current_item), FALSE);
- priv->current_item = GLADE_PALETTE_ITEM (button);
+ priv->current_item = button;
if (is_root_active)
{
- adaptor = glade_palette_item_get_adaptor (GLADE_PALETTE_ITEM (button));
glade_palette_create_root_widget (palette, adaptor);
return;
}
@@ -494,7 +492,6 @@ glade_palette_on_button_toggled (GtkWidget *button, GladePalette *palette)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->selector_button), FALSE);
/* check whether to enable sticky selection */
- adaptor = glade_palette_item_get_adaptor (GLADE_PALETTE_ITEM (button));
gdk_window_get_pointer (gtk_widget_get_window (button), NULL, NULL, &mask);
priv->sticky_selection_mode = (!GWA_IS_TOPLEVEL (adaptor)) && (mask & GDK_CONTROL_MASK);
@@ -502,23 +499,94 @@ glade_palette_on_button_toggled (GtkWidget *button, GladePalette *palette)
}
+static void
+glade_palette_item_refresh (GtkWidget *item)
+{
+ GladeProject *project;
+ GladeSupportMask support;
+ GladeWidgetAdaptor *adaptor;
+ gchar *warning, *text;
+
+ adaptor = g_object_get_data (G_OBJECT (item), "glade-widget-adaptor");
+ g_assert (adaptor);
+
+ if ((project = glade_app_check_get_project ()) &&
+ (warning =
+ glade_project_verify_widget_adaptor (project, adaptor, &support)) != NULL)
+ {
+ /* set sensitivity */
+ gtk_widget_set_sensitive (GTK_WIDGET (item),
+ !(support & (GLADE_SUPPORT_LIBGLADE_UNSUPPORTED |
+ GLADE_SUPPORT_LIBGLADE_ONLY |
+ GLADE_SUPPORT_MISMATCH)));
+
+ if (support & GLADE_SUPPORT_DEPRECATED)
+ /* XXX Todo, draw a cross overlaying the widget icon */
+ gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON (item), GTK_STOCK_DIALOG_WARNING);
+ else
+ gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), adaptor->icon_name);
+
+ /* prepend widget title */
+ text = g_strdup_printf ("%s: %s", adaptor->title, warning);
+ gtk_widget_set_tooltip_text (item, text);
+ g_free (text);
+ g_free (warning);
+ }
+ else
+ {
+ gtk_widget_set_tooltip_text (GTK_WIDGET (item), adaptor->title);
+ gtk_widget_set_sensitive (GTK_WIDGET (item), TRUE);
+ gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), adaptor->icon_name);
+ }
+}
+
+
+static gint
+glade_palette_item_button_press (GtkWidget *button,
+ GdkEventButton *event,
+ GladePalette *item)
+{
+ if (glade_popup_is_popup_event (event))
+ {
+ GladeWidgetAdaptor *adaptor;
+
+ adaptor = g_object_get_data (G_OBJECT (item), "glade-widget-adaptor");
+
+ glade_popup_palette_pop (adaptor, event);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static GtkWidget*
glade_palette_new_item (GladePalette *palette, GladeWidgetAdaptor *adaptor)
{
- GladePalettePrivate *priv;
- GtkWidget *item;
+ GtkWidget *item, *button;
- g_return_val_if_fail (GLADE_IS_PALETTE (palette), NULL);
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- priv = GLADE_PALETTE_GET_PRIVATE (palette);
+ item = (GtkWidget *)gtk_toggle_tool_button_new ();
+ g_object_set_data (G_OBJECT (item), "glade-widget-adaptor", adaptor);
- item = glade_palette_item_new (adaptor);
+ button = gtk_bin_get_child (GTK_BIN (item));
+ g_assert (GTK_IS_BUTTON (button));
- glade_palette_item_set_appearance (GLADE_PALETTE_ITEM (item), priv->item_appearance);
+ gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), adaptor->title);
+ glade_palette_item_refresh (item);
+ /* Update selection when the item is pushed */
g_signal_connect (G_OBJECT (item), "toggled",
G_CALLBACK (glade_palette_on_button_toggled), palette);
+ /* Update palette item when active project state changes */
+ g_signal_connect_swapped (G_OBJECT (palette), "refresh",
+ G_CALLBACK (glade_palette_item_refresh), item);
+
+ /* Fire Glade palette popup menus */
+ g_signal_connect (G_OBJECT (button), "button-press-event",
+ G_CALLBACK (glade_palette_item_button_press), item);
+
+ gtk_widget_show (item);
+
return item;
}
@@ -526,96 +594,68 @@ static GtkWidget*
glade_palette_new_item_group (GladePalette *palette, GladeWidgetGroup *group)
{
GladePalettePrivate *priv;
- GtkWidget *expander;
- GtkWidget *box;
- GtkWidget *item;
- GList *l;
+ GtkWidget *item_group;
+ GtkWidget *item;
+ GList *l;
- g_return_val_if_fail (GLADE_IS_PALETTE (palette), NULL);
- g_return_val_if_fail (group != NULL, NULL);
- priv = GLADE_PALETTE_GET_PRIVATE (palette);
+ priv = palette->priv;
- box = glade_palette_box_new ();
+ item_group = gtk_tool_item_group_new (glade_widget_group_get_title (group));
/* Go through all the widget classes in this catalog. */
for (l = (GList *) glade_widget_group_get_adaptors (group); l; l = l->next)
{
GladeWidgetAdaptor *adaptor = GLADE_WIDGET_ADAPTOR (l->data);
- /* Create new item */
+ /* Create/append new item */
item = glade_palette_new_item (palette, adaptor);
- gtk_size_group_add_widget (priv->size_group, GTK_WIDGET (item));
- gtk_container_add (GTK_CONTAINER (box), item);
-
+ gtk_tool_item_group_insert (GTK_TOOL_ITEM_GROUP (item_group),
+ GTK_TOOL_ITEM (item), -1);
}
- /* Put items box in a expander */
- expander = glade_palette_expander_new (glade_widget_group_get_title (group));
- glade_palette_expander_set_spacing (GLADE_PALETTE_EXPANDER (expander), 2);
- glade_palette_expander_set_use_markup (GLADE_PALETTE_EXPANDER (expander), TRUE);
- gtk_container_set_border_width (GTK_CONTAINER (expander), 0);
-
/* set default expanded state */
- glade_palette_expander_set_expanded (GLADE_PALETTE_EXPANDER (expander),
- glade_widget_group_get_expanded (group));
+ gtk_tool_item_group_set_collapsed (GTK_TOOL_ITEM_GROUP (item_group),
+ glade_widget_group_get_expanded (group) == FALSE);
- gtk_container_add (GTK_CONTAINER (expander), box);
+ gtk_widget_show (item_group);
- return expander;
+ return item_group;
}
static void
glade_palette_append_item_group (GladePalette *palette,
GladeWidgetGroup *group)
{
- GladePalettePrivate *priv;
- GtkWidget *expander;
-
- g_return_if_fail (GLADE_IS_PALETTE (palette));
- g_return_if_fail (group != NULL);
- priv = GLADE_PALETTE_GET_PRIVATE (palette);
-
- expander = glade_palette_new_item_group (palette, group);
-
- priv->sections = g_slist_append (priv->sections, expander);
-
- gtk_box_pack_start (GTK_BOX (priv->tray), expander, FALSE, FALSE, 0);
+ GladePalettePrivate *priv = palette->priv;
+ GtkWidget *item_group;
+ if ((item_group = glade_palette_new_item_group (palette, group)) != NULL)
+ gtk_container_add (GTK_CONTAINER (priv->toolpalette), item_group);
}
static void
glade_palette_update_appearance (GladePalette *palette)
{
GladePalettePrivate *priv;
- GtkWidget *viewport;
- GSList *sections;
- GList *items, *i;
+ GtkToolbarStyle style;
+ GtkIconSize size;
- priv = GLADE_PALETTE_GET_PRIVATE (palette);
+ priv = palette->priv;
- for (sections = priv->sections; sections; sections = sections->next)
- {
- items = gtk_container_get_children (GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (sections->data))));
+ size = priv->use_small_item_icons ? GTK_ICON_SIZE_MENU : GTK_ICON_SIZE_BUTTON;
- for (i = items; i; i = i->next)
- {
- glade_palette_item_set_appearance (GLADE_PALETTE_ITEM (i->data), priv->item_appearance);
- glade_palette_item_set_use_small_icon (GLADE_PALETTE_ITEM (i->data), priv->use_small_item_icons);
- }
- g_list_free (items);
+ switch (priv->item_appearance)
+ {
+ case GLADE_ITEM_ICON_AND_LABEL: style = GTK_TOOLBAR_BOTH; break;
+ case GLADE_ITEM_ICON_ONLY: style = GTK_TOOLBAR_ICONS; break;
+ case GLADE_ITEM_LABEL_ONLY: style = GTK_TOOLBAR_TEXT; break;
+ default:
+ g_assert_not_reached ();
+ break;
}
- /* FIXME: Removing and then adding the tray again to the Viewport
- * is the only way I can get the Viewport to
- * respect the new width of the tray.
- * There should be a better solution.
- */
- viewport = gtk_widget_get_parent (priv->tray);
- if (viewport != NULL)
- {
- gtk_container_remove (GTK_CONTAINER (viewport), priv->tray);
- gtk_container_add (GTK_CONTAINER (viewport), priv->tray);
- }
+ gtk_tool_palette_set_icon_size (GTK_TOOL_PALETTE (priv->toolpalette), size);
+ gtk_tool_palette_set_style (GTK_TOOL_PALETTE (priv->toolpalette), style);
}
static GtkWidget*
@@ -675,7 +715,6 @@ glade_palette_init (GladePalette *palette)
priv->catalogs = NULL;
priv->current_item = NULL;
- priv->sections = NULL;
priv->item_appearance = GLADE_ITEM_ICON_ONLY;
priv->use_small_item_icons = FALSE;
priv->sticky_selection_mode = FALSE;
@@ -694,27 +733,21 @@ glade_palette_init (GladePalette *palette)
gtk_widget_set_tooltip_text (priv->selector_button, _("Widget selector"));
gtk_widget_set_tooltip_text (priv->create_root_button, _("Create root widget"));
- /* create size group */
- priv->size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
- gtk_size_group_set_ignore_hidden (priv->size_group, FALSE);
-
- /* add items tray (via a scrolled window) */
- priv->tray = gtk_vbox_new (FALSE, 0);
- g_object_ref_sink (G_OBJECT (priv->tray));
- gtk_container_set_border_width (GTK_CONTAINER (priv->tray), 1);
+ /* The GtkToolPalette */
+ priv->toolpalette = gtk_tool_palette_new ();
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), priv->tray);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
GTK_SHADOW_NONE);
+ gtk_container_add (GTK_CONTAINER (sw), priv->toolpalette);
gtk_box_pack_start (GTK_BOX (palette), sw, TRUE, TRUE, 0);
gtk_widget_show (sw);
- gtk_widget_show (priv->tray);
+ gtk_widget_show (priv->toolpalette);
gtk_widget_set_no_show_all (GTK_WIDGET (palette), TRUE);
}
@@ -734,14 +767,9 @@ glade_palette_get_current_item (GladePalette *palette)
g_return_val_if_fail (GLADE_IS_PALETTE (palette), NULL);
if (palette->priv->current_item)
- {
- return glade_palette_item_get_adaptor (palette->priv->current_item);
- }
- else
- {
- return NULL;
- }
+ return g_object_get_data (G_OBJECT (palette->priv->current_item), "glade-widget-adaptor");
+ return NULL;
}
/**
@@ -785,7 +813,7 @@ glade_palette_deselect_current_item (GladePalette *palette, gboolean sticky_awar
if (palette->priv->current_item)
{
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (palette->priv->current_item), FALSE);
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (palette->priv->current_item), FALSE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (palette->priv->selector_button), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (palette->priv->create_root_button), FALSE);
@@ -851,23 +879,8 @@ glade_palette_get_show_selector_button (GladePalette *palette)
void
glade_palette_refresh (GladePalette *palette)
{
- GladePalettePrivate *priv;
- GSList *sections;
- GList *items, *i;
-
g_return_if_fail (GLADE_IS_PALETTE (palette));
- priv = GLADE_PALETTE_GET_PRIVATE (palette);
-
- for (sections = priv->sections; sections; sections = sections->next)
- {
- items = gtk_container_get_children
- (GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (sections->data))));
-
- for (i = items; i; i = i->next)
- glade_palette_item_refresh (GLADE_PALETTE_ITEM (i->data));
-
- g_list_free (items);
- }
+ g_signal_emit (G_OBJECT (palette), glade_palette_signals[REFRESH], 0);
}
diff --git a/gladeui/glade-palette.h b/gladeui/glade-palette.h
index c625e26c..d6358c9a 100644
--- a/gladeui/glade-palette.h
+++ b/gladeui/glade-palette.h
@@ -57,7 +57,8 @@ struct _GladePaletteClass
{
GtkVBoxClass parent_class;
- void (*toggled) (GladePalette *palette);
+ void (* toggled) (GladePalette *palette);
+ void (* refresh) (GladePalette *palette);
};
typedef enum
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index aef431ec..7df81cd5 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -2014,7 +2014,7 @@ glade_gtk_box_get_first_blank (GtkBox *box)
child && child->data;
child = child->next, position++)
{
- GtkWidget *widget = ((GtkBoxChild *) (child->data))->widget;
+ GtkWidget *widget = child->data;
if ((gwidget = glade_widget_get_from_gobject (widget)) != NULL)
{
@@ -2213,7 +2213,7 @@ glade_gtk_box_add_child (GladeWidgetAdaptor *adaptor,
for (l = g_list_last (children); l; l = g_list_previous (l))
{
- GtkWidget *child_widget = ((GtkBoxChild *) (l->data))->widget;
+ GtkWidget *child_widget = l->data;
if (GLADE_IS_PLACEHOLDER (child_widget))
{
gtk_container_remove (GTK_CONTAINER (box), child_widget);
diff --git a/plugins/gtk+/glade-model-data.c b/plugins/gtk+/glade-model-data.c
index d9ff5c4a..1b38b34a 100644
--- a/plugins/gtk+/glade-model-data.c
+++ b/plugins/gtk+/glade-model-data.c
@@ -335,7 +335,6 @@ static gboolean
update_and_focus_data_tree_idle (GladeEditorProperty *eprop)
{
GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
- GValue value = { 0, };
eprop_data->want_focus = TRUE;
eprop_data->want_next_focus = TRUE;