Back to index

unity  6.0.0
unity-panel-view-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: Rodrigo Moya <rodrigo.moya@canonical.com>
00017  */
00018 
00031 #include <glib/gi18n-lib.h>
00032 #include <Nux/Nux.h>
00033 #include "PanelView.h"
00034 #include "unity-panel-view-accessible.h"
00035 
00036 #include "unitya11y.h"
00037 
00038 using namespace unity;
00039 
00040 /* GObject */
00041 static void unity_panel_view_accessible_class_init(UnityPanelViewAccessibleClass* klass);
00042 static void unity_panel_view_accessible_init(UnityPanelViewAccessible* self);
00043 
00044 /* AtkObject */
00045 static void         unity_panel_view_accessible_initialize(AtkObject* accessible, gpointer data);
00046 static gint         unity_panel_view_accessible_get_n_children(AtkObject* accessible);
00047 static AtkObject*   unity_panel_view_accessible_ref_child(AtkObject* accessible, gint i);
00048 
00049 G_DEFINE_TYPE(UnityPanelViewAccessible, unity_panel_view_accessible,  NUX_TYPE_VIEW_ACCESSIBLE)
00050 
00051 static void
00052 unity_panel_view_accessible_class_init(UnityPanelViewAccessibleClass* klass)
00053 {
00054   AtkObjectClass* atk_class = ATK_OBJECT_CLASS(klass);
00055 
00056   /* AtkObject */
00057   atk_class->initialize = unity_panel_view_accessible_initialize;
00058   atk_class->get_n_children = unity_panel_view_accessible_get_n_children;
00059   atk_class->ref_child = unity_panel_view_accessible_ref_child;
00060 }
00061 
00062 static void
00063 unity_panel_view_accessible_init(UnityPanelViewAccessible* self)
00064 {
00065 }
00066 
00067 AtkObject*
00068 unity_panel_view_accessible_new(nux::Object* object)
00069 {
00070   AtkObject* accessible;
00071 
00072   g_return_val_if_fail(dynamic_cast<PanelView*>(object), NULL);
00073 
00074   accessible = ATK_OBJECT(g_object_new(UNITY_TYPE_PANEL_VIEW_ACCESSIBLE, NULL));
00075 
00076   atk_object_initialize(accessible, object);
00077 
00078   return accessible;
00079 }
00080 
00081 static void
00082 unity_panel_view_accessible_initialize(AtkObject* accessible, gpointer data)
00083 {
00084   ATK_OBJECT_CLASS(unity_panel_view_accessible_parent_class)->initialize(accessible, data);
00085 
00086   accessible->role = ATK_ROLE_PANEL;
00087 }
00088 
00089 static gint
00090 unity_panel_view_accessible_get_n_children(AtkObject* accessible)
00091 {
00092   nux::Object* nux_object = NULL;
00093   gint rc = 0;
00094 
00095   g_return_val_if_fail(UNITY_IS_PANEL_VIEW_ACCESSIBLE(accessible), 0);
00096 
00097   nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(accessible));
00098   if (!nux_object) /* state is defunct */
00099     return 0;
00100 
00101   return rc;
00102 }
00103 
00104 static AtkObject*
00105 unity_panel_view_accessible_ref_child(AtkObject* accessible, gint i)
00106 {
00107   nux::Object* nux_object = NULL;
00108   AtkObject* child_accessible = NULL;
00109 
00110   g_return_val_if_fail(UNITY_IS_PANEL_VIEW_ACCESSIBLE(accessible), NULL);
00111 
00112   nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(accessible));
00113   if (!nux_object) /* state is defunct */
00114     return NULL;
00115 
00116   return child_accessible;
00117 }