Deduplicate cell_renderer_height_override()
authorArkadiy Illarionov <qarkai@gmail.com>
Fri, 8 Mar 2024 16:14:12 +0000 (19:14 +0300)
committerColin Clark <colin.clark@cclark.uk>
Sat, 9 Mar 2024 09:53:59 +0000 (09:53 +0000)
src/dupe.cc
src/dupe.h
src/misc.cc
src/misc.h
src/search.cc
src/view-file/view-file-list.cc

index 57f8ba5..dc86cb8 100644 (file)
@@ -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;
index 791e66c..29b9dd2 100644 (file)
@@ -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: */
index 15439d0..9cebbab 100644 (file)
 #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<gdouble>(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: */
index a9e841d..28c5aed 100644 (file)
@@ -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: */
index 56d1cf5..a16851f 100644 (file)
@@ -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"
index 02b4ce4..f42ac32 100644 (file)
@@ -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;