summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlex Valavanis <valavanisalex@gmail.com>2011-07-10 00:56:02 +0000
committerAlex Valavanis <valavanisalex@gmail.com>2011-07-10 00:56:02 +0000
commit55fd3861b1b1cc012225ce351bc7f4bfa891e740 (patch)
tree4f39f96aa6a08ed6fd3821e596dca363427fbf80 /src
parentMerge upstream GDL 2.26.0 changes (diff)
downloadinkscape-55fd3861b1b1cc012225ce351bc7f4bfa891e740.tar.gz
inkscape-55fd3861b1b1cc012225ce351bc7f4bfa891e740.zip
Merge upstream GDL: GNOME_2_30_0
(bzr r10436)
Diffstat (limited to 'src')
-rw-r--r--src/libgdl/Makefile_insert4
-rw-r--r--src/libgdl/gdl-combo-button.c383
-rw-r--r--src/libgdl/gdl-combo-button.h63
-rw-r--r--src/libgdl/gdl-dock-item-button-image.c169
-rw-r--r--src/libgdl/gdl-dock-item-button-image.h70
-rw-r--r--src/libgdl/gdl-dock-item-grip.c584
-rw-r--r--src/libgdl/gdl-dock-item-grip.h33
-rw-r--r--src/libgdl/gdl-dock-item.c47
-rw-r--r--src/libgdl/gdl-dock-item.h19
-rw-r--r--src/libgdl/gdl-dock-layout.c208
-rw-r--r--src/libgdl/gdl-dock-master.c2
-rw-r--r--src/libgdl/gdl-dock-master.h9
-rw-r--r--src/libgdl/gdl-dock-notebook.c6
-rw-r--r--src/libgdl/gdl-dock-object.h2
-rw-r--r--src/libgdl/gdl-dock-paned.c1
-rw-r--r--src/libgdl/gdl-dock-placeholder.c5
-rw-r--r--src/libgdl/gdl-dock-placeholder.h2
-rw-r--r--src/libgdl/gdl-dock.c15
-rw-r--r--src/libgdl/gdl-stock.c126
-rw-r--r--src/libgdl/gdl-stock.h37
-rw-r--r--src/libgdl/gdl-switcher.c206
-rw-r--r--src/libgdl/gdl-switcher.h24
-rw-r--r--src/libgdl/gdl.h33
-rw-r--r--src/libgdl/test-dock.c3
24 files changed, 861 insertions, 1190 deletions
diff --git a/src/libgdl/Makefile_insert b/src/libgdl/Makefile_insert
index 2276aa801..e151fd5d6 100644
--- a/src/libgdl/Makefile_insert
+++ b/src/libgdl/Makefile_insert
@@ -16,7 +16,6 @@ libgdl_libgdl_a_SOURCES = \
libgdl/gdl-dock-tablabel.h \
libgdl/gdl-dock-placeholder.h \
libgdl/gdl-dock-bar.h \
- libgdl/gdl-stock.h \
libgdl/gdl-stock-icons.h \
libgdl/gdl-i18n.h \
libgdl/gdl-i18n.c \
@@ -24,6 +23,8 @@ libgdl_libgdl_a_SOURCES = \
libgdl/gdl-dock-master.c \
libgdl/gdl-dock.c \
libgdl/gdl-dock-item.c \
+ libgdl/gdl-dock-item-button-image.c \
+ libgdl/gdl-dock-item-button-image.h \
libgdl/gdl-dock-item-grip.h \
libgdl/gdl-dock-item-grip.c \
libgdl/gdl-dock-notebook.c \
@@ -31,7 +32,6 @@ libgdl_libgdl_a_SOURCES = \
libgdl/gdl-dock-tablabel.c \
libgdl/gdl-dock-placeholder.c \
libgdl/gdl-dock-bar.c \
- libgdl/gdl-stock.c \
libgdl/gdl-switcher.h \
libgdl/gdl-switcher.c \
libgdl/gdl-win32.h \
diff --git a/src/libgdl/gdl-combo-button.c b/src/libgdl/gdl-combo-button.c
deleted file mode 100644
index 6414a8110..000000000
--- a/src/libgdl/gdl-combo-button.c
+++ /dev/null
@@ -1,383 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- * gdl-combo-button.c
- *
- * Copyright (C) 2003 Jeroen Zwartepoorte
- *
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gtk/gtk.h>
-#include "gdl-tools.h"
-#include "gdl-combo-button.h"
-
-struct _GdlComboButtonPrivate {
- GtkWidget *default_button;
- GtkWidget *image;
- GtkWidget *label;
- GtkWidget *menu_button;
- GtkWidget *menu;
- gboolean menu_popped_up;
-};
-
-GDL_CLASS_BOILERPLATE (GdlComboButton, gdl_combo_button, GtkHBox, GTK_TYPE_HBOX);
-
-static void
-default_button_clicked_cb (GtkButton *button,
- gpointer user_data)
-{
- GdlComboButton *combo;
- GdlComboButtonPrivate *priv;
-
- combo = GDL_COMBO_BUTTON (user_data);
- priv = combo->priv;
-
- if (!priv->menu_popped_up)
- g_signal_emit_by_name (G_OBJECT (combo),
- "activate-default", NULL);
-}
-
-static gboolean
-default_button_press_event_cb (GtkWidget *widget,
- GdkEventButton *event,
- gpointer user_data)
-{
- GdlComboButton *combo_button;
- GdlComboButtonPrivate *priv;
-
- combo_button = GDL_COMBO_BUTTON (user_data);
- priv = combo_button->priv;
-
- if (event->type == GDK_BUTTON_PRESS && event->button == 1) {
- GTK_BUTTON (priv->menu_button)->button_down = TRUE;
- gtk_button_pressed (GTK_BUTTON (priv->menu_button));
- }
-
- return FALSE;
-}
-
-static gboolean
-default_button_release_event_cb (GtkWidget *widget,
- GdkEventButton *event,
- gpointer user_data)
-{
- GdlComboButton *combo_button;
- GdlComboButtonPrivate *priv;
-
- combo_button = GDL_COMBO_BUTTON (user_data);
- priv = combo_button->priv;
-
- if (event->button == 1) {
- gtk_button_released (GTK_BUTTON (priv->menu_button));
- }
-
- return FALSE;
-}
-
-static gboolean
-button_enter_notify_cb (GtkWidget *widget,
- GdkEventCrossing *event,
- gpointer user_data)
-{
- GdlComboButton *combo_button;
- GdlComboButtonPrivate *priv;
-
- combo_button = GDL_COMBO_BUTTON (user_data);
- priv = combo_button->priv;
-
- if (event->detail != GDK_NOTIFY_INFERIOR) {
- GTK_BUTTON (priv->default_button)->in_button = TRUE;
- GTK_BUTTON (priv->menu_button)->in_button = TRUE;
- gtk_button_enter (GTK_BUTTON (priv->default_button));
- gtk_button_enter (GTK_BUTTON (priv->menu_button));
- }
-
- return TRUE;
-}
-
-static gboolean
-button_leave_notify_cb (GtkWidget *widget,
- GdkEventCrossing *event,
- gpointer user_data)
-{
- GdlComboButton *combo_button;
- GdlComboButtonPrivate *priv;
-
- combo_button = GDL_COMBO_BUTTON (user_data);
- priv = combo_button->priv;
-
- if (priv->menu_popped_up)
- return TRUE;
-
- if (event->detail != GDK_NOTIFY_INFERIOR) {
- GTK_BUTTON (priv->default_button)->in_button = FALSE;
- GTK_BUTTON (priv->menu_button)->in_button = FALSE;
- gtk_button_leave (GTK_BUTTON (priv->default_button));
- gtk_button_leave (GTK_BUTTON (priv->menu_button));
- }
-
- return TRUE;
-}
-
-static void
-menu_position_func (GtkMenu *menu,
- gint *x_return,
- gint *y_return,
- gboolean *push_in,
- gpointer user_data)
-{
- GdlComboButton *combo_button;
- GdlComboButtonPrivate *priv;
- GtkAllocation *allocation;
-
- combo_button = GDL_COMBO_BUTTON (user_data);
- priv = combo_button->priv;
- allocation = &(priv->default_button->allocation);
-
- gdk_window_get_origin (priv->default_button->window, x_return, y_return);
-
- *x_return += allocation->x;
- *y_return += allocation->height;
-}
-
-static gboolean
-menu_button_press_event_cb (GtkWidget *widget,
- GdkEventButton *event,
- gpointer user_data)
-{
- GdlComboButton *combo_button;
- GdlComboButtonPrivate *priv;
-
- combo_button = GDL_COMBO_BUTTON (user_data);
- priv = combo_button->priv;
-
- if (event->type == GDK_BUTTON_PRESS &&
- (event->button == 1 || event->button == 3)) {
- GTK_BUTTON (priv->menu_button)->button_down = TRUE;
-
- gtk_button_pressed (GTK_BUTTON (priv->menu_button));
-
- priv->menu_popped_up = TRUE;
- gtk_menu_popup (GTK_MENU (priv->menu), NULL, NULL,
- menu_position_func, combo_button,
- event->button, event->time);
- }
-
- return TRUE;
-}
-
-static void
-menu_deactivate_cb (GtkMenuShell *menu_shell,
- gpointer user_data)
-{
- GdlComboButton *combo_button;
- GdlComboButtonPrivate *priv;
-
- combo_button = GDL_COMBO_BUTTON (user_data);
- priv = combo_button->priv;
-
- priv->menu_popped_up = FALSE;
-
- GTK_BUTTON (priv->menu_button)->button_down = FALSE;
- GTK_BUTTON (priv->menu_button)->in_button = FALSE;
- GTK_BUTTON (priv->default_button)->in_button = FALSE;
- gtk_button_leave (GTK_BUTTON (priv->menu_button));
- gtk_button_leave (GTK_BUTTON (priv->default_button));
- gtk_button_clicked (GTK_BUTTON (priv->menu_button));
-}
-
-static void
-menu_detacher (GtkWidget *widget,
- GtkMenu *menu)
-{
- GdlComboButton *combo_button;
-
- combo_button = GDL_COMBO_BUTTON (widget);
-
- g_signal_handlers_disconnect_by_func (G_OBJECT (menu),
- menu_deactivate_cb,
- combo_button);
- combo_button->priv->menu = NULL;
-}
-
-static void
-gdl_combo_button_destroy (GtkObject *object)
-{
- GdlComboButton *combo_button;
- GdlComboButtonPrivate *priv;
-
- combo_button = GDL_COMBO_BUTTON (object);
- priv = combo_button->priv;
-
- if (priv) {
- g_free (priv);
- combo_button->priv = NULL;
- }
-
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-static void
-gdl_combo_button_class_init (GdlComboButtonClass *klass)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- parent_class = g_type_class_peek_parent (klass);
- object_class = GTK_OBJECT_CLASS (klass);
- widget_class = GTK_WIDGET_CLASS (klass);
-
- object_class->destroy = gdl_combo_button_destroy;
-
- g_signal_new ("activate-default",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GdlComboButtonClass, activate_default),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-static void
-gdl_combo_button_instance_init (GdlComboButton *combo_button)
-{
- GdlComboButtonPrivate *priv;
- GtkWidget *hbox, *align, *arrow;
-
- priv = g_new (GdlComboButtonPrivate, 1);
- combo_button->priv = priv;
-
- priv->menu = NULL;
- priv->menu_popped_up = FALSE;
-
- priv->default_button = gtk_button_new ();
- gtk_button_set_relief (GTK_BUTTON (priv->default_button), GTK_RELIEF_NONE);
-
- /* Following code copied from gtk_button_construct_child. */
- priv->label = gtk_label_new ("");
- gtk_label_set_use_underline (GTK_LABEL (priv->label), TRUE);
- gtk_label_set_mnemonic_widget (GTK_LABEL (priv->label),
- priv->default_button);
-
- priv->image = gtk_image_new ();
- hbox = gtk_hbox_new (FALSE, 2);
-
- align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
-
- gtk_box_pack_start (GTK_BOX (hbox), priv->image, FALSE, FALSE, 0);
- gtk_box_pack_end (GTK_BOX (hbox), priv->label, FALSE, FALSE, 0);
-
- gtk_container_add (GTK_CONTAINER (priv->default_button), align);
- gtk_container_add (GTK_CONTAINER (align), hbox);
- /* End copied block. */
-
- gtk_box_pack_start (GTK_BOX (combo_button), priv->default_button,
- FALSE, FALSE, 0);
- gtk_widget_show_all (priv->default_button);
-
- priv->menu_button = gtk_button_new ();
- gtk_button_set_relief (GTK_BUTTON (priv->menu_button), GTK_RELIEF_NONE);
- arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
- gtk_container_add (GTK_CONTAINER (priv->menu_button), arrow);
- gtk_box_pack_start (GTK_BOX (combo_button), priv->menu_button, FALSE,
- FALSE, 0);
- gtk_widget_show_all (priv->menu_button);
-
- /* Default button. */
- g_signal_connect (G_OBJECT (priv->default_button), "clicked",
- G_CALLBACK (default_button_clicked_cb), combo_button);
- g_signal_connect (G_OBJECT (priv->default_button), "button_press_event",
- G_CALLBACK (default_button_press_event_cb), combo_button);
- g_signal_connect (G_OBJECT (priv->default_button), "button_release_event",
- G_CALLBACK (default_button_release_event_cb), combo_button);
- g_signal_connect (G_OBJECT (priv->default_button), "enter_notify_event",
- G_CALLBACK (button_enter_notify_cb), combo_button);
- g_signal_connect (G_OBJECT (priv->default_button), "leave_notify_event",
- G_CALLBACK (button_leave_notify_cb), combo_button);
-
- /* Menu button. */
- g_signal_connect (G_OBJECT (priv->menu_button), "button_press_event",
- G_CALLBACK (menu_button_press_event_cb), combo_button);
- g_signal_connect (G_OBJECT (priv->menu_button), "enter_notify_event",
- G_CALLBACK (button_enter_notify_cb), combo_button);
- g_signal_connect (G_OBJECT (priv->menu_button), "leave_notify_event",
- G_CALLBACK (button_leave_notify_cb), combo_button);
-}
-
-GtkWidget *
-gdl_combo_button_new (void)
-{
- GtkWidget *combo_button;
-
- combo_button = GTK_WIDGET (g_object_new (GDL_TYPE_COMBO_BUTTON, NULL));
-
- return combo_button;
-}
-
-void
-gdl_combo_button_set_icon (GdlComboButton *combo_button,
- GdkPixbuf *pixbuf)
-{
- GdlComboButtonPrivate *priv;
-
- g_return_if_fail (GDL_IS_COMBO_BUTTON (combo_button));
- g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
-
- priv = combo_button->priv;
-
- gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), pixbuf);
-}
-
-void
-gdl_combo_button_set_label (GdlComboButton *combo_button,
- const gchar *label)
-{
- GdlComboButtonPrivate *priv;
-
- g_return_if_fail (GDL_IS_COMBO_BUTTON (combo_button));
- g_return_if_fail (label != NULL);
-
- priv = combo_button->priv;
-
- gtk_label_set_text (GTK_LABEL (priv->label), label);
-}
-
-void
-gdl_combo_button_set_menu (GdlComboButton *combo_button,
- GtkMenu *menu)
-{
- GdlComboButtonPrivate *priv;
-
- g_return_if_fail (GDL_IS_COMBO_BUTTON (combo_button));
- g_return_if_fail (GTK_IS_MENU (menu));
-
- priv = combo_button->priv;
-
- if (priv->menu != NULL)
- gtk_menu_detach (GTK_MENU (priv->menu));
-
- priv->menu = GTK_WIDGET (menu);
- if (menu == NULL)
- return;
-
- gtk_menu_attach_to_widget (menu, GTK_WIDGET (combo_button), menu_detacher);
-
- g_signal_connect (G_OBJECT (menu), "deactivate",
- G_CALLBACK (menu_deactivate_cb), combo_button);
-}
diff --git a/src/libgdl/gdl-combo-button.h b/src/libgdl/gdl-combo-button.h
deleted file mode 100644
index 2f9c3ca2c..000000000
--- a/src/libgdl/gdl-combo-button.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- * gdl-combo-button.h
- *
- * Copyright (C) 2003 Jeroen Zwartepoorte
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef _GDL_COMBO_BUTTON_H_
-#define _GDL_COMBO_BUTTON_H_
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-#define GDL_TYPE_COMBO_BUTTON (gdl_combo_button_get_type ())
-#define GDL_COMBO_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_COMBO_BUTTON, GdlComboButton))
-#define GDL_COMBO_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_COMBO_BUTTON, GdlComboButtonClass))
-#define GDL_IS_COMBO_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_COMBO_BUTTON))
-#define GDL_IS_COMBO_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GDL_TYPE_COMBO_BUTTON))
-
-typedef struct _GdlComboButton GdlComboButton;
-typedef struct _GdlComboButtonPrivate GdlComboButtonPrivate;
-typedef struct _GdlComboButtonClass GdlComboButtonClass;
-
-struct _GdlComboButton {
- GtkHBox parent;
-
- GdlComboButtonPrivate *priv;
-};
-
-struct _GdlComboButtonClass {
- GtkHBoxClass parent_class;
-
- /* Signals. */
- void (* activate_default) (GdlComboButton *combo_button);
-};
-
-GType gdl_combo_button_get_type (void);
-GtkWidget *gdl_combo_button_new (void);
-
-void gdl_combo_button_set_icon (GdlComboButton *combo_button,
- GdkPixbuf *pixbuf);
-void gdl_combo_button_set_label (GdlComboButton *combo_button,
- const gchar *label);
-void gdl_combo_button_set_menu (GdlComboButton *combo_button,
- GtkMenu *menu);
-
-G_END_DECLS
-
-#endif /* _GDL_COMBO_BUTTON_H_ */
diff --git a/src/libgdl/gdl-dock-item-button-image.c b/src/libgdl/gdl-dock-item-button-image.c
new file mode 100644
index 000000000..f115c652c
--- /dev/null
+++ b/src/libgdl/gdl-dock-item-button-image.c
@@ -0,0 +1,169 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * gdl-dock-item-button-image.c
+ *
+ * Author: Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "gdl-dock-item-button-image.h"
+
+#include <math.h>
+#include "gdl-tools.h"
+
+#define ICON_SIZE 12
+
+GDL_CLASS_BOILERPLATE (GdlDockItemButtonImage,
+ gdl_dock_item_button_image,
+ GtkWidget, GTK_TYPE_WIDGET);
+
+static gint
+gdl_dock_item_button_image_expose (GtkWidget *widget,
+ GdkEventExpose *event)
+{
+ GdlDockItemButtonImage *button_image;
+ GtkStyle *style;
+ GdkColor *color;
+
+ g_return_val_if_fail (widget != NULL, 0);
+ button_image = GDL_DOCK_ITEM_BUTTON_IMAGE (widget);
+
+ cairo_t *cr = gdk_cairo_create (event->window);
+ cairo_translate (cr, event->area.x, event->area.y);
+
+ /* Set up the pen */
+ cairo_set_line_width(cr, 1.0);
+
+ style = gtk_widget_get_style (widget);
+ g_return_if_fail (style != NULL);
+ color = &style->fg[GTK_STATE_NORMAL];
+ cairo_set_source_rgba(cr, color->red / 65535.0,
+ color->green / 65535.0, color->blue / 65535.0, 0.55);
+
+ /* Draw the icon border */
+ cairo_move_to (cr, 10.5, 2.5);
+ cairo_arc (cr, 10.5, 4.5, 2, -0.5 * M_PI, 0);
+ cairo_line_to (cr, 12.5, 10.5);
+ cairo_arc (cr, 10.5, 10.5, 2, 0, 0.5 * M_PI);
+ cairo_line_to (cr, 4.5, 12.5);
+ cairo_arc (cr, 4.5, 10.5, 2, 0.5 * M_PI, M_PI);
+ cairo_line_to (cr, 2.5, 4.5);
+ cairo_arc (cr, 4.5, 4.5, 2, M_PI, 1.5 * M_PI);
+ cairo_close_path (cr);
+
+ cairo_stroke (cr);
+
+ /* Draw the icon */
+ cairo_new_path (cr);
+
+ switch(button_image->image_type) {
+ case GDL_DOCK_ITEM_BUTTON_IMAGE_CLOSE:
+ cairo_move_to (cr, 4.0, 5.5);
+ cairo_line_to (cr, 4.0, 5.5);
+ cairo_line_to (cr, 6.0, 7.5);
+ cairo_line_to (cr, 4.0, 9.5);
+ cairo_line_to (cr, 5.5, 11.0);
+ cairo_line_to (cr, 7.5, 9.0);
+ cairo_line_to (cr, 9.5, 11.0);
+ cairo_line_to (cr, 11.0, 9.5);
+ cairo_line_to (cr, 9.0, 7.5);
+ cairo_line_to (cr, 11.0, 5.5);
+ cairo_line_to (cr, 9.5, 4.0);
+ cairo_line_to (cr, 7.5, 6.0);
+ cairo_line_to (cr, 5.5, 4.0);
+ cairo_close_path (cr);
+ break;
+
+ case GDL_DOCK_ITEM_BUTTON_IMAGE_ICONIFY:
+ if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) {
+ cairo_move_to (cr, 4.5, 7.5);
+ cairo_line_to (cr, 10.0, 4.75);
+ cairo_line_to (cr, 10.0, 10.25);
+ cairo_close_path (cr);
+ } else {
+ cairo_move_to (cr, 10.5, 7.5);
+ cairo_line_to (cr, 5, 4.75);
+ cairo_line_to (cr, 5, 10.25);
+ cairo_close_path (cr);
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ cairo_fill (cr);
+
+ /* Finish up */
+ cairo_destroy (cr);
+
+ return 0;
+}
+
+static void
+gdl_dock_item_button_image_instance_init (
+ GdlDockItemButtonImage *button_image)
+{
+ GTK_WIDGET_SET_FLAGS (button_image, GTK_NO_WINDOW);
+}
+
+static void
+gdl_dock_item_button_image_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ g_return_if_fail (GDL_IS_DOCK_ITEM_BUTTON_IMAGE (widget));
+ g_return_if_fail (requisition != NULL);
+
+ requisition->width = ICON_SIZE;
+ requisition->height = ICON_SIZE;
+}
+
+static void
+gdl_dock_item_button_image_class_init (
+ GdlDockItemButtonImageClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ widget_class->expose_event =
+ gdl_dock_item_button_image_expose;
+ widget_class->size_request =
+ gdl_dock_item_button_image_size_request;
+}
+
+/* ----- Public interface ----- */
+
+/**
+ * gdl_dock_item_button_image_new:
+ * @param image_type: Specifies what type of image the widget should
+ * display
+ *
+ * Creates a new GDL dock button image object.
+ * Returns: The newly created dock item button image widget.
+ **/
+GtkWidget*
+gdl_dock_item_button_image_new (GdlDockItemButtonImageType image_type)
+{
+ GdlDockItemButtonImage *button_image = g_object_new (
+ GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE, NULL);
+ button_image->image_type = image_type;
+
+ return GTK_WIDGET (button_image);
+}
diff --git a/src/libgdl/gdl-dock-item-button-image.h b/src/libgdl/gdl-dock-item-button-image.h
new file mode 100644
index 000000000..ce0c6faaf
--- /dev/null
+++ b/src/libgdl/gdl-dock-item-button-image.h
@@ -0,0 +1,70 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * gdl-dock-item-button-image.h
+ *
+ * Author: Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _GDL_DOCK_ITEM_BUTTON_IMAGE_H_
+#define _GDL_DOCK_ITEM_BUTTON_IMAGE_H_
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+/* Standard Macros */
+#define GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE \
+ (gdl_dock_item_button_image_get_type())
+#define GDL_DOCK_ITEM_BUTTON_IMAGE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE, GdlDockItemButtonImage))
+#define GDL_DOCK_ITEM_BUTTON_IMAGE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE, GdlDockItemButtonImageClass))
+#define GDL_IS_DOCK_ITEM_BUTTON_IMAGE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE))
+#define GDL_IS_DOCK_ITEM_BUTTON_IMAGE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE))
+#define GDL_DOCK_ITEM_BUTTON_IMAGE_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE, GdlDockItemButtonImageClass))
+
+/* Data Types & Structures */
+typedef enum {
+ GDL_DOCK_ITEM_BUTTON_IMAGE_CLOSE,
+ GDL_DOCK_ITEM_BUTTON_IMAGE_ICONIFY
+} GdlDockItemButtonImageType;
+
+typedef struct _GdlDockItemButtonImage GdlDockItemButtonImage;
+typedef struct _GdlDockItemButtonImageClass GdlDockItemButtonImageClass;
+
+struct _GdlDockItemButtonImage {
+ GtkWidget parent;
+
+ GdlDockItemButtonImageType image_type;
+};
+
+struct _GdlDockItemButtonImageClass {
+ GtkWidgetClass parent_class;
+};
+
+/* Data Public Functions */
+GType gdl_dock_item_button_image_get_type (void);
+GtkWidget *gdl_dock_item_button_image_new (
+ GdlDockItemButtonImageType image_type);
+
+G_END_DECLS
+
+#endif /* _GDL_DOCK_ITEM_BUTTON_IMAGE_H_ */
diff --git a/src/libgdl/gdl-dock-item-grip.c b/src/libgdl/gdl-dock-item-grip.c
index 7f7d17ab2..c5eb6f370 100644
--- a/src/libgdl/gdl-dock-item-grip.c
+++ b/src/libgdl/gdl-dock-item-grip.c
@@ -1,13 +1,30 @@
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 8 -*- */
-/**
+/*
* gdl-dock-item-grip.c
*
- * Based on bonobo-dock-item-grip. Original copyright notice follows.
+ * Author: Michael Meeks Copyright (C) 2002 Sun Microsystems, Inc.
+ *
+ * Based on BonoboDockItemGrip. Original copyright notice follows.
+ *
+ * Copyright (C) 1998 Ettore Perazzoli
+ * Copyright (C) 1998 Elliot Lee
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ * All rights reserved.
*
- * Author:
- * Michael Meeks
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2002 Sun Microsystems, Inc.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
@@ -20,10 +37,12 @@
#include <gtk/gtk.h>
#include "gdl-dock-item.h"
#include "gdl-dock-item-grip.h"
-#include "gdl-stock.h"
+#include "gdl-dock-item-button-image.h"
+#include "gdl-switcher.h"
#include "gdl-tools.h"
#define ALIGN_BORDER 5
+#define DRAG_HANDLE_SIZE 10
enum {
PROP_0,
@@ -31,93 +50,64 @@ enum {
};
struct _GdlDockItemGripPrivate {
+ GtkWidget *label;
+
GtkWidget *close_button;
GtkWidget *iconify_button;
-
- gboolean icon_pixbuf_valid;
- GdkPixbuf *icon_pixbuf;
-
- gchar *title;
- PangoLayout *title_layout;
+
+ gboolean handle_shown;
};
GDL_CLASS_BOILERPLATE (GdlDockItemGrip, gdl_dock_item_grip,
GtkContainer, GTK_TYPE_CONTAINER);
-
-/* must be called after size_allocate */
-static void
-gdl_dock_item_grip_get_title_area (GdlDockItemGrip *grip,
- GdkRectangle *area)
-{
- GtkWidget *widget = GTK_WIDGET (grip);
- gint border = GTK_CONTAINER (grip)->border_width;
- gint alloc_height;
-
- area->width = (widget->allocation.width - 2 * border - ALIGN_BORDER);
-
- pango_layout_get_pixel_size (grip->_priv->title_layout, NULL, &alloc_height);
-
- alloc_height = MAX (grip->_priv->close_button->allocation.height, alloc_height);
- alloc_height = MAX (grip->_priv->iconify_button->allocation.height, alloc_height);
- if (gtk_widget_get_visible (grip->_priv->close_button)) {
- area->width -= grip->_priv->close_button->allocation.width;
- }
- if (gtk_widget_get_visible (grip->_priv->iconify_button)) {
- area->width -= grip->_priv->iconify_button->allocation.width;
- }
-
- area->x = widget->allocation.x + border + ALIGN_BORDER;
- area->y = widget->allocation.y + border;
- area->height = alloc_height;
-
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- area->x += (widget->allocation.width - 2 * border) - area->width;
-}
-
-static void
-ensure_title_and_icon_pixbuf (GdlDockItemGrip *grip)
+
+GtkWidget*
+gdl_dock_item_create_label_widget(GdlDockItemGrip *grip)
{
- gchar *stock_id;
+ GtkHBox *label_box;
+ GtkImage *image;
+ GtkLabel *label;
+ gchar *stock_id = NULL;
+ gchar *title = NULL;
GdkPixbuf *pixbuf;
+
+ label_box = (GtkHBox*)gtk_hbox_new (FALSE, 0);
- g_return_if_fail (GDL_IS_DOCK_ITEM_GRIP (grip));
-
- /* get long name property from the dock object */
- if (!grip->_priv->title) {
- g_object_get (G_OBJECT (grip->item), "long-name", &grip->_priv->title, NULL);
- if (!grip->_priv->title)
- grip->_priv->title = g_strdup ("");
- }
-
- /* retrieve stock pixbuf, if any */
- if (!grip->_priv->icon_pixbuf_valid) {
- g_object_get (G_OBJECT (grip->item), "stock-id", &stock_id, NULL);
+ g_object_get (G_OBJECT (grip->item), "stock-id", &stock_id, NULL);
+ g_object_get (G_OBJECT (grip->item), "pixbuf-icon", &pixbuf, NULL);
+ if(stock_id) {
+ image = GTK_IMAGE(gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU));
- if (stock_id) {
- grip->_priv->icon_pixbuf = gtk_widget_render_icon (GTK_WIDGET (grip),
- stock_id,
- GTK_ICON_SIZE_MENU, "");
- g_free (stock_id);
- grip->_priv->icon_pixbuf_valid = TRUE;
- }
+ gtk_widget_show (GTK_WIDGET(image));
+ gtk_box_pack_start(GTK_BOX(label_box), GTK_WIDGET(image), FALSE, TRUE, 0);
+
+ g_free (stock_id);
+ }
+ else if (pixbuf) {
+ image = GTK_IMAGE(gtk_image_new_from_pixbuf (pixbuf));
+
+ gtk_widget_show (GTK_WIDGET(image));
+ gtk_box_pack_start(GTK_BOX(label_box), GTK_WIDGET(image), FALSE, TRUE, 0);
}
-
- /* retrieve pixbuf icon, if any */
- if (!grip->_priv->icon_pixbuf_valid) {
- g_object_get (G_OBJECT (grip->item), "pixbuf-icon", &pixbuf, NULL);
- if (pixbuf) {
- grip->_priv->icon_pixbuf = pixbuf;
- grip->_priv->icon_pixbuf_valid = TRUE;
+ g_object_get (G_OBJECT (grip->item), "long-name", &title, NULL);
+ if (title) {
+ label = GTK_LABEL(gtk_label_new(title));
+ gtk_label_set_ellipsize(label, PANGO_ELLIPSIZE_END);
+ gtk_label_set_justify(label, GTK_JUSTIFY_LEFT);
+ gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
+ gtk_widget_show (GTK_WIDGET(label));
+
+ if (gtk_widget_get_direction (GTK_WIDGET(grip)) == GTK_TEXT_DIR_RTL) {
+ gtk_box_pack_end(GTK_BOX(label_box), GTK_WIDGET(label), TRUE, TRUE, 1);
+ } else {
+ gtk_box_pack_start(GTK_BOX(label_box), GTK_WIDGET(label), TRUE, TRUE, 1);
}
+
+ g_free(title);
}
-
- /* create layout: the actual text is reset at size_allocate */
- if (!grip->_priv->title_layout) {
- grip->_priv->title_layout = gtk_widget_create_pango_layout (GTK_WIDGET (grip),
- grip->_priv->title);
- pango_layout_set_single_paragraph_mode (grip->_priv->title_layout, TRUE);
- }
+
+ return GTK_WIDGET(label_box);
}
static gint
@@ -125,6 +115,14 @@ gdl_dock_item_grip_expose (GtkWidget *widget,
GdkEventExpose *event)
{
GdlDockItemGrip *grip;
+/*<<<<<<< HEAD */
+ GdkRectangle handle_area;
+ GdkRectangle expose_area;
+
+ grip = GDL_DOCK_ITEM_GRIP (widget);
+
+ if(grip->_priv->handle_shown) {
+/*=======
GdkRectangle title_area;
GdkRectangle expose_area;
GdkGC *bg_style;
@@ -134,11 +132,11 @@ gdl_dock_item_grip_expose (GtkWidget *widget,
gint text_y;
grip = GDL_DOCK_ITEM_GRIP (widget);
- gdl_dock_item_grip_get_title_area (grip, &title_area);
+ gdl_dock_item_grip_get_title_area (grip, &title_area); */
/* draw background, highlight it if the dock item or any of its
* descendants have focus */
- bg_style = (gdl_dock_item_or_child_has_focus (grip->item) ?
+/* bg_style = (gdl_dock_item_or_child_has_focus (grip->item) ?
gtk_widget_get_style (widget)->dark_gc[widget->state] :
gtk_widget_get_style (widget)->mid_gc[widget->state]);
@@ -148,51 +146,35 @@ gdl_dock_item_grip_expose (GtkWidget *widget,
if (grip->_priv->icon_pixbuf) {
GdkRectangle pixbuf_rect;
+>>>>>>> gdl-2.26.0-with-inkscape */
- pixbuf_rect.width = gdk_pixbuf_get_width (grip->_priv->icon_pixbuf);
- pixbuf_rect.height = gdk_pixbuf_get_height (grip->_priv->icon_pixbuf);
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) {
- pixbuf_rect.x = title_area.x + title_area.width - pixbuf_rect.width;
+ if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) {
+ handle_area.x = widget->allocation.x;
+ handle_area.y = widget->allocation.y;
+ handle_area.width = DRAG_HANDLE_SIZE;
+ handle_area.height = widget->allocation.height;
} else {
- pixbuf_rect.x = title_area.x;
- title_area.x += pixbuf_rect.width + 1;
+ handle_area.x = widget->allocation.x + widget->allocation.width
+ - DRAG_HANDLE_SIZE;
+ handle_area.y = widget->allocation.y;
+ handle_area.width = DRAG_HANDLE_SIZE;
+ handle_area.height = widget->allocation.height;
}
- /* shrink title area by the pixbuf width plus a 1px spacing */
- title_area.width -= pixbuf_rect.width + 1;
- pixbuf_rect.y = title_area.y + (title_area.height - pixbuf_rect.height) / 2;
-
- if (gdk_rectangle_intersect (&event->area, &pixbuf_rect, &expose_area)) {
- GdkGC *gc;
- GtkStyle *style;
-
- style = gtk_widget_get_style (widget);
- gc = style->bg_gc[widget->state];
- gdk_draw_pixbuf (GDK_DRAWABLE (widget->window), gc,
- grip->_priv->icon_pixbuf,
- 0, 0, pixbuf_rect.x, pixbuf_rect.y,
- pixbuf_rect.width, pixbuf_rect.height,
- GDK_RGB_DITHER_NONE, 0, 0);
- }
- }
- if (gdk_rectangle_intersect (&title_area, &event->area, &expose_area)) {
- pango_layout_get_pixel_size (grip->_priv->title_layout, &layout_width,
- &layout_height);
+ if (gdk_rectangle_intersect (&handle_area, &event->area, &expose_area)) {
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- text_x = title_area.x + title_area.width - layout_width;
- else
- text_x = title_area.x;
-
- text_y = title_area.y + (title_area.height - layout_height) / 2;
-
- gtk_paint_layout (widget->style, widget->window, widget->state, TRUE,
- &expose_area, widget, NULL, text_x, text_y,
- grip->_priv->title_layout);
+ gtk_paint_handle (widget->style, widget->window, widget->state,
+ GTK_SHADOW_NONE, &expose_area, widget,
+ "handlebox", handle_area.x, handle_area.y,
+ handle_area.width, handle_area.height,
+ GTK_ORIENTATION_VERTICAL);
+
+ }
+
}
return GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
-}
+}
static void
gdl_dock_item_grip_item_notify (GObject *master,
@@ -205,23 +187,12 @@ gdl_dock_item_grip_item_notify (GObject *master,
grip = GDL_DOCK_ITEM_GRIP (data);
- if (strcmp (pspec->name, "stock-id") == 0) {
- if (grip->_priv->icon_pixbuf) {
- g_object_unref (grip->_priv->icon_pixbuf);
- grip->_priv->icon_pixbuf = NULL;
- }
- grip->_priv->icon_pixbuf_valid = FALSE;
- ensure_title_and_icon_pixbuf (grip);
-
- } else if (strcmp (pspec->name, "long-name") == 0) {
- if (grip->_priv->title_layout) {
- g_object_unref (grip->_priv->title_layout);
- grip->_priv->title_layout = NULL;
- }
- g_free (grip->_priv->title);
- grip->_priv->title = NULL;
- ensure_title_and_icon_pixbuf (grip);
- gtk_widget_queue_draw (GTK_WIDGET (grip));
+ if ((strcmp (pspec->name, "stock-id") == 0) ||
+ (strcmp (pspec->name, "long-name") == 0)) {
+
+ gdl_dock_item_grip_set_label (grip,
+ gdl_dock_item_create_label_widget(grip));
+
} else if (strcmp (pspec->name, "behavior") == 0) {
cursor = FALSE;
if (grip->_priv->close_button) {
@@ -250,20 +221,13 @@ static void
gdl_dock_item_grip_destroy (GtkObject *object)
{
GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP (object);
-
+
if (grip->_priv) {
GdlDockItemGripPrivate *priv = grip->_priv;
- if (priv->title_layout) {
- g_object_unref (priv->title_layout);
- priv->title_layout = NULL;
- }
- g_free (priv->title);
- priv->title = NULL;
-
- if (priv->icon_pixbuf) {
- g_object_unref (priv->icon_pixbuf);
- priv->icon_pixbuf = NULL;
+ if (priv->label) {
+ gtk_widget_unparent(grip->_priv->label);
+ priv->label = NULL;
}
if (grip->item)
@@ -275,7 +239,7 @@ gdl_dock_item_grip_destroy (GtkObject *object)
grip->_priv = NULL;
g_free (priv);
}
-
+
GDL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
}
@@ -331,10 +295,34 @@ static void
gdl_dock_item_grip_iconify_clicked (GtkWidget *widget,
GdlDockItemGrip *grip)
{
+ GtkWidget *parent;
+
(void)widget;
g_return_if_fail (grip->item != NULL);
- gdl_dock_item_iconify_item (grip->item);
+ parent = gtk_widget_get_parent (GTK_WIDGET (grip->item));
+ if (GDL_IS_SWITCHER (parent))
+ {
+ /* Note: We can not use gtk_container_foreach (parent) here because
+ * during iconificatoin, the internal children changes in parent.
+ * Instead we keep a list of items to iconify and iconify them
+ * one by one.
+ */
+ GList *node;
+ GList *items =
+ gtk_container_get_children (GTK_CONTAINER (parent));
+ for (node = items; node != NULL; node = node->next)
+ {
+ GdlDockItem *item = GDL_DOCK_ITEM (node->data);
+ if (!GDL_DOCK_ITEM_CANT_ICONIFY (item))
+ gdl_dock_item_iconify_item (item);
+ }
+ g_list_free (items);
+ }
+ else
+ {
+ gdl_dock_item_iconify_item (grip->item);
+ }
/* Workaround to unhighlight the iconify button. */
GTK_BUTTON (grip->_priv->iconify_button)->in_button = FALSE;
@@ -349,10 +337,9 @@ gdl_dock_item_grip_instance_init (GdlDockItemGrip *grip)
gtk_widget_set_has_window (GTK_WIDGET (grip), FALSE);
grip->_priv = g_new0 (GdlDockItemGripPrivate, 1);
- grip->_priv->icon_pixbuf_valid = FALSE;
- grip->_priv->icon_pixbuf = NULL;
- grip->_priv->title_layout = NULL;
-
+ grip->_priv->label = NULL;
+ grip->_priv->handle_shown = FALSE;
+
/* create the close button */
gtk_widget_push_composite_child ();
grip->_priv->close_button = gtk_button_new ();
@@ -363,7 +350,7 @@ gdl_dock_item_grip_instance_init (GdlDockItemGrip *grip)
gtk_button_set_relief (GTK_BUTTON (grip->_priv->close_button), GTK_RELIEF_NONE);
gtk_widget_show (grip->_priv->close_button);
- image = gtk_image_new_from_stock (GDL_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
+ image = gdl_dock_item_button_image_new(GDL_DOCK_ITEM_BUTTON_IMAGE_CLOSE);
gtk_container_add (GTK_CONTAINER (grip->_priv->close_button), image);
gtk_widget_show (image);
@@ -380,7 +367,7 @@ gdl_dock_item_grip_instance_init (GdlDockItemGrip *grip)
gtk_button_set_relief (GTK_BUTTON (grip->_priv->iconify_button), GTK_RELIEF_NONE);
gtk_widget_show (grip->_priv->iconify_button);
- image = gtk_image_new_from_stock (GDL_STOCK_MENU_RIGHT, GTK_ICON_SIZE_MENU);
+ image = gdl_dock_item_button_image_new(GDL_DOCK_ITEM_BUTTON_IMAGE_ICONIFY);
gtk_container_add (GTK_CONTAINER (grip->_priv->iconify_button), image);
gtk_widget_show (image);
@@ -401,33 +388,36 @@ gdl_dock_item_grip_realize (GtkWidget *widget)
GTK_WIDGET_CLASS (parent_class)->realize (widget);
+ g_return_if_fail (grip->_priv != NULL);
+
if (!grip->title_window) {
GdkWindowAttr attributes;
- GdkRectangle area;
GdkCursor *cursor;
- ensure_title_and_icon_pixbuf (grip);
- gdl_dock_item_grip_get_title_area (grip, &area);
-
- attributes.x = area.x;
- attributes.y = area.y;
- attributes.width = area.width;
- attributes.height = area.height;
- attributes.window_type = GDK_WINDOW_TEMP;
- attributes.wclass = GDK_INPUT_ONLY;
- attributes.override_redirect = TRUE;
- attributes.event_mask = (GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_BUTTON_MOTION_MASK |
- gtk_widget_get_events (widget));
+ g_return_if_fail (grip->_priv->label != NULL);
+
+ attributes.x = grip->_priv->label->allocation.x;
+ attributes.y = grip->_priv->label->allocation.y;
+ attributes.width = grip->_priv->label->allocation.width;
+ attributes.height = grip->_priv->label->allocation.height;
+ attributes.window_type = GDK_WINDOW_CHILD;
+ attributes.wclass = GDK_INPUT_OUTPUT;
+ attributes.event_mask = GDK_ALL_EVENTS_MASK;
grip->title_window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes,
- (GDK_WA_X |
- GDK_WA_Y |
- GDK_WA_NOREDIR));
+ &attributes, (GDK_WA_X | GDK_WA_Y));
+
+ gdk_window_set_user_data (grip->title_window, grip);
+
+ /* Unref the ref from parent realize for NO_WINDOW */
+ g_object_unref (widget->window);
+
+ /* Need to ref widget->window, because parent unrealize unrefs it */
+ widget->window = g_object_ref (grip->title_window);
+ GTK_WIDGET_UNSET_FLAGS(widget, GTK_NO_WINDOW);
- gdk_window_set_user_data (grip->title_window, widget);
+ /* Unset the background so as to make the colour match the parent window */
+ gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, NULL);
if (GDL_DOCK_ITEM_CANT_CLOSE (grip->item) &&
GDL_DOCK_ITEM_CANT_ICONIFY (grip->item))
@@ -447,6 +437,7 @@ gdl_dock_item_grip_unrealize (GtkWidget *widget)
GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP (widget);
if (grip->title_window) {
+ GTK_WIDGET_SET_FLAGS(widget, GTK_NO_WINDOW);
gdk_window_set_user_data (grip->title_window, NULL);
gdk_window_destroy (grip->title_window);
grip->title_window = NULL;
@@ -484,7 +475,7 @@ gdl_dock_item_grip_size_request (GtkWidget *widget,
GtkRequisition child_requisition;
GtkContainer *container;
GdlDockItemGrip *grip;
- gint layout_height;
+ gint layout_height = 0;
g_return_if_fail (GDL_IS_DOCK_ITEM_GRIP (widget));
g_return_if_fail (requisition != NULL);
@@ -492,11 +483,11 @@ gdl_dock_item_grip_size_request (GtkWidget *widget,
container = GTK_CONTAINER (widget);
grip = GDL_DOCK_ITEM_GRIP (widget);
- requisition->width = container->border_width * 2 + ALIGN_BORDER;
+ requisition->width = container->border_width * 2/* + ALIGN_BORDER*/;
requisition->height = container->border_width * 2;
- ensure_title_and_icon_pixbuf (grip);
- pango_layout_get_pixel_size (grip->_priv->title_layout, NULL, &layout_height);
+ if(grip->_priv->handle_shown)
+ requisition->width += DRAG_HANDLE_SIZE;
gtk_widget_size_request (grip->_priv->close_button, &child_requisition);
layout_height = MAX (layout_height, child_requisition.height);
@@ -509,54 +500,12 @@ gdl_dock_item_grip_size_request (GtkWidget *widget,
if (GTK_WIDGET_VISIBLE (grip->_priv->iconify_button)) {
requisition->width += child_requisition.width;
}
-
- requisition->height += layout_height;
-
- if (grip->_priv->icon_pixbuf) {
- requisition->width += gdk_pixbuf_get_width (grip->_priv->icon_pixbuf) + 1;
- }
-}
-
-#define ELLIPSIS "..."
-
-static void
-ellipsize_layout (PangoLayout *layout, gint width)
-{
- PangoLayoutLine *line;
- PangoLayout *ell;
- gint h, w, ell_w, x;
- GString *text;
-
- if (width <= 0) {
- pango_layout_set_text (layout, "", -1);
- return;
- }
-
- pango_layout_get_pixel_size (layout, &w, &h);
- if (w <= width) return;
+
+ gtk_widget_size_request (grip->_priv->label, &child_requisition);
+ requisition->width += child_requisition.width;
+ layout_height = MAX (layout_height, child_requisition.height);
- /* calculate ellipsis width */
- ell = pango_layout_copy (layout);
- pango_layout_set_text (ell, ELLIPSIS, -1);
- pango_layout_get_pixel_size (ell, &ell_w, NULL);
- g_object_unref (ell);
-
- if (width < ell_w) {
- /* not even ellipsis fits, so hide the text */
- pango_layout_set_text (layout, "", -1);
- return;
- }
-
- /* shrink total available width by the width of the ellipsis */
- width -= ell_w;
- line = pango_layout_get_line (layout, 0);
- text = g_string_new (pango_layout_get_text (layout));
- if (pango_layout_line_x_to_index (line, width * PANGO_SCALE, &x, NULL)) {
- g_string_set_size (text, x);
- g_string_append (text, ELLIPSIS);
- pango_layout_set_text (layout, text->str, -1);
- }
- g_string_free (text, TRUE);
+ requisition->height += layout_height;
}
static void
@@ -565,9 +514,10 @@ gdl_dock_item_grip_size_allocate (GtkWidget *widget,
{
GdlDockItemGrip *grip;
GtkContainer *container;
- GtkRequisition button_requisition;
+ GtkRequisition close_requisition = { 0, };
+ GtkRequisition iconify_requisition = { 0, };
GtkAllocation child_allocation;
- memset(&button_requisition, 0, sizeof(button_requisition));
+ GdkRectangle label_area;
g_return_if_fail (GDL_IS_DOCK_ITEM_GRIP (widget));
g_return_if_fail (allocation != NULL);
@@ -577,59 +527,96 @@ gdl_dock_item_grip_size_allocate (GtkWidget *widget,
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
+ gtk_widget_size_request (grip->_priv->close_button,
+ &close_requisition);
+ gtk_widget_size_request (grip->_priv->iconify_button,
+ &iconify_requisition);
+
+ /* Calculate the Minimum Width where buttons will fit */
+ int min_width = close_requisition.width + iconify_requisition.width
+ + container->border_width * 2;
+ if(grip->_priv->handle_shown)
+ min_width += DRAG_HANDLE_SIZE;
+ const gboolean space_for_buttons = (allocation->width >= min_width);
+
+ /* Set up the rolling child_allocation rectangle */
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- child_allocation.x = allocation->x + container->border_width + ALIGN_BORDER;
+ child_allocation.x = container->border_width/* + ALIGN_BORDER*/;
else
- child_allocation.x = allocation->x + allocation->width - container->border_width;
- child_allocation.y = allocation->y + container->border_width;
+ child_allocation.x = allocation->width - container->border_width;
+ child_allocation.y = container->border_width;
+ /* Layout Close Button */
if (GTK_WIDGET_VISIBLE (grip->_priv->close_button)) {
- gtk_widget_size_request (grip->_priv->close_button, &button_requisition);
- if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL)
- child_allocation.x -= button_requisition.width;
-
- child_allocation.width = button_requisition.width;
- child_allocation.height = button_requisition.height;
+ if(space_for_buttons) {
+ if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL)
+ child_allocation.x -= close_requisition.width;
+
+ child_allocation.width = close_requisition.width;
+ child_allocation.height = close_requisition.height;
+ } else {
+ child_allocation.width = 0;
+ }
gtk_widget_size_allocate (grip->_priv->close_button, &child_allocation);
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- child_allocation.x += button_requisition.width;
+ child_allocation.x += close_requisition.width;
}
+ /* Layout Iconify Button */
if (GTK_WIDGET_VISIBLE (grip->_priv->iconify_button)) {
- gtk_widget_size_request (grip->_priv->iconify_button, &button_requisition);
- if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL)
- child_allocation.x -= button_requisition.width;
+ if(space_for_buttons) {
+ if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL)
+ child_allocation.x -= iconify_requisition.width;
- child_allocation.width = button_requisition.width;
- child_allocation.height = button_requisition.height;
+ child_allocation.width = iconify_requisition.width;
+ child_allocation.height = iconify_requisition.height;
+ } else {
+ child_allocation.width = 0;
+ }
gtk_widget_size_allocate (grip->_priv->iconify_button, &child_allocation);
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- child_allocation.x += button_requisition.width;
+ child_allocation.x += iconify_requisition.width;
}
- if (grip->title_window) {
- GdkRectangle area;
+ /* Layout the Grip Handle*/
+ if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) {
+ child_allocation.width = child_allocation.x;
+ child_allocation.x = container->border_width/* + ALIGN_BORDER*/;
- /* set layout text */
- ensure_title_and_icon_pixbuf (grip);
- pango_layout_set_text (grip->_priv->title_layout, grip->_priv->title, -1);
-
- gdl_dock_item_grip_get_title_area (grip, &area);
-
- gdk_window_move_resize (grip->title_window,
- area.x, area.y, area.width, area.height);
-
- if (grip->_priv->icon_pixbuf)
- area.width -= gdk_pixbuf_get_width (grip->_priv->icon_pixbuf) + 1;
+ if(grip->_priv->handle_shown) {
+ child_allocation.x += DRAG_HANDLE_SIZE;
+ child_allocation.width -= DRAG_HANDLE_SIZE;
+ }
+
+ } else {
+ child_allocation.width = allocation->width -
+ (child_allocation.x - allocation->x)/* - ALIGN_BORDER*/;
- /* ellipsize title if it doesn't fit the title area */
- ellipsize_layout (grip->_priv->title_layout, area.width);
+ if(grip->_priv->handle_shown)
+ child_allocation.width -= DRAG_HANDLE_SIZE;
+ }
+
+ if(child_allocation.width < 0)
+ child_allocation.width = 0;
+
+ child_allocation.y = container->border_width;
+ child_allocation.height = allocation->height - container->border_width * 2;
+ if(grip->_priv->label) {
+ gtk_widget_size_allocate (grip->_priv->label, &child_allocation);
+ }
+
+ if (grip->title_window) {
+ gdk_window_move_resize (grip->title_window,
+ allocation->x,
+ allocation->y,
+ allocation->width,
+ allocation->height);
}
}
@@ -646,9 +633,8 @@ static void
gdl_dock_item_grip_remove (GtkContainer *container,
GtkWidget *widget)
{
- (void)container;
(void)widget;
- g_warning ("gtk_container_remove not implemented for GdlDockItemGrip");
+ gdl_dock_item_grip_set_label (GDL_DOCK_ITEM_GRIP (container), NULL);
}
static void
@@ -660,12 +646,17 @@ gdl_dock_item_grip_forall (GtkContainer *container,
GdlDockItemGrip *grip;
g_return_if_fail (GDL_IS_DOCK_ITEM_GRIP (container));
-
grip = GDL_DOCK_ITEM_GRIP (container);
+
+ if (grip->_priv) {
+ if(grip->_priv->label) {
+ (* callback) (grip->_priv->label, callback_data);
+ }
- if (include_internals) {
- (* callback) (grip->_priv->close_button, callback_data);
- (* callback) (grip->_priv->iconify_button, callback_data);
+ if (include_internals) {
+ (* callback) (grip->_priv->close_button, callback_data);
+ (* callback) (grip->_priv->iconify_button, callback_data);
+ }
}
}
@@ -713,9 +704,12 @@ gdl_dock_item_grip_class_init (GdlDockItemGripClass *klass)
_("Dockitem which 'owns' this grip"),
GDL_TYPE_DOCK_ITEM,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+}
- /* initialize stock images */
- gdl_stock_init ();
+static void
+gdl_dock_item_grip_showhide_handle (GdlDockItemGrip *grip)
+{
+ gtk_widget_queue_resize (GTK_WIDGET (grip));
}
/* ----- Public interface ----- */
@@ -735,3 +729,61 @@ gdl_dock_item_grip_new (GdlDockItem *item)
return GTK_WIDGET (grip);
}
+
+/**
+ * gdl_dock_item_grip_set_label:
+ * @grip: The grip that will get it's label widget set.
+ * @label: The widget that will become the label.
+ *
+ * Replaces the current label widget with another widget.
+ **/
+void
+gdl_dock_item_grip_set_label (GdlDockItemGrip *grip,
+ GtkWidget *label)
+{
+ g_return_if_fail (grip != NULL);
+
+ if (grip->_priv->label) {
+ gtk_widget_unparent(grip->_priv->label);
+ g_object_unref (grip->_priv->label);
+ grip->_priv->label = NULL;
+ }
+
+ if (label) {
+ g_object_ref (label);
+ gtk_widget_set_parent (label, GTK_WIDGET (grip));
+ gtk_widget_show (label);
+ grip->_priv->label = label;
+ }
+}
+/**
+ * gdl_dock_item_grip_hide_handle:
+ * @item: The dock item grip to hide the handle of.
+ *
+ * This function hides the dock item's grip widget handle hatching.
+ **/
+void
+gdl_dock_item_grip_hide_handle (GdlDockItemGrip *grip)
+{
+ g_return_if_fail (grip != NULL);
+ if (grip->_priv->handle_shown) {
+ grip->_priv->handle_shown = FALSE;
+ gdl_dock_item_grip_showhide_handle (grip);
+ };
+}
+
+/**
+ * gdl_dock_item_grip_show_handle:
+ * @grip: The dock item grip to show the handle of.
+ *
+ * This function shows the dock item's grip widget handle hatching.
+ **/
+void
+gdl_dock_item_grip_show_handle (GdlDockItemGrip *grip)
+{
+ g_return_if_fail (grip != NULL);
+ if (!grip->_priv->handle_shown) {
+ grip->_priv->handle_shown = TRUE;
+ gdl_dock_item_grip_showhide_handle (grip);
+ };
+}
diff --git a/src/libgdl/gdl-dock-item-grip.h b/src/libgdl/gdl-dock-item-grip.h
index 4dfdd7ab3..a44ef91fb 100644
--- a/src/libgdl/gdl-dock-item-grip.h
+++ b/src/libgdl/gdl-dock-item-grip.h
@@ -1,13 +1,30 @@
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 8 -*- */
-/**
+/*
* gdl-dock-item-grip.h
- *
- * Based on bonobo-dock-item-grip. Original copyright notice follows.
*
- * Author:
- * Michael Meeks
+ * Author: Michael Meeks Copyright (C) 2002 Sun Microsystems, Inc.
*
- * Copyright (C) 2002 Sun Microsystems, Inc.
+ * Based on BonoboDockItemGrip. Original copyright notice follows.
+ *
+ * Copyright (C) 1998 Ettore Perazzoli
+ * Copyright (C) 1998 Elliot Lee
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
*/
#ifndef _GDL_DOCK_ITEM_GRIP_H_
@@ -50,6 +67,10 @@ struct _GdlDockItemGripClass {
GType gdl_dock_item_grip_get_type (void);
GtkWidget *gdl_dock_item_grip_new (GdlDockItem *item);
+void gdl_dock_item_grip_set_label (GdlDockItemGrip *grip,
+ GtkWidget *label);
+void gdl_dock_item_grip_hide_handle (GdlDockItemGrip *grip);
+void gdl_dock_item_grip_show_handle (GdlDockItemGrip *grip);
G_END_DECLS
diff --git a/src/libgdl/gdl-dock-item.c b/src/libgdl/gdl-dock-item.c
index 86f729c61..0c0d765df 100644
--- a/src/libgdl/gdl-dock-item.c
+++ b/src/libgdl/gdl-dock-item.c
@@ -163,6 +163,7 @@ enum {
DOCK_DRAG_BEGIN,
DOCK_DRAG_MOTION,
DOCK_DRAG_END,
+ SELECTED,
MOVE_FOCUS_CHILD,
LAST_SIGNAL
};
@@ -407,6 +408,22 @@ gdl_dock_item_class_init (GdlDockItemClass *klass)
1,
G_TYPE_BOOLEAN);
+ /**
+ * GdlDockItem::selected:
+ *
+ * Signals that this dock has been selected from a switcher.
+ */
+ gdl_dock_item_signals [SELECTED] =
+ g_signal_new ("selected",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
gdl_dock_item_signals [MOVE_FOCUS_CHILD] =
g_signal_new ("move_focus_child",
G_TYPE_FROM_CLASS (klass),
@@ -1925,6 +1942,23 @@ gdl_dock_item_set_tablabel (GdlDockItem *item,
}
/**
+ * gdl_dock_item_get_grip:
+ * @item: The dock item from which to to get the grip of.
+ *
+ * This function returns the dock item's grip label widget.
+ *
+ * Returns: Returns the current label widget.
+ **/
+GtkWidget *
+gdl_dock_item_get_grip(GdlDockItem *item)
+{
+ g_return_if_fail (item != NULL);
+ g_return_val_if_fail (GDL_IS_DOCK_ITEM (item), NULL);
+
+ return item->_priv->grip;
+}
+
+/**
* gdl_dock_item_hide_grip:
* @item: The dock item to hide the grip of.
*
@@ -1957,6 +1991,19 @@ gdl_dock_item_show_grip (GdlDockItem *item)
};
}
+/**
+ * gdl_dock_item_notify_selected:
+ * @item: the dock item to emit a selected signal on.
+ *
+ * This function emits the selected signal. It is to be used by #GdlSwitcher
+ * to let clients know that this item has been switched to.
+ **/
+void
+gdl_dock_item_notify_selected (GdlDockItem *item)
+{
+ g_signal_emit (item, gdl_dock_item_signals [SELECTED], 0);
+}
+
/* convenient function (and to preserve source compat) */
/**
* gdl_dock_item_bind:
diff --git a/src/libgdl/gdl-dock-item.h b/src/libgdl/gdl-dock-item.h
index 6c0029d13..d97fdf6fd 100644
--- a/src/libgdl/gdl-dock-item.h
+++ b/src/libgdl/gdl-dock-item.h
@@ -93,17 +93,16 @@ struct _GdlDockItemClass {
gboolean has_grip;
/* virtuals */
- void (* dock_drag_begin) (GdlDockItem *item);
- void (* dock_drag_motion) (GdlDockItem *item,
- gint x,
- gint y);
- void (* dock_drag_end) (GdlDockItem *item,
- gboolean cancelled);
+ void (* dock_drag_begin) (GdlDockItem *item);
+ void (* dock_drag_motion) (GdlDockItem *item,
+ gint x,
+ gint y);
+ void (* dock_drag_end) (GdlDockItem *item,
+ gboolean cancelled);
void (* move_focus_child) (GdlDockItem *item,
GtkDirectionType direction);
-
- void (* set_orientation) (GdlDockItem *item,
- GtkOrientation orientation);
+ void (* set_orientation) (GdlDockItem *item,
+ GtkOrientation orientation);
};
/* additional macros */
@@ -163,8 +162,10 @@ void gdl_dock_item_set_orientation (GdlDockItem *item,
GtkWidget *gdl_dock_item_get_tablabel (GdlDockItem *item);
void gdl_dock_item_set_tablabel (GdlDockItem *item,
GtkWidget *tablabel);
+GtkWidget *gdl_dock_item_get_grip (GdlDockItem *item);
void gdl_dock_item_hide_grip (GdlDockItem *item);
void gdl_dock_item_show_grip (GdlDockItem *item);
+void gdl_dock_item_notify_selected (GdlDockItem *item);
/* bind and unbind items to a dock */
void gdl_dock_item_bind (GdlDockItem *item,
diff --git a/src/libgdl/gdl-dock-layout.c b/src/libgdl/gdl-dock-layout.c
index a0f0a3e3a..7c5279507 100644
--- a/src/libgdl/gdl-dock-layout.c
+++ b/src/libgdl/gdl-dock-layout.c
@@ -28,7 +28,6 @@
#include <stdlib.h>
#include <libxml/parser.h>
#include <gtk/gtk.h>
-#include <glade/glade.h>
#include "gdl-dock-layout.h"
#include "gdl-tools.h"
@@ -48,7 +47,7 @@ enum {
#define LAYOUT_ELEMENT_NAME "layout"
#define NAME_ATTRIBUTE_NAME "name"
-#define LAYOUT_GLADE_FILE "layout.glade"
+#define LAYOUT_UI_FILE "layout.ui"
enum {
COLUMN_NAME,
@@ -548,20 +547,23 @@ master_locked_notify_cb (GdlDockMaster *master,
}
}
-static GladeXML *
-load_interface (const gchar *top_widget)
+static GtkBuilder *
+load_interface ()
{
- GladeXML *gui;
+ GtkBuilder *gui;
gchar *gui_file;
+ GError* error = NULL;
/* load ui */
- gui_file = g_build_filename (GDL_GLADEDIR, LAYOUT_GLADE_FILE, NULL);
- gui = glade_xml_new (gui_file, top_widget, GETTEXT_PACKAGE);
+ gui_file = g_build_filename (GDL_UIDIR, LAYOUT_UI_FILE, NULL);
+ gui = gtk_builder_new();
+ gtk_builder_add_from_file (gui, gui_file, &error);
g_free (gui_file);
- if (!gui) {
- /* FIXME: pop up an error dialog */
+ if (error) {
g_warning (_("Could not load layout user interface file '%s'"),
- LAYOUT_GLADE_FILE);
+ LAYOUT_UI_FILE);
+ g_object_unref (gui);
+ g_error_free (error);
return NULL;
};
return gui;
@@ -570,8 +572,8 @@ load_interface (const gchar *top_widget)
static GtkWidget *
gdl_dock_layout_construct_items_ui (GdlDockLayout *layout)
{
- GladeXML *gui;
- GtkWidget *container;
+ GtkBuilder *gui;
+ GtkWidget *dialog;
GtkWidget *items_list;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
@@ -579,23 +581,23 @@ gdl_dock_layout_construct_items_ui (GdlDockLayout *layout)
GdlDockLayoutUIData *ui_data;
/* load the interface if it wasn't provided */
- gui = load_interface ("items_vbox");
+ gui = load_interface ();
if (!gui)
return NULL;
/* get the container */
- container = glade_xml_get_widget (gui, "items_vbox");
+ dialog = GTK_WIDGET (gtk_builder_get_object (gui, "layout_dialog"));
ui_data = g_new0 (GdlDockLayoutUIData, 1);
ui_data->layout = layout;
g_object_add_weak_pointer (G_OBJECT (layout),
(gpointer *) &ui_data->layout);
- g_object_set_data (G_OBJECT (container), "ui_data", ui_data);
+ g_object_set_data (G_OBJECT (dialog), "ui_data", ui_data);
/* get ui widget references */
- ui_data->locked_check = glade_xml_get_widget (gui, "locked_check");
- items_list = glade_xml_get_widget (gui, "items_list");
+ ui_data->locked_check = GTK_WIDGET (gtk_builder_get_object (gui, "locked_check"));
+ items_list = GTK_WIDGET (gtk_builder_get_object(gui, "items_list"));
/* locked check connections */
g_signal_connect (ui_data->locked_check, "toggled",
@@ -629,11 +631,11 @@ gdl_dock_layout_construct_items_ui (GdlDockLayout *layout)
gtk_tree_view_append_column (GTK_TREE_VIEW (items_list), column);
/* connect signals */
- g_signal_connect (container, "destroy", (GCallback) layout_ui_destroyed, NULL);
+ g_signal_connect (dialog, "destroy", (GCallback) layout_ui_destroyed, NULL);
g_object_unref (gui);
- return container;
+ return dialog;
}
static void
@@ -671,22 +673,24 @@ cell_edited_cb (GtkCellRendererText *cell,
static GtkWidget *
gdl_dock_layout_construct_layouts_ui (GdlDockLayout *layout)
{
- GladeXML *gui;
+ GtkBuilder *gui;
GtkWidget *container;
GtkWidget *layouts_list;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
+ GtkWidget *load_button;
+ GtkWidget *delete_button;
GdlDockLayoutUIData *ui_data;
/* load the interface if it wasn't provided */
- gui = load_interface ("layouts_vbox");
+ gui = load_interface ();
if (!gui)
return NULL;
/* get the container */
- container = glade_xml_get_widget (gui, "layouts_vbox");
+ container = GTK_WIDGET (gtk_builder_get_object(gui, "layouts_vbox"));
ui_data = g_new0 (GdlDockLayoutUIData, 1);
ui_data->layout = layout;
@@ -695,7 +699,7 @@ gdl_dock_layout_construct_layouts_ui (GdlDockLayout *layout)
g_object_set_data (G_OBJECT (container), "ui-data", ui_data);
/* get ui widget references */
- layouts_list = glade_xml_get_widget (gui, "layouts_list");
+ layouts_list = GTK_WIDGET (gtk_builder_get_object(gui, "layouts_list"));
/* set models */
gtk_tree_view_set_model (GTK_TREE_VIEW (layouts_list),
@@ -714,10 +718,12 @@ gdl_dock_layout_construct_layouts_ui (GdlDockLayout *layout)
ui_data->selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (layouts_list));
/* connect signals */
- glade_xml_signal_connect_data (gui, "on_load_button_clicked",
- G_CALLBACK (load_layout_cb), ui_data);
- glade_xml_signal_connect_data (gui, "on_delete_button_clicked",
- G_CALLBACK (delete_layout_cb), ui_data);
+ load_button = GTK_WIDGET (gtk_builder_get_object(gui, "load_button"));
+ delete_button = GTK_WIDGET (gtk_builder_get_object(gui, "delete_button"));
+
+ g_signal_connect (load_button, "clicked", (GCallback) load_layout_cb, ui_data);
+ g_signal_connect (delete_button, "clicked", (GCallback) delete_layout_cb, ui_data);
+
g_signal_connect (container, "destroy", (GCallback) layout_ui_destroyed, NULL);
@@ -726,31 +732,6 @@ gdl_dock_layout_construct_layouts_ui (GdlDockLayout *layout)
return container;
}
-static GtkWidget *
-gdl_dock_layout_construct_ui (GdlDockLayout *layout)
-{
- GtkWidget *container, *child;
-
- container = gtk_notebook_new ();
- gtk_widget_show (container);
-
- child = gdl_dock_layout_construct_items_ui (layout);
- if (child)
- gtk_notebook_append_page (GTK_NOTEBOOK (container),
- child,
- gtk_label_new (_("Dock items")));
-
- child = gdl_dock_layout_construct_layouts_ui (layout);
- if (child)
- gtk_notebook_append_page (GTK_NOTEBOOK (container),
- child,
- gtk_label_new (_("Saved layouts")));
-
- gtk_notebook_set_current_page (GTK_NOTEBOOK (container), 0);
-
- return container;
-}
-
/* ----- Save & Load layout functions --------- */
#define GDL_DOCK_PARAM_CONSTRUCTION(p) \
@@ -1095,6 +1076,13 @@ gdl_dock_layout_save (GdlDockMaster *master,
/* ----- Public interface ----- */
+/**
+ * gdl_dock_layout_new:
+ * @dock: The dock item.
+ * Creates a new #GdlDockLayout
+ *
+ * Returns: New #GdlDockLayout item.
+ */
GdlDockLayout *
gdl_dock_layout_new (GdlDock *dock)
{
@@ -1133,6 +1121,15 @@ gdl_dock_layout_layout_changed_cb (GdlDockMaster *master,
}
}
+
+/**
+ * gdl_dock_layout_attach:
+ * @layout: The layout item
+ * @master: The master item to which the layout will be attached
+ *
+ * Attach the @layout to the @master and delete the reference to
+ * the master that the layout attached previously
+ */
void
gdl_dock_layout_attach (GdlDockLayout *layout,
GdlDockMaster *master)
@@ -1159,6 +1156,17 @@ gdl_dock_layout_attach (GdlDockLayout *layout,
update_items_model (layout);
}
+/**
+* gdl_dock_layout_load_layout:
+* @layout: The dock item.
+* @name: The name of the layout to load.
+*
+* Loads the layout with the given name to the memory.
+* This will set #GdlDockLayout:dirty to %TRUE.
+*
+* See also gdl_dock_layout_load_from_file()
+* Returns: %TRUE if layout successfully loaded else %FALSE
+*/
gboolean
gdl_dock_layout_load_layout (GdlDockLayout *layout,
const gchar *name)
@@ -1188,6 +1196,17 @@ gdl_dock_layout_load_layout (GdlDockLayout *layout,
return FALSE;
}
+/**
+* gdl_dock_layout_save_layout:
+* @layout: The dock item.
+* @name: The name of the layout to save.
+*
+* Saves the @layout with the given name to the memory.
+* This will set #GdlDockLayout:dirty to %TRUE.
+*
+* See also gdl_dock_layout_save_to_file().
+*/
+
void
gdl_dock_layout_save_layout (GdlDockLayout *layout,
const gchar *name)
@@ -1224,6 +1243,15 @@ gdl_dock_layout_save_layout (GdlDockLayout *layout,
g_object_notify (G_OBJECT (layout), "dirty");
}
+/**
+* gdl_dock_layout_delete_layout:
+* @layout: The dock item.
+* @name: The name of the layout to delete.
+*
+* Deletes the layout with the given name from the memory.
+* This will set #GdlDockLayout:dirty to %TRUE.
+*/
+
void
gdl_dock_layout_delete_layout (GdlDockLayout *layout,
const gchar *name)
@@ -1245,10 +1273,17 @@ gdl_dock_layout_delete_layout (GdlDockLayout *layout,
}
}
+/**
+* gdl_dock_layout_run_manager:
+* @layout: The dock item.
+*
+* Runs the layout manager.
+*/
+
void
gdl_dock_layout_run_manager (GdlDockLayout *layout)
{
- GtkWidget *dialog, *container;
+ GtkWidget *dialog;
GtkWidget *parent = NULL;
g_return_if_fail (layout != NULL);
@@ -1257,28 +1292,24 @@ gdl_dock_layout_run_manager (GdlDockLayout *layout)
/* not attached to a dock yet */
return;
- container = gdl_dock_layout_construct_ui (layout);
- if (!container)
- return;
-
- parent = GTK_WIDGET (gdl_dock_master_get_controller (layout->master));
- if (parent)
- parent = gtk_widget_get_toplevel (parent);
-
- dialog = gtk_dialog_new_with_buttons (_("Layout managment"),
- parent ? GTK_WINDOW (parent) : NULL,
- GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR,
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
- NULL);
-
- gtk_window_set_default_size (GTK_WINDOW (dialog), -1, 300);
- gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), container);
+ dialog = gdl_dock_layout_construct_items_ui (layout);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
+/**
+* gdl_dock_layout_load_from_file:
+* @layout: The layout item.
+* @filename: The name of the file to load.
+*
+* Loads the layout from file with the given @filename.
+* This will set #GdlDockLayout:dirty to %FALSE.
+*
+* Returns: %TRUE if @layout successfully loaded else %FALSE
+*/
+
gboolean
gdl_dock_layout_load_from_file (GdlDockLayout *layout,
const gchar *filename)
@@ -1311,6 +1342,16 @@ gdl_dock_layout_load_from_file (GdlDockLayout *layout,
return retval;
}
+/**
+ * gdl_dock_layout_save_to_file:
+ * @layout: The layout item.
+ * @filename: Name of the file we want to save in layout
+ *
+ * This function saves the current layout in XML format to
+ * the file with the given @filename.
+ *
+ * Returns: %TRUE if @layout successfuly save to the file, otherwise %FALSE.
+ */
gboolean
gdl_dock_layout_save_to_file (GdlDockLayout *layout,
const gchar *filename)
@@ -1340,6 +1381,13 @@ gdl_dock_layout_save_to_file (GdlDockLayout *layout,
return retval;
}
+/**
+ * gdl_dock_layout_is_dirty:
+ * @layout: The layout item.
+ *
+ * Checks whether the XML tree in memory is different from the file where the layout was saved.
+ * Returns: %TRUE is the layout in the memory is different from the file, else %FALSE.
+ */
gboolean
gdl_dock_layout_is_dirty (GdlDockLayout *layout)
{
@@ -1378,28 +1426,6 @@ gdl_dock_layout_get_layouts (GdlDockLayout *layout,
}
GtkWidget *
-gdl_dock_layout_get_ui (GdlDockLayout *layout)
-{
- GtkWidget *ui;
-
- g_return_val_if_fail (layout != NULL, NULL);
- ui = gdl_dock_layout_construct_ui (layout);
-
- return ui;
-}
-
-GtkWidget *
-gdl_dock_layout_get_items_ui (GdlDockLayout *layout)
-{
- GtkWidget *ui;
-
- g_return_val_if_fail (layout != NULL, NULL);
- ui = gdl_dock_layout_construct_items_ui (layout);
-
- return ui;
-}
-
-GtkWidget *
gdl_dock_layout_get_layouts_ui (GdlDockLayout *layout)
{
GtkWidget *ui;
diff --git a/src/libgdl/gdl-dock-master.c b/src/libgdl/gdl-dock-master.c
index 78cbf69ec..57d0618ec 100644
--- a/src/libgdl/gdl-dock-master.c
+++ b/src/libgdl/gdl-dock-master.c
@@ -31,6 +31,8 @@
#include "gdl-dock-master.h"
#include "gdl-dock.h"
#include "gdl-dock-item.h"
+#include "gdl-dock-notebook.h"
+#include "gdl-switcher.h"
#include "libgdlmarshal.h"
#include "libgdltypebuiltins.h"
#ifdef WIN32
diff --git a/src/libgdl/gdl-dock-master.h b/src/libgdl/gdl-dock-master.h
index 3268e68b5..266ca7ee4 100644
--- a/src/libgdl/gdl-dock-master.h
+++ b/src/libgdl/gdl-dock-master.h
@@ -44,6 +44,15 @@ typedef struct _GdlDockMaster GdlDockMaster;
typedef struct _GdlDockMasterClass GdlDockMasterClass;
typedef struct _GdlDockMasterPrivate GdlDockMasterPrivate;
+typedef enum {
+ GDL_SWITCHER_STYLE_TEXT,
+ GDL_SWITCHER_STYLE_ICON,
+ GDL_SWITCHER_STYLE_BOTH,
+ GDL_SWITCHER_STYLE_TOOLBAR,
+ GDL_SWITCHER_STYLE_TABS,
+ GDL_SWITCHER_STYLE_NONE
+} GdlSwitcherStyle;
+
struct _GdlDockMaster {
GObject object;
diff --git a/src/libgdl/gdl-dock-notebook.c b/src/libgdl/gdl-dock-notebook.c
index f6e0aeeef..3db3fab3f 100644
--- a/src/libgdl/gdl-dock-notebook.c
+++ b/src/libgdl/gdl-dock-notebook.c
@@ -270,7 +270,7 @@ gdl_dock_notebook_switch_page_cb (GtkNotebook *nb,
{
GdlDockNotebook *notebook;
GtkWidget *tablabel;
- (void)page_num;
+ GdlDockItem *item;
notebook = GDL_DOCK_NOTEBOOK (data);
@@ -293,6 +293,10 @@ gdl_dock_notebook_switch_page_cb (GtkNotebook *nb,
GDL_DOCK_OBJECT (notebook)->master)
g_signal_emit_by_name (GDL_DOCK_OBJECT (notebook)->master,
"layout-changed");
+
+ /* Signal that a new dock item has been selected */
+ item = GDL_DOCK_ITEM (gtk_notebook_get_nth_page (nb, page_num));
+ gdl_dock_item_notify_selected (item);
}
static void
diff --git a/src/libgdl/gdl-dock-object.h b/src/libgdl/gdl-dock-object.h
index 6ac36a44c..d1c27ffbd 100644
--- a/src/libgdl/gdl-dock-object.h
+++ b/src/libgdl/gdl-dock-object.h
@@ -221,7 +221,7 @@ GType gdl_dock_object_set_type_for_nick (const gchar *nick,
__PRETTY_FUNCTION__, \
G_OBJECT_TYPE_NAME (object), object, \
G_OBJECT (object)->ref_count, \
- (GTK_IS_OBJECT (object) && GTK_OBJECT_FLOATING (object)) ? "(float)" : "", \
+ (GTK_IS_OBJECT (object) && g_object_is_floating (object)) ? "(float)" : "", \
GDL_IS_DOCK_OBJECT (object) ? GDL_DOCK_OBJECT (object)->freeze_count : -1, \
##args); } G_STMT_END
diff --git a/src/libgdl/gdl-dock-paned.c b/src/libgdl/gdl-dock-paned.c
index 5d0ac17ed..141770aa2 100644
--- a/src/libgdl/gdl-dock-paned.c
+++ b/src/libgdl/gdl-dock-paned.c
@@ -710,6 +710,7 @@ gdl_dock_paned_dock (GdlDockObject *object,
}
else {
gdl_dock_item_show_grip (GDL_DOCK_ITEM (requestor));
+ gtk_widget_show (GTK_WIDGET (requestor));
GDL_DOCK_OBJECT_SET_FLAGS (requestor, GDL_DOCK_ATTACHED);
}
}
diff --git a/src/libgdl/gdl-dock-placeholder.c b/src/libgdl/gdl-dock-placeholder.c
index 33934e2e0..7a86ebe81 100644
--- a/src/libgdl/gdl-dock-placeholder.c
+++ b/src/libgdl/gdl-dock-placeholder.c
@@ -30,6 +30,7 @@
#include "gdl-tools.h"
#include "gdl-dock-placeholder.h"
#include "gdl-dock-item.h"
+#include "gdl-dock-paned.h"
#include "gdl-dock-master.h"
#include "libgdltypebuiltins.h"
@@ -494,7 +495,7 @@ gdl_dock_placeholder_dock (GdlDockObject *object,
GdlDockObject *toplevel;
if (!gdl_dock_object_is_bound (GDL_DOCK_OBJECT (ph))) {
- g_warning ("%s",_("Attempt to dock a dock object to an unbound placeholder"));
+ g_warning ("%s", _("Attempt to dock a dock object to an unbound placeholder"));
return;
}
@@ -543,7 +544,7 @@ gdl_dock_placeholder_present (GdlDockObject *object,
/* ----- Public interface ----- */
GtkWidget *
-gdl_dock_placeholder_new (gchar *name,
+gdl_dock_placeholder_new (const gchar *name,
GdlDockObject *object,
GdlDockPlacement position,
gboolean sticky)
diff --git a/src/libgdl/gdl-dock-placeholder.h b/src/libgdl/gdl-dock-placeholder.h
index aeb55da67..c7e57e204 100644
--- a/src/libgdl/gdl-dock-placeholder.h
+++ b/src/libgdl/gdl-dock-placeholder.h
@@ -55,7 +55,7 @@ struct _GdlDockPlaceholderClass {
GType gdl_dock_placeholder_get_type (void);
-GtkWidget *gdl_dock_placeholder_new (gchar *name,
+GtkWidget *gdl_dock_placeholder_new (const gchar *name,
GdlDockObject *object,
GdlDockPlacement position,
gboolean sticky);
diff --git a/src/libgdl/gdl-dock.c b/src/libgdl/gdl-dock.c
index 3b0dc4e6b..47a4f5b3d 100644
--- a/src/libgdl/gdl-dock.c
+++ b/src/libgdl/gdl-dock.c
@@ -349,21 +349,6 @@ gdl_dock_constructor (GType type,
g_signal_connect (dock, "notify::long-name",
(GCallback) gdl_dock_notify_cb, NULL);
- /* set transient for the first dock if that is a non-floating dock */
- controller = gdl_dock_master_get_controller (master);
- if (controller && GDL_IS_DOCK (controller)) {
- gboolean first_is_floating;
- g_object_get (controller, "floating", &first_is_floating, NULL);
- if (!first_is_floating) {
- GtkWidget *toplevel =
- gtk_widget_get_toplevel (GTK_WIDGET (controller));
-
- if (GTK_IS_WINDOW (toplevel))
- gtk_window_set_transient_for (GTK_WINDOW (dock->_priv->window),
- GTK_WINDOW (toplevel));
- }
- }
-
gtk_container_add (GTK_CONTAINER (dock->_priv->window), GTK_WIDGET (dock));
g_signal_connect (dock->_priv->window, "delete_event",
diff --git a/src/libgdl/gdl-stock.c b/src/libgdl/gdl-stock.c
deleted file mode 100644
index 4cb7bf929..000000000
--- a/src/libgdl/gdl-stock.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- * gdl-stock.c
- *
- * Copyright (C) 2003 Jeroen Zwartepoorte
- *
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gtk/gtk.h>
-#include "gdl-stock.h"
-#include "gdl-stock-icons.h"
-
-static GtkIconFactory *gdl_stock_factory = NULL;
-
-static struct {
- const gchar *stock_id;
- const guint8 *icon_data;
- const guint data_size;
-}
-gdl_icons[] =
-{
- { GDL_STOCK_CLOSE, stock_close_icon, sizeof (stock_close_icon) },
- { GDL_STOCK_MENU_LEFT, stock_menu_left_icon, sizeof (stock_menu_left_icon) },
- { GDL_STOCK_MENU_RIGHT, stock_menu_right_icon, sizeof (stock_menu_right_icon) }
-};
-
-static void
-icon_set_from_data (GtkIconSet *set,
- const guint8 *icon_data,
- const guint data_size,
- GtkIconSize size,
- gboolean fallback)
-{
- GtkIconSource *source;
- GdkPixbuf *pixbuf;
- GError *err = NULL;
-
- source = gtk_icon_source_new ();
-
- gtk_icon_source_set_size (source, size);
- gtk_icon_source_set_size_wildcarded (source, FALSE);
-
- pixbuf = gdk_pixbuf_new_from_inline (data_size, icon_data, FALSE, &err);
- if (err) {
- g_warning ("%s", err->message);
- g_error_free (err);
- err = NULL;
- g_object_unref (source);
- return;
- }
-
- gtk_icon_source_set_pixbuf (source, pixbuf);
-
- g_object_unref (pixbuf);
-
- gtk_icon_set_add_source (set, source);
-
- if (fallback) {
- gtk_icon_source_set_size_wildcarded (source, TRUE);
- gtk_icon_set_add_source (set, source);
- }
-
- gtk_icon_source_free (source);
-}
-
-static void
-add_icon (GtkIconFactory *factory,
- const gchar *stock_id,
- const guint8 *icon_data,
- const guint data_size)
-{
- GtkIconSet *set;
- gboolean fallback = FALSE;
-
- set = gtk_icon_factory_lookup (factory, stock_id);
-
- if (!set) {
- set = gtk_icon_set_new ();
- gtk_icon_factory_add (factory, stock_id, set);
- gtk_icon_set_unref (set);
-
- fallback = TRUE;
- }
-
- icon_set_from_data (set, icon_data, data_size, GTK_ICON_SIZE_MENU, fallback);
-}
-
-void
-gdl_stock_init (void)
-{
- static gboolean initialized = FALSE;
- gint i;
-
- if (initialized)
- return;
-
- gdl_stock_factory = gtk_icon_factory_new ();
-
- for (i = 0; i < G_N_ELEMENTS (gdl_icons); i++) {
- add_icon (gdl_stock_factory,
- gdl_icons[i].stock_id,
- gdl_icons[i].icon_data,
- gdl_icons[i].data_size);
- }
-
- gtk_icon_factory_add_default (gdl_stock_factory);
-
- initialized = TRUE;
-}
diff --git a/src/libgdl/gdl-stock.h b/src/libgdl/gdl-stock.h
deleted file mode 100644
index cb6f7abb9..000000000
--- a/src/libgdl/gdl-stock.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- * gdl-stock.h
- *
- * Copyright (C) 2003 Jeroen Zwartepoorte
- *
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef __GDL_STOCK_H__
-#define __GDL_STOCK_H__
-
-#include <glib/gmacros.h> // G_BEGIN_DECLS
-
-G_BEGIN_DECLS
-
-#define GDL_STOCK_CLOSE "gdl-close"
-#define GDL_STOCK_MENU_LEFT "gdl-menu-left"
-#define GDL_STOCK_MENU_RIGHT "gdl-menu-right"
-
-void gdl_stock_init (void);
-
-G_END_DECLS
-
-#endif /* __GDL_STOCK_H__ */
diff --git a/src/libgdl/gdl-switcher.c b/src/libgdl/gdl-switcher.c
index fea3218ae..65013e390 100644
--- a/src/libgdl/gdl-switcher.c
+++ b/src/libgdl/gdl-switcher.c
@@ -4,20 +4,22 @@
* Copyright (C) 2003 Ettore Perazzoli,
* 2007 Naba Kumar
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
+ * Library 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
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
+ *
* Copied and adapted from ESidebar.[ch] from evolution
*
* Authors: Ettore Perazzoli <ettore@ximian.com>
@@ -36,10 +38,6 @@
#include <gtk/gtk.h>
-#if HAVE_GNOME
-#include <gconf/gconf-client.h>
-#endif
-
static void gdl_switcher_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -608,12 +606,6 @@ static void
gdl_switcher_notify_cb (GObject *g_object, GParamSpec *pspec,
GdlSwitcher *switcher)
{
- gboolean show_tabs;
- (void)g_object;
- (void)pspec;
- g_return_if_fail (switcher != NULL && GDL_IS_SWITCHER (switcher));
- show_tabs = gtk_notebook_get_show_tabs (GTK_NOTEBOOK (switcher));
- gdl_switcher_set_show_buttons (switcher, !show_tabs);
}
static void
@@ -879,179 +871,87 @@ gdl_switcher_insert_page (GdlSwitcher *switcher, GtkWidget *page,
}
static void
-set_switcher_style_internal (GdlSwitcher *switcher,
- GdlSwitcherStyle switcher_style )
+set_switcher_style_toolbar (GdlSwitcher *switcher,
+ GdlSwitcherStyle switcher_style)
{
GSList *p;
- if (switcher_style == GDL_SWITCHER_STYLE_TABS &&
- switcher->priv->show == FALSE)
+ if (switcher_style == GDL_SWITCHER_STYLE_NONE
+ || switcher_style == GDL_SWITCHER_STYLE_TABS)
return;
- if (switcher_style == GDL_SWITCHER_STYLE_TABS)
- {
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), TRUE);
- return;
- }
-
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), FALSE);
-
+ if (switcher_style == GDL_SWITCHER_STYLE_TOOLBAR)
+ switcher_style = GDL_SWITCHER_STYLE_BOTH;
+
if (switcher_style == INTERNAL_MODE (switcher))
return;
-
+
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), FALSE);
+
for (p = switcher->priv->buttons; p != NULL; p = p->next) {
Button *button = p->data;
gtk_container_remove (GTK_CONTAINER (button->hbox), button->arrow);
+
+ if (gtk_widget_get_parent (button->icon))
+ gtk_container_remove (GTK_CONTAINER (button->hbox), button->icon);
+ if (gtk_widget_get_parent (button->label))
+ gtk_container_remove (GTK_CONTAINER (button->hbox), button->label);
+
switch (switcher_style) {
case GDL_SWITCHER_STYLE_TEXT:
- gtk_container_remove (GTK_CONTAINER (button->hbox), button->icon);
- if (INTERNAL_MODE (switcher)
- == GDL_SWITCHER_STYLE_ICON) {
- gtk_box_pack_start (GTK_BOX (button->hbox), button->label,
- TRUE, TRUE, 0);
- gtk_widget_show (button->label);
- }
+ gtk_box_pack_start (GTK_BOX (button->hbox), button->label,
+ TRUE, TRUE, 0);
+ gtk_widget_show (button->label);
break;
+
case GDL_SWITCHER_STYLE_ICON:
- gtk_container_remove(GTK_CONTAINER (button->hbox), button->label);
- if (INTERNAL_MODE (switcher)
- == GDL_SWITCHER_STYLE_TEXT) {
- gtk_box_pack_start (GTK_BOX (button->hbox), button->icon,
- TRUE, TRUE, 0);
- gtk_widget_show (button->icon);
- } else
- gtk_container_child_set (GTK_CONTAINER (button->hbox),
- button->icon, "expand", TRUE, NULL);
+ gtk_box_pack_start (GTK_BOX (button->hbox), button->icon,
+ TRUE, TRUE, 0);
+ gtk_widget_show (button->icon);
break;
- case GDL_SWITCHER_STYLE_BOTH:
- if (INTERNAL_MODE (switcher)
- == GDL_SWITCHER_STYLE_TEXT) {
- gtk_container_remove (GTK_CONTAINER (button->hbox),
- button->label);
- gtk_box_pack_start (GTK_BOX (button->hbox), button->icon,
- FALSE, TRUE, 0);
- gtk_widget_show (button->icon);
- } else {
- gtk_container_child_set (GTK_CONTAINER (button->hbox),
- button->icon, "expand", FALSE, NULL);
- }
- gtk_box_pack_start (GTK_BOX (button->hbox), button->label, TRUE,
- TRUE, 0);
+ case GDL_SWITCHER_STYLE_BOTH:
+ gtk_box_pack_start (GTK_BOX (button->hbox), button->icon,
+ FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (button->hbox), button->label,
+ TRUE, TRUE, 0);
+ gtk_widget_show (button->icon);
gtk_widget_show (button->label);
break;
+
default:
break;
}
- gtk_box_pack_start (GTK_BOX (button->hbox), button->arrow, FALSE,
- FALSE, 0);
- }
-}
-
-#if HAVE_GNOME
-static GConfEnumStringPair toolbar_styles[] = {
- { GDL_SWITCHER_STYLE_TEXT, "text" },
- { GDL_SWITCHER_STYLE_ICON, "icons" },
- { GDL_SWITCHER_STYLE_BOTH, "both" },
- { GDL_SWITCHER_STYLE_BOTH, "both-horiz" },
- { GDL_SWITCHER_STYLE_BOTH, "both_horiz" },
- { -1, NULL }
-};
-
-static void
-style_changed_notify (GConfClient *gconf, guint id, GConfEntry *entry,
- void *data)
-{
- GdlSwitcher *switcher = data;
- char *val;
- int switcher_style;
-
- val = gconf_client_get_string (gconf,
- "/desktop/gnome/interface/toolbar_style",
- NULL);
- if (val == NULL || !gconf_string_to_enum (toolbar_styles, val,
- &switcher_style))
- switcher_style = GDL_SWITCHER_STYLE_BOTH;
- g_free(val);
- set_switcher_style_internal (GDL_SWITCHER (switcher), switcher_style);
- switcher->priv->toolbar_style = switcher_style;
+ gtk_box_pack_start (GTK_BOX (button->hbox), button->arrow,
+ FALSE, FALSE, 0);
+ }
- gtk_widget_queue_resize (GTK_WIDGET (switcher));
+ gdl_switcher_set_show_buttons (switcher, TRUE);
}
static void
gdl_switcher_set_style (GdlSwitcher *switcher, GdlSwitcherStyle switcher_style)
{
- GConfClient *gconf_client = gconf_client_get_default ();
-
- if (switcher_style == GDL_SWITCHER_STYLE_TABS &&
- switcher->priv->show == FALSE)
- return;
-
- if (switcher->priv->switcher_style == switcher_style &&
- switcher->priv->show == TRUE)
+ if (switcher->priv->switcher_style == switcher_style)
return;
- if (switcher->priv->switcher_style == GDL_SWITCHER_STYLE_TOOLBAR) {
- if (switcher->priv->style_changed_id) {
- gconf_client_notify_remove (gconf_client,
- switcher->priv->style_changed_id);
- switcher->priv->style_changed_id = 0;
- }
+ if (switcher_style == GDL_SWITCHER_STYLE_NONE) {
+ gdl_switcher_set_show_buttons (switcher, FALSE);
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), FALSE);
}
-
- if (switcher_style != GDL_SWITCHER_STYLE_TOOLBAR) {
- set_switcher_style_internal (switcher, switcher_style);
-
- gtk_widget_queue_resize (GTK_WIDGET (switcher));
- } else {
- /* This is a little bit tricky, toolbar style is more
- * of a meta-style where the actual style is dictated by
- * the gnome toolbar setting, so that is why we have
- * the is_toolbar_style bool - it tracks the toolbar
- * style while the switcher_style member is the actual look and
- * feel */
- switcher->priv->style_changed_id =
- gconf_client_notify_add (gconf_client,
- "/desktop/gnome/interface/toolbar_style",
- style_changed_notify, switcher,
- NULL, NULL);
- style_changed_notify (gconf_client, 0, NULL, switcher);
+ else if (switcher_style == GDL_SWITCHER_STYLE_TABS) {
+ gdl_switcher_set_show_buttons (switcher, FALSE);
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), TRUE);
}
-
- g_object_unref (gconf_client);
-
- if (switcher_style != GDL_SWITCHER_STYLE_TABS)
- switcher->priv->switcher_style = switcher_style;
-}
-
-#else /* HAVE_GNOME */
-
-static void
-gdl_switcher_set_style (GdlSwitcher *switcher, GdlSwitcherStyle switcher_style)
-{
- if (switcher_style == GDL_SWITCHER_STYLE_TABS &&
- switcher->priv->show == FALSE)
- return;
-
- if (switcher->priv->switcher_style == switcher_style &&
- switcher->priv->show == TRUE)
- return;
+ else
+ set_switcher_style_toolbar (switcher, switcher_style);
- set_switcher_style_internal (switcher,
- ((switcher_style ==
- GDL_SWITCHER_STYLE_TOOLBAR)?
- GDL_SWITCHER_STYLE_BOTH : switcher_style));
gtk_widget_queue_resize (GTK_WIDGET (switcher));
-
- if (switcher_style != GDL_SWITCHER_STYLE_TABS)
- switcher->priv->switcher_style = switcher_style;
+ switcher->priv->switcher_style = switcher_style;
}
-#endif /* HAVE_GNOME */
-
static void
gdl_switcher_set_show_buttons (GdlSwitcher *switcher, gboolean show)
{
diff --git a/src/libgdl/gdl-switcher.h b/src/libgdl/gdl-switcher.h
index 9c33f8bbf..991f2da20 100644
--- a/src/libgdl/gdl-switcher.h
+++ b/src/libgdl/gdl-switcher.h
@@ -4,20 +4,22 @@
* Copyright (C) 2003 Ettore Perazzoli
* 2007 Naba Kumar
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
+* This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
+ * Library 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
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
+ *
* Authors: Ettore Perazzoli <ettore@ximian.com>
* Naba Kumar <naba@gnome.org>
*/
@@ -39,14 +41,6 @@ typedef struct _GdlSwitcher GdlSwitcher;
typedef struct _GdlSwitcherPrivate GdlSwitcherPrivate;
typedef struct _GdlSwitcherClass GdlSwitcherClass;
-typedef enum {
- GDL_SWITCHER_STYLE_TEXT,
- GDL_SWITCHER_STYLE_ICON,
- GDL_SWITCHER_STYLE_BOTH,
- GDL_SWITCHER_STYLE_TOOLBAR,
- GDL_SWITCHER_STYLE_TABS
-} GdlSwitcherStyle;
-
struct _GdlSwitcher {
GtkNotebook parent;
diff --git a/src/libgdl/gdl.h b/src/libgdl/gdl.h
index e47dc310d..467b2b67e 100644
--- a/src/libgdl/gdl.h
+++ b/src/libgdl/gdl.h
@@ -1,23 +1,22 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
* This file is part of the GNOME Devtools Libraries.
- *
+ *
* Copyright (C) 1999-2000 Dave Camp <dave@helixcode.com>
*
- * This 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 library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU 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.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __GDL_H__
@@ -28,12 +27,8 @@
#include "libgdl/gdl-dock-master.h"
#include "libgdl/gdl-dock.h"
#include "libgdl/gdl-dock-item.h"
+#include "libgdl/gdl-dock-item-grip.h"
#include "libgdl/gdl-dock-layout.h"
-#include "libgdl/gdl-dock-paned.h"
-#include "libgdl/gdl-dock-notebook.h"
-#include "libgdl/gdl-dock-tablabel.h"
#include "libgdl/gdl-dock-bar.h"
-#include "libgdl/gdl-combo-button.h"
-#include "libgdl/gdl-switcher.h"
#endif
diff --git a/src/libgdl/test-dock.c b/src/libgdl/test-dock.c
index 1e9c80111..abaecf703 100644
--- a/src/libgdl/test-dock.c
+++ b/src/libgdl/test-dock.c
@@ -81,6 +81,9 @@ create_styles_item (GtkWidget *dock)
group = create_style_button (dock, vbox1, group,
GDL_SWITCHER_STYLE_TABS,
"Notebook tabs");
+ group = create_style_button (dock, vbox1, group,
+ GDL_SWITCHER_STYLE_NONE,
+ "None of the above");
return vbox1;
}