1 commit 048812613c8e8a77d1afb9b9cceb9fc8ed864572
2 Author: Stephan Arts <stephan@xfce.org>
3 Date: Wed Sep 22 04:40:34 2010 +0200
5 - Fix saving of scale-state on images
6 - Set 'local_only' property to false on filechooser
8 diff --git a/src/image.c b/src/image.c
9 index f0344cc..2e45a98 100644
13 #define RSTTO_IMAGE_BUFFER_SIZE 131072
16 +#define STD_IMAGE_SIZE 1024
20 RSTTO_IMAGE_SIGNAL_UPDATED= 0,
21 @@ -114,7 +116,7 @@ struct _RsttoImagePriv
28 /* Animation data for animated images (like .gif/.mng) */
29 /*******************************************************/
30 @@ -310,8 +312,9 @@ rstto_image_new (GFile *file)
31 * Return value: TRUE on success.
34 -rstto_image_load (RsttoImage *image, gboolean empty_cache, guint max_size, gboolean preload, GError **error)
35 +rstto_image_load (RsttoImage *image, gboolean empty_cache, gdouble scale, gboolean preload, GError **error)
37 + g_debug("%s: %f", __FUNCTION__, scale);
38 RsttoImageCache *cache;
40 g_return_val_if_fail (image != NULL, FALSE);
41 @@ -320,8 +323,8 @@ rstto_image_load (RsttoImage *image, gboolean empty_cache, guint max_size, gbool
43 g_cancellable_reset (image->priv->cancellable);
46 - image->priv->max_size = max_size;
48 + image->priv->scale = scale;
50 /* Check if a GIOChannel is present, if so... the load is already in progress */
51 /* The image needs to be loaded if:
52 @@ -680,11 +682,27 @@ cb_rstto_image_size_prepared (GdkPixbufLoader *loader, gint width, gint height,
53 image->priv->width = width;
54 image->priv->height = height;
56 - if (image->priv->max_size > 0)
57 + if (image->priv->scale > 0.0)
59 + gdk_pixbuf_loader_set_size (loader, (gint)((gdouble)width*image->priv->scale), (gint)((gdouble)height*image->priv->scale));
63 - gdouble ratio = (gdouble)(image->priv->max_size)/(gdouble)(width * height);
65 - gdk_pixbuf_loader_set_size (loader, width*ratio, height*ratio);
68 + if (width > STD_IMAGE_SIZE)
70 + gdk_pixbuf_loader_set_size (loader, STD_IMAGE_SIZE, (height*STD_IMAGE_SIZE)/width);
75 + if (height > STD_IMAGE_SIZE)
77 + gdk_pixbuf_loader_set_size (loader, (width*STD_IMAGE_SIZE)/height, STD_IMAGE_SIZE);
83 g_signal_emit(G_OBJECT(image), rstto_image_signals[RSTTO_IMAGE_SIGNAL_PREPARED], 0, image, NULL);
84 diff --git a/src/image.h b/src/image.h
85 index 1e17346..a36659b 100644
88 @@ -81,7 +81,7 @@ gint rstto_image_get_height (RsttoImage *image);
90 GFile *rstto_image_get_file (RsttoImage *image);
91 void rstto_image_unload (RsttoImage *image);
92 -gboolean rstto_image_load (RsttoImage *image, gboolean empty_cache, guint max_size, gboolean preload, GError **error);
93 +gboolean rstto_image_load (RsttoImage *image, gboolean empty_cache, gdouble scale, gboolean preload, GError **error);
95 guint64 rstto_image_get_size (RsttoImage *image);
97 diff --git a/src/main.c b/src/main.c
98 index cc51e6c..a69c683 100644
101 @@ -84,6 +84,9 @@ main(int argc, char **argv)
102 textdomain (GETTEXT_PACKAGE);
105 + g_thread_init(NULL);
106 + gdk_threads_init();
108 if(!gtk_init_with_args(&argc, &argv, "", entries, PACKAGE, &cli_error))
110 if (cli_error != NULL)
111 @@ -126,7 +129,9 @@ main(int argc, char **argv)
112 g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
113 gtk_widget_show_all (window);
115 + GDK_THREADS_ENTER();
117 + GDK_THREADS_LEAVE();
119 g_object_unref (settings);
121 diff --git a/src/main_window.c b/src/main_window.c
122 index a96e94f..747496f 100644
123 --- a/src/main_window.c
124 +++ b/src/main_window.c
125 @@ -1680,10 +1680,10 @@ cb_rstto_main_window_image_list_new_image (RsttoImageList *image_list, RsttoImag
128 rstto_image_list_iter_find_image (window->priv->iter, image);
129 + rstto_main_window_image_list_iter_changed (window);
131 window->priv->open_image_timer_id = g_timeout_add (
132 1000, rstto_window_open_image_timer, window);
133 - rstto_main_window_image_list_iter_changed (window);
137 @@ -1946,6 +1946,8 @@ cb_rstto_main_window_open_image (GtkWidget *widget, RsttoMainWindow *window)
140 gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE);
141 + gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dialog), FALSE);
143 if (g_value_get_string (¤t_uri_val))
144 gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog), g_value_get_string (¤t_uri_val));
146 @@ -1957,6 +1959,7 @@ cb_rstto_main_window_open_image (GtkWidget *widget, RsttoMainWindow *window)
147 gtk_file_filter_add_mime_type (filter, "image/jpeg");
148 gtk_file_filter_set_name (filter, _(".jp(e)g"));
149 gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
150 + gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER(dialog), FALSE);
153 response = gtk_dialog_run(GTK_DIALOG(dialog));
154 diff --git a/src/picture_viewer.c b/src/picture_viewer.c
155 index 5c23703..b171a39 100644
156 --- a/src/picture_viewer.c
157 +++ b/src/picture_viewer.c
158 @@ -771,6 +771,9 @@ rstto_picture_viewer_set_scale (RsttoPictureViewer *viewer, gdouble scale)
159 * since the old and new values are required in the above code
162 + g_object_set_data (G_OBJECT (viewer->priv->image), "viewer-scale", img_scale);
164 + rstto_image_load (viewer->priv->image, TRUE, scale, FALSE, NULL);
166 rstto_picture_viewer_queued_repaint (viewer, TRUE);
168 @@ -896,6 +899,8 @@ cb_rstto_picture_viewer_scroll_event (RsttoPictureViewer *viewer, GdkEventScroll
173 + rstto_picture_viewer_set_scale (viewer, *p_scale);
174 gtk_adjustment_value_changed(viewer->hadjustment);
175 gtk_adjustment_value_changed(viewer->vadjustment);
176 viewer->priv->repaint.idle_id = g_idle_add((GSourceFunc)cb_rstto_picture_viewer_queued_repaint, viewer);
177 @@ -1479,6 +1484,7 @@ cb_rstto_picture_viewer_button_release_event (RsttoPictureViewer *viewer, GdkEve
180 g_object_set_data (G_OBJECT(viewer->priv->image), "viewer-scale", scale);
181 + rstto_picture_viewer_set_scale(viewer, *scale);
183 if(viewer->hadjustment)
185 @@ -1594,8 +1600,7 @@ rstto_picture_viewer_set_zoom_mode(RsttoPictureViewer *viewer, RsttoZoomMode mod
186 g_object_set_data (G_OBJECT (viewer->priv->image), "viewer-fit-to-screen", p_fit_to_screen);
188 scale = rstto_picture_viewer_calculate_scale (viewer);
190 - rstto_picture_viewer_set_scale (viewer, scale);
191 + rstto_picture_viewer_set_scale (viewer, scale);
193 case RSTTO_ZOOM_MODE_100:
194 if (viewer->priv->image)
195 @@ -1658,7 +1663,7 @@ rstto_picture_viewer_set_image (RsttoPictureViewer *viewer, RsttoImage *image)
196 g_object_set_data (G_OBJECT (viewer->priv->image), "viewer-fit-to-screen", fit_to_screen);
199 - rstto_image_load (viewer->priv->image, FALSE, g_value_get_uint (&max_size), FALSE, NULL);
200 + rstto_image_load (viewer->priv->image, FALSE, *scale, FALSE, NULL);
204 diff --git a/src/preferences_dialog.c b/src/preferences_dialog.c
205 index d18c6f6..8455e20 100644
206 --- a/src/preferences_dialog.c
207 +++ b/src/preferences_dialog.c
208 @@ -50,8 +50,6 @@ cb_rstto_preferences_dialog_cache_preload_check_button_toggled (GtkToggleButton
210 cb_rstto_preferences_dialog_cache_spin_button_value_changed (GtkSpinButton *, gpointer);
212 -cb_rstto_preferences_dialog_image_quality_combo_box_changed (GtkComboBox *, gpointer);
214 cb_rstto_preferences_dialog_image_preview_toggled (GtkToggleButton *button,
217 @@ -90,12 +88,6 @@ struct _RsttoPreferencesDialogPriv
218 GtkWidget *bgcolor_color_button;
219 GtkWidget *bgcolor_override_check_button;
222 - GtkWidget *image_quality_frame;
223 - GtkWidget *image_quality_vbox;
224 - GtkWidget *image_quality_hbox;
225 - GtkWidget *image_quality_label;
226 - GtkWidget *image_quality_combo;
227 GtkWidget *image_preview_check_button;
230 @@ -176,7 +168,6 @@ rstto_preferences_dialog_get_type (void)
232 rstto_preferences_dialog_init(RsttoPreferencesDialog *dialog)
234 - guint uint_image_quality;
235 guint uint_cache_size;
236 gboolean bool_preload_images;
237 gboolean bool_enable_cache;
238 @@ -208,7 +199,6 @@ rstto_preferences_dialog_init(RsttoPreferencesDialog *dialog)
240 dialog->priv->settings = rstto_settings_new ();
241 g_object_get (G_OBJECT (dialog->priv->settings),
242 - "image-quality", &uint_image_quality,
243 "cache-size", &uint_cache_size,
244 "show-preview", &bool_show_preview,
245 "preload-images", &bool_preload_images,
246 @@ -261,15 +251,6 @@ rstto_preferences_dialog_init(RsttoPreferencesDialog *dialog)
247 g_signal_connect (G_OBJECT (dialog->priv->display_tab.bgcolor_color_button),
248 "color-set", G_CALLBACK (cb_rstto_preferences_dialog_bgcolor_color_set), dialog);
250 -/** Image-quality frame */
251 - dialog->priv->display_tab.image_quality_vbox = gtk_vbox_new(FALSE, 0);
252 - dialog->priv->display_tab.image_quality_frame = xfce_create_framebox_with_content (_("Quality"),
253 - dialog->priv->display_tab.image_quality_vbox);
254 - gtk_box_pack_start (GTK_BOX (display_main_vbox), dialog->priv->display_tab.image_quality_frame, FALSE, FALSE, 0);
256 - dialog->priv->display_tab.image_quality_label = gtk_label_new (_("Maximum render quality:"));
257 - dialog->priv->display_tab.image_quality_hbox= gtk_hbox_new (FALSE, 4);
258 - dialog->priv->display_tab.image_quality_combo= gtk_combo_box_new_text ();
259 dialog->priv->display_tab.image_preview_check_button = gtk_check_button_new_with_label (_("Show preview when loading image"));
261 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->display_tab.image_preview_check_button),
262 @@ -277,45 +258,6 @@ rstto_preferences_dialog_init(RsttoPreferencesDialog *dialog)
263 g_signal_connect (G_OBJECT (dialog->priv->display_tab.image_preview_check_button),
264 "toggled", (GCallback)cb_rstto_preferences_dialog_image_preview_toggled, dialog);
266 - gtk_combo_box_append_text (GTK_COMBO_BOX (dialog->priv->display_tab.image_quality_combo), _("Best"));
267 - gtk_combo_box_append_text (GTK_COMBO_BOX (dialog->priv->display_tab.image_quality_combo), _("High"));
268 - gtk_combo_box_append_text (GTK_COMBO_BOX (dialog->priv->display_tab.image_quality_combo), _("Medium"));
269 - gtk_combo_box_append_text (GTK_COMBO_BOX (dialog->priv->display_tab.image_quality_combo), _("Low"));
271 - gtk_box_pack_start (GTK_BOX (dialog->priv->display_tab.image_quality_vbox),
272 - dialog->priv->display_tab.image_quality_hbox, FALSE, FALSE, 0);
273 - gtk_box_pack_start (GTK_BOX (dialog->priv->display_tab.image_quality_vbox),
274 - dialog->priv->display_tab.image_preview_check_button, FALSE, FALSE, 0);
276 - gtk_box_pack_start (GTK_BOX (dialog->priv->display_tab.image_quality_hbox),
277 - dialog->priv->display_tab.image_quality_label, FALSE, FALSE, 0);
278 - gtk_box_pack_start (GTK_BOX (dialog->priv->display_tab.image_quality_hbox),
279 - dialog->priv->display_tab.image_quality_combo, FALSE, FALSE, 0);
280 - /* set current value */
281 - switch (uint_image_quality-(uint_image_quality%1000000))
284 - gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->priv->display_tab.image_quality_combo), 0);
287 - gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->priv->display_tab.image_quality_combo), 1);
290 - gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->priv->display_tab.image_quality_combo), 2);
293 - gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->priv->display_tab.image_quality_combo), 3);
296 - gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->priv->display_tab.image_quality_combo), 2);
300 - /* connect signals */
301 - g_signal_connect (G_OBJECT (dialog->priv->display_tab.image_quality_combo),
302 - "changed", (GCallback)cb_rstto_preferences_dialog_image_quality_combo_box_changed, dialog);
305 /*******************/
306 /** Slideshow tab **/
307 /*******************/
308 @@ -642,38 +584,6 @@ cb_rstto_preferences_dialog_cache_spin_button_value_changed (GtkSpinButton *butt
312 -cb_rstto_preferences_dialog_image_quality_combo_box_changed (GtkComboBox *combo_box,
313 - gpointer user_data)
317 - RsttoPreferencesDialog *dialog = RSTTO_PREFERENCES_DIALOG (user_data);
318 - switch (gtk_combo_box_get_active (combo_box))
320 - case 0: /* unlimited */
321 - g_object_set (G_OBJECT (dialog->priv->settings),
322 - "image-quality", 0,
325 - case 1: /* 1 MegaPixel */
326 - g_object_set (G_OBJECT (dialog->priv->settings),
327 - "image-quality", 8000000,
330 - case 2: /* 2 MegaPixel */
331 - g_object_set (G_OBJECT (dialog->priv->settings),
332 - "image-quality", 4000000,
335 - case 3: /* 4 MegaPixel */
336 - g_object_set (G_OBJECT (dialog->priv->settings),
337 - "image-quality", 2000000,
344 cb_rstto_preferences_dialog_image_preview_toggled (GtkToggleButton *button,