gdl-switcher.c revision d6b764cc205f348b6d2398edd654e8a9684f5dad
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 8 -*- */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b/* gdl-switcher.c
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b *
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * Copyright (C) 2003 Ettore Perazzoli,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * 2007 Naba Kumar
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b *
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * This program is free software; you can redistribute it and/or
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * modify it under the terms of version 2 of the GNU General Public
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * License as published by the Free Software Foundation.
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b *
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * This program is distributed in the hope that it will be useful,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * but WITHOUT ANY WARRANTY; without even the implied warranty of
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * General Public License for more details.
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b *
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * You should have received a copy of the GNU General Public
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * License along with this program; if not, write to the
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * Boston, MA 02111-1307, USA.
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b *
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * Copied and adapted from ESidebar.[ch] from evolution
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b *
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * Authors: Ettore Perazzoli <ettore@ximian.com>
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * Naba Kumar <naba@gnome.org>
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#ifdef HAVE_CONFIG_H
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#include <config.h>
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#endif
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#include "gdl-i18n.h"
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#include "gdl-switcher.h"
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#include "gdl-tools.h"
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#include "libgdlmarshal.h"
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#include "libgdltypebuiltins.h"
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#include <gtk/gtk.h>
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#if HAVE_GNOME
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#include <gconf/gconf-client.h>
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#endif
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void gdl_switcher_set_property (GObject *object,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b guint prop_id,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b const GValue *value,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GParamSpec *pspec);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void gdl_switcher_get_property (GObject *object,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b guint prop_id,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GValue *value,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GParamSpec *pspec);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void gdl_switcher_add_button (GdlSwitcher *switcher,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b const gchar *label,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b const gchar *tooltips,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b const gchar *stock_id,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b const GdkPixbuf *pixbuf_icon,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gint switcher_id);
7a10406c7610c65f3600986ded11320fe870ccb9Alex Valavanis/* static void gdl_switcher_remove_button (GdlSwitcher *switcher, gint switcher_id); */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void gdl_switcher_select_page (GdlSwitcher *switcher, gint switcher_id);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void gdl_switcher_select_button (GdlSwitcher *switcher, gint switcher_id);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void gdl_switcher_set_show_buttons (GdlSwitcher *switcher, gboolean show);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void gdl_switcher_set_style (GdlSwitcher *switcher,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlSwitcherStyle switcher_style);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic GdlSwitcherStyle gdl_switcher_get_style (GdlSwitcher *switcher);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_benum {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b PROP_0,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b PROP_SWITCHER_STYLE
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b};
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_btypedef struct {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkWidget *button_widget;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkWidget *label;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkWidget *icon;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkWidget *arrow;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkWidget *hbox;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b int id;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b} Button;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstruct _GdlSwitcherPrivate {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlSwitcherStyle switcher_style;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlSwitcherStyle toolbar_style;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gboolean show;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GSList *buttons;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b guint style_changed_id;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gint buttons_height_request;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gboolean in_toggle;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b};
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bGDL_CLASS_BOILERPLATE (GdlSwitcher, gdl_switcher, GtkNotebook, GTK_TYPE_NOTEBOOK)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#define INTERNAL_MODE(switcher) (switcher->priv->switcher_style == \
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GDL_SWITCHER_STYLE_TOOLBAR ? switcher->priv->toolbar_style : \
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher->priv->switcher_style)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#define H_PADDING 2
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#define V_PADDING 2
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b/* Utility functions. */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic Button *
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bbutton_new (GtkWidget *button_widget, GtkWidget *label, GtkWidget *icon,
b25122b8f1c7572aeef3abac486346c2d33a8404Alex Valavanis GtkWidget *arrow, GtkWidget *hbox, int id)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b Button *button = g_new (Button, 1);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b button->button_widget = button_widget;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b button->label = label;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b button->icon = icon;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b button->arrow = arrow;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b button->hbox = hbox;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b button->id = id;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_ref (button_widget);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_ref (label);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_ref (icon);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_ref (arrow);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_ref (hbox);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return button;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bbutton_free (Button *button)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_unref (button->button_widget);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_unref (button->label);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_unref (button->icon);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_unref (button->hbox);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_free (button);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic gint
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_switcher_get_page_id (GtkWidget *widget)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b static gint switcher_id_count = 0;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gint switcher_id;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher_id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget),
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b "__switcher_id"));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (switcher_id <= 0) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher_id = ++switcher_id_count;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_set_data (G_OBJECT (widget), "__switcher_id",
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GINT_TO_POINTER (switcher_id));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return switcher_id;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bupdate_buttons (GdlSwitcher *switcher, int new_selected_id)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GSList *p;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher->priv->in_toggle = TRUE;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b for (p = switcher->priv->buttons; p != NULL; p = p->next) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b Button *button = p->data;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (button->id == new_selected_id) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b (button->button_widget), TRUE);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_set_sensitive (button->arrow, TRUE);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b } else {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b (button->button_widget), FALSE);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_set_sensitive (button->arrow, FALSE);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher->priv->in_toggle = FALSE;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b/* Callbacks. */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bbutton_toggled_callback (GtkToggleButton *toggle_button,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlSwitcher *switcher)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b int id = 0;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gboolean is_active = FALSE;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GSList *p;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (switcher->priv->in_toggle)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher->priv->in_toggle = TRUE;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (gtk_toggle_button_get_active (toggle_button))
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b is_active = TRUE;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b for (p = switcher->priv->buttons; p != NULL; p = p->next) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b Button *button = p->data;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (button->button_widget != GTK_WIDGET (toggle_button)) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b (button->button_widget), FALSE);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_set_sensitive (button->arrow, FALSE);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b } else {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b (button->button_widget), TRUE);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_set_sensitive (button->arrow, TRUE);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b id = button->id;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher->priv->in_toggle = FALSE;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (is_active)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gdl_switcher_select_page (switcher, id);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b/* Returns -1 if layout didn't happen because a resize request was queued */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic int
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_blayout_buttons (GdlSwitcher *switcher)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkRequisition client_requisition;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkAllocation *allocation = & GTK_WIDGET (switcher)->allocation;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlSwitcherStyle switcher_style;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gboolean icons_only;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b int num_btns = g_slist_length (switcher->priv->buttons);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b int btns_per_row;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GSList **rows, *p;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b Button *button;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b int row_number;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b int max_btn_width = 0, max_btn_height = 0;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b int optimal_layout_width = 0;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b int row_last;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b int x, y;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b int i;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b int rows_count;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b int last_buttons_height;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b last_buttons_height = switcher->priv->buttons_height_request;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GDL_CALL_PARENT (GTK_WIDGET_CLASS, size_request,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b (GTK_WIDGET (switcher), &client_requisition));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b y = allocation->y + allocation->height - V_PADDING - 1;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (num_btns == 0)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return y;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher_style = INTERNAL_MODE (switcher);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b icons_only = (switcher_style == GDL_SWITCHER_STYLE_ICON);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b /* Figure out the max width and height */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b optimal_layout_width = H_PADDING;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b for (p = switcher->priv->buttons; p != NULL; p = p->next) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkRequisition requisition;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b button = p->data;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_size_request (GTK_WIDGET (button->button_widget),
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b &requisition);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b optimal_layout_width += requisition.width + H_PADDING;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b max_btn_height = MAX (max_btn_height, requisition.height);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b max_btn_width = MAX (max_btn_width, requisition.width);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b /* Figure out how many rows and columns we'll use. */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b btns_per_row = allocation->width / (max_btn_width + H_PADDING);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b /* If all the buttons could fit in the single row, have it so */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (allocation->width >= optimal_layout_width)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b btns_per_row = num_btns;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (!icons_only) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b /* If using text buttons, we want to try to have a
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * completely filled-in grid, but if we can't, we want
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * the odd row to have just a single button.
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b while (num_btns % btns_per_row > 1)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b btns_per_row--;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b rows_count = num_btns / btns_per_row;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (num_btns % btns_per_row != 0)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b rows_count++;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b /* Assign buttons to rows */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b rows = g_new0 (GSList *, rows_count);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (!icons_only && num_btns % btns_per_row != 0) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b button = switcher->priv->buttons->data;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b rows [0] = g_slist_append (rows [0], button->button_widget);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b p = switcher->priv->buttons->next;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b row_number = p ? 1 : 0;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b } else {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b p = switcher->priv->buttons;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b row_number = 0;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b for (; p != NULL; p = p->next) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b button = p->data;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (g_slist_length (rows [row_number]) == btns_per_row)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b row_number ++;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b rows [row_number] = g_slist_append (rows [row_number],
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b button->button_widget);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b row_last = row_number;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b /* If there are more than 1 row of buttons, save the current height
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * requirement for subsequent size requests.
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (row_last > 0)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher->priv->buttons_height_request =
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b (row_last + 1) * (max_btn_height + V_PADDING) + 1;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b } else { /* Otherwize clear it */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (last_buttons_height >= 0) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher->priv->buttons_height_request = -1;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b /* If it turns out that we now require smaller height for the buttons
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * than it was last time, make a resize request to ensure our
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * size requisition is properly communicated to the parent (otherwise
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * parent tend to keep assuming the older size).
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (last_buttons_height > switcher->priv->buttons_height_request)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_queue_resize (GTK_WIDGET (switcher));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return -1;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b /* Layout the buttons. */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b for (i = row_last; i >= 0; i --) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b int len, extra_width;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b y -= max_btn_height;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b /* Check for possible size over flow (taking into account client
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * requisition
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (y < (allocation->y + client_requisition.height)) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b /* We have an overflow: Insufficient allocation */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (last_buttons_height < switcher->priv->buttons_height_request) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b /* Request for a new resize */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_queue_resize (GTK_WIDGET (switcher));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return -1;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b x = H_PADDING + allocation->x;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b len = g_slist_length (rows[i]);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (switcher_style == GDL_SWITCHER_STYLE_TEXT ||
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher_style == GDL_SWITCHER_STYLE_BOTH)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b extra_width = (allocation->width - (len * max_btn_width )
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b - (len * H_PADDING)) / len;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b else
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b extra_width = 0;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b for (p = rows [i]; p != NULL; p = p->next) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkAllocation child_allocation;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b child_allocation.x = x;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b child_allocation.y = y;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (rows_count == 1 && row_number == 0)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkRequisition child_requisition;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_size_request (GTK_WIDGET (p->data),
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b &child_requisition);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b child_allocation.width = child_requisition.width;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b else
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b child_allocation.width = max_btn_width + extra_width;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b child_allocation.height = max_btn_height;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_size_allocate (GTK_WIDGET (p->data), &child_allocation);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b x += child_allocation.width + H_PADDING;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b y -= V_PADDING;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b for (i = 0; i <= row_last; i ++)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_slist_free (rows [i]);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_free (rows);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return y;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bdo_layout (GdlSwitcher *switcher)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkAllocation *allocation = & GTK_WIDGET (switcher)->allocation;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkAllocation child_allocation;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b int y;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (switcher->priv->show) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b y = layout_buttons (switcher);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (y < 0) /* Layout did not happen and a resize was requested */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b else
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b y = allocation->y + allocation->height;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b /* Place the parent widget. */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b child_allocation.x = allocation->x;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b child_allocation.y = allocation->y;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b child_allocation.width = allocation->width;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b child_allocation.height = y - allocation->y;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GDL_CALL_PARENT (GTK_WIDGET_CLASS, size_allocate,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b (GTK_WIDGET (switcher), &child_allocation));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b/* GtkContainer methods. */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_switcher_forall (GtkContainer *container, gboolean include_internals,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkCallback callback, void *callback_data)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlSwitcher *switcher =
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GDL_SWITCHER (container);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GSList *p;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GDL_CALL_PARENT (GTK_CONTAINER_CLASS, forall,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b (GTK_CONTAINER (switcher), include_internals,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b callback, callback_data));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (include_internals) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b for (p = switcher->priv->buttons; p != NULL; p = p->next) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkWidget *widget = ((Button *) p->data)->button_widget;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b (* callback) (widget, callback_data);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_switcher_remove (GtkContainer *container, GtkWidget *widget)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gint switcher_id;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlSwitcher *switcher =
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GDL_SWITCHER (container);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GSList *p;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher_id = gdl_switcher_get_page_id (widget);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b for (p = switcher->priv->buttons; p != NULL; p = p->next) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b Button *b = (Button *) p->data;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (b->id == switcher_id) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_unparent (b->button_widget);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher->priv->buttons =
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_slist_remove_link (switcher->priv->buttons, p);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b button_free (b);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_queue_resize (GTK_WIDGET (switcher));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b break;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GDL_CALL_PARENT (GTK_CONTAINER_CLASS, remove,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b (GTK_CONTAINER (switcher), widget));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b/* GtkWidget methods. */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_switcher_size_request (GtkWidget *widget, GtkRequisition *requisition)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlSwitcher *switcher = GDL_SWITCHER (widget);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GSList *p;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gint button_height = 0;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GDL_CALL_PARENT (GTK_WIDGET_CLASS, size_request,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b (GTK_WIDGET (switcher), requisition));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (!switcher->priv->show)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b for (p = switcher->priv->buttons; p != NULL; p = p->next) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gint button_width;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b Button *button = p->data;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkRequisition button_requisition;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_size_request (button->button_widget, &button_requisition);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b button_width = button_requisition.width + 2 * H_PADDING;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b requisition->width = MAX (requisition->width, button_width);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b button_height = MAX (button_height,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b button_requisition.height + 2 * V_PADDING);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (switcher->priv->buttons_height_request > 0) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b requisition->height += switcher->priv->buttons_height_request;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b } else {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b requisition->height += button_height + V_PADDING;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_switcher_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b widget->allocation = *allocation;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b do_layout (GDL_SWITCHER (widget));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic gint
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_switcher_expose (GtkWidget *widget, GdkEventExpose *event)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GSList *p;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlSwitcher *switcher = GDL_SWITCHER (widget);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (switcher->priv->show) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b for (p = switcher->priv->buttons; p != NULL; p = p->next) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkWidget *button = ((Button *) p->data)->button_widget;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_container_propagate_expose (GTK_CONTAINER (widget),
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b button, event);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
456c673d721e5463a5a8d0a710e1cc920c4cac05Jon A. Cruz return GDL_CALL_PARENT_WITH_DEFAULT (GTK_WIDGET_CLASS, expose_event,
7a10406c7610c65f3600986ded11320fe870ccb9Alex Valavanis (widget, event), FALSE);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_switcher_map (GtkWidget *widget)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GSList *p;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlSwitcher *switcher = GDL_SWITCHER (widget);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (switcher->priv->show) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b for (p = switcher->priv->buttons; p != NULL; p = p->next) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkWidget *button = ((Button *) p->data)->button_widget;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_map (button);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GDL_CALL_PARENT (GTK_WIDGET_CLASS, map, (widget));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b/* GObject methods. */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_switcher_set_property (GObject *object,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b guint prop_id,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b const GValue *value,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GParamSpec *pspec)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlSwitcher *switcher = GDL_SWITCHER (object);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switch (prop_id) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b case PROP_SWITCHER_STYLE:
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gdl_switcher_set_style (switcher, g_value_get_enum (value));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b break;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b default:
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b break;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_switcher_get_property (GObject *object,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b guint prop_id,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GValue *value,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GParamSpec *pspec)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlSwitcher *switcher = GDL_SWITCHER (object);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switch (prop_id) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b case PROP_SWITCHER_STYLE:
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_value_set_enum (value, gdl_switcher_get_style (switcher));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b break;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b default:
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b break;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_switcher_dispose (GObject *object)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlSwitcherPrivate *priv = GDL_SWITCHER (object)->priv;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#if HAVE_GNOME
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GConfClient *gconf_client = gconf_client_get_default ();
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (priv->style_changed_id) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gconf_client_notify_remove (gconf_client, priv->style_changed_id);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b priv->style_changed_id = 0;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_unref (gconf_client);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#endif
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_slist_foreach (priv->buttons, (GFunc) button_free, NULL);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_slist_free (priv->buttons);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b priv->buttons = NULL;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GDL_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_switcher_finalize (GObject *object)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlSwitcherPrivate *priv = GDL_SWITCHER (object)->priv;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_free (priv);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GDL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b/* Signal handlers */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_switcher_notify_cb (GObject *g_object, GParamSpec *pspec,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlSwitcher *switcher)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gboolean show_tabs;
031bc7c8466696f17530077ee74a3a983df28f3eJon A. Cruz (void)g_object;
031bc7c8466696f17530077ee74a3a983df28f3eJon A. Cruz (void)pspec;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_return_if_fail (switcher != NULL && GDL_IS_SWITCHER (switcher));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b show_tabs = gtk_notebook_get_show_tabs (GTK_NOTEBOOK (switcher));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gdl_switcher_set_show_buttons (switcher, !show_tabs);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
aa99761247ff88d39faf6a989c4e06a6c5dd8e57Alex Valavanisgdl_switcher_switch_page_cb (GtkNotebook *nb, GtkWidget *page_widget,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gint page_num, GdlSwitcher *switcher)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gint switcher_id;
031bc7c8466696f17530077ee74a3a983df28f3eJon A. Cruz
031bc7c8466696f17530077ee74a3a983df28f3eJon A. Cruz (void)nb;
031bc7c8466696f17530077ee74a3a983df28f3eJon A. Cruz (void)page_num;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b /* Change switcher button */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher_id = gdl_switcher_get_page_id (page_widget);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gdl_switcher_select_button (GDL_SWITCHER (switcher), switcher_id);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_switcher_page_added_cb (GtkNotebook *nb, GtkWidget *page,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gint page_num, GdlSwitcher *switcher)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gint switcher_id;
031bc7c8466696f17530077ee74a3a983df28f3eJon A. Cruz
031bc7c8466696f17530077ee74a3a983df28f3eJon A. Cruz (void)nb;
031bc7c8466696f17530077ee74a3a983df28f3eJon A. Cruz (void)page_num;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher_id = gdl_switcher_get_page_id (page);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gdl_switcher_add_button (GDL_SWITCHER (switcher), NULL, NULL, NULL, NULL,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher_id);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gdl_switcher_select_button (GDL_SWITCHER (switcher), switcher_id);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_switcher_select_page (GdlSwitcher *switcher, gint id)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GList *children, *node;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b children = gtk_container_get_children (GTK_CONTAINER (switcher));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b node = children;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b while (node)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gint switcher_id;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher_id = gdl_switcher_get_page_id (GTK_WIDGET (node->data));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (switcher_id == id)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gint page_num;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b page_num = gtk_notebook_page_num (GTK_NOTEBOOK (switcher),
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GTK_WIDGET (node->data));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_signal_handlers_block_by_func (switcher,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gdl_switcher_switch_page_cb,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_notebook_set_current_page (GTK_NOTEBOOK (switcher), page_num);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_signal_handlers_unblock_by_func (switcher,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gdl_switcher_switch_page_cb,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b break;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b node = g_list_next (node);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_list_free (children);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b/* Initialization. */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_switcher_class_init (GdlSwitcherClass *klass)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GObjectClass *object_class = G_OBJECT_CLASS (klass);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b container_class->forall = gdl_switcher_forall;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b container_class->remove = gdl_switcher_remove;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b widget_class->size_request = gdl_switcher_size_request;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b widget_class->size_allocate = gdl_switcher_size_allocate;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b widget_class->expose_event = gdl_switcher_expose;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b widget_class->map = gdl_switcher_map;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b object_class->dispose = gdl_switcher_dispose;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b object_class->finalize = gdl_switcher_finalize;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b object_class->set_property = gdl_switcher_set_property;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b object_class->get_property = gdl_switcher_get_property;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_class_install_property (
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b object_class, PROP_SWITCHER_STYLE,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_param_spec_enum ("switcher-style", _("Switcher Style"),
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b _("Switcher buttons style"),
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GDL_TYPE_SWITCHER_STYLE,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GDL_SWITCHER_STYLE_BOTH,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b G_PARAM_READWRITE));
d6b764cc205f348b6d2398edd654e8a9684f5dadAlex Valavanis
d6b764cc205f348b6d2398edd654e8a9684f5dadAlex Valavanis gtk_rc_parse_string ("style \"gdl-button-style\"\n"
d6b764cc205f348b6d2398edd654e8a9684f5dadAlex Valavanis "{\n"
d6b764cc205f348b6d2398edd654e8a9684f5dadAlex Valavanis "GtkWidget::focus-padding = 1\n"
d6b764cc205f348b6d2398edd654e8a9684f5dadAlex Valavanis "GtkWidget::focus-line-width = 1\n"
d6b764cc205f348b6d2398edd654e8a9684f5dadAlex Valavanis "xthickness = 0\n"
d6b764cc205f348b6d2398edd654e8a9684f5dadAlex Valavanis "ythickness = 0\n"
d6b764cc205f348b6d2398edd654e8a9684f5dadAlex Valavanis "}\n"
d6b764cc205f348b6d2398edd654e8a9684f5dadAlex Valavanis "widget \"*.gdl-button\" style \"gdl-button-style\"");
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_switcher_instance_init (GdlSwitcher *switcher)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlSwitcherPrivate *priv;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
9f32e6203d2f30a5bd17dbb294c8956b714e59e6Alex Valavanis gtk_widget_set_has_window (GTK_WIDGET (switcher), FALSE);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b priv = g_new0 (GdlSwitcherPrivate, 1);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher->priv = priv;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b priv->show = TRUE;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b priv->buttons_height_request = -1;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_notebook_set_tab_pos (GTK_NOTEBOOK (switcher), GTK_POS_BOTTOM);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), FALSE);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_notebook_set_show_border (GTK_NOTEBOOK (switcher), FALSE);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gdl_switcher_set_style (switcher, GDL_SWITCHER_STYLE_BOTH);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b /* notebook signals */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_signal_connect (switcher, "switch-page",
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b G_CALLBACK (gdl_switcher_switch_page_cb), switcher);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_signal_connect (switcher, "page-added",
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b G_CALLBACK (gdl_switcher_page_added_cb), switcher);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_signal_connect (switcher, "notify::show-tabs",
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b G_CALLBACK (gdl_switcher_notify_cb), switcher);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bGtkWidget *
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_switcher_new (void)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlSwitcher *switcher = g_object_new (gdl_switcher_get_type (), NULL);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return GTK_WIDGET (switcher);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bvoid
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_switcher_add_button (GdlSwitcher *switcher, const gchar *label,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b const gchar *tooltips, const gchar *stock_id,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b const GdkPixbuf *pixbuf_icon, gint switcher_id)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
d6b764cc205f348b6d2398edd654e8a9684f5dadAlex Valavanis GtkWidget *event_box;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkWidget *button_widget;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkWidget *hbox;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkWidget *icon_widget;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkWidget *label_widget;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkWidget *arrow;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b button_widget = gtk_toggle_button_new ();
d6b764cc205f348b6d2398edd654e8a9684f5dadAlex Valavanis gtk_widget_set_name (button_widget, "gdl-button");
d6b764cc205f348b6d2398edd654e8a9684f5dadAlex Valavanis gtk_button_set_relief (GTK_BUTTON(button_widget), GTK_RELIEF_HALF);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (switcher->priv->show)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_show (button_widget);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_signal_connect (button_widget, "toggled",
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b G_CALLBACK (button_toggled_callback),
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b hbox = gtk_hbox_new (FALSE, 3);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_container_set_border_width (GTK_CONTAINER (hbox), 0);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_container_add (GTK_CONTAINER (button_widget), hbox);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_show (hbox);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
031bc7c8466696f17530077ee74a3a983df28f3eJon A. Cruz if (stock_id) {
7a10406c7610c65f3600986ded11320fe870ccb9Alex Valavanis icon_widget = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
031bc7c8466696f17530077ee74a3a983df28f3eJon A. Cruz } else if (pixbuf_icon) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b icon_widget = gtk_image_new_from_pixbuf (pixbuf_icon);
031bc7c8466696f17530077ee74a3a983df28f3eJon A. Cruz } else {
7a10406c7610c65f3600986ded11320fe870ccb9Alex Valavanis icon_widget = gtk_image_new_from_stock (GTK_STOCK_NEW, GTK_ICON_SIZE_MENU);
031bc7c8466696f17530077ee74a3a983df28f3eJon A. Cruz }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_show (icon_widget);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (!label) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gchar *text = g_strdup_printf ("Item %d", switcher_id);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b label_widget = gtk_label_new (text);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_free (text);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b } else {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b label_widget = gtk_label_new (label);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_misc_set_alignment (GTK_MISC (label_widget), 0.0, 0.5);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_show (label_widget);
d6b764cc205f348b6d2398edd654e8a9684f5dadAlex Valavanis
d6b764cc205f348b6d2398edd654e8a9684f5dadAlex Valavanis
d6b764cc205f348b6d2398edd654e8a9684f5dadAlex Valavanis gtk_widget_set_tooltip_text (button_widget,
d6b764cc205f348b6d2398edd654e8a9684f5dadAlex Valavanis tooltips);
d6b764cc205f348b6d2398edd654e8a9684f5dadAlex Valavanis
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switch (INTERNAL_MODE (switcher)) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b case GDL_SWITCHER_STYLE_TEXT:
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_box_pack_start (GTK_BOX (hbox), label_widget, TRUE, TRUE, 0);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b break;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b case GDL_SWITCHER_STYLE_ICON:
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_box_pack_start (GTK_BOX (hbox), icon_widget, TRUE, TRUE, 0);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b break;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b case GDL_SWITCHER_STYLE_BOTH:
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b default:
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_box_pack_start (GTK_BOX (hbox), icon_widget, FALSE, TRUE, 0);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_box_pack_start (GTK_BOX (hbox), label_widget, TRUE, TRUE, 0);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b break;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b arrow = gtk_arrow_new (GTK_ARROW_UP, GTK_SHADOW_NONE);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_show (arrow);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_box_pack_start (GTK_BOX (hbox), arrow, FALSE, FALSE, 0);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher->priv->buttons =
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_slist_append (switcher->priv->buttons,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b button_new (button_widget, label_widget,
d6b764cc205f348b6d2398edd654e8a9684f5dadAlex Valavanis icon_widget,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b arrow, hbox, switcher_id));
d6b764cc205f348b6d2398edd654e8a9684f5dadAlex Valavanis
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_set_parent (button_widget, GTK_WIDGET (switcher));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_queue_resize (GTK_WIDGET (switcher));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
7a10406c7610c65f3600986ded11320fe870ccb9Alex Valavanis#if 0
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_switcher_remove_button (GdlSwitcher *switcher, gint switcher_id)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GSList *p;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b for (p = switcher->priv->buttons; p != NULL; p = p->next) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b Button *button = p->data;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (button->id == switcher_id)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_container_remove (GTK_CONTAINER (switcher),
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b button->button_widget);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b break;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_queue_resize (GTK_WIDGET (switcher));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
7a10406c7610c65f3600986ded11320fe870ccb9Alex Valavanis#endif
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_switcher_select_button (GdlSwitcher *switcher, gint switcher_id)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b update_buttons (switcher, switcher_id);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b /* Select the notebook page associated with this button */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gdl_switcher_select_page (switcher, switcher_id);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgint
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_switcher_insert_page (GdlSwitcher *switcher, GtkWidget *page,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GtkWidget *tab_widget, const gchar *label,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b const gchar *tooltips, const gchar *stock_id,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b const GdkPixbuf *pixbuf_icon, gint position)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gint ret_position;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gint switcher_id;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_signal_handlers_block_by_func (switcher,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gdl_switcher_page_added_cb,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (!tab_widget) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b tab_widget = gtk_label_new (label);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_show (tab_widget);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher_id = gdl_switcher_get_page_id (page);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gdl_switcher_add_button (switcher, label, tooltips, stock_id, pixbuf_icon, switcher_id);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b ret_position = gtk_notebook_insert_page (GTK_NOTEBOOK (switcher), page,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b tab_widget, position);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_signal_handlers_unblock_by_func (switcher,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gdl_switcher_page_added_cb,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return ret_position;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bset_switcher_style_internal (GdlSwitcher *switcher,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlSwitcherStyle switcher_style )
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GSList *p;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (switcher_style == GDL_SWITCHER_STYLE_TABS &&
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher->priv->show == FALSE)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (switcher_style == GDL_SWITCHER_STYLE_TABS)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), TRUE);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), FALSE);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (switcher_style == INTERNAL_MODE (switcher))
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b for (p = switcher->priv->buttons; p != NULL; p = p->next) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b Button *button = p->data;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_container_remove (GTK_CONTAINER (button->hbox), button->arrow);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switch (switcher_style) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b case GDL_SWITCHER_STYLE_TEXT:
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_container_remove (GTK_CONTAINER (button->hbox), button->icon);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (INTERNAL_MODE (switcher)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b == GDL_SWITCHER_STYLE_ICON) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_box_pack_start (GTK_BOX (button->hbox), button->label,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b TRUE, TRUE, 0);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_show (button->label);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b break;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b case GDL_SWITCHER_STYLE_ICON:
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_container_remove(GTK_CONTAINER (button->hbox), button->label);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (INTERNAL_MODE (switcher)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b == GDL_SWITCHER_STYLE_TEXT) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_box_pack_start (GTK_BOX (button->hbox), button->icon,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b TRUE, TRUE, 0);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_show (button->icon);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b } else
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_container_child_set (GTK_CONTAINER (button->hbox),
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b button->icon, "expand", TRUE, NULL);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b break;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b case GDL_SWITCHER_STYLE_BOTH:
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (INTERNAL_MODE (switcher)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b == GDL_SWITCHER_STYLE_TEXT) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_container_remove (GTK_CONTAINER (button->hbox),
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b button->label);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_box_pack_start (GTK_BOX (button->hbox), button->icon,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b FALSE, TRUE, 0);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_show (button->icon);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b } else {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_container_child_set (GTK_CONTAINER (button->hbox),
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b button->icon, "expand", FALSE, NULL);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_box_pack_start (GTK_BOX (button->hbox), button->label, TRUE,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b TRUE, 0);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_show (button->label);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b break;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b default:
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b break;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_box_pack_start (GTK_BOX (button->hbox), button->arrow, FALSE,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b FALSE, 0);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#if HAVE_GNOME
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic GConfEnumStringPair toolbar_styles[] = {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b { GDL_SWITCHER_STYLE_TEXT, "text" },
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b { GDL_SWITCHER_STYLE_ICON, "icons" },
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b { GDL_SWITCHER_STYLE_BOTH, "both" },
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b { GDL_SWITCHER_STYLE_BOTH, "both-horiz" },
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b { GDL_SWITCHER_STYLE_BOTH, "both_horiz" },
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b { -1, NULL }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b};
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstyle_changed_notify (GConfClient *gconf, guint id, GConfEntry *entry,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b void *data)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GdlSwitcher *switcher = data;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b char *val;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b int switcher_style;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b val = gconf_client_get_string (gconf,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b "/desktop/gnome/interface/toolbar_style",
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b NULL);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (val == NULL || !gconf_string_to_enum (toolbar_styles, val,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b &switcher_style))
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher_style = GDL_SWITCHER_STYLE_BOTH;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_free(val);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b set_switcher_style_internal (GDL_SWITCHER (switcher), switcher_style);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher->priv->toolbar_style = switcher_style;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_queue_resize (GTK_WIDGET (switcher));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_switcher_set_style (GdlSwitcher *switcher, GdlSwitcherStyle switcher_style)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GConfClient *gconf_client = gconf_client_get_default ();
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (switcher_style == GDL_SWITCHER_STYLE_TABS &&
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher->priv->show == FALSE)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (switcher->priv->switcher_style == switcher_style &&
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher->priv->show == TRUE)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (switcher->priv->switcher_style == GDL_SWITCHER_STYLE_TOOLBAR) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (switcher->priv->style_changed_id) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gconf_client_notify_remove (gconf_client,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher->priv->style_changed_id);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher->priv->style_changed_id = 0;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (switcher_style != GDL_SWITCHER_STYLE_TOOLBAR) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b set_switcher_style_internal (switcher, switcher_style);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_queue_resize (GTK_WIDGET (switcher));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b } else {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b /* This is a little bit tricky, toolbar style is more
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * of a meta-style where the actual style is dictated by
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * the gnome toolbar setting, so that is why we have
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * the is_toolbar_style bool - it tracks the toolbar
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * style while the switcher_style member is the actual look and
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * feel */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher->priv->style_changed_id =
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gconf_client_notify_add (gconf_client,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b "/desktop/gnome/interface/toolbar_style",
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b style_changed_notify, switcher,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b NULL, NULL);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b style_changed_notify (gconf_client, 0, NULL, switcher);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b g_object_unref (gconf_client);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (switcher_style != GDL_SWITCHER_STYLE_TABS)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher->priv->switcher_style = switcher_style;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#else /* HAVE_GNOME */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_switcher_set_style (GdlSwitcher *switcher, GdlSwitcherStyle switcher_style)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (switcher_style == GDL_SWITCHER_STYLE_TABS &&
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher->priv->show == FALSE)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (switcher->priv->switcher_style == switcher_style &&
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher->priv->show == TRUE)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b set_switcher_style_internal (switcher,
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b ((switcher_style ==
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GDL_SWITCHER_STYLE_TOOLBAR)?
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GDL_SWITCHER_STYLE_BOTH : switcher_style));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_queue_resize (GTK_WIDGET (switcher));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (switcher_style != GDL_SWITCHER_STYLE_TABS)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher->priv->switcher_style = switcher_style;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b#endif /* HAVE_GNOME */
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic void
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_switcher_set_show_buttons (GdlSwitcher *switcher, gboolean show)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b GSList *p;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (switcher->priv->show == show)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b for (p = switcher->priv->buttons; p != NULL; p = p->next) {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b Button *button = p->data;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (show)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_show (button->button_widget);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b else
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_hide (button->button_widget);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b }
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b switcher->priv->show = show;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b gtk_widget_queue_resize (GTK_WIDGET (switcher));
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic GdlSwitcherStyle
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bgdl_switcher_get_style (GdlSwitcher *switcher)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b{
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b if (!switcher->priv->show)
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return GDL_SWITCHER_STYLE_TABS;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b return switcher->priv->switcher_style;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b}