3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU Lesser General Public License as published by
5 * the Free Software Foundation.
7 * This program is distributed in the hope that it will be useful, but
8 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
9 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * You should have received a copy of the GNU Lesser General Public License
13 * along with this program; if not, see <http://www.gnu.org/licenses/>.
17 * Yang Wu <yang.wu@sun.com>
19 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
23 #include "evolution-config.h"
25 #include "ea-jump-button.h"
26 #include "ea-calendar-helpers.h"
27 #include "ea-week-view.h"
28 #include "e-week-view.h"
29 #include <libgnomecanvas/libgnomecanvas.h>
30 #include <glib/gi18n.h>
32 static void ea_jump_button_class_init (EaJumpButtonClass
*klass
);
34 static const gchar
* ea_jump_button_get_name (AtkObject
*accessible
);
35 static const gchar
* ea_jump_button_get_description (AtkObject
*accessible
);
37 /* action interface */
38 static void atk_action_interface_init (AtkActionIface
*iface
);
39 static gboolean
jump_button_do_action (AtkAction
*action
,
41 static gint
jump_button_get_n_actions (AtkAction
*action
);
42 static const gchar
* jump_button_get_keybinding (AtkAction
*action
,
45 static gpointer parent_class
= NULL
;
48 ea_jump_button_get_type (void)
50 static GType type
= 0;
51 AtkObjectFactory
*factory
;
53 GType derived_atk_type
;
56 static GTypeInfo tinfo
= {
57 sizeof (EaJumpButtonClass
),
59 (GBaseFinalizeFunc
) NULL
,
60 (GClassInitFunc
) ea_jump_button_class_init
,
61 (GClassFinalizeFunc
) NULL
,
62 /* class_data */ NULL
,
63 sizeof (EaJumpButton
),
65 (GInstanceInitFunc
) NULL
,
66 /* value_table */ NULL
69 static const GInterfaceInfo atk_action_info
= {
70 (GInterfaceInitFunc
) atk_action_interface_init
,
71 (GInterfaceFinalizeFunc
) NULL
,
76 * Figure out the size of the class and instance
77 * we are run-time deriving from (atk object for
78 * GNOME_TYPE_CANVAS_ITEM, in this case)
81 factory
= atk_registry_get_factory (
82 atk_get_default_registry (), GNOME_TYPE_CANVAS_ITEM
);
84 atk_object_factory_get_accessible_type (factory
);
85 g_type_query (derived_atk_type
, &query
);
87 tinfo
.class_size
= query
.class_size
;
88 tinfo
.instance_size
= query
.instance_size
;
90 /* we inherit the component and other
91 * interfaces from GNOME_TYPE_CANVAS_ITEM */
92 type
= g_type_register_static (
93 derived_atk_type
, "EaJumpButton", &tinfo
, 0);
95 g_type_add_interface_static (
96 type
, ATK_TYPE_ACTION
, &atk_action_info
);
103 ea_jump_button_class_init (EaJumpButtonClass
*klass
)
105 AtkObjectClass
*class = ATK_OBJECT_CLASS (klass
);
107 parent_class
= g_type_class_peek_parent (klass
);
109 class->get_name
= ea_jump_button_get_name
;
110 class->get_description
= ea_jump_button_get_description
;
114 ea_jump_button_new (GObject
*obj
)
116 AtkObject
*atk_obj
= NULL
;
119 g_return_val_if_fail (GNOME_IS_CANVAS_ITEM (obj
), NULL
);
122 atk_obj
= g_object_get_data (target_obj
, "accessible-object");
125 static AtkRole event_role
= ATK_ROLE_INVALID
;
126 atk_obj
= ATK_OBJECT (
127 g_object_new (EA_TYPE_JUMP_BUTTON
, NULL
));
128 atk_object_initialize (atk_obj
, target_obj
);
129 if (event_role
== ATK_ROLE_INVALID
)
130 event_role
= atk_role_register ("Jump Button");
131 atk_obj
->role
= event_role
;
134 /* The registered factory for GNOME_TYPE_CANVAS_ITEM cannot create
135 * an EaJumpbutton, we should save the EaJumpbutton object in it. */
136 g_object_set_data (obj
, "accessible-object", atk_obj
);
142 ea_jump_button_get_name (AtkObject
*accessible
)
144 g_return_val_if_fail (EA_IS_JUMP_BUTTON (accessible
), NULL
);
146 if (accessible
->name
)
147 return accessible
->name
;
148 return _("Jump button");
152 ea_jump_button_get_description (AtkObject
*accessible
)
154 if (accessible
->description
)
155 return accessible
->description
;
157 return _("Click here, you can find more events.");
161 atk_action_interface_init (AtkActionIface
*iface
)
163 g_return_if_fail (iface
!= NULL
);
165 iface
->do_action
= jump_button_do_action
;
166 iface
->get_n_actions
= jump_button_get_n_actions
;
167 iface
->get_keybinding
= jump_button_get_keybinding
;
171 jump_button_do_action (AtkAction
*action
,
174 gboolean return_value
= TRUE
;
175 AtkGObjectAccessible
*atk_gobj
;
177 GnomeCanvasItem
*item
;
178 ECalendarView
*cal_view
;
179 EWeekView
*week_view
;
181 atk_gobj
= ATK_GOBJECT_ACCESSIBLE (action
);
182 g_obj
= atk_gobject_accessible_get_object (atk_gobj
);
186 item
= GNOME_CANVAS_ITEM (g_obj
);
187 cal_view
= ea_calendar_helpers_get_cal_view_from (GNOME_CANVAS_ITEM (item
));
188 week_view
= E_WEEK_VIEW (cal_view
);
193 e_week_view_jump_to_button_item (week_view
, GNOME_CANVAS_ITEM (item
));
196 return_value
= FALSE
;
203 jump_button_get_n_actions (AtkAction
*action
)
209 jump_button_get_keybinding (AtkAction
*action
,
212 const gchar
*return_value
= NULL
;
218 return_value
= "space or enter";