* Boston, MA 02111-1307, USA.
*/
+#include "config.h"
+
#include <string.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <libgail-util/gailmisc.h>
static void gail_expander_class_init (GailExpanderClass *klass);
-static void gail_expander_object_init (GailExpander *expander);
+static void gail_expander_init (GailExpander *expander);
static G_CONST_RETURN gchar* gail_expander_get_name (AtkObject *obj);
static gint gail_expander_get_n_children (AtkObject *obj)
static void gail_expander_finalize (GObject *object);
static void gail_expander_init_textutil (GailExpander *expander,
GtkExpander *widget);
+static G_CONST_RETURN gchar* gail_expander_get_full_text (GtkExpander *widget);
static void atk_action_interface_init (AtkActionIface *iface);
static gboolean gail_expander_do_action (AtkAction *action,
static AtkAttributeSet* gail_expander_get_default_attributes
(AtkText *text);
-static GailContainer* parent_class = NULL;
-
-GType
-gail_expander_get_type (void)
-{
- static GType type = 0;
-
- if (!type)
- {
- static const GTypeInfo tinfo =
- {
- sizeof (GailExpanderClass),
- (GBaseInitFunc) NULL, /* base init */
- (GBaseFinalizeFunc) NULL, /* base finalize */
- (GClassInitFunc) gail_expander_class_init, /* class init */
- (GClassFinalizeFunc) NULL, /* class finalize */
- NULL, /* class data */
- sizeof (GailExpander), /* instance size */
- 0, /* nb preallocs */
- (GInstanceInitFunc) gail_expander_object_init, /* instance init */
- NULL /* value table */
- };
-
- static const GInterfaceInfo atk_action_info =
- {
- (GInterfaceInitFunc) atk_action_interface_init,
- (GInterfaceFinalizeFunc) NULL,
- NULL
- };
-
- static const GInterfaceInfo atk_text_info =
- {
- (GInterfaceInitFunc) atk_text_interface_init,
- (GInterfaceFinalizeFunc) NULL,
- NULL
- };
-
- type = g_type_register_static (GAIL_TYPE_CONTAINER,
- "GailExpander", &tinfo, 0);
-
- g_type_add_interface_static (type, ATK_TYPE_ACTION,
- &atk_action_info);
- g_type_add_interface_static (type, ATK_TYPE_TEXT,
- &atk_text_info);
-
- }
-
- return type;
-}
+G_DEFINE_TYPE_WITH_CODE (GailExpander, gail_expander, GAIL_TYPE_CONTAINER,
+ G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init)
+ G_IMPLEMENT_INTERFACE (ATK_TYPE_TEXT, atk_text_interface_init))
static void
gail_expander_class_init (GailExpanderClass *klass)
gobject_class->finalize = gail_expander_finalize;
- parent_class = g_type_class_peek_parent (klass);
-
class->get_name = gail_expander_get_name;
class->get_n_children = gail_expander_get_n_children;
class->ref_child = gail_expander_ref_child;
}
static void
-gail_expander_object_init (GailExpander *expander)
+gail_expander_init (GailExpander *expander)
{
expander->activate_description = NULL;
expander->activate_keybinding = NULL;
expander->textutil = NULL;
}
-AtkObject*
-gail_expander_new (GtkWidget *widget)
-{
- GObject *object;
- AtkObject *accessible;
-
- g_return_val_if_fail (GTK_IS_EXPANDER (widget), NULL);
-
- object = g_object_new (GAIL_TYPE_EXPANDER, NULL);
-
- accessible = ATK_OBJECT (object);
- atk_object_initialize (accessible, widget);
-
- return accessible;
-}
-
static G_CONST_RETURN gchar*
gail_expander_get_name (AtkObject *obj)
{
G_CONST_RETURN gchar *name;
g_return_val_if_fail (GAIL_IS_EXPANDER (obj), NULL);
- name = ATK_OBJECT_CLASS (parent_class)->get_name (obj);
+ name = ATK_OBJECT_CLASS (gail_expander_parent_class)->get_name (obj);
if (name != NULL)
return name;
else
g_return_val_if_fail (GTK_IS_EXPANDER (widget), NULL);
- return gtk_expander_get_label (GTK_EXPANDER (widget));
+ return gail_expander_get_full_text (GTK_EXPANDER (widget));
}
}
/* See if there is a label - if there is, reduce our count by 1
* since we don't want the label included with the children.
*/
- if (gtk_expander_get_label_widget (widget))
+ if (gtk_expander_get_label_widget (GTK_EXPANDER (widget)))
count -= 1;
return count;
/* See if there is a label - if there is, we need to skip it
* since we don't want the label included with the children.
*/
- label = gtk_expander_get_label_widget (widget);
+ label = gtk_expander_get_label_widget (GTK_EXPANDER (widget));
if (label) {
count = g_list_length (children);
for (index = 0; index <= i; index++) {
GailExpander *gail_expander = GAIL_EXPANDER (obj);
GtkWidget *expander;
- ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);
+ ATK_OBJECT_CLASS (gail_expander_parent_class)->initialize (obj, data);
expander = GTK_WIDGET (data);
if (GTK_WIDGET_MAPPED (expander))
const gchar* label_text;
- label_text = gtk_expander_get_label (expander);
+ label_text = gail_expander_get_full_text (expander);
gail_expander = GAIL_EXPANDER (atk_obj);
if (gail_expander->textutil)
g_signal_emit_by_name (atk_obj, "visible_data_changed");
}
else
- GAIL_WIDGET_CLASS (parent_class)->notify_gtk (obj, pspec);
+ GAIL_WIDGET_CLASS (gail_expander_parent_class)->notify_gtk (obj, pspec);
+}
+
+static G_CONST_RETURN gchar*
+gail_expander_get_full_text (GtkExpander *widget)
+{
+ GtkWidget *label_widget;
+
+ label_widget = gtk_expander_get_label_widget (widget);
+
+ if (!GTK_IS_LABEL (label_widget))
+ return NULL;
+
+ return gtk_label_get_text (GTK_LABEL (label_widget));
}
static void
const gchar *label_text;
expander->textutil = gail_text_util_new ();
- label_text = gtk_expander_get_label (widget);
+ label_text = gail_expander_get_full_text (widget);
gail_text_util_text_setup (expander->textutil, label_text);
}
static void
atk_action_interface_init (AtkActionIface *iface)
{
- g_return_if_fail (iface != NULL);
-
iface->do_action = gail_expander_do_action;
iface->get_n_actions = gail_expander_get_n_actions;
iface->get_description = gail_expander_get_description;
*/
return FALSE;
- if (!GTK_WIDGET_IS_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget))
+ if (!gtk_widget_is_sensitive (widget) || !gtk_widget_get_visible (widget))
return FALSE;
expander = GAIL_EXPANDER (action);
if (expander->action_idle_handler)
return_value = FALSE;
else
- expander->action_idle_handler = g_idle_add (idle_do_action, expander);
+ expander->action_idle_handler = gdk_threads_add_idle (idle_do_action, expander);
break;
default:
return_value = FALSE;
GtkWidget *widget;
GailExpander *gail_expander;
- GDK_THREADS_ENTER ();
-
gail_expander = GAIL_EXPANDER (data);
gail_expander->action_idle_handler = 0;
widget = GTK_ACCESSIBLE (gail_expander)->widget;
if (widget == NULL /* State is defunct */ ||
- !GTK_WIDGET_IS_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget))
- {
- GDK_THREADS_LEAVE ();
- return FALSE;
- }
+ !gtk_widget_is_sensitive (widget) || !gtk_widget_get_visible (widget))
+ return FALSE;
gtk_widget_activate (widget);
- GDK_THREADS_LEAVE ();
-
- return FALSE;
+ return FALSE;
}
static gint
GtkWidget *widget;
GtkExpander *expander;
- state_set = ATK_OBJECT_CLASS (parent_class)->ref_state_set (obj);
+ state_set = ATK_OBJECT_CLASS (gail_expander_parent_class)->ref_state_set (obj);
widget = GTK_ACCESSIBLE (obj)->widget;
if (widget == NULL)
static void
atk_text_interface_init (AtkTextIface *iface)
{
- g_return_if_fail (iface != NULL);
iface->get_text = gail_expander_get_text;
iface->get_character_at_offset = gail_expander_get_character_at_offset;
iface->get_text_before_offset = gail_expander_get_text_before_offset;
if (!expander->textutil)
gail_expander_init_textutil (expander, GTK_EXPANDER (widget));
- label_text = gtk_expander_get_label (GTK_EXPANDER (widget));
+ label_text = gail_expander_get_full_text (GTK_EXPANDER (widget));
if (label_text == NULL)
return NULL;
if (expander->textutil)
g_object_unref (expander->textutil);
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (gail_expander_parent_class)->finalize (object);
}