summaryrefslogtreecommitdiff
path: root/gtk/gtkpathbar.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2007-05-16 17:42:53 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2007-05-16 17:42:53 +0000
commit6d80f2d1dc32295fbd666df469f7010d20892cdc (patch)
tree4debd44de4a5048ef894767aaaeb3c2020eec842 /gtk/gtkpathbar.c
parent94dcec33c18664b4bc6e8e595c94e33a664b2ec2 (diff)
downloadgtk+-6d80f2d1dc32295fbd666df469f7010d20892cdc.tar.gz
Add ATK names to the Up, Down, and Root buttons. Keep the focus from
2007-05-16 Matthias Clasen <mclasen@redhat.com> * gtk/gtkpathbar.c: Add ATK names to the Up, Down, and Root buttons. Keep the focus from vanishing when Up or Down arrows become insensitive or invisible. (#357005, Patrick Wade) svn path=/trunk/; revision=17856
Diffstat (limited to 'gtk/gtkpathbar.c')
-rw-r--r--gtk/gtkpathbar.c77
1 files changed, 76 insertions, 1 deletions
diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c
index 3e78225ada..fdda4f9308 100644
--- a/gtk/gtkpathbar.c
+++ b/gtk/gtkpathbar.c
@@ -98,6 +98,12 @@ static void gtk_path_bar_scroll_up (GtkWidget *button,
static void gtk_path_bar_scroll_down (GtkWidget *button,
GtkPathBar *path_bar);
static void gtk_path_bar_stop_scrolling (GtkPathBar *path_bar);
+static gboolean gtk_path_bar_slider_up_defocus (GtkWidget *widget,
+ GdkEventButton *event,
+ GtkPathBar *path_bar);
+static gboolean gtk_path_bar_slider_down_defocus (GtkWidget *widget,
+ GdkEventButton *event,
+ GtkPathBar *path_bar);
static gboolean gtk_path_bar_slider_button_press (GtkWidget *widget,
GdkEventButton *event,
GtkPathBar *path_bar);
@@ -132,10 +138,17 @@ get_slider_button (GtkPathBar *path_bar,
GtkArrowType arrow_type)
{
GtkWidget *button;
+ AtkObject *atk_obj;
gtk_widget_push_composite_child ();
button = gtk_button_new ();
+ atk_obj = gtk_widget_get_accessible (button);
+ if (arrow_type == GTK_ARROW_LEFT)
+ atk_object_set_name (atk_obj, _("Up Path"));
+ else
+ atk_object_set_name (atk_obj, _("Down Path"));
+
gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
gtk_container_add (GTK_CONTAINER (button), gtk_arrow_new (arrow_type, GTK_SHADOW_OUT));
gtk_container_add (GTK_CONTAINER (path_bar), button);
@@ -165,6 +178,9 @@ gtk_path_bar_init (GtkPathBar *path_bar)
g_signal_connect (path_bar->up_slider_button, "clicked", G_CALLBACK (gtk_path_bar_scroll_up), path_bar);
g_signal_connect (path_bar->down_slider_button, "clicked", G_CALLBACK (gtk_path_bar_scroll_down), path_bar);
+ g_signal_connect (path_bar->up_slider_button, "focus_out_event", G_CALLBACK (gtk_path_bar_slider_up_defocus), path_bar);
+ g_signal_connect (path_bar->down_slider_button, "focus_out_event", G_CALLBACK (gtk_path_bar_slider_down_defocus), path_bar);
+
g_signal_connect (path_bar->up_slider_button, "button_press_event", G_CALLBACK (gtk_path_bar_slider_button_press), path_bar);
g_signal_connect (path_bar->up_slider_button, "button_release_event", G_CALLBACK (gtk_path_bar_slider_button_release), path_bar);
g_signal_connect (path_bar->down_slider_button, "button_press_event", G_CALLBACK (gtk_path_bar_slider_button_press), path_bar);
@@ -794,6 +810,62 @@ gtk_path_bar_stop_scrolling (GtkPathBar *path_bar)
}
static gboolean
+gtk_path_bar_slider_up_defocus (GtkWidget *widget,
+ GdkEventButton *event,
+ GtkPathBar *path_bar)
+{
+ GList *list;
+ GList *up_button = NULL;
+
+ if (event->type != GDK_FOCUS_CHANGE)
+ return FALSE;
+
+ for (list = g_list_last (path_bar->button_list); list; list = list->prev)
+ {
+ if (gtk_widget_get_child_visible (BUTTON_DATA (list->data)->button))
+ {
+ up_button = list;
+ break;
+ }
+ }
+
+ /* don't let the focus vanish */
+ if ((!GTK_WIDGET_IS_SENSITIVE (path_bar->up_slider_button)) ||
+ (!gtk_widget_get_child_visible (path_bar->up_slider_button)))
+ gtk_widget_grab_focus (BUTTON_DATA (up_button->data)->button);
+
+ return FALSE;
+}
+
+static gboolean
+gtk_path_bar_slider_down_defocus (GtkWidget *widget,
+ GdkEventButton *event,
+ GtkPathBar *path_bar)
+{
+ GList *list;
+ GList *down_button = NULL;
+
+ if (event->type != GDK_FOCUS_CHANGE)
+ return FALSE;
+
+ for (list = path_bar->button_list; list; list = list->next)
+ {
+ if (gtk_widget_get_child_visible (BUTTON_DATA (list->data)->button))
+ {
+ down_button = list;
+ break;
+ }
+ }
+
+ /* don't let the focus vanish */
+ if ((!GTK_WIDGET_IS_SENSITIVE (path_bar->down_slider_button)) ||
+ (!gtk_widget_get_child_visible (path_bar->down_slider_button)))
+ gtk_widget_grab_focus (BUTTON_DATA (down_button->data)->button);
+
+ return FALSE;
+}
+
+static gboolean
gtk_path_bar_slider_button_press (GtkWidget *widget,
GdkEventButton *event,
GtkPathBar *path_bar)
@@ -1279,6 +1351,7 @@ make_directory_button (GtkPathBar *path_bar,
{ "text/uri-list", 0, 0 }
};
+ AtkObject *atk_obj;
GtkWidget *child = NULL;
GtkWidget *label_alignment = NULL;
ButtonData *button_data;
@@ -1289,6 +1362,7 @@ make_directory_button (GtkPathBar *path_bar,
button_data->type = find_button_type (path_bar, path);
button_data->button = gtk_toggle_button_new ();
+ atk_obj = gtk_widget_get_accessible (button_data->button);
gtk_button_set_focus_on_click (GTK_BUTTON (button_data->button), FALSE);
switch (button_data->type)
@@ -1296,7 +1370,8 @@ make_directory_button (GtkPathBar *path_bar,
case ROOT_BUTTON:
button_data->image = gtk_image_new ();
child = button_data->image;
- button_data->label = NULL;
+ button_data->label = gtk_label_new (NULL);
+ atk_object_set_name (atk_obj, _("File System Root"));
break;
case HOME_BUTTON:
case DESKTOP_BUTTON: