[maemo-commits] [maemo-commits] r11308 - in projects/haf/trunk/hail: . hail/hail-hildon-desktop
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Wed Apr 25 16:46:57 EEST 2007
- Previous message: [maemo-commits] r11307 - in projects/haf/trunk/hildon-1: . src
- Next message: [maemo-commits] r11309 - in projects/haf/trunk/hildon-1: . debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: fherrera Date: 2007-04-25 16:46:56 +0300 (Wed, 25 Apr 2007) New Revision: 11308 Added: projects/haf/trunk/hail/hail/hail-hildon-desktop/hailhomearea.c projects/haf/trunk/hail/hail/hail-hildon-desktop/hailhomearea.h projects/haf/trunk/hail/hail/hail-hildon-desktop/hailhometitlebar.c projects/haf/trunk/hail/hail/hail-hildon-desktop/hailhometitlebar.h projects/haf/trunk/hail/hail/hail-hildon-desktop/hailtogglebutton.c projects/haf/trunk/hail/hail/hail-hildon-desktop/hailtogglebutton.h Modified: projects/haf/trunk/hail/ChangeLog Log: 2007-04-25 Fernando Herrera <fernando.herrera-de-las-heras at nokia.com> * hail/hail-hildon-desktop/*: Added forgotten files in the previous commit. Modified: projects/haf/trunk/hail/ChangeLog =================================================================== --- projects/haf/trunk/hail/ChangeLog 2007-04-25 13:44:25 UTC (rev 11307) +++ projects/haf/trunk/hail/ChangeLog 2007-04-25 13:46:56 UTC (rev 11308) @@ -1,3 +1,8 @@ +2007-04-25 Fernando Herrera <fernando.herrera-de-las-heras at nokia.com> + + * hail/hail-hildon-desktop/*: + Added forgotten files in the previous commit. + 2007-04-23 Fernando Herrera <fernando.herrera-de-las-heras at nokia.com> * hail/hail-hildon-desktop/Makefile.am: Added: projects/haf/trunk/hail/hail/hail-hildon-desktop/hailhomearea.c =================================================================== --- projects/haf/trunk/hail/hail/hail-hildon-desktop/hailhomearea.c 2007-04-25 13:44:25 UTC (rev 11307) +++ projects/haf/trunk/hail/hail/hail-hildon-desktop/hailhomearea.c 2007-04-25 13:46:56 UTC (rev 11308) @@ -0,0 +1,197 @@ +/* HAIL - The Hildon Accessibility Implementation Library + * Copyright (C) 2007 Nokia Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that 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 along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/** + * SECTION:haildesktopwindow + * @short_description: Implementation of the ATK interfaces for a #HailHomeArea. + * @see_also: #HildonHomeArea + * + * #HailHomeArea implements the required ATK interfaces of #HailHomeArea. + * In particular it exposes: + * <itemizedlist> + * <listitem>The embedded control. It gets a default name and a default description.</listitem> + * </itemizedlist> + */ + +#include <libhildondesktop/hildon-home-area.h> +#include "hailhomearea.h" + +static void hail_home_area_class_init (HailHomeAreaClass *klass); +static void hail_home_area_object_init (HailHomeArea *home_area); +static void hail_home_area_finalize (GObject *object); + + +static G_CONST_RETURN gchar *hail_home_area_get_name (AtkObject *obj); +static G_CONST_RETURN gchar *hail_home_area_get_description (AtkObject *obj); + +#define HAIL_HOME_AREA_DEFAULT_NAME "Hildon Home Area" +#define HAIL_HOME_AREA_DEFAULT_DESCRIPTION "Area used as space for home applets and applications" + +static GType parent_type; +static GtkAccessibleClass *parent_class = NULL; + +/** + * hail_home_area_get_type: + * + * Initialises, and returns the type of a #HailHomeArea. + * + * Return value: GType of #HailHomeArea. + **/ +GType +hail_home_area_get_type (void) +{ + static GType type = 0; + + if (!type) + { + AtkObjectFactory *factory; + GTypeQuery query; + GTypeInfo tinfo = + { + (guint16) sizeof (HailHomeAreaClass), + (GBaseInitFunc) NULL, /* base init */ + (GBaseFinalizeFunc) NULL, /* base finalize */ + (GClassInitFunc) hail_home_area_class_init, /* class init */ + (GClassFinalizeFunc) NULL, /* class finalize */ + NULL, /* class data */ + (guint16) sizeof (HailHomeArea), /* instance size */ + 0, /* nb preallocs */ + (GInstanceInitFunc) hail_home_area_object_init, /* instance init */ + NULL /* value table */ + }; + + factory = atk_registry_get_factory (atk_get_default_registry (), HILDON_TYPE_HOME_AREA); + parent_type = atk_object_factory_get_accessible_type (factory); + g_type_query (parent_type, &query); + + tinfo.class_size = (guint16) query.class_size; + tinfo.instance_size = (guint16) query.instance_size; + + type = g_type_register_static (parent_type, + "HailHomeArea", &tinfo, 0); + } + + return type; +} + +static void +hail_home_area_class_init (HailHomeAreaClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + AtkObjectClass *class = ATK_OBJECT_CLASS (klass); + + gobject_class->finalize = hail_home_area_finalize; + + parent_class = g_type_class_peek_parent (klass); + + /* bind virtual methods */ + class->get_name = hail_home_area_get_name; + class->get_description = hail_home_area_get_description; +} + +static void +hail_home_area_object_init (HailHomeArea *home_area) +{ +} + +static void +hail_home_area_finalize (GObject *object) +{ + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +/** + * hail_home_area_new: + * @widget: a #HildonHomeArea casted as a #GtkWidget + * + * Creates a new instance of the ATK implementation for the + * #HildonHomeArea. + * + * Return value: An #AtkObject + **/ +AtkObject * +hail_home_area_new (GtkWidget *widget) +{ + GObject *object = NULL; + AtkObject *accessible = NULL; + + g_return_val_if_fail (HILDON_IS_HOME_AREA(widget), NULL); + + object = g_object_new (HAIL_TYPE_HOME_AREA, NULL); + + accessible = ATK_OBJECT (object); + atk_object_initialize (accessible, widget); + + return accessible; +} + +/* + * Implementation of AtkObject method get_name() + */ +static G_CONST_RETURN gchar * +hail_home_area_get_name (AtkObject *obj) +{ +/*REMOVE*/fprintf(stderr, "hail_home_area_get_name\n"); + G_CONST_RETURN gchar *name = NULL; + + g_return_val_if_fail (HAIL_IS_HOME_AREA (obj), NULL); + + /* parent name */ + name = ATK_OBJECT_CLASS (parent_class)->get_name (obj); + + /* HildonHomeArea name */ + if (name == NULL) + { + GtkWidget *widget = NULL; + + widget = GTK_ACCESSIBLE(obj)->widget; + + /* Since we are in the top class, + * we'll use the class name for the a11y name + * and not test for the type of the widget. + */ +/* name = G_OBJECT_CLASS_NAME(G_OBJECT_CLASS(GTK_WIDGET_GET_CLASS(widget))); */ + name = HAIL_HOME_AREA_DEFAULT_NAME; + } + + return name; +} + +/* + * Implementation of AtkObject method get_description() + */ +static G_CONST_RETURN gchar * +hail_home_area_get_description (AtkObject *obj) +{ + G_CONST_RETURN gchar *description = NULL; + + g_return_val_if_fail (HAIL_IS_HOME_AREA (obj), NULL); + + /* parent description */ + description = ATK_OBJECT_CLASS (parent_class)->get_description (obj); + + /* HildonHomeArea description */ + if (description == NULL) + { + /* get the default description */ + description = HAIL_HOME_AREA_DEFAULT_DESCRIPTION; + } + + return description; +} Added: projects/haf/trunk/hail/hail/hail-hildon-desktop/hailhomearea.h =================================================================== --- projects/haf/trunk/hail/hail/hail-hildon-desktop/hailhomearea.h 2007-04-25 13:44:25 UTC (rev 11307) +++ projects/haf/trunk/hail/hail/hail-hildon-desktop/hailhomearea.h 2007-04-25 13:46:56 UTC (rev 11308) @@ -0,0 +1,55 @@ +/* HAIL - The Hildon Accessibility Implementation Library + * Copyright (C) 2005 Nokia Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __HAIL_HOME_AREA_H__ +#define __HAIL_HOME_AREA_H__ + +#include <gtk/gtkaccessible.h> + +G_BEGIN_DECLS + +#define HAIL_TYPE_HOME_AREA (hail_home_area_get_type ()) +#define HAIL_HOME_AREA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), HAIL_TYPE_HOME_AREA, HailHomeArea)) +#define HAIL_HOME_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), HAIL_TYPE_HOME_AREA, HailHomeAreaClass)) +#define HAIL_IS_HOME_AREA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), HAIL_TYPE_HOME_AREA)) +#define HAIL_IS_HOME_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), HAIL_TYPE_HOME_AREA)) +#define HAIL_HOME_AREA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), HAIL_TYPE_HOME_AREA, HailHomeAreaClass)) + + +typedef struct _HailHomeArea HailHomeArea; +typedef struct _HailHomeAreaClass HailHomeAreaClass; + +struct _HailHomeArea +{ + GtkAccessible parent; +}; + +GType hail_home_area_get_type (void); + +struct _HailHomeAreaClass +{ + GtkAccessibleClass parent_class; +}; + +AtkObject *hail_home_area_new (GtkWidget *widget); + +G_END_DECLS + + +#endif /* __HAIL_HOME_AREA_H__ */ Added: projects/haf/trunk/hail/hail/hail-hildon-desktop/hailhometitlebar.c =================================================================== --- projects/haf/trunk/hail/hail/hail-hildon-desktop/hailhometitlebar.c 2007-04-25 13:44:25 UTC (rev 11307) +++ projects/haf/trunk/hail/hail/hail-hildon-desktop/hailhometitlebar.c 2007-04-25 13:46:56 UTC (rev 11308) @@ -0,0 +1,337 @@ +/* HAIL - The Hildon Accessibility Implementation Library + * Copyright (C) 2007 Nokia Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that 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 along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/** + * SECTION:hailhometitlebar + * @short_description: Implementation of the ATK interfaces for a #HailHomeTitlebar. + * @see_also: #HildonHomeTitlebar + * + * #HailHomeTitlebar implements the required ATK interfaces of #AtkObject. + * In particular it exposes: + * <itemizedlist> + * <listitem>The embedded control. It gives a default name and description. + * <listitem>Added the 'press' action within the titlebar for showing the menu.</listitem> + * </itemizedlist> + */ + +#include <gdk/gdk.h> +#include <libhildondesktop/hildon-home-titlebar.h> +#include "hailhometitlebar.h" + +static void hail_home_titlebar_class_init (HailHomeTitlebarClass *klass); +static void hail_home_titlebar_object_init (HailHomeTitlebar *home_titlebar); +static void hail_home_titlebar_finalize (GObject *object); + +static G_CONST_RETURN gchar *hail_home_titlebar_get_name (AtkObject *obj); +static G_CONST_RETURN gchar *hail_home_titlebar_get_description (AtkObject *obj); + +/* AtkAction.h */ +static void hail_home_titlebar_atk_action_interface_init + (AtkActionIface *iface); +static gint hail_home_titlebar_action_get_n_actions + (AtkAction *action); +static gboolean hail_home_titlebar_action_do_action (AtkAction *action, + gint index); +static const gchar * hail_home_titlebar_action_get_name (AtkAction *action, + gint index); +static const gchar * hail_home_titlebar_action_get_description + (AtkAction *action, + gint index); +static const gchar * hail_home_titlebar_action_get_keybinding + (AtkAction *action, + gint index); + +#define HAIL_HOME_TITLEBAR_DEFAULT_NAME "Home Titlebar" +#define HAIL_HOME_TITLEBAR_DEFAULT_DESCRIPTION "Bar for showing titles and layout menu" +#define HAIL_HOME_TITLEBAR_ACTION_PRESS_NAME "press" +#define HAIL_HOME_TITLEBAR_ACTION_PRESS_DESCRIPTION "Synthesize press signal for showing the menu" + +static GType parent_type; +static GtkAccessibleClass *parent_class = NULL; + +/** + * hail_home_titlebar_get_type: + * + * Initialises, and returns the type of a #HailHomeTitlebar. + * + * Return value: GType of #HailHomeTitlebar. + **/ +GType +hail_home_titlebar_get_type (void) +{ + static GType type = 0; + + if (!type) + { + AtkObjectFactory *factory; + GTypeQuery query; + GTypeInfo tinfo = + { + (guint16) sizeof (HailHomeTitlebarClass), + (GBaseInitFunc) NULL, /* base init */ + (GBaseFinalizeFunc) NULL, /* base finalize */ + (GClassInitFunc) hail_home_titlebar_class_init, /* class init */ + (GClassFinalizeFunc) NULL, /* class finalize */ + NULL, /* class data */ + (guint16) sizeof (HailHomeTitlebar), /* instance size */ + 0, /* nb preallocs */ + (GInstanceInitFunc) hail_home_titlebar_object_init, /* instance init */ + NULL /* value table */ + }; + + static const GInterfaceInfo atk_action_info = + { + (GInterfaceInitFunc) hail_home_titlebar_atk_action_interface_init, + (GInterfaceFinalizeFunc) NULL, + NULL + }; + + factory = atk_registry_get_factory (atk_get_default_registry (), HILDON_TYPE_HOME_TITLEBAR); + parent_type = atk_object_factory_get_accessible_type (factory); + g_type_query (parent_type, &query); + + tinfo.class_size = (guint16) query.class_size; + tinfo.instance_size = (guint16) query.instance_size; + + type = g_type_register_static (parent_type, + "HailHomeTitlebar", &tinfo, 0); + + g_type_add_interface_static (type, ATK_TYPE_ACTION, + &atk_action_info); + + } + + return type; +} + +static void +hail_home_titlebar_class_init (HailHomeTitlebarClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + AtkObjectClass *class = ATK_OBJECT_CLASS (klass); + + gobject_class->finalize = hail_home_titlebar_finalize; + + parent_class = g_type_class_peek_parent (klass); + + /* bind virtual methods for AtkObject */ + class->get_name = hail_home_titlebar_get_name; + class->get_description = hail_home_titlebar_get_description; +} + +static void +hail_home_titlebar_object_init (HailHomeTitlebar *home_titlebar) +{ +} + +static void +hail_home_titlebar_finalize (GObject *object) +{ + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +/** + * hail_home_titlebar_new: + * @widget: a #HildonHomeTitlebar casted as a #GtkWidget + * + * Creates a new instance of the ATK implementation for the + * #GtkHomeTitlebar. + * + * Return value: An #AtkObject + **/ +AtkObject * +hail_home_titlebar_new (GtkWidget *widget) +{ + GObject *object = NULL; + AtkObject *accessible = NULL; + + g_return_val_if_fail (HILDON_IS_HOME_TITLEBAR(widget), NULL); + + object = g_object_new (HAIL_TYPE_HOME_TITLEBAR, NULL); + + accessible = ATK_OBJECT (object); + atk_object_initialize (accessible, widget); + + return accessible; +} + +/* + * Implementation of AtkObject method get_name() + */ +static G_CONST_RETURN gchar * +hail_home_titlebar_get_name (AtkObject *obj) +{ + G_CONST_RETURN gchar *name = NULL; + GtkWidget *home_titlebar = NULL; + + g_return_val_if_fail (HAIL_IS_HOME_TITLEBAR (obj), NULL); + home_titlebar = GTK_ACCESSIBLE(obj)->widget; + + /* parent name */ + name = ATK_OBJECT_CLASS (parent_class)->get_name (obj); + + if (name == NULL) + { + name = HAIL_HOME_TITLEBAR_DEFAULT_NAME; + } + + return name; +} + +/* + * Implementation of AtkObject method get_description() + */ +static G_CONST_RETURN gchar * +hail_home_titlebar_get_description (AtkObject *obj) +{ + G_CONST_RETURN gchar *description = NULL; + GtkWidget *home_titlebar = NULL; + + g_return_val_if_fail (HAIL_IS_HOME_TITLEBAR (obj), NULL); + home_titlebar = GTK_ACCESSIBLE(obj)->widget; + + /* parent description */ + description = ATK_OBJECT_CLASS (parent_class)->get_description (obj); + + if (description == NULL) + { + description = HAIL_HOME_TITLEBAR_DEFAULT_DESCRIPTION; + } + + return description; +} + +/* + * Initializes the AtkAction interface, and binds the virtual methods + */ +static void +hail_home_titlebar_atk_action_interface_init (AtkActionIface *iface) +{ + g_return_if_fail (iface != NULL); + + iface->get_n_actions = hail_home_titlebar_action_get_n_actions; + iface->do_action = hail_home_titlebar_action_do_action; + iface->get_name = hail_home_titlebar_action_get_name; + iface->get_description = hail_home_titlebar_action_get_description; + iface->get_keybinding = hail_home_titlebar_action_get_keybinding; +} + +/* + * Implementation of AtkAction method get_n_actions() + */ +static gint +hail_home_titlebar_action_get_n_actions (AtkAction *action) +{ + g_return_val_if_fail (HAIL_IS_HOME_TITLEBAR (action), 0); + GtkWidget *home_titlebar = NULL; + + home_titlebar = GTK_ACCESSIBLE (action)->widget; + g_return_val_if_fail (HILDON_IS_HOME_TITLEBAR(home_titlebar), 0); + + /* expose the "press" */ + return 1; +} + +/* + * Implementation of AtkAction method do_action() + */ +static gboolean +hail_home_titlebar_action_do_action (AtkAction *action, + gint index) +{ + GtkWidget *home_titlebar = NULL; + + g_return_val_if_fail (HAIL_IS_HOME_TITLEBAR (action), FALSE); + + home_titlebar = GTK_ACCESSIBLE (action)->widget; + g_return_val_if_fail (HILDON_IS_HOME_TITLEBAR (home_titlebar), FALSE); + + if (index == 0) + { + /* we are going to synthesize the "button-press-event" + * over the HildonHomeTitlebar + */ + HildonHomeTitlebarClass *klass = HILDON_HOME_TITLEBAR_GET_CLASS (home_titlebar); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + GdkEvent *event = gdk_event_new (GDK_BUTTON_PRESS); + + /* + * need to assign button.[xy] for the GdkEventButton + * as we are generating an event for this + * widget GdkWindow itself we can use x=1 and y=1 + */ + event->button.x = event->button.y = 1; + + /* begin the process for showing the menu */ + widget_class->button_press_event(home_titlebar, event); + } + + return TRUE; +} + +/* + * Implementation of AtkAction method get_name() + */ +static const gchar * +hail_home_titlebar_action_get_name (AtkAction *action, + gint index) +{ + GtkWidget *home_titlebar = NULL; + g_return_val_if_fail (HAIL_IS_HOME_TITLEBAR (action), NULL); + g_return_val_if_fail ((index == 0), NULL); + + home_titlebar = GTK_ACCESSIBLE (action)->widget; + g_return_val_if_fail (HILDON_IS_HOME_TITLEBAR(home_titlebar), NULL); + + return HAIL_HOME_TITLEBAR_ACTION_PRESS_NAME; +} + +/* + * Implementation of AtkAction method get_description() + */ +static const gchar * +hail_home_titlebar_action_get_description (AtkAction *action, + gint index) +{ + GtkWidget *home_titlebar = NULL; + + g_return_val_if_fail (HAIL_IS_HOME_TITLEBAR (action), NULL); + g_return_val_if_fail ((index == 0), NULL); + + home_titlebar = GTK_ACCESSIBLE (action)->widget; + g_return_val_if_fail (HILDON_IS_HOME_TITLEBAR(home_titlebar), NULL); + + return HAIL_HOME_TITLEBAR_ACTION_PRESS_DESCRIPTION; +} + +/* Implementation of AtkAction method get_keybinding */ +static const gchar * +hail_home_titlebar_action_get_keybinding (AtkAction *action, + gint index) +{ + GtkWidget *home_titlebar = NULL; + + g_return_val_if_fail (HAIL_IS_HOME_TITLEBAR (action), NULL); + g_return_val_if_fail ((index == 0), NULL); + + home_titlebar = GTK_ACCESSIBLE (action)->widget; + g_return_val_if_fail (HILDON_IS_HOME_TITLEBAR(home_titlebar), NULL); + + return NULL; +} Added: projects/haf/trunk/hail/hail/hail-hildon-desktop/hailhometitlebar.h =================================================================== --- projects/haf/trunk/hail/hail/hail-hildon-desktop/hailhometitlebar.h 2007-04-25 13:44:25 UTC (rev 11307) +++ projects/haf/trunk/hail/hail/hail-hildon-desktop/hailhometitlebar.h 2007-04-25 13:46:56 UTC (rev 11308) @@ -0,0 +1,55 @@ +/* HAIL - The Hildon Accessibility Implementation Library + * Copyright (C) 2005 Nokia Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General License + * Public as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __HAIL_HOME_TITLEBAR_H__ +#define __HAIL_HOME_TITLEBAR_H__ + +#include <gtk/gtkaccessible.h> + +G_BEGIN_DECLS + +#define HAIL_TYPE_HOME_TITLEBAR (hail_home_titlebar_get_type ()) +#define HAIL_HOME_TITLEBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), HAIL_TYPE_HOME_TITLEBAR, HailHomeTitlebar)) +#define HAIL_HOME_TITLEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), HAIL_TYPE_HOME_TITLEBAR, HailHomeTitlebarClass)) +#define HAIL_IS_HOME_TITLEBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), HAIL_TYPE_HOME_TITLEBAR)) +#define HAIL_IS_HOME_TITLEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), HAIL_TYPE_HOME_TITLEBAR)) +#define HAIL_HOME_TITLEBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), HAIL_TYPE_HOME_TITLEBAR, HailHomeTitlebarClass)) + + +typedef struct _HailHomeTitlebar HailHomeTitlebar; +typedef struct _HailHomeTitlebarClass HailHomeTitlebarClass; + +struct _HailHomeTitlebar +{ + GtkAccessible parent; +}; + +GType hail_home_titlebar_get_type (void); + +struct _HailHomeTitlebarClass +{ + GtkAccessibleClass parent_class; +}; + +AtkObject *hail_home_titlebar_new (GtkWidget *widget); + +G_END_DECLS + + +#endif /* __HAIL_HOME_TITLEBAR_H__ */ Added: projects/haf/trunk/hail/hail/hail-hildon-desktop/hailtogglebutton.c =================================================================== --- projects/haf/trunk/hail/hail/hail-hildon-desktop/hailtogglebutton.c 2007-04-25 13:44:25 UTC (rev 11307) +++ projects/haf/trunk/hail/hail/hail-hildon-desktop/hailtogglebutton.c 2007-04-25 13:46:56 UTC (rev 11308) @@ -0,0 +1,417 @@ +/* HAIL - The Hildon Accessibility Implementation Library + * Copyright (C) 2007 Nokia Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that 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 along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/** + * SECTION:hailtogglebutton + * @short_description: Implementation of the ATK interfaces for a #HailToggleButton. + * @see_also: #GtkToggleButton, #HNAppButton + * + * #HailToggleButton implements the required ATK interfaces of #AtkObject. + * In particular it exposes (for HNAppButton): + * <itemizedlist> + * <listitem>The embedded control. It gets the name from the #HDEntryInfo taken the name + it represents, + * taken it from the #HDEntryInfo. When no applications are running, a + * default name is given.</listitem> + * <listitem>Added behaviour to action of clicking the toggle button</listitem> + * </itemizedlist> + */ + +#include <gtk/gtktogglebutton.h> +#include <libhildonwm/hd-entry-info.h> +#include <libhildonwm/hd-wm.h> +#include "hailtogglebutton.h" + +static void hail_toggle_button_class_init (HailToggleButtonClass *klass); +static void hail_toggle_button_object_init (HailToggleButton *toggle_button); +static void hail_toggle_button_finalize (GObject *object); + +static G_CONST_RETURN gchar *hail_toggle_button_get_name (AtkObject *obj); +static G_CONST_RETURN gchar *hail_toggle_button_get_description (AtkObject *obj); + +/* AtkAction.h */ +static void hail_toggle_button_atk_action_interface_init + (AtkActionIface *iface); +static gboolean hail_toggle_button_action_do_action (AtkAction *action, + gint index); + +static void hail_toggle_button_real_initialize (AtkObject *obj, + gpointer data); + +static void hail_toggle_button_app_button_entry_changed_cb + (GObject *toggle_button, + GParamSpec *spec, + gpointer data); + +#define HAIL_HN_APP_BUTTON_DEFAULT_NAME "HNAppButton" +#define HAIL_HN_APP_BUTTON_DEFAULT_DESCRIPTION "A single HNAppButton" +#define HAIL_TOGGLE_BUTTON_DEFAULT_NAME "Toggle Button" +#define HAIL_TOGGLE_BUTTON_DEFAULT_DESCRIPTION "A single toggle button" + +typedef struct _HailToggleButtonPrivate HailToggleButtonPrivate; +struct _HailToggleButtonPrivate +{ + /* name to expose */ + /* not freed at finalize because it is constant */ + const gchar *name; +}; + +#define HAIL_TOGGLE_BUTTON_GET_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((o), HAIL_TYPE_TOGGLE_BUTTON, HailToggleButtonPrivate)) + +static GType parent_type; +static GType hn_app_button_type; +static GtkAccessibleClass *parent_class = NULL; + +/** + * hail_toggle_button_get_type: + * + * Initialises, and returns the type of a #HailToggleButton. + * + * Return value: GType of #HailToggleButton. + **/ +GType +hail_toggle_button_get_type (void) +{ + static GType type = 0; + + if (!type) + { + AtkObjectFactory *factory; + GTypeQuery query; + GTypeInfo tinfo = + { + (guint16) sizeof (HailToggleButtonClass), + (GBaseInitFunc) NULL, /* base init */ + (GBaseFinalizeFunc) NULL, /* base finalize */ + (GClassInitFunc) hail_toggle_button_class_init, /* class init */ + (GClassFinalizeFunc) NULL, /* class finalize */ + NULL, /* class data */ + (guint16) sizeof (HailToggleButton), /* instance size */ + 0, /* nb preallocs */ + (GInstanceInitFunc) hail_toggle_button_object_init, /* instance init */ + NULL /* value table */ + }; + + static const GInterfaceInfo atk_action_info = + { + (GInterfaceInitFunc) hail_toggle_button_atk_action_interface_init, + (GInterfaceFinalizeFunc) NULL, + NULL + }; + + factory = atk_registry_get_factory (atk_get_default_registry (), GTK_TYPE_TOGGLE_BUTTON); + parent_type = atk_object_factory_get_accessible_type (factory); + g_type_query (parent_type, &query); + + tinfo.class_size = (guint16) query.class_size; + tinfo.instance_size = (guint16) query.instance_size; + + type = g_type_register_static (parent_type, + "HailToggleButton", &tinfo, 0); + + g_type_add_interface_static (type, ATK_TYPE_ACTION, + &atk_action_info); + + } + + return type; +} + +static void +hail_toggle_button_class_init (HailToggleButtonClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + AtkObjectClass *class = ATK_OBJECT_CLASS (klass); + + gobject_class->finalize = hail_toggle_button_finalize; + + parent_class = g_type_class_peek_parent (klass); + + g_type_class_add_private(klass, (gsize) sizeof(HailToggleButtonPrivate)); + + /* bind virtual methods for AtkObject */ + class->get_name = hail_toggle_button_get_name; + class->get_description = hail_toggle_button_get_description; + class->initialize = hail_toggle_button_real_initialize; +} + +static void +hail_toggle_button_object_init (HailToggleButton *toggle_button) +{ + HailToggleButtonPrivate *priv = NULL; + + g_return_if_fail (HAIL_IS_TOGGLE_BUTTON (toggle_button)); + priv = HAIL_TOGGLE_BUTTON_GET_PRIVATE(HAIL_TOGGLE_BUTTON(toggle_button)); + + /* type */ + hn_app_button_type = g_type_from_name ("HNAppButton"); + + /* default values */ + priv->name = NULL; +} + +static void +hail_toggle_button_finalize (GObject *object) +{ + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +/** + * hail_toggle_button_new: + * @widget: a #GtkToggleButton (HNAppMenuItem) casted as a #GtkWidget + * + * Creates a new instance of the ATK implementation for the + * #GtkToggleButton. + * + * Return value: An #AtkObject + **/ +AtkObject * +hail_toggle_button_new (GtkWidget *widget) +{ + GObject *object = NULL; + AtkObject *accessible = NULL; + + g_return_val_if_fail (GTK_IS_TOGGLE_BUTTON(widget), NULL); + + object = g_object_new (HAIL_TYPE_TOGGLE_BUTTON, NULL); + + accessible = ATK_OBJECT (object); + atk_object_initialize (accessible, widget); + + return accessible; +} + +/* + * Implementation of AtkObject method get_name() + */ +static G_CONST_RETURN gchar * +hail_toggle_button_get_name (AtkObject *obj) +{ + G_CONST_RETURN gchar *name = NULL; + GtkWidget *toggle_button = NULL; + + g_return_val_if_fail (HAIL_IS_TOGGLE_BUTTON (obj), NULL); + toggle_button = GTK_ACCESSIBLE(obj)->widget; + + /* parent name */ + name = ATK_OBJECT_CLASS (parent_class)->get_name (obj); + + if (name == NULL) + { + /* concrete implementation for HNAppButton */ + if (g_type_is_a (G_TYPE_FROM_INSTANCE(toggle_button), hn_app_button_type)) + { + HailToggleButtonPrivate *priv = NULL; + priv = HAIL_TOGGLE_BUTTON_GET_PRIVATE(HAIL_TOGGLE_BUTTON(obj)); + + /* updated by the callback (hail_toggle_button_app_button_entry_changed_cb) */ + name = priv->name; + + } + + /* for GtkToggleButton */ + else + { + name = HAIL_TOGGLE_BUTTON_DEFAULT_NAME; + } + } + + return name; +} + +/* + * Implementation of AtkObject method get_description() + */ +static G_CONST_RETURN gchar * +hail_toggle_button_get_description (AtkObject *obj) +{ + G_CONST_RETURN gchar *description = NULL; + GtkWidget *toggle_button = NULL; + + g_return_val_if_fail (HAIL_IS_TOGGLE_BUTTON (obj), NULL); + toggle_button = GTK_ACCESSIBLE(obj)->widget; + + /* parent description */ + description = ATK_OBJECT_CLASS (parent_class)->get_description (obj); + + if (description == NULL) + { + /* concrete implementation for HNAppButton */ + if (g_type_is_a (G_TYPE_FROM_INSTANCE(toggle_button), hn_app_button_type)) + { + description = HAIL_HN_APP_BUTTON_DEFAULT_DESCRIPTION; + } + + /* for GtkToggleButton */ + else + { + description = HAIL_TOGGLE_BUTTON_DEFAULT_DESCRIPTION; + } + } + + return description; +} + +/* + * Initializes the AtkAction interface, and binds the virtual methods + */ +static void +hail_toggle_button_atk_action_interface_init (AtkActionIface *iface) +{ + g_return_if_fail (iface != NULL); + + iface->do_action = hail_toggle_button_action_do_action; +} + +/* + * Implementation of AtkAction method do_action() + */ +static gboolean +hail_toggle_button_action_do_action (AtkAction *action, + gint index) +{ + GtkWidget *toggle_button = NULL; + + g_return_val_if_fail (HAIL_IS_TOGGLE_BUTTON (action), FALSE); + + toggle_button = GTK_ACCESSIBLE (action)->widget; + g_return_val_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button), FALSE); + + /* apply parent behaviour */ + AtkActionIface *parent_action_iface = + g_type_interface_peek_parent (ATK_ACTION_GET_IFACE (action)); + + if (parent_action_iface->do_action(action, index) == FALSE) + { + return FALSE; + } + + /* implementation for HNAppButton */ + if (g_type_is_a (G_TYPE_FROM_INSTANCE(toggle_button), hn_app_button_type)) + { + /* we want to add behaviour for "click" action */ + if (index == 0) + { + /* top the selected app: + * see hn-app-button:hn_app_button_pop_menu for details + */ + HDEntryInfo *info = NULL; + + /* entry-info is a pointer property, + * so we mustn't free it with hd_entry_info_free + */ + g_object_get (G_OBJECT(toggle_button), + "entry-info", &info, + NULL); + + if (info != NULL) + { + hd_wm_top_item (info); + } + } + } + + return TRUE; +} + +/* + * Implementation of AtkObject method initialize() + */ +static void +hail_toggle_button_real_initialize (AtkObject *obj, gpointer data) +{ + HailToggleButtonPrivate *priv = NULL; + GtkWidget *toggle_button = NULL; + + g_return_if_fail (HAIL_IS_TOGGLE_BUTTON (obj)); + priv = HAIL_TOGGLE_BUTTON_GET_PRIVATE(HAIL_TOGGLE_BUTTON(obj)); + + /* parent initialize */ + ATK_OBJECT_CLASS (parent_class)->initialize (obj, data); + + toggle_button = GTK_ACCESSIBLE(obj)->widget; + + /* accessibility HNAppButton initialize */ + if (g_type_is_a (G_TYPE_FROM_INSTANCE(toggle_button), hn_app_button_type)) + { + HDEntryInfo *info = NULL; + + /* entry-info is a pointer property, + * so we mustn't free it with hd_entry_info_free + */ + g_object_get (G_OBJECT(toggle_button), + "entry-info", &info, + NULL); + + if (info != NULL) + { + /* name of the application */ + priv->name = hd_entry_info_peek_app_name (info); + } + else + { + /* default name */ + priv->name = HAIL_HN_APP_BUTTON_DEFAULT_NAME; + } + + /* connect for changes in the HDEntryInfo */ + g_signal_connect (G_OBJECT(toggle_button), "notify", + G_CALLBACK(hail_toggle_button_app_button_entry_changed_cb), obj); + } +} + +static void +hail_toggle_button_app_button_entry_changed_cb (GObject *toggle_button, + GParamSpec *spec, + gpointer data) +{ + HailToggleButtonPrivate *priv = NULL; + AtkObject *obj = ATK_OBJECT(data); + + priv = HAIL_TOGGLE_BUTTON_GET_PRIVATE(HAIL_TOGGLE_BUTTON(obj)); + + /* implementation for HNAppButton */ + if (g_type_is_a (G_TYPE_FROM_INSTANCE(toggle_button), hn_app_button_type)) + { + /* check for HDEntryInfo property changes */ + if (g_ascii_strcasecmp (spec->name, "entry-info")) + { + HDEntryInfo *info = NULL; + + /* entry-info is a pointer property, + * so we mustn't free it with hd_entry_info_free + */ + g_object_get (G_OBJECT(toggle_button), + "entry-info", &info, + NULL); + + if (info != NULL) + { + /* name of the application */ + priv->name = hd_entry_info_peek_app_name (info); + } + else + { + priv->name = HAIL_HN_APP_BUTTON_DEFAULT_NAME; + } + } + } +} + Added: projects/haf/trunk/hail/hail/hail-hildon-desktop/hailtogglebutton.h =================================================================== --- projects/haf/trunk/hail/hail/hail-hildon-desktop/hailtogglebutton.h 2007-04-25 13:44:25 UTC (rev 11307) +++ projects/haf/trunk/hail/hail/hail-hildon-desktop/hailtogglebutton.h 2007-04-25 13:46:56 UTC (rev 11308) @@ -0,0 +1,55 @@ +/* HAIL - The Hildon Accessibility Implementation Library + * Copyright (C) 2005 Nokia Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General License + * Public as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __HAIL_TOGGLE_BUTTON_H__ +#define __HAIL_TOGGLE_BUTTON_H__ + +#include <gtk/gtkaccessible.h> + +G_BEGIN_DECLS + +#define HAIL_TYPE_TOGGLE_BUTTON (hail_toggle_button_get_type ()) +#define HAIL_TOGGLE_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), HAIL_TYPE_TOGGLE_BUTTON, HailToggleButton)) +#define HAIL_TOGGLE_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), HAIL_TYPE_TOGGLE_BUTTON, HailToggleButtonClass)) +#define HAIL_IS_TOGGLE_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), HAIL_TYPE_TOGGLE_BUTTON)) +#define HAIL_IS_TOGGLE_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), HAIL_TYPE_TOGGLE_BUTTON)) +#define HAIL_TOGGLE_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), HAIL_TYPE_TOGGLE_BUTTON, HailToggleButtonClass)) + + +typedef struct _HailToggleButton HailToggleButton; +typedef struct _HailToggleButtonClass HailToggleButtonClass; + +struct _HailToggleButton +{ + GtkAccessible parent; +}; + +GType hail_toggle_button_get_type (void); + +struct _HailToggleButtonClass +{ + GtkAccessibleClass parent_class; +}; + +AtkObject *hail_toggle_button_new (GtkWidget *widget); + +G_END_DECLS + + +#endif /* __HAIL_TOGGLE_BUTTON_H__ */
- Previous message: [maemo-commits] r11307 - in projects/haf/trunk/hildon-1: . src
- Next message: [maemo-commits] r11309 - in projects/haf/trunk/hildon-1: . debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]