Back to index

unity  6.0.0
unity-result-accessible.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2011 Canonical Ltd
00003  *
00004  * This program is free software: you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License version 3 as
00006  * published by the Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  * GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00015  *
00016  * Authored by: Alejandro PiƱeiro Iglesias <apinheiro@igalia.com>
00017  */
00018 
00034 #include "unity-result-accessible.h"
00035 #include "unity-rvgrid-accessible.h"
00036 
00037 #include "unitya11y.h"
00038 
00039 /* GObject */
00040 static void unity_result_accessible_class_init(UnityResultAccessibleClass* klass);
00041 static void unity_result_accessible_init(UnityResultAccessible* result_accessible);
00042 
00043 /* AtkObject.h */
00044 static void          unity_result_accessible_initialize(AtkObject* accessible,
00045                                                         gpointer   data);
00046 static AtkStateSet*  unity_result_accessible_ref_state_set(AtkObject* obj);
00047 
00048 G_DEFINE_TYPE(UnityResultAccessible,
00049               unity_result_accessible,
00050               ATK_TYPE_OBJECT);
00051 
00052 #define UNITY_RESULT_ACCESSIBLE_GET_PRIVATE(obj) \
00053   (G_TYPE_INSTANCE_GET_PRIVATE ((obj), UNITY_TYPE_RESULT_ACCESSIBLE, \
00054                                 UnityResultAccessiblePrivate))
00055 
00056 struct _UnityResultAccessiblePrivate
00057 {
00058 };
00059 
00060 static void
00061 unity_result_accessible_class_init(UnityResultAccessibleClass* klass)
00062 {
00063   GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
00064   AtkObjectClass* atk_class = ATK_OBJECT_CLASS(klass);
00065 
00066   /* AtkObject */
00067   atk_class->initialize = unity_result_accessible_initialize;
00068   atk_class->ref_state_set = unity_result_accessible_ref_state_set;
00069 
00070   g_type_class_add_private(gobject_class, sizeof(UnityResultAccessiblePrivate));
00071 }
00072 
00073 static void
00074 unity_result_accessible_init(UnityResultAccessible* result_accessible)
00075 {
00076   UnityResultAccessiblePrivate* priv =
00077     UNITY_RESULT_ACCESSIBLE_GET_PRIVATE(result_accessible);
00078 
00079   result_accessible->priv = priv;
00080 }
00081 
00082 AtkObject*
00083 unity_result_accessible_new()
00084 {
00085   AtkObject* accessible = NULL;
00086 
00087   accessible = ATK_OBJECT(g_object_new(UNITY_TYPE_RESULT_ACCESSIBLE, NULL));
00088 
00089   atk_object_initialize(accessible, NULL);
00090 
00091   return accessible;
00092 }
00093 
00094 /* AtkObject.h */
00095 static void
00096 unity_result_accessible_initialize(AtkObject* accessible,
00097                                    gpointer data)
00098 {
00099   ATK_OBJECT_CLASS(unity_result_accessible_parent_class)->initialize(accessible, data);
00100 
00101   /* On unity Result is just data, but on the accessible
00102      implementation we are using this object to represent each icon
00103      selected on the result grid, so a push button */
00104   atk_object_set_role(accessible, ATK_ROLE_PUSH_BUTTON);
00105 }
00106 
00107 static AtkStateSet*
00108 unity_result_accessible_ref_state_set(AtkObject* obj)
00109 {
00110   AtkStateSet* state_set = NULL;
00111 
00112   g_return_val_if_fail(UNITY_IS_RESULT_ACCESSIBLE(obj), NULL);
00113 
00114   state_set = ATK_OBJECT_CLASS(unity_result_accessible_parent_class)->ref_state_set(obj);
00115 
00116   /* by default, this is a fly-weight/dummy object, so if created we have
00117      this information */
00118   atk_state_set_add_state(state_set, ATK_STATE_FOCUSABLE);
00119   atk_state_set_add_state(state_set, ATK_STATE_ENABLED);
00120   atk_state_set_add_state(state_set, ATK_STATE_SENSITIVE);
00121 
00122   atk_state_set_add_state(state_set, ATK_STATE_VISIBLE);
00123   atk_state_set_add_state(state_set, ATK_STATE_SHOWING);
00124 
00125   /* This object is not focused, the focused is the parent
00126      ResultViewGrid */
00127   // atk_state_set_add_state(state_set, ATK_STATE_FOCUSED);
00128   atk_state_set_add_state(state_set, ATK_STATE_SELECTED);
00129   atk_state_set_add_state(state_set, ATK_STATE_ACTIVE);
00130 
00131   return state_set;
00132 }