Compare commits

..

1 Commits

Author SHA1 Message Date
Matthias Clasen
a9c7f94e04 Change list widget to use a GtkSelectionModel
Change the type of the model property in GtkListView,
GtkColumnView and GtkGridView to be GtkSelectionModel.

The convenience of automatic interposition of a selection
model is minor, compared to the confusion.

Update all callers.
2020-07-17 07:35:09 -04:00
414 changed files with 40563 additions and 6378 deletions

View File

@@ -56,6 +56,7 @@ building for:
- [Pango](https://download.gnome.org/sources/pango)
- [Epoxy](https://github.com/anholt/libepoxy)
- [Graphene](https://github.com/ebassi/graphene)
- [ATK](https://download.gnome.org/sources/atk)
- [Xkb-common](https://github.com/xkbcommon/libxkbcommon)
If you are building the X11 backend, you will also need:
@@ -69,6 +70,7 @@ If you are building the X11 backend, you will also need:
- xcursor
- xdamage
- xcomposite
- [atk-bridge-2.0](https://download.gnome.org/sources/at-spi2-atk)
If you are building the Wayland backend, you will also need:

View File

@@ -95,6 +95,9 @@
<property name="program-name" translatable="yes">Builder demo</property>
<property name="logo-icon-name" translatable="yes">gtk3-demo</property>
<property name="modal">True</property>
<accessibility>
<relation target="window1" type="subwindow-of"/>
</accessibility>
</object>
<object class="GtkWindow" id="window1">
<property name="default-height">250</property>
@@ -110,6 +113,11 @@
</child>
<child>
<object class="GtkBox" id="toolbar1">
<child internal-child="accessible">
<object class="AtkObject" id="a11y-toolbar">
<property name="AtkObject::accessible-name">The toolbar</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">New</property>
@@ -166,6 +174,14 @@
<object class="GtkTreeView" id="treeview1">
<property name="model">liststore1</property>
<property name="tooltip-column">3</property>
<child internal-child="accessible">
<object class="AtkObject" id="a11y-treeview">
<property name="AtkObject::accessible-name">Name list</property>
<property name="AtkObject::accessible-description">
A list of person with name, surname and age columns
</property>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="column1">
<property name="title">Name</property>

View File

@@ -23,6 +23,7 @@
#include "demotaggedentry.h"
#include <gtk/gtk.h>
#include <gtk/gtk-a11y.h>
struct _DemoTaggedEntry
{
@@ -118,6 +119,7 @@ demo_tagged_entry_class_init (DemoTaggedEntryClass *klass)
gtk_editable_install_properties (object_class, 1);
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_ENTRY_ACCESSIBLE);
gtk_widget_class_set_css_name (widget_class, "entry");
}

View File

@@ -45,6 +45,9 @@
<attributes>
<attribute name="weight" value="bold"></attribute>
</attributes>
<accessibility>
<relation type="label-for" target="treeview1"/>
</accessibility>
<layout>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
@@ -80,6 +83,9 @@
</child>
</object>
</child>
<accessibility>
<relation type="labelled-by" target="label1"/>
</accessibility>
<layout>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
@@ -127,6 +133,9 @@
</child>
</object>
</child>
<accessibility>
<relation type="labelled-by" target="label2"/>
</accessibility>
<layout>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
@@ -140,6 +149,9 @@
<attributes>
<attribute name="weight" value="bold"></attribute>
</attributes>
<accessibility>
<relation type="label-for" target="treeview2"/>
</accessibility>
<layout>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
@@ -153,6 +165,9 @@
<attributes>
<attribute name="weight" value="bold"></attribute>
</attributes>
<accessibility>
<relation type="label-for" target="treeview3"/>
</accessibility>
<layout>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
@@ -182,6 +197,9 @@
</child>
</object>
</child>
<accessibility>
<relation type="labelled-by" target="label3"/>
</accessibility>
<layout>
<property name="left-attach">0</property>
<property name="top-attach">3</property>

View File

@@ -84,6 +84,9 @@
<property name="yalign">0</property>
<property name="label" translatable="0">Message</property>
<property name="wrap">1</property>
<accessibility>
<role type="static"/>
</accessibility>
<layout>
<property name="left-attach">1</property>
<property name="top-attach">1</property>

View File

@@ -144,6 +144,7 @@ do_listview_applauncher (GtkWidget *do_widget)
{
GtkWidget *list, *sw;
GListModel *model;
GtkSelectionModel *selection;
GtkListItemFactory *factory;
/* Create a window and set a few defaults */
@@ -181,8 +182,10 @@ do_listview_applauncher (GtkWidget *do_widget)
* to create as many listitems as it needs to show itself to the user.
*/
model = create_application_list ();
gtk_list_view_set_model (GTK_LIST_VIEW (list), model);
selection = GTK_SELECTION_MODEL (gtk_single_selection_new (model));
gtk_list_view_set_model (GTK_LIST_VIEW (list), selection);
g_object_unref (model);
g_object_unref (selection);
/* List widgets should always be contained in a #GtkScrolledWindow,
* because otherwise they might get too large or they might not

View File

@@ -491,7 +491,7 @@ do_listview_clocks (GtkWidget *do_widget)
model = create_clocks_model ();
selection = gtk_no_selection_new (model);
gtk_grid_view_set_model (GTK_GRID_VIEW (gridview), G_LIST_MODEL (selection));
gtk_grid_view_set_model (GTK_GRID_VIEW (gridview), GTK_SELECTION_MODEL (selection));
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), gridview);
g_object_unref (selection);
g_object_unref (model);

View File

@@ -662,7 +662,8 @@ create_color_grid (void)
{
GtkWidget *gridview;
GtkListItemFactory *factory;
GListModel *model, *selection;
GListModel *model;
GtkSelectionModel *selection;
gridview = gtk_grid_view_new ();
gtk_scrollable_set_hscroll_policy (GTK_SCROLLABLE (gridview), GTK_SCROLL_NATURAL);
@@ -678,7 +679,7 @@ create_color_grid (void)
model = G_LIST_MODEL (gtk_sort_list_model_new (gtk_color_list_new (0), NULL));
selection = G_LIST_MODEL (gtk_multi_selection_new (model));
selection = GTK_SELECTION_MODEL (gtk_multi_selection_new (model));
gtk_grid_view_set_model (GTK_GRID_VIEW (gridview), selection);
g_object_unref (selection);
g_object_unref (model);
@@ -857,7 +858,7 @@ do_listview_colors (GtkWidget *do_widget)
guint len;
GtkWidget *selection_view;
GListModel *selection_filter;
GListModel *no_selection;
GtkSelectionModel *selection;
GtkWidget *grid;
GtkWidget *selection_size_label;
GtkWidget *selection_average_picture;
@@ -945,10 +946,10 @@ do_listview_colors (GtkWidget *do_widget)
g_signal_connect (selection_filter, "items-changed", G_CALLBACK (update_selection_count), selection_size_label);
g_signal_connect (selection_filter, "items-changed", G_CALLBACK (update_selection_average), selection_average_picture);
no_selection = G_LIST_MODEL (gtk_no_selection_new (selection_filter));
gtk_grid_view_set_model (GTK_GRID_VIEW (selection_view), no_selection);
selection = GTK_SELECTION_MODEL (gtk_no_selection_new (selection_filter));
gtk_grid_view_set_model (GTK_GRID_VIEW (selection_view), selection);
g_object_unref (selection_filter);
g_object_unref (no_selection);
g_object_unref (selection);
model = gtk_multi_selection_get_model (GTK_MULTI_SELECTION (model));
g_object_ref (model);

View File

@@ -345,7 +345,7 @@ do_listview_settings (GtkWidget *do_widget)
GtkWidget *listview, *columnview;
GListModel *model;
GtkTreeListModel *treemodel;
GtkSingleSelection *selection;
GtkSelectionModel *selection;
GtkBuilderScope *scope;
GtkBuilder *builder;
GtkColumnViewColumn *name_column;
@@ -409,14 +409,14 @@ do_listview_settings (GtkWidget *do_widget)
create_settings_model,
NULL,
NULL);
selection = gtk_single_selection_new (G_LIST_MODEL (treemodel));
selection = GTK_SELECTION_MODEL (gtk_single_selection_new (G_LIST_MODEL (treemodel)));
g_object_bind_property_full (selection, "selected-item",
columnview, "model",
G_BINDING_SYNC_CREATE,
transform_settings_to_keys,
NULL,
columnview, NULL);
gtk_list_view_set_model (GTK_LIST_VIEW (listview), G_LIST_MODEL (selection));
gtk_list_view_set_model (GTK_LIST_VIEW (listview), selection);
g_object_unref (selection);
g_object_unref (treemodel);
g_object_unref (model);

View File

@@ -281,7 +281,8 @@ GtkWidget *
create_weather_view (void)
{
GtkWidget *listview;
GListModel *model, *selection;
GListModel *model;
GtkSelectionModel *selection;
GtkListItemFactory *factory;
factory = gtk_signal_list_item_factory_new ();
@@ -291,7 +292,7 @@ create_weather_view (void)
gtk_orientable_set_orientation (GTK_ORIENTABLE (listview), GTK_ORIENTATION_HORIZONTAL);
gtk_list_view_set_show_separators (GTK_LIST_VIEW (listview), TRUE);
model = create_weather_model ();
selection = G_LIST_MODEL (gtk_no_selection_new (model));
selection = GTK_SELECTION_MODEL (gtk_no_selection_new (model));
gtk_list_view_set_model (GTK_LIST_VIEW (listview), selection);
g_object_unref (selection);
g_object_unref (model);

View File

@@ -157,7 +157,7 @@ do_listview_words (GtkWidget *do_widget)
{
GtkWidget *header, *listview, *sw, *vbox, *search_entry, *open_button, *overlay;
GtkFilterListModel *filter_model;
GtkNoSelection *selection;
GtkSelectionModel *selection;
GtkStringList *stringlist;
GtkFilter *filter;
GFile *file;
@@ -218,8 +218,8 @@ do_listview_words (GtkWidget *do_widget)
gtk_builder_list_item_factory_new_from_bytes (NULL,
g_bytes_new_static (factory_text, strlen (factory_text))));
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listview);
selection = gtk_no_selection_new (G_LIST_MODEL (filter_model));
gtk_list_view_set_model (GTK_LIST_VIEW (listview), G_LIST_MODEL (selection));
selection = GTK_SELECTION_MODEL (gtk_no_selection_new (G_LIST_MODEL (filter_model)));
gtk_list_view_set_model (GTK_LIST_VIEW (listview), selection);
g_object_unref (selection);
g_signal_connect (filter_model, "items-changed", G_CALLBACK (update_title_cb), progress);

View File

@@ -16,7 +16,7 @@ static GtkWidget *source_view;
static gchar *current_file = NULL;
static GtkWidget *notebook;
static GtkSingleSelection *selection;
static GtkSelectionModel *selection;
static GtkWidget *toplevel;
static char **search_needle;
@@ -220,7 +220,7 @@ activate_run (GSimpleAction *action,
GVariant *parameter,
gpointer window)
{
GtkTreeListRow *row = gtk_single_selection_get_selected_item (selection);
GtkTreeListRow *row = gtk_single_selection_get_selected_item (GTK_SINGLE_SELECTION (selection));
GtkDemo *demo = gtk_tree_list_row_get_item (row);
gtk_demo_run (demo, window);
@@ -932,7 +932,7 @@ activate_cb (GtkWidget *widget,
guint position,
gpointer window)
{
GtkTreeListRow *row = g_list_model_get_item (gtk_list_view_get_model (GTK_LIST_VIEW (widget)), position);
GtkTreeListRow *row = g_list_model_get_item (G_LIST_MODEL (gtk_list_view_get_model (GTK_LIST_VIEW (widget))), position);
GtkDemo *demo = gtk_tree_list_row_get_item (row);
gtk_demo_run (demo, window);
@@ -1152,11 +1152,11 @@ activate (GApplication *app)
search_entry = GTK_WIDGET (gtk_builder_get_object (builder, "search-entry"));
g_signal_connect (search_entry, "search-changed", G_CALLBACK (demo_search_changed_cb), filter);
selection = gtk_single_selection_new (G_LIST_MODEL (filter_model));
selection = GTK_SELECTION_MODEL (gtk_single_selection_new (G_LIST_MODEL (filter_model)));
g_signal_connect (selection, "notify::selected-item", G_CALLBACK (selection_cb), NULL);
gtk_list_view_set_model (GTK_LIST_VIEW (listview), G_LIST_MODEL (selection));
gtk_list_view_set_model (GTK_LIST_VIEW (listview), selection);
selection_cb (selection, NULL, NULL);
selection_cb (GTK_SINGLE_SELECTION (selection), NULL, NULL);
g_object_unref (builder);
}

View File

@@ -33,6 +33,9 @@
<object class="GtkLabel" id="label_plain">
<property name="label">Plain</property>
<property name="xalign">0</property>
<accessibility>
<relation type="label-for" target="scale_plain"/>
</accessibility>
<layout>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
@@ -45,6 +48,9 @@
<property name="draw-value">0</property>
<property name="adjustment">adjustment1</property>
<property name="hexpand">1</property>
<accessibility>
<relation type="labelled-by" target="label_plain"/>
</accessibility>
<layout>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
@@ -55,6 +61,9 @@
<object class="GtkLabel" id="label_marks">
<property name="label">Marks</property>
<property name="xalign">0</property>
<accessibility>
<relation type="label-for" target="scale_marks"/>
</accessibility>
<layout>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
@@ -74,6 +83,9 @@
<mark value="3" position="bottom"></mark>
<mark value="4" position="bottom"></mark>
</marks>
<accessibility>
<relation type="labelled-by" target="label_marks"/>
</accessibility>
<layout>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
@@ -84,6 +96,9 @@
<object class="GtkLabel" id="label_discrete">
<property name="label">Discrete</property>
<property name="xalign">0</property>
<accessibility>
<relation type="label-for" target="scale_discrete"/>
</accessibility>
<layout>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
@@ -97,6 +112,9 @@
<property name="draw-value">0</property>
<property name="adjustment">adjustment3</property>
<property name="hexpand">1</property>
<accessibility>
<relation type="labelled-by" target="label_discrete"/>
</accessibility>
<marks>
<mark value="0" position="bottom"></mark>
<mark value="1" position="bottom"></mark>

View File

@@ -245,6 +245,9 @@
<object class="GtkImage" id="image1">
<property name="halign">center</property>
<property name="valign">end</property>
<accessibility>
<relation type="labelled-by" target="label1"/>
</accessibility>
<layout>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
@@ -255,6 +258,9 @@
<object class="GtkImage" id="image2">
<property name="halign">center</property>
<property name="valign">end</property>
<accessibility>
<relation type="labelled-by" target="label2"/>
</accessibility>
<layout>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
@@ -265,6 +271,9 @@
<object class="GtkImage" id="image3">
<property name="halign">center</property>
<property name="valign">end</property>
<accessibility>
<relation type="labelled-by" target="label3"/>
</accessibility>
<layout>
<property name="left-attach">2</property>
<property name="top-attach">1</property>
@@ -275,6 +284,9 @@
<object class="GtkImage" id="image4">
<property name="halign">center</property>
<property name="valign">end</property>
<accessibility>
<relation type="labelled-by" target="label4"/>
</accessibility>
<layout>
<property name="left-attach">3</property>
<property name="top-attach">1</property>
@@ -285,6 +297,9 @@
<object class="GtkImage" id="image5">
<property name="halign">center</property>
<property name="valign">end</property>
<accessibility>
<relation type="labelled-by" target="label5"/>
</accessibility>
<layout>
<property name="left-attach">4</property>
<property name="top-attach">1</property>
@@ -295,6 +310,9 @@
<object class="GtkImage" id="image6">
<property name="halign">center</property>
<property name="valign">end</property>
<accessibility>
<relation type="labelled-by" target="label5"/>
</accessibility>
<layout>
<property name="left-attach">5</property>
<property name="top-attach">1</property>
@@ -305,6 +323,9 @@
<object class="GtkImage" id="image7">
<property name="halign">center</property>
<property name="valign">end</property>
<accessibility>
<relation type="labelled-by" target="label5"/>
</accessibility>
<layout>
<property name="left-attach">6</property>
<property name="top-attach">1</property>
@@ -315,6 +336,9 @@
<object class="GtkImage" id="image8">
<property name="halign">center</property>
<property name="valign">end</property>
<accessibility>
<relation type="labelled-by" target="label6"/>
</accessibility>
<layout>
<property name="left-attach">7</property>
<property name="top-attach">1</property>
@@ -329,6 +353,9 @@
<style>
<class name="dim-label"/>
</style>
<accessibility>
<relation type="label-for" target="image1"/>
</accessibility>
<layout>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
@@ -343,6 +370,9 @@
<style>
<class name="dim-label"/>
</style>
<accessibility>
<relation type="label-for" target="image2"/>
</accessibility>
<layout>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
@@ -357,6 +387,9 @@
<style>
<class name="dim-label"/>
</style>
<accessibility>
<relation type="label-for" target="image3"/>
</accessibility>
<layout>
<property name="left-attach">2</property>
<property name="top-attach">2</property>
@@ -371,6 +404,9 @@
<style>
<class name="dim-label"/>
</style>
<accessibility>
<relation type="label-for" target="image4"/>
</accessibility>
<layout>
<property name="left-attach">3</property>
<property name="top-attach">2</property>
@@ -385,6 +421,9 @@
<style>
<class name="dim-label"/>
</style>
<accessibility>
<relation type="label-for" target="image5"/>
</accessibility>
<layout>
<property name="left-attach">4</property>
<property name="top-attach">2</property>
@@ -399,6 +438,9 @@
<style>
<class name="dim-label"/>
</style>
<accessibility>
<relation type="label-for" target="image6"/>
</accessibility>
<layout>
<property name="left-attach">5</property>
<property name="top-attach">2</property>
@@ -413,6 +455,9 @@
<style>
<class name="dim-label"/>
</style>
<accessibility>
<relation type="label-for" target="image7"/>
</accessibility>
<layout>
<property name="left-attach">6</property>
<property name="top-attach">2</property>
@@ -427,6 +472,9 @@
<style>
<class name="dim-label"/>
</style>
<accessibility>
<relation type="label-for" target="image8"/>
</accessibility>
<layout>
<property name="left-attach">7</property>
<property name="top-attach">2</property>

View File

@@ -565,6 +565,7 @@ on_scale_button_value_changed (GtkScaleButton *button,
}
gtk_widget_set_tooltip_text (GTK_WIDGET (button), str);
atk_object_set_description (gtk_widget_get_accessible (GTK_WIDGET (button)), str);
g_free (str);
}

View File

@@ -3029,6 +3029,9 @@ bad things might happen.</property>
<property name="margin-top">20</property>
<property name="margin-bottom">20</property>
<property name="label" translatable="yes">To free the princess, you have to slay the dragon.</property>
<accessibility>
<role type="static"/>
</accessibility>
</object>
</child>
</object>
@@ -3228,6 +3231,9 @@ bad things might happen.</property>
<object class="GtkLabel" id="title_label">
<property name="label">Title:</property>
<property name="xalign">1</property>
<accessibility>
<relation type="label-for" target="open_popover_entry"/>
</accessibility>
</object>
</child>
<child>
@@ -3235,6 +3241,9 @@ bad things might happen.</property>
<property name="valign">start</property>
<property name="label">Description:</property>
<property name="xalign">1</property>
<accessibility>
<relation type="label-for" target="open_popover_textview"/>
</accessibility>
<layout>
<property name="top-attach">1</property>
</layout>
@@ -3250,6 +3259,9 @@ bad things might happen.</property>
<property name="max-content-width">100</property>
<child>
<object class="GtkTextView" id="open_popover_textview">
<accessibility>
<relation type="labelled-by" target="description_label"/>
</accessibility>
</object>
</child>
<layout>
@@ -3262,6 +3274,9 @@ bad things might happen.</property>
<child>
<object class="GtkEntry" id="open_popover_entry">
<property name="activates-default">1</property>
<accessibility>
<relation type="labelled-by" target="title_label"/>
</accessibility>
<layout>
<property name="left-attach">1</property>
<property name="column-span">2</property>
@@ -3342,6 +3357,9 @@ bad things might happen.</property>
<child>
<object class="GtkLabel">
<property name="label">No updates at this time</property>
<accessibility>
<role type="static"/>
</accessibility>
</object>
</child>
</object>
@@ -3350,6 +3368,9 @@ bad things might happen.</property>
<child>
<object class="GtkLabel">
<property name="label">You&apos;re in too deep!</property>
<accessibility>
<role type="static"/>
</accessibility>
</object>
</child>
</object>

View File

@@ -127,7 +127,7 @@ compilation flags needed for that library along with version number
information.)
Some of the libraries that GTK depends on are maintained by the
GTK team: GLib, GdkPixbuf, Pango, and GObject Introspection.
GTK team: GLib, GdkPixbuf, Pango, ATK and GObject Introspection.
Other libraries are maintained separately.
- The GLib library provides core non-graphical functionality
@@ -139,6 +139,10 @@ Other libraries are maintained separately.
file formats. It is available [here](ttps://download.gnome.org/sources/gdk-pixbuf/).
- [Pango](http://www.pango.org) is a library for internationalized
text handling. It is available [here](https://download.gnome.org/sources/pango/).
- ATK is the Accessibility Toolkit. It provides a set of generic
interfaces allowing accessibility technologies such as
screen readers to interact with a graphical user interface.
It is available [here](https://download.gnome.org/sources/atk/).
- [GObject Introspection](https://wiki.gnome.org/Projects/GObjectIntrospection)
is a framework for making introspection data available to language
bindings. It is available [here](https://download.gnome.org/sources/gobject-introspection/).
@@ -188,7 +192,7 @@ you'll have all of these installed already, or they will be easily
accessible through your operating system package repositories.
Then build and install the GTK libraries in the order:
GLib, Cairo, Pango, then GTK. For each library, follow the
GLib, Cairo, Pango, ATK, then GTK. For each library, follow the
instructions they provide, and make sure to share common settings
between them and the GTK build; if you are using a separate prefix
for GTK, for instance, you will need to use the same prefix for

View File

@@ -9,9 +9,9 @@ is used (the actual output on your system may be different):
```
$ pkg-config --cflags gtk4
-pthread -I/usr/include/gtk-4.0 -I/usr/lib64/gtk-4.0/include -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12
-pthread -I/usr/include/gtk-4.0 -I/usr/lib64/gtk-4.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12
$ pkg-config --libs gtk4
-pthread -lgtk-4 -lgdk-4 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0
-pthread -lgtk-4 -lgdk-4 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0
```
The simplest way to compile a program is to use the "backticks"
feature of the shell. If you enclose a command in backticks

View File

@@ -65,9 +65,9 @@
<section>
<xi:include href="xml/gtksorter.xml" />
<xi:include href="xml/gtkcustomsorter.xml" />
<xi:include href="xml/gtkmultisorter.xml" />
<xi:include href="xml/gtkstringsorter.xml" />
<xi:include href="xml/gtknumericsorter.xml" />
<xi:include href="xml/gtkmultisorter.xml" />
</section>
<xi:include href="xml/gtkselectionmodel.xml" />
<section>
@@ -93,9 +93,7 @@
<xi:include href="xml/gtklistview.xml" />
<xi:include href="xml/gtkgridview.xml" />
<xi:include href="xml/gtkcolumnview.xml" />
<section>
<xi:include href="xml/gtkcolumnviewcolumn.xml" />
</section>
<xi:include href="xml/gtkcolumnviewcolumn.xml" />
<xi:include href="xml/gtkdropdown.xml" />
</chapter>
@@ -337,13 +335,6 @@
<xi:include href="xml/gtkshortcutlabel.xml" />
</chapter>
<chapter id="Accessibility">
<title>Accessibility</title>
<xi:include href="section-accessibility.xml"/>
<xi:include href="xml/gtkaccessible.xml" />
<xi:include href="xml/gtkatcontext.xml" />
</chapter>
<chapter id="MiscObjects">
<title>Miscellaneous</title>
<xi:include href="xml/gtkadjustment.xml" />

View File

@@ -3420,7 +3420,6 @@ gtk_tree_list_row_get_type
<SECTION>
<FILE>gtktreeexpander</FILE>
<TITLE>GtkTreeExpander</TITLE>
GtkTreeExpander
gtk_tree_expander_new
gtk_tree_expander_get_child
gtk_tree_expander_set_child
@@ -7552,17 +7551,6 @@ gtk_object_expression_get_object
gtk_closure_expression_new
gtk_cclosure_expression_new
<SUBSECTION>
GTK_VALUE_HOLDS_EXPRESSION
gtk_value_set_expression
gtk_value_take_expression
gtk_value_get_expression
gtk_value_dup_expression
<SUBSECTION>
GtkParamSpecExpression
gtk_param_spec_expression
<SUBSECTION Standard>
GTK_IS_EXPRESSION
GTK_TYPE_EXPRESSION
@@ -7638,41 +7626,3 @@ gtk_selection_filter_model_new_for_type
gtk_selection_filter_model_set_model
gtk_selection_filter_model_get_model
</SECTION>
<SECTION>
<FILE>gtkaccessible</FILE>
GtkAccessible
GtkAccessibleRole
GtkAccessibleState
GtkAccessibleProperty
gtk_accessible_update_state
<SUBSECTION Standard>
GTK_TYPE_ACCESSIBLE
GTK_TYPE_ACCESSIBLE_PROPERTY
GTK_TYPE_ACCESSIBLE_ROLE
GTK_TYPE_ACCESSIBLE_STATE
GTK_ACCESSIBLE
GTK_ACCESSIBLE_GET_IFACE
GTK_IS_ACCESSIBLE
<SUBSECTION Private>
gtk_accessible_get_type
</SECTION>
<SECTION>
<FILE>gtkatcontext</FILE>
GtkATContext
gtk_at_context_get_accessible
gtk_at_context_get_accessible_role
<SUBSECTION>
gtk_at_context_create
<SUBSECTION Standard>
GTK_TYPE_AT_CONTEXT
GTK_AT_CONTEXT
GTK_AT_CONTEXT_CLASS
GTK_AT_CONTEXT_GET_CLASS
GTK_IS_AT_CONTEXT
GTK_IS_AT_CONTEXT_CLASS
<SUBSECTION Private>
GtkATContextClass
gtk_at_context_get_type
</SECTION>

View File

@@ -17,10 +17,8 @@ gtk_application_window_get_type
gtk_aspect_frame_get_type
gtk_assistant_get_type
gtk_assistant_page_get_type
gtk_at_context_get_type
gtk_bin_layout_get_type
gtk_bitset_get_type
gtk_expression_get_type
gtk_bookmark_list_get_type
gtk_box_get_type
gtk_box_layout_get_type
@@ -31,7 +29,6 @@ gtk_builder_list_item_factory_get_type
gtk_builder_scope_get_type
gtk_button_get_type
gtk_calendar_get_type
gtk_cclosure_expression_get_type
gtk_cell_area_get_type
gtk_cell_area_box_get_type
gtk_cell_area_context_get_type
@@ -49,7 +46,6 @@ gtk_cell_renderer_toggle_get_type
gtk_cell_view_get_type
gtk_center_layout_get_type
gtk_check_button_get_type
gtk_closure_expression_get_type
gtk_color_button_get_type
gtk_color_chooser_get_type
gtk_color_chooser_dialog_get_type
@@ -58,7 +54,6 @@ gtk_column_view_get_type
gtk_column_view_column_get_type
gtk_combo_box_get_type
gtk_combo_box_text_get_type
gtk_constant_expression_get_type
gtk_constraint_get_type
gtk_constraint_guide_get_type
gtk_constraint_layout_get_type
@@ -155,7 +150,6 @@ gtk_no_selection_get_type
gtk_notebook_get_type
gtk_notebook_page_get_type
gtk_numeric_sorter_get_type
gtk_object_expression_get_type
gtk_orientable_get_type
gtk_overlay_get_type
gtk_overlay_layout_get_type
@@ -178,7 +172,6 @@ gtk_print_operation_preview_get_type
gtk_print_settings_get_type
@DISABLE_ON_W32@gtk_print_unix_dialog_get_type
gtk_progress_bar_get_type
gtk_property_expression_get_type
gtk_radio_button_get_type
gtk_range_get_type
gtk_recent_manager_get_type
@@ -236,7 +229,6 @@ gtk_text_view_get_type
gtk_toggle_button_get_type
gtk_tree_drag_dest_get_type
gtk_tree_drag_source_get_type
gtk_tree_expander_get_type
gtk_tree_list_model_get_type
gtk_tree_list_row_get_type
gtk_tree_list_row_sorter_get_type

View File

@@ -393,7 +393,6 @@ expand_content_md_files = [
'drawing-model.md',
'css-overview.md',
'css-properties.md',
'section-accessibility.md',
'section-text-widget.md',
'section-tree-widget.md',
'section-list-widget.md',

View File

@@ -170,7 +170,7 @@ in GTK 3, you can prepare for the switch by using gtk_widget_destroy()
only on toplevel windows, and replace all other uses with
gtk_container_remove() or g_object_unref().
### Reduce the use of generic container APIs
### Reduce the use of generic container APIs</title>
GTK 4 removes gtk_container_add() and gtk_container_remove(). While there
is not always a replacement for gtk_container_remove() in GTK 3, you can

View File

@@ -61,6 +61,18 @@ other widgets that display text.
</para></listitem>
</varlistentry>
<varlistentry>
<term>ATK</term>
<listitem><para>
ATK is the Accessibility Toolkit. It provides a set of generic
interfaces allowing accessibility technologies to interact with a
graphical user interface. For example, a screen reader uses ATK to
discover the text in an interface and read it to blind users. GTK
widgets have built-in support for accessibility using the ATK
framework.
</para></listitem>
</varlistentry>
<varlistentry>
<term>GdkPixbuf</term>
<listitem><para>

View File

@@ -1,121 +0,0 @@
# GTK Accessibility {#gtk-accessibility}
## The standard accessibility interface
The #GtkAccessible interface provides the accessibility information about
an application's user interface elements. Assistive technology (AT)
applications, like Orca, convey this information to users with disabilities,
or reduced abilities, to help them use the application.
Standard GTK controls implement the #GtkAccessible interface and are thus
accessible to ATs by default. This means that if you use GTK controls such
as #GtkButton, #GtkEntry, or #GtkListView, you only need to supply
application-specific details when the defaults values are incomplete. You
can do this by setting the appropriate properties in your #GtkBuilder
template and UI definition files, or by setting the properties defined by
the #GtkAccessible interface.
If you are implementing your own #GtkWidget derived type, you will need to
set the #GtkAccessible properties yourself, and provide an implementation
of the #GtkAccessible virtual functions.
## Accessible roles and states
The fundamental concepts of an accessible widget are *roles* and *states*;
each GTK control fills out a role and its functionality is described by a
set of *states*.
### Roles
Roles define the taxonomy and semantics of a UI control to any assistive
technology application; for instance, a button will have a role of
%GTK\_ACCESSIBLE\_ROLE\_BUTTON`; an entry will have a role of
%GTK\_ACCESSIBLE\_ROLE\_TEXTBOX`; a toggle button will have a role of
%GTK\_ACCESSIBLE\_ROLE\_CHECKBOX`; etc.
Each role is part of the widget's instance, and **CANNOT** be changed over
time or as the result of a user action. Roles allows assistive technology
applications to identify a UI control and decide how to present it to a
user; if a part of the application's UI changes role, the control needs to
be removed and replaced with another one with the appropriate role.
#### List of accessible roles
Each role name is part of the `GtkAccessibleRole` enumeration.
| Role name | Description |
|-----------|-------------|
| `ALERT` | A message with important information |
| `BUTTON` | A control that performs an action when pressed |
| `CHECKBOX` | A control that has three possible value: `true`, `false`, or `undefined` |
| `COLUMNHEADER` | The header of a column in a list or grid |
| `COMBOBOX` | A control that can be expanded to show a list of possible values to select |
| `...` | … |
See the [WAI-ARIA](https://www.w3.org/WAI/PF/aria/appendices#quickref) list
of roles for additional information.
### States
States, or properties, provide specific information about an accessible UI
control, and describe it for the assistive technology applications.
Unlike roles, states may change over time, or in response to user action;
for instance, a toggle button will change its %GTK\_ACCESSIBLE\_STATE\_CHECKED
state every time it is toggled, either by the user or programmatically.
#### List of accessible states
Each state name is part of the #GtkAccessibleState enumeration.
| State name | Description |
|------------|-------------|
| `...` | … |
See the [WAI-ARIA](https://www.w3.org/WAI/PF/aria/appendices#quickref) list of states for additional information.
## Application development rules
Even if standard UI controls provided by GTK have accessibility information
out of the box, there are some additional properties and considerations for
application developers. For instance, if your application presents the user
with a form to fill out, you should ensure that:
* the container of the form has a `Gtk.AccessibleRole.FORM` role
* each text entry widget in the form has the `GtkAccessible:labelled-by`
property pointing to the label widget that describes it
Another example: if you create a tool bar containing buttons with only icons, you should ensure that:
* the container has a `Gtk.AccessibleRole.TOOLBAR` role
* each button has a `GtkAccessible:label` property set with the user
readable and localised action performed when pressed; for instance "Copy",
"Paste", "Add layer", or "Remove"
GTK will try to fill in some information by using ancillary UI control
property, for instance the accessible label will be taken from the label or
placeholder text used by the UI control, or from its tooltip, if the
`GtkAccessible:label` or the `GtkAccessible:labelled-by` properties are
unset. Nevertheless, it is good practice and project hygiene to explicitly
specify the accessible properties, just like it's good practice to specify
tooltips and style classes.
Application developers using GTK **SHOULD** ensure that their UI controls
are accessible as part of the development process. When using `GtkBuilder`
templates and UI definition files, GTK provides a validation tool that
verifies that each UI element has a valid role and properties; this tool can
be used as part of the application's test suite to avoid regressions.
## Implementations
Each UI control implements the `GtkAccessible` interface to allow widget and
application developers to specify the roles, state, and relations between UI
controls. This API is purely descriptive.
Each `GtkAccessible` implementation must provide a `GtkATContext` instance,
which acts as a proxy to the specific platform's accessibility API:
* AT-SPI on Linux/BSD
* NSAccessibility on macOS
* Active Accessibility on Windows
Additionally, an ad hoc accessibility backend is available for the GTK
testsuite, to ensure reproducibility of issues in the CI pipeline.

View File

@@ -183,7 +183,7 @@ transitioning code for easy lookup:
| #GtkTreeModel | #GListModel |
| #GtkTreePath | #guint position, #GtkTreeListRow |
| #GtkTreeIter | #guint position |
| #GtkTreeRowReference | #GObject item |
| GtkTreeRowReference | #GObject item |
| #GtkListStore | #GListStore |
| #GtkTreeStore | #GtkTreeListModel, #GtkTreeExpander |
| #GtkTreeSelection | #GtkSelectionModel |

View File

@@ -354,7 +354,7 @@ gdk_rgba_equal (gconstpointer p1,
*
* Returns a textual specification of @rgba in the form
* `rgb(r,g,b)` or
* `rgba(r,g,b,a)`,
* `rgba(r g,b,a)`,
* where “r”, “g”, “b” and “a” represent the red, green,
* blue and alpha values respectively. “r”, “g”, and “b” are
* represented as integers in the range 0 to 255, and “a”

View File

@@ -70,6 +70,7 @@ typedef enum
RESET_CLIP = 1 << 1,
RESET_OPACITY = 1 << 2,
DUMP_FRAMEBUFFER = 1 << 3,
CENTER_CHILD = 1 << 4,
NO_CACHE_PLZ = 1 << 5,
} OffscreenFlags;
@@ -905,7 +906,6 @@ upload_texture (GskGLRenderer *self,
}
else
{
out_region->texture_id =
gsk_gl_driver_get_texture_for_texture (self->gl_driver,
texture,
@@ -1152,59 +1152,6 @@ rounded_inner_rect_contains_rect (const GskRoundedRect *rounded,
return graphene_rect_contains_rect (&inner, rect);
}
/* Current clip is NOT rounded but new one is definitely! */
static inline bool
intersect_rounded_rectilinear (const graphene_rect_t *non_rounded,
const GskRoundedRect *rounded,
GskRoundedRect *result)
{
int n_corners = 0;
bool corners[4];
/* Intersects with top left corner? */
n_corners += corners[0] = rounded_rect_has_corner (rounded, 0) &&
graphene_rect_intersection (non_rounded,
&rounded_rect_corner (rounded, 0), NULL);
/* top right? */
n_corners += corners[1] = rounded_rect_has_corner (rounded, 1) &&
graphene_rect_intersection (non_rounded,
&rounded_rect_corner (rounded, 1), NULL);
/* bottom right? */
n_corners += corners[2] = rounded_rect_has_corner (rounded, 2) &&
graphene_rect_intersection (non_rounded,
&rounded_rect_corner (rounded, 2), NULL);
/* bottom left */
n_corners += corners[3] = rounded_rect_has_corner (rounded, 3) &&
graphene_rect_intersection (non_rounded,
&rounded_rect_corner (rounded, 3), NULL);
if (corners[0] && !graphene_rect_contains_rect (non_rounded, &rounded_rect_corner (rounded, 0)))
return false;
if (corners[1] && !graphene_rect_contains_rect (non_rounded, &rounded_rect_corner (rounded, 1)))
return false;
if (corners[2] && !graphene_rect_contains_rect (non_rounded, &rounded_rect_corner (rounded, 2)))
return false;
if (corners[3] && !graphene_rect_contains_rect (non_rounded, &rounded_rect_corner (rounded, 3)))
return false;
/* We do intersect with at least one of the corners, but in such a way that the
* intersection between the two clips can still be represented by a single rounded
* rect in a trivial way. do that. */
graphene_rect_intersection (non_rounded, &rounded->bounds, &result->bounds);
for (int i = 0; i < 4; i++)
{
if (corners[i])
result->corner[i] = rounded->corner[i];
else
result->corner[i].width = result->corner[i].height = 0;
}
return true;
}
/* This code intersects the current (maybe rounded) clip with the new
* non-rounded clip */
static inline void
render_clipped_child (GskGLRenderer *self,
RenderOpBuilder *builder,
@@ -1212,57 +1159,112 @@ render_clipped_child (GskGLRenderer *self,
GskRenderNode *child)
{
graphene_rect_t transformed_clip;
GskRoundedRect intersection;
GskRoundedRect child_clip;
ops_transform_bounds_modelview (builder, clip, &transformed_clip);
if (builder->clip_is_rectilinear)
{
memset (&intersection, 0, sizeof (GskRoundedRect));
graphene_rect_intersection (&transformed_clip,
&builder->current_clip->bounds,
&intersection.bounds);
goto trivial;
ops_push_clip (builder, &intersection);
{
const GskRoundedRect *cur_clip = builder->current_clip;
int n_corners = 0;
bool corners[4];
/* Intersects with top left corner? */
n_corners += corners[0] = rounded_rect_has_corner (cur_clip, 0) &&
graphene_rect_intersection (&transformed_clip,
&rounded_rect_corner (cur_clip, 0), NULL);
/* top right? */
n_corners += corners[1] = rounded_rect_has_corner (cur_clip, 1) &&
graphene_rect_intersection (&transformed_clip,
&rounded_rect_corner (cur_clip, 1), NULL);
/* bottom right? */
n_corners += corners[2] = rounded_rect_has_corner (cur_clip, 2) &&
graphene_rect_intersection (&transformed_clip,
&rounded_rect_corner (cur_clip, 2), NULL);
/* bottom left */
n_corners += corners[3] = rounded_rect_has_corner (cur_clip, 3) &&
graphene_rect_intersection (&transformed_clip,
&rounded_rect_corner (cur_clip, 3), NULL);
if (n_corners == 0)
goto trivial;
if (corners[0] && !graphene_rect_contains_rect (&transformed_clip, &rounded_rect_corner (cur_clip, 0)))
goto rtt;
if (corners[1] && !graphene_rect_contains_rect (&transformed_clip, &rounded_rect_corner (cur_clip, 1)))
goto rtt;
if (corners[2] && !graphene_rect_contains_rect (&transformed_clip, &rounded_rect_corner (cur_clip, 2)))
goto rtt;
if (corners[3] && !graphene_rect_contains_rect (&transformed_clip, &rounded_rect_corner (cur_clip, 3)))
goto rtt;
/* We do intersect with at least one of the corners, but in such a way that the
* intersection between the two clips can still be represented by a single rounded
* rect in a trivial way. do that. */
{
GskRoundedRect real_intersection;
graphene_rect_intersection (&transformed_clip, &cur_clip->bounds, &real_intersection.bounds);
for (int i = 0; i < 4; i++)
{
if (corners[i])
real_intersection.corner[i] = cur_clip->corner[i];
else
real_intersection.corner[i].width = real_intersection.corner[i].height = 0;
}
/* Draw with that new clip */
ops_push_clip (builder, &real_intersection);
gsk_gl_renderer_add_render_ops (self, child, builder);
ops_pop_clip (builder);
}
else if (intersect_rounded_rectilinear (&transformed_clip,
builder->current_clip,
&intersection))
{
ops_push_clip (builder, &intersection);
gsk_gl_renderer_add_render_ops (self, child, builder);
ops_pop_clip (builder);
}
else
{
/* well fuck */
const float scale = ops_get_scale (builder);
gboolean is_offscreen;
TextureRegion region;
GskRoundedRect scaled_clip;
return;
}
memset (&scaled_clip, 0, sizeof (GskRoundedRect));
rtt:
{
/* well fuck */
const float scale = ops_get_scale (builder);
gboolean is_offscreen;
TextureRegion region;
GskRoundedRect scaled_clip;
scaled_clip.bounds.origin.x = clip->origin.x * scale;
scaled_clip.bounds.origin.y = clip->origin.y * scale;
scaled_clip.bounds.size.width = clip->size.width * scale;
scaled_clip.bounds.size.height = clip->size.height * scale;
memset (&scaled_clip, 0, sizeof (GskRoundedRect));
ops_push_clip (builder, &scaled_clip);
if (!add_offscreen_ops (self, builder, &child->bounds,
child,
&region, &is_offscreen,
RESET_OPACITY | FORCE_OFFSCREEN))
g_assert_not_reached ();
ops_pop_clip (builder);
scaled_clip.bounds.origin.x = clip->origin.x * scale;
scaled_clip.bounds.origin.y = clip->origin.y * scale;
scaled_clip.bounds.size.width = clip->size.width * scale;
scaled_clip.bounds.size.height = clip->size.height * scale;
ops_set_program (builder, &self->programs->blit_program);
ops_set_texture (builder, region.texture_id);
ops_push_clip (builder, &scaled_clip);
if (!add_offscreen_ops (self, builder, &child->bounds,
child,
&region, &is_offscreen,
RESET_OPACITY | FORCE_OFFSCREEN))
g_assert_not_reached ();
ops_pop_clip (builder);
load_offscreen_vertex_data (ops_draw (builder, NULL), child, builder);
}
ops_set_program (builder, &self->programs->blit_program);
ops_set_texture (builder, region.texture_id);
load_offscreen_vertex_data (ops_draw (builder, NULL), child, builder);
return;
}
trivial:
memset (&child_clip, 0, sizeof (GskRoundedRect));
graphene_rect_intersection (&transformed_clip,
&builder->current_clip->bounds,
&child_clip.bounds);
ops_push_clip (builder, &child_clip);
gsk_gl_renderer_add_render_ops (self, child, builder);
ops_pop_clip (builder);
return;
}
static inline void
@@ -1292,29 +1294,6 @@ render_rounded_clip_node (GskGLRenderer *self,
return;
ops_transform_bounds_modelview (builder, &clip->bounds, &transformed_clip.bounds);
for (i = 0; i < 4; i ++)
{
transformed_clip.corner[i].width = clip->corner[i].width * scale;
transformed_clip.corner[i].height = clip->corner[i].height * scale;
}
if (builder->clip_is_rectilinear)
{
GskRoundedRect intersected_clip;
if (intersect_rounded_rectilinear (&builder->current_clip->bounds,
&transformed_clip,
&intersected_clip))
{
ops_push_clip (builder, &intersected_clip);
gsk_gl_renderer_add_render_ops (self, child, builder);
ops_pop_clip (builder);
return;
}
}
/* After this point we are really working with a new and a current clip
* which both have rounded corners. */
if (!ops_has_clip (builder))
need_offscreen = FALSE;
@@ -1328,16 +1307,12 @@ render_rounded_clip_node (GskGLRenderer *self,
{
/* If they don't intersect at all, we can simply set
* the new clip and add the render ops */
/* If the new clip entirely contains the current clip, the intersection is simply
* the current clip, so we can ignore the new one */
if (rounded_inner_rect_contains_rect (&transformed_clip, &builder->current_clip->bounds))
for (i = 0; i < 4; i ++)
{
gsk_gl_renderer_add_render_ops (self, child, builder);
return;
transformed_clip.corner[i].width = clip->corner[i].width * scale;
transformed_clip.corner[i].height = clip->corner[i].height * scale;
}
/* TODO: Intersect current and new clip */
ops_push_clip (builder, &transformed_clip);
gsk_gl_renderer_add_render_ops (self, child, builder);
ops_pop_clip (builder);
@@ -1379,6 +1354,7 @@ render_rounded_clip_node (GskGLRenderer *self,
load_offscreen_vertex_data (ops_draw (builder, NULL), node, builder);
}
/* Else this node is entirely out of the current clip node and we don't draw it anyway. */
}
static inline void
@@ -1786,6 +1762,7 @@ render_unblurred_outset_shadow_node (GskGLRenderer *self,
}
static GdkRGBA COLOR_WHITE = { 1, 1, 1, 1 };
static inline void
render_outset_shadow_node (GskGLRenderer *self,
@@ -1806,32 +1783,19 @@ render_outset_shadow_node (GskGLRenderer *self,
OpShadow *shadow;
int blurred_texture_id;
int cached_tid;
bool do_slicing;
/* scaled_outline is the minimal outline we need to draw the given drop shadow,
* enlarged by the spread and offset by the blur radius. */
scaled_outline = *outline;
if (outline->bounds.size.width < blur_extra ||
outline->bounds.size.height < blur_extra)
{
do_slicing = false;
gsk_rounded_rect_shrink (&scaled_outline, -spread, -spread, -spread, -spread);
}
else
{
/* Shrink our outline to the minimum size that can still hold all the border radii */
gsk_rounded_rect_shrink_to_minimum (&scaled_outline);
/* Increase by the spread */
gsk_rounded_rect_shrink (&scaled_outline, -spread, -spread, -spread, -spread);
/* Grow bounds but don't grow corners */
graphene_rect_inset (&scaled_outline.bounds, - blur_extra / 2.0, - blur_extra / 2.0);
/* For the center part, we add a few pixels */
scaled_outline.bounds.size.width += SHADOW_EXTRA_SIZE;
scaled_outline.bounds.size.height += SHADOW_EXTRA_SIZE;
do_slicing = true;
}
/* Shrink our outline to the minimum size that can still hold all the border radii */
gsk_rounded_rect_shrink_to_minimum (&scaled_outline);
/* Increase by the spread */
gsk_rounded_rect_shrink (&scaled_outline, -spread, -spread, -spread, -spread);
/* Grow bounds but don't grow corners */
graphene_rect_inset (&scaled_outline.bounds, - extra_blur_pixels, - extra_blur_pixels);
/* For the center part, we add a few pixels */
scaled_outline.bounds.size.width += SHADOW_EXTRA_SIZE;
scaled_outline.bounds.size.height += SHADOW_EXTRA_SIZE;
texture_width = (int)ceil ((scaled_outline.bounds.size.width + blur_extra) * scale);
texture_height = (int)ceil ((scaled_outline.bounds.size.height + blur_extra) * scale);
@@ -1916,41 +1880,6 @@ render_outset_shadow_node (GskGLRenderer *self,
blurred_texture_id = cached_tid;
}
if (!do_slicing)
{
const float min_x = floorf (builder->dx + outline->bounds.origin.x - spread - (blur_extra / 2.0) + dx);
const float min_y = floorf (builder->dy + outline->bounds.origin.y - spread - (blur_extra / 2.0) + dy);
float x1, x2, y1, y2, tx1, tx2, ty1, ty2;
ops_set_program (builder, &self->programs->outset_shadow_program);
ops_set_color (builder, color);
ops_set_texture (builder, blurred_texture_id);
shadow = ops_begin (builder, OP_CHANGE_OUTSET_SHADOW);
shadow->outline = transform_rect (self, builder, outline);
tx1 = 0; tx2 = 1;
ty1 = 0; ty2 = 1;
x1 = min_x;
x2 = min_x + texture_width / scale;
y1 = min_y;
y2 = min_y + texture_height / scale;
ops_draw (builder, (GskQuadVertex[GL_N_VERTICES]) {
{ { x1, y1 }, { tx1, ty2 }, },
{ { x1, y2 }, { tx1, ty1 }, },
{ { x2, y1 }, { tx2, ty2 }, },
{ { x2, y2 }, { tx2, ty1 }, },
{ { x1, y2 }, { tx1, ty1 }, },
{ { x2, y1 }, { tx2, ty2 }, },
});
return;
}
ops_set_program (builder, &self->programs->outset_shadow_program);
ops_set_color (builder, color);
ops_set_texture (builder, blurred_texture_id);
@@ -3388,8 +3317,19 @@ add_offscreen_ops (GskGLRenderer *self,
bounds->origin.y * scale,
width, height));
builder->dx = 0;
builder->dy = 0;
if (flags & CENTER_CHILD)
{
ops_offset (builder,
(bounds->size.width - child_node->bounds.size.width) / 2.0 -
child_node->bounds.origin.x,
(bounds->size.height - child_node->bounds.size.height) / 2.0 -
child_node->bounds.origin.y);
}
else
{
builder->dx = 0;
builder->dy = 0;
}
if (flags & RESET_OPACITY)
prev_opacity = ops_set_opacity (builder, 1.0);

View File

@@ -0,0 +1,67 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#ifndef __GI_SCANNER__
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkBooleanCellAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkButtonAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkCellAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkCellAccessibleParent, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkComboBoxAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkContainerCellAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkEntryAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkExpanderAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkFlowBoxAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkFlowBoxChildAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkFrameAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkIconViewAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkImageAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkImageCellAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkLabelAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkLevelBarAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkLinkButtonAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkListBoxAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkListBoxRowAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkLockButtonAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkMenuButtonAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkNotebookAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkNotebookPageAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkPanedAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkPopoverAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkProgressBarAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRadioButtonAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRangeAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRendererCellAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkScaleAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkScaleButtonAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkScrolledWindowAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkSpinButtonAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkSpinnerAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkStatusbarAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkSwitchAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkTextCellAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkTextViewAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkToggleButtonAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkToplevelAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkTreeViewAccessible, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkWindowAccessible, g_object_unref)
#endif

View File

@@ -0,0 +1,43 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkaccessibility.h"
#include "gtkaccessibilityutil.h"
#ifdef GDK_WINDOWING_X11
#include <atk-bridge.h>
#endif
static int initialized = FALSE;
void
_gtk_accessibility_init (void)
{
if (initialized)
return;
initialized = TRUE;
_gtk_accessibility_override_atk_util ();
#ifdef GDK_WINDOWING_X11
atk_bridge_adaptor_init (NULL, NULL);
#endif
}

View File

@@ -0,0 +1,30 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_ACCESSIBILITY_H__
#define __GTK_ACCESSIBILITY_H__
#include <glib.h>
#include "gtk/gtkwidget.h"
G_BEGIN_DECLS
void _gtk_accessibility_init (void);
G_END_DECLS
#endif /* __GTK_ACCESSIBILITY_H__ */

View File

@@ -0,0 +1,109 @@
/* GTK+ - accessibility implementations
* Copyright 2011, F123 Consulting & Mais Diferenças
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <gtk/gtk.h>
#include "gtkaccessibility.h"
#include "gtkaccessibilityutil.h"
#include "gtktoplevelaccessible.h"
static GSList *key_listener_list = NULL;
typedef struct {
AtkKeySnoopFunc func;
gpointer data;
guint key;
} KeyEventListener;
static guint
add_key_event_listener (AtkKeySnoopFunc listener_func,
gpointer listener_data)
{
static guint key = 0;
KeyEventListener *listener;
key++;
listener = g_slice_new0 (KeyEventListener);
listener->func = listener_func;
listener->data = listener_data;
listener->key = key;
key_listener_list = g_slist_append (key_listener_list, listener);
return key;
}
static void
remove_key_event_listener (guint listener_key)
{
GSList *l;
for (l = key_listener_list; l; l = l->next)
{
KeyEventListener *listener = l->data;
if (listener->key == listener_key)
{
g_slice_free (KeyEventListener, listener);
key_listener_list = g_slist_delete_link (key_listener_list, l);
break;
}
}
}
static AtkObject *
get_root (void)
{
static AtkObject *root = NULL;
if (!root)
{
root = g_object_new (GTK_TYPE_TOPLEVEL_ACCESSIBLE, NULL);
atk_object_initialize (root, NULL);
}
return root;
}
static const gchar *
get_toolkit_name (void)
{
return "gtk";
}
static const gchar *
get_toolkit_version (void)
{
return GTK_VERSION;
}
void
_gtk_accessibility_override_atk_util (void)
{
AtkUtilClass *atk_class = ATK_UTIL_CLASS (g_type_class_ref (ATK_TYPE_UTIL));
atk_class->add_key_event_listener = add_key_event_listener;
atk_class->remove_key_event_listener = remove_key_event_listener;
atk_class->get_root = get_root;
atk_class->get_toolkit_name = get_toolkit_name;
atk_class->get_toolkit_version = get_toolkit_version;
}

View File

@@ -0,0 +1,29 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_ACCESSIBILITY_UTIL_H__
#define __GTK_ACCESSIBILITY_UTIL_H__
#include <atk/atk.h>
G_BEGIN_DECLS
void _gtk_accessibility_override_atk_util (void);
G_END_DECLS
#endif /* __GTK_ACCESSIBILITY_UTIL_H__ */

View File

@@ -0,0 +1,164 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
#include "gtkbooleancellaccessible.h"
struct _GtkBooleanCellAccessiblePrivate
{
gboolean cell_value;
gboolean cell_sensitive;
};
static AtkActionIface *parent_action_iface;
static gint
gtk_boolean_cell_accessible_get_n_actions (AtkAction *action)
{
return parent_action_iface->get_n_actions (action) + 1;
}
static const gchar *
gtk_boolean_cell_accessible_get_description (AtkAction *action,
gint i)
{
if (i == 0)
return C_("Action description", "Toggles the cell");
return parent_action_iface->get_description (action, i - 1);
}
static const gchar *
gtk_boolean_cell_accessible_action_get_name (AtkAction *action,
gint i)
{
if (i == 0)
return "toggle";
return parent_action_iface->get_description (action, i - 1);
}
static const gchar *
gtk_boolean_cell_accessible_action_get_localized_name (AtkAction *action,
gint i)
{
if (i == 0)
return C_("Action name", "Toggle");
return parent_action_iface->get_description (action, i - 1);
}
static gboolean
gtk_boolean_cell_accessible_do_action (AtkAction *action,
gint i)
{
if (i == 0)
return parent_action_iface->do_action (action, 2);
return parent_action_iface->do_action (action, i - 1);
}
static void
gtk_boolean_cell_accessible_action_interface_init (AtkActionIface *iface)
{
parent_action_iface = g_type_interface_peek_parent (iface);
iface->do_action = gtk_boolean_cell_accessible_do_action;
iface->get_n_actions = gtk_boolean_cell_accessible_get_n_actions;
iface->get_description = gtk_boolean_cell_accessible_get_description;
iface->get_name = gtk_boolean_cell_accessible_action_get_name;
iface->get_localized_name = gtk_boolean_cell_accessible_action_get_localized_name;
}
G_DEFINE_TYPE_WITH_CODE (GtkBooleanCellAccessible, gtk_boolean_cell_accessible, GTK_TYPE_RENDERER_CELL_ACCESSIBLE,
G_ADD_PRIVATE (GtkBooleanCellAccessible)
G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, gtk_boolean_cell_accessible_action_interface_init))
static AtkStateSet *
gtk_boolean_cell_accessible_ref_state_set (AtkObject *accessible)
{
GtkBooleanCellAccessible *cell = GTK_BOOLEAN_CELL_ACCESSIBLE (accessible);
AtkStateSet *state_set;
state_set = ATK_OBJECT_CLASS (gtk_boolean_cell_accessible_parent_class)->ref_state_set (accessible);
if (cell->priv->cell_value)
atk_state_set_add_state (state_set, ATK_STATE_CHECKED);
if (cell->priv->cell_sensitive)
atk_state_set_add_state (state_set, ATK_STATE_SENSITIVE);
else
atk_state_set_remove_state (state_set, ATK_STATE_SENSITIVE);
return state_set;
}
static void
gtk_boolean_cell_accessible_update_cache (GtkCellAccessible *cell,
gboolean emit_signal)
{
GtkBooleanCellAccessible *boolean_cell = GTK_BOOLEAN_CELL_ACCESSIBLE (cell);
gboolean active;
gboolean sensitive;
GtkCellRenderer *renderer;
g_object_get (cell, "renderer", &renderer, NULL);
g_object_get (renderer,
"active", &active,
"sensitive", &sensitive,
NULL);
g_object_unref (renderer);
if (boolean_cell->priv->cell_value != active)
{
boolean_cell->priv->cell_value = !boolean_cell->priv->cell_value;
if (emit_signal)
atk_object_notify_state_change (ATK_OBJECT (cell), ATK_STATE_CHECKED, active);
}
if (boolean_cell->priv->cell_sensitive != sensitive)
{
boolean_cell->priv->cell_sensitive = !boolean_cell->priv->cell_sensitive;
if (emit_signal)
atk_object_notify_state_change (ATK_OBJECT (cell), ATK_STATE_SENSITIVE, sensitive);
}
}
static void
gtk_boolean_cell_accessible_class_init (GtkBooleanCellAccessibleClass *klass)
{
GtkCellAccessibleClass *cell_class = GTK_CELL_ACCESSIBLE_CLASS (klass);
AtkObjectClass *atkobject_class = ATK_OBJECT_CLASS (klass);
atkobject_class->ref_state_set = gtk_boolean_cell_accessible_ref_state_set;
cell_class->update_cache = gtk_boolean_cell_accessible_update_cache;
}
static void
gtk_boolean_cell_accessible_init (GtkBooleanCellAccessible *cell)
{
cell->priv = gtk_boolean_cell_accessible_get_instance_private (cell);
}

View File

@@ -0,0 +1,58 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_BOOLEAN_CELL_ACCESSIBLE_H__
#define __GTK_BOOLEAN_CELL_ACCESSIBLE_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <atk/atk.h>
#include <gtk/a11y/gtkrenderercellaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_BOOLEAN_CELL_ACCESSIBLE (gtk_boolean_cell_accessible_get_type ())
#define GTK_BOOLEAN_CELL_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_BOOLEAN_CELL_ACCESSIBLE, GtkBooleanCellAccessible))
#define GTK_BOOLEAN_CELL_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_BOOLEAN_CELL, GtkBooleanCellAccessibleClass))
#define GTK_IS_BOOLEAN_CELL_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_BOOLEAN_CELL_ACCESSIBLE))
#define GTK_IS_BOOLEAN_CELL_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_BOOLEAN_CELL_ACCESSIBLE))
#define GTK_BOOLEAN_CELL_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_BOOLEAN_CELL_ACCESSIBLE, GtkBooleanCellAccessibleClass))
typedef struct _GtkBooleanCellAccessible GtkBooleanCellAccessible;
typedef struct _GtkBooleanCellAccessibleClass GtkBooleanCellAccessibleClass;
typedef struct _GtkBooleanCellAccessiblePrivate GtkBooleanCellAccessiblePrivate;
struct _GtkBooleanCellAccessible
{
GtkRendererCellAccessible parent;
GtkBooleanCellAccessiblePrivate *priv;
};
struct _GtkBooleanCellAccessibleClass
{
GtkRendererCellAccessibleClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType gtk_boolean_cell_accessible_get_type (void);
G_END_DECLS
#endif /* __GAIL_TREE_VIEW_BOOLEAN_CELL_H__ */

View File

@@ -0,0 +1,436 @@
/* GTK+ - accessibility implementations
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
#include "gtkbuttonaccessible.h"
static void atk_action_interface_init (AtkActionIface *iface);
static void atk_image_interface_init (AtkImageIface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkButtonAccessible, gtk_button_accessible, GTK_TYPE_WIDGET_ACCESSIBLE,
G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init)
G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE, atk_image_interface_init))
static void
gtk_button_accessible_initialize (AtkObject *obj,
gpointer data)
{
GtkWidget *parent;
ATK_OBJECT_CLASS (gtk_button_accessible_parent_class)->initialize (obj, data);
parent = gtk_widget_get_parent (gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)));
if (GTK_IS_TREE_VIEW (parent))
{
/* Even though the accessible parent of the column header will
* be reported as the table because the parent widget of the
* GtkTreeViewColumn's button is the GtkTreeView we set
* the accessible parent for column header to be the table
* to ensure that atk_object_get_index_in_parent() returns
* the correct value; see gail_widget_get_index_in_parent().
*/
atk_object_set_parent (obj, gtk_widget_get_accessible (parent));
obj->role = ATK_ROLE_TABLE_COLUMN_HEADER;
}
else
obj->role = ATK_ROLE_PUSH_BUTTON;
}
static GtkWidget *
get_image_from_button (GtkWidget *button)
{
GtkWidget *image;
image = gtk_button_get_child (GTK_BUTTON (button));
if (GTK_IS_IMAGE (image))
return image;
return NULL;
}
static GtkWidget *
find_label_child (GtkWidget *widget)
{
GtkWidget *child;
for (child = gtk_widget_get_first_child (widget);
child != NULL;
child = gtk_widget_get_next_sibling (widget))
{
if (GTK_IS_LABEL (child))
return child;
else
{
GtkWidget *w = find_label_child (child);
if (w)
return w;
}
}
return NULL;
}
static GtkWidget *
get_label_from_button (GtkWidget *button)
{
GtkWidget *child;
child = gtk_button_get_child (GTK_BUTTON (button));
if (!GTK_IS_LABEL (child))
child = find_label_child (child);
return child;
}
static const gchar *
gtk_button_accessible_get_name (AtkObject *obj)
{
const gchar *name = NULL;
GtkWidget *widget;
GtkWidget *child;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return NULL;
name = ATK_OBJECT_CLASS (gtk_button_accessible_parent_class)->get_name (obj);
if (name != NULL)
return name;
child = get_label_from_button (widget);
if (GTK_IS_LABEL (child))
name = gtk_label_get_text (GTK_LABEL (child));
else
{
GtkWidget *image;
image = get_image_from_button (widget);
if (GTK_IS_IMAGE (image))
{
AtkObject *atk_obj;
atk_obj = gtk_widget_get_accessible (image);
name = atk_object_get_name (atk_obj);
}
}
return name;
}
static gint
gtk_button_accessible_get_n_children (AtkObject* obj)
{
return 0;
}
static AtkObject *
gtk_button_accessible_ref_child (AtkObject *obj,
gint i)
{
return NULL;
}
static AtkStateSet *
gtk_button_accessible_ref_state_set (AtkObject *obj)
{
AtkStateSet *state_set;
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return NULL;
state_set = ATK_OBJECT_CLASS (gtk_button_accessible_parent_class)->ref_state_set (obj);
if ((gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_ACTIVE) != 0)
atk_state_set_add_state (state_set, ATK_STATE_ARMED);
if (!gtk_widget_get_can_focus (widget))
atk_state_set_remove_state (state_set, ATK_STATE_SELECTABLE);
return state_set;
}
void
gtk_button_accessible_update_label (GtkButtonAccessible *self)
{
g_return_if_fail (GTK_IS_BUTTON_ACCESSIBLE (self));
/* If we don't have an overridden name, we use the label as the
* accessible name
*/
if (atk_object_get_name (ATK_OBJECT (self)) == NULL)
g_object_notify (G_OBJECT (self), "accessible-name");
g_signal_emit_by_name (self, "visible-data-changed");
}
static void
gtk_button_accessible_class_init (GtkButtonAccessibleClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
class->get_name = gtk_button_accessible_get_name;
class->get_n_children = gtk_button_accessible_get_n_children;
class->ref_child = gtk_button_accessible_ref_child;
class->ref_state_set = gtk_button_accessible_ref_state_set;
class->initialize = gtk_button_accessible_initialize;
}
static void
gtk_button_accessible_init (GtkButtonAccessible *button)
{
}
static gboolean
gtk_button_accessible_do_action (AtkAction *action,
gint i)
{
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (action));
if (widget == NULL)
return FALSE;
if (i != 0)
return FALSE;
if (!gtk_widget_is_sensitive (widget) || !gtk_widget_get_visible (widget))
return FALSE;
g_signal_emit_by_name (widget, "clicked");
return TRUE;
}
static gint
gtk_button_accessible_get_n_actions (AtkAction *action)
{
return 1;
}
static const gchar *
gtk_button_accessible_get_keybinding (AtkAction *action,
gint i)
{
gchar *return_value = NULL;
GtkWidget *widget;
GtkWidget *label;
guint key_val;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (action));
if (widget == NULL)
return NULL;
if (i != 0)
return NULL;
label = get_label_from_button (widget);
if (GTK_IS_LABEL (label))
{
key_val = gtk_label_get_mnemonic_keyval (GTK_LABEL (label));
if (key_val != GDK_KEY_VoidSymbol)
return_value = gtk_accelerator_name (key_val, GDK_ALT_MASK);
}
if (return_value == NULL)
{
/* Find labelled-by relation */
AtkRelationSet *set;
AtkRelation *relation;
GPtrArray *target;
gpointer target_object;
set = atk_object_ref_relation_set (ATK_OBJECT (action));
if (set)
{
relation = atk_relation_set_get_relation_by_type (set, ATK_RELATION_LABELLED_BY);
if (relation)
{
target = atk_relation_get_target (relation);
target_object = g_ptr_array_index (target, 0);
label = gtk_accessible_get_widget (GTK_ACCESSIBLE (target_object));
}
g_object_unref (set);
}
if (GTK_IS_LABEL (label))
{
key_val = gtk_label_get_mnemonic_keyval (GTK_LABEL (label));
if (key_val != GDK_KEY_VoidSymbol)
return_value = gtk_accelerator_name (key_val, GDK_ALT_MASK);
}
}
return return_value;
}
static const gchar *
gtk_button_accessible_action_get_name (AtkAction *action,
gint i)
{
if (i == 0)
return "click";
return NULL;
}
static const gchar *
gtk_button_accessible_action_get_localized_name (AtkAction *action,
gint i)
{
if (i == 0)
return C_("Action name", "Click");
return NULL;
}
static const gchar *
gtk_button_accessible_action_get_description (AtkAction *action,
gint i)
{
if (i == 0)
return C_("Action description", "Clicks the button");
return NULL;
}
static void
atk_action_interface_init (AtkActionIface *iface)
{
iface->do_action = gtk_button_accessible_do_action;
iface->get_n_actions = gtk_button_accessible_get_n_actions;
iface->get_keybinding = gtk_button_accessible_get_keybinding;
iface->get_name = gtk_button_accessible_action_get_name;
iface->get_localized_name = gtk_button_accessible_action_get_localized_name;
iface->get_description = gtk_button_accessible_action_get_description;
}
static const gchar *
gtk_button_accessible_get_image_description (AtkImage *image)
{
GtkWidget *widget;
GtkWidget *button_image;
AtkObject *obj;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (image));
if (widget == NULL)
return NULL;
button_image = get_image_from_button (widget);
if (GTK_IS_IMAGE (button_image))
{
obj = gtk_widget_get_accessible (button_image);
return atk_image_get_image_description (ATK_IMAGE (obj));
}
return NULL;
}
static void
gtk_button_accessible_get_image_position (AtkImage *image,
gint *x,
gint *y,
AtkCoordType coord_type)
{
GtkWidget *widget;
GtkWidget *button_image;
AtkObject *obj;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (image));
if (widget == NULL)
{
*x = G_MININT;
*y = G_MININT;
return;
}
button_image = get_image_from_button (widget);
if (button_image != NULL)
{
obj = gtk_widget_get_accessible (button_image);
atk_component_get_extents (ATK_COMPONENT (obj), x, y, NULL, NULL,
coord_type);
}
else
{
*x = G_MININT;
*y = G_MININT;
}
}
static void
gtk_button_accessible_get_image_size (AtkImage *image,
gint *width,
gint *height)
{
GtkWidget *widget;
GtkWidget *button_image;
AtkObject *obj;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (image));
if (widget == NULL)
{
*width = -1;
*height = -1;
return;
}
button_image = get_image_from_button (widget);
if (GTK_IS_IMAGE (button_image))
{
obj = gtk_widget_get_accessible (GTK_WIDGET (button_image));
atk_image_get_image_size (ATK_IMAGE (obj), width, height);
}
else
{
*width = -1;
*height = -1;
}
}
static gboolean
gtk_button_accessible_set_image_description (AtkImage *image,
const gchar *description)
{
GtkWidget *widget;
GtkWidget *button_image;
AtkObject *obj;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (image));
if (widget == NULL)
return FALSE;
button_image = get_image_from_button (widget);
if (GTK_IMAGE (button_image))
{
obj = gtk_widget_get_accessible (GTK_WIDGET (button_image));
return atk_image_set_image_description (ATK_IMAGE (obj), description);
}
return FALSE;
}
static void
atk_image_interface_init (AtkImageIface *iface)
{
iface->get_image_description = gtk_button_accessible_get_image_description;
iface->get_image_position = gtk_button_accessible_get_image_position;
iface->get_image_size = gtk_button_accessible_get_image_size;
iface->set_image_description = gtk_button_accessible_set_image_description;
}

View File

@@ -0,0 +1,60 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_BUTTON_ACCESSIBLE_H__
#define __GTK_BUTTON_ACCESSIBLE_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <gtk/a11y/gtkwidgetaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_BUTTON_ACCESSIBLE (gtk_button_accessible_get_type ())
#define GTK_BUTTON_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_BUTTON_ACCESSIBLE, GtkButtonAccessible))
#define GTK_BUTTON_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_BUTTON_ACCESSIBLE, GtkButtonAccessibleClass))
#define GTK_IS_BUTTON_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_BUTTON_ACCESSIBLE))
#define GTK_IS_BUTTON_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_BUTTON_ACCESSIBLE))
#define GTK_BUTTON_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_BUTTON_ACCESSIBLE, GtkButtonAccessibleClass))
typedef struct _GtkButtonAccessible GtkButtonAccessible;
typedef struct _GtkButtonAccessibleClass GtkButtonAccessibleClass;
typedef struct _GtkButtonAccessiblePrivate GtkButtonAccessiblePrivate;
struct _GtkButtonAccessible
{
GtkWidgetAccessible parent;
GtkButtonAccessiblePrivate *priv;
};
struct _GtkButtonAccessibleClass
{
GtkWidgetAccessibleClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType gtk_button_accessible_get_type (void);
/*< private >*/
void gtk_button_accessible_update_label (GtkButtonAccessible *self);
G_END_DECLS
#endif /* __GTK_BUTTON_ACCESSIBLE_H__ */

View File

@@ -0,0 +1,533 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include "gtkcontainercellaccessible.h"
#include "gtkcellaccessibleprivate.h"
#include "gtkcellaccessibleparent.h"
struct _GtkCellAccessiblePrivate
{
AtkObject *parent;
};
static const struct {
AtkState atk_state;
GtkCellRendererState renderer_state;
gboolean invert;
} state_map[] = {
{ ATK_STATE_SENSITIVE, GTK_CELL_RENDERER_INSENSITIVE, TRUE },
{ ATK_STATE_ENABLED, GTK_CELL_RENDERER_INSENSITIVE, TRUE },
{ ATK_STATE_SELECTED, GTK_CELL_RENDERER_SELECTED, FALSE },
/* XXX: why do we map ACTIVE here? */
{ ATK_STATE_ACTIVE, GTK_CELL_RENDERER_FOCUSED, FALSE },
{ ATK_STATE_FOCUSED, GTK_CELL_RENDERER_FOCUSED, FALSE },
{ ATK_STATE_EXPANDABLE,GTK_CELL_RENDERER_EXPANDABLE, FALSE },
{ ATK_STATE_EXPANDED, GTK_CELL_RENDERER_EXPANDED, FALSE },
};
static GtkCellRendererState gtk_cell_accessible_get_state (GtkCellAccessible *cell);
static void atk_action_interface_init (AtkActionIface *iface);
static void atk_component_interface_init (AtkComponentIface *iface);
static void atk_table_cell_interface_init (AtkTableCellIface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkCellAccessible, gtk_cell_accessible, GTK_TYPE_ACCESSIBLE,
G_ADD_PRIVATE (GtkCellAccessible)
G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init)
G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_interface_init)
G_IMPLEMENT_INTERFACE (ATK_TYPE_TABLE_CELL, atk_table_cell_interface_init))
static gint
gtk_cell_accessible_get_index_in_parent (AtkObject *obj)
{
GtkCellAccessible *cell;
AtkObject *parent;
cell = GTK_CELL_ACCESSIBLE (obj);
if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (cell->priv->parent))
return g_list_index (gtk_container_cell_accessible_get_children (GTK_CONTAINER_CELL_ACCESSIBLE (cell->priv->parent)), obj);
parent = gtk_widget_get_accessible (gtk_accessible_get_widget (GTK_ACCESSIBLE (cell)));
if (parent == NULL)
return -1;
return gtk_cell_accessible_parent_get_child_index (GTK_CELL_ACCESSIBLE_PARENT (cell->priv->parent), cell);
}
static AtkRelationSet *
gtk_cell_accessible_ref_relation_set (AtkObject *object)
{
GtkCellAccessible *cell;
AtkRelationSet *relationset;
AtkObject *parent;
relationset = ATK_OBJECT_CLASS (gtk_cell_accessible_parent_class)->ref_relation_set (object);
if (relationset == NULL)
relationset = atk_relation_set_new ();
cell = GTK_CELL_ACCESSIBLE (object);
parent = gtk_widget_get_accessible (gtk_accessible_get_widget (GTK_ACCESSIBLE (cell)));
gtk_cell_accessible_parent_update_relationset (GTK_CELL_ACCESSIBLE_PARENT (parent),
cell,
relationset);
return relationset;
}
static AtkStateSet *
gtk_cell_accessible_ref_state_set (AtkObject *accessible)
{
GtkCellAccessible *cell_accessible;
AtkStateSet *state_set;
GtkCellRendererState flags;
guint i;
cell_accessible = GTK_CELL_ACCESSIBLE (accessible);
state_set = atk_state_set_new ();
if (gtk_accessible_get_widget (GTK_ACCESSIBLE (cell_accessible)) == NULL)
{
atk_state_set_add_state (state_set, ATK_STATE_DEFUNCT);
return state_set;
}
flags = gtk_cell_accessible_get_state (cell_accessible);
atk_state_set_add_state (state_set, ATK_STATE_FOCUSABLE);
atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE);
atk_state_set_add_state (state_set, ATK_STATE_TRANSIENT);
atk_state_set_add_state (state_set, ATK_STATE_VISIBLE);
for (i = 0; i < G_N_ELEMENTS (state_map); i++)
{
if (flags & state_map[i].renderer_state)
{
if (!state_map[i].invert)
atk_state_set_add_state (state_set, state_map[i].atk_state);
}
else
{
if (state_map[i].invert)
atk_state_set_add_state (state_set, state_map[i].atk_state);
}
}
if (gtk_widget_get_mapped (gtk_accessible_get_widget (GTK_ACCESSIBLE (cell_accessible))))
atk_state_set_add_state (state_set, ATK_STATE_SHOWING);
return state_set;
}
static AtkObject *
gtk_cell_accessible_get_parent (AtkObject *object)
{
GtkCellAccessible *cell = GTK_CELL_ACCESSIBLE (object);
return cell->priv->parent;
}
static void
gtk_cell_accessible_class_init (GtkCellAccessibleClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
class->get_index_in_parent = gtk_cell_accessible_get_index_in_parent;
class->ref_state_set = gtk_cell_accessible_ref_state_set;
class->ref_relation_set = gtk_cell_accessible_ref_relation_set;
class->get_parent = gtk_cell_accessible_get_parent;
}
static void
gtk_cell_accessible_init (GtkCellAccessible *cell)
{
cell->priv = gtk_cell_accessible_get_instance_private (cell);
}
void
_gtk_cell_accessible_initialize (GtkCellAccessible *cell,
GtkWidget *widget,
AtkObject *parent)
{
gtk_accessible_set_widget (GTK_ACCESSIBLE (cell), widget);
cell->priv->parent = parent;
}
gboolean
_gtk_cell_accessible_add_state (GtkCellAccessible *cell,
AtkStateType state_type,
gboolean emit_signal)
{
/* The signal should only be generated if the value changed,
* not when the cell is set up. So states that are set
* initially should pass FALSE as the emit_signal argument.
*/
if (emit_signal)
{
atk_object_notify_state_change (ATK_OBJECT (cell), state_type, TRUE);
/* If state_type is ATK_STATE_VISIBLE, additional notification */
if (state_type == ATK_STATE_VISIBLE)
g_signal_emit_by_name (cell, "visible-data-changed");
}
/* If the parent is a flyweight container cell, propagate the state
* change to it also
*/
if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (cell->priv->parent))
_gtk_cell_accessible_add_state (GTK_CELL_ACCESSIBLE (cell->priv->parent), state_type, emit_signal);
return TRUE;
}
gboolean
_gtk_cell_accessible_remove_state (GtkCellAccessible *cell,
AtkStateType state_type,
gboolean emit_signal)
{
/* The signal should only be generated if the value changed,
* not when the cell is set up. So states that are set
* initially should pass FALSE as the emit_signal argument.
*/
if (emit_signal)
{
atk_object_notify_state_change (ATK_OBJECT (cell), state_type, FALSE);
/* If state_type is ATK_STATE_VISIBLE, additional notification */
if (state_type == ATK_STATE_VISIBLE)
g_signal_emit_by_name (cell, "visible-data-changed");
}
/* If the parent is a flyweight container cell, propagate the state
* change to it also
*/
if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (cell->priv->parent))
_gtk_cell_accessible_remove_state (GTK_CELL_ACCESSIBLE (cell->priv->parent), state_type, emit_signal);
return TRUE;
}
static gint
gtk_cell_accessible_action_get_n_actions (AtkAction *action)
{
return 3;
}
static const gchar *
gtk_cell_accessible_action_get_name (AtkAction *action,
gint index)
{
switch (index)
{
case 0:
return "expand or contract";
case 1:
return "edit";
case 2:
return "activate";
default:
return NULL;
}
}
static const gchar *
gtk_cell_accessible_action_get_localized_name (AtkAction *action,
gint index)
{
switch (index)
{
case 0:
return C_("Action name", "Expand or contract");
case 1:
return C_("Action name", "Edit");
case 2:
return C_("Action name", "Activate");
default:
return NULL;
}
}
static const gchar *
gtk_cell_accessible_action_get_description (AtkAction *action,
gint index)
{
switch (index)
{
case 0:
return C_("Action description", "Expands or contracts the row in the tree view containing this cell");
case 1:
return C_("Action description", "Creates a widget in which the contents of the cell can be edited");
case 2:
return C_("Action description", "Activates the cell");
default:
return NULL;
}
}
static const gchar *
gtk_cell_accessible_action_get_keybinding (AtkAction *action,
gint index)
{
return NULL;
}
static gboolean
gtk_cell_accessible_action_do_action (AtkAction *action,
gint index)
{
GtkCellAccessible *cell = GTK_CELL_ACCESSIBLE (action);
GtkCellAccessibleParent *parent;
if (gtk_accessible_get_widget (GTK_ACCESSIBLE (cell)) == NULL)
return FALSE;
parent = GTK_CELL_ACCESSIBLE_PARENT (gtk_widget_get_accessible (gtk_accessible_get_widget (GTK_ACCESSIBLE (cell))));
switch (index)
{
case 0:
gtk_cell_accessible_parent_expand_collapse (parent, cell);
break;
case 1:
gtk_cell_accessible_parent_edit (parent, cell);
break;
case 2:
gtk_cell_accessible_parent_activate (parent, cell);
break;
default:
return FALSE;
}
return TRUE;
}
static void
atk_action_interface_init (AtkActionIface *iface)
{
iface->get_n_actions = gtk_cell_accessible_action_get_n_actions;
iface->do_action = gtk_cell_accessible_action_do_action;
iface->get_name = gtk_cell_accessible_action_get_name;
iface->get_localized_name = gtk_cell_accessible_action_get_localized_name;
iface->get_description = gtk_cell_accessible_action_get_description;
iface->get_keybinding = gtk_cell_accessible_action_get_keybinding;
}
static void
gtk_cell_accessible_get_extents (AtkComponent *component,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coord_type)
{
GtkCellAccessible *cell;
AtkObject *parent;
cell = GTK_CELL_ACCESSIBLE (component);
parent = gtk_widget_get_accessible (gtk_accessible_get_widget (GTK_ACCESSIBLE (cell)));
gtk_cell_accessible_parent_get_cell_extents (GTK_CELL_ACCESSIBLE_PARENT (parent),
cell,
x, y, width, height, coord_type);
}
static gboolean
gtk_cell_accessible_grab_focus (AtkComponent *component)
{
GtkCellAccessible *cell;
AtkObject *parent;
cell = GTK_CELL_ACCESSIBLE (component);
parent = gtk_widget_get_accessible (gtk_accessible_get_widget (GTK_ACCESSIBLE (cell)));
return gtk_cell_accessible_parent_grab_focus (GTK_CELL_ACCESSIBLE_PARENT (parent), cell);
}
static void
atk_component_interface_init (AtkComponentIface *iface)
{
iface->get_extents = gtk_cell_accessible_get_extents;
iface->grab_focus = gtk_cell_accessible_grab_focus;
}
static int
gtk_cell_accessible_get_column_span (AtkTableCell *table_cell)
{
return 1;
}
static GPtrArray *
gtk_cell_accessible_get_column_header_cells (AtkTableCell *table_cell)
{
GtkCellAccessible *cell;
AtkObject *parent;
cell = GTK_CELL_ACCESSIBLE (table_cell);
parent = gtk_widget_get_accessible (gtk_accessible_get_widget (GTK_ACCESSIBLE (cell)));
return gtk_cell_accessible_parent_get_column_header_cells (GTK_CELL_ACCESSIBLE_PARENT (parent),
cell);
}
static gboolean
gtk_cell_accessible_get_position (AtkTableCell *table_cell,
gint *row,
gint *column)
{
GtkCellAccessible *cell;
AtkObject *parent;
cell = GTK_CELL_ACCESSIBLE (table_cell);
parent = gtk_widget_get_accessible (gtk_accessible_get_widget (GTK_ACCESSIBLE (cell)));
gtk_cell_accessible_parent_get_cell_position (GTK_CELL_ACCESSIBLE_PARENT (parent),
cell,
row, column);
return ((row && *row > 0) || (column && *column > 0));
}
static int
gtk_cell_accessible_get_row_span (AtkTableCell *table_cell)
{
return 1;
}
static GPtrArray *
gtk_cell_accessible_get_row_header_cells (AtkTableCell *table_cell)
{
GtkCellAccessible *cell;
AtkObject *parent;
cell = GTK_CELL_ACCESSIBLE (table_cell);
parent = gtk_widget_get_accessible (gtk_accessible_get_widget (GTK_ACCESSIBLE (cell)));
return gtk_cell_accessible_parent_get_row_header_cells (GTK_CELL_ACCESSIBLE_PARENT (parent),
cell);
}
static AtkObject *
gtk_cell_accessible_get_table (AtkTableCell *table_cell)
{
AtkObject *obj;
obj = ATK_OBJECT (table_cell);
do
{
AtkRole role;
obj = atk_object_get_parent (obj);
role = atk_object_get_role (obj);
if (role == ATK_ROLE_TABLE || role == ATK_ROLE_TREE_TABLE)
break;
}
while (obj);
return obj;
}
static void
atk_table_cell_interface_init (AtkTableCellIface *iface)
{
iface->get_column_span = gtk_cell_accessible_get_column_span;
iface->get_column_header_cells = gtk_cell_accessible_get_column_header_cells;
iface->get_position = gtk_cell_accessible_get_position;
iface->get_row_span = gtk_cell_accessible_get_row_span;
iface->get_row_header_cells = gtk_cell_accessible_get_row_header_cells;
iface->get_table = gtk_cell_accessible_get_table;
}
static GtkCellRendererState
gtk_cell_accessible_get_state (GtkCellAccessible *cell)
{
AtkObject *parent;
g_return_val_if_fail (GTK_IS_CELL_ACCESSIBLE (cell), 0);
parent = gtk_widget_get_accessible (gtk_accessible_get_widget (GTK_ACCESSIBLE (cell)));
if (parent == NULL)
return 0;
return gtk_cell_accessible_parent_get_renderer_state (GTK_CELL_ACCESSIBLE_PARENT (parent), cell);
}
/*
* gtk_cell_accessible_state_changed:
* @cell: a #GtkCellAccessible
* @added: the flags that were added from @cell
* @removed: the flags that were removed from @cell
*
* Notifies @cell of state changes. Multiple states may be added
* or removed at the same time. A state that is @added may not be
* @removed at the same time.
**/
void
_gtk_cell_accessible_state_changed (GtkCellAccessible *cell,
GtkCellRendererState added,
GtkCellRendererState removed)
{
AtkObject *object;
guint i;
g_return_if_fail (GTK_IS_CELL_ACCESSIBLE (cell));
g_return_if_fail ((added & removed) == 0);
object = ATK_OBJECT (cell);
for (i = 0; i < G_N_ELEMENTS (state_map); i++)
{
if (added & state_map[i].renderer_state)
atk_object_notify_state_change (object,
state_map[i].atk_state,
!state_map[i].invert);
if (removed & state_map[i].renderer_state)
atk_object_notify_state_change (object,
state_map[i].atk_state,
state_map[i].invert);
}
}
/*
* gtk_cell_accessible_update_cache:
* @cell: the cell that is changed
* @emit_signal: whether or not to notify the ATK bridge
*
* Notifies the cell that the values in the data in the row that
* is used to feed the cell renderer with has changed. The
* cell_changed function of @cell is called to send update
* notifications for the properties it takes from its cell
* renderer. If @emit_signal is TRUE, also notify the ATK bridge
* of the change. The bridge should be notified when an existing
* cell changes; not when a newly-created cell is being set up.
*
* Note that there is no higher granularity available about which
* properties changed, so you will need to make do with this
* function.
**/
void
_gtk_cell_accessible_update_cache (GtkCellAccessible *cell,
gboolean emit_signal)
{
GtkCellAccessibleClass *klass;
g_return_if_fail (GTK_CELL_ACCESSIBLE (cell));
klass = GTK_CELL_ACCESSIBLE_GET_CLASS (cell);
if (klass->update_cache)
klass->update_cache (cell, emit_signal);
}

