[eog: 6/11] unify pixel string creation via helper method
- From: Felix Riemann <friemann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [eog: 6/11] unify pixel string creation via helper method
- Date: Sat, 12 Feb 2022 18:09:30 +0000 (UTC)
commit e302fbef4cc56832e0d87db0a0830dec94a487b9
Author: Peter Eisenmann <p3732 getgoogleoff me>
Date: Sun Aug 15 03:00:30 2021 +0200
unify pixel string creation via helper method
src/eog-file-chooser.c | 6 ++----
src/eog-metadata-sidebar.c | 4 +---
src/eog-remote-presenter.c | 3 +--
src/eog-thumb-view.c | 9 +++------
src/eog-util.c | 9 +++++++++
src/eog-util.h | 3 +++
6 files changed, 19 insertions(+), 15 deletions(-)
---
diff --git a/src/eog-file-chooser.c b/src/eog-file-chooser.c
index 03052549..da24db89 100644
--- a/src/eog-file-chooser.c
+++ b/src/eog-file-chooser.c
@@ -20,6 +20,7 @@
#include "eog-file-chooser.h"
#include "eog-pixbuf-util.h"
+#include "eog-util.h"
#include <stdlib.h>
@@ -254,7 +255,6 @@ set_preview_pixbuf (EogFileChooser *chooser, GdkPixbuf *pixbuf, goffset size)
{
EogFileChooserPrivate *priv;
int bytes;
- int pixels;
const char *bytes_str;
const char *width;
const char *height;
@@ -284,9 +284,7 @@ set_preview_pixbuf (EogFileChooser *chooser, GdkPixbuf *pixbuf, goffset size)
height = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::Image::Height");
if ((width != NULL) && (height != NULL)) {
- pixels = atoi (height);
- /* Pixel size of image: width x height in pixel */
- dim_str = g_strdup_printf ("%s x %s %s", width, height, ngettext ("pixel", "pixels",
pixels));
+ dim_str = eog_util_create_width_height_string(atoi (width), atoi (height));
}
#if 0
diff --git a/src/eog-metadata-sidebar.c b/src/eog-metadata-sidebar.c
index 92e13ad6..1363a6e5 100644
--- a/src/eog-metadata-sidebar.c
+++ b/src/eog-metadata-sidebar.c
@@ -146,9 +146,7 @@ eog_metadata_sidebar_update_general_section (EogMetadataSidebar *sidebar)
}
eog_image_get_size (img, &width, &height);
- str = g_strdup_printf (ngettext("%i × %i pixel",
- "%i × %i pixels", height),
- width, height);
+ str = eog_util_create_width_height_string(width, height);
gtk_label_set_text (GTK_LABEL (priv->size_label), str);
g_free (str);
diff --git a/src/eog-remote-presenter.c b/src/eog-remote-presenter.c
index 66f1ba02..f31c82bb 100644
--- a/src/eog-remote-presenter.c
+++ b/src/eog-remote-presenter.c
@@ -343,8 +343,7 @@ eog_remote_presenter_update (EogRemotePresenter *remote_presenter,
eog_image_get_size (image, &width, &height);
- size_str = g_strdup_printf ("%d × %d %s", width, height,
- ngettext ("pixel", "pixels", width * height));
+ size_str = eog_util_create_width_height_string(width, height);
gtk_label_set_text (GTK_LABEL (remote_presenter->priv->size_label), size_str);
diff --git a/src/eog-thumb-view.c b/src/eog-thumb-view.c
index 5e0c2f59..ef900439 100644
--- a/src/eog-thumb-view.c
+++ b/src/eog-thumb-view.c
@@ -27,6 +27,7 @@
#include "eog-list-store.h"
#include "eog-image.h"
#include "eog-job-scheduler.h"
+#include "eog-util.h"
#ifdef HAVE_EXIF
#include "eog-exif-util.h"
@@ -519,15 +520,11 @@ thumbview_get_tooltip_string (EogImage *image)
if (width > -1 && height > -1) {
tooltip_string = g_markup_printf_escaped ("<b><big>%s</big></b>\n"
- "%i x %i %s\n"
+ "%s\n"
"%s\n"
"%s",
eog_image_get_caption (image),
- width,
- height,
- ngettext ("pixel",
- "pixels",
- height),
+ eog_util_create_width_height_string(width, height),
bytes,
type_str);
} else {
diff --git a/src/eog-util.c b/src/eog-util.c
index 56d23472..4fcdf21c 100644
--- a/src/eog-util.c
+++ b/src/eog-util.c
@@ -508,6 +508,15 @@ eog_util_show_file_in_filemanager (GFile *file, GtkWindow *toplevel)
_eog_util_show_file_in_filemanager_fallback (file, toplevel);
}
+gchar *
+eog_util_create_width_height_string (gint width, gint height)
+{
+ return g_strdup_printf (
+ ngettext("%i × %i pixel", "%i × %i pixels", width * height),
+ width, height);
+}
+
+
/* Portal */
#ifdef HAVE_LIBPORTAL
diff --git a/src/eog-util.h b/src/eog-util.h
index ae3c0244..ee77d5ad 100644
--- a/src/eog-util.h
+++ b/src/eog-util.h
@@ -69,6 +69,9 @@ G_GNUC_INTERNAL
void eog_util_show_file_in_filemanager (GFile *file,
GtkWindow *toplevel);
+G_GNUC_INTERNAL
+gchar *eog_util_create_width_height_string (gint width, gint height);
+
#ifdef HAVE_LIBPORTAL
G_GNUC_INTERNAL
gboolean eog_util_is_running_inside_flatpak (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]