static gboolean nautilus_zoom_control_scroll_event (GtkWidget *widget, GdkEventScroll *event) { NautilusZoomControl *zoom_control; zoom_control = NAUTILUS_ZOOM_CONTROL (widget); if (event->type != GDK_SCROLL) { return FALSE; } if (event->direction == GDK_SCROLL_DOWN && nautilus_zoom_control_can_zoom_out (zoom_control)) { g_signal_emit (widget, signals[ZOOM_OUT], 0); } else if (event->direction == GDK_SCROLL_UP && nautilus_zoom_control_can_zoom_in (zoom_control)) { g_signal_emit (widget, signals[ZOOM_IN], 0); } /* We don't change our state (to reflect the new zoom) here. The zoomable will * call back with the new level. Actually, the callback goes to the view-frame * containing the zoomable which, in turn, emits zoom_level_changed, which * someone (e.g. nautilus_window) picks up and handles by calling into us - * nautilus_zoom_control_set_zoom_level. */ return TRUE; }
static void label_style_set_callback (GtkWidget *label, GtkStyle *style, gpointer user_data) { set_label_size (NAUTILUS_ZOOM_CONTROL (user_data)); }
static void zoom_menu_callback (GtkMenuItem *item, gpointer callback_data) { NautilusZoomLevel zoom_level; NautilusZoomControl *zoom_control; gboolean can_zoom; zoom_control = NAUTILUS_ZOOM_CONTROL (callback_data); /* Don't do anything if we're just setting the toggle state of menu items. */ if (zoom_control->details->marking_menu_items) { return; } /* 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 = (NautilusZoomLevel) GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "zoom_level")); /* Assume we can zoom and then check whether we're right. */ can_zoom = TRUE; if (zoom_control->details->has_min_zoom_level && zoom_level < zoom_control->details->min_zoom_level) can_zoom = FALSE; /* no, we're below the minimum zoom level. */ if (zoom_control->details->has_max_zoom_level && zoom_level > zoom_control->details->max_zoom_level) can_zoom = FALSE; /* no, we're beyond the upper zoom level. */ /* if we can zoom */ if (can_zoom) { g_signal_emit (zoom_control, signals[ZOOM_TO_LEVEL], 0, zoom_level); } }
static void nautilus_zoom_control_finalize (GObject *object) { g_list_free (NAUTILUS_ZOOM_CONTROL (object)->details->preferred_zoom_levels); G_OBJECT_CLASS (nautilus_zoom_control_parent_class)->finalize (object); }
static void zoom_changed_callback (NautilusWindow *window, NautilusZoomLevel zoom_level, gboolean supports_zooming, gboolean can_zoom, gboolean can_zoom_in, gboolean can_zoom_out, GtkWidget *zoom_control) { if (supports_zooming) { gtk_widget_set_sensitive (zoom_control, can_zoom); gtk_widget_show (zoom_control); if (can_zoom) { nautilus_zoom_control_set_zoom_level (NAUTILUS_ZOOM_CONTROL (zoom_control), zoom_level); } } else { gtk_widget_hide (zoom_control); } }