View File

@@ -0,0 +1,60 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_CELL_ACCESSIBLE_H__
#define __GTK_CELL_ACCESSIBLE_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <atk/atk.h>
#include <gtk/gtkaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_CELL_ACCESSIBLE (gtk_cell_accessible_get_type ())
#define GTK_CELL_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CELL_ACCESSIBLE, GtkCellAccessible))
#define GTK_CELL_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_CELL_ACCESSIBLE, GtkCellAccessibleClass))
#define GTK_IS_CELL_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CELL_ACCESSIBLE))
#define GTK_IS_CELL_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CELL_ACCESSIBLE))
#define GTK_CELL_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CELL_ACCESSIBLE, GtkCellAccessibleClass))
typedef struct _GtkCellAccessible GtkCellAccessible;
typedef struct _GtkCellAccessibleClass GtkCellAccessibleClass;
typedef struct _GtkCellAccessiblePrivate GtkCellAccessiblePrivate;
struct _GtkCellAccessible
{
GtkAccessible parent;
GtkCellAccessiblePrivate *priv;
};
struct _GtkCellAccessibleClass
{
GtkAccessibleClass parent_class;
void (*update_cache) (GtkCellAccessible *cell,
gboolean emit_signal);
};
GDK_AVAILABLE_IN_ALL
GType gtk_cell_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_CELL_ACCESSIBLE_H__ */

