2009-09-29 19:08:01 +00:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
2009-09-10 03:13:35 +00:00
|
|
|
/*
|
|
|
|
* st-button.c: Plain button actor
|
|
|
|
*
|
|
|
|
* Copyright 2007 OpenedHand
|
|
|
|
* Copyright 2008, 2009 Intel Corporation.
|
2010-11-10 22:00:45 +00:00
|
|
|
* Copyright 2009, 2010 Red Hat, Inc.
|
2009-09-10 03:13:35 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU Lesser General Public License,
|
|
|
|
* version 2.1, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT ANY
|
|
|
|
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
2010-11-10 22:00:45 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-09-10 03:13:35 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:st-button
|
|
|
|
* @short_description: Button widget
|
|
|
|
*
|
|
|
|
* A button widget with support for either a text label or icon, toggle mode
|
|
|
|
* and transitions effects between states.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
#include <clutter/clutter.h>
|
|
|
|
|
|
|
|
#include "st-button.h"
|
|
|
|
|
2011-01-25 21:22:00 +00:00
|
|
|
#include "st-enum-types.h"
|
2009-09-10 03:13:35 +00:00
|
|
|
#include "st-texture-cache.h"
|
|
|
|
#include "st-private.h"
|
|
|
|
|
2011-05-23 19:35:28 +00:00
|
|
|
#include <st/st-widget-accessible.h>
|
|
|
|
|
2009-09-10 03:13:35 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
|
|
|
|
PROP_LABEL,
|
2011-01-25 21:22:00 +00:00
|
|
|
PROP_BUTTON_MASK,
|
2009-09-30 13:55:02 +00:00
|
|
|
PROP_TOGGLE_MODE,
|
2011-01-25 21:22:00 +00:00
|
|
|
PROP_CHECKED,
|
|
|
|
PROP_PRESSED
|
2009-09-10 03:13:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
CLICKED,
|
|
|
|
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
#define ST_BUTTON_GET_PRIVATE(obj) \
|
|
|
|
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), ST_TYPE_BUTTON, StButtonPrivate))
|
|
|
|
|
|
|
|
struct _StButtonPrivate
|
|
|
|
{
|
2011-01-25 21:22:00 +00:00
|
|
|
gchar *text;
|
2009-09-10 03:13:35 +00:00
|
|
|
|
2014-07-22 10:23:25 +00:00
|
|
|
ClutterInputDevice *device;
|
|
|
|
ClutterEventSequence *press_sequence;
|
|
|
|
|
2011-01-25 21:22:00 +00:00
|
|
|
guint button_mask : 3;
|
|
|
|
guint is_toggle : 1;
|
2009-09-10 03:13:35 +00:00
|
|
|
|
2011-01-25 21:22:00 +00:00
|
|
|
guint pressed : 3;
|
|
|
|
guint grabbed : 3;
|
|
|
|
guint is_checked : 1;
|
|
|
|
|
|
|
|
gint spacing;
|
2009-09-10 03:13:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static guint button_signals[LAST_SIGNAL] = { 0, };
|
|
|
|
|
2009-09-20 01:10:15 +00:00
|
|
|
G_DEFINE_TYPE (StButton, st_button, ST_TYPE_BIN);
|
2009-09-10 03:13:35 +00:00
|
|
|
|
2011-05-23 19:35:28 +00:00
|
|
|
static GType st_button_accessible_get_type (void) G_GNUC_CONST;
|
|
|
|
|
2009-09-10 03:13:35 +00:00
|
|
|
static void
|
|
|
|
st_button_update_label_style (StButton *button)
|
|
|
|
{
|
|
|
|
ClutterActor *label;
|
|
|
|
|
2010-11-02 17:24:29 +00:00
|
|
|
label = st_bin_get_child (ST_BIN (button));
|
2009-09-10 03:13:35 +00:00
|
|
|
|
|
|
|
/* check the child is really a label */
|
|
|
|
if (!CLUTTER_IS_TEXT (label))
|
|
|
|
return;
|
|
|
|
|
2010-11-02 17:24:29 +00:00
|
|
|
_st_set_text_from_style (CLUTTER_TEXT (label), st_widget_get_theme_node (ST_WIDGET (button)));
|
2009-09-10 03:13:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
st_button_style_changed (StWidget *widget)
|
|
|
|
{
|
|
|
|
StButton *button = ST_BUTTON (widget);
|
|
|
|
StButtonPrivate *priv = button->priv;
|
|
|
|
StButtonClass *button_class = ST_BUTTON_GET_CLASS (button);
|
2009-09-20 01:10:15 +00:00
|
|
|
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (button));
|
|
|
|
double spacing;
|
2009-09-10 03:13:35 +00:00
|
|
|
|
2009-09-20 01:10:15 +00:00
|
|
|
ST_WIDGET_CLASS (st_button_parent_class)->style_changed (widget);
|
|
|
|
|
|
|
|
spacing = 6;
|
StThemeNode: simplify use of get_color/get_double/get_length
Although within St itself there are situations where the semantics of
these functions (return TRUE or FALSE and return the actual value in
an out parameter) is useful, it's mostly just annoying at the
application level, where you generally know that the CSS property is
going to specified, and there is no especially sane fallback if it's
not.
So rename the current methods to lookup_color, lookup_double, and
lookup_length, and add new get_color, get_double, and get_length
methods that don't take an "inherit" parameter, and return their
values directly. (Well, except for get_color, due to the lack of (out
caller-allocates) in gjs.)
And update the code to use either the old or new methods as appropriate.
https://bugzilla.gnome.org/show_bug.cgi?id=632590
2010-09-26 21:38:36 +00:00
|
|
|
st_theme_node_lookup_length (theme_node, "border-spacing", FALSE, &spacing);
|
2009-10-01 20:32:38 +00:00
|
|
|
priv->spacing = (int)(0.5 + spacing);
|
2009-09-10 03:13:35 +00:00
|
|
|
|
|
|
|
/* update the label styling */
|
|
|
|
st_button_update_label_style (button);
|
|
|
|
|
|
|
|
/* run a transition if applicable */
|
|
|
|
if (button_class->transition)
|
|
|
|
{
|
2010-02-08 19:57:33 +00:00
|
|
|
button_class->transition (button);
|
2009-09-10 03:13:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-07-22 10:23:25 +00:00
|
|
|
st_button_press (StButton *button,
|
|
|
|
ClutterInputDevice *device,
|
|
|
|
StButtonMask mask,
|
|
|
|
ClutterEventSequence *sequence)
|
2009-09-10 03:13:35 +00:00
|
|
|
{
|
2014-07-22 10:23:25 +00:00
|
|
|
if (button->priv->pressed == 0 || sequence)
|
2011-01-25 21:22:00 +00:00
|
|
|
st_widget_add_style_pseudo_class (ST_WIDGET (button), "active");
|
2010-11-02 17:24:29 +00:00
|
|
|
|
2011-01-25 21:22:00 +00:00
|
|
|
button->priv->pressed |= mask;
|
2014-07-22 10:23:25 +00:00
|
|
|
button->priv->press_sequence = sequence;
|
|
|
|
button->priv->device = device;
|
2009-09-10 03:13:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-07-22 10:23:25 +00:00
|
|
|
st_button_release (StButton *button,
|
|
|
|
ClutterInputDevice *device,
|
|
|
|
StButtonMask mask,
|
|
|
|
int clicked_button,
|
|
|
|
ClutterEventSequence *sequence)
|
2009-09-10 03:13:35 +00:00
|
|
|
{
|
2014-07-22 10:23:25 +00:00
|
|
|
if ((device && button->priv->device != device) ||
|
|
|
|
(sequence && button->priv->press_sequence != sequence))
|
2010-11-02 17:24:29 +00:00
|
|
|
return;
|
2014-07-22 10:23:25 +00:00
|
|
|
else if (!sequence)
|
|
|
|
{
|
|
|
|
button->priv->pressed &= ~mask;
|
2010-11-02 17:24:29 +00:00
|
|
|
|
2014-07-22 10:23:25 +00:00
|
|
|
if (button->priv->pressed != 0)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
button->priv->press_sequence = NULL;
|
|
|
|
button->priv->device = NULL;
|
2010-11-02 17:24:29 +00:00
|
|
|
st_widget_remove_style_pseudo_class (ST_WIDGET (button), "active");
|
2010-11-02 17:24:29 +00:00
|
|
|
|
2014-07-22 10:23:25 +00:00
|
|
|
if (clicked_button || sequence)
|
2010-11-02 17:24:29 +00:00
|
|
|
{
|
|
|
|
if (button->priv->is_toggle)
|
|
|
|
st_button_set_checked (button, !button->priv->is_checked);
|
|
|
|
|
2011-01-25 21:22:00 +00:00
|
|
|
g_signal_emit (button, button_signals[CLICKED], 0, clicked_button);
|
2010-11-02 17:24:29 +00:00
|
|
|
}
|
2009-09-10 03:13:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
st_button_button_press (ClutterActor *actor,
|
|
|
|
ClutterButtonEvent *event)
|
|
|
|
{
|
2011-01-25 21:22:00 +00:00
|
|
|
StButton *button = ST_BUTTON (actor);
|
|
|
|
StButtonMask mask = ST_BUTTON_MASK_FROM_BUTTON (event->button);
|
2014-07-22 10:23:25 +00:00
|
|
|
ClutterInputDevice *device = clutter_event_get_device ((ClutterEvent*) event);
|
|
|
|
|
|
|
|
if (button->priv->press_sequence)
|
|
|
|
return CLUTTER_EVENT_PROPAGATE;
|
2011-01-25 21:22:00 +00:00
|
|
|
|
|
|
|
if (button->priv->button_mask & mask)
|
2009-09-10 03:13:35 +00:00
|
|
|
{
|
2011-01-25 21:22:00 +00:00
|
|
|
if (button->priv->grabbed == 0)
|
|
|
|
clutter_grab_pointer (actor);
|
2009-09-10 03:13:35 +00:00
|
|
|
|
2011-01-25 21:22:00 +00:00
|
|
|
button->priv->grabbed |= mask;
|
2014-07-22 10:23:25 +00:00
|
|
|
st_button_press (button, device, mask, NULL);
|
2009-09-10 03:13:35 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
st_button_button_release (ClutterActor *actor,
|
|
|
|
ClutterButtonEvent *event)
|
|
|
|
{
|
2011-01-25 21:22:00 +00:00
|
|
|
StButton *button = ST_BUTTON (actor);
|
|
|
|
StButtonMask mask = ST_BUTTON_MASK_FROM_BUTTON (event->button);
|
2014-07-22 10:23:25 +00:00
|
|
|
ClutterInputDevice *device = clutter_event_get_device ((ClutterEvent*) event);
|
2011-01-25 21:22:00 +00:00
|
|
|
|
|
|
|
if (button->priv->button_mask & mask)
|
2009-09-10 03:13:35 +00:00
|
|
|
{
|
2010-11-02 17:24:29 +00:00
|
|
|
gboolean is_click;
|
2009-09-10 03:13:35 +00:00
|
|
|
|
2011-01-25 21:22:00 +00:00
|
|
|
is_click = button->priv->grabbed && st_widget_get_hover (ST_WIDGET (button));
|
2014-07-22 10:23:25 +00:00
|
|
|
st_button_release (button, device, mask, is_click ? event->button : 0, NULL);
|
2009-09-10 03:13:35 +00:00
|
|
|
|
2011-01-25 21:22:00 +00:00
|
|
|
button->priv->grabbed &= ~mask;
|
|
|
|
if (button->priv->grabbed == 0)
|
|
|
|
clutter_ungrab_pointer ();
|
2009-09-10 03:13:35 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2014-07-22 10:23:25 +00:00
|
|
|
static gboolean
|
|
|
|
st_button_touch_event (ClutterActor *actor,
|
|
|
|
ClutterTouchEvent *event)
|
|
|
|
{
|
|
|
|
StButton *button = ST_BUTTON (actor);
|
|
|
|
StButtonMask mask = ST_BUTTON_MASK_FROM_BUTTON (1);
|
|
|
|
ClutterEventSequence *sequence;
|
|
|
|
ClutterInputDevice *device;
|
|
|
|
|
|
|
|
if (button->priv->pressed != 0)
|
|
|
|
return CLUTTER_EVENT_PROPAGATE;
|
|
|
|
|
|
|
|
device = clutter_event_get_device ((ClutterEvent*) event);
|
|
|
|
sequence = clutter_event_get_event_sequence ((ClutterEvent*) event);
|
|
|
|
|
|
|
|
if (event->type == CLUTTER_TOUCH_BEGIN && !button->priv->press_sequence)
|
|
|
|
{
|
|
|
|
clutter_input_device_sequence_grab (device, sequence, actor);
|
|
|
|
st_button_press (button, device, 0, sequence);
|
|
|
|
return CLUTTER_EVENT_STOP;
|
|
|
|
}
|
|
|
|
else if (event->type == CLUTTER_TOUCH_END &&
|
|
|
|
button->priv->device == device &&
|
|
|
|
button->priv->press_sequence == sequence)
|
|
|
|
{
|
|
|
|
st_button_release (button, device, mask, 0, sequence);
|
|
|
|
clutter_input_device_sequence_ungrab (device, sequence);
|
|
|
|
return CLUTTER_EVENT_STOP;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CLUTTER_EVENT_PROPAGATE;
|
|
|
|
}
|
|
|
|
|
2010-10-13 19:53:42 +00:00
|
|
|
static gboolean
|
|
|
|
st_button_key_press (ClutterActor *actor,
|
|
|
|
ClutterKeyEvent *event)
|
|
|
|
{
|
2011-01-25 21:22:00 +00:00
|
|
|
StButton *button = ST_BUTTON (actor);
|
|
|
|
|
|
|
|
if (button->priv->button_mask & ST_BUTTON_ONE)
|
2010-10-13 19:53:42 +00:00
|
|
|
{
|
2011-01-25 21:22:00 +00:00
|
|
|
if (event->keyval == CLUTTER_KEY_space ||
|
2012-03-20 13:50:59 +00:00
|
|
|
event->keyval == CLUTTER_KEY_Return ||
|
|
|
|
event->keyval == CLUTTER_KEY_KP_Enter)
|
2011-01-25 21:22:00 +00:00
|
|
|
{
|
2014-07-22 10:23:25 +00:00
|
|
|
st_button_press (button, NULL, ST_BUTTON_ONE, NULL);
|
2011-01-25 21:22:00 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2010-10-13 19:53:42 +00:00
|
|
|
}
|
|
|
|
|
2011-01-26 19:45:38 +00:00
|
|
|
return CLUTTER_ACTOR_CLASS (st_button_parent_class)->key_press_event (actor, event);
|
2010-10-13 19:53:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
st_button_key_release (ClutterActor *actor,
|
|
|
|
ClutterKeyEvent *event)
|
|
|
|
{
|
2011-01-25 21:22:00 +00:00
|
|
|
StButton *button = ST_BUTTON (actor);
|
|
|
|
|
|
|
|
if (button->priv->button_mask & ST_BUTTON_ONE)
|
2010-10-13 19:53:42 +00:00
|
|
|
{
|
2011-01-25 21:22:00 +00:00
|
|
|
if (event->keyval == CLUTTER_KEY_space ||
|
2012-03-20 13:50:59 +00:00
|
|
|
event->keyval == CLUTTER_KEY_Return ||
|
|
|
|
event->keyval == CLUTTER_KEY_KP_Enter)
|
2011-01-25 21:22:00 +00:00
|
|
|
{
|
2011-03-21 12:21:18 +00:00
|
|
|
gboolean is_click;
|
|
|
|
|
|
|
|
is_click = (button->priv->pressed & ST_BUTTON_ONE);
|
2014-07-22 10:23:25 +00:00
|
|
|
st_button_release (button, NULL, ST_BUTTON_ONE, is_click ? 1 : 0, NULL);
|
2011-01-25 21:22:00 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2010-10-13 19:53:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-01-25 21:22:00 +00:00
|
|
|
static void
|
|
|
|
st_button_key_focus_out (ClutterActor *actor)
|
|
|
|
{
|
|
|
|
StButton *button = ST_BUTTON (actor);
|
|
|
|
|
|
|
|
/* If we lose focus between a key press and release, undo the press */
|
|
|
|
if ((button->priv->pressed & ST_BUTTON_ONE) &&
|
|
|
|
!(button->priv->grabbed & ST_BUTTON_ONE))
|
2014-07-22 10:23:25 +00:00
|
|
|
st_button_release (button, NULL, ST_BUTTON_ONE, 0, NULL);
|
2011-01-25 21:22:00 +00:00
|
|
|
|
|
|
|
CLUTTER_ACTOR_CLASS (st_button_parent_class)->key_focus_out (actor);
|
|
|
|
}
|
|
|
|
|
2009-09-10 03:13:35 +00:00
|
|
|
static gboolean
|
|
|
|
st_button_enter (ClutterActor *actor,
|
|
|
|
ClutterCrossingEvent *event)
|
|
|
|
{
|
|
|
|
StButton *button = ST_BUTTON (actor);
|
2010-11-02 17:24:29 +00:00
|
|
|
gboolean ret;
|
2009-09-10 03:13:35 +00:00
|
|
|
|
2010-11-02 17:24:29 +00:00
|
|
|
ret = CLUTTER_ACTOR_CLASS (st_button_parent_class)->enter_event (actor, event);
|
2009-09-10 03:13:35 +00:00
|
|
|
|
2011-01-25 21:22:00 +00:00
|
|
|
if (button->priv->grabbed)
|
2010-11-02 17:24:29 +00:00
|
|
|
{
|
|
|
|
if (st_widget_get_hover (ST_WIDGET (button)))
|
2014-07-22 10:23:25 +00:00
|
|
|
st_button_press (button, button->priv->device,
|
|
|
|
button->priv->grabbed, NULL);
|
2010-11-02 17:24:29 +00:00
|
|
|
else
|
2014-07-22 10:23:25 +00:00
|
|
|
st_button_release (button, button->priv->device,
|
|
|
|
button->priv->grabbed, 0, NULL);
|
2010-11-02 17:24:29 +00:00
|
|
|
}
|
2009-09-10 03:13:35 +00:00
|
|
|
|
2010-11-02 17:24:29 +00:00
|
|
|
return ret;
|
2009-09-10 03:13:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
st_button_leave (ClutterActor *actor,
|
|
|
|
ClutterCrossingEvent *event)
|
|
|
|
{
|
|
|
|
StButton *button = ST_BUTTON (actor);
|
2010-11-02 17:24:29 +00:00
|
|
|
gboolean ret;
|
2009-09-10 03:13:35 +00:00
|
|
|
|
2010-11-02 17:24:29 +00:00
|
|
|
ret = CLUTTER_ACTOR_CLASS (st_button_parent_class)->leave_event (actor, event);
|
2009-09-10 03:13:35 +00:00
|
|
|
|
2011-01-25 21:22:00 +00:00
|
|
|
if (button->priv->grabbed)
|
2009-09-10 03:13:35 +00:00
|
|
|
{
|
2010-11-02 17:24:29 +00:00
|
|
|
if (st_widget_get_hover (ST_WIDGET (button)))
|
2014-07-22 10:23:25 +00:00
|
|
|
st_button_press (button, button->priv->device,
|
|
|
|
button->priv->grabbed, NULL);
|
2010-11-02 17:24:29 +00:00
|
|
|
else
|
2014-07-22 10:23:25 +00:00
|
|
|
st_button_release (button, button->priv->device,
|
|
|
|
button->priv->grabbed, 0, NULL);
|
2009-09-10 03:13:35 +00:00
|
|
|
}
|
|
|
|
|
2010-11-02 17:24:29 +00:00
|
|
|
return ret;
|
2009-09-10 03:13:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
st_button_set_property (GObject *gobject,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
StButton *button = ST_BUTTON (gobject);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_LABEL:
|
|
|
|
st_button_set_label (button, g_value_get_string (value));
|
|
|
|
break;
|
2011-01-25 21:22:00 +00:00
|
|
|
case PROP_BUTTON_MASK:
|
|
|
|
st_button_set_button_mask (button, g_value_get_flags (value));
|
|
|
|
break;
|
2009-09-30 13:55:02 +00:00
|
|
|
case PROP_TOGGLE_MODE:
|
2009-09-10 03:13:35 +00:00
|
|
|
st_button_set_toggle_mode (button, g_value_get_boolean (value));
|
|
|
|
break;
|
2009-09-30 13:55:02 +00:00
|
|
|
case PROP_CHECKED:
|
2009-09-10 03:13:35 +00:00
|
|
|
st_button_set_checked (button, g_value_get_boolean (value));
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
st_button_get_property (GObject *gobject,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
StButtonPrivate *priv = ST_BUTTON (gobject)->priv;
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_LABEL:
|
|
|
|
g_value_set_string (value, priv->text);
|
|
|
|
break;
|
2011-01-25 21:22:00 +00:00
|
|
|
case PROP_BUTTON_MASK:
|
|
|
|
g_value_set_flags (value, priv->button_mask);
|
|
|
|
break;
|
2009-09-30 13:55:02 +00:00
|
|
|
case PROP_TOGGLE_MODE:
|
2009-09-10 03:13:35 +00:00
|
|
|
g_value_set_boolean (value, priv->is_toggle);
|
|
|
|
break;
|
2009-09-30 13:55:02 +00:00
|
|
|
case PROP_CHECKED:
|
2009-09-10 03:13:35 +00:00
|
|
|
g_value_set_boolean (value, priv->is_checked);
|
|
|
|
break;
|
2011-01-25 21:22:00 +00:00
|
|
|
case PROP_PRESSED:
|
|
|
|
g_value_set_boolean (value, priv->pressed != 0);
|
|
|
|
break;
|
2009-09-10 03:13:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
st_button_finalize (GObject *gobject)
|
|
|
|
{
|
|
|
|
StButtonPrivate *priv = ST_BUTTON (gobject)->priv;
|
|
|
|
|
|
|
|
g_free (priv->text);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (st_button_parent_class)->finalize (gobject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
st_button_class_init (StButtonClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
|
|
|
StWidgetClass *widget_class = ST_WIDGET_CLASS (klass);
|
|
|
|
GParamSpec *pspec;
|
|
|
|
|
|
|
|
g_type_class_add_private (klass, sizeof (StButtonPrivate));
|
|
|
|
|
|
|
|
gobject_class->set_property = st_button_set_property;
|
|
|
|
gobject_class->get_property = st_button_get_property;
|
|
|
|
gobject_class->finalize = st_button_finalize;
|
|
|
|
|
|
|
|
actor_class->button_press_event = st_button_button_press;
|
|
|
|
actor_class->button_release_event = st_button_button_release;
|
2010-10-13 19:53:42 +00:00
|
|
|
actor_class->key_press_event = st_button_key_press;
|
|
|
|
actor_class->key_release_event = st_button_key_release;
|
2011-01-25 21:22:00 +00:00
|
|
|
actor_class->key_focus_out = st_button_key_focus_out;
|
2009-09-10 03:13:35 +00:00
|
|
|
actor_class->enter_event = st_button_enter;
|
|
|
|
actor_class->leave_event = st_button_leave;
|
2014-07-22 10:23:25 +00:00
|
|
|
actor_class->touch_event = st_button_touch_event;
|
2009-09-10 03:13:35 +00:00
|
|
|
|
2009-09-20 01:10:15 +00:00
|
|
|
widget_class->style_changed = st_button_style_changed;
|
2011-05-23 19:35:28 +00:00
|
|
|
widget_class->get_accessible_type = st_button_accessible_get_type;
|
2009-09-10 03:13:35 +00:00
|
|
|
|
|
|
|
pspec = g_param_spec_string ("label",
|
|
|
|
"Label",
|
|
|
|
"Label of the button",
|
|
|
|
NULL, G_PARAM_READWRITE);
|
|
|
|
g_object_class_install_property (gobject_class, PROP_LABEL, pspec);
|
|
|
|
|
2011-01-25 21:22:00 +00:00
|
|
|
pspec = g_param_spec_flags ("button-mask",
|
|
|
|
"Button mask",
|
|
|
|
"Which buttons trigger the 'clicked' signal",
|
|
|
|
ST_TYPE_BUTTON_MASK, ST_BUTTON_ONE,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
g_object_class_install_property (gobject_class, PROP_BUTTON_MASK, pspec);
|
|
|
|
|
2009-09-10 03:13:35 +00:00
|
|
|
pspec = g_param_spec_boolean ("toggle-mode",
|
|
|
|
"Toggle Mode",
|
|
|
|
"Enable or disable toggling",
|
|
|
|
FALSE, G_PARAM_READWRITE);
|
2009-09-30 13:55:02 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_TOGGLE_MODE, pspec);
|
2009-09-10 03:13:35 +00:00
|
|
|
|
|
|
|
pspec = g_param_spec_boolean ("checked",
|
|
|
|
"Checked",
|
|
|
|
"Indicates if a toggle button is \"on\""
|
|
|
|
" or \"off\"",
|
|
|
|
FALSE, G_PARAM_READWRITE);
|
2009-09-30 13:55:02 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_CHECKED, pspec);
|
2009-09-10 03:13:35 +00:00
|
|
|
|
2011-01-25 21:22:00 +00:00
|
|
|
pspec = g_param_spec_boolean ("pressed",
|
|
|
|
"Pressed",
|
|
|
|
"Indicates if the button is pressed in",
|
|
|
|
FALSE, G_PARAM_READABLE);
|
|
|
|
g_object_class_install_property (gobject_class, PROP_PRESSED, pspec);
|
|
|
|
|
2009-09-10 03:13:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* StButton::clicked:
|
|
|
|
* @button: the object that received the signal
|
2011-01-25 21:22:00 +00:00
|
|
|
* @clicked_button: the mouse button that was used
|
2009-09-10 03:13:35 +00:00
|
|
|
*
|
|
|
|
* Emitted when the user activates the button, either with a mouse press and
|
|
|
|
* release or with the keyboard.
|
|
|
|
*/
|
|
|
|
button_signals[CLICKED] =
|
|
|
|
g_signal_new ("clicked",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (StButtonClass, clicked),
|
2011-10-18 22:17:49 +00:00
|
|
|
NULL, NULL, NULL,
|
2011-01-25 21:22:00 +00:00
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
G_TYPE_INT);
|
2009-09-10 03:13:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
st_button_init (StButton *button)
|
|
|
|
{
|
|
|
|
button->priv = ST_BUTTON_GET_PRIVATE (button);
|
|
|
|
button->priv->spacing = 6;
|
2011-01-25 21:22:00 +00:00
|
|
|
button->priv->button_mask = ST_BUTTON_ONE;
|
2009-09-10 03:13:35 +00:00
|
|
|
|
2010-11-02 17:24:29 +00:00
|
|
|
clutter_actor_set_reactive (CLUTTER_ACTOR (button), TRUE);
|
2010-11-02 17:24:29 +00:00
|
|
|
st_widget_set_track_hover (ST_WIDGET (button), TRUE);
|
2009-09-10 03:13:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* st_button_new:
|
|
|
|
*
|
|
|
|
* Create a new button
|
|
|
|
*
|
|
|
|
* Returns: a new #StButton
|
|
|
|
*/
|
|
|
|
StWidget *
|
|
|
|
st_button_new (void)
|
|
|
|
{
|
|
|
|
return g_object_new (ST_TYPE_BUTTON, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* st_button_new_with_label:
|
|
|
|
* @text: text to set the label to
|
|
|
|
*
|
|
|
|
* Create a new #StButton with the specified label
|
|
|
|
*
|
|
|
|
* Returns: a new #StButton
|
|
|
|
*/
|
|
|
|
StWidget *
|
|
|
|
st_button_new_with_label (const gchar *text)
|
|
|
|
{
|
|
|
|
return g_object_new (ST_TYPE_BUTTON, "label", text, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* st_button_get_label:
|
|
|
|
* @button: a #StButton
|
|
|
|
*
|
|
|
|
* Get the text displayed on the button
|
|
|
|
*
|
|
|
|
* Returns: the text for the button. This must not be freed by the application
|
|
|
|
*/
|
2011-01-25 21:22:00 +00:00
|
|
|
const gchar *
|
2009-09-10 03:13:35 +00:00
|
|
|
st_button_get_label (StButton *button)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (ST_IS_BUTTON (button), NULL);
|
|
|
|
|
|
|
|
return button->priv->text;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* st_button_set_label:
|
|
|
|
* @button: a #Stbutton
|
|
|
|
* @text: text to set the label to
|
|
|
|
*
|
|
|
|
* Sets the text displayed on the button
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
st_button_set_label (StButton *button,
|
|
|
|
const gchar *text)
|
|
|
|
{
|
|
|
|
StButtonPrivate *priv;
|
|
|
|
ClutterActor *label;
|
|
|
|
|
|
|
|
g_return_if_fail (ST_IS_BUTTON (button));
|
|
|
|
|
|
|
|
priv = button->priv;
|
|
|
|
|
|
|
|
g_free (priv->text);
|
|
|
|
|
|
|
|
if (text)
|
|
|
|
priv->text = g_strdup (text);
|
|
|
|
else
|
|
|
|
priv->text = g_strdup ("");
|
|
|
|
|
2010-11-02 17:24:29 +00:00
|
|
|
label = st_bin_get_child (ST_BIN (button));
|
2009-09-10 03:13:35 +00:00
|
|
|
|
|
|
|
if (label && CLUTTER_IS_TEXT (label))
|
|
|
|
{
|
|
|
|
clutter_text_set_text (CLUTTER_TEXT (label), priv->text);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
label = g_object_new (CLUTTER_TYPE_TEXT,
|
|
|
|
"text", priv->text,
|
|
|
|
"line-alignment", PANGO_ALIGN_CENTER,
|
|
|
|
"ellipsize", PANGO_ELLIPSIZE_END,
|
|
|
|
"use-markup", TRUE,
|
|
|
|
NULL);
|
2010-11-02 17:24:29 +00:00
|
|
|
st_bin_set_child (ST_BIN (button), label);
|
2009-09-10 03:13:35 +00:00
|
|
|
}
|
|
|
|
|
2009-09-20 01:10:15 +00:00
|
|
|
/* Fake a style change so that we reset the style properties on the label */
|
|
|
|
st_widget_style_changed (ST_WIDGET (button));
|
2009-09-10 03:13:35 +00:00
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (button), "label");
|
|
|
|
}
|
|
|
|
|
2011-01-25 21:22:00 +00:00
|
|
|
/**
|
|
|
|
* st_button_get_button_mask:
|
|
|
|
* @button: a #StButton
|
|
|
|
*
|
|
|
|
* Gets the mask of mouse buttons that @button emits the
|
|
|
|
* #StButton::clicked signal for.
|
|
|
|
*
|
|
|
|
* Returns: the mask of mouse buttons that @button emits the
|
|
|
|
* #StButton::clicked signal for.
|
|
|
|
*/
|
|
|
|
StButtonMask
|
|
|
|
st_button_get_button_mask (StButton *button)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (ST_IS_BUTTON (button), 0);
|
|
|
|
|
|
|
|
return button->priv->button_mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* st_button_set_button_mask:
|
|
|
|
* @button: a #Stbutton
|
|
|
|
* @mask: the mask of mouse buttons that @button responds to
|
|
|
|
*
|
|
|
|
* Sets which mouse buttons @button emits #StButton::clicked for.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
st_button_set_button_mask (StButton *button,
|
|
|
|
StButtonMask mask)
|
|
|
|
{
|
|
|
|
g_return_if_fail (ST_IS_BUTTON (button));
|
|
|
|
|
|
|
|
button->priv->button_mask = mask;
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (button), "button-mask");
|
|
|
|
}
|
|
|
|
|
2009-09-10 03:13:35 +00:00
|
|
|
/**
|
|
|
|
* st_button_get_toggle_mode:
|
|
|
|
* @button: a #StButton
|
|
|
|
*
|
|
|
|
* Get the toggle mode status of the button.
|
|
|
|
*
|
2010-03-23 23:56:10 +00:00
|
|
|
* Returns: %TRUE if toggle mode is set, otherwise %FALSE
|
2009-09-10 03:13:35 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
st_button_get_toggle_mode (StButton *button)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (ST_IS_BUTTON (button), FALSE);
|
|
|
|
|
|
|
|
return button->priv->is_toggle;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* st_button_set_toggle_mode:
|
|
|
|
* @button: a #Stbutton
|
2010-03-23 23:56:10 +00:00
|
|
|
* @toggle: %TRUE or %FALSE
|
2009-09-10 03:13:35 +00:00
|
|
|
*
|
|
|
|
* Enables or disables toggle mode for the button. In toggle mode, the active
|
|
|
|
* state will be "toggled" when the user clicks the button.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
st_button_set_toggle_mode (StButton *button,
|
|
|
|
gboolean toggle)
|
|
|
|
{
|
|
|
|
g_return_if_fail (ST_IS_BUTTON (button));
|
|
|
|
|
|
|
|
button->priv->is_toggle = toggle;
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (button), "toggle-mode");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* st_button_get_checked:
|
|
|
|
* @button: a #StButton
|
|
|
|
*
|
|
|
|
* Get the state of the button that is in toggle mode.
|
|
|
|
*
|
2010-03-23 23:56:10 +00:00
|
|
|
* Returns: %TRUE if the button is checked, or %FALSE if not
|
2009-09-10 03:13:35 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
st_button_get_checked (StButton *button)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (ST_IS_BUTTON (button), FALSE);
|
|
|
|
|
|
|
|
return button->priv->is_checked;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* st_button_set_checked:
|
|
|
|
* @button: a #Stbutton
|
2010-03-23 23:56:10 +00:00
|
|
|
* @checked: %TRUE or %FALSE
|
2009-09-10 03:13:35 +00:00
|
|
|
*
|
|
|
|
* Sets the pressed state of the button. This is only really useful if the
|
2010-03-23 23:56:10 +00:00
|
|
|
* button has #toggle-mode mode set to %TRUE.
|
2009-09-10 03:13:35 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
st_button_set_checked (StButton *button,
|
|
|
|
gboolean checked)
|
|
|
|
{
|
|
|
|
g_return_if_fail (ST_IS_BUTTON (button));
|
|
|
|
|
|
|
|
if (button->priv->is_checked != checked)
|
|
|
|
{
|
|
|
|
button->priv->is_checked = checked;
|
|
|
|
|
|
|
|
if (checked)
|
2010-11-02 17:24:29 +00:00
|
|
|
st_widget_add_style_pseudo_class (ST_WIDGET (button), "checked");
|
2009-09-10 03:13:35 +00:00
|
|
|
else
|
2010-11-02 17:24:29 +00:00
|
|
|
st_widget_remove_style_pseudo_class (ST_WIDGET (button), "checked");
|
2009-09-10 03:13:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (button), "checked");
|
|
|
|
}
|
2011-01-25 21:22:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* st_button_fake_release:
|
|
|
|
* @button: an #StButton
|
|
|
|
*
|
|
|
|
* If this widget is holding a pointer grab, this function will
|
|
|
|
* will ungrab it, and reset the pressed state. The effect is
|
|
|
|
* similar to if the user had released the mouse button, but without
|
|
|
|
* emitting the clicked signal.
|
|
|
|
*
|
|
|
|
* This function is useful if for example you want to do something
|
|
|
|
* after the user is holding the mouse button for a given period of
|
|
|
|
* time, breaking the grab.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
st_button_fake_release (StButton *button)
|
|
|
|
{
|
|
|
|
if (button->priv->pressed)
|
2014-07-22 10:23:25 +00:00
|
|
|
st_button_release (button, button->priv->device,
|
|
|
|
button->priv->pressed, 0, NULL);
|
2011-01-25 21:22:00 +00:00
|
|
|
|
|
|
|
if (button->priv->grabbed)
|
|
|
|
{
|
|
|
|
button->priv->grabbed = 0;
|
|
|
|
clutter_ungrab_pointer ();
|
|
|
|
}
|
2014-07-22 10:23:25 +00:00
|
|
|
|
|
|
|
if (button->priv->device &&
|
|
|
|
button->priv->press_sequence)
|
|
|
|
{
|
|
|
|
clutter_input_device_sequence_ungrab (button->priv->device,
|
|
|
|
button->priv->press_sequence);
|
|
|
|
button->priv->press_sequence = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
button->priv->device = NULL;
|
2011-01-25 21:22:00 +00:00
|
|
|
}
|
2011-05-23 19:35:28 +00:00
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
/*************************** ACCESSIBILITY SUPPORT ****************************/
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
#define ST_TYPE_BUTTON_ACCESSIBLE st_button_accessible_get_type ()
|
|
|
|
|
|
|
|
#define ST_BUTTON_ACCESSIBLE(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
|
|
|
|
ST_TYPE_BUTTON_ACCESSIBLE, StButtonAccessible))
|
|
|
|
|
|
|
|
#define ST_IS_BUTTON_ACCESSIBLE(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
|
|
|
|
ST_TYPE_BUTTON_ACCESSIBLE))
|
|
|
|
|
|
|
|
#define ST_BUTTON_ACCESSIBLE_CLASS(klass) \
|
|
|
|
(G_TYPE_CHECK_CLASS_CAST ((klass), \
|
|
|
|
ST_TYPE_BUTTON_ACCESSIBLE, StButtonAccessibleClass))
|
|
|
|
|
|
|
|
#define ST_IS_BUTTON_ACCESSIBLE_CLASS(klass) \
|
|
|
|
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
|
|
|
|
ST_TYPE_BUTTON_ACCESSIBLE))
|
|
|
|
|
|
|
|
#define ST_BUTTON_ACCESSIBLE_GET_CLASS(obj) \
|
|
|
|
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
|
|
|
|
ST_TYPE_BUTTON_ACCESSIBLE, StButtonAccessibleClass))
|
|
|
|
|
|
|
|
typedef struct _StButtonAccessible StButtonAccessible;
|
|
|
|
typedef struct _StButtonAccessibleClass StButtonAccessibleClass;
|
|
|
|
|
|
|
|
struct _StButtonAccessible
|
|
|
|
{
|
|
|
|
StWidgetAccessible parent;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _StButtonAccessibleClass
|
|
|
|
{
|
|
|
|
StWidgetAccessibleClass parent_class;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void st_button_accessible_class_init (StButtonAccessibleClass *klass);
|
|
|
|
static void st_button_accessible_init (StButtonAccessible *button);
|
|
|
|
|
|
|
|
/* AtkObject */
|
|
|
|
static void st_button_accessible_initialize (AtkObject *obj,
|
|
|
|
gpointer data);
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (StButtonAccessible, st_button_accessible, ST_TYPE_WIDGET_ACCESSIBLE)
|
|
|
|
|
2012-02-18 01:30:27 +00:00
|
|
|
static const gchar *
|
|
|
|
st_button_accessible_get_name (AtkObject *obj)
|
|
|
|
{
|
|
|
|
StButton *button = NULL;
|
|
|
|
const gchar *name = NULL;
|
|
|
|
|
|
|
|
button = ST_BUTTON (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (obj)));
|
|
|
|
|
|
|
|
if (button == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
name = ATK_OBJECT_CLASS (st_button_accessible_parent_class)->get_name (obj);
|
|
|
|
if (name != NULL)
|
|
|
|
return name;
|
|
|
|
|
|
|
|
return button->priv->text;
|
|
|
|
}
|
|
|
|
|
2011-05-23 19:35:28 +00:00
|
|
|
static void
|
|
|
|
st_button_accessible_class_init (StButtonAccessibleClass *klass)
|
|
|
|
{
|
|
|
|
AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
atk_class->initialize = st_button_accessible_initialize;
|
2012-02-18 01:30:27 +00:00
|
|
|
atk_class->get_name = st_button_accessible_get_name;
|
2011-05-23 19:35:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
st_button_accessible_init (StButtonAccessible *self)
|
|
|
|
{
|
|
|
|
/* initialization done on AtkObject->initialize */
|
|
|
|
}
|
|
|
|
|
2012-02-18 01:30:27 +00:00
|
|
|
static void
|
|
|
|
st_button_accessible_notify_label_cb (StButton *button,
|
|
|
|
GParamSpec *psec,
|
|
|
|
AtkObject *accessible)
|
|
|
|
{
|
|
|
|
g_object_notify (G_OBJECT (accessible), "accessible-name");
|
|
|
|
}
|
|
|
|
|
2012-08-24 15:18:31 +00:00
|
|
|
static void
|
|
|
|
st_button_accessible_compute_role (AtkObject *accessible,
|
|
|
|
StButton *button)
|
|
|
|
{
|
|
|
|
atk_object_set_role (accessible, button->priv->is_toggle
|
|
|
|
? ATK_ROLE_TOGGLE_BUTTON : ATK_ROLE_PUSH_BUTTON);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
st_button_accessible_notify_toggle_mode_cb (StButton *button,
|
|
|
|
GParamSpec *psec,
|
|
|
|
AtkObject *accessible)
|
|
|
|
{
|
|
|
|
st_button_accessible_compute_role (accessible, button);
|
|
|
|
}
|
|
|
|
|
2011-05-23 19:35:28 +00:00
|
|
|
static void
|
|
|
|
st_button_accessible_initialize (AtkObject *obj,
|
2012-08-24 15:18:31 +00:00
|
|
|
gpointer data)
|
2011-05-23 19:35:28 +00:00
|
|
|
{
|
|
|
|
ATK_OBJECT_CLASS (st_button_accessible_parent_class)->initialize (obj, data);
|
|
|
|
|
2012-08-24 15:18:31 +00:00
|
|
|
st_button_accessible_compute_role (obj, ST_BUTTON (data));
|
2012-02-18 01:30:27 +00:00
|
|
|
|
|
|
|
g_signal_connect (data, "notify::label",
|
|
|
|
G_CALLBACK (st_button_accessible_notify_label_cb), obj);
|
2012-08-24 15:18:31 +00:00
|
|
|
g_signal_connect (data, "notify::toggle-mode",
|
|
|
|
G_CALLBACK (st_button_accessible_notify_toggle_mode_cb), obj);
|
2011-05-23 19:35:28 +00:00
|
|
|
}
|