summary({'Code Correctness' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
endif
+# Single value enum checks
+enum_check_sh = find_program('enum-check.sh', dirs : scriptsdir, required : true)
+if enum_check_sh.found()
+ foreach source_file : main_sources + pan_view_sources + view_file_sources
+ source_file_name = fs.name(source_file)
+ test('Single Value enum_ ' + source_file_name, enum_check_sh, args : [source_file], timeout : 100)
+ endforeach
+
+ summary({'Single Value enum' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
+else
+ summary({'Single Value enum' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
+endif
+
# Lua test
option = get_option('lua')
if not option.disabled()
--- /dev/null
+#!/bin/sh
+#**********************************************************************
+# Copyright (C) 2024 - The Geeqie Team
+#
+# Author: Colin Clark
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#**********************************************************************
+
+## @file
+## @brief Check for single value enums
+##
+## $1 Source file to check
+##
+## The expected format is: \n
+## enum { \n
+## bookmark_drop_types_n = 3 \n
+## }; \n
+##
+## The grep operation prepends line numbers so resulting in: \n
+## 123:enum { \n
+## 124- bookmark_drop_types_n = 3 \n
+## 125-};
+##
+
+res=$(grep --line-number --after-context=2 'enum\ {$' "$1" | grep --before-context=2 '^[[:digit:]]\+\-};')
+
+if [ -z "$res" ]
+then
+ exit 0
+else
+ printf "%s\n" "$res"
+ exit 1
+fi
+
#include "ui-misc.h"
#include "window.h"
+namespace
+{
+
+constexpr gint ADVANCED_EXIF_DATA_COLUMN_WIDTH = 200;
+
+} // namespace
+
struct ExifData;
struct ExifItem;
-enum {
- ADVANCED_EXIF_DATA_COLUMN_WIDTH = 200
-};
-
/*
*-------------------------------------------------------------------
* EXIF window
#include "ui-utildlg.h"
#include "uri-utils.h"
+namespace
+{
+
+constexpr gint THUMB_SIZE = 100;
+constexpr int DIRECTION_SIZE = 300;
+
+} // namespace
+
#define MARKER_COLOUR 0x00, 0x00, 0xff, 0xff
#define TEXT_COLOUR 0x00, 0x00, 0x00, 0xff
#define THUMB_COLOUR 0xff, 0xff, 0xff, 0xff
-#define THUMB_SIZE 100
-
-#define DIRECTION_SIZE 300
/*
*-------------------------------------------------------------------
#include "ui-utildlg.h"
#include "window.h"
+namespace
+{
+
+constexpr gint PURGE_DIALOG_WIDTH = 400;
+
+} // namespace
struct CMData
{
gboolean remote;
};
-enum {
- PURGE_DIALOG_WIDTH = 400
-};
-
/*
*-----------------------------------------------------------------------------
* Command line cache maintenance program functions *-----------------------------------------------------------------------------
* Currently SimilarityGrid is always assumed to be 32 x 32 RGB. \n
*/
+namespace
+{
+
+constexpr gint CACHE_LOAD_LINE_NOISE = 8;
+
+} // namespace
/*
*-------------------------------------------------------------------
return FALSE;
}
-enum {
- CACHE_LOAD_LINE_NOISE = 8
-};
-
CacheData *cache_sim_data_load(const gchar *path)
{
FILE *f;
#include <cairo.h>
#include <gdk/gdk.h>
-enum {
- FIXED_ICON_SIZE_MAX = 512
-};
+namespace
+{
+
+constexpr gint FIXED_ICON_SIZE_MAX = 512;
+} // namespace
static void gqv_cell_renderer_icon_get_property(GObject *object,
guint param_id,
*----------------------------------------------------------------------------
*/
-enum {
- HISTMAP_SIZE = 256
-};
+namespace
+{
+
+constexpr gint HISTMAP_SIZE = 256;
+
+} // namespace
struct HistMap {
gulong r[HISTMAP_SIZE];
guint16 color_mode; /* color mode as defined below */
};
-enum {
- PSD_HEADER_SIZE = 26
-};
+constexpr guint PSD_HEADER_SIZE = 26;
enum PsdColorMode
{
#include "typedefs.h"
#include "ui-fileops.h"
+namespace
+{
+
+constexpr gint IMAGE_OSD_DEFAULT_DURATION = 30;
+
+} // namespace
+
struct HistMap;
/*
#define OSD_DATA "overlay-data"
-enum {
- IMAGE_OSD_DEFAULT_DURATION = 30
-};
-
enum {
HISTOGRAM_HEIGHT = 140,
HISTOGRAM_WIDTH = 256
#include "view-file.h"
#include "window.h"
-enum {
- MENU_EDIT_ACTION_OFFSET = 16,
-};
-
static gboolean layout_bar_enabled(LayoutWindow *lw);
static gboolean layout_bar_sort_enabled(LayoutWindow *lw);
static void layout_bars_hide_toggle(LayoutWindow *lw);
#include "pixbuf-util.h"
#include "typedefs.h"
+namespace
+{
+
+constexpr guint8 PAN_CAL_DOT_ALPHA = 128;
+
+} // namespace
+
#define PAN_CAL_POPUP_COLOR 220, 220, 220
enum {
PAN_CAL_POPUP_ALPHA = 255,
PAN_CAL_DOT_GAP = 2
};
#define PAN_CAL_DOT_COLOR 128, 128, 128
-enum {
- PAN_CAL_DOT_ALPHA = 128
-};
#define PAN_CAL_DAY_OF_WEEK_COLOR 128, 128, 128
#include "utilops.h"
#include "window.h"
+namespace
+{
+
+constexpr gint PAN_TILE_SIZE = 512;
+constexpr gint ZOOM_LABEL_WIDTH = 64;
+
+} // namespace
enum {
PAN_WINDOW_DEFAULT_WIDTH = 720,
PAN_WINDOW_DEFAULT_HEIGHT = 500
};
-enum {
- PAN_TILE_SIZE = 512
-};
-
#define ZOOM_INCREMENT 1.0
-enum {
- ZOOM_LABEL_WIDTH = 64
-};
-
#define PAN_PREF_GROUP "pan_view_options"
#define PAN_PREF_HIDE_WARNING "hide_performance_warning"
};
#endif
-
-/* default min and max zoom */
-#define PR_ZOOM_MIN (-32.0)
-#define PR_ZOOM_MAX 32.0
+namespace
+{
/* distance to drag mouse to disable image flip */
-enum {
- PR_DRAG_SCROLL_THRESHHOLD = 4
-};
+constexpr gint PR_DRAG_SCROLL_THRESHHOLD = 4;
/* increase pan rate when holding down shift */
-enum {
- PR_PAN_SHIFT_MULTIPLIER = 6
-};
+constexpr gint PR_PAN_SHIFT_MULTIPLIER = 6;
+
+} // namespace
+
+/* default min and max zoom */
+#define PR_ZOOM_MIN (-32.0)
+#define PR_ZOOM_MAX 32.0
/* scroller config */
enum {
#include "utilops.h"
#include "window.h"
+namespace
+{
+
+constexpr gint PRE_FORMATTED_COLUMNS = 5;
+constexpr gint KEYWORD_DIALOG_WIDTH = 400;
+
+} // namespace
+
struct ZoneDetect;
enum {
options->fullscreen.disable_saver, &c_options->fullscreen.disable_saver);
}
-enum {
- PRE_FORMATTED_COLUMNS = 5
-};
static void config_tab_osd(GtkWidget *notebook)
{
GtkWidget *hbox;
guint idle_id; /* event source id */
};
-enum {
- KEYWORD_DIALOG_WIDTH = 400
-};
-
static void keywords_find_folder(KeywordFindData *kfd, FileData *dir_fd)
{
GList *list_d = nullptr;
/* method to use when scaling down image data */
#define PRINT_MAX_INTERP GDK_INTERP_BILINEAR
+namespace
+{
+
+constexpr gint PRE_FORMATTED_COLUMNS = 4;
+
+} // namespace
+
/* reverse order is important */
enum TextPosition {
FOOTER_2,
gtk_text_buffer_get_text(pTextBuffer, &iStart, &iEnd, TRUE));
}
-enum {
- PRE_FORMATTED_COLUMNS = 4
-};
static void print_text_menu(GtkWidget *box, PrintWindow *pw)
{
GtkWidget *group;
#include "utilops.h"
#include "view-file.h"
-enum {
- SERVER_MAX_CLIENTS = 8
-};
-
-enum {
- REMOTE_SERVER_BACKLOG = 4
-};
-
-
#ifndef UNIX_PATH_MAX
#define UNIX_PATH_MAX 108
#endif
+namespace
+{
+
+constexpr guint SERVER_MAX_CLIENTS = 8;
+constexpr int REMOTE_SERVER_BACKLOG = 4;
+
+} // namespace
static RemoteConnection *remote_client_open(const gchar *path);
static gint remote_client_send(RemoteConnection *rc, const gchar *text);
};
#endif
+namespace
+{
+
+constexpr size_t COLOR_BYTES = 3; /* rgb */
+
+} // namespace
+
struct QueueData;
struct ImageTile
return rt->spare_tile;
}
-enum {
- COLOR_BYTES = 3 /* rgb */
-};
-
static void rt_tile_rotate_90_clockwise(RendererTiles *rt, GdkPixbuf **tile, gint x, gint y, gint w, gint h)
{
GdkPixbuf *src = *tile;
#define MARKER_PATH "[path]"
#define MARKER_ICON "[icon]"
+namespace
+{
+
+constexpr gint bookmark_drop_types_n = 3;
+constexpr gint bookmark_drag_types_n = 2;
+
+} // namespace
+
struct BookButtonData;
struct BookMarkData
{ const_cast<gchar *>("x-url/http"), 0, TARGET_X_URL },
{ const_cast<gchar *>("_NETSCAPE_URL"), 0, TARGET_X_URL }
};
-enum {
- bookmark_drop_types_n = 3
-};
static GtkTargetEntry bookmark_drag_types[] = {
{ const_cast<gchar *>("text/uri-list"), 0, TARGET_URI_LIST },
{ const_cast<gchar *>("text/plain"), 0, TARGET_TEXT_PLAIN }
};
-enum {
- bookmark_drag_types_n = 2
-};
-
static GList *bookmark_widget_list = nullptr;
static GList *bookmark_default_list = nullptr;
#include "uri-utils.h"
#include "utilops.h"
+namespace
+{
+
+constexpr gint dest_drag_types_n = 2;
+
+} // namespace
enum {
DEST_WIDTH = 250,
DEST_HEIGHT = 210
};
-enum {
- RENAME_PRESS_DELAY = 333 /* 1/3 second, to allow double clicks */
-};
-
#define PATH_SEL_USE_HEADINGS FALSE
enum {
{ const_cast<gchar *>("text/uri-list"), 0, TARGET_URI_LIST },
{ const_cast<gchar *>("text/plain"), 0, TARGET_TEXT_PLAIN }
};
-enum {
- dest_drag_types_n = 2
-};
-
static void dest_dnd_set_data(GtkWidget *view, GdkDragContext *,
GtkSelectionData *selection_data,
namespace
{
+constexpr gint DIALOG_WIDTH = 750;
+
+/* thumbnail spec has a max depth of 4 (.thumb??/fail/appname/??.png) */
+constexpr gint UTILITY_DELETE_MAX_DEPTH = 5;
+
struct PixmapErrors
{
GdkPixbuf *error;
return pe.apply;
}
-}
-
-enum {
- DIALOG_WIDTH = 750
-};
+} // namespace
enum ClipboardDestination {
CLIPBOARD_TEXT_PLAIN = 0,
UTILITY_LIST_MIN_HEIGHT = 150
};
-/* thumbnail spec has a max depth of 4 (.thumb??/fail/appname/??.png) */
-enum {
- UTILITY_DELETE_MAX_DEPTH = 5
-};
-
static UtilityData *file_util_data_new(UtilityType type)
{
UtilityData *ud;