View File

@@ -0,0 +1,271 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "gtkcellaccessibleparent.h"
GType
gtk_cell_accessible_parent_get_type (void)
{
static volatile gsize g_define_type_id__volatile = 0;
if (g_once_init_enter (&g_define_type_id__volatile))
{
GType g_define_type_id =
g_type_register_static_simple (G_TYPE_INTERFACE,
g_intern_static_string ("GtkCellAccessibleParent"),
sizeof (GtkCellAccessibleParentIface),
NULL,
0,
NULL,
0);
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
}
return g_define_type_id__volatile;
}
/**
* gtk_cell_accessible_parent_get_cell_extents:
* @x: (out):
* @y: (out):
* @width: (out):
* @height: (out):
*/
void
gtk_cell_accessible_parent_get_cell_extents (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coord_type)
{
GtkCellAccessibleParentIface *iface;
g_return_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent));
iface = GTK_CELL_ACCESSIBLE_PARENT_GET_IFACE (parent);
if (iface->get_cell_extents)
(iface->get_cell_extents) (parent, cell, x, y, width, height, coord_type);
}
/**
* gtk_cell_accessible_parent_get_cell_area:
* @cell_rect: (out):
*/
void
gtk_cell_accessible_parent_get_cell_area (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell,
GdkRectangle *cell_rect)
{
GtkCellAccessibleParentIface *iface;
g_return_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent));
g_return_if_fail (cell_rect);
iface = GTK_CELL_ACCESSIBLE_PARENT_GET_IFACE (parent);
if (iface->get_cell_area)
(iface->get_cell_area) (parent, cell, cell_rect);
}
gboolean
gtk_cell_accessible_parent_grab_focus (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell)
{
GtkCellAccessibleParentIface *iface;
g_return_val_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent), FALSE);
iface = GTK_CELL_ACCESSIBLE_PARENT_GET_IFACE (parent);
if (iface->grab_focus)
return (iface->grab_focus) (parent, cell);
else
return FALSE;
}
int
gtk_cell_accessible_parent_get_child_index (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell)
{
GtkCellAccessibleParentIface *iface;
g_return_val_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent), FALSE);
iface = GTK_CELL_ACCESSIBLE_PARENT_GET_IFACE (parent);
if (iface->get_child_index)
return (iface->get_child_index) (parent, cell);
else
return -1;
}
GtkCellRendererState
gtk_cell_accessible_parent_get_renderer_state (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell)
{
GtkCellAccessibleParentIface *iface;
g_return_val_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent), 0);
g_return_val_if_fail (GTK_IS_CELL_ACCESSIBLE (cell), 0);
iface = GTK_CELL_ACCESSIBLE_PARENT_GET_IFACE (parent);
if (iface->get_renderer_state)
return (iface->get_renderer_state) (parent, cell);
else
return 0;
}
void
gtk_cell_accessible_parent_expand_collapse (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell)
{
GtkCellAccessibleParentIface *iface;
g_return_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent));
g_return_if_fail (GTK_IS_CELL_ACCESSIBLE (cell));
iface = GTK_CELL_ACCESSIBLE_PARENT_GET_IFACE (parent);
if (iface->expand_collapse)
(iface->expand_collapse) (parent, cell);
}
void
gtk_cell_accessible_parent_activate (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell)
{
GtkCellAccessibleParentIface *iface;
g_return_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent));
g_return_if_fail (GTK_IS_CELL_ACCESSIBLE (cell));
iface = GTK_CELL_ACCESSIBLE_PARENT_GET_IFACE (parent);
if (iface->activate)
(iface->activate) (parent, cell);
}
void
gtk_cell_accessible_parent_edit (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell)
{
GtkCellAccessibleParentIface *iface;
g_return_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent));
g_return_if_fail (GTK_IS_CELL_ACCESSIBLE (cell));
iface = GTK_CELL_ACCESSIBLE_PARENT_GET_IFACE (parent);
if (iface->edit)
(iface->edit) (parent, cell);
}
void
gtk_cell_accessible_parent_update_relationset (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell,
AtkRelationSet *relationset)
{
GtkCellAccessibleParentIface *iface;
g_return_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent));
g_return_if_fail (GTK_IS_CELL_ACCESSIBLE (cell));
g_return_if_fail (ATK_IS_RELATION_SET (relationset));
iface = GTK_CELL_ACCESSIBLE_PARENT_GET_IFACE (parent);
if (iface->update_relationset)
(iface->update_relationset) (parent, cell, relationset);
}
/**
* gtk_cell_accessible_parent_get_cell_position:
* @row: (out):
* @column: (out):
*/
void
gtk_cell_accessible_parent_get_cell_position (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell,
gint *row,
gint *column)
{
GtkCellAccessibleParentIface *iface;
g_return_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent));
g_return_if_fail (GTK_IS_CELL_ACCESSIBLE (cell));
iface = GTK_CELL_ACCESSIBLE_PARENT_GET_IFACE (parent);
if (iface->get_cell_position)
(iface->get_cell_position) (parent, cell, row, column);
else
{
if (row)
*row = -1;
if (column)
*column = -1;
}
}
/**
* gtk_cell_accessible_parent_get_column_header_cells:
* Returns: (transfer full) (element-type AtkObject)
*/
GPtrArray *
gtk_cell_accessible_parent_get_column_header_cells (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell)
{
GtkCellAccessibleParentIface *iface;
g_return_val_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent), NULL);
g_return_val_if_fail (GTK_IS_CELL_ACCESSIBLE (cell), NULL);
iface = GTK_CELL_ACCESSIBLE_PARENT_GET_IFACE (parent);
if (iface->get_column_header_cells)
return (iface->get_column_header_cells) (parent, cell);
else
return NULL;
}
/**
* gtk_cell_accessible_parent_get_row_header_cells:
* Returns: (transfer full) (element-type AtkObject)
*/
GPtrArray *
gtk_cell_accessible_parent_get_row_header_cells (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell)
{
GtkCellAccessibleParentIface *iface;
g_return_val_if_fail (GTK_IS_CELL_ACCESSIBLE_PARENT (parent), NULL);
g_return_val_if_fail (GTK_IS_CELL_ACCESSIBLE (cell), NULL);
iface = GTK_CELL_ACCESSIBLE_PARENT_GET_IFACE (parent);
if (iface->get_row_header_cells)
return (iface->get_row_header_cells) (parent, cell);
else
return NULL;
}

View File

