]> git.pld-linux.org Git - packages/ristretto.git/blob - ristretto-scale-state.patch
- 0.0.93
[packages/ristretto.git] / ristretto-scale-state.patch
1 commit 048812613c8e8a77d1afb9b9cceb9fc8ed864572
2 Author: Stephan Arts <stephan@xfce.org>
3 Date:   Wed Sep 22 04:40:34 2010 +0200
4
5     - Fix saving of scale-state on images
6     - Set 'local_only' property to false on filechooser
7
8 diff --git a/src/image.c b/src/image.c
9 index f0344cc..2e45a98 100644
10 --- a/src/image.c
11 +++ b/src/image.c
12 @@ -34,6 +34,8 @@
13  #define RSTTO_IMAGE_BUFFER_SIZE 131072
14  #endif
15  
16 +#define STD_IMAGE_SIZE 1024
17 +
18  enum
19  {
20      RSTTO_IMAGE_SIGNAL_UPDATED= 0,
21 @@ -114,7 +116,7 @@ struct _RsttoImagePriv
22      GdkPixbuf *pixbuf;
23      gint       width;
24      gint       height;
25 -    guint      max_size;
26 +    gdouble    scale;
27  
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.
32   */
33  gboolean
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)
36  {
37 +    g_debug("%s: %f", __FUNCTION__, scale);
38      RsttoImageCache *cache;
39  
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
42  
43      g_cancellable_reset (image->priv->cancellable);
44  
45 -    /* NEW */
46 -    image->priv->max_size = max_size;
47 +    /* Image scale */
48 +    image->priv->scale = scale;
49  
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;
55  
56 -    if (image->priv->max_size > 0)
57 +    if (image->priv->scale > 0.0)
58 +    {
59 +       gdk_pixbuf_loader_set_size (loader, (gint)((gdouble)width*image->priv->scale), (gint)((gdouble)height*image->priv->scale));
60 +    }
61 +    else
62      {
63 -        gdouble ratio = (gdouble)(image->priv->max_size)/(gdouble)(width * height);
64 -        if (ratio < 1)
65 -           gdk_pixbuf_loader_set_size (loader, width*ratio, height*ratio);
66 +        if (width > height)
67 +        {
68 +            if (width > STD_IMAGE_SIZE)
69 +            {
70 +               gdk_pixbuf_loader_set_size (loader, STD_IMAGE_SIZE, (height*STD_IMAGE_SIZE)/width);
71 +            }
72 +        }
73 +        else
74 +        {
75 +            if (height > STD_IMAGE_SIZE)
76 +            {
77 +               gdk_pixbuf_loader_set_size (loader, (width*STD_IMAGE_SIZE)/height, STD_IMAGE_SIZE);
78 +            }
79 +
80 +        }
81      }
82  
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
86 --- a/src/image.h
87 +++ b/src/image.h
88 @@ -81,7 +81,7 @@ gint rstto_image_get_height (RsttoImage *image);
89  
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);
94  
95  guint64 rstto_image_get_size (RsttoImage *image);
96  
97 diff --git a/src/main.c b/src/main.c
98 index cc51e6c..a69c683 100644
99 --- a/src/main.c
100 +++ b/src/main.c
101 @@ -84,6 +84,9 @@ main(int argc, char **argv)
102      textdomain (GETTEXT_PACKAGE);
103      #endif
104  
105 +    g_thread_init(NULL);
106 +    gdk_threads_init();
107 +
108      if(!gtk_init_with_args(&argc, &argv, "", entries, PACKAGE, &cli_error))
109      {
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);
114  
115 +    GDK_THREADS_ENTER();
116      gtk_main();
117 +    GDK_THREADS_LEAVE();
118  
119      g_object_unref (settings);
120  
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
126      else
127      {
128          rstto_image_list_iter_find_image (window->priv->iter, image);
129 +        rstto_main_window_image_list_iter_changed (window);
130      }
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);
134  }
135  
136  static gboolean
137 @@ -1946,6 +1946,8 @@ cb_rstto_main_window_open_image (GtkWidget *widget, RsttoMainWindow *window)
138                                           NULL);
139  
140      gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE);
141 +    gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dialog), FALSE);
142 +
143      if (g_value_get_string (&current_uri_val))
144          gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog), g_value_get_string (&current_uri_val));
145  
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);
151  
152  
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
160               */
161              *img_scale = scale;
162 +            g_object_set_data (G_OBJECT (viewer->priv->image), "viewer-scale", img_scale);
163 +
164 +            rstto_image_load (viewer->priv->image, TRUE, scale, FALSE, NULL);
165  
166              rstto_picture_viewer_queued_repaint (viewer, TRUE);
167          }
168 @@ -896,6 +899,8 @@ cb_rstto_picture_viewer_scroll_event (RsttoPictureViewer *viewer, GdkEventScroll
169  
170                      break;
171              }
172 +
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
178                              }
179  
180                              g_object_set_data (G_OBJECT(viewer->priv->image), "viewer-scale", scale);
181 +                            rstto_picture_viewer_set_scale(viewer, *scale);
182  
183                              if(viewer->hadjustment)
184                              {
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);
187              }
188              scale = rstto_picture_viewer_calculate_scale (viewer);
189 -            if (scale != -1.0)
190 -                rstto_picture_viewer_set_scale (viewer, scale);
191 +            rstto_picture_viewer_set_scale (viewer, scale);
192              break;
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);
197          }
198  
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);
201      }
202      else
203      {
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
209  static void
210  cb_rstto_preferences_dialog_cache_spin_button_value_changed (GtkSpinButton *, gpointer);
211  static void
212 -cb_rstto_preferences_dialog_image_quality_combo_box_changed (GtkComboBox *, gpointer);
213 -static void
214  cb_rstto_preferences_dialog_image_preview_toggled (GtkToggleButton *button, 
215                                                        gpointer user_data);
216  static void
217 @@ -90,12 +88,6 @@ struct _RsttoPreferencesDialogPriv
218          GtkWidget *bgcolor_color_button;
219          GtkWidget *bgcolor_override_check_button;
220  
221 -
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;
228      } display_tab;
229  
230 @@ -176,7 +168,6 @@ rstto_preferences_dialog_get_type (void)
231  static void
232  rstto_preferences_dialog_init(RsttoPreferencesDialog *dialog)
233  {
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)
239  
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);
249  
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);
255 -
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"));
260  
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);
265  
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"));
270 -
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);
275 -
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))
282 -    {
283 -        case 0:
284 -            gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->priv->display_tab.image_quality_combo), 0);
285 -            break;
286 -        case 8000000:
287 -            gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->priv->display_tab.image_quality_combo), 1);
288 -            break;
289 -        case 4000000:
290 -            gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->priv->display_tab.image_quality_combo), 2);
291 -            break;
292 -        case 2000000:
293 -            gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->priv->display_tab.image_quality_combo), 3);
294 -            break;
295 -        default:
296 -            gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->priv->display_tab.image_quality_combo), 2);
297 -            break;
298 -    }
299 -
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);
303 -    
304 -
305  /*******************/
306  /** Slideshow tab **/
307  /*******************/
308 @@ -642,38 +584,6 @@ cb_rstto_preferences_dialog_cache_spin_button_value_changed (GtkSpinButton *butt
309  }
310  
311  static void
312 -cb_rstto_preferences_dialog_image_quality_combo_box_changed (GtkComboBox *combo_box,
313 -                                                             gpointer user_data)
314 -
315 -{
316 -    /* FIXME */
317 -    RsttoPreferencesDialog *dialog = RSTTO_PREFERENCES_DIALOG (user_data);
318 -    switch (gtk_combo_box_get_active (combo_box))
319 -    {
320 -        case 0: /* unlimited */
321 -            g_object_set (G_OBJECT (dialog->priv->settings),
322 -                          "image-quality", 0,
323 -                          NULL);
324 -            break;
325 -        case 1: /* 1 MegaPixel */
326 -            g_object_set (G_OBJECT (dialog->priv->settings),
327 -                          "image-quality", 8000000,
328 -                          NULL);
329 -            break;
330 -        case 2: /* 2 MegaPixel */
331 -            g_object_set (G_OBJECT (dialog->priv->settings),
332 -                          "image-quality", 4000000,
333 -                          NULL);
334 -            break;
335 -        case 3: /* 4 MegaPixel */
336 -            g_object_set (G_OBJECT (dialog->priv->settings),
337 -                          "image-quality", 2000000,
338 -                          NULL);
339 -            break;
340 -    }
341 -}
342 -
343 -static void
344  cb_rstto_preferences_dialog_image_preview_toggled (GtkToggleButton *button, 
345                                                        gpointer user_data)
346  {
This page took 0.088229 seconds and 3 git commands to generate.