configurable frame around image - geeqie_autofit_maxsize.patch by Laurent MONIN
authorVladimir Nadvornik <nadvornik@suse.cz>
Sat, 29 Mar 2008 14:59:14 +0000 (14:59 +0000)
committerVladimir Nadvornik <nadvornik@suse.cz>
Sat, 29 Mar 2008 14:59:14 +0000 (14:59 +0000)
src/globals.c
src/gqview.h
src/image.c
src/pixbuf-renderer.c
src/pixbuf-renderer.h
src/preferences.c
src/rcfile.c

index a1fa2fd..9984c14 100644 (file)
@@ -52,6 +52,8 @@ gint fit_window = FALSE;
 gint limit_window_size = FALSE;
 gint zoom_to_fit_expands = TRUE;
 gint max_window_size = 100;
+gint limit_autofit_size = FALSE;
+gint max_autofit_size = 100;
 gint thumb_max_width = 96;
 gint thumb_max_height = 72;
 gint enable_thumb_caching = TRUE;
index 49fa4b0..9100f90 100644 (file)
@@ -132,6 +132,8 @@ extern gint fit_window;
 extern gint limit_window_size;
 extern gint zoom_to_fit_expands;
 extern gint max_window_size;
+extern gint limit_autofit_size;
+extern gint max_autofit_size;
 extern gint thumb_max_width;
 extern gint thumb_max_height;
 extern gint enable_thumb_caching;
index 563541a..5f6a1be 100644 (file)
@@ -1720,6 +1720,9 @@ static void image_options_set(ImageWindow *imd)
                                        "window_fit", (imd->top_window_sync && fit_window),
                                        "window_limit", limit_window_size,
                                        "window_limit_value", max_window_size,
+                                       "autofit_limit", limit_autofit_size,
+                                       "autofit_limit_value", max_autofit_size,
+
                                        NULL);
 
        pixbuf_renderer_set_parent((PixbufRenderer *)imd->pr, (GtkWindow *)imd->top_window);
index 1724b18..30c32f2 100644 (file)
@@ -156,7 +156,9 @@ enum {
        PROP_CACHE_SIZE_TILES,
        PROP_WINDOW_FIT,
        PROP_WINDOW_LIMIT,
-       PROP_WINDOW_LIMIT_VALUE
+       PROP_WINDOW_LIMIT_VALUE,
+       PROP_AUTOFIT_LIMIT,
+       PROP_AUTOFIT_LIMIT_VALUE
 };
 
 
@@ -383,6 +385,25 @@ static void pixbuf_renderer_class_init(PixbufRendererClass *class)
                                                          150,
                                                          100,
                                                          G_PARAM_READABLE | G_PARAM_WRITABLE));
