static void fit_to_width_cb (GSimpleAction *simple, GVariant *parameter, gpointer user_data) { EogWindow *window; GtkWidget *view; EogImage *image; gint image_width; gint image_height; gint view_width; double zoom; GtkAllocation allocation; g_return_if_fail (EOG_IS_WINDOW (user_data)); window = EOG_WINDOW (user_data); view = eog_window_get_view (window); image = eog_window_get_image (window); g_return_if_fail (EOG_IS_SCROLL_VIEW (view)); g_return_if_fail (EOG_IS_IMAGE (image)); eog_image_get_size (image, &image_width, &image_height); gtk_widget_get_allocation (view, &allocation); view_width = allocation.width; // HACK: It's necessary subtract the width size (15) of vscrollbar // to scrollview for obtain the display area. zoom = (double) (view_width - 15) / image_width; eog_scroll_view_set_zoom (EOG_SCROLL_VIEW (view), zoom); }
/** * eog_list_store_remove_image: * @store: An #EogListStore. * @image: An #EogImage. * * Removes @image from @store. **/ void eog_list_store_remove_image (EogListStore *store, EogImage *image) { GtkTreeIter iter; GFile *file; g_return_if_fail (EOG_IS_LIST_STORE (store)); g_return_if_fail (EOG_IS_IMAGE (image)); file = eog_image_get_file (image); if (is_file_in_list_store_file (store, file, &iter)) { eog_list_store_remove (store, &iter); } g_object_unref (file); }
/** * eog_list_store_get_pos_by_image: * @store: An #EogListStore. * @image: An #EogImage. * * Gets the position where @image is stored in @store. If @image * is not stored in @store, -1 is returned. * * Returns: the position of @image in @store or -1 if not found. **/ gint eog_list_store_get_pos_by_image (EogListStore *store, EogImage *image) { GtkTreeIter iter; gint pos = -1; GFile *file; g_return_val_if_fail (EOG_IS_LIST_STORE (store), -1); g_return_val_if_fail (EOG_IS_IMAGE (image), -1); file = eog_image_get_file (image); if (is_file_in_list_store_file (store, file, &iter)) { pos = eog_list_store_get_pos_by_iter (store, &iter); } g_object_unref (file); return pos; }