aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarry Lu <harry.lu@sun.com>2005-01-04 15:40:37 +0800
committerHarry Lu <haip@src.gnome.org>2005-01-04 15:40:37 +0800
commitad5c80a5bea1b6201033be2bc74ad197828ea0f5 (patch)
tree86a231d239533fb27369469315d533be92ddf4a5
parent929792231aae9868bbcf6388b309a78e26ae10ba (diff)
downloadgsoc2013-evolution-ad5c80a5bea1b6201033be2bc74ad197828ea0f5.tar.gz
gsoc2013-evolution-ad5c80a5bea1b6201033be2bc74ad197828ea0f5.tar.zst
gsoc2013-evolution-ad5c80a5bea1b6201033be2bc74ad197828ea0f5.zip
add ea-combo-button.[ch] to Makefile.
2005-01-04 Harry Lu <harry.lu@sun.com> * widgets/Makefile.am: add ea-combo-button.[ch] to Makefile. * widgets/ea-combo-button.c: * widgets/ea-combo-button.h: implement a11y object for e-combo-button. * widgets/ea-widgets.c: (e_combo_button_a11y_init): set a11y factory. * widgets/ea-widgets.h: add declaration. svn path=/trunk/; revision=28228
-rw-r--r--a11y/ChangeLog8
-rw-r--r--a11y/widgets/Makefile.am2
-rw-r--r--a11y/widgets/ea-combo-button.c170
-rw-r--r--a11y/widgets/ea-combo-button.h35
-rw-r--r--a11y/widgets/ea-widgets.c9
-rw-r--r--a11y/widgets/ea-widgets.h1
6 files changed, 224 insertions, 1 deletions
diff --git a/a11y/ChangeLog b/a11y/ChangeLog
index da27fc5275..a7b15a3b5d 100644
--- a/a11y/ChangeLog
+++ b/a11y/ChangeLog
@@ -1,3 +1,11 @@
+2005-01-04 Harry Lu <harry.lu@sun.com>
+
+ * widgets/Makefile.am: add ea-combo-button.[ch] to Makefile.
+ * widgets/ea-combo-button.c:
+ * widgets/ea-combo-button.h: implement a11y object for e-combo-button.
+ * widgets/ea-widgets.c: (e_combo_button_a11y_init): set a11y factory.
+ * widgets/ea-widgets.h: add declaration.
+
2004-12-09 Harry Lu <harry.lu@sun.com>
Fix a warning.
diff --git a/a11y/widgets/Makefile.am b/a11y/widgets/Makefile.am
index 2480c3bba7..6e8e0e4a1d 100644
--- a/a11y/widgets/Makefile.am
+++ b/a11y/widgets/Makefile.am
@@ -23,6 +23,8 @@ libevolution_widgets_a11y_la_SOURCES = \
ea-calendar-item.h \
ea-calendar-cell.c \
ea-calendar-cell.h \
+ ea-combo-button.c \
+ ea-combo-button.h \
ea-widgets.c \
ea-widgets.h
diff --git a/a11y/widgets/ea-combo-button.c b/a11y/widgets/ea-combo-button.c
new file mode 100644
index 0000000000..aad60c3023
--- /dev/null
+++ b/a11y/widgets/ea-combo-button.c
@@ -0,0 +1,170 @@
+/*
+ * Authors: Harry Lu <harry.lu@sun.com>
+ *
+ * Copyright (C) 2004 Ximian, Inc.
+ */
+
+#include <config.h>
+#include "ea-combo-button.h"
+#include <gtk/gtkbutton.h>
+#include <gtk/gtklabel.h>
+#include <glib/gi18n.h>
+
+static AtkObjectClass *parent_class;
+static GType parent_type;
+
+/*Action IDs */
+enum {
+ ACTIVATE_DEFAULT,
+ POPUP_MENU,
+ LAST_ACTION
+};
+
+/* Static functions */
+static G_CONST_RETURN gchar*
+ea_combo_button_get_name (AtkObject *a11y)
+{
+ GtkWidget *widget;
+ GtkWidget *label;
+ EComboButton *button;
+
+ widget = GTK_ACCESSIBLE (a11y)->widget;
+ if (!widget)
+ return NULL;
+
+ button = E_COMBO_BUTTON (widget);
+ label = e_combo_button_get_label (button);
+ if (label)
+ return gtk_label_get_text (GTK_LABEL (label));
+
+ return _("Combo Button");
+}
+
+/* Action interface */
+static G_CONST_RETURN gchar *
+ea_combo_button_action_get_name (AtkAction *action, gint i)
+{
+ switch (i)
+ {
+ case ACTIVATE_DEFAULT:
+ return _("Activate Default");
+ case POPUP_MENU:
+ return _("Popup Menu");
+ default:
+ return NULL;
+ }
+}
+
+static gboolean
+ea_combo_button_do_action (AtkAction *action,
+ gint i)
+{
+ GtkWidget *widget;
+ EComboButton *button;
+
+ widget = GTK_ACCESSIBLE (action)->widget;
+ if (!widget || !GTK_WIDGET_IS_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget))
+ return FALSE;
+
+ button = E_COMBO_BUTTON (widget);
+
+ switch (i)
+ {
+ case ACTIVATE_DEFAULT:
+ g_signal_emit_by_name (button, "activate_default");
+ return TRUE;
+ case POPUP_MENU:
+ return e_combo_button_popup_menu (button);
+ default:
+ return FALSE;
+ }
+}
+
+static gint
+ea_combo_button_get_n_actions (AtkAction *action)
+{
+ return LAST_ACTION;
+}
+
+static void
+atk_action_interface_init (AtkActionIface *iface)
+{
+ g_return_if_fail (iface != NULL);
+
+ iface->do_action = ea_combo_button_do_action;
+ iface->get_n_actions = ea_combo_button_get_n_actions;
+ iface->get_name = ea_combo_button_action_get_name;
+}
+
+static void
+ea_combo_button_class_init (EaComboButtonClass *klass)
+{
+ AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass);
+
+ parent_class = g_type_class_ref (parent_type);
+
+ atk_object_class->get_name = ea_combo_button_get_name;
+}
+
+static void
+ea_combo_button_init (EaComboButton *a11y)
+{
+ /* Empty for now */
+}
+
+GType
+ea_combo_button_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type) {
+ AtkObjectFactory *factory;
+ GTypeQuery query;
+
+ GTypeInfo info = {
+ sizeof (EaComboButtonClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) ea_combo_button_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EaComboButton),
+ 0,
+ (GInstanceInitFunc) ea_combo_button_init,
+ NULL /* value_tree */
+ };
+
+ static const GInterfaceInfo atk_action_info = {
+ (GInterfaceInitFunc) atk_action_interface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL
+ };
+
+ factory = atk_registry_get_factory (atk_get_default_registry (), GTK_TYPE_BUTTON);
+ parent_type = atk_object_factory_get_accessible_type (factory);
+ g_type_query (parent_type, &query);
+
+ info.class_size = query.class_size;
+ info.instance_size = query.instance_size;
+
+ type = g_type_register_static (parent_type, "EaComboButton", &info, 0);
+ g_type_add_interface_static (type, ATK_TYPE_ACTION,
+ &atk_action_info);
+
+ }
+
+ return type;
+}
+
+AtkObject *
+ea_combo_button_new (GtkWidget *widget)
+{
+ EaComboButton *a11y;
+
+ a11y = g_object_new (ea_combo_button_get_type (), NULL);
+
+ GTK_ACCESSIBLE (a11y)->widget = GTK_WIDGET (widget);
+ ATK_OBJECT (a11y)->role = ATK_ROLE_PUSH_BUTTON;
+
+ return ATK_OBJECT (a11y);
+}
diff --git a/a11y/widgets/ea-combo-button.h b/a11y/widgets/ea-combo-button.h
new file mode 100644
index 0000000000..8f4c279cba
--- /dev/null
+++ b/a11y/widgets/ea-combo-button.h
@@ -0,0 +1,35 @@
+/*
+ * Authors: Harry Lu <harry.lu@sun.com>
+ *
+ * Copyright (C) 2004 Ximian, Inc.
+ */
+
+#ifndef __EA_COMBO_BUTTON_H_
+#define __EA_COMBO_BUTTON_H_
+
+#include <gtk/gtkaccessible.h>
+#include <misc/e-combo-button.h>
+
+#define EA_TYPE_COMBO_BUTTON (ea_combo_button_get_type ())
+#define EA_COMBO_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_COMBO_BUTTON, EaComboButton))
+#define EA_COMBO_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_COMBO_BUTTON, EaComboButtonClass))
+#define EA_IS_COMBO_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_COMBO_BUTTON))
+#define EA_IS_COMBO_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_COMBO_BUTTON))
+
+typedef struct _EaComboButton EaComboButton;
+typedef struct _EaComboButtonClass EaComboButtonClass;
+
+struct _EaComboButton {
+ GtkAccessible object;
+};
+
+struct _EaComboButtonClass {
+ GtkAccessibleClass parent_class;
+};
+
+
+/* Standard Glib function */
+GType ea_combo_button_get_type (void);
+AtkObject *ea_combo_button_new (GtkWidget *combo_button);
+
+#endif /* ! __EA_COMBO_BUTTON_H_ */
diff --git a/a11y/widgets/ea-widgets.c b/a11y/widgets/ea-widgets.c
index edead1b785..feef6d1ef3 100644
--- a/a11y/widgets/ea-widgets.c
+++ b/a11y/widgets/ea-widgets.c
@@ -25,11 +25,18 @@
#include "ea-factory.h"
#include "widgets/ea-calendar-item.h"
+#include "widgets/ea-combo-button.h"
#include "ea-widgets.h"
-EA_FACTORY_GOBJECT (EA_TYPE_CALENDAR_ITEM, ea_calendar_item, ea_calendar_item_new)
+EA_FACTORY_GOBJECT (EA_TYPE_CALENDAR_ITEM, ea_calendar_item, ea_calendar_item_new);
+EA_FACTORY (EA_TYPE_COMBO_BUTTON, ea_combo_button, ea_combo_button_new);
void e_calendar_item_a11y_init (void)
{
EA_SET_FACTORY (e_calendar_item_get_type (), ea_calendar_item);
}
+
+void e_combo_button_a11y_init (void)
+{
+ EA_SET_FACTORY (e_combo_button_get_type (), ea_combo_button);
+}
diff --git a/a11y/widgets/ea-widgets.h b/a11y/widgets/ea-widgets.h
index e9ec9b3ad9..fc8e7f1b90 100644
--- a/a11y/widgets/ea-widgets.h
+++ b/a11y/widgets/ea-widgets.h
@@ -30,5 +30,6 @@
#define _EA_WIDGETS_H__
void e_calendar_item_a11y_init (void);
+void e_combo_button_a11y_init (void);
#endif /* _EA_WIDGETS_H__ */