@@ -0,0 +1,140 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_CELL_ACCESSIBLE_PARENT_H__
#define __GTK_CELL_ACCESSIBLE_PARENT_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <atk/atk.h>
#include <gtk/a11y/gtkcellaccessible.h>
G_BEGIN_DECLS
/*
* The GtkCellAccessibleParent interface should be supported by any object
* which contains children which are flyweights, i.e. do not have corresponding
* widgets and the children need help from their parent to provide
* functionality. One example is GtkTreeViewAccessible where the children
* GtkCellAccessible need help from the GtkTreeViewAccessible in order to
* implement atk_component_get_extents().
*/
#define GTK_TYPE_CELL_ACCESSIBLE_PARENT (gtk_cell_accessible_parent_get_type ())
#define GTK_IS_CELL_ACCESSIBLE_PARENT(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CELL_ACCESSIBLE_PARENT)
#define GTK_CELL_ACCESSIBLE_PARENT(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CELL_ACCESSIBLE_PARENT, GtkCellAccessibleParent)
#define GTK_CELL_ACCESSIBLE_PARENT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_CELL_ACCESSIBLE_PARENT, GtkCellAccessibleParentIface))
typedef struct _GtkCellAccessibleParent GtkCellAccessibleParent;
typedef struct _GtkCellAccessibleParentIface GtkCellAccessibleParentIface;
struct _GtkCellAccessibleParentIface
{
GTypeInterface parent;
void ( *get_cell_extents) (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coord_type);
void ( *get_cell_area) (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell,
GdkRectangle *cell_rect);
gboolean ( *grab_focus) (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell);
int ( *get_child_index) (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell);
GtkCellRendererState
( *get_renderer_state) (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell);
/* actions */
void ( *expand_collapse) (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell);
void ( *activate) (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell);
void ( *edit) (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell);
/* end of actions */
void ( *update_relationset) (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell,
AtkRelationSet *relationset);
void ( *get_cell_position) (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell,
gint *row,
gint *column);
GPtrArray * ( *get_column_header_cells) (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell);
GPtrArray * ( *get_row_header_cells) (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell);
};
GDK_AVAILABLE_IN_ALL
GType gtk_cell_accessible_parent_get_type (void);
GDK_AVAILABLE_IN_ALL
void gtk_cell_accessible_parent_get_cell_extents (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coord_type);
GDK_AVAILABLE_IN_ALL
void gtk_cell_accessible_parent_get_cell_area (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell,
GdkRectangle *cell_rect);
GDK_AVAILABLE_IN_ALL
gboolean gtk_cell_accessible_parent_grab_focus (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell);
GDK_AVAILABLE_IN_ALL
int gtk_cell_accessible_parent_get_child_index (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell);
GDK_AVAILABLE_IN_ALL
GtkCellRendererState
gtk_cell_accessible_parent_get_renderer_state(GtkCellAccessibleParent *parent,
GtkCellAccessible *cell);
GDK_AVAILABLE_IN_ALL
void gtk_cell_accessible_parent_expand_collapse (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell);
GDK_AVAILABLE_IN_ALL
void gtk_cell_accessible_parent_activate (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell);
GDK_AVAILABLE_IN_ALL
void gtk_cell_accessible_parent_edit (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell);
GDK_AVAILABLE_IN_ALL
void gtk_cell_accessible_parent_update_relationset (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell,
AtkRelationSet *relationset);
GDK_AVAILABLE_IN_ALL
void gtk_cell_accessible_parent_get_cell_position(GtkCellAccessibleParent *parent,
GtkCellAccessible *cell,
gint *row,
gint *column);
GDK_AVAILABLE_IN_ALL
GPtrArray *gtk_cell_accessible_parent_get_column_header_cells (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell);
GDK_AVAILABLE_IN_ALL
GPtrArray *gtk_cell_accessible_parent_get_row_header_cells (GtkCellAccessibleParent *parent,
GtkCellAccessible *cell);
G_END_DECLS
#endif /* __GTK_CELL_ACCESSIBLE_PARENT_H__ */

View File

@@ -0,0 +1,42 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_CELL_ACCESSIBLE_PRIVATE_H__
#define __GTK_CELL_ACCESSIBLE_PRIVATE_H__
#include <gtk/a11y/gtkcellaccessible.h>
G_BEGIN_DECLS
void _gtk_cell_accessible_state_changed (GtkCellAccessible *cell,
GtkCellRendererState added,
GtkCellRendererState removed);
void _gtk_cell_accessible_update_cache (GtkCellAccessible *cell,
gboolean emit_signal);
void _gtk_cell_accessible_initialize (GtkCellAccessible *cell,
GtkWidget *widget,
AtkObject *parent);
gboolean _gtk_cell_accessible_add_state (GtkCellAccessible *cell,
AtkStateType state_type,
gboolean emit_signal);
gboolean _gtk_cell_accessible_remove_state (GtkCellAccessible *cell,
AtkStateType state_type,
gboolean emit_signal);
G_END_DECLS
#endif /* __GTK_CELL_ACCESSIBLE_PRIVATE_H__ */

View File

@@ -0,0 +1,211 @@
/* GTK+ - accessibility implementations
* Copyright 2012 Red Hat, Inc
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkcolorswatchaccessibleprivate.h"
#include "gtkcolorswatchprivate.h"
#include <glib/gi18n-lib.h>
static void atk_action_interface_init (AtkActionIface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkColorSwatchAccessible, _gtk_color_swatch_accessible, GTK_TYPE_WIDGET_ACCESSIBLE,
G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init))
static void
state_changed_cb (GtkWidget *widget,
GtkStateFlags previous_flags,
AtkObject *accessible)
{
GtkStateFlags flags;
gboolean was_selected;
gboolean selected;
flags = gtk_widget_get_state_flags (widget);
was_selected = (previous_flags & GTK_STATE_FLAG_SELECTED) != 0;
selected = (flags & GTK_STATE_FLAG_SELECTED) != 0;
if (selected && !was_selected)
atk_object_notify_state_change (accessible, ATK_STATE_CHECKED, TRUE);
else if (!selected && was_selected)
atk_object_notify_state_change (accessible, ATK_STATE_CHECKED, FALSE);
}
static void
on_selectable_changed_cb (GObject *gobject,
GParamSpec *pspec,
AtkObject *accessible)
{
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (gobject);
AtkRole role;
if (gtk_color_swatch_get_selectable (swatch))
role = ATK_ROLE_RADIO_BUTTON;
else
role = ATK_ROLE_PUSH_BUTTON;
atk_object_set_role (accessible, role);
}
static void
gtk_color_swatch_accessible_initialize (AtkObject *obj,
gpointer data)
{
GtkColorSwatch *swatch = data;
ATK_OBJECT_CLASS (_gtk_color_swatch_accessible_parent_class)->initialize (obj, data);
g_signal_connect (data, "state-flags-changed",
G_CALLBACK (state_changed_cb),
obj);
g_signal_connect (data, "notify::selectable",
G_CALLBACK (on_selectable_changed_cb),
obj);
obj->role = gtk_color_swatch_get_selectable (swatch)
? ATK_ROLE_RADIO_BUTTON
: ATK_ROLE_PUSH_BUTTON;
}
static AtkStateSet *
gtk_color_swatch_accessible_ref_state_set (AtkObject *accessible)
{
GtkWidget *widget;
AtkStateSet *state_set;
state_set = ATK_OBJECT_CLASS (_gtk_color_swatch_accessible_parent_class)->ref_state_set (accessible);
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
if (widget != NULL)
{
if ((gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_SELECTED) != 0)
atk_state_set_add_state (state_set, ATK_STATE_CHECKED);
}
return state_set;
}
static void
_gtk_color_swatch_accessible_class_init (GtkColorSwatchAccessibleClass *klass)
{
AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass);
atk_class->initialize = gtk_color_swatch_accessible_initialize;
atk_class->ref_state_set = gtk_color_swatch_accessible_ref_state_set;
}
static void
_gtk_color_swatch_accessible_init (GtkColorSwatchAccessible *self)
{
ATK_OBJECT (self)->role = ATK_ROLE_RADIO_BUTTON;
}
static gint
gtk_color_swatch_accessible_get_n_actions (AtkAction *action)
{
return 3;
}
static const gchar *
gtk_color_swatch_accessible_get_keybinding (AtkAction *action,
gint i)
{
return NULL;
}
static const gchar *
gtk_color_swatch_accessible_get_name (AtkAction *action,
gint i)
{
switch (i)
{
case 0: return "select";
case 1: return "activate";
case 2: return "customize";
default: return NULL;
}
}
static const gchar *
gtk_color_swatch_accessible_get_localized_name (AtkAction *action,
gint i)
{
switch (i)
{
case 0: return C_("Action name", "Select");
case 1: return C_("Action name", "Activate");
case 2: return C_("Action name", "Customize");
default: return NULL;
}
}
static const gchar *
gtk_color_swatch_accessible_get_description (AtkAction *action,
gint i)
{
switch (i)
{
case 0: return C_("Action description", "Selects the color");
case 1: return C_("Action description", "Activates the color");
case 2: return C_("Action description", "Customizes the color");
default: return NULL;
}
}
static gboolean
gtk_color_swatch_accessible_do_action (AtkAction *action,
gint i)
{
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (action));
if (widget == NULL)
return FALSE;
switch (i)
{
case 0:
gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_SELECTED, FALSE);
break;
case 1:
g_signal_emit_by_name (widget, "activate");
break;
case 2:
g_signal_emit_by_name (widget, "customize");
break;
default:
return FALSE;
}
return TRUE;
}
static void
atk_action_interface_init (AtkActionIface *iface)
{
iface->do_action = gtk_color_swatch_accessible_do_action;
iface->get_n_actions = gtk_color_swatch_accessible_get_n_actions;
iface->get_keybinding = gtk_color_swatch_accessible_get_keybinding;
iface->get_name = gtk_color_swatch_accessible_get_name;
iface->get_localized_name = gtk_color_swatch_accessible_get_localized_name;
iface->get_description = gtk_color_swatch_accessible_get_description;
}

View File

@@ -0,0 +1,52 @@
/* GTK+ - accessibility implementations
* Copyright 2012, Red Hat, Inc
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_COLOR_SWATCH_ACCESSIBLE_H__
#define __GTK_COLOR_SWATCH_ACCESSIBLE_H__
#include <gtk/a11y/gtkwidgetaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_COLOR_SWATCH_ACCESSIBLE (_gtk_color_swatch_accessible_get_type ())
#define GTK_COLOR_SWATCH_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_COLOR_SWATCH_ACCESSIBLE, GtkColorSwatchAccessible))
#define GTK_COLOR_SWATCH_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_COLOR_SWATCH_ACCESSIBLE, GtkColorSwatchAccessibleClass))
#define GTK_IS_COLOR_SWATCH_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_COLOR_SWATCH_ACCESSIBLE))
#define GTK_IS_COLOR_SWATCH_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_COLOR_SWATCH_ACCESSIBLE))
#define GTK_COLOR_SWATCH_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_COLOR_SWATCH_ACCESSIBLE, GtkColorSwatchAccessibleClass))
typedef struct _GtkColorSwatchAccessible GtkColorSwatchAccessible;
typedef struct _GtkColorSwatchAccessibleClass GtkColorSwatchAccessibleClass;
typedef struct _GtkColorSwatchAccessiblePrivate GtkColorSwatchAccessiblePrivate;
struct _GtkColorSwatchAccessible
{
GtkWidgetAccessible parent;
GtkColorSwatchAccessiblePrivate *priv;
};
struct _GtkColorSwatchAccessibleClass
{
GtkWidgetAccessibleClass parent_class;
};
GType _gtk_color_swatch_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_COLOR_SWATCH_ACCESSIBLE_H__ */

View File

@@ -0,0 +1,435 @@
/* GTK+ - accessibility implementations
* Copyright 2004 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include "gtkcomboboxaccessible.h"
struct _GtkComboBoxAccessiblePrivate
{
gchar *name;
gint old_selection;
gboolean popup_set;
};
static void atk_action_interface_init (AtkActionIface *iface);
static void atk_selection_interface_init (AtkSelectionIface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkComboBoxAccessible, gtk_combo_box_accessible, GTK_TYPE_WIDGET_ACCESSIBLE,
G_ADD_PRIVATE (GtkComboBoxAccessible)
G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init)
G_IMPLEMENT_INTERFACE (ATK_TYPE_SELECTION, atk_selection_interface_init))
static void
changed_cb (GtkWidget *widget)
{
GtkComboBox *combo_box;
AtkObject *obj;
GtkComboBoxAccessible *accessible;
gint index;
combo_box = GTK_COMBO_BOX (widget);
index = gtk_combo_box_get_active (combo_box);
obj = gtk_widget_get_accessible (widget);
accessible = GTK_COMBO_BOX_ACCESSIBLE (obj);
if (accessible->priv->old_selection != index)
{
accessible->priv->old_selection = index;
g_object_notify (G_OBJECT (obj), "accessible-name");
g_signal_emit_by_name (obj, "selection-changed");
}
}
static void
gtk_combo_box_accessible_initialize (AtkObject *obj,
gpointer data)
{
GtkComboBox *combo_box;
GtkComboBoxAccessible *accessible;
AtkObject *popup;
ATK_OBJECT_CLASS (gtk_combo_box_accessible_parent_class)->initialize (obj, data);
combo_box = GTK_COMBO_BOX (data);
accessible = GTK_COMBO_BOX_ACCESSIBLE (obj);
g_signal_connect (combo_box, "changed", G_CALLBACK (changed_cb), NULL);
accessible->priv->old_selection = gtk_combo_box_get_active (combo_box);
popup = gtk_combo_box_get_popup_accessible (combo_box);
if (popup)
{
atk_object_set_parent (popup, obj);
accessible->priv->popup_set = TRUE;
}
if (gtk_combo_box_get_has_entry (combo_box))
atk_object_set_parent (gtk_widget_get_accessible (gtk_combo_box_get_child (GTK_COMBO_BOX (combo_box))), obj);
obj->role = ATK_ROLE_COMBO_BOX;
}
static void
gtk_combo_box_accessible_finalize (GObject *object)
{
GtkComboBoxAccessible *combo_box = GTK_COMBO_BOX_ACCESSIBLE (object);
g_free (combo_box->priv->name);
G_OBJECT_CLASS (gtk_combo_box_accessible_parent_class)->finalize (object);
}
static const gchar *
gtk_combo_box_accessible_get_name (AtkObject *obj)
{
GtkWidget *widget;
GtkComboBox *combo_box;
GtkComboBoxAccessible *accessible;
GtkTreeIter iter;
const gchar *name;
GtkTreeModel *model;
gint n_columns;
gint i;
name = ATK_OBJECT_CLASS (gtk_combo_box_accessible_parent_class)->get_name (obj);
if (name)
return name;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return NULL;
combo_box = GTK_COMBO_BOX (widget);
accessible = GTK_COMBO_BOX_ACCESSIBLE (obj);
if (gtk_combo_box_get_active_iter (combo_box, &iter))
{
model = gtk_combo_box_get_model (combo_box);
n_columns = gtk_tree_model_get_n_columns (model);
for (i = 0; i < n_columns; i++)
{
GValue value = G_VALUE_INIT;
gtk_tree_model_get_value (model, &iter, i, &value);
if (G_VALUE_HOLDS_STRING (&value))
{
g_free (accessible->priv->name);
accessible->priv->name = g_strdup (g_value_get_string (&value));
g_value_unset (&value);
break;
}
else
g_value_unset (&value);
}
}
return accessible->priv->name;
}
static gint
gtk_combo_box_accessible_get_n_children (AtkObject* obj)
{
gint n_children = 0;
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return 0;
n_children++;
if (gtk_combo_box_get_has_entry (GTK_COMBO_BOX (widget)))
n_children++;
return n_children;
}
static AtkObject *
gtk_combo_box_accessible_ref_child (AtkObject *obj,
gint i)
{
GtkWidget *widget;
AtkObject *child;
GtkComboBoxAccessible *box;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return NULL;
if (i == 0)
{
child = gtk_combo_box_get_popup_accessible (GTK_COMBO_BOX (widget));
box = GTK_COMBO_BOX_ACCESSIBLE (obj);
if (!box->priv->popup_set)
{
atk_object_set_parent (child, obj);
box->priv->popup_set = TRUE;
}
}
else if (i == 1 && gtk_combo_box_get_has_entry (GTK_COMBO_BOX (widget)))
{
child = gtk_widget_get_accessible (gtk_combo_box_get_child (GTK_COMBO_BOX (widget)));
}
else
{
return NULL;
}
return g_object_ref (child);
}
static void
gtk_combo_box_accessible_class_init (GtkComboBoxAccessibleClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
gobject_class->finalize = gtk_combo_box_accessible_finalize;
class->get_name = gtk_combo_box_accessible_get_name;
class->get_n_children = gtk_combo_box_accessible_get_n_children;
class->ref_child = gtk_combo_box_accessible_ref_child;
class->initialize = gtk_combo_box_accessible_initialize;
}
static void
gtk_combo_box_accessible_init (GtkComboBoxAccessible *combo_box)
{
combo_box->priv = gtk_combo_box_accessible_get_instance_private (combo_box);
combo_box->priv->old_selection = -1;
combo_box->priv->name = NULL;
combo_box->priv->popup_set = FALSE;
}
static gboolean
gtk_combo_box_accessible_do_action (AtkAction *action,
gint i)
{
GtkComboBox *combo_box;
GtkWidget *widget;
gboolean popup_shown;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (action));
if (widget == NULL)
return FALSE;
if (!gtk_widget_get_sensitive (widget) || !gtk_widget_get_visible (widget))
return FALSE;
if (i != 0)
return FALSE;
combo_box = GTK_COMBO_BOX (widget);
g_object_get (combo_box, "popup-shown", &popup_shown, NULL);
if (popup_shown)
gtk_combo_box_popdown (combo_box);
else
gtk_combo_box_popup (combo_box);
return TRUE;
}
static gint
gtk_combo_box_accessible_get_n_actions (AtkAction *action)
{
return 1;
}
static const gchar *
gtk_combo_box_accessible_get_keybinding (AtkAction *action,
gint i)
{
GtkComboBoxAccessible *combo_box;
GtkWidget *widget;
GtkWidget *label;
AtkRelationSet *set;
AtkRelation *relation;
GPtrArray *target;
gpointer target_object;
guint key_val;
gchar *return_value = NULL;
if (i != 0)
return NULL;
combo_box = GTK_COMBO_BOX_ACCESSIBLE (action);
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (combo_box));
if (widget == NULL)
return NULL;
set = atk_object_ref_relation_set (ATK_OBJECT (action));
if (set == NULL)
return NULL;
label = NULL;
relation = atk_relation_set_get_relation_by_type (set, ATK_RELATION_LABELLED_BY);
if (relation)
{
target = atk_relation_get_target (relation);
target_object = g_ptr_array_index (target, 0);
label = gtk_accessible_get_widget (GTK_ACCESSIBLE (target_object));
}
g_object_unref (set);
if (GTK_IS_LABEL (label))
{
key_val = gtk_label_get_mnemonic_keyval (GTK_LABEL (label));
if (key_val != GDK_KEY_VoidSymbol)
return_value = gtk_accelerator_name (key_val, GDK_ALT_MASK);
}
return return_value;
}
static const gchar *
gtk_combo_box_accessible_action_get_name (AtkAction *action,
gint i)
{
if (i == 0)
return "press";
return NULL;
}
static const gchar *
gtk_combo_box_accessible_action_get_localized_name (AtkAction *action,
gint i)
{
if (i == 0)
return C_("Action name", "Press");
return NULL;
}
static const gchar *
gtk_combo_box_accessible_action_get_description (AtkAction *action,
gint i)
{
if (i == 0)
return C_("Action description", "Presses the combobox");
return NULL;
}
static void
atk_action_interface_init (AtkActionIface *iface)
{
iface->do_action = gtk_combo_box_accessible_do_action;
iface->get_n_actions = gtk_combo_box_accessible_get_n_actions;
iface->get_keybinding = gtk_combo_box_accessible_get_keybinding;
iface->get_name = gtk_combo_box_accessible_action_get_name;
iface->get_localized_name = gtk_combo_box_accessible_action_get_localized_name;
iface->get_description = gtk_combo_box_accessible_action_get_description;
}
static gboolean
gtk_combo_box_accessible_add_selection (AtkSelection *selection,
gint i)
{
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (widget == NULL)
return FALSE;
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), i);
return TRUE;
}
static gboolean
gtk_combo_box_accessible_clear_selection (AtkSelection *selection)
{
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (widget == NULL)
return FALSE;
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), -1);
return TRUE;
}
static AtkObject *
gtk_combo_box_accessible_ref_selection (AtkSelection *selection,
gint i)
{
GtkComboBox *combo_box;
GtkWidget *widget;
AtkObject *obj;
gint index;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (widget == NULL)
return NULL;
if (i != 0)
return NULL;
combo_box = GTK_COMBO_BOX (widget);
obj = gtk_combo_box_get_popup_accessible (combo_box);
index = gtk_combo_box_get_active (combo_box);
return atk_object_ref_accessible_child (obj, index);
}
static gint
gtk_combo_box_accessible_get_selection_count (AtkSelection *selection)
{
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (widget == NULL)
return 0;
return (gtk_combo_box_get_active (GTK_COMBO_BOX (widget)) == -1) ? 0 : 1;
}
static gboolean
gtk_combo_box_accessible_is_child_selected (AtkSelection *selection,
gint i)
{
GtkWidget *widget;
gint j;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (widget == NULL)
return FALSE;
j = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
return (j == i);
}
static gboolean
gtk_combo_box_accessible_remove_selection (AtkSelection *selection,
gint i)
{
if (atk_selection_is_child_selected (selection, i))
atk_selection_clear_selection (selection);
return TRUE;
}
static void
atk_selection_interface_init (AtkSelectionIface *iface)
{
iface->add_selection = gtk_combo_box_accessible_add_selection;
iface->clear_selection = gtk_combo_box_accessible_clear_selection;
iface->ref_selection = gtk_combo_box_accessible_ref_selection;
iface->get_selection_count = gtk_combo_box_accessible_get_selection_count;
iface->is_child_selected = gtk_combo_box_accessible_is_child_selected;
iface->remove_selection = gtk_combo_box_accessible_remove_selection;
}

View File

@@ -0,0 +1,57 @@
/* GTK+ - accessibility implementations
* Copyright 2004 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_COMBO_BOX_ACCESSIBLE_H__
#define __GTK_COMBO_BOX_ACCESSIBLE_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <gtk/a11y/gtkwidgetaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_COMBO_BOX_ACCESSIBLE (gtk_combo_box_accessible_get_type ())
#define GTK_COMBO_BOX_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_COMBO_BOX_ACCESSIBLE, GtkComboBoxAccessible))
#define GTK_COMBO_BOX_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_COMBO_BOX_ACCESSIBLE, GtkComboBoxAccessibleClass))
#define GTK_IS_COMBO_BOX_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_COMBO_BOX_ACCESSIBLE))
#define GTK_IS_COMBO_BOX_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_COMBO_BOX_ACCESSIBLE))
#define GTK_COMBO_BOX_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_COMBO_BOX_ACCESSIBLE, GtkComboBoxAccessibleClass))
typedef struct _GtkComboBoxAccessible GtkComboBoxAccessible;
typedef struct _GtkComboBoxAccessibleClass GtkComboBoxAccessibleClass;
typedef struct _GtkComboBoxAccessiblePrivate GtkComboBoxAccessiblePrivate;
struct _GtkComboBoxAccessible
{
GtkWidgetAccessible parent;
GtkComboBoxAccessiblePrivate *priv;
};
struct _GtkComboBoxAccessibleClass
{
GtkWidgetAccessibleClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType gtk_combo_box_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_COMBO_BOX_ACCESSIBLE_H__ */

View File

@@ -0,0 +1,87 @@
/* GTK+ - accessibility implementations
* Copyright 2020 Red Hat, Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkcompositeaccessible.h"
#include <gtk/gtk.h>
#include "gtkwidgetprivate.h"
G_DEFINE_TYPE (GtkCompositeAccessible, gtk_composite_accessible, GTK_TYPE_WIDGET_ACCESSIBLE)
static int
gtk_composite_accessible_get_n_children (AtkObject *obj)
{
GtkWidget *widget;
GtkWidget *child;
int count = 0;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return 0;
for (child = gtk_widget_get_first_child (widget); child; child = gtk_widget_get_next_sibling (child))
count++;
return count;
}
static AtkObject *
gtk_composite_accessible_ref_child (AtkObject *obj,
int i)
{
GtkWidget *widget;
GtkWidget *child;
int pos;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return NULL;
for (child = gtk_widget_get_first_child (widget), pos = 0; child && pos < i; child = gtk_widget_get_next_sibling (child), pos++);
if (child)
return g_object_ref (gtk_widget_get_accessible (GTK_WIDGET (child)));
return NULL;
}
static void
gtk_composite_accessible_initialize (AtkObject *obj,
gpointer data)
{
ATK_OBJECT_CLASS (gtk_composite_accessible_parent_class)->initialize (obj, data);
obj->role = ATK_ROLE_FILLER;
}
static void
gtk_composite_accessible_class_init (GtkCompositeAccessibleClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
class->initialize = gtk_composite_accessible_initialize;
class->get_n_children = gtk_composite_accessible_get_n_children;
class->ref_child = gtk_composite_accessible_ref_child;
}
static void
gtk_composite_accessible_init (GtkCompositeAccessible *composite)
{
}

View File

@@ -0,0 +1,55 @@
/* GTK+ - accessibility implementations
* Copyright 2020 Red Hat, Inc
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_COMPOSITE_ACCESSIBLE_H__
#define __GTK_COMPOSITE_ACCESSIBLE_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <gtk/gtkwidget.h>
#include <gtk/a11y/gtkwidgetaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_COMPOSITE_ACCESSIBLE (gtk_composite_accessible_get_type ())
#define GTK_COMPOSITE_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_COMPOSITE_ACCESSIBLE, GtkCompositeAccessible))
#define GTK_COMPOSITE_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_COMPOSITE_ACCESSIBLE, GtkCompositeAccessibleClass))
#define GTK_IS_COMPOSITE_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_COMPOSITE_ACCESSIBLE))
#define GTK_IS_COMPOSITE_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_COMPOSITE_ACCESSIBLE))
#define GTK_COMPOSITE_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_COMPOSITE_ACCESSIBLE, GtkCompositeAccessibleClass))
typedef struct _GtkCompositeAccessible GtkCompositeAccessible;
typedef struct _GtkCompositeAccessibleClass GtkCompositeAccessibleClass;
struct _GtkCompositeAccessible
{
GtkWidgetAccessible parent;
};
struct _GtkCompositeAccessibleClass
{
GtkWidgetAccessibleClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType gtk_composite_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_COMPOSITE_ACCESSIBLE_H__ */

View File

@@ -0,0 +1,180 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "gtkcontainercellaccessible.h"
#include "gtkcellaccessibleprivate.h"
struct _GtkContainerCellAccessiblePrivate
{
GList *children;
gint n_children;
};
G_DEFINE_TYPE_WITH_PRIVATE (GtkContainerCellAccessible, gtk_container_cell_accessible, GTK_TYPE_CELL_ACCESSIBLE)
static void
gtk_container_cell_accessible_finalize (GObject *obj)
{
GtkContainerCellAccessible *container = GTK_CONTAINER_CELL_ACCESSIBLE (obj);
g_list_free_full (container->priv->children, g_object_unref);
G_OBJECT_CLASS (gtk_container_cell_accessible_parent_class)->finalize (obj);
}
static gint
gtk_container_cell_accessible_get_n_children (AtkObject *obj)
{
GtkContainerCellAccessible *cell = GTK_CONTAINER_CELL_ACCESSIBLE (obj);
return cell->priv->n_children;
}
static AtkObject *
gtk_container_cell_accessible_ref_child (AtkObject *obj,
gint child)
{
GtkContainerCellAccessible *cell = GTK_CONTAINER_CELL_ACCESSIBLE (obj);
GList *l;
l = g_list_nth (cell->priv->children, child);
if (l == NULL)
return NULL;
return g_object_ref (ATK_OBJECT (l->data));
}
static void
gtk_container_cell_accessible_update_cache (GtkCellAccessible *cell,
gboolean emit_signal)
{
GtkContainerCellAccessible *container = GTK_CONTAINER_CELL_ACCESSIBLE (cell);
GList *l;
for (l = container->priv->children; l; l = l->next)
_gtk_cell_accessible_update_cache (l->data, emit_signal);
}
static void
gtk_container_cell_widget_set (GtkAccessible *accessible)
{
GtkContainerCellAccessible *container = GTK_CONTAINER_CELL_ACCESSIBLE (accessible);
GList *l;
for (l = container->priv->children; l; l = l->next)
gtk_accessible_set_widget (l->data, gtk_accessible_get_widget (accessible));
GTK_ACCESSIBLE_CLASS (gtk_container_cell_accessible_parent_class)->widget_set (accessible);
}
static void
gtk_container_cell_widget_unset (GtkAccessible *accessible)
{
GtkContainerCellAccessible *container = GTK_CONTAINER_CELL_ACCESSIBLE (accessible);
GList *l;
for (l = container->priv->children; l; l = l->next)
gtk_accessible_set_widget (l->data, NULL);
GTK_ACCESSIBLE_CLASS (gtk_container_cell_accessible_parent_class)->widget_unset (accessible);
}
static void
gtk_container_cell_accessible_class_init (GtkContainerCellAccessibleClass *klass)
{
GtkCellAccessibleClass *cell_class = GTK_CELL_ACCESSIBLE_CLASS (klass);
GtkAccessibleClass *accessible_class = GTK_ACCESSIBLE_CLASS (klass);
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
g_object_class->finalize = gtk_container_cell_accessible_finalize;
class->get_n_children = gtk_container_cell_accessible_get_n_children;
class->ref_child = gtk_container_cell_accessible_ref_child;
accessible_class->widget_set = gtk_container_cell_widget_set;
accessible_class->widget_unset = gtk_container_cell_widget_unset;
cell_class->update_cache = gtk_container_cell_accessible_update_cache;
}
static void
gtk_container_cell_accessible_init (GtkContainerCellAccessible *cell)
{
cell->priv = gtk_container_cell_accessible_get_instance_private (cell);
}
GtkContainerCellAccessible *
gtk_container_cell_accessible_new (void)
{
GObject *object;
object = g_object_new (GTK_TYPE_CONTAINER_CELL_ACCESSIBLE, NULL);
ATK_OBJECT (object)->role = ATK_ROLE_TABLE_CELL;
return GTK_CONTAINER_CELL_ACCESSIBLE (object);
}
void
gtk_container_cell_accessible_add_child (GtkContainerCellAccessible *container,
GtkCellAccessible *child)
{
g_return_if_fail (GTK_IS_CONTAINER_CELL_ACCESSIBLE (container));
g_return_if_fail (GTK_IS_CELL_ACCESSIBLE (child));
g_object_ref (child);
container->priv->n_children++;
container->priv->children = g_list_append (container->priv->children, child);
atk_object_set_parent (ATK_OBJECT (child), ATK_OBJECT (container));
}
void
gtk_container_cell_accessible_remove_child (GtkContainerCellAccessible *container,
GtkCellAccessible *child)
{
g_return_if_fail (GTK_IS_CONTAINER_CELL_ACCESSIBLE (container));
g_return_if_fail (GTK_IS_CELL_ACCESSIBLE (child));
g_return_if_fail (container->priv->n_children > 0);
container->priv->children = g_list_remove (container->priv->children, child);
container->priv->n_children--;
g_object_unref (child);
}
/**
* gtk_container_cell_accessible_get_children:
* @container: the container
*
* Get a list of children.
*
* Returns: (transfer none) (element-type Gtk.CellAccessible)
*/
GList *
gtk_container_cell_accessible_get_children (GtkContainerCellAccessible *container)
{
g_return_val_if_fail (GTK_IS_CONTAINER_CELL_ACCESSIBLE (container), NULL);
return container->priv->children;
}

View File

