From a4ce95bc11a58700e29c15d324f9ed4d7c27900a Mon Sep 17 00:00:00 2001 From: Colin Clark Date: Wed, 7 Feb 2024 12:26:09 +0000 Subject: [PATCH] clang-tidy: modernize-macro-to-enum - Fix warnings identified by this flag - Remove the exclude from .clang-tidy file Clang-tidy fix resulted in indentation dissimilar to that used so far. This awk script was run on the .diff file: /^+[A-Z]/ { sub (/\+/,"+\t",$0) print next } $0 !~ /^+[A-Z]/ { print next } The following files were hand-edited: thumb-standard.cc ui-bookmark.cc --- src/advanced-exif.cc | 4 +++- src/bar-exif.cc | 4 +++- src/cache-maint.cc | 4 +++- src/cache.cc | 4 +++- src/cellrenderericon.cc | 4 +++- src/collect-io.cc | 14 +++++++++----- src/collect-table.cc | 19 +++++++++++------- src/collect.cc | 6 ++++-- src/desktop-file.cc | 6 ++++-- src/dupe.cc | 10 +++++++--- src/editors.cc | 6 ++++-- src/histogram.cc | 4 +++- src/image-load-dds.cc | 32 ++++++++++++++++--------------- src/image-load-psd.cc | 4 +++- src/image-load.cc | 6 ++++-- src/image-overlay.cc | 10 +++++++--- src/jpeg-parser.cc | 12 +++++++----- src/layout-config.cc | 4 +++- src/layout-image.cc | 4 +++- src/layout-util.cc | 6 ++++-- src/layout.cc | 28 ++++++++++++++++++--------- src/misc.cc | 4 +++- src/pan-view/pan-calendar.cc | 34 ++++++++++++++++++++++----------- src/pan-view/pan-view.cc | 14 ++++++++++---- src/pixbuf-renderer.cc | 28 ++++++++++++++++++--------- src/pixbuf-util.cc | 6 ++++-- src/preferences.cc | 20 +++++++++++++------ src/print.cc | 4 +++- src/remote.cc | 8 ++++++-- src/renderer-tiles.cc | 4 +++- src/search.cc | 16 ++++++++++------ src/thumb-standard.cc | 15 ++++++--------- src/ui-bookmark.cc | 8 ++++++-- src/ui-help.cc | 6 ++++-- src/ui-pathsel.cc | 14 ++++++++++---- src/ui-tree-edit.cc | 6 ++++-- src/utilops.cc | 20 +++++++++++++------ src/view-file/view-file-icon.cc | 16 +++++++++++----- src/view-file/view-file-list.cc | 4 +++- 39 files changed, 278 insertions(+), 140 deletions(-) diff --git a/src/advanced-exif.cc b/src/advanced-exif.cc index bcc1c25d..dba400d2 100644 --- a/src/advanced-exif.cc +++ b/src/advanced-exif.cc @@ -31,7 +31,9 @@ #include "window.h" #include "dnd.h" -#define ADVANCED_EXIF_DATA_COLUMN_WIDTH 200 +enum { + ADVANCED_EXIF_DATA_COLUMN_WIDTH = 200 +}; /* *------------------------------------------------------------------- diff --git a/src/bar-exif.cc b/src/bar-exif.cc index 0eaf5f7d..82b7b792 100644 --- a/src/bar-exif.cc +++ b/src/bar-exif.cc @@ -34,7 +34,9 @@ #include "ui-misc.h" #include "ui-utildlg.h" -#define MIN_HEIGHT 25 +enum { + MIN_HEIGHT = 25 +}; /* *------------------------------------------------------------------- * EXIF widget diff --git a/src/cache-maint.cc b/src/cache-maint.cc index f7cf7c49..d7dff19e 100644 --- a/src/cache-maint.cc +++ b/src/cache-maint.cc @@ -51,7 +51,9 @@ struct CMData gboolean remote; }; -#define PURGE_DIALOG_WIDTH 400 +enum { + PURGE_DIALOG_WIDTH = 400 +}; /* *----------------------------------------------------------------------------- diff --git a/src/cache.cc b/src/cache.cc index 118123bd..3d1cf223 100644 --- a/src/cache.cc +++ b/src/cache.cc @@ -393,7 +393,9 @@ static gboolean cache_sim_read_similarity(FILE *f, gchar *buf, gint s, CacheData return FALSE; } -#define CACHE_LOAD_LINE_NOISE 8 +enum { + CACHE_LOAD_LINE_NOISE = 8 +}; CacheData *cache_sim_data_load(const gchar *path) { diff --git a/src/cellrenderericon.cc b/src/cellrenderericon.cc index 322f5efa..75449f5f 100644 --- a/src/cellrenderericon.cc +++ b/src/cellrenderericon.cc @@ -20,7 +20,9 @@ #include "main.h" #include "cellrenderericon.h" -#define FIXED_ICON_SIZE_MAX 512 +enum { + FIXED_ICON_SIZE_MAX = 512 +}; static void gqv_cell_renderer_icon_get_property(GObject *object, diff --git a/src/collect-io.cc b/src/collect-io.cc index 40937343..a60938aa 100644 --- a/src/collect-io.cc +++ b/src/collect-io.cc @@ -31,9 +31,11 @@ #define GQ_COLLECTION_MARKER "#" GQ_APPNAME -#define GQ_COLLECTION_FAIL_MIN 300 -#define GQ_COLLECTION_FAIL_PERCENT 98 -#define GQ_COLLECTION_READ_BUFSIZE 4096 +enum { + GQ_COLLECTION_FAIL_MIN = 300, + GQ_COLLECTION_FAIL_PERCENT = 98, + GQ_COLLECTION_READ_BUFSIZE = 4096 +}; struct CollectManagerEntry; @@ -475,8 +477,10 @@ gboolean collection_load_only_geometry(CollectionData *cd, const gchar *path) *------------------------------------------------------------------- */ -#define COLLECT_MANAGER_ACTIONS_PER_IDLE 1000 -#define COLLECT_MANAGER_FLUSH_DELAY 10000 +enum { + COLLECT_MANAGER_ACTIONS_PER_IDLE = 1000, + COLLECT_MANAGER_FLUSH_DELAY = 10000 +}; struct CollectManagerEntry { diff --git a/src/collect-table.cc b/src/collect-table.cc index 61944d6d..8f1af773 100644 --- a/src/collect-table.cc +++ b/src/collect-table.cc @@ -44,15 +44,20 @@ #include "view-file.h" /* between these, the icon width is increased by thumb_max_width / 2 */ -#define THUMB_MIN_ICON_WIDTH 128 -#define THUMB_MAX_ICON_WIDTH 150 - -#define COLLECT_TABLE_MAX_COLUMNS 32 -#define THUMB_BORDER_PADDING 2 +enum { + THUMB_MIN_ICON_WIDTH = 128, + THUMB_MAX_ICON_WIDTH = 150 +}; -#define COLLECT_TABLE_TIP_DELAY 500 -#define COLLECT_TABLE_TIP_DELAY_PATH (COLLECT_TABLE_TIP_DELAY * 1.7) +enum { + COLLECT_TABLE_MAX_COLUMNS = 32, + THUMB_BORDER_PADDING = 2 +}; +enum { + COLLECT_TABLE_TIP_DELAY = 500, + COLLECT_TABLE_TIP_DELAY_PATH = 850 +}; enum { CTABLE_COLUMN_POINTER = 0, diff --git a/src/collect.cc b/src/collect.cc index e3fd8202..8a735986 100644 --- a/src/collect.cc +++ b/src/collect.cc @@ -37,8 +37,10 @@ #include "utilops.h" #include "window.h" -#define COLLECT_DEF_WIDTH 440 -#define COLLECT_DEF_HEIGHT 450 +enum { + COLLECT_DEF_WIDTH = 440, + COLLECT_DEF_HEIGHT = 450 +}; /** * list of paths to collections */ diff --git a/src/desktop-file.cc b/src/desktop-file.cc index bd972419..6879fa35 100644 --- a/src/desktop-file.cc +++ b/src/desktop-file.cc @@ -31,8 +31,10 @@ #include "utilops.h" #include "window.h" -#define CONFIG_WINDOW_DEF_WIDTH 700 -#define CONFIG_WINDOW_DEF_HEIGHT 400 +enum { + CONFIG_WINDOW_DEF_WIDTH = 700, + CONFIG_WINDOW_DEF_HEIGHT = 400 +}; diff --git a/src/dupe.cc b/src/dupe.cc index 2e84522a..c67fca85 100644 --- a/src/dupe.cc +++ b/src/dupe.cc @@ -50,8 +50,10 @@ #include -#define DUPE_DEF_WIDTH 800 -#define DUPE_DEF_HEIGHT 400 +enum { + DUPE_DEF_WIDTH = 800, + DUPE_DEF_HEIGHT = 400 +}; #define DUPE_PROGRESS_PULSE_STEP 0.0001 /** column assignment order (simply change them here) @@ -3967,7 +3969,9 @@ 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 */ -#define CELL_HEIGHT_OVERRIDE 512 +enum { + CELL_HEIGHT_OVERRIDE = 512 +}; void cell_renderer_height_override(GtkCellRenderer *renderer) { diff --git a/src/editors.cc b/src/editors.cc index 58a8e026..9bf3c3ca 100644 --- a/src/editors.cc +++ b/src/editors.cc @@ -28,8 +28,10 @@ #include "ui-fileops.h" #include "utilops.h" -#define EDITOR_WINDOW_WIDTH 500 -#define EDITOR_WINDOW_HEIGHT 300 +enum { + EDITOR_WINDOW_WIDTH = 500, + EDITOR_WINDOW_HEIGHT = 300 +}; diff --git a/src/histogram.cc b/src/histogram.cc index 3f858e8f..019de2d1 100644 --- a/src/histogram.cc +++ b/src/histogram.cc @@ -32,7 +32,9 @@ *---------------------------------------------------------------------------- */ -#define HISTMAP_SIZE 256 +enum { + HISTMAP_SIZE = 256 +}; struct HistMap { gulong r[HISTMAP_SIZE]; diff --git a/src/image-load-dds.cc b/src/image-load-dds.cc index 0cfe9e69..78427946 100644 --- a/src/image-load-dds.cc +++ b/src/image-load-dds.cc @@ -89,21 +89,23 @@ uint ddsGetAlphaMask(unsigned const char * buffer) { } // Image Type -#define DXT1 (0x44585431) -#define DXT2 (0x44585432) -#define DXT3 (0x44585433) -#define DXT4 (0x44585434) -#define DXT5 (0x44585435) -#define A1R5G5B5 ((1 << 16) | 2) -#define X1R5G5B5 ((2 << 16) | 2) -#define A4R4G4B4 ((3 << 16) | 2) -#define X4R4G4B4 ((4 << 16) | 2) -#define R5G6B5 ((5 << 16) | 2) -#define R8G8B8 ((1 << 16) | 3) -#define A8B8G8R8 ((1 << 16) | 4) -#define X8B8G8R8 ((2 << 16) | 4) -#define A8R8G8B8 ((3 << 16) | 4) -#define X8R8G8B8 ((4 << 16) | 4) +enum { + DXT1 = (0x44585431), + DXT2 = (0x44585432), + DXT3 = (0x44585433), + DXT4 = (0x44585434), + DXT5 = (0x44585435), + A1R5G5B5 = ((1 << 16) | 2), + X1R5G5B5 = ((2 << 16) | 2), + A4R4G4B4 = ((3 << 16) | 2), + X4R4G4B4 = ((4 << 16) | 2), + R5G6B5 = ((5 << 16) | 2), + R8G8B8 = ((1 << 16) | 3), + A8B8G8R8 = ((1 << 16) | 4), + X8B8G8R8 = ((2 << 16) | 4), + A8R8G8B8 = ((3 << 16) | 4), + X8R8G8B8 = ((4 << 16) | 4) +}; // RGBA Masks static const uint A1R5G5B5_MASKS[] = { 0x7C00, 0x03E0, 0x001F, 0x8000 }; diff --git a/src/image-load-psd.cc b/src/image-load-psd.cc index 6fb9e5fe..92f1239e 100644 --- a/src/image-load-psd.cc +++ b/src/image-load-psd.cc @@ -76,7 +76,9 @@ struct PsdHeader guint16 color_mode; /* color mode as defined below */ }; -#define PSD_HEADER_SIZE 26 +enum { + PSD_HEADER_SIZE = 26 +}; enum PsdColorMode { diff --git a/src/image-load.cc b/src/image-load.cc index da06b41b..22bca7e2 100644 --- a/src/image-load.cc +++ b/src/image-load.cc @@ -66,8 +66,10 @@ #include #include -#define IMAGE_LOADER_READ_BUFFER_SIZE_DEFAULT 4096 -#define IMAGE_LOADER_IDLE_READ_LOOP_COUNT_DEFAULT 1 +enum { + IMAGE_LOADER_READ_BUFFER_SIZE_DEFAULT = 4096, + IMAGE_LOADER_IDLE_READ_LOOP_COUNT_DEFAULT = 1 +}; /* image loader class */ diff --git a/src/image-overlay.cc b/src/image-overlay.cc index 1883637f..abe13812 100644 --- a/src/image-overlay.cc +++ b/src/image-overlay.cc @@ -86,10 +86,14 @@ static OSDIcon osd_icons[] = { #define OSD_DATA "overlay-data" -#define IMAGE_OSD_DEFAULT_DURATION 30 +enum { + IMAGE_OSD_DEFAULT_DURATION = 30 +}; -#define HISTOGRAM_HEIGHT 140 -#define HISTOGRAM_WIDTH 256 +enum { + HISTOGRAM_HEIGHT = 140, + HISTOGRAM_WIDTH = 256 +}; static void image_osd_timer_schedule(OverlayStateData *osd); diff --git a/src/jpeg-parser.cc b/src/jpeg-parser.cc index 96e0b3d5..09b998ac 100644 --- a/src/jpeg-parser.cc +++ b/src/jpeg-parser.cc @@ -65,11 +65,13 @@ enum TiffByteOrder { TIFF_BYTE_ORDER_MOTOROLA }; -#define TIFF_TIFD_OFFSET_TAG 0 -#define TIFF_TIFD_OFFSET_FORMAT 2 -#define TIFF_TIFD_OFFSET_COUNT 4 -#define TIFF_TIFD_OFFSET_DATA 8 -#define TIFF_TIFD_SIZE 12 +enum { + TIFF_TIFD_OFFSET_TAG = 0, + TIFF_TIFD_OFFSET_FORMAT = 2, + TIFF_TIFD_OFFSET_COUNT = 4, + TIFF_TIFD_OFFSET_DATA = 8, + TIFF_TIFD_SIZE = 12 +}; diff --git a/src/layout-config.cc b/src/layout-config.cc index 6dccf1fe..51a56bd4 100644 --- a/src/layout-config.cc +++ b/src/layout-config.cc @@ -231,7 +231,9 @@ static void layout_config_table_button(GtkWidget *table, LayoutLocation l, const gtk_widget_show(button); } -#define LAYOUT_STYLE_SIZE 48 +enum { + LAYOUT_STYLE_SIZE = 48 +}; static GtkWidget *layout_config_widget(GtkWidget *group, GtkWidget *box, gint style, LayoutConfig *lc) { diff --git a/src/layout-image.cc b/src/layout-image.cc index 49fea7f0..0c98ab58 100644 --- a/src/layout-image.cc +++ b/src/layout-image.cc @@ -45,7 +45,9 @@ #include "utilops.h" #include "view-file.h" -#define FILE_COLUMN_POINTER 0 +enum { + FILE_COLUMN_POINTER = 0 +}; static GtkWidget *layout_image_pop_menu(LayoutWindow *lw); static void layout_image_set_buttons(LayoutWindow *lw); diff --git a/src/layout-util.cc b/src/layout-util.cc index 5dc2ff55..1ebbb2ee 100644 --- a/src/layout-util.cc +++ b/src/layout-util.cc @@ -63,8 +63,10 @@ #include #include "keymap-template.h" -#define MENU_EDIT_ACTION_OFFSET 16 -#define FILE_COLUMN_POINTER 0 +enum { + MENU_EDIT_ACTION_OFFSET = 16, + FILE_COLUMN_POINTER = 0 +}; static gboolean layout_bar_enabled(LayoutWindow *lw); static gboolean layout_bar_sort_enabled(LayoutWindow *lw); diff --git a/src/layout.cc b/src/layout.cc index 43c6bf5d..a911a67a 100644 --- a/src/layout.cc +++ b/src/layout.cc @@ -53,19 +53,27 @@ #include #endif -#define MAINWINDOW_DEF_WIDTH 700 -#define MAINWINDOW_DEF_HEIGHT 500 +enum { + MAINWINDOW_DEF_WIDTH = 700, + MAINWINDOW_DEF_HEIGHT = 500 +}; #define MAIN_WINDOW_DIV_HPOS (MAINWINDOW_DEF_WIDTH / 2) #define MAIN_WINDOW_DIV_VPOS (MAINWINDOW_DEF_HEIGHT / 2) -#define TOOLWINDOW_DEF_WIDTH 260 -#define TOOLWINDOW_DEF_HEIGHT 450 +enum { + TOOLWINDOW_DEF_WIDTH = 260, + TOOLWINDOW_DEF_HEIGHT = 450 +}; -#define PROGRESS_WIDTH 150 -#define ZOOM_LABEL_WIDTH 120 +enum { + PROGRESS_WIDTH = 150, + ZOOM_LABEL_WIDTH = 120 +}; -#define PANE_DIVIDER_SIZE 10 +enum { + PANE_DIVIDER_SIZE = 10 +}; GList *layout_window_list = nullptr; @@ -2224,8 +2232,10 @@ void layout_info_pixel_set(LayoutWindow *lw, gboolean show) *----------------------------------------------------------------------------- */ -#define CONFIG_WINDOW_DEF_WIDTH 600 -#define CONFIG_WINDOW_DEF_HEIGHT 400 +enum { + CONFIG_WINDOW_DEF_WIDTH = 600, + CONFIG_WINDOW_DEF_HEIGHT = 400 +}; struct LayoutConfig { diff --git a/src/misc.cc b/src/misc.cc index 053efbfc..ceba42eb 100644 --- a/src/misc.cc +++ b/src/misc.cc @@ -135,7 +135,9 @@ gchar *expand_tilde(const gchar *filename) */ #define GEOCODE_NAME "geocode-parameters.awk" -#define BUFSIZE 128 +enum { + BUFSIZE = 128 +}; gchar *decode_geo_script(const gchar *path_dir, const gchar *input_text) { diff --git a/src/pan-view/pan-calendar.cc b/src/pan-view/pan-calendar.cc index 54e70d04..668d91fe 100644 --- a/src/pan-view/pan-calendar.cc +++ b/src/pan-view/pan-calendar.cc @@ -30,30 +30,42 @@ #include "pixbuf-util.h" #define PAN_CAL_POPUP_COLOR 220, 220, 220 -#define PAN_CAL_POPUP_ALPHA 255 -#define PAN_CAL_POPUP_BORDER 1 +enum { + PAN_CAL_POPUP_ALPHA = 255, + PAN_CAL_POPUP_BORDER = 1 +}; #define PAN_CAL_POPUP_BORDER_COLOR 0, 0, 0 #define PAN_CAL_POPUP_TEXT_COLOR 0, 0, 0 -#define PAN_CAL_DAY_WIDTH 100 -#define PAN_CAL_DAY_HEIGHT 80 +enum { + PAN_CAL_DAY_WIDTH = 100, + PAN_CAL_DAY_HEIGHT = 80 +}; #define PAN_CAL_DAY_COLOR 255, 255, 255 -#define PAN_CAL_DAY_ALPHA 220 -#define PAN_CAL_DAY_BORDER 2 +enum { + PAN_CAL_DAY_ALPHA = 220, + PAN_CAL_DAY_BORDER = 2 +}; #define PAN_CAL_DAY_BORDER_COLOR 0, 0, 0 #define PAN_CAL_DAY_TEXT_COLOR 0, 0, 0 #define PAN_CAL_MONTH_COLOR 255, 255, 255 -#define PAN_CAL_MONTH_ALPHA 200 -#define PAN_CAL_MONTH_BORDER 4 +enum { + PAN_CAL_MONTH_ALPHA = 200, + PAN_CAL_MONTH_BORDER = 4 +}; #define PAN_CAL_MONTH_BORDER_COLOR 0, 0, 0 #define PAN_CAL_MONTH_TEXT_COLOR 0, 0, 0 -#define PAN_CAL_DOT_SIZE 3 -#define PAN_CAL_DOT_GAP 2 +enum { + PAN_CAL_DOT_SIZE = 3, + PAN_CAL_DOT_GAP = 2 +}; #define PAN_CAL_DOT_COLOR 128, 128, 128 -#define PAN_CAL_DOT_ALPHA 128 +enum { + PAN_CAL_DOT_ALPHA = 128 +}; #define PAN_CAL_DAY_OF_WEEK_COLOR 128, 128, 128 diff --git a/src/pan-view/pan-view.cc b/src/pan-view/pan-view.cc index 0e2482fe..d067aee2 100644 --- a/src/pan-view/pan-view.cc +++ b/src/pan-view/pan-view.cc @@ -52,13 +52,19 @@ #include -#define PAN_WINDOW_DEFAULT_WIDTH 720 -#define PAN_WINDOW_DEFAULT_HEIGHT 500 +enum { + PAN_WINDOW_DEFAULT_WIDTH = 720, + PAN_WINDOW_DEFAULT_HEIGHT = 500 +}; -#define PAN_TILE_SIZE 512 +enum { + PAN_TILE_SIZE = 512 +}; #define ZOOM_INCREMENT 1.0 -#define ZOOM_LABEL_WIDTH 64 +enum { + ZOOM_LABEL_WIDTH = 64 +}; #define PAN_PREF_GROUP "pan_view_options" diff --git a/src/pixbuf-renderer.cc b/src/pixbuf-renderer.cc index 2e95b987..7e5d58e4 100644 --- a/src/pixbuf-renderer.cc +++ b/src/pixbuf-renderer.cc @@ -58,19 +58,27 @@ enum ExifOrientationType { #define PR_ZOOM_MAX 32.0 /* distance to drag mouse to disable image flip */ -#define PR_DRAG_SCROLL_THRESHHOLD 4 +enum { + PR_DRAG_SCROLL_THRESHHOLD = 4 +}; /* increase pan rate when holding down shift */ -#define PR_PAN_SHIFT_MULTIPLIER 6 +enum { + PR_PAN_SHIFT_MULTIPLIER = 6 +}; /* scroller config */ -#define PR_SCROLLER_UPDATES_PER_SEC 30 -#define PR_SCROLLER_DEAD_ZONE 6 +enum { + PR_SCROLLER_UPDATES_PER_SEC = 30, + PR_SCROLLER_DEAD_ZONE = 6 +}; /* when scaling image to below this size, use nearest pixel for scaling * (below about 4, the other scale types become slow generating their conversion tables) */ -#define PR_MIN_SCALE_SIZE 8 +//~ enum { +//~ PR_MIN_SCALE_SIZE = 8 +//~ }; enum { SIGNAL_ZOOM = 0, @@ -2213,10 +2221,12 @@ static void pr_signals_connect(PixbufRenderer *pr) *------------------------------------------------------------------- */ -#define COLOR_BYTES 3 /* rgb */ -#define RC 0 /* Red-Cyan */ -#define GM 1 /* Green-Magenta */ -#define YB 2 /* Yellow-Blue */ +enum { + COLOR_BYTES = 3, /* rgb */ + RC = 0, /* Red-Cyan */ + GM = 1, /* Green-Magenta */ + YB = 2 /* Yellow-Blue */ +}; static void pr_create_anaglyph_color(GdkPixbuf *pixbuf, GdkPixbuf *right, gint x, gint y, gint w, gint h, guint mode) { diff --git a/src/pixbuf-util.cc b/src/pixbuf-util.cc index c2780e2f..4a140c58 100644 --- a/src/pixbuf-util.cc +++ b/src/pixbuf-util.cc @@ -452,8 +452,10 @@ static void pixbuf_copy_block(guchar *src, gint src_row_stride, gint w, gint h, } } -#define ROTATE_BUFFER_WIDTH 48 -#define ROTATE_BUFFER_HEIGHT 48 +enum { + ROTATE_BUFFER_WIDTH = 48, + ROTATE_BUFFER_HEIGHT = 48 +}; /* * Returns a copy of pixbuf src rotated 90 degrees clockwise or 90 counterclockwise diff --git a/src/preferences.cc b/src/preferences.cc index 6470c6ea..d7225ca2 100644 --- a/src/preferences.cc +++ b/src/preferences.cc @@ -60,8 +60,10 @@ #include #endif -#define EDITOR_NAME_MAX_LENGTH 32 -#define EDITOR_COMMAND_MAX_LENGTH 1024 +enum { + EDITOR_NAME_MAX_LENGTH = 32, + EDITOR_COMMAND_MAX_LENGTH = 1024 +}; static void image_overlay_set_text_colors(); @@ -155,8 +157,10 @@ static GtkWidget *help_search_engine_entry; static GtkWidget *log_window_f1_entry; -#define CONFIG_WINDOW_DEF_WIDTH 700 -#define CONFIG_WINDOW_DEF_HEIGHT 600 +enum { + CONFIG_WINDOW_DEF_WIDTH = 700, + CONFIG_WINDOW_DEF_HEIGHT = 600 +}; /* *----------------------------------------------------------------------------- @@ -2460,7 +2464,9 @@ static void config_tab_windows(GtkWidget *notebook) options->fullscreen.disable_saver, &c_options->fullscreen.disable_saver); } -#define PRE_FORMATTED_COLUMNS 5 +enum { + PRE_FORMATTED_COLUMNS = 5 +}; static void config_tab_osd(GtkWidget *notebook) { GtkWidget *hbox; @@ -2998,7 +3004,9 @@ struct KeywordFindData guint idle_id; /* event source id */ }; -#define KEYWORD_DIALOG_WIDTH 400 +enum { + KEYWORD_DIALOG_WIDTH = 400 +}; static void keywords_find_folder(KeywordFindData *kfd, FileData *dir_fd) { diff --git a/src/print.cc b/src/print.cc index 90739433..33ffa73e 100644 --- a/src/print.cc +++ b/src/print.cc @@ -343,7 +343,9 @@ static void image_text_template_view_changed_cb(GtkWidget *, gpointer data) gtk_text_buffer_get_text(pTextBuffer, &iStart, &iEnd, TRUE)); } -#define PRE_FORMATTED_COLUMNS 4 +enum { + PRE_FORMATTED_COLUMNS = 4 +}; static void print_text_menu(GtkWidget *box, PrintWindow *pw) { GtkWidget *group; diff --git a/src/remote.cc b/src/remote.cc index 451b5be4..e13be4bb 100644 --- a/src/remote.cc +++ b/src/remote.cc @@ -47,9 +47,13 @@ #include "glua.h" -#define SERVER_MAX_CLIENTS 8 +enum { + SERVER_MAX_CLIENTS = 8 +}; -#define REMOTE_SERVER_BACKLOG 4 +enum { + REMOTE_SERVER_BACKLOG = 4 +}; #ifndef UNIX_PATH_MAX diff --git a/src/renderer-tiles.cc b/src/renderer-tiles.cc index 9a3fb814..e92e7c9d 100644 --- a/src/renderer-tiles.cc +++ b/src/renderer-tiles.cc @@ -852,7 +852,9 @@ static GdkPixbuf *rt_get_spare_tile(RendererTiles *rt) return rt->spare_tile; } -#define COLOR_BYTES 3 /* rgb */ +enum { + COLOR_BYTES = 3 /* rgb */ +}; static void rt_tile_rotate_90_clockwise(RendererTiles *rt, GdkPixbuf **tile, gint x, gint y, gint w, gint h) { diff --git a/src/search.cc b/src/search.cc index f35cd431..08400f9a 100644 --- a/src/search.cc +++ b/src/search.cc @@ -50,13 +50,17 @@ #include -#define DEF_SEARCH_WIDTH 700 -#define DEF_SEARCH_HEIGHT 650 +enum { + DEF_SEARCH_WIDTH = 700, + DEF_SEARCH_HEIGHT = 650 +}; -#define SEARCH_BUFFER_MATCH_LOAD 20 -#define SEARCH_BUFFER_MATCH_HIT 5 -#define SEARCH_BUFFER_MATCH_MISS 1 -#define SEARCH_BUFFER_FLUSH_SIZE 99 +enum { + SEARCH_BUFFER_MATCH_LOAD = 20, + SEARCH_BUFFER_MATCH_HIT = 5, + SEARCH_BUFFER_MATCH_MISS = 1, + SEARCH_BUFFER_FLUSH_SIZE = 99 +}; #define FORMAT_CLASS_BROKEN static_cast(FILE_FORMAT_CLASSES + 1) diff --git a/src/thumb-standard.cc b/src/thumb-standard.cc index ef803d48..a78212ec 100644 --- a/src/thumb-standard.cc +++ b/src/thumb-standard.cc @@ -53,8 +53,10 @@ */ -#define THUMB_SIZE_NORMAL 128 -#define THUMB_SIZE_LARGE 256 +enum { + THUMB_SIZE_NORMAL = 128, + THUMB_SIZE_LARGE = 256 +}; #define THUMB_MARKER_URI "tEXt::Thumb::URI" #define THUMB_MARKER_MTIME "tEXt::Thumb::MTime" @@ -63,11 +65,6 @@ #define THUMB_MARKER_HEIGHT "tEXt::Thumb::Image::Height" #define THUMB_MARKER_APP "tEXt::Software" -#define THUMB_PERMS_FOLDER 0700 -#define THUMB_PERMS_THUMB 0600 - - - /* *----------------------------------------------------------------------------- * thumbnail loader @@ -328,7 +325,7 @@ static void thumb_loader_std_save(ThumbLoaderStd *tl, GdkPixbuf *pixbuf) } else { - recursive_mkdir_if_not_exists(base_path, THUMB_PERMS_FOLDER); + recursive_mkdir_if_not_exists(base_path, S_IRWXU); } g_free(base_path); @@ -357,7 +354,7 @@ static void thumb_loader_std_save(ThumbLoaderStd *tl, GdkPixbuf *pixbuf) NULL); if (success) { - chmod(pathl, (tl->cache_local) ? tl->source_mode : THUMB_PERMS_THUMB); + chmod(pathl, (tl->cache_local) ? tl->source_mode : S_IRUSR & S_IWUSR); success = rename_file(tmp_path, tl->thumb_path); } diff --git a/src/ui-bookmark.cc b/src/ui-bookmark.cc index 3bb0f548..1a89354a 100644 --- a/src/ui-bookmark.cc +++ b/src/ui-bookmark.cc @@ -96,13 +96,17 @@ static GtkTargetEntry bookmark_drop_types[] = { { const_cast("x-url/http"), 0, TARGET_X_URL }, { const_cast("_NETSCAPE_URL"), 0, TARGET_X_URL } }; -#define bookmark_drop_types_n 3 +enum { + bookmark_drop_types_n = 3 +}; static GtkTargetEntry bookmark_drag_types[] = { { const_cast("text/uri-list"), 0, TARGET_URI_LIST }, { const_cast("text/plain"), 0, TARGET_TEXT_PLAIN } }; -#define bookmark_drag_types_n 2 +enum { + bookmark_drag_types_n = 2 +}; static GList *bookmark_widget_list = nullptr; diff --git a/src/ui-help.cc b/src/ui-help.cc index 3e9832a7..065264ca 100644 --- a/src/ui-help.cc +++ b/src/ui-help.cc @@ -30,8 +30,10 @@ #include "window.h" -#define HELP_WINDOW_WIDTH 650 -#define HELP_WINDOW_HEIGHT 350 +enum { + HELP_WINDOW_WIDTH = 650, + HELP_WINDOW_HEIGHT = 350 +}; /* diff --git a/src/ui-pathsel.cc b/src/ui-pathsel.cc index 1fdf999c..79dfde4f 100644 --- a/src/ui-pathsel.cc +++ b/src/ui-pathsel.cc @@ -39,10 +39,14 @@ #include "utilops.h" -#define DEST_WIDTH 250 -#define DEST_HEIGHT 210 +enum { + DEST_WIDTH = 250, + DEST_HEIGHT = 210 +}; -#define RENAME_PRESS_DELAY 333 /* 1/3 second, to allow double clicks */ +enum { + RENAME_PRESS_DELAY = 333 /* 1/3 second, to allow double clicks */ +}; #define PATH_SEL_USE_HEADINGS FALSE @@ -319,7 +323,9 @@ static GtkTargetEntry dest_drag_types[] = { { const_cast("text/uri-list"), 0, TARGET_URI_LIST }, { const_cast("text/plain"), 0, TARGET_TEXT_PLAIN } }; -#define dest_drag_types_n 2 +enum { + dest_drag_types_n = 2 +}; static void dest_dnd_set_data(GtkWidget *view, GdkDragContext *, diff --git a/src/ui-tree-edit.cc b/src/ui-tree-edit.cc index 2a53ce6e..2921d0de 100644 --- a/src/ui-tree-edit.cc +++ b/src/ui-tree-edit.cc @@ -519,8 +519,10 @@ void shift_color(GdkRGBA *src, gshort val, gint direction) *------------------------------------------------------------------- */ -#define AUTO_SCROLL_DEFAULT_SPEED 100 -#define AUTO_SCROLL_DEFAULT_REGION 20 +enum { + AUTO_SCROLL_DEFAULT_SPEED = 100, + AUTO_SCROLL_DEFAULT_REGION = 20 +}; struct AutoScrollData { diff --git a/src/utilops.cc b/src/utilops.cc index 63bfb0cc..19a51b6f 100644 --- a/src/utilops.cc +++ b/src/utilops.cc @@ -81,7 +81,9 @@ GdkPixbuf *file_util_get_error_icon(FileData *fd, GList *list, GtkWidget *widget } -#define DIALOG_WIDTH 750 +enum { + DIALOG_WIDTH = 750 +}; enum ClipboardDestination { CLIPBOARD_TEXT_PLAIN = 0, @@ -111,8 +113,10 @@ struct ClipboardData *-------------------------------------------------------------------------- */ -#define DIALOG_DEF_IMAGE_DIM_X 150 -#define DIALOG_DEF_IMAGE_DIM_Y 100 +enum { + DIALOG_DEF_IMAGE_DIM_X = 150, + DIALOG_DEF_IMAGE_DIM_Y = 100 +}; static void generic_dialog_add_image(GenericDialog *gd, GtkWidget *box, FileData *fd1, const gchar *header1, @@ -477,11 +481,15 @@ static void generic_dialog_image_set(UtilityData *ud, FileData *fd) static gboolean file_util_write_metadata_first(UtilityType type, UtilityPhase phase, GList *flist, const gchar *dest_path, const gchar *editor_key, GtkWidget *parent); -#define UTILITY_LIST_MIN_WIDTH 250 -#define UTILITY_LIST_MIN_HEIGHT 150 +enum { + UTILITY_LIST_MIN_WIDTH = 250, + UTILITY_LIST_MIN_HEIGHT = 150 +}; /* thumbnail spec has a max depth of 4 (.thumb??/fail/appname/??.png) */ -#define UTILITY_DELETE_MAX_DEPTH 5 +enum { + UTILITY_DELETE_MAX_DEPTH = 5 +}; static UtilityData *file_util_data_new(UtilityType type) { diff --git a/src/view-file/view-file-icon.cc b/src/view-file/view-file-icon.cc index 8fc272f8..d3767403 100644 --- a/src/view-file/view-file-icon.cc +++ b/src/view-file/view-file-icon.cc @@ -37,14 +37,20 @@ #include "view-file.h" /* between these, the icon width is increased by thumb_max_width / 2 */ -#define THUMB_MIN_ICON_WIDTH 128 -#define THUMB_MAX_ICON_WIDTH 160 +enum { + THUMB_MIN_ICON_WIDTH = 128, + THUMB_MAX_ICON_WIDTH = 160 +}; #define THUMB_MIN_ICON_WIDTH_WITH_MARKS TOGGLE_SPACING * FILEDATA_MARKS_SIZE -#define VFICON_MAX_COLUMNS 32 -#define THUMB_BORDER_PADDING 2 +enum { + VFICON_MAX_COLUMNS = 32, + THUMB_BORDER_PADDING = 2 +}; -#define VFICON_TIP_DELAY 500 +enum { + VFICON_TIP_DELAY = 500 +}; enum { FILE_COLUMN_POINTER = 0, diff --git a/src/view-file/view-file-list.cc b/src/view-file/view-file-list.cc index a65e3dfd..f41a4b3b 100644 --- a/src/view-file/view-file-list.cc +++ b/src/view-file/view-file-list.cc @@ -1936,7 +1936,9 @@ gboolean vflist_refresh(ViewFile *vf) /* this overrides the low default of a GtkCellRenderer from 100 to CELL_HEIGHT_OVERRIDE, something sane for our purposes */ -#define CELL_HEIGHT_OVERRIDE 512 +enum { + CELL_HEIGHT_OVERRIDE = 512 +}; static void cell_renderer_height_override(GtkCellRenderer *renderer) { -- 2.20.1