[gthumb] image viewer: added 'fit to height' button
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] image viewer: added 'fit to height' button
- Date: Sat, 21 Mar 2015 22:34:04 +0000 (UTC)
commit b3d2908edc76a58632510cac1f1e6098d270a927
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sat Mar 21 23:30:36 2015 +0100
image viewer: added 'fit to height' button
data/icons/hicolor/16x16/actions/Makefile.am | 1 +
.../actions/view-zoom-fit-height-symbolic.svg | 113 ++++++++++++++++++++
extensions/file_tools/gth-file-tool-curves.c | 2 +-
extensions/image_viewer/actions.c | 12 ++
extensions/image_viewer/actions.h | 1 +
extensions/image_viewer/gth-image-viewer-page.c | 25 +++--
gthumb/gth-image-viewer.c | 48 ++++++++-
gthumb/gth-image-viewer.h | 8 +-
8 files changed, 191 insertions(+), 19 deletions(-)
---
diff --git a/data/icons/hicolor/16x16/actions/Makefile.am b/data/icons/hicolor/16x16/actions/Makefile.am
index 9418400..eaa17ec 100644
--- a/data/icons/hicolor/16x16/actions/Makefile.am
+++ b/data/icons/hicolor/16x16/actions/Makefile.am
@@ -53,6 +53,7 @@ icons_DATA = \
tools-symbolic.svg \
view-presentation-symbolic.svg \
view-zoom-fit-symbolic.svg \
+ view-zoom-fit-height-symbolic.svg \
view-zoom-fit-width-symbolic.svg \
view-zoom-in-symbolic.svg \
view-zoom-original-symbolic.svg \
diff --git a/data/icons/hicolor/16x16/actions/view-zoom-fit-height-symbolic.svg
b/data/icons/hicolor/16x16/actions/view-zoom-fit-height-symbolic.svg
new file mode 100644
index 0000000..0d018b2
--- /dev/null
+++ b/data/icons/hicolor/16x16/actions/view-zoom-fit-height-symbolic.svg
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="view-zoom-fit-height-symbolic.svg">
+ <defs
+ id="defs4">
+ <linearGradient
+ id="linearGradient3946">
+ <stop
+ id="stop3948"
+ offset="0"
+ style="stop-color:#000000;stop-opacity:0.74698794;" />
+ <stop
+ id="stop3950"
+ offset="1"
+ style="stop-color:#000000;stop-opacity:0.02409638;" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient3830-9">
+ <stop
+ style="stop-color:#000000;stop-opacity:0.74698794;"
+ offset="0"
+ id="stop3832-7" />
+ <stop
+ style="stop-color:#000000;stop-opacity:0.02409638;"
+ offset="1"
+ id="stop3834-5" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient3984">
+ <stop
+ style="stop-color:#f4deba;stop-opacity:1;"
+ offset="0"
+ id="stop3986" />
+ <stop
+ style="stop-color:#de9625;stop-opacity:0;"
+ offset="1"
+ id="stop3988" />
+ </linearGradient>
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#555753"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="1"
+ inkscape:pageshadow="2"
+ inkscape:zoom="16"
+ inkscape:cx="6.9654989"
+ inkscape:cy="9.886072"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ inkscape:snap-grids="true"
+ inkscape:window-width="1680"
+ inkscape:window-height="984"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ showborder="true"
+ fit-margin-top="0"
+ fit-margin-right="0"
+ fit-margin-left="0"
+ fit-margin-bottom="0"
+ showguides="true"
+ inkscape:guide-bbox="true">
+ <inkscape:grid
+ type="xygrid"
+ id="grid7044"
+ empspacing="8"
+ visible="true"
+ enabled="true"
+ snapvisiblegridlinesonly="true"
+ originx="-31.97559px"
+ originy="-816.00002px" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Livello 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-31.97559,-220.36218)">
+ <path
+ style="fill:#bebebe;fill-opacity:1;stroke:none"
+ d="m 47.00684,221.36218 -14,0 0,14 14,0 0,-14 z m -4.03125,4.40625 0,1 -1,0 c -0.25721,4e-5
-0.52849,-0.12938 -0.71875,-0.3125 l -1.28125,-1.28125 -1.28125,1.28125 c -0.19051,0.18288 -0.46155,0.3125
-0.71875,0.3125 l -1,0 0,-1 c 0,-0.30979 0.0901,-0.55207 0.28125,-0.75 l 2.71875,-2.65625 2.71875,2.65625 c
0.19132,0.19788 0.28125,0.4402 0.28125,0.75 z m 0,4.15625 0,1 c 0,0.3098 -0.08993,0.55212 -0.28125,0.75 l
-2.71875,2.65625 -2.71875,-2.65625 c -0.19115,-0.19793 -0.28125,-0.44021 -0.28125,-0.75 l 0,-1 1,0 c 0.2572,0
0.52824,0.12962 0.71875,0.3125 l 1.28125,1.28125 1.28125,-1.28125 c 0.19026,-0.18312 0.46154,-0.31254
0.71875,-0.3125 l 1,0 z"
+ id="rect3002"
+ inkscape:connector-curvature="0" />
+ </g>
+</svg>
diff --git a/extensions/file_tools/gth-file-tool-curves.c b/extensions/file_tools/gth-file-tool-curves.c
index 7cb7f24..33e5644 100644
--- a/extensions/file_tools/gth-file-tool-curves.c
+++ b/extensions/file_tools/gth-file-tool-curves.c
@@ -362,7 +362,7 @@ add_to_presets_dialog_response_cb (GtkDialog *dialog,
GthPoints points[GTH_HISTOGRAM_N_CHANNELS];
if (response != GTK_RESPONSE_OK) {
- gtk_widget_destroy (dialog);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
return;
}
diff --git a/extensions/image_viewer/actions.c b/extensions/image_viewer/actions.c
index ff8f6f8..be11eff 100644
--- a/extensions/image_viewer/actions.c
+++ b/extensions/image_viewer/actions.c
@@ -87,6 +87,18 @@ gth_browser_activate_image_zoom_fit_width (GSimpleAction *action,
void
+gth_browser_activate_image_zoom_fit_height (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GthBrowser *browser = user_data;
+ GthImageViewerPage *self = GTH_IMAGE_VIEWER_PAGE (gth_browser_get_viewer_page (browser));
+
+ gth_image_viewer_set_fit_mode (GTH_IMAGE_VIEWER (gth_image_viewer_page_get_image_viewer (self)),
GTH_FIT_HEIGHT);
+}
+
+
+void
gth_browser_activate_image_undo (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
diff --git a/extensions/image_viewer/actions.h b/extensions/image_viewer/actions.h
index 89d0803..9dc0450 100644
--- a/extensions/image_viewer/actions.h
+++ b/extensions/image_viewer/actions.h
@@ -29,6 +29,7 @@ DEF_ACTION_CALLBACK (gth_browser_activate_image_zoom_out)
DEF_ACTION_CALLBACK (gth_browser_activate_image_zoom_100)
DEF_ACTION_CALLBACK (gth_browser_activate_image_zoom_fit)
DEF_ACTION_CALLBACK (gth_browser_activate_image_zoom_fit_width)
+DEF_ACTION_CALLBACK (gth_browser_activate_image_zoom_fit_height)
DEF_ACTION_CALLBACK (gth_browser_activate_image_undo)
DEF_ACTION_CALLBACK (gth_browser_activate_image_redo)
DEF_ACTION_CALLBACK (gth_browser_activate_copy_image)
diff --git a/extensions/image_viewer/gth-image-viewer-page.c b/extensions/image_viewer/gth-image-viewer-page.c
index c5a483f..9618a27 100644
--- a/extensions/image_viewer/gth-image-viewer-page.c
+++ b/extensions/image_viewer/gth-image-viewer-page.c
@@ -30,10 +30,10 @@
#define UPDATE_QUALITY_DELAY 200
#define UPDATE_VISIBILITY_DELAY 100
-#define N_HEADER_BAR_BUTTONS 4
+#define N_HEADER_BAR_BUTTONS 5
#define HIDE_OVERVIEW_TIMEOUT 2 /* in seconds */
#define OVERLAY_MARGIN 10
-#define APPLY_ICC_PROFILE_BUTTON 3
+#define APPLY_ICC_PROFILE_BUTTON 4
#undef ALWAYS_LOAD_ORIGINAL_SIZE
@@ -53,6 +53,7 @@ static const GActionEntry actions[] = {
{ "image-zoom-100", gth_browser_activate_image_zoom_100 },
{ "image-zoom-fit", gth_browser_activate_image_zoom_fit },
{ "image-zoom-fit-width", gth_browser_activate_image_zoom_fit_width },
+ { "image-zoom-fit-height", gth_browser_activate_image_zoom_fit_height },
{ "image-undo", gth_browser_activate_image_undo },
{ "image-redo", gth_browser_activate_image_redo },
{ "copy-image", gth_browser_activate_copy_image },
@@ -150,12 +151,7 @@ _gth_image_preloader_get_requested_size_for_next_images (GthImageViewerPage *sel
case GTH_ZOOM_CHANGE_ACTUAL_SIZE:
requested_size = -1;
break;
-
- case GTH_ZOOM_CHANGE_KEEP_PREV:
- case GTH_ZOOM_CHANGE_FIT_SIZE:
- case GTH_ZOOM_CHANGE_FIT_SIZE_IF_LARGER:
- case GTH_ZOOM_CHANGE_FIT_WIDTH:
- case GTH_ZOOM_CHANGE_FIT_WIDTH_IF_LARGER:
+ default:
requested_size = get_viewer_size (self);
break;
}
@@ -186,10 +182,7 @@ _gth_image_preloader_get_requested_size_for_current_image (GthImageViewerPage *s
requested_size = -1;
break;
- case GTH_FIT_SIZE:
- case GTH_FIT_SIZE_IF_LARGER:
- case GTH_FIT_WIDTH:
- case GTH_FIT_WIDTH_IF_LARGER:
+ default:
requested_size = get_viewer_size (self);
break;
}
@@ -855,6 +848,13 @@ gth_image_viewer_page_real_activate (GthViewerPage *base,
_("Fit to width"),
"win.image-zoom-fit-width",
NULL);
+ self->priv->buttons[3] =
+ gth_browser_add_header_bar_button (browser,
+ GTH_BROWSER_HEADER_SECTION_VIEWER_VIEW,
+ "view-zoom-fit-height-symbolic",
+ _("Fit to height"),
+ "win.image-zoom-fit-height",
+ NULL);
self->priv->buttons[APPLY_ICC_PROFILE_BUTTON] =
gth_browser_add_header_bar_toggle_button (browser,
GTH_BROWSER_HEADER_SECTION_VIEWER_TOOLS,
@@ -1249,6 +1249,7 @@ gth_image_viewer_page_real_update_sensitivity (GthViewerPage *base)
fit_mode = gth_image_viewer_get_fit_mode (GTH_IMAGE_VIEWER (self->priv->viewer));
gth_window_enable_action (GTH_WINDOW (self->priv->browser), "image-zoom-fit", zoom_enabled &&
(fit_mode != GTH_FIT_SIZE));
gth_window_enable_action (GTH_WINDOW (self->priv->browser), "image-zoom-fit-width", zoom_enabled &&
(fit_mode != GTH_FIT_WIDTH));
+ gth_window_enable_action (GTH_WINDOW (self->priv->browser), "image-zoom-fit-height", zoom_enabled &&
(fit_mode != GTH_FIT_HEIGHT));
image = gth_image_viewer_get_image (GTH_IMAGE_VIEWER (self->priv->viewer));
gtk_widget_set_visible (self->priv->buttons[APPLY_ICC_PROFILE_BUTTON], (image != NULL) &&
(gth_image_get_icc_profile (image) != NULL));
diff --git a/gthumb/gth-image-viewer.c b/gthumb/gth-image-viewer.c
index c22350e..00c8a2b 100644
--- a/gthumb/gth-image-viewer.c
+++ b/gthumb/gth-image-viewer.c
@@ -615,6 +615,20 @@ get_zoom_to_fit_width (GthImageViewer *self,
static double
+get_zoom_to_fit_height (GthImageViewer *self,
+ GtkAllocation *allocation)
+{
+ int original_height;
+ int frame_border_2;
+
+ gth_image_viewer_get_original_size (self, NULL, &original_height);
+ frame_border_2 = _gth_image_viewer_get_frame_border (self) * 2;
+
+ return (double) (allocation->height - frame_border_2) / original_height;
+}
+
+
+static double
get_zoom_level_for_allocation (GthImageViewer *self,
GtkAllocation *allocation)
{
@@ -636,25 +650,30 @@ get_zoom_level_for_allocation (GthImageViewer *self,
case GTH_FIT_SIZE:
zoom_level = get_zoom_to_fit (self, allocation);
break;
-
case GTH_FIT_SIZE_IF_LARGER:
if ((allocation->width < original_width + frame_border_2) || (allocation->height <
original_height + frame_border_2))
zoom_level = get_zoom_to_fit (self, allocation);
else
zoom_level = 1.0;
break;
-
case GTH_FIT_WIDTH:
zoom_level = get_zoom_to_fit_width (self, allocation);
break;
-
case GTH_FIT_WIDTH_IF_LARGER:
if (allocation->width < original_width + frame_border_2)
zoom_level = get_zoom_to_fit_width (self, allocation);
else
zoom_level = 1.0;
break;
-
+ case GTH_FIT_HEIGHT:
+ zoom_level = get_zoom_to_fit_height (self, allocation);
+ break;
+ case GTH_FIT_HEIGHT_IF_LARGER:
+ if (allocation->height < original_height + frame_border_2)
+ zoom_level = get_zoom_to_fit_height (self, allocation);
+ else
+ zoom_level = 1.0;
+ break;
default:
break;
}
@@ -1463,6 +1482,12 @@ gth_image_viewer_class_init (GthImageViewerClass *class)
gtk_binding_entry_add_signal (binding_set, GDK_KEY_w, GDK_SHIFT_MASK,
"set_fit_mode", 1,
GTH_TYPE_FIT, GTH_FIT_WIDTH);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_h, 0,
+ "set_fit_mode", 1,
+ GTH_TYPE_FIT, GTH_FIT_HEIGHT_IF_LARGER);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_h, GDK_SHIFT_MASK,
+ "set_fit_mode", 1,
+ GTH_TYPE_FIT, GTH_FIT_HEIGHT);
}
@@ -1650,6 +1675,16 @@ _gth_image_viewer_content_changed (GthImageViewer *self,
gth_image_viewer_set_fit_mode (self, GTH_FIT_WIDTH_IF_LARGER);
queue_animation_frame_change (self);
break;
+
+ case GTH_ZOOM_CHANGE_FIT_HEIGHT:
+ gth_image_viewer_set_fit_mode (self, GTH_FIT_HEIGHT);
+ queue_animation_frame_change (self);
+ break;
+
+ case GTH_ZOOM_CHANGE_FIT_HEIGHT_IF_LARGER:
+ gth_image_viewer_set_fit_mode (self, GTH_FIT_HEIGHT_IF_LARGER);
+ queue_animation_frame_change (self);
+ break;
}
}
@@ -2360,6 +2395,11 @@ gth_image_viewer_needs_scrollbars (GthImageViewer *self,
hscrollbar_visible = FALSE;
break;
+ case GTH_FIT_HEIGHT:
+ case GTH_FIT_HEIGHT_IF_LARGER:
+ vscrollbar_visible = FALSE;
+ break;
+
case GTH_FIT_NONE:
if (hscrollbar_visible != vscrollbar_visible) {
if (vscrollbar_visible) {
diff --git a/gthumb/gth-image-viewer.h b/gthumb/gth-image-viewer.h
index 694e4ed..8b03a33 100644
--- a/gthumb/gth-image-viewer.h
+++ b/gthumb/gth-image-viewer.h
@@ -59,7 +59,9 @@ typedef enum {
GTH_FIT_SIZE,
GTH_FIT_SIZE_IF_LARGER,
GTH_FIT_WIDTH,
- GTH_FIT_WIDTH_IF_LARGER
+ GTH_FIT_WIDTH_IF_LARGER,
+ GTH_FIT_HEIGHT,
+ GTH_FIT_HEIGHT_IF_LARGER
} GthFit;
@@ -69,7 +71,9 @@ typedef enum {
GTH_ZOOM_CHANGE_FIT_SIZE,
GTH_ZOOM_CHANGE_FIT_SIZE_IF_LARGER,
GTH_ZOOM_CHANGE_FIT_WIDTH,
- GTH_ZOOM_CHANGE_FIT_WIDTH_IF_LARGER
+ GTH_ZOOM_CHANGE_FIT_WIDTH_IF_LARGER,
+ GTH_ZOOM_CHANGE_FIT_HEIGHT,
+ GTH_ZOOM_CHANGE_FIT_HEIGHT_IF_LARGER
} GthZoomChange;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]