| 1 |
/* GTK+ - accessibility implementations |
| 2 |
* Copyright 2001, 2002, 2003 Sun Microsystems Inc. |
| 3 |
* |
| 4 |
* This library is free software; you can redistribute it and/or |
| 5 |
* modify it under the terms of the GNU Lesser General Public |
| 6 |
* License as published by the Free Software Foundation; either |
| 7 |
* version 2 of the License, or (at your option) any later version. |
| 8 |
* |
| 9 |
* This library is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 |
* Lesser General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU Lesser General Public |
| 15 |
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
*/ |
| 17 |
|
| 18 |
#include "config.h" |
| 19 |
|
| 20 |
#include <string.h> |
| 21 |
#include <gtk/gtk.h> |
| 22 |
#include <glib/gi18n-lib.h> |
| 23 |
#include "gtkfilechooserwidgetaccessible.h" |
| 24 |
|
| 25 |
|
| 26 |
static void atk_action_interface_init (AtkActionIface *iface); |
| 27 |
|
| 28 |
G_DEFINE_TYPE_WITH_CODE (GtkFileChooserWidgetAccessible, gtk_file_chooser_widget_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE, |
| 29 |
G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init)) |
| 30 |
|
| 31 |
static void |
| 32 |
gtk_file_chooser_widget_accessible_initialize (AtkObject *obj, |
| 33 |
gpointer data) |
| 34 |
{ |
| 35 |
ATK_OBJECT_CLASS (gtk_file_chooser_widget_accessible_parent_class)->initialize (obj, data); |
| 36 |
obj->role = ATK_ROLE_FILE_CHOOSER; |
| 37 |
} |
| 38 |
|
| 39 |
static void |
| 40 |
gtk_file_chooser_widget_accessible_class_init (GtkFileChooserWidgetAccessibleClass *klass) |
| 41 |
{ |
| 42 |
AtkObjectClass *class = ATK_OBJECT_CLASS (klass); |
| 43 |
GtkContainerAccessibleClass *container_class = (GtkContainerAccessibleClass*)klass; |
| 44 |
|
| 45 |
class->initialize = gtk_file_chooser_widget_accessible_initialize; |
| 46 |
|
| 47 |
container_class->add_gtk = NULL; |
| 48 |
container_class->remove_gtk = NULL; |
| 49 |
} |
| 50 |
|
| 51 |
static void |
| 52 |
gtk_file_chooser_widget_accessible_init (GtkFileChooserWidgetAccessible *file_chooser_widget) |
| 53 |
{ |
| 54 |
} |
| 55 |
|
| 56 |
static gboolean |
| 57 |
gtk_file_chooser_widget_accessible_do_action (AtkAction *action, |
| 58 |
gint i) |
| 59 |
{ |
| 60 |
GtkWidget *widget; |
| 61 |
|
| 62 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (action)); |
| 63 |
if (widget == NULL) |
| 64 |
return FALSE; |
| 65 |
|
| 66 |
if (!gtk_widget_is_sensitive (widget) || !gtk_widget_get_visible (widget)) |
| 67 |
return FALSE; |
| 68 |
|
| 69 |
switch (i) |
| 70 |
{ |
| 71 |
case 0: |
| 72 |
g_signal_emit_by_name (GTK_FILE_CHOOSER_WIDGET (widget), "location-popup", ""); |
| 73 |
return TRUE; |
| 74 |
default: |
| 75 |
break; |
| 76 |
} |
| 77 |
|
| 78 |
return FALSE; |
| 79 |
} |
| 80 |
|
| 81 |
static gint |
| 82 |
gtk_file_chooser_widget_accessible_get_n_actions (AtkAction *action) |
| 83 |
{ |
| 84 |
return 1; |
| 85 |
} |
| 86 |
|
| 87 |
static const gchar * |
| 88 |
gtk_file_chooser_widget_accessible_action_get_name (AtkAction *action, |
| 89 |
gint i) |
| 90 |
{ |
| 91 |
if (i == 0) |
| 92 |
return "show_location"; |
| 93 |
return NULL; |
| 94 |
} |
| 95 |
|
| 96 |
static const gchar * |
| 97 |
gtk_file_chooser_widget_accessible_action_get_localized_name (AtkAction *action, |
| 98 |
gint i) |
| 99 |
{ |
| 100 |
if (i == 0) |
| 101 |
return C_("Action name", "Show location"); |
| 102 |
return NULL; |
| 103 |
} |
| 104 |
|
| 105 |
static const gchar * |
| 106 |
gtk_file_chooser_widget_accessible_action_get_description (AtkAction *action, |
| 107 |
gint i) |
| 108 |
{ |
| 109 |
if (i == 0) |
| 110 |
return C_("Action description", "Show the File Chooser's Location text field"); |
| 111 |
return NULL; |
| 112 |
} |
| 113 |
|
| 114 |
static void |
| 115 |
atk_action_interface_init (AtkActionIface *iface) |
| 116 |
{ |
| 117 |
iface->do_action = gtk_file_chooser_widget_accessible_do_action; |
| 118 |
iface->get_n_actions = gtk_file_chooser_widget_accessible_get_n_actions; |
| 119 |
iface->get_name = gtk_file_chooser_widget_accessible_action_get_name; |
| 120 |
iface->get_localized_name = gtk_file_chooser_widget_accessible_action_get_localized_name; |
| 121 |
iface->get_description = gtk_file_chooser_widget_accessible_action_get_description; |
| 122 |
} |