+       
+       g_object_class_install_property(gobject_class,
+                                       PROP_AUTOFIT_LIMIT,
+                                       g_param_spec_boolean("autofit_limit",
+                                                            "Limit size of image when autofitting",
+                                                            NULL,
+                                                            FALSE,
+                                                            G_PARAM_READABLE | G_PARAM_WRITABLE));
+
+       g_object_class_install_property(gobject_class,
+                                       PROP_AUTOFIT_LIMIT_VALUE,
+                                       g_param_spec_uint("autofit_limit_value",
+                                                         "Size limit of image when autofitting",
+                                                         NULL,
+                                                         10,
+                                                         150,
+                                                         100,
+                                                         G_PARAM_READABLE | G_PARAM_WRITABLE));
+
 
        signals[SIGNAL_ZOOM] = 
                g_signal_new("zoom",
@@ -550,6 +571,12 @@ static void pixbuf_renderer_set_property(GObject *object, guint prop_id,
                case PROP_WINDOW_LIMIT_VALUE:
                        pr->window_limit_size = g_value_get_uint(value);
                        break;
+               case PROP_AUTOFIT_LIMIT:
+                       pr->autofit_limit = g_value_get_boolean(value);
+                       break;
+               case PROP_AUTOFIT_LIMIT_VALUE:
+                       pr->autofit_limit_size = g_value_get_uint(value);
+                       break;
                default:
                        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
                        break;
@@ -610,6 +637,12 @@ static void pixbuf_renderer_get_property(GObject *object, guint prop_id,
                case PROP_WINDOW_LIMIT_VALUE:
                        g_value_set_uint(value, pr->window_limit_size);
                        break;
+               case PROP_AUTOFIT_LIMIT:
+                       g_value_set_boolean(value, pr->autofit_limit);
+                       break;
+               case PROP_AUTOFIT_LIMIT_VALUE:
+                       g_value_set_uint(value, pr->autofit_limit_size);
+                       break;
                default:
                        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
                        break;
@@ -2630,6 +2663,13 @@ static gint pr_zoom_clamp(PixbufRenderer *pr, gdouble zoom,
                                h = h * scale + 0.5;
                                if (h > max_h) h = max_h;
                                }
+
+                       if (pr->autofit_limit)
+                               {
+                               w = w * pr->autofit_limit_size / 100;
+                               h = h * pr->autofit_limit_size / 100;
+                               }
+                       
                        if (w < 1) w = 1;
                        if (h < 1) h = 1;
                        }
index 872b0e9..9e95c82 100644 (file)
@@ -86,6 +86,10 @@ struct _PixbufRenderer
        gboolean window_limit;
        gint window_limit_size;
 
+       gboolean autofit_limit;
+       gint autofit_limit_size;
+
+
        gint tile_cache_max;            /* max mb to use for offscreen buffer */
 
        /*< private >*/
index 1714859..fd181bc 100644 (file)
@@ -81,6 +81,8 @@ static gint fit_window_c;
 static gint limit_window_size_c;
 static gint zoom_to_fit_expands_c;
 static gint max_window_size_c;
+static gint limit_autofit_size_c;
+static gint max_autofit_size_c;
 static gint progressive_key_scrolling_c;
 static gint thumb_max_width_c;
 static gint thumb_max_height_c;
@@ -242,6 +244,8 @@ static void config_window_apply(void)
        limit_window_size = limit_window_size_c;
        zoom_to_fit_expands = zoom_to_fit_expands_c;
        max_window_size = max_window_size_c;
+       limit_autofit_size = limit_autofit_size_c;
+       max_autofit_size = max_autofit_size_c;
        progressive_key_scrolling = progressive_key_scrolling_c;
        thumb_max_width = thumb_max_width_c;
        thumb_max_height = thumb_max_height_c;
@@ -938,6 +942,14 @@ static void config_window_create(void)
        pref_checkbox_new_int(group, _("Allow enlargement of image for zoom to fit"),
                              zoom_to_fit_expands, &zoom_to_fit_expands_c);
 
+       hbox = pref_box_new(group, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
+       ct_button = pref_checkbox_new_int(hbox, _("Limit image size when autofitting (%):"),
+                                         limit_autofit_size, &limit_autofit_size_c);
+       spin = pref_spin_new_int(hbox, NULL, NULL,
+                                10, 150, 1,
+                                max_autofit_size, &max_autofit_size_c);
+       pref_checkbox_link_sensitivity(ct_button, spin);
+
        zoom_increment_c = zoom_increment;
        spin = pref_spin_new(group, _("Zoom increment:"), NULL,
                             0.1, 4.0, 1.0, 1, (double)zoom_increment / 10.0,
index 357f601..fa6d020 100644 (file)
@@ -253,6 +253,8 @@ void save_options(void)
        write_bool_option(f, "fit_window_to_image", fit_window);
        write_bool_option(f, "limit_window_size", limit_window_size);
        write_int_option(f, "max_window_size", max_window_size);
+       write_bool_option(f, "limit_autofit_size", limit_autofit_size);
+       write_int_option(f, "max_autofit_size", max_autofit_size);
        fprintf(f,"\n");
 
        write_bool_option(f, "progressive_keyboard_scrolling", progressive_key_scrolling);
@@ -491,6 +493,10 @@ void load_options(void)
                        "limit_window_size", value, limit_window_size);
                max_window_size = read_int_option(f, option,
                        "max_window_size", value, max_window_size);
+               limit_autofit_size = read_bool_option(f, option,
+                       "limit_autofit_size", value, limit_autofit_size);
+               max_autofit_size = read_int_option(f, option,
+                       "max_autofit_size", value, max_autofit_size);
                progressive_key_scrolling = read_bool_option(f, option,
                        "progressive_keyboard_scrolling", value, progressive_key_scrolling);
                scroll_reset_method = read_int_option(f, option,