[Nautilus-list] two keynav/a11y patches
- From: Dave Camp <dave ximian com>
- To: nautilus-list eazel com
- Subject: [Nautilus-list] two keynav/a11y patches
- Date: 19 Apr 2002 15:33:42 -0400
The first patch makes the icon container popup a menu on shift-f10.
The second patch makes the zoom control show its focus, gives it some
keybindings, and adds AtkValue and AtkAction interfaces to it.The first
patch makes the icon container popup a menu on shift-f10.
The second patch makes the zoom control show its focus, gives it some
keybindings, and adds AtkValue and AtkAction interfaces to it.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.5200
diff -u -r1.5200 ChangeLog
--- ChangeLog 17 Apr 2002 13:46:07 -0000 1.5200
+++ ChangeLog 19 Apr 2002 17:44:19 -0000
@@ -1,3 +1,11 @@
+2002-04-17 Dave Camp <dave ximian com>
+
+ * libnautilus-private/nautilus-icon-container.c (popup_menu): New
+ function, handles the popup menu signal by emitting
+ context_click_selection or context_click_background.
+ (nautilus_icon_container_class_init): Initialize
+ widget_class->popup_menu.
+
2002-04-17 Anders Carlsson <andersca gnu org>
* components/hardware/nautilus-hardware-view.c:
Index: libnautilus-private/nautilus-icon-container.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-container.c,v
retrieving revision 1.272
diff -u -r1.272 nautilus-icon-container.c
--- libnautilus-private/nautilus-icon-container.c 14 Apr 2002 06:42:20 -0000 1.272
+++ libnautilus-private/nautilus-icon-container.c 19 Apr 2002 17:44:21 -0000
@@ -3034,6 +3034,28 @@
return eel_accessibility_set_atk_object_return (widget, accessible);
}
+static gboolean
+popup_menu (GtkWidget *widget)
+{
+ GList *l;
+ NautilusIcon *icon;
+ NautilusIconContainer *container;
+ container = NAUTILUS_ICON_CONTAINER (widget);
+ for (l = container->details->icons; l != NULL; l = l->next) {
+ icon = l->data;
+ if (icon->is_selected) {
+ g_signal_emit (widget,
+ signals[CONTEXT_CLICK_SELECTION],
+ 0, NULL);
+ return TRUE;
+ }
+ }
+
+ g_signal_emit (widget, signals[CONTEXT_CLICK_BACKGROUND], 0, NULL);
+
+ return TRUE;
+}
+
/* Initialization. */
static void
@@ -3316,6 +3338,7 @@
widget_class->motion_notify_event = motion_notify_event;
widget_class->key_press_event = key_press_event;
widget_class->get_accessible = get_accessible;
+ widget_class->popup_menu = popup_menu;
/* Initialize the stipple bitmap. */
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.5200
diff -u -r1.5200 ChangeLog
--- ChangeLog 17 Apr 2002 13:46:07 -0000 1.5200
+++ ChangeLog 19 Apr 2002 17:45:24 -0000
@@ -1,3 +1,28 @@
+2002-04-17 Dave Camp <dave ximian com>
+
+ * src/nautilus-zoom-control.c: (nautilus_zoom_control_expose):
+ Draw the focus rectangle if the zoom control is focused.
+ (nautilus_zoom_control_button_press_event): Grab focus.
+ (nautilus_zoom_control_class_init): Initialize keybindings.
+ (nautilus_zoom_control_get_accessible),
+ (nautilus_zoom_control_change_value),
+ (nautilus_zoom_control_accessible_do_action),
+ (nautilus_zoom_control_accessible_get_n_actions),
+ (nautilus_zoom_control_accessible_action_get_description),
+ (nautilus_zoom_control_accessible_action_get_name),
+ (nautilus_zoom_control_accessible_action_interface_init),
+ (nautilus_zoom_control_accessible_get_current_value),
+ (nautilus_zoom_control_accessible_get_maximum_value),
+ (nautilus_zoom_control_accessible_get_minimum_value),
+ (nautilus_zoom_control_accessible_set_current_value),
+ (nautilus_zoom_control_accessible_value_interface_init),
+ (nautilus_zoom_control_accessible_get_name),
+ (nautilus_zoom_control_accessible_get_description),
+ (nautilus_zoom_control_accessible_class_init),
+ (nautilus_zoom_control_accessible_get_type): Implement the zoom
+ control accessible.
+ * src/nautilus-zoom-control.h: Added the change_value signal.
+
2002-04-17 Anders Carlsson <andersca gnu org>
* components/hardware/nautilus-hardware-view.c:
Index: src/nautilus-zoom-control.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-zoom-control.c,v
retrieving revision 1.68
diff -u -r1.68 nautilus-zoom-control.c
--- src/nautilus-zoom-control.c 21 Mar 2002 00:03:39 -0000 1.68
+++ src/nautilus-zoom-control.c 19 Apr 2002 17:45:25 -0000
@@ -28,11 +28,17 @@
#include <config.h>
#include "nautilus-zoom-control.h"
+#include <atk/atkaction.h>
+#include <bonobo/bonobo-i18n.h>
+#include <eel/eel-accessibility.h>
#include <eel/eel-glib-extensions.h>
#include <eel/eel-graphic-effects.h>
#include <eel/eel-gtk-extensions.h>
+#include <gtk/gtkaccessible.h>
#include <gtk/gtkmenu.h>
#include <gtk/gtkradiomenuitem.h>
+#include <gtk/gtkbindings.h>
+#include <gdk/gdkkeysyms.h>
#include <libgnome/gnome-macros.h>
#include <libnautilus-private/nautilus-file-utilities.h>
#include <libnautilus-private/nautilus-global-preferences.h>
@@ -47,6 +53,7 @@
ZOOM_OUT,
ZOOM_TO_LEVEL,
ZOOM_TO_FIT,
+ CHANGE_VALUE,
LAST_SIGNAL
};
@@ -82,10 +89,32 @@
static guint signals[LAST_SIGNAL];
+gpointer accessible_parent_class;
+
+static const char *nautilus_zoom_control_accessible_action_names[] = {
+ N_("Zoom In"),
+ N_("Zoom Out"),
+ N_("Zoom to Fit"),
+};
+
+static int nautilus_zoom_control_accessible_action_signals[] = {
+ ZOOM_IN,
+ ZOOM_OUT,
+ ZOOM_TO_FIT
+};
+
+static const char *nautilus_zoom_control_accessible_action_descriptions[] = {
+ N_("Show the contents in more detail"),
+ N_("Show the contents in less detail"),
+ N_("Show the contents at optimal size"),
+};
+
static void nautilus_zoom_control_load_images (NautilusZoomControl *zoom_control);
static void nautilus_zoom_control_unload_images (NautilusZoomControl *zoom_control);
static void nautilus_zoom_control_theme_changed (gpointer user_data);
+static GType nautilus_zoom_control_accessible_get_type (void);
+
/* button assignments */
#define CONTEXTUAL_MENU_BUTTON 3
@@ -346,6 +375,17 @@
draw_zoom_control_image (widget, &box);
draw_number (widget, &box);
+
+ if (GTK_WIDGET_HAS_FOCUS (widget)) {
+ gtk_paint_focus (widget->style,
+ widget->window,
+ GTK_WIDGET_STATE (widget),
+ &event->area,
+ widget,
+ "nautilus-zoom-control",
+ box.x, box.y,
+ box.width, box.height);
+ }
return FALSE;
}
@@ -560,6 +600,8 @@
zoom_control = NAUTILUS_ZOOM_CONTROL (widget);
+ gtk_widget_grab_focus (widget);
+
/* check for the context menu button and handle by creating and showing the menu */
if (event->button == CONTEXTUAL_MENU_BUTTON) {
eel_pop_up_context_menu (create_zoom_menu (zoom_control),
@@ -585,7 +627,7 @@
* someone (e.g. nautilus_window) picks up and handles by calling into us -
* nautilus_zoom_control_set_zoom_level.
*/
-
+
return TRUE;
}
@@ -601,6 +643,21 @@
return FALSE;
}
+static AtkObject *
+nautilus_zoom_control_get_accessible (GtkWidget *widget)
+{
+ AtkObject *accessible;
+
+ if ((accessible = eel_accessibility_get_atk_object (widget))) {
+ return accessible;
+ }
+
+ accessible = g_object_new
+ (nautilus_zoom_control_accessible_get_type (), NULL);
+
+ return eel_accessibility_set_atk_object_return (widget, accessible);
+}
+
static gboolean
nautilus_zoom_control_motion_notify (GtkWidget *widget, GdkEventMotion *event)
{
@@ -647,6 +704,26 @@
nautilus_zoom_control_update_offsets (zoom_control);
}
+static void
+nautilus_zoom_control_change_value (NautilusZoomControl *zoom_control,
+ GtkScrollType scroll)
+{
+ switch (scroll) {
+ case GTK_SCROLL_STEP_DOWN :
+ if (nautilus_zoom_control_can_zoom_out (zoom_control)) {
+ g_signal_emit (zoom_control, signals[ZOOM_OUT], 0);
+ }
+ break;
+ case GTK_SCROLL_STEP_UP :
+ if (nautilus_zoom_control_can_zoom_in (zoom_control)) {
+ g_signal_emit (zoom_control, signals[ZOOM_IN], 0);
+ }
+ break;
+ default :
+ g_warning ("Invalid scroll type %d for NautilusZoomControl:change_value", scroll);
+ }
+}
+
void
nautilus_zoom_control_set_zoom_level (NautilusZoomControl *zoom_control, double zoom_level)
{
@@ -723,6 +800,7 @@
nautilus_zoom_control_class_init (NautilusZoomControlClass *class)
{
GtkWidgetClass *widget_class;
+ GtkBindingSet *binding_set;
G_OBJECT_CLASS (class)->finalize = nautilus_zoom_control_finalize;
@@ -733,7 +811,10 @@
widget_class->motion_notify_event = nautilus_zoom_control_motion_notify;
widget_class->size_allocate = nautilus_zoom_control_size_allocate;
widget_class->leave_notify_event = nautilus_zoom_control_leave_notify;
+ widget_class->get_accessible = nautilus_zoom_control_get_accessible;
+ class->change_value = nautilus_zoom_control_change_value;
+
signals[ZOOM_IN] =
g_signal_new ("zoom_in",
G_TYPE_FROM_CLASS (class),
@@ -769,10 +850,239 @@
signals[ZOOM_TO_FIT] =
g_signal_new ("zoom_to_fit",
G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (NautilusZoomControlClass,
zoom_to_fit),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
+ signals[CHANGE_VALUE] =
+ g_signal_new ("change_value",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (NautilusZoomControlClass,
+ change_value),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__ENUM,
+ G_TYPE_NONE, 1, GTK_TYPE_SCROLL_TYPE);
+
+ binding_set = gtk_binding_set_by_class (class);
+
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_KP_Subtract, 0,
+ "change_value",
+ 1, GTK_TYPE_SCROLL_TYPE,
+ GTK_SCROLL_STEP_DOWN);
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_minus, 0,
+ "change_value",
+ 1, GTK_TYPE_SCROLL_TYPE,
+ GTK_SCROLL_STEP_DOWN);
+
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_KP_Equal, 0,
+ "zoom_to_fit",
+ 0);
+
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_KP_Add, 0,
+ "change_value",
+ 1, GTK_TYPE_SCROLL_TYPE,
+ GTK_SCROLL_STEP_UP);
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_equal, 0,
+ "change_value",
+ 1, GTK_TYPE_SCROLL_TYPE,
+ GTK_SCROLL_STEP_UP);
+}
+
+static gboolean
+nautilus_zoom_control_accessible_do_action (AtkAction *accessible, int i)
+{
+ GtkWidget *widget;
+
+ widget = GTK_ACCESSIBLE (accessible)->widget;
+ if (!widget) {
+ return FALSE;
+ }
+
+ g_signal_emit (widget,
+ signals[nautilus_zoom_control_accessible_action_signals [i]],
+ 0);
+
+ return TRUE;
+}
+
+static int
+nautilus_zoom_control_accessible_get_n_actions (AtkAction *accessible)
+{
+ return sizeof (nautilus_zoom_control_accessible_action_names) / sizeof (nautilus_zoom_control_accessible_action_names[0]);;
+}
+
+static G_CONST_RETURN char *
+nautilus_zoom_control_accessible_action_get_description (AtkAction *accessible,
+ int i)
+{
+ return _(nautilus_zoom_control_accessible_action_descriptions[i]);
+}
+
+static G_CONST_RETURN char *
+nautilus_zoom_control_accessible_action_get_name (AtkAction *accessible,
+ int i)
+{
+ return _(nautilus_zoom_control_accessible_action_names[i]);
+}
+
+static void
+nautilus_zoom_control_accessible_action_interface_init (AtkActionIface *iface)
+{
+ iface->do_action = nautilus_zoom_control_accessible_do_action;
+ iface->get_n_actions = nautilus_zoom_control_accessible_get_n_actions;
+ iface->get_description = nautilus_zoom_control_accessible_action_get_description;
+ iface->get_name = nautilus_zoom_control_accessible_action_get_name;
+}
+
+static void
+nautilus_zoom_control_accessible_get_current_value (AtkValue *accessible,
+ GValue *value)
+{
+ NautilusZoomControl *control;
+
+ g_value_init (value, G_TYPE_DOUBLE);
+
+ control = NAUTILUS_ZOOM_CONTROL (GTK_ACCESSIBLE (accessible)->widget);
+ if (!control) {
+ g_value_set_double (value, 0.0);
+ return;
+ }
+
+ g_value_set_double (value, control->details->zoom_level);
+}
+
+static void
+nautilus_zoom_control_accessible_get_maximum_value (AtkValue *accessible,
+ GValue *value)
+{
+ NautilusZoomControl *control;
+
+ g_value_init (value, G_TYPE_DOUBLE);
+
+ control = NAUTILUS_ZOOM_CONTROL (GTK_ACCESSIBLE (accessible)->widget);
+ if (!control) {
+ g_value_set_double (value, 0);
+ return;
+ }
+
+ g_value_set_double (value, control->details->max_zoom_level);
+}
+
+static void
+nautilus_zoom_control_accessible_get_minimum_value (AtkValue *accessible,
+ GValue *value)
+{
+ NautilusZoomControl *control;
+
+ g_value_init (value, G_TYPE_DOUBLE);
+
+ control = NAUTILUS_ZOOM_CONTROL (GTK_ACCESSIBLE (accessible)->widget);
+ if (!control) {
+ g_value_set_double (value, 0);
+ return;
+ }
+
+ g_value_set_double (value, control->details->min_zoom_level);
+}
+
+static gboolean
+nautilus_zoom_control_accessible_set_current_value (AtkValue *accessible,
+ const GValue *value)
+{
+ NautilusZoomControl *control;
+ gboolean can_zoom;
+ double zoom;
+
+ control = NAUTILUS_ZOOM_CONTROL (GTK_ACCESSIBLE (accessible)->widget);
+ if (!control) {
+ return FALSE;
+ }
+
+ zoom = g_value_get_double (value);
+
+ can_zoom = TRUE;
+ if (control->details->has_min_zoom_level &&
+ zoom < control->details->min_zoom_level)
+ can_zoom = FALSE; /* no, we're below the minimum zoom level. */
+ if (control->details->has_max_zoom_level &&
+ zoom > control->details->max_zoom_level)
+ can_zoom = FALSE; /* no, we're beyond the upper zoom level. */
+
+ if (can_zoom) {
+ g_signal_emit (control, signals[ZOOM_TO_LEVEL], 0, zoom);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
+nautilus_zoom_control_accessible_value_interface_init (AtkValueIface *iface)
+{
+ iface->get_current_value = nautilus_zoom_control_accessible_get_current_value;
+ iface->get_maximum_value = nautilus_zoom_control_accessible_get_maximum_value;
+ iface->get_minimum_value = nautilus_zoom_control_accessible_get_minimum_value;
+ iface->set_current_value = nautilus_zoom_control_accessible_set_current_value;
+}
+
+static G_CONST_RETURN char *
+nautilus_zoom_control_accessible_get_name (AtkObject *accessible)
+{
+ return _("Zoom");
+}
+
+static G_CONST_RETURN char *
+nautilus_zoom_control_accessible_get_description (AtkObject *accessible)
+{
+ return _("Set the zoom level of the current view");
+}
+
+static void
+nautilus_zoom_control_accessible_class_init (AtkObjectClass *klass)
+{
+ accessible_parent_class = g_type_class_peek_parent (klass);
+
+ klass->get_name = nautilus_zoom_control_accessible_get_name;
+ klass->get_description = nautilus_zoom_control_accessible_get_description;
+}
+
+static GType
+nautilus_zoom_control_accessible_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type) {
+ static GInterfaceInfo atk_action_info = {
+ (GInterfaceInitFunc)nautilus_zoom_control_accessible_action_interface_init,
+ (GInterfaceFinalizeFunc)NULL,
+ NULL
+ };
+
+ static GInterfaceInfo atk_value_info = {
+ (GInterfaceInitFunc)nautilus_zoom_control_accessible_value_interface_init,
+ (GInterfaceFinalizeFunc)NULL,
+ NULL
+ };
+
+ type = eel_accessibility_create_derived_type
+ ("NautilusZoomControlAccessible",
+ GTK_TYPE_EVENT_BOX,
+ nautilus_zoom_control_accessible_class_init);
+
+ g_type_add_interface_static (type, ATK_TYPE_ACTION,
+ &atk_action_info);
+ g_type_add_interface_static (type, ATK_TYPE_VALUE,
+ &atk_value_info);
+ }
+
+ return type;
}
Index: src/nautilus-zoom-control.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-zoom-control.h,v
retrieving revision 1.15
diff -u -r1.15 nautilus-zoom-control.h
--- src/nautilus-zoom-control.h 8 Mar 2002 09:29:57 -0000 1.15
+++ src/nautilus-zoom-control.h 19 Apr 2002 17:45:25 -0000
@@ -52,6 +52,10 @@
void (*zoom_out) (NautilusZoomControl *control);
void (*zoom_to_level) (NautilusZoomControl *control);
void (*zoom_to_fit) (NautilusZoomControl *control);
+
+ /* Action signal for keybindings, do not connect to this */
+ void (*change_value) (NautilusZoomControl *control,
+ GtkScrollType scroll);
};
GtkType nautilus_zoom_control_get_type (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]