@@ -0,0 +1,69 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_CONTAINER_CELL_ACCESSIBLE_H__
#define __GTK_CONTAINER_CELL_ACCESSIBLE_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <atk/atk.h>
#include <gtk/a11y/gtkcellaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_CONTAINER_CELL_ACCESSIBLE (gtk_container_cell_accessible_get_type ())
#define GTK_CONTAINER_CELL_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CONTAINER_CELL_ACCESSIBLE, GtkContainerCellAccessible))
#define GTK_CONTAINER_CELL_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_CONTAINER_CELL_ACCESSIBLE, GtkContainerCellAccessibleClass))
#define GTK_IS_CONTAINER_CELL_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CONTAINER_CELL_ACCESSIBLE))
#define GTK_IS_CONTAINER_CELL_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CONTAINER_CELL_ACCESSIBLE))
#define GTK_CONTAINER_CELL_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CONTAINER_CELL_ACCESSIBLE, GtkContainerCellAccessibleClass))
typedef struct _GtkContainerCellAccessible GtkContainerCellAccessible;
typedef struct _GtkContainerCellAccessibleClass GtkContainerCellAccessibleClass;
typedef struct _GtkContainerCellAccessiblePrivate GtkContainerCellAccessiblePrivate;
struct _GtkContainerCellAccessible
{
GtkCellAccessible parent;
GtkContainerCellAccessiblePrivate *priv;
};
struct _GtkContainerCellAccessibleClass
{
GtkCellAccessibleClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType gtk_container_cell_accessible_get_type (void);
GDK_AVAILABLE_IN_ALL
GtkContainerCellAccessible *gtk_container_cell_accessible_new (void);
GDK_AVAILABLE_IN_ALL
void gtk_container_cell_accessible_add_child (GtkContainerCellAccessible *container,
GtkCellAccessible *child);
GDK_AVAILABLE_IN_ALL
void gtk_container_cell_accessible_remove_child (GtkContainerCellAccessible *container,
GtkCellAccessible *child);
GDK_AVAILABLE_IN_ALL
GList *gtk_container_cell_accessible_get_children (GtkContainerCellAccessible *container);
G_END_DECLS
#endif /* __GTK_CONTAINER_CELL_ACCESSIBLE_H__ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,60 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_ENTRY_ACCESSIBLE_H__
#define __GTK_ENTRY_ACCESSIBLE_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <gtk/a11y/gtkwidgetaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_ENTRY_ACCESSIBLE (gtk_entry_accessible_get_type ())
#define GTK_ENTRY_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ENTRY_ACCESSIBLE, GtkEntryAccessible))
#define GTK_ENTRY_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ENTRY_ACCESSIBLE, GtkEntryAccessibleClass))
#define GTK_IS_ENTRY_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ENTRY_ACCESSIBLE))
#define GTK_IS_ENTRY_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ENTRY_ACCESSIBLE))
#define GTK_ENTRY_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ENTRY_ACCESSIBLE, GtkEntryAccessibleClass))
typedef struct _GtkEntryAccessible GtkEntryAccessible;
typedef struct _GtkEntryAccessibleClass GtkEntryAccessibleClass;
typedef struct _GtkEntryAccessiblePrivate GtkEntryAccessiblePrivate;
struct _GtkEntryAccessible
{
GtkWidgetAccessible parent;
GtkEntryAccessiblePrivate *priv;
};
struct _GtkEntryAccessibleClass
{
GtkWidgetAccessibleClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType gtk_entry_accessible_get_type (void);
GDK_AVAILABLE_IN_ALL
GType gtk_entry_icon_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_ENTRY_ACCESSIBLE_H__ */

View File

@@ -0,0 +1,251 @@
/* GTK+ - accessibility implementations
* Copyright 2003 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkexpanderaccessibleprivate.h"
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
static void atk_action_interface_init (AtkActionIface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkExpanderAccessible, gtk_expander_accessible, GTK_TYPE_WIDGET_ACCESSIBLE,
G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init))
static const gchar *
gtk_expander_accessible_get_full_text (GtkExpander *widget)
{
GtkWidget *label_widget;
label_widget = gtk_expander_get_label_widget (widget);
if (!GTK_IS_LABEL (label_widget))
return NULL;
return gtk_label_get_text (GTK_LABEL (label_widget));
}
static const gchar *
gtk_expander_accessible_get_name (AtkObject *obj)
{
GtkWidget *widget;
const gchar *name;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return NULL;
name = ATK_OBJECT_CLASS (gtk_expander_accessible_parent_class)->get_name (obj);
if (name != NULL)
return name;
return gtk_expander_accessible_get_full_text (GTK_EXPANDER (widget));
}
static gint
gtk_expander_accessible_get_n_children (AtkObject *obj)
{
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return 0;
if (gtk_expander_get_child (GTK_EXPANDER (widget)))
return 1;
return 0;
}
static AtkObject *
gtk_expander_accessible_ref_child (AtkObject *obj,
gint i)
{
AtkObject *accessible;
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return NULL;
widget = gtk_expander_get_child (GTK_EXPANDER (widget));
if (widget == NULL)
return NULL;
accessible = gtk_widget_get_accessible (widget);
g_object_ref (accessible);
return accessible;
}
void
gtk_expander_accessible_update_label (GtkExpanderAccessible *self)
{
AtkObject *atk_obj = ATK_OBJECT (self);
if (atk_obj->name == NULL)
g_object_notify (G_OBJECT (atk_obj), "accessible-name");
g_signal_emit_by_name (atk_obj, "visible-data-changed");
}
void
gtk_expander_accessible_update_state (GtkExpanderAccessible *self,
gboolean expanded)
{
AtkObject *atk_obj = ATK_OBJECT (self);
atk_object_notify_state_change (atk_obj, ATK_STATE_CHECKED, expanded);
atk_object_notify_state_change (atk_obj, ATK_STATE_EXPANDED, expanded);
g_signal_emit_by_name (atk_obj, "visible-data-changed");
}
static AtkStateSet *
gtk_expander_accessible_ref_state_set (AtkObject *obj)
{
AtkStateSet *state_set;
GtkWidget *widget;
GtkExpander *expander;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return NULL;
state_set = ATK_OBJECT_CLASS (gtk_expander_accessible_parent_class)->ref_state_set (obj);
expander = GTK_EXPANDER (widget);
atk_state_set_add_state (state_set, ATK_STATE_EXPANDABLE);
if (gtk_expander_get_expanded (expander))
{
atk_state_set_add_state (state_set, ATK_STATE_CHECKED);
atk_state_set_add_state (state_set, ATK_STATE_EXPANDED);
}
return state_set;
}
static void
gtk_expander_accessible_class_init (GtkExpanderAccessibleClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
class->get_name = gtk_expander_accessible_get_name;
class->get_n_children = gtk_expander_accessible_get_n_children;
class->ref_child = gtk_expander_accessible_ref_child;
class->ref_state_set = gtk_expander_accessible_ref_state_set;
}
static void
gtk_expander_accessible_init (GtkExpanderAccessible *self)
{
ATK_OBJECT (self)->role = ATK_ROLE_TOGGLE_BUTTON;
}
static gboolean
gtk_expander_accessible_do_action (AtkAction *action,
gint i)
{
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (action));
if (widget == NULL)
return FALSE;
if (!gtk_widget_is_sensitive (widget) || !gtk_widget_get_visible (widget))
return FALSE;
if (i != 0)
return FALSE;
gtk_widget_activate (widget);
return TRUE;
}
static gint
gtk_expander_accessible_get_n_actions (AtkAction *action)
{
return 1;
}
static const gchar *
gtk_expander_accessible_get_keybinding (AtkAction *action,
gint i)
{
gchar *return_value = NULL;
GtkWidget *widget;
GtkWidget *label;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (action));
if (widget == NULL)
return NULL;
if (i != 0)
return NULL;
label = gtk_expander_get_label_widget (GTK_EXPANDER (widget));
if (GTK_IS_LABEL (label))
{
guint key_val;
key_val = gtk_label_get_mnemonic_keyval (GTK_LABEL (label));
if (key_val != GDK_KEY_VoidSymbol)
return_value = gtk_accelerator_name (key_val, GDK_ALT_MASK);
}
return return_value;
}
static const gchar *
gtk_expander_accessible_action_get_name (AtkAction *action,
gint i)
{
if (i == 0)
return "activate";
return NULL;
}
static const gchar *
gtk_expander_accessible_action_get_localized_name (AtkAction *action,
gint i)
{
if (i == 0)
return C_("Action name", "Activate");
return NULL;
}
static const gchar *
gtk_expander_accessible_action_get_description (AtkAction *action,
gint i)
{
if (i == 0)
return C_("Action description", "Activates the expander");
return NULL;
}
static void
atk_action_interface_init (AtkActionIface *iface)
{
iface->do_action = gtk_expander_accessible_do_action;
iface->get_n_actions = gtk_expander_accessible_get_n_actions;
iface->get_keybinding = gtk_expander_accessible_get_keybinding;
iface->get_name = gtk_expander_accessible_action_get_name;
iface->get_localized_name = gtk_expander_accessible_action_get_localized_name;
iface->get_description = gtk_expander_accessible_action_get_description;
}

View File

@@ -0,0 +1,57 @@
/* GTK+ - accessibility implementations
* Copyright 2003 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_EXPANDER_ACCESSIBLE_H__
#define __GTK_EXPANDER_ACCESSIBLE_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <gtk/a11y/gtkwidgetaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_EXPANDER_ACCESSIBLE (gtk_expander_accessible_get_type ())
#define GTK_EXPANDER_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_EXPANDER_ACCESSIBLE, GtkExpanderAccessible))
#define GTK_EXPANDER_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_EXPANDER_ACCESSIBLE, GtkExpanderAccessibleClass))
#define GTK_IS_EXPANDER_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_EXPANDER_ACCESSIBLE))
#define GTK_IS_EXPANDER_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_EXPANDER_ACCESSIBLE))
#define GTK_EXPANDER_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_EXPANDER_ACCESSIBLE, GtkExpanderAccessibleClass))
typedef struct _GtkExpanderAccessible GtkExpanderAccessible;
typedef struct _GtkExpanderAccessibleClass GtkExpanderAccessibleClass;
typedef struct _GtkExpanderAccessiblePrivate GtkExpanderAccessiblePrivate;
struct _GtkExpanderAccessible
{
GtkWidgetAccessible parent;
GtkExpanderAccessiblePrivate *priv;
};
struct _GtkExpanderAccessibleClass
{
GtkWidgetAccessibleClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType gtk_expander_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_EXPANDER_ACCESSIBLE_H__ */

View File

@@ -1,4 +1,4 @@
/* gtkatcontext.h: Assistive technology context
/* gtkexpanderaccessibleprivate.h: GtkExpanderAccessible private API
*
* Copyright 2020 GNOME Foundation
*
@@ -20,20 +20,12 @@
#pragma once
#include <gtk/gtktypes.h>
#include <gtk/gtkenums.h>
#include <gtk/gtkaccessible.h>
#include "gtkexpanderaccessible.h"
G_BEGIN_DECLS
#define GTK_TYPE_AT_CONTEXT (gtk_at_context_get_type())
GDK_AVAILABLE_IN_ALL
GDK_DECLARE_INTERNAL_TYPE (GtkATContext, gtk_at_context, GTK, AT_CONTEXT, GObject)
GDK_AVAILABLE_IN_ALL
GtkAccessible * gtk_at_context_get_accessible (GtkATContext *self);
GDK_AVAILABLE_IN_ALL
GtkAccessibleRole gtk_at_context_get_accessible_role (GtkATContext *self);
void gtk_expander_accessible_update_label (GtkExpanderAccessible *self);
void gtk_expander_accessible_update_state (GtkExpanderAccessible *self,
gboolean expanded);
G_END_DECLS

View File

@@ -0,0 +1,258 @@
/*
* Copyright (C) 2013 Red Hat, Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkflowboxaccessibleprivate.h"
#include "gtk/gtkflowbox.h"
static void atk_selection_interface_init (AtkSelectionIface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkFlowBoxAccessible, gtk_flow_box_accessible, GTK_TYPE_WIDGET_ACCESSIBLE,
G_IMPLEMENT_INTERFACE (ATK_TYPE_SELECTION, atk_selection_interface_init))
static void
gtk_flow_box_accessible_init (GtkFlowBoxAccessible *accessible)
{
}
static void
gtk_flow_box_accessible_initialize (AtkObject *obj,
gpointer data)
{
ATK_OBJECT_CLASS (gtk_flow_box_accessible_parent_class)->initialize (obj, data);
obj->role = ATK_ROLE_TABLE;
}
static AtkStateSet*
gtk_flow_box_accessible_ref_state_set (AtkObject *obj)
{
AtkStateSet *state_set;
GtkWidget *widget;
state_set = ATK_OBJECT_CLASS (gtk_flow_box_accessible_parent_class)->ref_state_set (obj);
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget != NULL)
atk_state_set_add_state (state_set, ATK_STATE_MANAGES_DESCENDANTS);
return state_set;
}
static void
gtk_flow_box_accessible_class_init (GtkFlowBoxAccessibleClass *klass)
{
AtkObjectClass *object_class = ATK_OBJECT_CLASS (klass);
object_class->initialize = gtk_flow_box_accessible_initialize;
object_class->ref_state_set = gtk_flow_box_accessible_ref_state_set;
}
static gboolean
gtk_flow_box_accessible_add_selection (AtkSelection *selection,
gint idx)
{
GtkWidget *box;
GtkWidget *child;
int pos;
box = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (box == NULL)
return FALSE;
for (child = gtk_widget_get_first_child (box), pos = 0;
child != NULL && pos < idx;
child = gtk_widget_get_next_sibling (child), pos++) ;
if (child && pos == idx)
{
gtk_flow_box_select_child (GTK_FLOW_BOX (box), GTK_FLOW_BOX_CHILD (child));
return TRUE;
}
return FALSE;
}
static gboolean
gtk_flow_box_accessible_remove_selection (AtkSelection *selection,
gint idx)
{
GtkWidget *box;
GtkWidget *child;
int pos;
box = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (box == NULL)
return FALSE;
for (child = gtk_widget_get_first_child (box), pos = 0;
child != NULL && pos < idx;
child = gtk_widget_get_next_sibling (child), pos++) ;
if (child && pos == idx)
{
gtk_flow_box_unselect_child (GTK_FLOW_BOX (box), GTK_FLOW_BOX_CHILD (child));
return TRUE;
}
return FALSE;
}
static gboolean
gtk_flow_box_accessible_clear_selection (AtkSelection *selection)
{
GtkWidget *box;
box = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (box == NULL)
return FALSE;
gtk_flow_box_unselect_all (GTK_FLOW_BOX (box));
return TRUE;
}
static gboolean
gtk_flow_box_accessible_select_all (AtkSelection *selection)
{
GtkWidget *box;
box = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (box == NULL)
return FALSE;
gtk_flow_box_select_all (GTK_FLOW_BOX (box));
return TRUE;
}
typedef struct
{
gint idx;
GtkWidget *child;
} FindSelectedData;
static void
find_selected_child (GtkFlowBox *box,
GtkFlowBoxChild *child,
gpointer data)
{
FindSelectedData *d = data;
if (d->idx == 0)
{
if (d->child == NULL)
d->child = GTK_WIDGET (child);
}
else
d->idx -= 1;
}
static AtkObject *
gtk_flow_box_accessible_ref_selection (AtkSelection *selection,
gint idx)
{
GtkWidget *box;
AtkObject *accessible;
FindSelectedData data;
box = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (box == NULL)
return NULL;
data.idx = idx;
data.child = NULL;
gtk_flow_box_selected_foreach (GTK_FLOW_BOX (box), find_selected_child, &data);
if (data.child == NULL)
return NULL;
accessible = gtk_widget_get_accessible (data.child);
g_object_ref (accessible);
return accessible;
}
static void
count_selected (GtkFlowBox *box,
GtkFlowBoxChild *child,
gpointer data)
{
gint *count = data;
*count += 1;
}
static gint
gtk_flow_box_accessible_get_selection_count (AtkSelection *selection)
{
GtkWidget *box;
gint count;
box = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (box == NULL)
return 0;
count = 0;
gtk_flow_box_selected_foreach (GTK_FLOW_BOX (box), count_selected, &count);
return count;
}
static gboolean
gtk_flow_box_accessible_is_child_selected (AtkSelection *selection,
gint idx)
{
GtkWidget *box;
GtkFlowBoxChild *child;
box = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (box == NULL)
return FALSE;
child = gtk_flow_box_get_child_at_index (GTK_FLOW_BOX (box), idx);
return gtk_flow_box_child_is_selected (child);
}
static void atk_selection_interface_init (AtkSelectionIface *iface)
{
iface->add_selection = gtk_flow_box_accessible_add_selection;
iface->remove_selection = gtk_flow_box_accessible_remove_selection;
iface->clear_selection = gtk_flow_box_accessible_clear_selection;
iface->ref_selection = gtk_flow_box_accessible_ref_selection;
iface->get_selection_count = gtk_flow_box_accessible_get_selection_count;
iface->is_child_selected = gtk_flow_box_accessible_is_child_selected;
iface->select_all_selection = gtk_flow_box_accessible_select_all;
}
void
_gtk_flow_box_accessible_selection_changed (GtkWidget *box)
{
AtkObject *accessible;
accessible = gtk_widget_get_accessible (box);
g_signal_emit_by_name (accessible, "selection-changed");
}
void
_gtk_flow_box_accessible_update_cursor (GtkWidget *box,
GtkWidget *child)
{
AtkObject *accessible;
AtkObject *descendant;
accessible = gtk_widget_get_accessible (box);
descendant = child ? gtk_widget_get_accessible (child) : NULL;
g_signal_emit_by_name (accessible, "active-descendant-changed", descendant);
}

View File

@@ -0,0 +1,57 @@
/*
* Copyright (C) 2013 Red Hat, Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_FLOW_BOX_ACCESSIBLE_H__
#define __GTK_FLOW_BOX_ACCESSIBLE_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <gtk/a11y/gtkwidgetaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_FLOW_BOX_ACCESSIBLE (gtk_flow_box_accessible_get_type ())
#define GTK_FLOW_BOX_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FLOW_BOX_ACCESSIBLE, GtkFlowBoxAccessible))
#define GTK_FLOW_BOX_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FLOW_BOX_ACCESSIBLE, GtkFlowBoxAccessibleClass))
#define GTK_IS_FLOW_BOX_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FLOW_BOX_ACCESSIBLE))
#define GTK_IS_FLOW_BOX_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FLOW_BOX_ACCESSIBLE))
#define GTK_FLOW_BOX_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FLOW_BOX_ACCESSIBLE, GtkFlowBoxAccessibleClass))
typedef struct _GtkFlowBoxAccessible GtkFlowBoxAccessible;
typedef struct _GtkFlowBoxAccessibleClass GtkFlowBoxAccessibleClass;
typedef struct _GtkFlowBoxAccessiblePrivate GtkFlowBoxAccessiblePrivate;
struct _GtkFlowBoxAccessible
{
GtkWidgetAccessible parent;
GtkFlowBoxAccessiblePrivate *priv;
};
struct _GtkFlowBoxAccessibleClass
{
GtkWidgetAccessibleClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType gtk_flow_box_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_FLOW_BOX_ACCESSIBLE_H__ */

View File

@@ -0,0 +1,30 @@
/*
* Copyright (C) 2013 Red Hat, Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_FLOW_BOX_ACCESSIBLE_PRIVATE_H__
#define __GTK_FLOW_BOX_ACCESSIBLE_PRIVATE_H__
#include <gtk/a11y/gtkflowboxaccessible.h>
G_BEGIN_DECLS
void _gtk_flow_box_accessible_selection_changed (GtkWidget *box);
void _gtk_flow_box_accessible_update_cursor (GtkWidget *box,
GtkWidget *child);
G_END_DECLS
#endif /* __GTK_FLOW_BOX_ACCESSIBLE_PRIVATE_H__ */

View File

@@ -0,0 +1,70 @@
/*
* Copyright (C) 2013 Red Hat, Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkflowboxchildaccessible.h"
#include "gtk/gtkflowbox.h"
G_DEFINE_TYPE (GtkFlowBoxChildAccessible, gtk_flow_box_child_accessible, GTK_TYPE_WIDGET_ACCESSIBLE)
static void
gtk_flow_box_child_accessible_init (GtkFlowBoxChildAccessible *accessible)
{
}
static void
gtk_flow_box_child_accessible_initialize (AtkObject *obj,
gpointer data)
{
ATK_OBJECT_CLASS (gtk_flow_box_child_accessible_parent_class)->initialize (obj, data);
obj->role = ATK_ROLE_TABLE_CELL;
}
static AtkStateSet *
gtk_flow_box_child_accessible_ref_state_set (AtkObject *obj)
{
AtkStateSet *state_set;
GtkWidget *widget, *parent;
state_set = ATK_OBJECT_CLASS (gtk_flow_box_child_accessible_parent_class)->ref_state_set (obj);
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget != NULL)
{
parent = gtk_widget_get_parent (widget);
if (gtk_flow_box_get_selection_mode (GTK_FLOW_BOX (parent)) != GTK_SELECTION_NONE)
atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE);
if (gtk_flow_box_child_is_selected (GTK_FLOW_BOX_CHILD (widget)))
atk_state_set_add_state (state_set, ATK_STATE_SELECTED);
}
return state_set;
}
static void
gtk_flow_box_child_accessible_class_init (GtkFlowBoxChildAccessibleClass *klass)
{
AtkObjectClass *object_class = ATK_OBJECT_CLASS (klass);
object_class->initialize = gtk_flow_box_child_accessible_initialize;
object_class->ref_state_set = gtk_flow_box_child_accessible_ref_state_set;
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright (C) 2013 Red Hat, Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_FLOW_BOX_CHILD_ACCESSIBLE_H__
#define __GTK_FLOW_BOX_CHILD_ACCESSIBLE_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <gtk/a11y/gtkwidgetaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_FLOW_BOX_CHILD_ACCESSIBLE (gtk_flow_box_child_accessible_get_type ())
#define GTK_FLOW_BOX_CHILD_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FLOW_BOX_CHILD_ACCESSIBLE, GtkFlowBoxChildAccessible))
#define GTK_FLOW_BOX_CHILD_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FLOW_BOX_CHILD_ACCESSIBLE, GtkFlowBoxChildAccessibleClass))
#define GTK_IS_FLOW_BOX_CHILD_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FLOW_BOX_CHILD_ACCESSIBLE))
#define GTK_IS_FLOW_BOX_CHILD_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FLOW_BOX_CHILD_ACCESSIBLE))
#define GTK_FLOW_BOX_CHILD_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FLOW_BOX_CHILD_ACCESSIBLE, GtkFlowBoxChildAccessibleClass))
typedef struct _GtkFlowBoxChildAccessible GtkFlowBoxChildAccessible;
typedef struct _GtkFlowBoxChildAccessibleClass GtkFlowBoxChildAccessibleClass;
struct _GtkFlowBoxChildAccessible
{
GtkWidgetAccessible parent;
};
struct _GtkFlowBoxChildAccessibleClass
{
GtkWidgetAccessibleClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType gtk_flow_box_child_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_FLOW_BOX_CHILD_ACCESSIBLE_H__ */

View File

@@ -0,0 +1,65 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "gtkframeaccessible.h"
G_DEFINE_TYPE (GtkFrameAccessible, gtk_frame_accessible, GTK_TYPE_WIDGET_ACCESSIBLE)
static void
gtk_frame_accessible_initialize (AtkObject *accessible,
gpointer data)
{
ATK_OBJECT_CLASS (gtk_frame_accessible_parent_class)->initialize (accessible, data);
accessible->role = ATK_ROLE_PANEL;
}
static const gchar *
gtk_frame_accessible_get_name (AtkObject *obj)
{
const gchar *name;
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return NULL;
name = ATK_OBJECT_CLASS (gtk_frame_accessible_parent_class)->get_name (obj);
if (name != NULL)
return name;
return gtk_frame_get_label (GTK_FRAME (widget));
}
static void
gtk_frame_accessible_class_init (GtkFrameAccessibleClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
class->initialize = gtk_frame_accessible_initialize;
class->get_name = gtk_frame_accessible_get_name;
}
static void
gtk_frame_accessible_init (GtkFrameAccessible *frame)
{
}

View File

@@ -0,0 +1,57 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_FRAME_ACCESSIBLE_H__
#define __GTK_FRAME_ACCESSIBLE_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <gtk/a11y/gtkwidgetaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_FRAME_ACCESSIBLE (gtk_frame_accessible_get_type ())
#define GTK_FRAME_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FRAME_ACCESSIBLE, GtkFrameAccessible))
#define GTK_FRAME_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FRAME_ACCESSIBLE, GtkFrameAccessibleClass))
#define GTK_IS_FRAME_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FRAME_ACCESSIBLE))
#define GTK_IS_FRAME_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FRAME_ACCESSIBLE))
#define GTK_FRAME_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FRAME_ACCESSIBLE, GtkFrameAccessibleClass))
typedef struct _GtkFrameAccessible GtkFrameAccessible;
typedef struct _GtkFrameAccessibleClass GtkFrameAccessibleClass;
typedef struct _GtkFrameAccessiblePrivate GtkFrameAccessiblePrivate;
struct _GtkFrameAccessible
{
GtkWidgetAccessible parent;
GtkFrameAccessiblePrivate *priv;
};
struct _GtkFrameAccessibleClass
{
GtkWidgetAccessibleClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType gtk_frame_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_FRAME_ACCESSIBLE_H__ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,54 @@
/* GTK+ - accessibility implementations
* Copyright (C) 2002, 2004 Anders Carlsson <andersca@gnu.org>
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_ICON_VIEW_ACCESSIBLE_H__
#define __GTK_ICON_VIEW_ACCESSIBLE_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <gtk/a11y/gtkwidgetaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_ICON_VIEW_ACCESSIBLE (gtk_icon_view_accessible_get_type ())
#define GTK_ICON_VIEW_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ICON_VIEW_ACCESSIBLE, GtkIconViewAccessible))
#define GTK_ICON_VIEW_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ICON_VIEW_ACCESSIBLE, GtkIconViewAccessibleClass))
#define GTK_IS_ICON_VIEW_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ICON_VIEW_ACCESSIBLE))
#define GTK_IS_ICON_VIEW_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ICON_VIEW_ACCESSIBLE))
#define GTK_ICON_VIEW_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ICON_VIEW_ACCESSIBLE, GtkIconViewAccessibleClass))
typedef struct _GtkIconViewAccessible GtkIconViewAccessible;
typedef struct _GtkIconViewAccessibleClass GtkIconViewAccessibleClass;
struct _GtkIconViewAccessible
{
GtkWidgetAccessible parent;
};
struct _GtkIconViewAccessibleClass
{
GtkWidgetAccessibleClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType gtk_icon_view_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_ICON_VIEW_ACCESSIBLE_H__ */

View File

@@ -0,0 +1,33 @@
/* GTK+ - accessibility implementations
* Copyright (C) 2002, 2004 Anders Carlsson <andersca@gnu.org>
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_ICON_VIEW_ACCESSIBLE_PRIVATE_H__
#define __GTK_ICON_VIEW_ACCESSIBLE_PRIVATE_H__
#include <gtk/a11y/gtkiconviewaccessible.h>
#include <gtk/gtkiconview.h>
G_BEGIN_DECLS
void gtk_icon_view_accessible_adjustment_changed (GtkIconViewAccessible *self);
void gtk_icon_view_accessible_update_model (GtkIconViewAccessible *self,
GtkTreeModel *model);
G_END_DECLS
#endif /* __GTK_ICON_VIEW_ACCESSIBLE_PRIVATE_H__ */

View File

@@ -0,0 +1,338 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "gtkimageaccessible.h"
#include "gtkimageprivate.h"
#include "gtkintl.h"
struct _GtkImageAccessiblePrivate
{
gchar *image_description;
gchar *stock_name;
};
static void atk_image_interface_init (AtkImageIface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkImageAccessible, gtk_image_accessible, GTK_TYPE_WIDGET_ACCESSIBLE,
G_ADD_PRIVATE (GtkImageAccessible)
G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE, atk_image_interface_init))
static void
gtk_image_accessible_initialize (AtkObject *accessible,
gpointer data)
{
ATK_OBJECT_CLASS (gtk_image_accessible_parent_class)->initialize (accessible, data);
accessible->role = ATK_ROLE_ICON;
}
typedef struct {
const gchar *name;
const gchar *label;
} NameMapEntry;
static const NameMapEntry name_map[] = {
{ "help-about", NC_("Stock label", "_About") },
{ "list-add", NC_("Stock label", "_Add") },
{ "format-text-bold", NC_("Stock label", "_Bold") },
{ "media-optical", NC_("Stock label", "_CD-ROM") },
{ "edit-clear", NC_("Stock label", "_Clear") },
{ "window-close", NC_("Stock label", "_Close") },
{ "window-minimize", N_("Minimize") },
{ "window-maximize", N_("Maximize") },
{ "window-restore", N_("Restore") },
{ "edit-copy", NC_("Stock label", "_Copy") },
{ "edit-cut", NC_("Stock label", "Cu_t") },
{ "edit-delete", NC_("Stock label", "_Delete") },
{ "dialog-error", NC_("Stock label", "Error") },
{ "dialog-information", NC_("Stock label", "Information") },
{ "dialog-question", NC_("Stock label", "Question") },
{ "dialog-warning", NC_("Stock label", "Warning") },
{ "system-run", NC_("Stock label", "_Execute") },
{ "text-x-generic", NC_("Stock label", "_File") },
{ "edit-find", NC_("Stock label", "_Find") },
{ "edit-find-replace", NC_("Stock label", "Find and _Replace") },
{ "media-floppy", NC_("Stock label", "_Floppy") },
{ "view-fullscreen", NC_("Stock label", "_Fullscreen") },
{ "go-bottom", NC_("Stock label, navigation", "_Bottom") },
{ "go-first", NC_("Stock label, navigation", "_First") },
{ "go-last", NC_("Stock label, navigation", "_Last") },
{ "go-top", NC_("Stock label, navigation", "_Top") },
{ "go-previous", NC_("Stock label, navigation", "_Back") },
{ "go-down", NC_("Stock label, navigation", "_Down") },
{ "go-next", NC_("Stock label, navigation", "_Forward") },
{ "go-up", NC_("Stock label, navigation", "_Up") },
{ "drive-harddisk", NC_("Stock label", "_Hard Disk") },
{ "help-contents", NC_("Stock label", "_Help") },
{ "go-home", NC_("Stock label", "_Home") },
{ "format-indent-more", NC_("Stock label", "Increase Indent") },
{ "format-text-italic", NC_("Stock label", "_Italic") },
{ "go-jump", NC_("Stock label", "_Jump to") },
{ "format-justify-center", NC_("Stock label", "_Center") },
{ "format-justify-fill", NC_("Stock label", "_Fill") },
{ "format-justify-left", NC_("Stock label", "_Left") },
{ "format-justify-right", NC_("Stock label", "_Right") },
{ "view-restore", NC_("Stock label", "_Leave Fullscreen") },
{ "media-seek-forward", NC_("Stock label, media", "_Forward") },
{ "media-skip-forward", NC_("Stock label, media", "_Next") },
{ "media-playback-pause", NC_("Stock label, media", "P_ause") },
{ "media-playback-start", NC_("Stock label, media", "_Play") },
{ "media-skip-backward", NC_("Stock label, media", "Pre_vious") },
{ "media-record", NC_("Stock label, media", "_Record") },
{ "media-seek-backward", NC_("Stock label, media", "R_ewind") },
{ "media-playback-stop", NC_("Stock label, media", "_Stop") },
{ "network-idle", NC_("Stock label", "_Network") },
{ "document-new", NC_("Stock label", "_New") },
{ "document-open", NC_("Stock label", "_Open") },
{ "edit-paste", NC_("Stock label", "_Paste") },
{ "document-print", NC_("Stock label", "_Print") },
{ "document-print-preview", NC_("Stock label", "Print Pre_view") },
{ "document-properties", NC_("Stock label", "_Properties") },
{ "application-exit", NC_("Stock label", "_Quit") },
{ "edit-redo", NC_("Stock label", "_Redo") },
{ "view-refresh", NC_("Stock label", "_Refresh") },
{ "list-remove", NC_("Stock label", "_Remove") },
{ "document-revert", NC_("Stock label", "_Revert") },
{ "document-save", NC_("Stock label", "_Save") },
{ "document-save-as", NC_("Stock label", "Save _As") },
{ "edit-select-all", NC_("Stock label", "Select _All") },
{ "view-sort-ascending", NC_("Stock label", "_Ascending") },
{ "view-sort-descending", NC_("Stock label", "_Descending") },
{ "tools-check-spelling", NC_("Stock label", "_Spell Check") },
{ "process-stop", NC_("Stock label", "_Stop") },
{ "format-text-strikethrough", NC_("Stock label", "_Strikethrough") },
{ "format-text-underline", NC_("Stock label", "_Underline") },
{ "edit-undo", NC_("Stock label", "_Undo") },
{ "format-indent-less", NC_("Stock label", "Decrease Indent") },
{ "zoom-original", NC_("Stock label", "_Normal Size") },
{ "zoom-fit-best", NC_("Stock label", "Best _Fit") },
{ "zoom-in", NC_("Stock label", "Zoom _In") },
{ "zoom-out", NC_("Stock label", "Zoom _Out") }
};
/* GTK+ internal methods */
static gchar *
elide_underscores (const gchar *original)
{
gchar *q, *result;
const gchar *p, *end;
gsize len;
gboolean last_underscore;
if (!original)
return NULL;
len = strlen (original);
q = result = g_malloc (len + 1);
last_underscore = FALSE;
end = original + len;
for (p = original; p < end; p++)
{
if (!last_underscore && *p == '_')
last_underscore = TRUE;
else
{
last_underscore = FALSE;
if (original + 2 <= p && p + 1 <= end &&
p[-2] == '(' && p[-1] == '_' && p[0] != '_' && p[1] == ')')
{
q--;
*q = '\0';
p++;
}
else
*q++ = *p;
}
}
if (last_underscore)
*q++ = '_';
*q = '\0';
return result;
}
static gchar *
name_from_icon_name (const gchar *icon_name)
{
gchar *name;
const gchar *label;
gint i;
name = g_strdup (icon_name);
if (g_str_has_suffix (name, "-symbolic"))
name[strlen (name) - strlen ("-symbolic")] = '\0';
for (i = 0; i < G_N_ELEMENTS (name_map); i++)
{
if (g_str_equal (name, name_map[i].name))
{
label = g_dpgettext2 (GETTEXT_PACKAGE, "Stock label", name_map[i].label);
g_free (name);
return elide_underscores (label);
}
}
g_free (name);
return NULL;
}
static void
gtk_image_accessible_finalize (GObject *object)
{
GtkImageAccessible *aimage = GTK_IMAGE_ACCESSIBLE (object);
g_free (aimage->priv->image_description);
g_free (aimage->priv->stock_name);
G_OBJECT_CLASS (gtk_image_accessible_parent_class)->finalize (object);
}
static const gchar *
gtk_image_accessible_get_name (AtkObject *accessible)
{
GtkWidget* widget;
GtkImage *image;
GtkImageAccessible *image_accessible;
const gchar *name;
GtkImageType storage_type;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
if (widget == NULL)
return NULL;
name = ATK_OBJECT_CLASS (gtk_image_accessible_parent_class)->get_name (accessible);
if (name)
return name;
image = GTK_IMAGE (widget);
image_accessible = GTK_IMAGE_ACCESSIBLE (accessible);
g_free (image_accessible->priv->stock_name);
image_accessible->priv->stock_name = NULL;
storage_type = gtk_image_get_storage_type (image);
if (storage_type == GTK_IMAGE_ICON_NAME)
{
image_accessible->priv->stock_name = name_from_icon_name (gtk_image_get_icon_name (image));
}
else if (storage_type == GTK_IMAGE_GICON)
{
GIcon *icon;
const gchar * const *icon_names;
icon = gtk_image_get_gicon (image);
if (G_IS_THEMED_ICON (icon))
{
icon_names = g_themed_icon_get_names (G_THEMED_ICON (icon));
image_accessible->priv->stock_name = name_from_icon_name (icon_names[0]);
}
}
return image_accessible->priv->stock_name;
}
static void
gtk_image_accessible_class_init (GtkImageAccessibleClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
gobject_class->finalize = gtk_image_accessible_finalize;
class->initialize = gtk_image_accessible_initialize;
class->get_name = gtk_image_accessible_get_name;
}
static void
gtk_image_accessible_init (GtkImageAccessible *image)
{
image->priv = gtk_image_accessible_get_instance_private (image);
}
static const gchar *
gtk_image_accessible_get_image_description (AtkImage *image)
{
GtkImageAccessible *accessible = GTK_IMAGE_ACCESSIBLE (image);
return accessible->priv->image_description;
}
static void
gtk_image_accessible_get_image_position (AtkImage *image,
gint *x,
gint *y,
AtkCoordType coord_type)
{
atk_component_get_extents (ATK_COMPONENT (image), x, y, NULL, NULL,
coord_type);
}
static void
gtk_image_accessible_get_image_size (AtkImage *image,
gint *width,
gint *height)
{
GtkWidget* widget;
GtkImage *gtk_image;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (image));
if (widget == NULL)
{
*height = -1;
*width = -1;
return;
}
gtk_image = GTK_IMAGE (widget);
if (gtk_image_get_storage_type (gtk_image) != GTK_IMAGE_EMPTY)
gtk_image_get_image_size (gtk_image, width, height);
else
{
*height = 0;
*width = 0;
}
}
static gboolean
gtk_image_accessible_set_image_description (AtkImage *image,
const gchar *description)
{
GtkImageAccessible* accessible = GTK_IMAGE_ACCESSIBLE (image);
g_free (accessible->priv->image_description);
accessible->priv->image_description = g_strdup (description);
return TRUE;
}
static void
atk_image_interface_init (AtkImageIface *iface)
{
iface->get_image_description = gtk_image_accessible_get_image_description;
iface->get_image_position = gtk_image_accessible_get_image_position;
iface->get_image_size = gtk_image_accessible_get_image_size;
iface->set_image_description = gtk_image_accessible_set_image_description;
}

View File

@@ -0,0 +1,57 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_IMAGE_ACCESSIBLE_H__
#define __GTK_IMAGE_ACCESSIBLE_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <gtk/a11y/gtkwidgetaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_IMAGE_ACCESSIBLE (gtk_image_accessible_get_type ())
#define GTK_IMAGE_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_IMAGE_ACCESSIBLE, GtkImageAccessible))
#define GTK_IMAGE_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_IMAGE_ACCESSIBLE, GtkImageAccessibleClass))
#define GTK_IS_IMAGE_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_IMAGE_ACCESSIBLE))
#define GTK_IS_IMAGE_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_IMAGE_ACCESSIBLE))
#define GTK_IMAGE_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_IMAGE_ACCESSIBLE, GtkImageAccessibleClass))
typedef struct _GtkImageAccessible GtkImageAccessible;
typedef struct _GtkImageAccessibleClass GtkImageAccessibleClass;
typedef struct _GtkImageAccessiblePrivate GtkImageAccessiblePrivate;
struct _GtkImageAccessible
{
GtkWidgetAccessible parent;
GtkImageAccessiblePrivate *priv;
};
struct _GtkImageAccessibleClass
{
GtkWidgetAccessibleClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType gtk_image_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_IMAGE_ACCESSIBLE_H__ */

View File

@@ -0,0 +1,123 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "gtkimagecellaccessible.h"
struct _GtkImageCellAccessiblePrivate
{
gchar *image_description;
};
static void atk_image_interface_init (AtkImageIface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkImageCellAccessible, gtk_image_cell_accessible, GTK_TYPE_RENDERER_CELL_ACCESSIBLE,
G_ADD_PRIVATE (GtkImageCellAccessible)
G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE, atk_image_interface_init))
static void
gtk_image_cell_accessible_finalize (GObject *object)
{
GtkImageCellAccessible *image_cell = GTK_IMAGE_CELL_ACCESSIBLE (object);
g_free (image_cell->priv->image_description);
G_OBJECT_CLASS (gtk_image_cell_accessible_parent_class)->finalize (object);
}
static void
gtk_image_cell_accessible_class_init (GtkImageCellAccessibleClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = gtk_image_cell_accessible_finalize;
}
static void
gtk_image_cell_accessible_init (GtkImageCellAccessible *image_cell)
{
image_cell->priv = gtk_image_cell_accessible_get_instance_private (image_cell);
}
static const gchar *
gtk_image_cell_accessible_get_image_description (AtkImage *image)
{
GtkImageCellAccessible *image_cell = GTK_IMAGE_CELL_ACCESSIBLE (image);
return image_cell->priv->image_description;
}
static gboolean
gtk_image_cell_accessible_set_image_description (AtkImage *image,
const gchar *description)
{
GtkImageCellAccessible *image_cell = GTK_IMAGE_CELL_ACCESSIBLE (image);
g_free (image_cell->priv->image_description);
image_cell->priv->image_description = g_strdup (description);
if (image_cell->priv->image_description)
return TRUE;
else
return FALSE;
}
static void
gtk_image_cell_accessible_get_image_position (AtkImage *image,
gint *x,
gint *y,
AtkCoordType coord_type)
{
atk_component_get_extents (ATK_COMPONENT (image), x, y, NULL, NULL,
coord_type);
}
static void
gtk_image_cell_accessible_get_image_size (AtkImage *image,
gint *width,
gint *height)
{
GtkImageCellAccessible *cell = GTK_IMAGE_CELL_ACCESSIBLE (image);
GtkCellRenderer *cell_renderer;
GdkPixbuf *pixbuf = NULL;
*width = 0;
*height = 0;
g_object_get (cell, "renderer", &cell_renderer, NULL);
g_object_get (cell_renderer,
"pixbuf", &pixbuf,
NULL);
g_object_unref (cell_renderer);
if (pixbuf)
{
*width = gdk_pixbuf_get_width (pixbuf);
*height = gdk_pixbuf_get_height (pixbuf);
g_object_unref (pixbuf);
}
}
static void
atk_image_interface_init (AtkImageIface *iface)
{
iface->get_image_description = gtk_image_cell_accessible_get_image_description;
iface->set_image_description = gtk_image_cell_accessible_set_image_description;
iface->get_image_position = gtk_image_cell_accessible_get_image_position;
iface->get_image_size = gtk_image_cell_accessible_get_image_size;
}

View File

@@ -0,0 +1,58 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_IMAGE_CELL_ACCESSIBLE_H__
#define __GTK_IMAGE_CELL_ACCESSIBLE_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <atk/atk.h>
#include <gtk/a11y/gtkrenderercellaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_IMAGE_CELL_ACCESSIBLE (gtk_image_cell_accessible_get_type ())
#define GTK_IMAGE_CELL_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_IMAGE_CELL_ACCESSIBLE, GtkImageCellAccessible))
#define GTK_IMAGE_CELL_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_IMAGE_CELL_ACCESSIBLE, GtkImageCellAccessibleClass))
#define GTK_IS_IMAGE_CELL_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_IMAGE_CELL_ACCESSIBLE))
#define GTK_IS_IMAGE_CELL_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_IMAGE_CELL_ACCESSIBLE))
#define GTK_IMAGE_CELL_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_IMAGE_CELL_ACCESSIBLE, GtkImageCellAccessibleClass))
typedef struct _GtkImageCellAccessible GtkImageCellAccessible;
typedef struct _GtkImageCellAccessibleClass GtkImageCellAccessibleClass;
typedef struct _GtkImageCellAccessiblePrivate GtkImageCellAccessiblePrivate;
struct _GtkImageCellAccessible
{
GtkRendererCellAccessible parent;
GtkImageCellAccessiblePrivate *priv;
};
struct _GtkImageCellAccessibleClass
{
GtkRendererCellAccessibleClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType gtk_image_cell_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_IMAGE_CELL_ACCESSIBLE_H__ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,57 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_LABEL_ACCESSIBLE_H__
#define __GTK_LABEL_ACCESSIBLE_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <gtk/a11y/gtkwidgetaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_LABEL_ACCESSIBLE (gtk_label_accessible_get_type ())
#define GTK_LABEL_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_LABEL_ACCESSIBLE, GtkLabelAccessible))
#define GTK_LABEL_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_LABEL_ACCESSIBLE, GtkLabelAccessibleClass))
#define GTK_IS_LABEL_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_LABEL_ACCESSIBLE))
#define GTK_IS_LABEL_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_LABEL_ACCESSIBLE))
#define GTK_LABEL_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_LABEL_ACCESSIBLE, GtkLabelAccessibleClass))
typedef struct _GtkLabelAccessible GtkLabelAccessible;
typedef struct _GtkLabelAccessibleClass GtkLabelAccessibleClass;
typedef struct _GtkLabelAccessiblePrivate GtkLabelAccessiblePrivate;
struct _GtkLabelAccessible
{
GtkWidgetAccessible parent;
GtkLabelAccessiblePrivate *priv;
};
struct _GtkLabelAccessibleClass
{
GtkWidgetAccessibleClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType gtk_label_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_LABEL_ACCESSIBLE_H__ */

View File

@@ -0,0 +1,34 @@
/* GTK+ - accessibility implementations
* Copyright (C) 2002, 2004 Anders Carlsson <andersca@gnu.org>
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_LABEL_ACCESSIBLE_PRIVATE_H__
#define __GTK_LABEL_ACCESSIBLE_PRIVATE_H__
#include <gtk/a11y/gtklabelaccessible.h>
G_BEGIN_DECLS
void _gtk_label_accessible_text_deleted (GtkLabel *label);
void _gtk_label_accessible_text_inserted (GtkLabel *label);
void _gtk_label_accessible_update_links (GtkLabel *label);
void _gtk_label_accessible_focus_link_changed (GtkLabel *label);
void _gtk_label_accessible_selection_bound_changed (GtkLabel *label);
void _gtk_label_accessible_cursor_position_changed (GtkLabel *label);
G_END_DECLS
#endif /* __GTK_LABEL_ACCESSIBLE_PRIVATE_H__ */

View File

@@ -0,0 +1,178 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
* Copyright 2013 SUSE LLC.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtklevelbaraccessible.h"
#include "gtklevelbar.h"
#include <string.h>
static void atk_value_interface_init (AtkValueIface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkLevelBarAccessible, gtk_level_bar_accessible, GTK_TYPE_WIDGET_ACCESSIBLE,
G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init))
static void
on_value_changed (GObject *gobject,
GParamSpec *pspec,
gpointer user_data)
{
GtkLevelBarAccessible *self = user_data;
g_object_notify (G_OBJECT (self), "accessible-value");
}
static void
gtk_level_bar_accessible_initialize (AtkObject *object,
gpointer data)
{
GtkLevelBar *level_bar = data;
g_signal_connect (level_bar, "notify::value", G_CALLBACK (on_value_changed), object);
}
static void
gtk_level_bar_accessible_class_init (GtkLevelBarAccessibleClass *klass)
{
AtkObjectClass *object_class = ATK_OBJECT_CLASS (klass);
object_class->initialize = gtk_level_bar_accessible_initialize;
}
static void
gtk_level_bar_accessible_init (GtkLevelBarAccessible *self)
{
ATK_OBJECT (self)->role = ATK_ROLE_LEVEL_BAR;
}
static void
gtk_level_bar_accessible_get_current_value (AtkValue *obj,
GValue *value)
{
GtkWidget *widget;
GtkLevelBar *level_bar;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
level_bar = GTK_LEVEL_BAR (widget);
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_level_bar_get_value (level_bar));
}
static void
gtk_level_bar_accessible_get_maximum_value (AtkValue *obj,
GValue *value)
{
GtkWidget *widget;
GtkLevelBar *level_bar;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
level_bar = GTK_LEVEL_BAR (widget);
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_level_bar_get_max_value (level_bar));
}
static void
gtk_level_bar_accessible_get_minimum_value (AtkValue *obj,
GValue *value)
{
GtkWidget *widget;
GtkLevelBar *level_bar;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
level_bar = GTK_LEVEL_BAR (widget);
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_level_bar_get_min_value (level_bar));
}
static gboolean
gtk_level_bar_accessible_set_current_value (AtkValue *obj,
const GValue *value)
{
GtkWidget *widget;
GtkLevelBar *level_bar;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
level_bar = GTK_LEVEL_BAR (widget);
gtk_level_bar_set_value (level_bar, g_value_get_double (value));
return TRUE;
}
static void
gtk_level_bar_accessible_get_value_and_text (AtkValue *obj,
gdouble *value,
gchar **text)
{
GtkWidget *widget;
GtkLevelBar *level_bar;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
level_bar = GTK_LEVEL_BAR (widget);
*value = gtk_level_bar_get_value (level_bar);
*text = NULL;
}
static AtkRange *
gtk_level_bar_accessible_get_range (AtkValue *obj)
{
GtkWidget *widget;
GtkLevelBar *level_bar;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
level_bar = GTK_LEVEL_BAR (widget);
return atk_range_new (gtk_level_bar_get_min_value (level_bar),
gtk_level_bar_get_max_value (level_bar),
NULL);
}
static void
gtk_level_bar_accessible_set_value (AtkValue *obj,
const gdouble value)
{
GtkWidget *widget;
GtkLevelBar *level_bar;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
level_bar = GTK_LEVEL_BAR (widget);
gtk_level_bar_set_value (level_bar, value);
}
static void
atk_value_interface_init (AtkValueIface *iface)
{
iface->get_current_value = gtk_level_bar_accessible_get_current_value;
iface->get_maximum_value = gtk_level_bar_accessible_get_maximum_value;
iface->get_minimum_value = gtk_level_bar_accessible_get_minimum_value;
iface->set_current_value = gtk_level_bar_accessible_set_current_value;
iface->get_value_and_text = gtk_level_bar_accessible_get_value_and_text;
iface->get_range = gtk_level_bar_accessible_get_range;
iface->set_value = gtk_level_bar_accessible_set_value;
}

View File

@@ -0,0 +1,58 @@
/* GAIL - The GNOME Accessibility Implementation Library
* Copyright 2001 Sun Microsystems Inc.
* Copyright 2013 SUSE LLC.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_LEVEL_BAR_ACCESSIBLE_H__
#define __GTK_LEVEL_BAR_ACCESSIBLE_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <gtk/a11y/gtkwidgetaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_LEVEL_BAR_ACCESSIBLE (gtk_level_bar_accessible_get_type ())
#define GTK_LEVEL_BAR_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_LEVEL_BAR_ACCESSIBLE, GtkLevelBarAccessible))
#define GTK_LEVEL_BAR_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_LEVEL_BAR_ACCESSIBLE, GtkLevelBarAccessibleClass))
#define GTK_IS_LEVEL_BAR_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_LEVEL_BAR_ACCESSIBLE))
#define GTK_IS_LEVEL_BAR_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_LEVEL_BAR_ACCESSIBLE))
#define GTK_LEVEL_BAR_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_LEVEL_BAR_ACCESSIBLE, GtkLevelBarAccessibleClass))
typedef struct _GtkLevelBarAccessible GtkLevelBarAccessible;
typedef struct _GtkLevelBarAccessibleClass GtkLevelBarAccessibleClass;
typedef struct _GtkLevelBarAccessiblePrivate GtkLevelBarAccessiblePrivate;
struct _GtkLevelBarAccessible
{
GtkWidgetAccessible parent;
GtkLevelBarAccessiblePrivate *priv;
};
struct _GtkLevelBarAccessibleClass
{
GtkWidgetAccessibleClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType gtk_level_bar_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_LEVEL_BAR_ACCESSIBLE_H__ */

View File

@@ -0,0 +1,234 @@
/* GTK+ - accessibility implementations
* Copyright 2011 Red Hat, Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "gtklinkbuttonaccessible.h"
typedef struct _GtkLinkButtonAccessibleLink GtkLinkButtonAccessibleLink;
typedef struct _GtkLinkButtonAccessibleLinkClass GtkLinkButtonAccessibleLinkClass;
struct _GtkLinkButtonAccessiblePrivate
{
AtkHyperlink *link;
};
struct _GtkLinkButtonAccessibleLink
{
AtkHyperlink parent;
GtkLinkButtonAccessible *button;
};
struct _GtkLinkButtonAccessibleLinkClass
{
AtkHyperlinkClass parent_class;
};
static void atk_action_interface_init (AtkActionIface *iface);
GType _gtk_link_button_accessible_link_get_type (void);
G_DEFINE_TYPE_WITH_CODE (GtkLinkButtonAccessibleLink, _gtk_link_button_accessible_link, ATK_TYPE_HYPERLINK,
G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init))
static AtkHyperlink *
gtk_link_button_accessible_link_new (GtkLinkButtonAccessible *button)
{
GtkLinkButtonAccessibleLink *l;
l = g_object_new (_gtk_link_button_accessible_link_get_type (), NULL);
l->button = button;
return ATK_HYPERLINK (l);
}
static gchar *
gtk_link_button_accessible_link_get_uri (AtkHyperlink *atk_link,
gint i)
{
GtkLinkButtonAccessibleLink *l = (GtkLinkButtonAccessibleLink *)atk_link;
GtkWidget *widget;
const gchar *uri;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (l->button));
uri = gtk_link_button_get_uri (GTK_LINK_BUTTON (widget));
return g_strdup (uri);
}
static gint
gtk_link_button_accessible_link_get_n_anchors (AtkHyperlink *atk_link)
{
return 1;
}
static gboolean
gtk_link_button_accessible_link_is_valid (AtkHyperlink *atk_link)
{
return TRUE;
}
static AtkObject *
gtk_link_button_accessible_link_get_object (AtkHyperlink *atk_link,
gint i)
{
GtkLinkButtonAccessibleLink *l = (GtkLinkButtonAccessibleLink *)atk_link;
return ATK_OBJECT (l->button);
}
static void
_gtk_link_button_accessible_link_init (GtkLinkButtonAccessibleLink *l)
{
}
static void
_gtk_link_button_accessible_link_class_init (GtkLinkButtonAccessibleLinkClass *class)
{
AtkHyperlinkClass *atk_link_class = ATK_HYPERLINK_CLASS (class);
atk_link_class->get_uri = gtk_link_button_accessible_link_get_uri;
atk_link_class->get_n_anchors = gtk_link_button_accessible_link_get_n_anchors;
atk_link_class->is_valid = gtk_link_button_accessible_link_is_valid;
atk_link_class->get_object = gtk_link_button_accessible_link_get_object;
}
static gboolean
gtk_link_button_accessible_link_do_action (AtkAction *action,
gint i)
{
GtkLinkButtonAccessibleLink *l = (GtkLinkButtonAccessibleLink *)action;
GtkWidget *widget;
widget = GTK_WIDGET (l->button);
if (widget == NULL)
return FALSE;
if (i != 0)
return FALSE;
if (!gtk_widget_is_sensitive (widget) || !gtk_widget_get_visible (widget))
return FALSE;
g_signal_emit_by_name (widget, "clicked");
return TRUE;
}
static gint
gtk_link_button_accessible_link_get_n_actions (AtkAction *action)
{
return 1;
}
static const gchar *
gtk_link_button_accessible_link_get_name (AtkAction *action,
gint i)
{
if (i != 0)
return NULL;
return "activate";
}
static void
atk_action_interface_init (AtkActionIface *iface)
{
iface->do_action = gtk_link_button_accessible_link_do_action;
iface->get_n_actions = gtk_link_button_accessible_link_get_n_actions;
iface->get_name = gtk_link_button_accessible_link_get_name;
}
static gboolean
activate_link (GtkLinkButton *button,
AtkHyperlink *atk_link)
{
g_signal_emit_by_name (atk_link, "link-activated");
return FALSE;
}
static AtkHyperlink *
gtk_link_button_accessible_get_hyperlink (AtkHyperlinkImpl *impl)
{
GtkLinkButtonAccessible *button = GTK_LINK_BUTTON_ACCESSIBLE (impl);
if (!button->priv->link)
{
button->priv->link = gtk_link_button_accessible_link_new (button);
g_signal_connect (gtk_accessible_get_widget (GTK_ACCESSIBLE (button)),
"activate-link", G_CALLBACK (activate_link), button->priv->link);
}
return g_object_ref (button->priv->link);
}
static void atk_hypertext_impl_interface_init (AtkHyperlinkImplIface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkLinkButtonAccessible, gtk_link_button_accessible, GTK_TYPE_BUTTON_ACCESSIBLE,
G_ADD_PRIVATE (GtkLinkButtonAccessible)
G_IMPLEMENT_INTERFACE (ATK_TYPE_HYPERLINK_IMPL, atk_hypertext_impl_interface_init))
static void
gtk_link_button_accessible_init (GtkLinkButtonAccessible *button)
{
button->priv = gtk_link_button_accessible_get_instance_private (button);
}
static void
gtk_link_button_accessible_finalize (GObject *object)
{
GtkLinkButtonAccessible *button = GTK_LINK_BUTTON_ACCESSIBLE (object);
if (button->priv->link)
g_object_unref (button->priv->link);
G_OBJECT_CLASS (gtk_link_button_accessible_parent_class)->finalize (object);
}
static AtkStateSet *
gtk_link_button_ref_state_set (AtkObject *accessible)
{
AtkStateSet *state_set;
GtkWidget *widget;
state_set = ATK_OBJECT_CLASS (gtk_link_button_accessible_parent_class)->ref_state_set (accessible);
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
if (widget != NULL)
{
if (gtk_link_button_get_visited (GTK_LINK_BUTTON (widget)))
atk_state_set_add_state (state_set, ATK_STATE_VISITED);
}
return state_set;
}
static void
gtk_link_button_accessible_class_init (GtkLinkButtonAccessibleClass *klass)
{
G_OBJECT_CLASS (klass)->finalize = gtk_link_button_accessible_finalize;
ATK_OBJECT_CLASS (klass)->ref_state_set = gtk_link_button_ref_state_set;
}
static void
atk_hypertext_impl_interface_init (AtkHyperlinkImplIface *iface)
{
iface->get_hyperlink = gtk_link_button_accessible_get_hyperlink;
}

View File

@@ -0,0 +1,57 @@
/* GTK+ - accessibility implementations
* Copyright 2011 Red Hat, Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_LINK_BUTTON_ACCESSIBLE_H__
#define __GTK_LINK_BUTTON_ACCESSIBLE_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <gtk/a11y/gtkbuttonaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_LINK_BUTTON_ACCESSIBLE (gtk_link_button_accessible_get_type ())
#define GTK_LINK_BUTTON_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_LINK_BUTTON_ACCESSIBLE, GtkLinkButtonAccessible))
#define GTK_LINK_BUTTON_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_LINK_BUTTON_ACCESSIBLE, GtkLinkButtonAccessibleClass))
#define GTK_IS_LINK_BUTTON_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_LINK_BUTTON_ACCESSIBLE))
#define GTK_IS_LINK_BUTTON_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_LINK_BUTTON_ACCESSIBLE))
#define GTK_LINK_BUTTON_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_LINK_BUTTON_ACCESSIBLE, GtkLinkButtonAccessibleClass))
typedef struct _GtkLinkButtonAccessible GtkLinkButtonAccessible;
typedef struct _GtkLinkButtonAccessibleClass GtkLinkButtonAccessibleClass;
typedef struct _GtkLinkButtonAccessiblePrivate GtkLinkButtonAccessiblePrivate;
struct _GtkLinkButtonAccessible
{
GtkButtonAccessible parent;
GtkLinkButtonAccessiblePrivate *priv;
};
struct _GtkLinkButtonAccessibleClass
{
GtkButtonAccessibleClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType gtk_link_button_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_LINK_BUTTON_ACCESSIBLE_H__ */

View File

@@ -0,0 +1,248 @@
/*
* Copyright (C) 2013 Red Hat, Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtklistboxaccessibleprivate.h"
#include "gtk/gtklistbox.h"
static void atk_selection_interface_init (AtkSelectionIface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkListBoxAccessible, gtk_list_box_accessible, GTK_TYPE_WIDGET_ACCESSIBLE,
G_IMPLEMENT_INTERFACE (ATK_TYPE_SELECTION, atk_selection_interface_init))
static void
gtk_list_box_accessible_init (GtkListBoxAccessible *accessible)
{
}
static void
gtk_list_box_accessible_initialize (AtkObject *obj,
gpointer data)
{
ATK_OBJECT_CLASS (gtk_list_box_accessible_parent_class)->initialize (obj, data);
obj->role = ATK_ROLE_LIST_BOX;
}
static AtkStateSet*
gtk_list_box_accessible_ref_state_set (AtkObject *obj)
{
AtkStateSet *state_set;
GtkWidget *widget;
state_set = ATK_OBJECT_CLASS (gtk_list_box_accessible_parent_class)->ref_state_set (obj);
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget != NULL)
atk_state_set_add_state (state_set, ATK_STATE_MANAGES_DESCENDANTS);
return state_set;
}
static void
gtk_list_box_accessible_class_init (GtkListBoxAccessibleClass *klass)
{
AtkObjectClass *object_class = ATK_OBJECT_CLASS (klass);
object_class->initialize = gtk_list_box_accessible_initialize;
object_class->ref_state_set = gtk_list_box_accessible_ref_state_set;
}
static gboolean
gtk_list_box_accessible_add_selection (AtkSelection *selection,
gint idx)
{
GtkWidget *box;
GtkListBoxRow *row;
box = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (box == NULL)
return FALSE;
row = gtk_list_box_get_row_at_index (GTK_LIST_BOX (box), idx);
if (row)
{
gtk_list_box_select_row (GTK_LIST_BOX (box), row);
return TRUE;
}
return FALSE;
}
static gboolean
gtk_list_box_accessible_remove_selection (AtkSelection *selection,
gint idx)
{
GtkWidget *box;
GtkListBoxRow *row;
box = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (box == NULL)
return FALSE;
row = gtk_list_box_get_row_at_index (GTK_LIST_BOX (box), idx);
if (row)
{
gtk_list_box_unselect_row (GTK_LIST_BOX (box), row);
return TRUE;
}
return FALSE;
}
static gboolean
gtk_list_box_accessible_clear_selection (AtkSelection *selection)
{
GtkWidget *box;
box = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (box == NULL)
return FALSE;
gtk_list_box_unselect_all (GTK_LIST_BOX (box));
return TRUE;
}
static gboolean
gtk_list_box_accessible_select_all (AtkSelection *selection)
{
GtkWidget *box;
box = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (box == NULL)
return FALSE;
gtk_list_box_select_all (GTK_LIST_BOX (box));
return TRUE;
}
typedef struct
{
gint idx;
GtkWidget *row;
} FindSelectedData;
static void
find_selected_row (GtkListBox *box,
GtkListBoxRow *row,
gpointer data)
{
FindSelectedData *d = data;
if (d->idx == 0)
{
if (d->row == NULL)
d->row = GTK_WIDGET (row);
}
else
d->idx -= 1;
}
static AtkObject *
gtk_list_box_accessible_ref_selection (AtkSelection *selection,
gint idx)
{
GtkWidget *box;
AtkObject *accessible;
FindSelectedData data;
box = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (box == NULL)
return NULL;
data.idx = idx;
data.row = NULL;
gtk_list_box_selected_foreach (GTK_LIST_BOX (box), find_selected_row, &data);
if (data.row == NULL)
return NULL;
accessible = gtk_widget_get_accessible (data.row);
g_object_ref (accessible);
return accessible;
}
static void
count_selected (GtkListBox *box,
GtkListBoxRow *row,
gpointer data)
{
gint *count = data;
*count += 1;
}
static gint
gtk_list_box_accessible_get_selection_count (AtkSelection *selection)
{
GtkWidget *box;
gint count;
box = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (box == NULL)
return 0;
count = 0;
gtk_list_box_selected_foreach (GTK_LIST_BOX (box), count_selected, &count);
return count;
}
static gboolean
gtk_list_box_accessible_is_child_selected (AtkSelection *selection,
gint idx)
{
GtkWidget *box;
GtkListBoxRow *row;
box = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (box == NULL)
return FALSE;
row = gtk_list_box_get_row_at_index (GTK_LIST_BOX (box), idx);
return gtk_list_box_row_is_selected (row);
}
static void atk_selection_interface_init (AtkSelectionIface *iface)
{
iface->add_selection = gtk_list_box_accessible_add_selection;
iface->remove_selection = gtk_list_box_accessible_remove_selection;
iface->clear_selection = gtk_list_box_accessible_clear_selection;
iface->ref_selection = gtk_list_box_accessible_ref_selection;
iface->get_selection_count = gtk_list_box_accessible_get_selection_count;
iface->is_child_selected = gtk_list_box_accessible_is_child_selected;
iface->select_all_selection = gtk_list_box_accessible_select_all;
}
void
_gtk_list_box_accessible_selection_changed (GtkListBox *box)
{
AtkObject *accessible;
accessible = gtk_widget_get_accessible (GTK_WIDGET (box));
g_signal_emit_by_name (accessible, "selection-changed");
}
void
_gtk_list_box_accessible_update_cursor (GtkListBox *box,
GtkListBoxRow *row)
{
AtkObject *accessible;
AtkObject *descendant;
accessible = gtk_widget_get_accessible (GTK_WIDGET (box));
descendant = row ? gtk_widget_get_accessible (GTK_WIDGET (row)) : NULL;
g_signal_emit_by_name (accessible, "active-descendant-changed", descendant);
}

View File

@@ -0,0 +1,57 @@
/*
* Copyright (C) 2013 Red Hat, Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_LIST_BOX_ACCESSIBLE_H__
#define __GTK_LIST_BOX_ACCESSIBLE_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <gtk/a11y/gtkwidgetaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_LIST_BOX_ACCESSIBLE (gtk_list_box_accessible_get_type ())
#define GTK_LIST_BOX_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_LIST_BOX_ACCESSIBLE, GtkListBoxAccessible))
#define GTK_LIST_BOX_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_LIST_BOX_ACCESSIBLE, GtkListBoxAccessibleClass))
#define GTK_IS_LIST_BOX_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_LIST_BOX_ACCESSIBLE))
#define GTK_IS_LIST_BOX_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_LIST_BOX_ACCESSIBLE))
#define GTK_LIST_BOX_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_LIST_BOX_ACCESSIBLE, GtkListBoxAccessibleClass))
typedef struct _GtkListBoxAccessible GtkListBoxAccessible;
typedef struct _GtkListBoxAccessibleClass GtkListBoxAccessibleClass;
typedef struct _GtkListBoxAccessiblePrivate GtkListBoxAccessiblePrivate;
struct _GtkListBoxAccessible
{
GtkWidgetAccessible parent;
GtkListBoxAccessiblePrivate *priv;
};
struct _GtkListBoxAccessibleClass
{
GtkWidgetAccessibleClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType gtk_list_box_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_LIST_BOX_ACCESSIBLE_H__ */

