X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fhildon-check-button.c;h=1bc26ca7039aee1b8801ae8318c6ae9fd62d8e8d;hb=e3a8bb2cb36fb7ee162c1e57333b7a77a8c15e70;hp=656a654dd1709a968562b65a1b5161f800237df1;hpb=9bcd79bb8d4cd19daf614b47410757d7a7866159;p=hildon
diff --git a/src/hildon-check-button.c b/src/hildon-check-button.c
index 656a654..1bc26ca 100644
--- a/src/hildon-check-button.c
+++ b/src/hildon-check-button.c
@@ -18,10 +18,21 @@
* SECTION:hildon-check-button
* @short_description: Button with a check box inside
*
- * This is a button containing a check box and a label. Functions are
- * provided to get and set the value of the check box. For the label
- * use gtk_button_set_label(). Note that this button does NOT support
- * an image, so don't use gtk_button_set_image()
+ * #HildonCheckButton is a button containing a label and a check box
+ * which will remain 'pressed-in' when clicked. Clicking again will
+ * make the check box toggle its state.
+ *
+ * The state of a #HildonCheckButton can be set using
+ * hildon_check_button_set_active(), and retrieved using
+ * hildon_check_button_get_active(). The label can be set using
+ * gtk_button_set_label() and retrieved using gtk_button_get_label().
+ *
+ *
+ *
+ * #HildonCheckButton does NOT support an image, so don't use
+ * gtk_button_set_image().
+ *
+ *
*
*
* Using a Hildon check button
@@ -52,7 +63,6 @@
* }
*
*
-
*/
#include "hildon-check-button.h"
@@ -80,6 +90,7 @@ struct _HildonCheckButtonPrivate
* @button: A #HildonCheckButton
*
* Emits the #HildonCheckButton::toggled signal on the #HildonCheckButton.
+ * There is no good reason for an application ever to call this function.
*
* Since: 2.2
*/
@@ -96,7 +107,9 @@ hildon_check_button_toggled (HildonCheckButton *button)
* @button: A #HildonCheckButton
* @is_active: new state for the button
*
- * Sets the state of @button to @is_active
+ * Sets the status of a #HildonCheckButton. Set to %TRUE if you want
+ * @button to be 'pressed-in', and %FALSE to raise it. This action
+ * causes the #HildonCheckButton::toggled signal to be emitted.
*
* Since: 2.2
**/
@@ -120,11 +133,11 @@ hildon_check_button_set_active (HildonCheckButton *button,
* hildon_check_button_get_active:
* @button: A #HildonCheckButton
*
- * Gets the state of the button.
+ * Gets the current state of @button.
*
* Return value: %TRUE if @button is active, %FALSE otherwise.
*
- * Since: 2.2
+ * Since: 2.2
**/
gboolean
hildon_check_button_get_active (HildonCheckButton *button)
@@ -138,7 +151,7 @@ hildon_check_button_get_active (HildonCheckButton *button)
* hildon_check_button_new:
* @size: Flags indicating the size of the new button
*
- * This function creates a #HildonCheckButton.
+ * Creates a new #HildonCheckButton.
*
* Return value: A newly created #HildonCheckButton
*
@@ -164,11 +177,34 @@ hildon_check_button_clicked (GtkButton *button)
}
static void
+hildon_check_button_apply_style (GtkWidget *widget)
+{
+ guint checkbox_size;
+ HildonCheckButtonPrivate *priv = HILDON_CHECK_BUTTON (widget)->priv;
+
+ gtk_widget_style_get (widget, "checkbox-size", &checkbox_size, NULL);
+
+ g_object_set (priv->toggle_renderer, "indicator-size", checkbox_size, NULL);
+}
+
+static void
+hildon_check_button_style_set (GtkWidget *widget,
+ GtkStyle *previous_style)
+{
+ if (GTK_WIDGET_CLASS (hildon_check_button_parent_class)->style_set)
+ GTK_WIDGET_CLASS (hildon_check_button_parent_class)->style_set (widget, previous_style);
+
+ hildon_check_button_apply_style (widget);
+}
+
+static void
hildon_check_button_class_init (HildonCheckButtonClass *klass)
{
GObjectClass *gobject_class = (GObjectClass*) klass;
+ GtkWidgetClass *widget_class = (GtkWidgetClass*) klass;
GtkButtonClass *button_class = (GtkButtonClass*) klass;
+ widget_class->style_set = hildon_check_button_style_set;
button_class->clicked = hildon_check_button_clicked;
klass->toggled = NULL;
@@ -176,7 +212,7 @@ hildon_check_button_class_init (HildonCheckButtonClass *klass)
/**
* HildonCheckButton::toggled
*
- * Emitted when the #HildonCheckButton's state is changed
+ * Emitted when the #HildonCheckButton's state is changed.
*
* Since: 2.2
*/
@@ -189,6 +225,15 @@ hildon_check_button_class_init (HildonCheckButtonClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+ gtk_widget_class_install_style_property (
+ widget_class,
+ g_param_spec_uint (
+ "checkbox-size",
+ "Size of the check box",
+ "Size of the check box",
+ 0, G_MAXUINT, 26,
+ G_PARAM_READABLE));
+
g_type_class_add_private (klass, sizeof (HildonCheckButtonPrivate));
}
@@ -211,4 +256,8 @@ hildon_check_button_init (HildonCheckButton *button)
/* Add cell view to the image */
gtk_button_set_image (GTK_BUTTON (button), cell_view);
+
+ gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
+
+ hildon_check_button_apply_style (GTK_WIDGET (button));
}