From c15e68cf681a55fce4302429780593e9a2ce2050 Mon Sep 17 00:00:00 2001 From: Arkadiy Illarionov Date: Fri, 8 Mar 2024 19:14:12 +0300 Subject: [PATCH] Deduplicate cell_renderer_height_override() --- src/dupe.cc | 20 -------------------- src/dupe.h | 2 -- src/misc.cc | 27 ++++++++++++++++++++++++--- src/misc.h | 2 ++ src/search.cc | 1 - src/view-file/view-file-list.cc | 21 --------------------- 6 files changed, 26 insertions(+), 47 deletions(-) diff --git a/src/dupe.cc b/src/dupe.cc index 57f8ba51..dc86cb81 100644 --- a/src/dupe.cc +++ b/src/dupe.cc @@ -3986,26 +3986,6 @@ static void dupe_menu_setup(DupeWindow *dw) *------------------------------------------------------------------- */ -/* this overrides the low default of a GtkCellRenderer from 100 to CELL_HEIGHT_OVERRIDE, something sane for our purposes */ - -enum { - CELL_HEIGHT_OVERRIDE = 512 -}; - -void cell_renderer_height_override(GtkCellRenderer *renderer) -{ - GParamSpec *spec; - - spec = g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(renderer)), "height"); - if (spec && G_IS_PARAM_SPEC_INT(spec)) - { - GParamSpecInt *spec_int; - - spec_int = G_PARAM_SPEC_INT(spec); - if (spec_int->maximum < CELL_HEIGHT_OVERRIDE) spec_int->maximum = CELL_HEIGHT_OVERRIDE; - } -} - static GdkRGBA *dupe_listview_color_shifted(GtkWidget *widget) { static GdkRGBA color; diff --git a/src/dupe.h b/src/dupe.h index 791e66c5..29b9dd2a 100644 --- a/src/dupe.h +++ b/src/dupe.h @@ -165,7 +165,5 @@ void dupe_window_close(DupeWindow *dw); void dupe_window_add_collection(DupeWindow *dw, CollectionData *collection); void dupe_window_add_files(DupeWindow *dw, GList *list, gboolean recurse); -void cell_renderer_height_override(GtkCellRenderer *renderer); /**< cell max with/height hack utility */ - #endif /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ diff --git a/src/misc.cc b/src/misc.cc index 15439d02..9cebbabc 100644 --- a/src/misc.cc +++ b/src/misc.cc @@ -38,6 +38,15 @@ #include "options.h" #include "ui-fileops.h" +namespace +{ + +constexpr int BUFSIZE = 128; + +constexpr gint CELL_HEIGHT_OVERRIDE = 512; + +} // namespace + gdouble get_zoom_increment() { return ((options->image.zoom_increment != 0) ? static_cast(options->image.zoom_increment) / 100.0 : 1.0); @@ -146,9 +155,6 @@ gchar *expand_tilde(const gchar *filename) */ #define GEOCODE_NAME "geocode-parameters.awk" -enum { - BUFSIZE = 128 -}; gchar *decode_geo_script(const gchar *path_dir, const gchar *input_text) { @@ -434,4 +440,19 @@ void gq_gtk_grid_attach_default(GtkGrid *grid, GtkWidget *child, guint left_atta gtk_grid_attach(grid, child, left_attach, top_attach, right_attach - left_attach, bottom_attach - top_attach); } +/* this overrides the low default of a GtkCellRenderer from 100 to CELL_HEIGHT_OVERRIDE, something sane for our purposes */ +void cell_renderer_height_override(GtkCellRenderer *renderer) +{ + GParamSpec *spec; + + spec = g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(renderer)), "height"); + if (spec && G_IS_PARAM_SPEC_INT(spec)) + { + GParamSpecInt *spec_int; + + spec_int = G_PARAM_SPEC_INT(spec); + if (spec_int->maximum < CELL_HEIGHT_OVERRIDE) spec_int->maximum = CELL_HEIGHT_OVERRIDE; + } +} + /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ diff --git a/src/misc.h b/src/misc.h index a9e841d1..28c5aedb 100644 --- a/src/misc.h +++ b/src/misc.h @@ -49,5 +49,7 @@ void convert_gdkcolor_to_gdkrgba(gpointer data, GdkRGBA *gdk_rgba); void convert_gdkcolor_to_gdkrgba(gpointer data, GdkRGBA *gdk_rgba); #endif /* HAVE_GTK4 */ +void cell_renderer_height_override(GtkCellRenderer *renderer); /**< cell max with/height hack utility */ + #endif /* MISC_H */ /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ diff --git a/src/search.cc b/src/search.cc index 56d1cf59..a16851f0 100644 --- a/src/search.cc +++ b/src/search.cc @@ -41,7 +41,6 @@ #include "compat.h" #include "debug.h" #include "dnd.h" -#include "dupe.h" #include "editors.h" #include "filedata.h" #include "image-load.h" diff --git a/src/view-file/view-file-list.cc b/src/view-file/view-file-list.cc index 02b4ce4c..f42ac326 100644 --- a/src/view-file/view-file-list.cc +++ b/src/view-file/view-file-list.cc @@ -1944,27 +1944,6 @@ gboolean vflist_refresh(ViewFile *vf) } - -/* this overrides the low default of a GtkCellRenderer from 100 to CELL_HEIGHT_OVERRIDE, something sane for our purposes */ - -enum { - CELL_HEIGHT_OVERRIDE = 512 -}; - -static void cell_renderer_height_override(GtkCellRenderer *renderer) -{ - GParamSpec *spec; - - spec = g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(renderer)), "height"); - if (spec && G_IS_PARAM_SPEC_INT(spec)) - { - GParamSpecInt *spec_int; - - spec_int = G_PARAM_SPEC_INT(spec); - if (spec_int->maximum < CELL_HEIGHT_OVERRIDE) spec_int->maximum = CELL_HEIGHT_OVERRIDE; - } -} - static GdkRGBA *vflist_listview_color_shifted(GtkWidget *widget) { static GdkRGBA color; -- 2.20.1