Commit bc51bea7 authored by Naba Kumar's avatar Naba Kumar

Added a properly 'switcher-style' that sets the global switcher style for

	* gdl/gdl-dock-master.c: (gdl_dock_master_class_init),
	(gdl_dock_master_instance_init), (gdl_dock_master_set_property),
	(gdl_dock_master_get_property), (gdl_dock_master_add),
	(set_switcher_style_foreach), (gdl_dock_master_set_switcher_style):
	Added a properly 'switcher-style' that sets the global switcher
	style for all notebook items.
	
	* gdl/gdl-switcher.c: (layout_buttons),
	(gdl_switcher_set_property), (gdl_switcher_get_property),
	(gdl_switcher_class_init), (gdl_switcher_instance_init),
	(gdl_switcher_add_button), (set_switcher_style_internal),
	(style_changed_notify), (gdl_switcher_set_style),
	(gdl_switcher_get_style), gdl/gdl-switcher.h: Renamed 'mode' to
	'style' and added a GDL_SWITCHER_STYLE_TABS. Set/get style as
	property.
	
	* gdl/test-dock.c: (on_style_button_toggled),
	(create_style_button), (create_styles_item), (main): Added
	switcher style test code.
	
	* gdl/gdl-dock-paned.c: (gdl_dock_paned_dock): Got proper pane
	resizing patch from screem's version of gdl (which was in turn
	taken from monodevelop).