View File

@@ -0,0 +1,33 @@
/*
* Copyright (C) 2013 Red Hat, Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_LIST_BOX_ACCESSIBLE_PRIVATE_H__
#define __GTK_LIST_BOX_ACCESSIBLE_PRIVATE_H__
#include <gtk/a11y/gtklistboxaccessible.h>
#include <gtk/gtklistbox.h>
G_BEGIN_DECLS
void _gtk_list_box_accessible_update_cursor (GtkListBox *box,
GtkListBoxRow *row);
void _gtk_list_box_accessible_selection_changed (GtkListBox *box);
G_END_DECLS
#endif /* __GTK_LIST_BOX_ACCESSIBLE_PRIVATE_H__ */

View File

@@ -0,0 +1,72 @@
/*
* Copyright (C) 2013 Red Hat, Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtklistboxrowaccessible.h"
#include "gtk/gtklistbox.h"
G_DEFINE_TYPE (GtkListBoxRowAccessible, gtk_list_box_row_accessible, GTK_TYPE_WIDGET_ACCESSIBLE)
static void
gtk_list_box_row_accessible_init (GtkListBoxRowAccessible *accessible)
{
}
static void
gtk_list_box_row_accessible_initialize (AtkObject *obj,
gpointer data)
{
ATK_OBJECT_CLASS (gtk_list_box_row_accessible_parent_class)->initialize (obj, data);
obj->role = ATK_ROLE_LIST_ITEM;
}
static AtkStateSet*
gtk_list_box_row_accessible_ref_state_set (AtkObject *obj)
{
AtkStateSet *state_set;
GtkWidget *widget, *parent;
state_set = ATK_OBJECT_CLASS (gtk_list_box_row_accessible_parent_class)->ref_state_set (obj);
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget != NULL)
{
parent = gtk_widget_get_parent (widget);
if (parent != NULL &&
GTK_IS_LIST_BOX (parent) &&
gtk_list_box_get_selection_mode (GTK_LIST_BOX (parent)) != GTK_SELECTION_NONE)
atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE);
if (gtk_list_box_row_is_selected (GTK_LIST_BOX_ROW (widget)))
atk_state_set_add_state (state_set, ATK_STATE_SELECTED);
}
return state_set;
}
static void
gtk_list_box_row_accessible_class_init (GtkListBoxRowAccessibleClass *klass)
{
AtkObjectClass *object_class = ATK_OBJECT_CLASS (klass);
object_class->initialize = gtk_list_box_row_accessible_initialize;
object_class->ref_state_set = gtk_list_box_row_accessible_ref_state_set;
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright (C) 2013 Red Hat, Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_LIST_BOX_ROW_ACCESSIBLE_H__
#define __GTK_LIST_BOX_ROW_ACCESSIBLE_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <gtk/a11y/gtkwidgetaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_LIST_BOX_ROW_ACCESSIBLE (gtk_list_box_row_accessible_get_type ())
#define GTK_LIST_BOX_ROW_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_LIST_BOX_ROW_ACCESSIBLE, GtkListBoxRowAccessible))
#define GTK_LIST_BOX_ROW_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_LIST_BOX_ROW_ACCESSIBLE, GtkListBoxRowAccessibleClass))
#define GTK_IS_LIST_BOX_ROW_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_LIST_BOX_ROW_ACCESSIBLE))
#define GTK_IS_LIST_BOX_ROW_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_LIST_BOX_ROW_ACCESSIBLE))
#define GTK_LIST_BOX_ROW_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_LIST_BOX_ROW_ACCESSIBLE, GtkListBoxRowAccessibleClass))
typedef struct _GtkListBoxRowAccessible GtkListBoxRowAccessible;
typedef struct _GtkListBoxRowAccessibleClass GtkListBoxRowAccessibleClass;
struct _GtkListBoxRowAccessible
{
GtkWidgetAccessible parent;
};
struct _GtkListBoxRowAccessibleClass
{
GtkWidgetAccessibleClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType gtk_list_box_row_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_LIST_BOX_ROW_ACCESSIBLE_H__ */

View File

@@ -0,0 +1,63 @@
/* GTK+ - accessibility implementations
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtklockbuttonaccessibleprivate.h"
#include "gtk/gtklockbuttonprivate.h"
#include "gtk/gtkwidgetprivate.h"
G_DEFINE_TYPE (GtkLockButtonAccessible, gtk_lock_button_accessible, GTK_TYPE_BUTTON_ACCESSIBLE)
static const gchar *
gtk_lock_button_accessible_get_name (AtkObject *obj)
{
GtkLockButton *lockbutton;
lockbutton = GTK_LOCK_BUTTON (gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)));
if (lockbutton == NULL)
return NULL;
return _gtk_lock_button_get_current_text (lockbutton);
}
static void
gtk_lock_button_accessible_class_init (GtkLockButtonAccessibleClass *klass)
{
AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass);
atk_object_class->get_name = gtk_lock_button_accessible_get_name;
}
static void
gtk_lock_button_accessible_init (GtkLockButtonAccessible *lockbutton)
{
}
void
_gtk_lock_button_accessible_name_changed (GtkLockButton *lockbutton)
{
AtkObject *obj;
obj = _gtk_widget_peek_accessible (GTK_WIDGET (lockbutton));
if (obj == NULL)
return;
g_object_notify (G_OBJECT (obj), "accessible-name");
}

View File

@@ -0,0 +1,57 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_LOCK_BUTTON_ACCESSIBLE_H__
#define __GTK_LOCK_BUTTON_ACCESSIBLE_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <gtk/a11y/gtkbuttonaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_LOCK_BUTTON_ACCESSIBLE (gtk_lock_button_accessible_get_type ())
#define GTK_LOCK_BUTTON_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_LOCK_BUTTON_ACCESSIBLE, GtkLockButtonAccessible))
#define GTK_LOCK_BUTTON_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_LOCK_BUTTON_ACCESSIBLE, GtkLockButtonAccessibleClass))
#define GTK_IS_LOCK_BUTTON_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_LOCK_BUTTON_ACCESSIBLE))
#define GTK_IS_LOCK_BUTTON_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_LOCK_BUTTON_ACCESSIBLE))
#define GTK_LOCK_BUTTON_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_LOCK_BUTTON_ACCESSIBLE, GtkLockButtonAccessibleClass))
typedef struct _GtkLockButtonAccessible GtkLockButtonAccessible;
typedef struct _GtkLockButtonAccessibleClass GtkLockButtonAccessibleClass;
typedef struct _GtkLockButtonAccessiblePrivate GtkLockButtonAccessiblePrivate;
struct _GtkLockButtonAccessible
{
GtkButtonAccessible parent;
GtkLockButtonAccessiblePrivate *priv;
};
struct _GtkLockButtonAccessibleClass
{
GtkButtonAccessibleClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType gtk_lock_button_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_LOCK_BUTTON_ACCESSIBLE_H__ */

View File

@@ -0,0 +1,31 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_LOCK_BUTTON_ACCESSIBLE_PRIVATE_H__
#define __GTK_LOCK_BUTTON_ACCESSIBLE_PRIVATE_H__
#include <gtk/a11y/gtklockbuttonaccessible.h>
#include <gtk/gtklockbutton.h>
G_BEGIN_DECLS
void _gtk_lock_button_accessible_name_changed (GtkLockButton *lockbutton);
G_END_DECLS
#endif /* __GTK_LOCK_BUTTON_ACCESSIBLE_PRIVATE_H__ */

View File

@@ -0,0 +1,117 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
#include "gtkmenubuttonaccessible.h"
G_DEFINE_TYPE (GtkMenuButtonAccessible, gtk_menu_button_accessible, GTK_TYPE_WIDGET_ACCESSIBLE)
static void
gtk_menu_button_accessible_initialize (AtkObject *accessible,
gpointer data)
{
ATK_OBJECT_CLASS (gtk_menu_button_accessible_parent_class)->initialize (accessible, data);
accessible->role = ATK_ROLE_TOGGLE_BUTTON;
}
static gint
gtk_menu_button_accessible_get_n_children (AtkObject* obj)
{
GtkWidget *widget;
gint count = 0;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return count;
return count;
}
static AtkObject *
gtk_menu_button_accessible_ref_child (AtkObject *obj,
gint i)
{
AtkObject *accessible = NULL;
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return NULL;
return accessible;
}
static const gchar *
gtk_menu_button_accessible_get_name (AtkObject *obj)
{
const gchar *name = NULL;
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return NULL;
name = ATK_OBJECT_CLASS (gtk_menu_button_accessible_parent_class)->get_name (obj);
if (name != NULL)
return name;
return _("Menu");
}
static AtkStateSet *
gtk_menu_button_accessible_ref_state_set (AtkObject *obj)
{
AtkStateSet *state_set;
GtkWidget *widget;
GtkWidget *button;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return NULL;
button = gtk_widget_get_first_child (widget);
state_set = ATK_OBJECT_CLASS (gtk_menu_button_accessible_parent_class)->ref_state_set (obj);
atk_state_set_add_state (state_set, ATK_STATE_FOCUSABLE);
if (gtk_widget_has_focus (button))
atk_state_set_add_state (state_set, ATK_STATE_FOCUSED);
return state_set;
}
static void
gtk_menu_button_accessible_class_init (GtkMenuButtonAccessibleClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
class->get_name = gtk_menu_button_accessible_get_name;
class->initialize = gtk_menu_button_accessible_initialize;
class->get_n_children = gtk_menu_button_accessible_get_n_children;
class->ref_child = gtk_menu_button_accessible_ref_child;
class->ref_state_set = gtk_menu_button_accessible_ref_state_set;
}
static void
gtk_menu_button_accessible_init (GtkMenuButtonAccessible *menu_button)
{
}

View File

@@ -0,0 +1,57 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_MENU_BUTTON_ACCESSIBLE_H__
#define __GTK_MENU_BUTTON_ACCESSIBLE_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <gtk/a11y/gtkwidgetaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_MENU_BUTTON_ACCESSIBLE (gtk_menu_button_accessible_get_type ())
#define GTK_MENU_BUTTON_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_MENU_BUTTON_ACCESSIBLE, GtkMenuButtonAccessible))
#define GTK_MENU_BUTTON_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_MENU_BUTTON_ACCESSIBLE, GtkMenuButtonAccessibleClass))
#define GTK_IS_MENU_BUTTON_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_MENU_BUTTON_ACCESSIBLE))
#define GTK_IS_MENU_BUTTON_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MENU_BUTTON_ACCESSIBLE))
#define GTK_MENU_BUTTON_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_MENU_BUTTON_ACCESSIBLE, GtkMenuButtonAccessibleClass))
typedef struct _GtkMenuButtonAccessible GtkMenuButtonAccessible;
typedef struct _GtkMenuButtonAccessibleClass GtkMenuButtonAccessibleClass;
typedef struct _GtkMenuButtonAccessiblePrivate GtkMenuButtonAccessiblePrivate;
struct _GtkMenuButtonAccessible
{
GtkWidgetAccessible parent;
GtkMenuButtonAccessiblePrivate *priv;
};
struct _GtkMenuButtonAccessibleClass
{
GtkWidgetAccessibleClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType gtk_menu_button_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_MENU_BUTTON_ACCESSIBLE_H__ */

View File

@@ -0,0 +1,312 @@
/* GTK+ - accessibility implementations
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtknotebookaccessibleprivate.h"
#include "gtknotebookpageaccessible.h"
#include "gtknotebook.h"
#include <string.h>
struct _GtkNotebookAccessiblePrivate
{
/*
* page_cache maintains a list of pre-ref'd Notebook Pages.
* This cache is queried by gtk_notebook_accessible_ref_child().
* If the page is found in the list then a new page does not
* need to be created
*/
GHashTable * pages;
gint selected_page;
};
static void atk_selection_interface_init (AtkSelectionIface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkNotebookAccessible, gtk_notebook_accessible, GTK_TYPE_WIDGET_ACCESSIBLE,
G_ADD_PRIVATE (GtkNotebookAccessible)
G_IMPLEMENT_INTERFACE (ATK_TYPE_SELECTION, atk_selection_interface_init))
static void
create_notebook_page_accessible (GtkNotebookAccessible *accessible,
GtkNotebook *notebook,
GtkWidget *child,
gint page_num)
{
AtkObject *obj;
obj = gtk_notebook_page_accessible_new (accessible, child);
g_hash_table_insert (accessible->priv->pages, child, obj);
atk_object_set_parent (obj, ATK_OBJECT (accessible));
g_signal_emit_by_name (accessible, "children-changed::add", page_num, obj, NULL);
}
static void
page_added_cb (GtkNotebook *notebook,
GtkWidget *child,
guint page_num,
gpointer data)
{
AtkObject *atk_obj;
GtkNotebookAccessible *accessible;
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (notebook));
accessible = GTK_NOTEBOOK_ACCESSIBLE (atk_obj);
create_notebook_page_accessible (accessible, notebook, child, page_num);
}
static void
page_removed_cb (GtkNotebook *notebook,
GtkWidget *widget,
guint page_num,
gpointer data)
{
GtkNotebookAccessible *accessible;
AtkObject *obj;
accessible = GTK_NOTEBOOK_ACCESSIBLE (gtk_widget_get_accessible (GTK_WIDGET (notebook)));
obj = g_hash_table_lookup (accessible->priv->pages, widget);
g_return_if_fail (obj);
g_signal_emit_by_name (accessible, "children-changed::remove",
page_num, obj, NULL);
gtk_notebook_page_accessible_invalidate (GTK_NOTEBOOK_PAGE_ACCESSIBLE (obj));
g_hash_table_remove (accessible->priv->pages, widget);
}
static void
gtk_notebook_accessible_initialize (AtkObject *obj,
gpointer data)
{
GtkNotebookAccessible *accessible;
GtkNotebook *notebook;
gint i;
ATK_OBJECT_CLASS (gtk_notebook_accessible_parent_class)->initialize (obj, data);
accessible = GTK_NOTEBOOK_ACCESSIBLE (obj);
notebook = GTK_NOTEBOOK (data);
for (i = 0; i < gtk_notebook_get_n_pages (notebook); i++)
{
create_notebook_page_accessible (accessible,
notebook,
gtk_notebook_get_nth_page (notebook, i),
i);
}
accessible->priv->selected_page = gtk_notebook_get_current_page (notebook);
g_signal_connect (notebook, "page-added",
G_CALLBACK (page_added_cb), NULL);
g_signal_connect (notebook, "page-removed",
G_CALLBACK (page_removed_cb), NULL);
obj->role = ATK_ROLE_PAGE_TAB_LIST;
}
static void
gtk_notebook_accessible_finalize (GObject *object)
{
GtkNotebookAccessible *accessible = GTK_NOTEBOOK_ACCESSIBLE (object);
g_hash_table_destroy (accessible->priv->pages);
G_OBJECT_CLASS (gtk_notebook_accessible_parent_class)->finalize (object);
}
static AtkObject *
gtk_notebook_accessible_ref_child (AtkObject *obj,
gint i)
{
AtkObject *child;
GtkNotebookAccessible *accessible;
GtkNotebook *notebook;
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return NULL;
accessible = GTK_NOTEBOOK_ACCESSIBLE (obj);
notebook = GTK_NOTEBOOK (widget);
child = g_hash_table_lookup (accessible->priv->pages,
gtk_notebook_get_nth_page (notebook, i));
/* can return NULL when i >= n_children */
if (child)
g_object_ref (child);
return child;
}
void
gtk_notebook_accessible_update_page (GtkNotebookAccessible *self,
int page_num)
{
GtkNotebookAccessiblePrivate *priv = gtk_notebook_accessible_get_instance_private (self);
AtkObject *atk_obj = ATK_OBJECT (self);
int old_page_num = priv->selected_page;
priv->selected_page = page_num;
/* Notify SELECTED state change for old and new page */
if (page_num != old_page_num)
{
AtkObject *child;
if (old_page_num != -1)
{
child = gtk_notebook_accessible_ref_child (atk_obj, old_page_num);
if (child != NULL)
{
atk_object_notify_state_change (child, ATK_STATE_SELECTED, FALSE);
g_object_unref (child);
}
}
child = gtk_notebook_accessible_ref_child (atk_obj, page_num);
if (child != NULL)
{
atk_object_notify_state_change (child, ATK_STATE_SELECTED, TRUE);
g_object_unref (child);
}
g_signal_emit_by_name (atk_obj, "selection-changed");
g_signal_emit_by_name (atk_obj, "visible-data-changed");
}
}
/*
* GtkNotebook only supports the selection of one page at a time.
* Selecting a page unselects any previous selection, so this
* changes the current selection instead of adding to it.
*/
static gboolean
gtk_notebook_accessible_add_selection (AtkSelection *selection,
gint i)
{
GtkNotebook *notebook;
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (widget == NULL)
return FALSE;
notebook = GTK_NOTEBOOK (widget);
gtk_notebook_set_current_page (notebook, i);
return TRUE;
}
static void
gtk_notebook_accessible_class_init (GtkNotebookAccessibleClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
gobject_class->finalize = gtk_notebook_accessible_finalize;
class->ref_child = gtk_notebook_accessible_ref_child;
class->initialize = gtk_notebook_accessible_initialize;
}
static void
gtk_notebook_accessible_init (GtkNotebookAccessible *notebook)
{
notebook->priv = gtk_notebook_accessible_get_instance_private (notebook);
notebook->priv->pages = g_hash_table_new_full (g_direct_hash,
g_direct_equal,
NULL,
g_object_unref);
notebook->priv->selected_page = -1;
}
static AtkObject *
gtk_notebook_accessible_ref_selection (AtkSelection *selection,
gint i)
{
AtkObject *accessible;
GtkWidget *widget;
GtkNotebook *notebook;
gint pagenum;
if (i != 0)
return NULL;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (widget == NULL)
return NULL;
notebook = GTK_NOTEBOOK (widget);
pagenum = gtk_notebook_get_current_page (notebook);
if (pagenum == -1)
return NULL;
accessible = gtk_notebook_accessible_ref_child (ATK_OBJECT (selection), pagenum);
return accessible;
}
/* Always return 1 because there can only be one page
* selected at any time
*/
static gint
gtk_notebook_accessible_get_selection_count (AtkSelection *selection)
{
GtkWidget *widget;
GtkNotebook *notebook;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (widget == NULL)
return 0;
notebook = GTK_NOTEBOOK (widget);
if (notebook == NULL || gtk_notebook_get_current_page (notebook) == -1)
return 0;
return 1;
}
static gboolean
gtk_notebook_accessible_is_child_selected (AtkSelection *selection,
gint i)
{
GtkWidget *widget;
GtkNotebook *notebook;
gint pagenumber;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection));
if (widget == NULL)
return FALSE;
notebook = GTK_NOTEBOOK (widget);
pagenumber = gtk_notebook_get_current_page(notebook);
if (pagenumber == i)
return TRUE;
return FALSE;
}
static void
atk_selection_interface_init (AtkSelectionIface *iface)
{
iface->add_selection = gtk_notebook_accessible_add_selection;
iface->ref_selection = gtk_notebook_accessible_ref_selection;
iface->get_selection_count = gtk_notebook_accessible_get_selection_count;
iface->is_child_selected = gtk_notebook_accessible_is_child_selected;
}

View File

@@ -0,0 +1,57 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_NOTEBOOK_ACCESSIBLE_H__
#define __GTK_NOTEBOOK_ACCESSIBLE_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <gtk/a11y/gtkwidgetaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_NOTEBOOK_ACCESSIBLE (gtk_notebook_accessible_get_type ())
#define GTK_NOTEBOOK_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_NOTEBOOK_ACCESSIBLE, GtkNotebookAccessible))
#define GTK_NOTEBOOK_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_NOTEBOOK_ACCESSIBLE, GtkNotebookAccessibleClass))
#define GTK_IS_NOTEBOOK_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_NOTEBOOK_ACCESSIBLE))
#define GTK_IS_NOTEBOOK_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_NOTEBOOK_ACCESSIBLE))
#define GTK_NOTEBOOK_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_NOTEBOOK_ACCESSIBLE, GtkNotebookAccessibleClass))
typedef struct _GtkNotebookAccessible GtkNotebookAccessible;
typedef struct _GtkNotebookAccessibleClass GtkNotebookAccessibleClass;
typedef struct _GtkNotebookAccessiblePrivate GtkNotebookAccessiblePrivate;
struct _GtkNotebookAccessible
{
GtkWidgetAccessible parent;
GtkNotebookAccessiblePrivate *priv;
};
struct _GtkNotebookAccessibleClass
{
GtkWidgetAccessibleClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType gtk_notebook_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_NOTEBOOK_ACCESSIBLE_H__ */

View File

@@ -1,4 +1,4 @@
/* gtkaccessibleprivate.h: Accessible interface
/* gtknotebookaccessibleprivate.h: GtkNotebookAccessible private API
*
* Copyright 2020 GNOME Foundation
*
@@ -20,18 +20,11 @@
#pragma once
#include "gtkaccessible.h"
#include "gtkatcontext.h"
#include "gtknotebookaccessible.h"
G_BEGIN_DECLS
struct _GtkAccessibleInterface
{
GTypeInterface g_iface;
GtkATContext * (* get_at_context) (GtkAccessible *self);
};
GtkATContext * gtk_accessible_get_at_context (GtkAccessible *self);
void gtk_notebook_accessible_update_page (GtkNotebookAccessible *self,
int page_num);
G_END_DECLS

View File

@@ -0,0 +1,334 @@
/* GTK+ - accessibility implementations
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "gtknotebookpageaccessible.h"
struct _GtkNotebookPageAccessiblePrivate
{
GtkAccessible *notebook;
GtkWidget *child;
};
static void atk_component_interface_init (AtkComponentIface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkNotebookPageAccessible, gtk_notebook_page_accessible, ATK_TYPE_OBJECT,
G_ADD_PRIVATE (GtkNotebookPageAccessible)
G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_interface_init))
static GtkWidget *
find_label_child (GtkWidget *widget)
{
GtkWidget *child;
for (child = gtk_widget_get_first_child (widget);
child != NULL;
child = gtk_widget_get_next_sibling (child))
{
if (GTK_IS_LABEL (child))
return child;
else
{
GtkWidget *w = find_label_child (child);
if (w)
return w;
}
}
return NULL;
}
static GtkWidget *
get_label_from_notebook_page (GtkNotebookPageAccessible *page)
{
GtkWidget *child;
GtkNotebook *notebook;
notebook = GTK_NOTEBOOK (gtk_accessible_get_widget (page->priv->notebook));
if (!notebook)
return NULL;
if (!gtk_notebook_get_show_tabs (notebook))
return NULL;
child = gtk_notebook_get_tab_label (notebook, page->priv->child);
if (GTK_IS_LABEL (child))
return child;
return find_label_child (child);
}
static const gchar *
gtk_notebook_page_accessible_get_name (AtkObject *accessible)
{
GtkWidget *label;
if (accessible->name != NULL)
return accessible->name;
label = get_label_from_notebook_page (GTK_NOTEBOOK_PAGE_ACCESSIBLE (accessible));
if (GTK_IS_LABEL (label))
return gtk_label_get_text (GTK_LABEL (label));
return NULL;
}
static AtkObject *
gtk_notebook_page_accessible_get_parent (AtkObject *accessible)
{
GtkNotebookPageAccessible *page;
page = GTK_NOTEBOOK_PAGE_ACCESSIBLE (accessible);
return ATK_OBJECT (page->priv->notebook);
}
static gint
gtk_notebook_page_accessible_get_n_children (AtkObject *accessible)
{
return 1;
}
static AtkObject *
gtk_notebook_page_accessible_ref_child (AtkObject *accessible,
gint i)
{
AtkObject *child_obj;
GtkNotebookPageAccessible *page = NULL;
if (i != 0)
return NULL;
page = GTK_NOTEBOOK_PAGE_ACCESSIBLE (accessible);
if (!page->priv->child)
return NULL;
child_obj = gtk_widget_get_accessible (page->priv->child);
g_object_ref (child_obj);
return child_obj;
}
static AtkStateSet *
gtk_notebook_page_accessible_ref_state_set (AtkObject *accessible)
{
GtkNotebookPageAccessible *page = GTK_NOTEBOOK_PAGE_ACCESSIBLE (accessible);
AtkStateSet *state_set, *label_state_set, *merged_state_set;
AtkObject *atk_label;
GtkWidget *label;
AtkObject *selected;
state_set = ATK_OBJECT_CLASS (gtk_notebook_page_accessible_parent_class)->ref_state_set (accessible);
atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE);
selected = atk_selection_ref_selection (ATK_SELECTION (page->priv->notebook), 0);
if (selected)
{
if (selected == accessible)
atk_state_set_add_state (state_set, ATK_STATE_SELECTED);
g_object_unref (selected);
}
label = get_label_from_notebook_page (GTK_NOTEBOOK_PAGE_ACCESSIBLE (accessible));
if (label)
{
atk_label = gtk_widget_get_accessible (label);
label_state_set = atk_object_ref_state_set (atk_label);
merged_state_set = atk_state_set_or_sets (state_set, label_state_set);
g_object_unref (label_state_set);
g_object_unref (state_set);
}
else
{
AtkObject *child;
child = atk_object_ref_accessible_child (accessible, 0);
if (!child)
return state_set;
merged_state_set = state_set;
state_set = atk_object_ref_state_set (child);
if (atk_state_set_contains_state (state_set, ATK_STATE_VISIBLE))
{
atk_state_set_add_state (merged_state_set, ATK_STATE_VISIBLE);
if (atk_state_set_contains_state (state_set, ATK_STATE_ENABLED))
atk_state_set_add_state (merged_state_set, ATK_STATE_ENABLED);
if (atk_state_set_contains_state (state_set, ATK_STATE_SHOWING))
atk_state_set_add_state (merged_state_set, ATK_STATE_SHOWING);
}
g_object_unref (state_set);
g_object_unref (child);
}
return merged_state_set;
}
static gint
gtk_notebook_page_accessible_get_index_in_parent (AtkObject *accessible)
{
GtkNotebookPageAccessible *page;
page = GTK_NOTEBOOK_PAGE_ACCESSIBLE (accessible);
if (!page->priv->child)
return -1;
return gtk_notebook_page_num (GTK_NOTEBOOK (gtk_accessible_get_widget (page->priv->notebook)),
page->priv->child);
}
static void
gtk_notebook_page_accessible_class_init (GtkNotebookPageAccessibleClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
class->get_name = gtk_notebook_page_accessible_get_name;
class->get_parent = gtk_notebook_page_accessible_get_parent;
class->get_n_children = gtk_notebook_page_accessible_get_n_children;
class->ref_child = gtk_notebook_page_accessible_ref_child;
class->ref_state_set = gtk_notebook_page_accessible_ref_state_set;
class->get_index_in_parent = gtk_notebook_page_accessible_get_index_in_parent;
}
static void
gtk_notebook_page_accessible_init (GtkNotebookPageAccessible *page)
{
page->priv = gtk_notebook_page_accessible_get_instance_private (page);
}
static void
notify_tab_label (GObject *object,
GParamSpec *pspec,
AtkObject *atk_obj)
{
if (atk_obj->name == NULL)
g_object_notify (G_OBJECT (atk_obj), "accessible-name");
g_signal_emit_by_name (atk_obj, "visible-data-changed");
}
AtkObject *
gtk_notebook_page_accessible_new (GtkNotebookAccessible *notebook,
GtkWidget *child)
{
GObject *object;
AtkObject *atk_object;
GtkNotebookPageAccessible *page;
GtkNotebook *nb;
g_return_val_if_fail (GTK_IS_NOTEBOOK_ACCESSIBLE (notebook), NULL);
g_return_val_if_fail (GTK_WIDGET (child), NULL);
object = g_object_new (GTK_TYPE_NOTEBOOK_PAGE_ACCESSIBLE, NULL);
page = GTK_NOTEBOOK_PAGE_ACCESSIBLE (object);
page->priv->notebook = GTK_ACCESSIBLE (notebook);
page->priv->child = child;
atk_object = ATK_OBJECT (page);
atk_object->role = ATK_ROLE_PAGE_TAB;
atk_object->layer = ATK_LAYER_WIDGET;
atk_object_set_parent (gtk_widget_get_accessible (child), atk_object);
nb = GTK_NOTEBOOK (gtk_accessible_get_widget (page->priv->notebook));
g_signal_connect (gtk_notebook_get_page (nb, child),
"notify::tab-label",
G_CALLBACK (notify_tab_label), page);
return atk_object;
}
void
gtk_notebook_page_accessible_invalidate (GtkNotebookPageAccessible *page)
{
AtkObject *obj = ATK_OBJECT (page);
GtkWidget *notebook;
notebook = gtk_accessible_get_widget (page->priv->notebook);
if (notebook)
g_signal_handlers_disconnect_by_func (notebook, notify_tab_label, page);
atk_object_notify_state_change (obj, ATK_STATE_DEFUNCT, TRUE);
atk_object_set_parent (obj, NULL);
page->priv->notebook = NULL;
atk_object_set_parent (gtk_widget_get_accessible (page->priv->child), NULL);
page->priv->child = NULL;
}
static AtkObject*
gtk_notebook_page_accessible_ref_accessible_at_point (AtkComponent *component,
gint x,
gint y,
AtkCoordType coord_type)
{
/* There is only one child so we return it */
AtkObject* child;
child = atk_object_ref_accessible_child (ATK_OBJECT (component), 0);
return child;
}
static void
gtk_notebook_page_accessible_get_extents (AtkComponent *component,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coord_type)
{
GtkWidget *label;
AtkObject *atk_label;
label = get_label_from_notebook_page (GTK_NOTEBOOK_PAGE_ACCESSIBLE (component));
if (!label)
{
AtkObject *child;
*width = 0;
*height = 0;
child = atk_object_ref_accessible_child (ATK_OBJECT (component), 0);
if (!child)
return;
atk_component_get_extents (ATK_COMPONENT (child), x, y, NULL, NULL,
coord_type);
g_object_unref (child);
}
else
{
atk_label = gtk_widget_get_accessible (label);
atk_component_get_extents (ATK_COMPONENT (atk_label),
x, y, width, height, coord_type);
}
}
static void
atk_component_interface_init (AtkComponentIface *iface)
{
/* We use the default implementations for contains, get_position, get_size */
iface->ref_accessible_at_point = gtk_notebook_page_accessible_ref_accessible_at_point;
iface->get_extents = gtk_notebook_page_accessible_get_extents;
}

View File

