diff options
-rw-r--r-- | example/menus.c | 1 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/idorange.c | 189 | ||||
-rw-r--r-- | src/idorange.h | 72 | ||||
-rw-r--r-- | src/idoscalemenuitem.c | 303 | ||||
-rw-r--r-- | src/idoscalemenuitem.h | 20 |
6 files changed, 562 insertions, 25 deletions
diff --git a/example/menus.c b/example/menus.c index 133c7c8..e6765b3 100644 --- a/example/menus.c +++ b/example/menus.c @@ -52,6 +52,7 @@ main (int argc, char *argv[]) gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); menuitem = ido_scale_menu_item_new_with_range ("Volume", 65, 0, 100, 1); + ido_scale_menu_item_set_style (IDO_SCALE_MENU_ITEM (menuitem), IDO_SCALE_MENU_ITEM_STYLE_IMAGE); image = ido_scale_menu_item_get_primary_image (IDO_SCALE_MENU_ITEM (menuitem)); gtk_image_set_from_stock (GTK_IMAGE (image), GTK_STOCK_NEW, GTK_ICON_SIZE_MENU); image = ido_scale_menu_item_get_secondary_image (IDO_SCALE_MENU_ITEM (menuitem)); diff --git a/src/Makefile.am b/src/Makefile.am index 8ed25da..92eee80 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,6 +8,7 @@ stamp_files = \ sources_h = \ idoentrymenuitem.h \ idomessagedialog.h \ + idorange.h \ idoscalemenuitem.h \ idotimeline.h \ libido.h @@ -52,6 +53,7 @@ libido_0_1_la_SOURCES = \ idotypebuiltins.c \ idoentrymenuitem.c \ idomessagedialog.c \ + idorange.c \ idoscalemenuitem.c \ idotimeline.c diff --git a/src/idorange.c b/src/idorange.c new file mode 100644 index 0000000..315d7fd --- /dev/null +++ b/src/idorange.c @@ -0,0 +1,189 @@ +/* + * Copyright 2010 Canonical, Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of either or both of the following licenses: + * + * 1) the GNU Lesser General Public License version 3, as published by the + * Free Software Foundation; and/or + * 2) the GNU Lesser General Public License version 2.1, as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the applicable version of the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of both the GNU Lesser General Public + * License version 3 and version 2.1 along with this program. If not, see + * <http://www.gnu.org/licenses/> + * + * Authors: + * Cody Russell <crussell@canonical.com> + */ + +#include "idorange.h" +#include "idotypebuiltins.h" + +struct _IdoRangePrivate +{ + IdoRangeStyle style; +}; + +static void ido_range_constructed (GObject *object); +static void ido_range_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void ido_range_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); + +#define IDO_RANGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), IDO_TYPE_RANGE, IdoRangePrivate)) + +G_DEFINE_TYPE (IdoRange, ido_range, GTK_TYPE_SCALE) + +enum { + PROP_0, + PROP_STYLE +}; + +static void +ido_range_class_init (IdoRangeClass *class) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (class); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); + + gobject_class->constructed = ido_range_constructed; + gobject_class->set_property = ido_range_set_property; + gobject_class->get_property = ido_range_get_property; + + g_object_class_install_property (gobject_class, + PROP_STYLE, + g_param_spec_enum ("range-style", + "Range style", + "The style of the range", + IDO_TYPE_RANGE_STYLE, + IDO_RANGE_STYLE_SMALL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + gtk_widget_class_install_style_property (widget_class, + g_param_spec_int ("knob-width", + "The knob width", + "The knob width", + G_MININT, + G_MAXINT, + 8, + G_PARAM_READABLE)); + + gtk_widget_class_install_style_property (widget_class, + g_param_spec_int ("knob-height", + "The knob height", + "The knob height", + G_MININT, + G_MAXINT, + 8, + G_PARAM_READABLE)); + + g_type_class_add_private (class, sizeof (IdoRangePrivate)); +} + +static void +ido_range_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + IdoRangePrivate *priv = IDO_RANGE (object)->priv; + + switch (prop_id) + { + case PROP_STYLE: + g_value_set_enum (value, priv->style); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +ido_range_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + IdoRangePrivate *priv = IDO_RANGE (object)->priv; + + switch (prop_id) + { + case PROP_STYLE: + priv->style = g_value_get_enum (value); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +ido_range_constructed (GObject *object) +{ + IdoRange *range = IDO_RANGE (object); + IdoRangeStyle style; + char buf[1024]; + + g_object_get (range, + "range-style", &style, + NULL); + + if (style == IDO_RANGE_STYLE_SMALL) + { + gint width, height; + + gtk_widget_style_get (GTK_WIDGET (range), + "knob-width", &width, + "knob-height", &height, + NULL); + + g_snprintf (buf, sizeof (buf), + "style \"ido-range\" {\n" + " GtkRange::slider-width = %d\n" + " GtkScale::slider-length = %d\n" + "} class \"IdoRange\" style \"ido-range\"\n", + width, height); + gtk_rc_parse_string (buf); + } + + gtk_range_set_slider_size_fixed (GTK_RANGE (range), TRUE); +} + +static void +ido_range_init (IdoRange *range) +{ + range->priv = IDO_RANGE_GET_PRIVATE (range); +} + +/** + * ido_range_new: + * @adj: A #GtkAdjustment providing the range values + * @style: The range style + * + * Creates a new #IdoRange widget. + **/ +GtkWidget * +ido_range_new (GtkAdjustment *adj, + IdoRangeStyle style) +{ + g_return_val_if_fail (GTK_IS_ADJUSTMENT (adj), NULL); + + return g_object_new (IDO_TYPE_RANGE, + "orientation", GTK_ORIENTATION_HORIZONTAL, + "adjustment", adj, + "range-style", style, + NULL); +} diff --git a/src/idorange.h b/src/idorange.h new file mode 100644 index 0000000..f502520 --- /dev/null +++ b/src/idorange.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2010 Canonical, Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of either or both of the following licenses: + * + * 1) the GNU Lesser General Public License version 3, as published by the + * Free Software Foundation; and/or + * 2) the GNU Lesser General Public License version 2.1, as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the applicable version of the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of both the GNU Lesser General Public + * License version 3 and version 2.1 along with this program. If not, see + * <http://www.gnu.org/licenses/> + * + * Authors: + * Cody Russell <crussell@canonical.com> + */ + +#ifndef __IDO_RANGE_H__ +#define __IDO_RANGE_H__ + +#include <gtk/gtk.h> + +#define IDO_TYPE_RANGE (ido_range_get_type ()) +#define IDO_RANGE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), IDO_TYPE_RANGE, IdoRange)) +#define IDO_RANGE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), IDO_TYPE_RANGE, IdoRangeClass)) +#define IDO_IS_RANGE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), IDO_TYPE_RANGE)) +#define IDO_IS_RANGE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), IDO_TYPE_RANGE)) +#define IDO_RANGE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), IDO_TYPE_RANGE, IdoRangeClass)) + +typedef enum +{ + IDO_RANGE_STYLE_DEFAULT, + IDO_RANGE_STYLE_SMALL +} IdoRangeStyle; + +typedef struct _IdoRange IdoRange; +typedef struct _IdoRangePrivate IdoRangePrivate; +typedef struct _IdoRangeClass IdoRangeClass; + +struct _IdoRange +{ + GtkScale parent_instance; + IdoRangePrivate *priv; +}; + +struct _IdoRangeClass +{ + GtkScaleClass parent_class; + + /* Padding for future expansion */ + void (*_ido_reserved1) (void); + void (*_ido_reserved2) (void); + void (*_ido_reserved3) (void); + void (*_ido_reserved4) (void); +}; + +GType ido_range_get_type (void) G_GNUC_CONST; + +GtkWidget* ido_range_new (GtkAdjustment *adj, + IdoRangeStyle style); + +G_END_DECLS + +#endif /* __IDO_RANGE_H__ */ diff --git a/src/idoscalemenuitem.c b/src/idoscalemenuitem.c index 4731de6..3aa73ac 100644 --- a/src/idoscalemenuitem.c +++ b/src/idoscalemenuitem.c @@ -24,7 +24,9 @@ */ #include <gtk/gtk.h> +#include "idorange.h" #include "idoscalemenuitem.h" +#include "idotypebuiltins.h" static void ido_scale_menu_item_set_property (GObject *object, guint prop_id, @@ -51,16 +53,19 @@ static void ido_scale_menu_item_notify (IdoScaleMenuItem gpointer user_data); struct _IdoScaleMenuItemPrivate { - GtkWidget *scale; - GtkAdjustment *adjustment; - GtkWidget *primary_image; - GtkWidget *secondary_image; - GtkWidget *hbox; - GtkAllocation child_allocation; - gdouble left_padding; - gdouble right_padding; - gboolean reverse_scroll; - gboolean grabbed; + GtkWidget *scale; + GtkAdjustment *adjustment; + GtkWidget *primary_image; + GtkWidget *secondary_image; + GtkWidget *primary_label; + GtkWidget *secondary_label; + GtkWidget *hbox; + GtkAllocation child_allocation; + gdouble left_padding; + gdouble right_padding; + gboolean reverse_scroll; + gboolean grabbed; + IdoScaleMenuItemStyle style; }; enum { @@ -72,7 +77,8 @@ enum { enum { PROP_0, PROP_ADJUSTMENT, - PROP_REVERSE_SCROLL_EVENTS + PROP_REVERSE_SCROLL_EVENTS, + PROP_STYLE }; static guint signals[LAST_SIGNAL] = { 0 }; @@ -123,23 +129,43 @@ ido_scale_menu_item_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { IdoScaleMenuItemPrivate *priv = GET_PRIVATE (widget); - GtkRequisition primary_image_req; - GtkRequisition secondary_image_req; + GtkRequisition primary_req; + GtkRequisition secondary_req; gint horizontal_padding; gint primary_padding, secondary_padding; GTK_WIDGET_CLASS (ido_scale_menu_item_parent_class)->size_allocate (widget, allocation); - gtk_widget_get_child_requisition (priv->primary_image, &primary_image_req); - gtk_widget_get_child_requisition (priv->secondary_image, &secondary_image_req); + switch (priv->style) + { + case IDO_SCALE_MENU_ITEM_STYLE_IMAGE: + gtk_widget_get_child_requisition (priv->primary_image, &primary_req); + gtk_widget_get_child_requisition (priv->secondary_image, &secondary_req); + + primary_padding = gtk_widget_get_visible (priv->primary_image) ? primary_req.width : 0; + secondary_padding = gtk_widget_get_visible (priv->secondary_image) ? secondary_req.width : 0; + break; + + case IDO_SCALE_MENU_ITEM_STYLE_LABEL: + gtk_widget_get_child_requisition (priv->primary_label, &primary_req); + gtk_widget_get_child_requisition (priv->secondary_label, &secondary_req); + + primary_padding = gtk_widget_get_visible (priv->primary_label) ? primary_req.width : 0; + secondary_padding = gtk_widget_get_visible (priv->secondary_label) ? secondary_req.width : 0; + break; + + default: + primary_req.width = primary_req.height = 0; + secondary_req.width = secondary_req.height = 0; + primary_padding = 0; + secondary_padding = 0; + break; + } gtk_widget_style_get (widget, "horizontal-padding", &horizontal_padding, NULL); - primary_padding = gtk_widget_get_visible (priv->primary_image) ? primary_image_req.width : 0; - secondary_padding = gtk_widget_get_visible (priv->secondary_image) ? secondary_image_req.width : 0; - priv->left_padding = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR ? primary_padding : secondary_padding; if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) @@ -184,6 +210,15 @@ ido_scale_menu_item_class_init (IdoScaleMenuItemClass *item_class) gobject_class->get_property = ido_scale_menu_item_get_property; g_object_class_install_property (gobject_class, + PROP_STYLE, + g_param_spec_enum ("range-style", + "Range style", + "The style of the range", + IDO_TYPE_SCALE_MENU_ITEM_STYLE, + IDO_SCALE_MENU_ITEM_STYLE_NONE, + G_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, PROP_ADJUSTMENT, g_param_spec_object ("adjustment", "Adjustment", @@ -219,14 +254,79 @@ ido_scale_menu_item_class_init (IdoScaleMenuItemClass *item_class) } static void +update_packing (IdoScaleMenuItem *self, IdoScaleMenuItemStyle style, IdoScaleMenuItemStyle old_style) +{ + IdoScaleMenuItemPrivate *priv = GET_PRIVATE (self); + GtkContainer *container = GTK_CONTAINER (priv->hbox); + + g_print ("%s %s %s\n", + G_OBJECT_TYPE_NAME (priv->primary_image), + G_OBJECT_TYPE_NAME (priv->scale), + G_OBJECT_TYPE_NAME (priv->secondary_image)); + + if (style != old_style) + { + switch (old_style) + { + case IDO_SCALE_MENU_ITEM_STYLE_NONE: + gtk_container_remove (container, priv->scale); + break; + + case IDO_SCALE_MENU_ITEM_STYLE_IMAGE: + gtk_container_remove (container, priv->primary_image); + gtk_container_remove (container, priv->secondary_image); + gtk_container_remove (container, priv->scale); + break; + + case IDO_SCALE_MENU_ITEM_STYLE_LABEL: + gtk_container_remove (container, priv->primary_label); + gtk_container_remove (container, priv->secondary_label); + gtk_container_remove (container, priv->scale); + break; + + default: + gtk_container_remove (container, priv->scale); + break; + } + } + + switch (style) + { + case IDO_SCALE_MENU_ITEM_STYLE_NONE: + gtk_box_pack_start (GTK_BOX (priv->hbox), priv->scale, FALSE, FALSE, 0); + break; + + case IDO_SCALE_MENU_ITEM_STYLE_IMAGE: + gtk_box_pack_start (GTK_BOX (priv->hbox), priv->primary_image, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (priv->hbox), priv->scale, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (priv->hbox), priv->secondary_image, FALSE, FALSE, 0); + break; + + case IDO_SCALE_MENU_ITEM_STYLE_LABEL: + gtk_box_pack_start (GTK_BOX (priv->hbox), priv->primary_label, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (priv->hbox), priv->scale, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (priv->hbox), priv->secondary_label, FALSE, FALSE, 0); + break; + + default: + gtk_box_pack_start (GTK_BOX (priv->hbox), priv->scale, FALSE, FALSE, 0); + break; + } + + gtk_widget_show_all (priv->hbox); +} + +static void ido_scale_menu_item_init (IdoScaleMenuItem *self) { IdoScaleMenuItemPrivate *priv = GET_PRIVATE (self); GtkWidget *hbox; + GtkAdjustment *adj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 100.0, 1.0, 10.0, 0.0)); priv->adjustment = NULL; - priv->scale = gtk_hscale_new_with_range (0.0, 100.0, 1.0); + priv->scale = ido_range_new (adj, IDO_RANGE_STYLE_SMALL); + g_object_ref (priv->scale); gtk_scale_set_draw_value (GTK_SCALE (priv->scale), FALSE); hbox = gtk_hbox_new (FALSE, 0); @@ -241,13 +341,12 @@ ido_scale_menu_item_init (IdoScaleMenuItem *self) G_CALLBACK (ido_scale_menu_item_secondary_image_notify), self); - gtk_box_pack_start (GTK_BOX (hbox), priv->primary_image, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), priv->scale, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), priv->secondary_image, FALSE, FALSE, 0); + priv->primary_label = gtk_label_new (""); + priv->secondary_label = gtk_label_new (""); priv->hbox = hbox; - gtk_widget_show_all (priv->hbox); + update_packing (self, priv->style, priv->style); g_signal_connect (self, "notify", G_CALLBACK (ido_scale_menu_item_notify), @@ -275,6 +374,10 @@ ido_scale_menu_item_set_property (GObject *object, priv->reverse_scroll = g_value_get_boolean (value); break; + case PROP_STYLE: + ido_scale_menu_item_set_style (menu_item, g_value_get_enum (value)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -543,6 +646,13 @@ ido_scale_menu_item_new_with_range (const gchar *label, NULL); } +/** + * ido_scale_menu_item_get_scale: + * @menuitem: The #IdoScaleMenuItem + * @returns: A pointer to the scale widget. + * + * Retrieves the scale widget. + **/ GtkWidget* ido_scale_menu_item_get_scale (IdoScaleMenuItem *menuitem) { @@ -555,6 +665,52 @@ ido_scale_menu_item_get_scale (IdoScaleMenuItem *menuitem) return priv->scale; } +/** + * ido_scale_menu_item_get_style: + * @menuitem: The #IdoScaleMenuItem + * @returns: A #IdoScaleMenuItemStyle enum describing the style. + * + * Retrieves the type of widgets being used for the primary and + * secondary widget slots. This could be images, labels, or nothing. + **/ +IdoScaleMenuItemStyle +ido_scale_menu_item_get_style (IdoScaleMenuItem *menuitem) +{ + IdoScaleMenuItemPrivate *priv; + + g_return_val_if_fail (IDO_IS_SCALE_MENU_ITEM (menuitem), IDO_SCALE_MENU_ITEM_STYLE_NONE); + + priv = GET_PRIVATE (menuitem); + + return priv->style; +} + +void +ido_scale_menu_item_set_style (IdoScaleMenuItem *menuitem, + IdoScaleMenuItemStyle style) +{ + IdoScaleMenuItemPrivate *priv; + IdoScaleMenuItemStyle old_style; + + g_return_if_fail (IDO_IS_SCALE_MENU_ITEM (menuitem)); + + priv = GET_PRIVATE (menuitem); + + old_style = priv->style; + priv->style = style; + + update_packing (menuitem, style, old_style); +} + +/** + * ido_scale_menu_item_get_primary_image: + * @menuitem: The #IdoScaleMenuItem + * @returns: A #GtkWidget pointer for the primary image. + * + * Retrieves a pointer to the image widget used in the primary slot. + * Whether this is visible depends upon the return value from + * ido_scale_menu_item_get_style(). + **/ GtkWidget * ido_scale_menu_item_get_primary_image (IdoScaleMenuItem *menuitem) { @@ -567,6 +723,15 @@ ido_scale_menu_item_get_primary_image (IdoScaleMenuItem *menuitem) return priv->primary_image; } +/** + * ido_scale_menu_item_get_secondary_image: + * @menuitem: The #IdoScaleMenuItem + * @returns: A #GtkWidget pointer for the secondary image. + * + * Retrieves a pointer to the image widget used in the secondary slot. + * Whether this is visible depends upon the return value from + * ido_scale_menu_item_get_style(). + **/ GtkWidget * ido_scale_menu_item_get_secondary_image (IdoScaleMenuItem *menuitem) { @@ -579,5 +744,97 @@ ido_scale_menu_item_get_secondary_image (IdoScaleMenuItem *menuitem) return priv->secondary_image; } +/** + * ido_scale_menu_item_get_primary_label: + * @menuitem: The #IdoScaleMenuItem + * @returns: A const gchar* string of the label text. + * + * Retrieves a string of the text for the primary label widget. + * Whether this is visible depends upon the return value from + * ido_scale_menu_item_get_style(). + **/ +G_CONST_RETURN gchar* +ido_scale_menu_item_get_primary_label (IdoScaleMenuItem *menuitem) +{ + IdoScaleMenuItemPrivate *priv; + + g_return_val_if_fail (IDO_IS_SCALE_MENU_ITEM (menuitem), NULL); + + priv = GET_PRIVATE (menuitem); + + return gtk_label_get_text (GTK_LABEL (priv->primary_label)); +} + +/** + * ido_scale_menu_item_get_primary_label: + * @menuitem: The #IdoScaleMenuItem + * @returns: A const gchar* string of the label text. + * + * Retrieves a string of the text for the primary label widget. + * Whether this is visible depends upon the return value from + * ido_scale_menu_item_get_style(). + **/ +G_CONST_RETURN gchar* +ido_scale_menu_item_get_secondary_label (IdoScaleMenuItem *menuitem) +{ + IdoScaleMenuItemPrivate *priv; + + g_return_val_if_fail (IDO_IS_SCALE_MENU_ITEM (menuitem), NULL); + + priv = GET_PRIVATE (menuitem); + + return gtk_label_get_text (GTK_LABEL (priv->secondary_label)); +} + +/** + * ido_scale_menu_item_set_primary_label: + * @menuitem: The #IdoScaleMenuItem + * @label: A string containing the label text + * + * Sets the text for the label widget in the primary slot. This + * widget will only be visibile if the return value of + * ido_scale_menu_item_get_style() is set to %IDO_SCALE_MENU_ITEM_STYLE_LABEL. + **/ +void +ido_scale_menu_item_set_primary_label (IdoScaleMenuItem *menuitem, + const gchar *label) +{ + IdoScaleMenuItemPrivate *priv; + + g_return_if_fail (IDO_IS_SCALE_MENU_ITEM (menuitem)); + + priv = GET_PRIVATE (menuitem); + + if (priv->primary_label) + { + gtk_label_set_text (GTK_LABEL (priv->primary_label), label); + } +} + +/** + * ido_scale_menu_item_set_primary_label: + * @menuitem: The #IdoScaleMenuItem + * @label: A string containing the label text + * + * Sets the text for the label widget in the primary slot. This + * widget will only be visibile if the return value of + * ido_scale_menu_item_get_style() is set to %IDO_SCALE_MENU_ITEM_STYLE_LABEL. + **/ +void +ido_scale_menu_item_set_secondary_label (IdoScaleMenuItem *menuitem, + const gchar *label) +{ + IdoScaleMenuItemPrivate *priv; + + g_return_if_fail (IDO_IS_SCALE_MENU_ITEM (menuitem)); + + priv = GET_PRIVATE (menuitem); + + if (priv->secondary_label) + { + gtk_label_set_text (GTK_LABEL (priv->secondary_label), label); + } +} + #define __IDO_SCALE_MENU_ITEM_C__ diff --git a/src/idoscalemenuitem.h b/src/idoscalemenuitem.h index 094763c..c51abd9 100644 --- a/src/idoscalemenuitem.h +++ b/src/idoscalemenuitem.h @@ -37,6 +37,12 @@ G_BEGIN_DECLS #define IDO_IS_SCALE_MENU_ITEM_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), IDO_TYPE_SCALE_MENU_ITEM)) #define IDO_SCALE_MENU_ITEM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), IDO_TYPE_SCALE_MENU_ITEM, IdoScaleMenuItemClass)) +typedef enum +{ + IDO_SCALE_MENU_ITEM_STYLE_NONE, + IDO_SCALE_MENU_ITEM_STYLE_IMAGE, + IDO_SCALE_MENU_ITEM_STYLE_LABEL +} IdoScaleMenuItemStyle; typedef struct _IdoScaleMenuItem IdoScaleMenuItem; typedef struct _IdoScaleMenuItemClass IdoScaleMenuItemClass; @@ -64,8 +70,18 @@ GtkWidget *ido_scale_menu_item_new_with_range (const gchar *label, gdouble max, gdouble step); GtkWidget *ido_scale_menu_item_get_scale (IdoScaleMenuItem *menuitem); -GtkWidget *ido_scale_menu_item_get_primary_image (IdoScaleMenuItem *menuitem); -GtkWidget *ido_scale_menu_item_get_secondary_image (IdoScaleMenuItem *menuitem); + +IdoScaleMenuItemStyle ido_scale_menu_item_get_style (IdoScaleMenuItem *menuitem); +void ido_scale_menu_item_set_style (IdoScaleMenuItem *menuitem, + IdoScaleMenuItemStyle style); +GtkWidget *ido_scale_menu_item_get_primary_image (IdoScaleMenuItem *menuitem); +GtkWidget *ido_scale_menu_item_get_secondary_image (IdoScaleMenuItem *menuitem); +G_CONST_RETURN gchar *ido_scale_menu_item_get_primary_label (IdoScaleMenuItem *menuitem); +G_CONST_RETURN gchar *ido_scale_menu_item_get_secondary_label (IdoScaleMenuItem *menuitem); +void ido_scale_menu_item_set_primary_label (IdoScaleMenuItem *menuitem, + const gchar *label); +void ido_scale_menu_item_set_secondary_label (IdoScaleMenuItem *menuitem, + const gchar *label); G_END_DECLS |