diff options
author | Dave Camp <dave@ximian.com> | 2002-04-26 19:45:22 +0000 |
---|---|---|
committer | Dave Camp <campd@src.gnome.org> | 2002-04-26 19:45:22 +0000 |
commit | 6470cc2fe404f9800efe8353e5e95f5a230a6dbb (patch) | |
tree | 395e41f65490308387173b7f31c6d1a9787fe278 /src | |
parent | 7bae31df7a8965658a45d1bfa5063ac082635703 (diff) | |
download | nautilus-6470cc2fe404f9800efe8353e5e95f5a230a6dbb.tar.gz |
Replace doubles in the zoom interfaces with floats to match the bonobo
2002-04-24 Dave Camp <dave@ximian.com>
* src/nautilus-view-frame.c: (nautilus_view_frame_set_zoom_level):
* src/nautilus-view-frame.h:
* src/nautilus-window-manage-views.c:
(zoom_parameters_changed_callback):
* src/nautilus-window-private.h:
* src/nautilus-window.c: (nautilus_window_zoom_to_level): Replace
doubles in the zoom interfaces with floats to match the bonobo
zoomable interface.
* 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.
(zoom_menu_callback), (create_zoom_menu_item),
(nautilus_zoom_control_change_value),
(nautilus_zoom_control_set_zoom_level),
(nautilus_zoom_control_set_parameters): Replace double with float.
(nautilus_zoom_control_class_init): Initialize keybindings.
(nautilus_zoom_control_get_accessible),
(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),
(nearest_preferred),
(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
accessible.
* src/nautilus-zoom-control.h: Added the change_value signal.
Diffstat (limited to 'src')
-rw-r--r-- | src/nautilus-navigation-window.c | 2 | ||||
-rw-r--r-- | src/nautilus-object-window.c | 2 | ||||
-rw-r--r-- | src/nautilus-spatial-window.c | 2 | ||||
-rw-r--r-- | src/nautilus-view-frame.c | 10 | ||||
-rw-r--r-- | src/nautilus-view-frame.h | 8 | ||||
-rw-r--r-- | src/nautilus-window-manage-views.c | 2 | ||||
-rw-r--r-- | src/nautilus-window-private.h | 2 | ||||
-rw-r--r-- | src/nautilus-window.c | 2 | ||||
-rw-r--r-- | src/nautilus-zoom-control.c | 381 | ||||
-rw-r--r-- | src/nautilus-zoom-control.h | 19 |
10 files changed, 391 insertions, 39 deletions
diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c index 4e6130664..652d8f1b7 100644 --- a/src/nautilus-navigation-window.c +++ b/src/nautilus-navigation-window.c @@ -423,7 +423,7 @@ nautilus_window_zoom_in (NautilusWindow *window) } void -nautilus_window_zoom_to_level (NautilusWindow *window, double level) +nautilus_window_zoom_to_level (NautilusWindow *window, float level) { if (window->content_view != NULL) { nautilus_view_frame_set_zoom_level (window->content_view, level); diff --git a/src/nautilus-object-window.c b/src/nautilus-object-window.c index 4e6130664..652d8f1b7 100644 --- a/src/nautilus-object-window.c +++ b/src/nautilus-object-window.c @@ -423,7 +423,7 @@ nautilus_window_zoom_in (NautilusWindow *window) } void -nautilus_window_zoom_to_level (NautilusWindow *window, double level) +nautilus_window_zoom_to_level (NautilusWindow *window, float level) { if (window->content_view != NULL) { nautilus_view_frame_set_zoom_level (window->content_view, level); diff --git a/src/nautilus-spatial-window.c b/src/nautilus-spatial-window.c index 4e6130664..652d8f1b7 100644 --- a/src/nautilus-spatial-window.c +++ b/src/nautilus-spatial-window.c @@ -423,7 +423,7 @@ nautilus_window_zoom_in (NautilusWindow *window) } void -nautilus_window_zoom_to_level (NautilusWindow *window, double level) +nautilus_window_zoom_to_level (NautilusWindow *window, float level) { if (window->content_view != NULL) { nautilus_view_frame_set_zoom_level (window->content_view, level); diff --git a/src/nautilus-view-frame.c b/src/nautilus-view-frame.c index 91bee5ce6..584e65ad3 100644 --- a/src/nautilus-view-frame.c +++ b/src/nautilus-view-frame.c @@ -921,7 +921,7 @@ nautilus_view_frame_get_is_zoomable (NautilusViewFrame *view) return view->details->zoomable_frame != NULL; } -double +float nautilus_view_frame_get_zoom_level (NautilusViewFrame *view) { g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), 0.0); @@ -935,7 +935,7 @@ nautilus_view_frame_get_zoom_level (NautilusViewFrame *view) void nautilus_view_frame_set_zoom_level (NautilusViewFrame *view, - double zoom_level) + float zoom_level) { g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); @@ -943,10 +943,10 @@ nautilus_view_frame_set_zoom_level (NautilusViewFrame *view, return; } - bonobo_zoomable_frame_set_zoom_level (view->details->zoomable_frame, (float) zoom_level); + bonobo_zoomable_frame_set_zoom_level (view->details->zoomable_frame, zoom_level); } -double +float nautilus_view_frame_get_min_zoom_level (NautilusViewFrame *view) { g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), 0.0); @@ -958,7 +958,7 @@ nautilus_view_frame_get_min_zoom_level (NautilusViewFrame *view) return bonobo_zoomable_frame_get_min_zoom_level (view->details->zoomable_frame); } -double +float nautilus_view_frame_get_max_zoom_level (NautilusViewFrame *view) { g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), 0.0); diff --git a/src/nautilus-view-frame.h b/src/nautilus-view-frame.h index bc684e4ed..76d45d967 100644 --- a/src/nautilus-view-frame.h +++ b/src/nautilus-view-frame.h @@ -115,11 +115,11 @@ void nautilus_view_frame_title_changed (NautilusViewFr const char *title); /* calls to Bonobo:Zoomable functions */ -double nautilus_view_frame_get_zoom_level (NautilusViewFrame *view); +float nautilus_view_frame_get_zoom_level (NautilusViewFrame *view); void nautilus_view_frame_set_zoom_level (NautilusViewFrame *view, - double zoom_level); -double nautilus_view_frame_get_min_zoom_level (NautilusViewFrame *view); -double nautilus_view_frame_get_max_zoom_level (NautilusViewFrame *view); + float zoom_level); +float nautilus_view_frame_get_min_zoom_level (NautilusViewFrame *view); +float nautilus_view_frame_get_max_zoom_level (NautilusViewFrame *view); gboolean nautilus_view_frame_get_has_min_zoom_level (NautilusViewFrame *view); gboolean nautilus_view_frame_get_has_max_zoom_level (NautilusViewFrame *view); gboolean nautilus_view_frame_get_is_continuous (NautilusViewFrame *view); diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c index c9d89b166..dbf43f1fa 100644 --- a/src/nautilus-window-manage-views.c +++ b/src/nautilus-window-manage-views.c @@ -1604,7 +1604,7 @@ static void zoom_parameters_changed_callback (NautilusViewFrame *view, NautilusWindow *window) { - double zoom_level; + float zoom_level; g_assert (NAUTILUS_IS_WINDOW (window)); diff --git a/src/nautilus-window-private.h b/src/nautilus-window-private.h index 73680f2c4..410e1f005 100644 --- a/src/nautilus-window-private.h +++ b/src/nautilus-window-private.h @@ -151,7 +151,7 @@ void nautilus_window_update_show_hide_menu_items (Nautil void nautilus_window_zoom_in (NautilusWindow *window); void nautilus_window_zoom_out (NautilusWindow *window); void nautilus_window_zoom_to_level (NautilusWindow *window, - double level); + float level); void nautilus_window_zoom_to_fit (NautilusWindow *window); void nautilus_window_show_view_as_dialog (NautilusWindow *window); void nautilus_window_set_content_view_widget (NautilusWindow *window, diff --git a/src/nautilus-window.c b/src/nautilus-window.c index 4e6130664..652d8f1b7 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -423,7 +423,7 @@ nautilus_window_zoom_in (NautilusWindow *window) } void -nautilus_window_zoom_to_level (NautilusWindow *window, double level) +nautilus_window_zoom_to_level (NautilusWindow *window, float level) { if (window->content_view != NULL) { nautilus_view_frame_set_zoom_level (window->content_view, level); diff --git a/src/nautilus-zoom-control.c b/src/nautilus-zoom-control.c index db53f0c4b..3ecd9ce38 100644 --- a/src/nautilus-zoom-control.c +++ b/src/nautilus-zoom-control.c @@ -28,11 +28,17 @@ #include <config.h> #include "nautilus-zoom-control.h" +#include <atk/atkaction.h> +#include <libgnome/gnome-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 @@ enum { ZOOM_OUT, ZOOM_TO_LEVEL, ZOOM_TO_FIT, + CHANGE_VALUE, LAST_SIGNAL }; @@ -60,9 +67,9 @@ typedef enum { #define GAP_WIDTH 2 struct NautilusZoomControlDetails { - double zoom_level; - double min_zoom_level; - double max_zoom_level; + float zoom_level; + float min_zoom_level; + float max_zoom_level; gboolean has_min_zoom_level; gboolean has_max_zoom_level; GList *preferred_zoom_levels; @@ -82,13 +89,37 @@ struct NautilusZoomControlDetails { 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_("Try to fit in window"), +}; + 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 +#define NUM_ACTIONS ((int)G_N_ELEMENTS (nautilus_zoom_control_accessible_action_names)) + GNOME_CLASS_BOILERPLATE (NautilusZoomControl, nautilus_zoom_control, GtkEventBox, GTK_TYPE_EVENT_BOX) @@ -346,6 +377,17 @@ nautilus_zoom_control_expose (GtkWidget *widget, GdkEventExpose *event) 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; } @@ -459,7 +501,7 @@ nautilus_zoom_control_load_images (NautilusZoomControl *zoom_control) static void zoom_menu_callback (GtkMenuItem *item, gpointer callback_data) { - double zoom_level; + float zoom_level; NautilusZoomControl *zoom_control; gboolean can_zoom; @@ -470,7 +512,12 @@ zoom_menu_callback (GtkMenuItem *item, gpointer callback_data) return; } - zoom_level = * (double *) g_object_get_data (G_OBJECT (item), "zoom_level"); + /* Don't send the signal if the menuitem was toggled off */ + if (!gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (item))) { + return; + } + + zoom_level = * (float *) g_object_get_data (G_OBJECT (item), "zoom_level"); /* Assume we can zoom and then check whether we're right. */ can_zoom = TRUE; @@ -494,7 +541,7 @@ create_zoom_menu_item (NautilusZoomControl *zoom_control, GtkMenu *menu, { GtkWidget *menu_item; char *item_text; - double *zoom_level_ptr; + float *zoom_level_ptr; GSList *radio_item_group; int percent; @@ -514,7 +561,7 @@ create_zoom_menu_item (NautilusZoomControl *zoom_control, GtkMenu *menu, : gtk_radio_menu_item_get_group (previous_radio_item); menu_item = gtk_radio_menu_item_new_with_label (radio_item_group, item_text); - zoom_level_ptr = g_new (double, 1); + zoom_level_ptr = g_new (float, 1); *zoom_level_ptr = zoom_level; gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), @@ -563,7 +610,9 @@ nautilus_zoom_control_button_press_event (GtkWidget *widget, GdkEventButton *eve if (event->type != GDK_BUTTON_PRESS) { return FALSE; } - + + 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), @@ -605,6 +654,23 @@ nautilus_zoom_control_leave_notify (GtkWidget *widget, return FALSE; } +static AtkObject * +nautilus_zoom_control_get_accessible (GtkWidget *widget) +{ + AtkObject *accessible; + + accessible = eel_accessibility_get_atk_object (widget); + + if (accessible) { + 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) { @@ -651,8 +717,28 @@ nautilus_zoom_control_size_allocate (GtkWidget *widget, GtkAllocation *allocatio 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) +nautilus_zoom_control_set_zoom_level (NautilusZoomControl *zoom_control, float zoom_level) { zoom_control->details->zoom_level = zoom_level; gtk_widget_queue_draw (GTK_WIDGET (zoom_control)); @@ -660,8 +746,8 @@ nautilus_zoom_control_set_zoom_level (NautilusZoomControl *zoom_control, double void nautilus_zoom_control_set_parameters (NautilusZoomControl *zoom_control, - double min_zoom_level, - double max_zoom_level, + float min_zoom_level, + float max_zoom_level, gboolean has_min_zoom_level, gboolean has_max_zoom_level, GList *zoom_levels) @@ -677,19 +763,19 @@ nautilus_zoom_control_set_parameters (NautilusZoomControl *zoom_control, gtk_widget_queue_draw (GTK_WIDGET (zoom_control)); } -double +float nautilus_zoom_control_get_zoom_level (NautilusZoomControl *zoom_control) { return zoom_control->details->zoom_level; } -double +float nautilus_zoom_control_get_min_zoom_level (NautilusZoomControl *zoom_control) { return zoom_control->details->min_zoom_level; } -double +float nautilus_zoom_control_get_max_zoom_level (NautilusZoomControl *zoom_control) { return zoom_control->details->max_zoom_level; @@ -727,6 +813,7 @@ static void nautilus_zoom_control_class_init (NautilusZoomControlClass *class) { GtkWidgetClass *widget_class; + GtkBindingSet *binding_set; G_OBJECT_CLASS (class)->finalize = nautilus_zoom_control_finalize; @@ -737,7 +824,10 @@ nautilus_zoom_control_class_init (NautilusZoomControlClass *class) 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), @@ -765,18 +855,275 @@ nautilus_zoom_control_class_init (NautilusZoomControlClass *class) G_STRUCT_OFFSET (NautilusZoomControlClass, zoom_to_level), NULL, NULL, - nautilus_marshal_VOID__DOUBLE, + g_cclosure_marshal_VOID__FLOAT, G_TYPE_NONE, 1, - G_TYPE_DOUBLE); + G_TYPE_FLOAT); 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_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_plus, 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; + + g_return_val_if_fail (i >= 0 && i < NUM_ACTIONS, FALSE); + + 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 NUM_ACTIONS; +} + +static G_CONST_RETURN char * +nautilus_zoom_control_accessible_action_get_description (AtkAction *accessible, + int i) +{ + g_return_val_if_fail (i >= 0 && i < NUM_ACTIONS, NULL); + + return _(nautilus_zoom_control_accessible_action_descriptions[i]); +} + +static G_CONST_RETURN char * +nautilus_zoom_control_accessible_action_get_name (AtkAction *accessible, + int i) +{ + g_return_val_if_fail (i >= 0 && i < NUM_ACTIONS, NULL); + + 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_FLOAT); + + control = NAUTILUS_ZOOM_CONTROL (GTK_ACCESSIBLE (accessible)->widget); + if (!control) { + g_value_set_float (value, 0.0); + return; + } + + g_value_set_float (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_FLOAT); + + control = NAUTILUS_ZOOM_CONTROL (GTK_ACCESSIBLE (accessible)->widget); + if (!control) { + g_value_set_float (value, 0.0); + return; + } + + g_value_set_float (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_FLOAT); + + control = NAUTILUS_ZOOM_CONTROL (GTK_ACCESSIBLE (accessible)->widget); + if (!control) { + g_value_set_float (value, 0.0); + return; + } + + g_value_set_float (value, control->details->min_zoom_level); +} + +static float +nearest_preferred (NautilusZoomControl *zoom_control, float value) +{ + float last_value; + float current_value; + GList *l; + + if (!zoom_control->details->preferred_zoom_levels) { + return value; + } + + last_value = * (float *)zoom_control->details->preferred_zoom_levels->data; + + for (l = zoom_control->details->preferred_zoom_levels; l != NULL; l = l->next) { + current_value = * (float*)l->data; + + if (current_value > value) { + float center = (last_value + current_value) / 2; + + return (value < center) ? last_value : current_value; + + } + + last_value = current_value; + } + + return current_value; +} + +static gboolean +nautilus_zoom_control_accessible_set_current_value (AtkValue *accessible, + const GValue *value) +{ + NautilusZoomControl *control; + float zoom; + + control = NAUTILUS_ZOOM_CONTROL (GTK_ACCESSIBLE (accessible)->widget); + if (!control) { + return FALSE; + } + + zoom = nearest_preferred (control, g_value_get_float (value)); + + g_signal_emit (control, signals[ZOOM_TO_LEVEL], 0, zoom); + + return TRUE; +} + +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; } diff --git a/src/nautilus-zoom-control.h b/src/nautilus-zoom-control.h index fd6b64908..1812b4523 100644 --- a/src/nautilus-zoom-control.h +++ b/src/nautilus-zoom-control.h @@ -50,25 +50,30 @@ struct NautilusZoomControlClass { void (*zoom_in) (NautilusZoomControl *control); void (*zoom_out) (NautilusZoomControl *control); - void (*zoom_to_level) (NautilusZoomControl *control); + void (*zoom_to_level) (NautilusZoomControl *control, + float zoom_level); 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); GtkWidget *nautilus_zoom_control_new (void); void nautilus_zoom_control_set_zoom_level (NautilusZoomControl *zoom_control, - double zoom_level); + float zoom_level); void nautilus_zoom_control_set_parameters (NautilusZoomControl *zoom_control, - double min_zoom_level, - double max_zoom_level, + float min_zoom_level, + float max_zoom_level, gboolean has_min_zoom_level, gboolean has_max_zoom_level, GList *zoom_levels); -double nautilus_zoom_control_get_zoom_level (NautilusZoomControl *zoom_control); -double nautilus_zoom_control_get_min_zoom_level (NautilusZoomControl *zoom_control); -double nautilus_zoom_control_get_max_zoom_level (NautilusZoomControl *zoom_control); +float nautilus_zoom_control_get_zoom_level (NautilusZoomControl *zoom_control); +float nautilus_zoom_control_get_min_zoom_level (NautilusZoomControl *zoom_control); +float nautilus_zoom_control_get_max_zoom_level (NautilusZoomControl *zoom_control); gboolean nautilus_zoom_control_has_min_zoom_level (NautilusZoomControl *zoom_control); gboolean nautilus_zoom_control_has_max_zoom_level (NautilusZoomControl *zoom_control); gboolean nautilus_zoom_control_can_zoom_in (NautilusZoomControl *zoom_control); |