svn path=/trunk/; revision=353
parent 85e2a47c
2007-04-04 Naba Kumar <naba.kumar@gnome.org>
* gdl/gdl-dock-master.c: (gdl_dock_master_class_init),
(gdl_dock_master_instance_init), (gdl_dock_master_set_property),
(gdl_dock_master_get_property), (gdl_dock_master_add),
(set_switcher_style_foreach), (gdl_dock_master_set_switcher_style):
Added a properly 'switcher-style' that sets the global switcher
style for all notebook items.
* gdl/gdl-switcher.c: (layout_buttons),
(gdl_switcher_set_property), (gdl_switcher_get_property),
(gdl_switcher_class_init), (gdl_switcher_instance_init),
(gdl_switcher_add_button), (set_switcher_style_internal),
(style_changed_notify), (gdl_switcher_set_style),
(gdl_switcher_get_style), gdl/gdl-switcher.h: Renamed 'mode' to
'style' and added a GDL_SWITCHER_STYLE_TABS. Set/get style as
property.
* gdl/test-dock.c: (on_style_button_toggled),
(create_style_button), (create_styles_item), (main): Added
switcher style test code.
* gdl/gdl-dock-paned.c: (gdl_dock_paned_dock): Got proper pane
resizing patch from screem's version of gdl (which was in turn
taken from monodevelop).
2007-04-03 Naba Kumar <naba.kumar@gnome.org>
* configure.in: Added HAVE_GNOME config define.
......
......@@ -32,7 +32,7 @@
#include "gdl-dock.h"
#include "gdl-dock-item.h"
#include "libgdlmarshal.h"
#include "libgdltypebuiltins.h"
/* ----- Private prototypes ----- */
......@@ -70,12 +70,16 @@ static void gdl_dock_master_xor_rect (GdlDockMaster *master);
static void gdl_dock_master_layout_changed (GdlDockMaster *master);
static void gdl_dock_master_set_switcher_style (GdlDockMaster *master,
GdlSwitcherStyle switcher_style);
/* ----- Private data types and variables ----- */
enum {
PROP_0,
PROP_DEFAULT_TITLE,
PROP_LOCKED
PROP_LOCKED,
PROP_SWITCHER_STYLE
};
enum {
......@@ -103,6 +107,8 @@ struct _GdlDockMasterPrivate {
*/
GHashTable *locked_items;
GHashTable *unlocked_items;
GdlSwitcherStyle switcher_style;
};
#define COMPUTE_LOCKED(master) \
......@@ -143,6 +149,14 @@ gdl_dock_master_class_init (GdlDockMasterClass *klass)
-1, 1, 0,
G_PARAM_READWRITE));
g_object_class_install_property (
g_object_class, PROP_SWITCHER_STYLE,
g_param_spec_enum ("switcher-style", _("Switcher Style"),
_("Switcher buttons style"),
GDL_TYPE_SWITCHER_STYLE,
GDL_SWITCHER_STYLE_BOTH,
G_PARAM_READWRITE));
master_signals [LAYOUT_CHANGED] =
g_signal_new ("layout-changed",
G_TYPE_FROM_CLASS (klass),
......@@ -168,7 +182,7 @@ gdl_dock_master_instance_init (GdlDockMaster *master)
master->_priv = g_new0 (GdlDockMasterPrivate, 1);
master->_priv->number = 1;
master->_priv->switcher_style = GDL_SWITCHER_STYLE_BOTH;
master->_priv->locked_items = g_hash_table_new (g_direct_hash, g_direct_equal);
master->_priv->unlocked_items = g_hash_table_new (g_direct_hash, g_direct_equal);
}
......@@ -342,6 +356,9 @@ gdl_dock_master_set_property (GObject *object,
if (g_value_get_int (value) >= 0)
gdl_dock_master_lock_unlock (master, (g_value_get_int (value) > 0));
break;
case PROP_SWITCHER_STYLE:
gdl_dock_master_set_switcher_style (master, g_value_get_enum (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -363,6 +380,9 @@ gdl_dock_master_get_property (GObject *object,
case PROP_LOCKED:
g_value_set_int (value, COMPUTE_LOCKED (master));
break;
case PROP_SWITCHER_STYLE:
g_value_set_enum (value, master->_priv->switcher_style);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -791,6 +811,14 @@ gdl_dock_master_add (GdlDockMaster *master,
item_notify_cb (object, NULL, master);
}
/* If the item is notebook, set the switcher style */
if (GDL_IS_DOCK_NOTEBOOK (object) &&
GDL_IS_SWITCHER (GDL_DOCK_ITEM (object)->child))
{
g_object_set (GDL_DOCK_ITEM (object)->child, "switcher-style",
master->_priv->switcher_style, NULL);
}
/* post a layout_changed emission if the item is not automatic
* (since it should be added to the items model) */
if (!GDL_DOCK_OBJECT_AUTOMATIC (object)) {
......@@ -917,3 +945,46 @@ gdl_dock_master_set_controller (GdlDockMaster *master,
g_object_unref (master);
}
}
static void
set_switcher_style_foreach (GtkWidget *obj, gpointer user_data)
{
GdlSwitcherStyle style = GPOINTER_TO_INT (user_data);
if (!GDL_IS_DOCK_ITEM (obj))
return;
if (GDL_IS_DOCK_NOTEBOOK (obj)) {
GtkWidget *child = GDL_DOCK_ITEM (obj)->child;
if (GDL_IS_SWITCHER (child)) {
g_object_set (child, "switcher-style", style, NULL);
}
} else if (gdl_dock_object_is_compound (GDL_DOCK_OBJECT (obj))) {
gtk_container_foreach (GTK_CONTAINER (obj),
set_switcher_style_foreach,
user_data);
}
}
static void
gdl_dock_master_set_switcher_style (GdlDockMaster *master,
GdlSwitcherStyle switcher_style)
{
GList *l;
g_return_if_fail (GDL_IS_DOCK_MASTER (master));
master->_priv->switcher_style = switcher_style;
for (l = master->toplevel_docks; l; l = l->next) {
GdlDock *dock = GDL_DOCK (l->data);
if (dock->root)
set_switcher_style_foreach (GTK_WIDGET (dock->root),
GINT_TO_POINTER (switcher_style));
}
/* just to be sure hidden items are set too */
gdl_dock_master_foreach (master, (GFunc) set_switcher_style_foreach,
GINT_TO_POINTER (switcher_style));
}
......@@ -535,12 +535,25 @@ gdl_dock_paned_dock (GdlDockObject *object,
{
GtkPaned *paned;
gboolean done = FALSE;
gboolean hresize = FALSE;
gboolean wresize = FALSE;
gint temp = 0;
g_return_if_fail (GDL_IS_DOCK_PANED (object));
g_return_if_fail (GDL_DOCK_ITEM (object)->child != NULL);
paned = GTK_PANED (GDL_DOCK_ITEM (object)->child);
if (GDL_IS_DOCK_ITEM (requestor)) {
g_object_get (G_OBJECT (requestor), "preferred_height", &temp, NULL);
if (temp == -2)
hresize = TRUE;
temp = 0;
g_object_get (G_OBJECT (requestor), "preferred_width", &temp, NULL);
if (temp == -2)
wresize = TRUE;
}
/* see if we can dock the item in our paned */
switch (GDL_DOCK_ITEM (object)->orientation) {
case GTK_ORIENTATION_HORIZONTAL:
......@@ -554,10 +567,10 @@ gdl_dock_paned_dock (GdlDockObject *object,
break;
case GTK_ORIENTATION_VERTICAL:
if (!paned->child1 && position == GDL_DOCK_TOP) {
gtk_paned_pack1 (paned, GTK_WIDGET (requestor), FALSE, FALSE);
gtk_paned_pack1 (paned, GTK_WIDGET (requestor), hresize, FALSE);
done = TRUE;
} else if (!paned->child2 && position == GDL_DOCK_BOTTOM) {
gtk_paned_pack2 (paned, GTK_WIDGET (requestor), TRUE, FALSE);
gtk_paned_pack2 (paned, GTK_WIDGET (requestor), hresize, FALSE);
done = TRUE;
}
break;
......
......@@ -28,9 +28,11 @@
#include <config.h>
#endif
#include "gdl-i18n.h"
#include "gdl-switcher.h"
#include "gdl-tools.h"
#include "libgdlmarshal.h"
#include "libgdltypebuiltins.h"
#include <gtk/gtk.h>
#include <gtk/gtkhbox.h>
......@@ -43,6 +45,15 @@
#include <libgnome/gnome-gconf.h>
#endif
static void gdl_switcher_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gdl_switcher_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void gdl_switcher_add_button (GdlSwitcher *switcher,
const gchar *label,
const gchar *tooltips,
......@@ -52,6 +63,14 @@ static void gdl_switcher_remove_button (GdlSwitcher *switcher, gint switcher_id)
static void gdl_switcher_select_page (GdlSwitcher *switcher, gint switcher_id);
static void gdl_switcher_select_button (GdlSwitcher *switcher, gint switcher_id);
static void gdl_switcher_set_show_buttons (GdlSwitcher *switcher, gboolean show);
static void gdl_switcher_set_style (GdlSwitcher *switcher,
GdlSwitcherStyle switcher_style);
static GdlSwitcherStyle gdl_switcher_get_style (GdlSwitcher *switcher);
enum {
PROP_0,
PROP_SWITCHER_STYLE
};
typedef struct {
GtkWidget *button_widget;
......@@ -64,8 +83,8 @@ typedef struct {
} Button;
struct _GdlSwitcherPrivate {
GdlSwitcherMode mode;
GdlSwitcherMode toolbar_mode;
GdlSwitcherStyle switcher_style;
GdlSwitcherStyle toolbar_style;
gboolean show;
GSList *buttons;
......@@ -77,9 +96,9 @@ struct _GdlSwitcherPrivate {
GDL_CLASS_BOILERPLATE (GdlSwitcher, gdl_switcher, GtkNotebook, GTK_TYPE_NOTEBOOK)
#define INTERNAL_MODE(switcher) (switcher->priv->mode == \
GDL_SWITCHER_MODE_TOOLBAR ? switcher->priv->toolbar_mode : \
switcher->priv->mode)
#define INTERNAL_MODE(switcher) (switcher->priv->switcher_style == \
GDL_SWITCHER_STYLE_TOOLBAR ? switcher->priv->toolbar_style : \
switcher->priv->switcher_style)
#define H_PADDING 2
#define V_PADDING 2
......@@ -207,7 +226,7 @@ layout_buttons (GdlSwitcher *switcher)
{
GtkRequisition client_requisition;
GtkAllocation *allocation = & GTK_WIDGET (switcher)->allocation;
GdlSwitcherMode mode;
GdlSwitcherStyle switcher_style;
gboolean icons_only;
int num_btns = g_slist_length (switcher->priv->buttons);
int btns_per_row;
......@@ -232,8 +251,8 @@ layout_buttons (GdlSwitcher *switcher)
if (num_btns == 0)
return y;
mode = INTERNAL_MODE (switcher);
icons_only = (mode == GDL_SWITCHER_MODE_ICON);
switcher_style = INTERNAL_MODE (switcher);
icons_only = (switcher_style == GDL_SWITCHER_STYLE_ICON);
/* Figure out the max width and height */
optimal_layout_width = H_PADDING;
......@@ -337,8 +356,8 @@ layout_buttons (GdlSwitcher *switcher)
}
x = H_PADDING + allocation->x;
len = g_slist_length (rows[i]);
if (mode == GDL_SWITCHER_MODE_TEXT ||
mode == GDL_SWITCHER_MODE_BOTH)
if (switcher_style == GDL_SWITCHER_STYLE_TEXT ||
switcher_style == GDL_SWITCHER_STYLE_BOTH)
extra_width = (allocation->width - (len * max_btn_width )
- (len * H_PADDING)) / len;
else
......@@ -521,6 +540,42 @@ gdl_switcher_map (GtkWidget *widget)
/* GObject methods. */
static void
gdl_switcher_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GdlSwitcher *switcher = GDL_SWITCHER (object);
switch (prop_id) {
case PROP_SWITCHER_STYLE:
gdl_switcher_set_style (switcher, g_value_get_enum (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gdl_switcher_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GdlSwitcher *switcher = GDL_SWITCHER (object);
switch (prop_id) {
case PROP_SWITCHER_STYLE:
g_value_set_enum (value, gdl_switcher_get_style (switcher));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gdl_switcher_dispose (GObject *object)
{
......@@ -641,6 +696,16 @@ gdl_switcher_class_init (GdlSwitcherClass *klass)
object_class->dispose = gdl_switcher_dispose;
object_class->finalize = gdl_switcher_finalize;
object_class->set_property = gdl_switcher_set_property;
object_class->get_property = gdl_switcher_get_property;
g_object_class_install_property (
object_class, PROP_SWITCHER_STYLE,
g_param_spec_enum ("switcher-style", _("Switcher Style"),
_("Switcher buttons style"),
GDL_TYPE_SWITCHER_STYLE,
GDL_SWITCHER_STYLE_BOTH,
G_PARAM_READWRITE));
}
static void
......@@ -659,7 +724,7 @@ gdl_switcher_instance_init (GdlSwitcher *switcher)
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (switcher), GTK_POS_BOTTOM);
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), FALSE);
gtk_notebook_set_show_border (GTK_NOTEBOOK (switcher), FALSE);
gdl_switcher_set_mode (switcher, GDL_SWITCHER_MODE_TOOLBAR);
gdl_switcher_set_style (switcher, GDL_SWITCHER_STYLE_BOTH);
/* notebook signals */
g_signal_connect (switcher, "switch-page",
......@@ -717,15 +782,15 @@ gdl_switcher_add_button (GdlSwitcher *switcher, const gchar *label,
tooltips, NULL);
switch (INTERNAL_MODE (switcher)) {
case GDL_SWITCHER_MODE_TEXT:
case GDL_SWITCHER_STYLE_TEXT:
gtk_box_pack_start (GTK_BOX (hbox), label_widget, TRUE, TRUE, 0);
gtk_tooltips_disable (button_tooltips);
break;
case GDL_SWITCHER_MODE_ICON:
case GDL_SWITCHER_STYLE_ICON:
gtk_box_pack_start (GTK_BOX (hbox), icon_widget, TRUE, TRUE, 0);
gtk_tooltips_enable (button_tooltips);
break;
case GDL_SWITCHER_MODE_BOTH:
case GDL_SWITCHER_STYLE_BOTH:
default:
gtk_box_pack_start (GTK_BOX (hbox), icon_widget, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox), label_widget, TRUE, TRUE, 0);
......@@ -799,40 +864,46 @@ gdl_switcher_insert_page (GdlSwitcher *switcher, GtkWidget *page,
return ret_position;
}
GdlSwitcherMode
gdl_switcher_get_mode (GdlSwitcher *switcher)
{
return switcher->priv->mode;
}
static void
set_mode_internal (GdlSwitcher *switcher,
GdlSwitcherMode mode )
set_switcher_style_internal (GdlSwitcher *switcher,
GdlSwitcherStyle switcher_style )
{
GSList *p;
if (switcher_style == GDL_SWITCHER_STYLE_TABS &&
switcher->priv->show == FALSE)
return;
if (mode == INTERNAL_MODE (switcher))
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 == INTERNAL_MODE (switcher))
return;
for (p = switcher->priv->buttons; p != NULL; p = p->next) {
Button *button = p->data;
gtk_container_remove (GTK_CONTAINER (button->hbox), button->arrow);
switch (mode) {
case GDL_SWITCHER_MODE_TEXT:
switch (switcher_style) {
case GDL_SWITCHER_STYLE_TEXT:
gtk_container_remove (GTK_CONTAINER (button->hbox), button->icon);
if (INTERNAL_MODE (switcher)
== GDL_SWITCHER_MODE_ICON) {
== GDL_SWITCHER_STYLE_ICON) {
gtk_box_pack_start (GTK_BOX (button->hbox), button->label,
TRUE, TRUE, 0);
gtk_widget_show (button->label);
gtk_tooltips_disable (button->tooltips);
}
break;
case GDL_SWITCHER_MODE_ICON:
case GDL_SWITCHER_STYLE_ICON:
gtk_container_remove(GTK_CONTAINER (button->hbox), button->label);
if (INTERNAL_MODE (switcher)
== GDL_SWITCHER_MODE_TEXT) {
== GDL_SWITCHER_STYLE_TEXT) {
gtk_box_pack_start (GTK_BOX (button->hbox), button->icon,
TRUE, TRUE, 0);
gtk_widget_show (button->icon);
......@@ -841,9 +912,9 @@ set_mode_internal (GdlSwitcher *switcher,
button->icon, "expand", TRUE, NULL);
gtk_tooltips_enable (button->tooltips);
break;
case GDL_SWITCHER_MODE_BOTH:
case GDL_SWITCHER_STYLE_BOTH:
if (INTERNAL_MODE (switcher)
== GDL_SWITCHER_MODE_TEXT) {
== GDL_SWITCHER_STYLE_TEXT) {
gtk_container_remove (GTK_CONTAINER (button->hbox),
button->label);
gtk_box_pack_start (GTK_BOX (button->hbox), button->icon,
......@@ -869,11 +940,11 @@ set_mode_internal (GdlSwitcher *switcher,
#if HAVE_GNOME
static GConfEnumStringPair toolbar_styles[] = {
{ GDL_SWITCHER_MODE_TEXT, "text" },
{ GDL_SWITCHER_MODE_ICON, "icons" },
{ GDL_SWITCHER_MODE_BOTH, "both" },
{ GDL_SWITCHER_MODE_BOTH, "both-horiz" },
{ GDL_SWITCHER_MODE_BOTH, "both_horiz" },
{ 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 }
};
......@@ -883,30 +954,36 @@ style_changed_notify (GConfClient *gconf, guint id, GConfEntry *entry,
{
GdlSwitcher *switcher = data;
char *val;
int mode;
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, &mode))
mode = GDL_SWITCHER_MODE_BOTH;
if (val == NULL || !gconf_string_to_enum (toolbar_styles, val,
&switcher_style))
switcher_style = GDL_SWITCHER_STYLE_BOTH;
g_free(val);
set_mode_internal (GDL_SWITCHER (switcher), mode);
switcher->priv->toolbar_mode = mode;
set_switcher_style_internal (GDL_SWITCHER (switcher), switcher_style);
switcher->priv->toolbar_style = switcher_style;
gtk_widget_queue_resize (GTK_WIDGET (switcher));
}
void
gdl_switcher_set_mode (GdlSwitcher *switcher, GdlSwitcherMode mode)
static void
gdl_switcher_set_style (GdlSwitcher *switcher, GdlSwitcherStyle switcher_style)
{
GConfClient *gconf_client = gconf_client_get_default ();
if (switcher->priv->mode == mode)
if (switcher_style == GDL_SWITCHER_STYLE_TABS &&
switcher->priv->show == FALSE)
return;
if (switcher->priv->switcher_style == switcher_style &&
switcher->priv->show == TRUE)
return;
if (switcher->priv->mode == GDL_SWITCHER_MODE_TOOLBAR) {
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);
......@@ -914,16 +991,16 @@ gdl_switcher_set_mode (GdlSwitcher *switcher, GdlSwitcherMode mode)
}
}
if (mode != GDL_SWITCHER_MODE_TOOLBAR) {
set_mode_internal (switcher, mode);
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 mode is more
* of a meta-mode where the actual mode is dictated by
/* 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_mode bool - it tracks the toolbar
* mode while the mode member is the actual look and
* 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,
......@@ -935,21 +1012,31 @@ gdl_switcher_set_mode (GdlSwitcher *switcher, GdlSwitcherMode mode)
g_object_unref (gconf_client);
switcher->priv->mode = mode;
if (switcher_style != GDL_SWITCHER_STYLE_TABS)
switcher->priv->switcher_style = switcher_style;
}
#else /* HAVE_GNOME */
void
gdl_switcher_set_mode (GdlSwitcher *switcher, GdlSwitcherMode mode)
static void
gdl_switcher_set_style (GdlSwitcher *switcher, GdlSwitcherStyle switcher_style)
{
if (switcher->priv->mode == mode)
if (switcher_style == GDL_SWITCHER_STYLE_TABS &&
switcher->priv->show == FALSE)
return;
if (switcher->priv->switcher_style == switcher_style &&
switcher->priv->show == TRUE)
return;
set_mode_internal (switcher, ((mode == GDL_SWITCHER_MODE_TOOLBAR)?
GDL_SWITCHER_MODE_BOTH : mode));
set_switcher_style_internal (switcher,
((switcher_style ==
GDL_SWITCHER_STYLE_TOOLBAR)?
GDL_SWITCHER_STYLE_BOTH : switcher_style));
gtk_widget_queue_resize (GTK_WIDGET (switcher));
switcher->priv->mode = mode;
if (switcher_style != GDL_SWITCHER_STYLE_TABS)
switcher->priv->switcher_style = switcher_style;
}
#endif /* HAVE_GNOME */
......@@ -975,3 +1062,11 @@ gdl_switcher_set_show_buttons (GdlSwitcher *switcher, gboolean show)
gtk_widget_queue_resize (GTK_WIDGET (switcher));
}
static GdlSwitcherStyle
gdl_switcher_get_style (GdlSwitcher *switcher)
{
if (!switcher->priv->show)
return GDL_SWITCHER_STYLE_TABS;
return switcher->priv->switcher_style;
}
......@@ -27,6 +27,8 @@
#include <gtk/gtknotebook.h>
G_BEGIN_DECLS
#define GDL_TYPE_SWITCHER (gdl_switcher_get_type ())
#define GDL_SWITCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_SWITCHER, GdlSwitcher))
#define GDL_SWITCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_SWITCHER, GdlSwitcherClass))
......@@ -38,11 +40,12 @@ typedef struct _GdlSwitcherPrivate GdlSwitcherPrivate;
typedef struct _GdlSwitcherClass GdlSwitcherClass;
typedef enum {
GDL_SWITCHER_MODE_TEXT,
GDL_SWITCHER_MODE_ICON,
GDL_SWITCHER_MODE_BOTH,
GDL_SWITCHER_MODE_TOOLBAR
} GdlSwitcherMode;
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;
......@@ -52,8 +55,6 @@ struct _GdlSwitcher {
struct _GdlSwitcherClass {
GtkNotebookClass parent_class;
void (* button_selected) (GdlSwitcher *switcher, int id);
};
GType gdl_switcher_get_type (void);
......@@ -66,10 +67,6 @@ gint gdl_switcher_insert_page (GdlSwitcher *switcher,
const gchar *tooltips,
const gchar *stock_id,
gint position);
void gdl_switcher_set_mode (GdlSwitcher *switcher,
GdlSwitcherMode mode);
GdlSwitcherMode gdl_switcher_get_mode (GdlSwitcher *switcher);
G_END_DECLS
#endif /* _GDL_SWITCHER_H_ */
......@@ -15,11 +15,74 @@
#include "gdl-dock-layout.h"
#include "gdl-dock-placeholder.h"
#include "gdl-dock-bar.h"
#include "gdl-switcher.h"
#include <glib.h>
/* ---- end of debugging code */
static void
on_style_button_toggled (GtkRadioButton *button, GdlDock *dock)
{
gboolean active;
GdlDockMaster *master = GDL_DOCK_OBJECT_GET_MASTER (dock);
GdlSwitcherStyle style =
GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button),
"__style_id"));
active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
if (active) {
g_object_set (master, "switcher-style", style, NULL);
}
}
static GtkWidget *
create_style_button (GtkWidget *dock, GtkWidget *box, GtkWidget *group,
GdlSwitcherStyle style, const gchar *style_text)
{
GdlSwitcherStyle current_style;
GtkWidget *button1;
GdlDockMaster *master = GDL_DOCK_OBJECT_GET_MASTER (dock);
g_object_get (master, "switcher-style", &current_style, NULL);
button1 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (group),
style_text);
gtk_widget_show (button1);
g_object_set_data (G_OBJECT (button1), "__style_id",
GINT_TO_POINTER (style));
if (current_style == style) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button1), TRUE);
}
g_signal_connect (button1, "toggled",
G_CALLBACK (on_style_button_toggled),
dock);
gtk_box_pack_start (GTK_BOX (box), button1, FALSE, FALSE, 0);
return button1;
}
static GtkWidget *
create_styles_item (GtkWidget *dock)
{
GtkWidget *vbox1;
GtkWidget *group;
vbox1 = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox1);
group = create_style_button (dock, vbox1, NULL,
GDL_SWITCHER_STYLE_ICON,