@@ -0,0 +1,64 @@
/* GTK+ - accessibility implementations
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_NOTEBOOK_PAGE_ACCESSIBLE_H__
#define __GTK_NOTEBOOK_PAGE_ACCESSIBLE_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <gtk/a11y/gtknotebookaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_NOTEBOOK_PAGE_ACCESSIBLE (gtk_notebook_page_accessible_get_type ())
#define GTK_NOTEBOOK_PAGE_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),GTK_TYPE_NOTEBOOK_PAGE_ACCESSIBLE, GtkNotebookPageAccessible))
#define GTK_NOTEBOOK_PAGE_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_NOTEBOOK_PAGE_ACCESSIBLE, GtkNotebookPageAccessibleClass))
#define GTK_IS_NOTEBOOK_PAGE_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_NOTEBOOK_PAGE_ACCESSIBLE))
#define GTK_IS_NOTEBOOK_PAGE_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_NOTEBOOK_PAGE_ACCESSIBLE))
#define GTK_NOTEBOOK_PAGE_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_NOTEBOOK_PAGE_ACCESSIBLE, GtkNotebookPageAccessibleClass))
typedef struct _GtkNotebookPageAccessible GtkNotebookPageAccessible;
typedef struct _GtkNotebookPageAccessibleClass GtkNotebookPageAccessibleClass;
typedef struct _GtkNotebookPageAccessiblePrivate GtkNotebookPageAccessiblePrivate;
struct _GtkNotebookPageAccessible
{
AtkObject parent;
GtkNotebookPageAccessiblePrivate *priv;
};
struct _GtkNotebookPageAccessibleClass
{
AtkObjectClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType gtk_notebook_page_accessible_get_type (void);
GDK_AVAILABLE_IN_ALL
AtkObject *gtk_notebook_page_accessible_new (GtkNotebookAccessible *notebook,
GtkWidget *child);
GDK_AVAILABLE_IN_ALL
void gtk_notebook_page_accessible_invalidate (GtkNotebookPageAccessible *page);
G_END_DECLS
#endif /* __GTK_NOTEBOOK_PAGE_ACCESSIBLE_H__ */

View File

@@ -0,0 +1,200 @@
/* GTK+ - accessibility implementations
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "gtkpanedaccessible.h"
static void atk_value_interface_init (AtkValueIface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkPanedAccessible, gtk_paned_accessible, GTK_TYPE_WIDGET_ACCESSIBLE,
G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init))
static void
gtk_paned_accessible_position_changed (GtkWidget *widget)
{
AtkObject *obj = gtk_widget_get_accessible (widget);
g_object_notify (G_OBJECT (obj), "accessible-value");
}
static void
gtk_paned_accessible_initialize (AtkObject *obj,
gpointer data)
{
ATK_OBJECT_CLASS (gtk_paned_accessible_parent_class)->initialize (obj, data);
g_signal_connect (data, "notify::position",
G_CALLBACK (gtk_paned_accessible_position_changed), NULL);
obj->role = ATK_ROLE_SPLIT_PANE;
}
static void
gtk_paned_accessible_class_init (GtkPanedAccessibleClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
class->initialize = gtk_paned_accessible_initialize;
}
static void
gtk_paned_accessible_init (GtkPanedAccessible *paned)
{
}
static void
gtk_paned_accessible_get_current_value (AtkValue *obj,
GValue *value)
{
GtkWidget* widget;
gint current_value;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return;
current_value = gtk_paned_get_position (GTK_PANED (widget));
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_INT);
g_value_set_int (value, current_value);
}
static void
gtk_paned_accessible_get_maximum_value (AtkValue *obj,
GValue *value)
{
GtkWidget* widget;
gint maximum_value;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return;
g_object_get (GTK_PANED (widget),
"max-position", &maximum_value,
NULL);
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_INT);
g_value_set_int (value, maximum_value);
}
static void
gtk_paned_accessible_get_minimum_value (AtkValue *obj,
GValue *value)
{
GtkWidget* widget;
gint minimum_value;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return;
g_object_get (GTK_PANED (widget),
"min-position", &minimum_value,
NULL);
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_INT);
g_value_set_int (value, minimum_value);
}
/* Calling atk_value_set_current_value() is no guarantee that the value
* is acceptable; it is necessary to listen for accessible-value signals
* and check whether the current value has been changed or check what the
* maximum and minimum values are.
*/
static gboolean
gtk_paned_accessible_set_current_value (AtkValue *obj,
const GValue *value)
{
GtkWidget* widget;
gint new_value;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return FALSE;
if (G_VALUE_HOLDS_INT (value))
{
new_value = g_value_get_int (value);
gtk_paned_set_position (GTK_PANED (widget), new_value);
return TRUE;
}
else
return FALSE;
}
static void
gtk_paned_accessible_get_value_and_text (AtkValue *obj,
gdouble *value,
gchar **text)
{
GtkWidget *widget;
GtkPaned *paned;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
paned = GTK_PANED (widget);
*value = gtk_paned_get_position (paned);
*text = NULL;
}
static AtkRange *
gtk_paned_accessible_get_range (AtkValue *obj)
{
GtkWidget *widget;
gint minimum_value;
gint maximum_value;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
g_object_get (widget,
"min-position", &minimum_value,
"max-position", &maximum_value,
NULL);
return atk_range_new (minimum_value, maximum_value, NULL);
}
static void
gtk_paned_accessible_set_value (AtkValue *obj,
const gdouble value)
{
GtkWidget *widget;
GtkPaned *paned;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
paned = GTK_PANED (widget);
gtk_paned_set_position (paned, (gint)(value + 0.5));
}
static void
atk_value_interface_init (AtkValueIface *iface)
{
iface->get_current_value = gtk_paned_accessible_get_current_value;
iface->get_maximum_value = gtk_paned_accessible_get_maximum_value;
iface->get_minimum_value = gtk_paned_accessible_get_minimum_value;
iface->set_current_value = gtk_paned_accessible_set_current_value;
iface->get_value_and_text = gtk_paned_accessible_get_value_and_text;
iface->get_range = gtk_paned_accessible_get_range;
iface->set_value = gtk_paned_accessible_set_value;
}

View File

@@ -0,0 +1,57 @@
/* GTK+ - accessibility implementations
* Copyright 2001 Sun Microsystems Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_PANED_ACCESSIBLE_H__
#define __GTK_PANED_ACCESSIBLE_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <gtk/a11y/gtkwidgetaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_PANED_ACCESSIBLE (gtk_paned_accessible_get_type ())
#define GTK_PANED_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PANED_ACCESSIBLE, GtkPanedAccessible))
#define GTK_PANED_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_PANED_ACCESSIBLE, GtkPanedAccessibleClass))
#define GTK_IS_PANED_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PANED_ACCESSIBLE))
#define GTK_IS_PANED_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PANED_ACCESSIBLE))
#define GTK_PANED_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PANED_ACCESSIBLE, GtkPanedAccessibleClass))
typedef struct _GtkPanedAccessible GtkPanedAccessible;
typedef struct _GtkPanedAccessibleClass GtkPanedAccessibleClass;
typedef struct _GtkPanedAccessiblePrivate GtkPanedAccessiblePrivate;
struct _GtkPanedAccessible
{
GtkWidgetAccessible parent;
GtkPanedAccessiblePrivate *priv;
};
struct _GtkPanedAccessibleClass
{
GtkWidgetAccessibleClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType gtk_paned_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_PANED_ACCESSIBLE_H__ */

View File

@@ -0,0 +1,654 @@
/* gtkpasswordentryaccessible.c: A GtkWidgetAccessible for GtkPasswordEntry
*
* Copyright 2020 GNOME Foundation
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* 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.1 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, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkpasswordentryaccessibleprivate.h"
#include "gtkeditable.h"
#include "gtkimage.h"
#include "gtkintl.h"
#include "gtklabel.h"
#include "gtkpango.h"
#include "gtkpasswordentryprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtktextprivate.h"
struct _GtkPasswordEntryAccessible
{
GtkWidgetAccessible parent_instance;
int cursor_position;
int selection_bound;
};
static void atk_editable_text_interface_init (AtkEditableTextIface *iface);
static void atk_text_interface_init (AtkTextIface *iface);
static void atk_action_interface_init (AtkActionIface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkPasswordEntryAccessible, gtk_password_entry_accessible, GTK_TYPE_WIDGET_ACCESSIBLE,
G_IMPLEMENT_INTERFACE (ATK_TYPE_EDITABLE_TEXT, atk_editable_text_interface_init)
G_IMPLEMENT_INTERFACE (ATK_TYPE_TEXT, atk_text_interface_init)
G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init))
static inline GtkText *
get_text_widget (GtkAccessible *accessible)
{
GtkWidget *widget = gtk_accessible_get_widget (accessible);
if (widget == NULL)
return NULL;
GtkPasswordEntry *entry = GTK_PASSWORD_ENTRY (widget);
return gtk_password_entry_get_text_widget (entry);
}
static gunichar
gtk_password_entry_accessible_get_character_at_offset (AtkText *atk_text,
gint offset)
{
GtkText *text;
char *contents, *index;
gunichar result;
result = '\0';
text = get_text_widget (GTK_ACCESSIBLE (atk_text));
if (text == NULL)
return 0;
if (!gtk_text_get_visibility (text))
return result;
contents = gtk_text_get_display_text (text, 0, -1);
if (offset < g_utf8_strlen (contents, -1))
{
index = g_utf8_offset_to_pointer (contents, offset);
result = g_utf8_get_char (index);
g_free (contents);
}
return result;
}
static gint
gtk_password_entry_accessible_get_caret_offset (AtkText *atk_text)
{
GtkWidget *widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (atk_text));
if (widget == NULL)
return -1;
int cursor_position = 0;
gboolean result = gtk_editable_get_selection_bounds (GTK_EDITABLE (widget), NULL, &cursor_position);
if (!result)
return -1;
return cursor_position;
}
static gboolean
gtk_password_entry_accessible_set_caret_offset (AtkText *atk_text,
gint offset)
{
GtkWidget *widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (atk_text));
if (widget == NULL)
return FALSE;
gtk_editable_set_position (GTK_EDITABLE (widget), offset);
return TRUE;
}
static gint
gtk_password_entry_accessible_get_character_count (AtkText *atk_text)
{
GtkText *text = get_text_widget (GTK_ACCESSIBLE (atk_text));
if (text == NULL)
return 0;
char *display_text = gtk_text_get_display_text (text, 0, -1);
int char_count = 0;
if (display_text)
{
char_count = g_utf8_strlen (display_text, -1);
g_free (display_text);
}
return char_count;
}
static gint
gtk_password_entry_accessible_get_offset_at_point (AtkText *atk_text,
gint x,
gint y,
AtkCoordType coords)
{
GtkText *text = get_text_widget (GTK_ACCESSIBLE (atk_text));
int index, x_layout, y_layout;
int x_local, y_local;
glong offset;
if (text == NULL)
return 1;
gtk_text_get_layout_offsets (text, &x_layout, &y_layout);
x_local = x - x_layout;
y_local = y - y_layout;
if (!pango_layout_xy_to_index (gtk_text_get_layout (text),
x_local * PANGO_SCALE,
y_local * PANGO_SCALE,
&index, NULL))
{
if (x_local < 0 || y_local < 0)
index = 0;
else
index = -1;
}
offset = -1;
if (index != -1)
{
char *entry_text = gtk_text_get_display_text (text, 0, -1);
offset = g_utf8_pointer_to_offset (entry_text, entry_text + index);
g_free (entry_text);
}
return offset;
}
static void
atk_text_interface_init (AtkTextIface *iface)
{
iface->get_character_at_offset = gtk_password_entry_accessible_get_character_at_offset;
iface->get_caret_offset = gtk_password_entry_accessible_get_caret_offset;
iface->set_caret_offset = gtk_password_entry_accessible_set_caret_offset;
iface->get_character_count = gtk_password_entry_accessible_get_character_count;
iface->get_offset_at_point = gtk_password_entry_accessible_get_offset_at_point;
}
static void
gtk_password_entry_accessible_set_text_contents (AtkEditableText *text,
const gchar *string)
{
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
if (widget == NULL)
return;
if (!gtk_editable_get_editable (GTK_EDITABLE (widget)))
return;
gtk_editable_set_text (GTK_EDITABLE (widget), string);
}
static void
gtk_password_entry_accessible_insert_text (AtkEditableText *text,
const gchar *string,
gint length,
gint *position)
{
GtkWidget *widget;
GtkEditable *editable;
int pos = 0;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
if (widget == NULL)
return;
editable = GTK_EDITABLE (widget);
if (!gtk_editable_get_editable (editable))
return;
if (position != NULL)
pos = *position;
gtk_editable_insert_text (editable, string, length, &pos);
gtk_editable_set_position (editable, pos);
if (position != NULL)
*position = pos;
}
static void
gtk_password_entry_accessible_delete_text (AtkEditableText *text,
gint start_pos,
gint end_pos)
{
GtkWidget *widget;
GtkEditable *editable;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
if (widget == NULL)
return;
editable = GTK_EDITABLE (widget);
if (!gtk_editable_get_editable (editable))
return;
gtk_editable_delete_text (editable, start_pos, end_pos);
}
typedef struct
{
GtkEditable *entry;
int position;
} PasteData;
static void
paste_received_cb (GObject *clipboard,
GAsyncResult *result,
gpointer data)
{
PasteData *paste = data;
char *text;
text = gdk_clipboard_read_text_finish (GDK_CLIPBOARD (clipboard), result, NULL);
if (text != NULL)
gtk_editable_insert_text (paste->entry,
text, -1,
&(paste->position));
g_object_unref (paste->entry);
g_free (paste);
g_free (text);
}
static void
gtk_password_entry_accessible_paste_text (AtkEditableText *text,
gint position)
{
GtkWidget *widget;
GtkEditable *editable;
PasteData *paste;
GdkClipboard *clipboard;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
if (widget == NULL)
return;
editable = GTK_EDITABLE (widget);
if (!gtk_editable_get_editable (editable))
return;
paste = g_new0 (PasteData, 1);
paste->entry = GTK_EDITABLE (widget);
paste->position = position;
g_object_ref (paste->entry);
clipboard = gtk_widget_get_clipboard (widget);
gdk_clipboard_read_text_async (clipboard, NULL, paste_received_cb, paste);
}
static void
atk_editable_text_interface_init (AtkEditableTextIface *iface)
{
iface->set_text_contents = gtk_password_entry_accessible_set_text_contents;
iface->insert_text = gtk_password_entry_accessible_insert_text;
iface->copy_text = NULL;
iface->cut_text = NULL;
iface->delete_text = gtk_password_entry_accessible_delete_text;
iface->paste_text = gtk_password_entry_accessible_paste_text;
iface->set_run_attributes = NULL;
}
static gboolean
gtk_password_entry_accessible_do_action (AtkAction *action,
gint i)
{
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (action));
if (widget == NULL)
return FALSE;
if (!gtk_widget_get_sensitive (widget) || !gtk_widget_get_visible (widget))
return FALSE;
if (i == 0)
{
gtk_widget_activate (widget);
return TRUE;
}
if (i == 1)
{
GtkText *text = get_text_widget (GTK_ACCESSIBLE (action));
gboolean visibility = gtk_text_get_visibility (text);
gtk_text_set_visibility (text, !visibility);
return TRUE;
}
return FALSE;
}
static gint
gtk_password_entry_accessible_get_n_actions (AtkAction *action)
{
GtkAccessible *accessible = GTK_ACCESSIBLE (action);
GtkWidget *widget = gtk_accessible_get_widget (accessible);
if (widget == NULL)
return 0;
int n_actions = 1;
if (gtk_password_entry_get_show_peek_icon (GTK_PASSWORD_ENTRY (widget)))
n_actions += 1;
return n_actions;
}
static const gchar *
gtk_password_entry_accessible_get_keybinding (AtkAction *action,
gint i)
{
GtkWidget *widget;
GtkWidget *label;
AtkRelationSet *set;
AtkRelation *relation;
GPtrArray *target;
gpointer target_object;
guint key_val;
if (i != 0)
return NULL;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (action));
if (widget == NULL)
return NULL;
set = atk_object_ref_relation_set (ATK_OBJECT (action));
if (!set)
return NULL;
label = NULL;
relation = atk_relation_set_get_relation_by_type (set, ATK_RELATION_LABELLED_BY);
if (relation)
{
target = atk_relation_get_target (relation);
target_object = g_ptr_array_index (target, 0);
label = gtk_accessible_get_widget (GTK_ACCESSIBLE (target_object));
}
g_object_unref (set);
if (GTK_IS_LABEL (label))
{
key_val = gtk_label_get_mnemonic_keyval (GTK_LABEL (label));
if (key_val != GDK_KEY_VoidSymbol)
return gtk_accelerator_name (key_val, GDK_ALT_MASK);
}
return NULL;
}
static const gchar *
gtk_password_entry_accessible_action_get_name (AtkAction *action,
gint i)
{
switch (i)
{
case 0:
return "activate";
case 1:
return "peek";
default:
break;
}
return NULL;
}
static const gchar*
gtk_password_entry_accessible_action_get_localized_name (AtkAction *action,
gint i)
{
if (i == 0)
return C_("Action name", "Activate");
if (i == 1)
return C_("Action name", "Peek");
return NULL;
}
static const gchar *
gtk_password_entry_accessible_action_get_description (AtkAction *action,
gint i)
{
if (i == 0)
return C_("Action description", "Activates the entry");
if (i == 1)
return C_("Action description", "Reveals the contents the entry");
return NULL;
}
static void
atk_action_interface_init (AtkActionIface *iface)
{
iface->do_action = gtk_password_entry_accessible_do_action;
iface->get_n_actions = gtk_password_entry_accessible_get_n_actions;
iface->get_keybinding = gtk_password_entry_accessible_get_keybinding;
iface->get_name = gtk_password_entry_accessible_action_get_name;
iface->get_localized_name = gtk_password_entry_accessible_action_get_localized_name;
iface->get_description = gtk_password_entry_accessible_action_get_description;
}
static AtkAttributeSet *
gtk_password_entry_accessible_get_attributes (AtkObject *accessible)
{
GtkWidget *widget;
AtkAttributeSet *attributes;
AtkAttribute *placeholder_text;
char *text = NULL;
attributes = ATK_OBJECT_CLASS (gtk_password_entry_accessible_parent_class)->get_attributes (accessible);
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
if (widget == NULL)
return attributes;
g_object_get (widget, "placeholder-text", &text, NULL);
if (text == NULL)
return attributes;
placeholder_text = g_malloc (sizeof (AtkAttribute));
placeholder_text->name = g_strdup ("placeholder-text");
placeholder_text->value = text;
attributes = g_slist_append (attributes, placeholder_text);
return attributes;
}
static gboolean
check_for_selection_change (GtkPasswordEntryAccessible *self,
GtkEditable *editable)
{
gboolean ret_val = FALSE;
gint start, end;
if (gtk_editable_get_selection_bounds (editable, &start, &end))
{
if (end != self->cursor_position ||
start != self->selection_bound)
/*
* This check is here as this function can be called
* for notification of selection_bound and current_pos.
* The values of current_pos and selection_bound may be the same
* for both notifications and we only want to generate one
* text_selection_changed signal.
*/
ret_val = TRUE;
}
else
{
/* We had a selection */
ret_val = (self->cursor_position != self->selection_bound);
}
self->cursor_position = end;
self->selection_bound = start;
return ret_val;
}
static void
on_cursor_position_changed (GObject *gobject,
GParamSpec *pspec,
gpointer data)
{
GtkPasswordEntryAccessible *self = data;
GtkEditable *editable = GTK_EDITABLE (gobject);
if (check_for_selection_change (self, editable))
g_signal_emit_by_name (self, "text-selection-changed");
// The entry cursor position has moved so generate the signal
g_signal_emit_by_name (self, "text-caret-moved",
gtk_editable_get_position (editable));
}
static void
on_selection_bound_changed (GObject *gobject,
GParamSpec *pspec,
gpointer data)
{
GtkPasswordEntryAccessible *self = data;
GtkEditable *editable = GTK_EDITABLE (gobject);
if (check_for_selection_change (self, editable))
g_signal_emit_by_name (self, "text-selection-changed");
}
static void
insert_text_cb (GtkEditable *editable,
gchar *new_text,
gint new_text_length,
gint *position,
GtkPasswordEntryAccessible *self)
{
int length;
if (new_text_length == 0)
return;
length = g_utf8_strlen (new_text, new_text_length);
g_signal_emit_by_name (self,
"text-changed::insert",
*position - length,
length);
}
static void
delete_text_cb (GtkEditable *editable,
gint start,
gint end,
GtkPasswordEntryAccessible *self)
{
GtkText *text;
text = get_text_widget (GTK_ACCESSIBLE (self));
if (text == NULL)
return;
if (end < 0)
{
char *contents;
contents = gtk_text_get_display_text (text, 0, -1);
end = g_utf8_strlen (contents, -1);
g_free (contents);
}
if (end == start)
return;
g_signal_emit_by_name (self,
"text-changed::delete",
start,
end - start);
}
static void
gtk_password_entry_accessible_initialize (AtkObject *atk_object,
gpointer data)
{
GtkPasswordEntryAccessible *self = GTK_PASSWORD_ENTRY_ACCESSIBLE (atk_object);
GtkEditable *editable = data;
GtkWidget *widget = data;
int start_pos, end_pos;
gtk_editable_get_selection_bounds (editable, &start_pos, &end_pos);
self->cursor_position = end_pos;
self->selection_bound = start_pos;
/* Set up signal callbacks */
g_signal_connect_after (widget, "insert-text", G_CALLBACK (insert_text_cb), self);
g_signal_connect (widget, "delete-text", G_CALLBACK (delete_text_cb), self);
g_signal_connect (widget, "notify::cursor-position",
G_CALLBACK (on_cursor_position_changed), self);
g_signal_connect (widget, "notify::selection-bound",
G_CALLBACK (on_selection_bound_changed), self);
}
static void
gtk_password_entry_accessible_class_init (GtkPasswordEntryAccessibleClass *klass)
{
AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass);
atk_object_class->initialize = gtk_password_entry_accessible_initialize;
atk_object_class->get_attributes = gtk_password_entry_accessible_get_attributes;
}
static void
gtk_password_entry_accessible_init (GtkPasswordEntryAccessible *self)
{
AtkObject *atk_obj = ATK_OBJECT (self);
atk_obj->role = ATK_ROLE_PASSWORD_TEXT;
atk_object_set_name (atk_obj, _("Password"));
}
void
gtk_password_entry_accessible_update_visibility (GtkPasswordEntryAccessible *self)
{
GtkText *text = get_text_widget (GTK_ACCESSIBLE (self));
if (text == NULL)
return;
gboolean visibility = gtk_text_get_visibility (text);
AtkRole role = visibility ? ATK_ROLE_TEXT : ATK_ROLE_PASSWORD_TEXT;
atk_object_set_role (ATK_OBJECT (self), role);
}

View File

@@ -0,0 +1,48 @@
/* gtkpasswordentryaccessible.h: A GtkWidgetAccessible for GtkPasswordEntry
*
* Copyright 2020 GNOME Foundation
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* 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.1 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, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <gtk/a11y/gtkentryaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_PASSWORD_ENTRY_ACCESSIBLE (gtk_password_entry_accessible_get_type())
#define GTK_PASSWORD_ENTRY_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PASSWORD_ENTRY_ACCESSIBLE, GtkPasswordEntryAccessible))
#define GTK_IS_PASSWORD_ENTRY_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PASSWORD_ENTRY_ACCESSIBLE))
typedef struct _GtkPasswordEntryAccessible GtkPasswordEntryAccessible;
typedef struct _GtkPasswordEntryAccessibleClass GtkPasswordEntryAccessibleClass;
struct _GtkPasswordEntryAccessibleClass
{
GtkWidgetAccessibleClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType gtk_password_entry_accessible_get_type (void) G_GNUC_CONST;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GtkPasswordEntryAccessible, g_object_unref)
G_END_DECLS

View File

@@ -1,4 +1,4 @@
/* gtktestatcontextprivate.h: Private test AT context
/* gtkpasswordentryaccessibleprivate.h: Private API for GtkPasswordEntryAccessible
*
* Copyright 2020 GNOME Foundation
*
@@ -20,28 +20,10 @@
#pragma once
#include "gtkatcontextprivate.h"
#include "gtkpasswordentryaccessible.h"
G_BEGIN_DECLS
#define GTK_TYPE_TEST_AT_CONTEXT (gtk_test_at_context_get_type())
G_DECLARE_FINAL_TYPE (GtkTestATContext, gtk_test_at_context, GTK, TEST_AT_CONTEXT, GtkATContext)
GtkATContext *
gtk_test_at_context_new (GtkAccessibleRole accessible_role,
GtkAccessible *accessible);
void
gtk_test_at_context_assert_role (GtkTestATContext *self,
GtkAccessibleRole role);
void
gtk_test_at_context_assert_state_added (GtkTestATContext *self,
GtkAccessibleState state);
void
gtk_test_at_context_assert_state_removed (GtkTestATContext *self,
GtkAccessibleState state);
void gtk_password_entry_accessible_update_visibility (GtkPasswordEntryAccessible *self);
G_END_DECLS

View File

@@ -0,0 +1,136 @@
/*
* Copyright © 2018 Benjamin Otte
*
* 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.1 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, see <http://www.gnu.org/licenses/>.
*
* Authors: Benjamin Otte <otte@gnome.org>
*/
#include "config.h"
#include "gtkpictureaccessibleprivate.h"
#include "gtkpicture.h"
struct _GtkPictureAccessible
{
GtkWidgetAccessible parent_instance;
};
struct _GtkPictureAccessibleClass
{
GtkWidgetAccessibleClass parent_class;
};
static const gchar *
gtk_picture_accessible_get_image_description (AtkImage *image)
{
GtkWidget* widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (image));
if (widget == NULL)
return NULL;
return gtk_picture_get_alternative_text (GTK_PICTURE (widget));
}
static void
gtk_picture_accessible_get_image_position (AtkImage *image,
gint *x,
gint *y,
AtkCoordType coord_type)
{
atk_component_get_extents (ATK_COMPONENT (image), x, y, NULL, NULL,
coord_type);
}
static void
gtk_picture_accessible_get_image_size (AtkImage *image,
gint *width,
gint *height)
{
GtkWidget* widget;
GdkPaintable *paintable;
*width = -1;
*height = -1;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (image));
if (widget == NULL)
return;
paintable = gtk_picture_get_paintable (GTK_PICTURE (widget));
if (paintable == NULL)
return;
*width = gdk_paintable_get_intrinsic_width (paintable);
if (*width == 0)
*width = -1;
*height = gdk_paintable_get_intrinsic_height (paintable);
if (*height == 0)
*height = -1;
}
static void
gtk_picture_accessible_image_init (AtkImageIface *iface)
{
iface->get_image_description = gtk_picture_accessible_get_image_description;
iface->get_image_position = gtk_picture_accessible_get_image_position;
iface->get_image_size = gtk_picture_accessible_get_image_size;
}
G_DEFINE_TYPE_WITH_CODE (GtkPictureAccessible, gtk_picture_accessible, GTK_TYPE_WIDGET_ACCESSIBLE,
G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE, gtk_picture_accessible_image_init))
static void
gtk_picture_accessible_initialize (AtkObject *accessible,
gpointer data)
{
ATK_OBJECT_CLASS (gtk_picture_accessible_parent_class)->initialize (accessible, data);
accessible->role = ATK_ROLE_IMAGE;
}
static const gchar *
gtk_picture_accessible_get_name (AtkObject *accessible)
{
GtkWidget* widget;
const gchar *name;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
if (widget == NULL)
return NULL;
name = ATK_OBJECT_CLASS (gtk_picture_accessible_parent_class)->get_name (accessible);
if (name)
return name;
return gtk_picture_get_alternative_text (GTK_PICTURE (widget));
}
static void
gtk_picture_accessible_class_init (GtkPictureAccessibleClass *klass)
{
AtkObjectClass *atkobject_class = ATK_OBJECT_CLASS (klass);
atkobject_class->initialize = gtk_picture_accessible_initialize;
atkobject_class->get_name = gtk_picture_accessible_get_name;
}
static void
gtk_picture_accessible_init (GtkPictureAccessible *image)
{
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright © 2018 Benjamin Otte
*
* 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.1 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, see <http://www.gnu.org/licenses/>.
*
* Authors: Benjamin Otte <otte@gnome.org>
*/
#ifndef __GTK_PICTURE_ACCESSIBLE_PRIVATE_H__
#define __GTK_PICTURE_ACCESSIBLE_PRIVATE_H__
#include <gtk/a11y/gtkwidgetaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_PICTURE_ACCESSIBLE (gtk_picture_accessible_get_type ())
GDK_AVAILABLE_IN_ALL
G_DECLARE_FINAL_TYPE (GtkPictureAccessible, gtk_picture_accessible, GTK, PICTURE_ACCESSIBLE, GtkWidgetAccessible)
G_END_DECLS
#endif /* __GTK_PICTURE_ACCESSIBLE_PRIVATE_H__ */

View File

@@ -0,0 +1,93 @@
/* GTK - The GIMP Toolkit
* Copyright © 2014 Red Hat Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Author: Carlos Garnacho <carlosg@gnome.org>
*/
#include "config.h"
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include "gtkpopoveraccessible.h"
typedef struct _GtkPopoverAccessiblePrivate GtkPopoverAccessiblePrivate;
G_DEFINE_TYPE (GtkPopoverAccessible, gtk_popover_accessible, GTK_TYPE_WIDGET_ACCESSIBLE)
static void
popover_update_modality (AtkObject *object,
GtkPopover *popover)
{
atk_object_notify_state_change (object, ATK_STATE_MODAL,
gtk_popover_get_autohide (popover));
}
static void
popover_notify_cb (GtkPopover *popover,
GParamSpec *pspec,
AtkObject *object)
{
AtkObject *popover_accessible;
popover_accessible = gtk_widget_get_accessible (GTK_WIDGET (popover));
if (strcmp (g_param_spec_get_name (pspec), "modal") == 0)
popover_update_modality (popover_accessible, popover);
}
static void
gtk_popover_accessible_initialize (AtkObject *obj,
gpointer data)
{
GtkPopover *popover = GTK_POPOVER (data);
ATK_OBJECT_CLASS (gtk_popover_accessible_parent_class)->initialize (obj, data);
g_signal_connect (popover, "notify",
G_CALLBACK (popover_notify_cb), obj);
popover_update_modality (obj, popover);
obj->role = ATK_ROLE_PANEL;
}
static AtkStateSet *
gtk_popover_accessible_ref_state_set (AtkObject *obj)
{
AtkStateSet *state_set;
GtkWidget *widget;
state_set = ATK_OBJECT_CLASS (gtk_popover_accessible_parent_class)->ref_state_set (obj);
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (gtk_popover_get_autohide (GTK_POPOVER (widget)))
atk_state_set_add_state (state_set, ATK_STATE_MODAL);
return state_set;
}
static void
gtk_popover_accessible_class_init (GtkPopoverAccessibleClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
class->initialize = gtk_popover_accessible_initialize;
class->ref_state_set = gtk_popover_accessible_ref_state_set;
}
static void
gtk_popover_accessible_init (GtkPopoverAccessible *popover)
{
}

View File

@@ -0,0 +1,56 @@
/* GTK - The GIMP Toolkit
* Copyright © 2014 Red Hat Inc.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Author: Carlos Garnacho <carlosg@gnome.org>
*/
#ifndef __GTK_POPOVER_ACCESSIBLE_H__
#define __GTK_POPOVER_ACCESSIBLE_H__
#if !defined (__GTK_A11Y_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk-a11y.h> can be included directly."
#endif
#include <gtk/a11y/gtkwidgetaccessible.h>
G_BEGIN_DECLS
#define GTK_TYPE_POPOVER_ACCESSIBLE (gtk_popover_accessible_get_type ())
#define GTK_POPOVER_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_POPOVER_ACCESSIBLE, GtkPopoverAccessible))
#define GTK_POPOVER_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_POPOVER_ACCESSIBLE, GtkPopoverAccessibleClass))
#define GTK_IS_POPOVER_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_POPOVER_ACCESSIBLE))
#define GTK_IS_POPOVER_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_POPOVER_ACCESSIBLE))
#define GTK_POPOVER_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_POPOVER_ACCESSIBLE, GtkPopoverAccessibleClass))
typedef struct _GtkPopoverAccessible GtkPopoverAccessible;
typedef struct _GtkPopoverAccessibleClass GtkPopoverAccessibleClass;
struct _GtkPopoverAccessible
{
GtkWidgetAccessible parent;
};
struct _GtkPopoverAccessibleClass
{
GtkWidgetAccessibleClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType gtk_popover_accessible_get_type (void);
G_END_DECLS
#endif /* __GTK_POPOVER_ACCESSIBLE_H__ */

Some files were not shown because too many files have changed in this diff Show More