clang-tidy: modernize-macro-to-enum
[geeqie.git] / src / dupe.cc
index 7da7d98..c67fca8 100644 (file)
 #include <cmath>
 
 
-#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)
@@ -341,7 +343,7 @@ static void dupe_window_update_progress(DupeWindow *dw, const gchar *status, gdo
                                d = dw->setup_count - dw->setup_n;
                                }
 
-                       rem = (t - d) ? (static_cast<gdouble>(dw->setup_time_count / 1000000) / (t - d)) * d : 0;
+                       rem = (t - d) ? (static_cast<gdouble>(dw->setup_time_count / 1000000.0) / (t - d)) * d : 0;
 
                        gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(dw->extra_label), value);
 
@@ -351,7 +353,8 @@ static void dupe_window_update_progress(DupeWindow *dw, const gchar *status, gdo
 
                        return;
                        }
-               else if (force ||
+
+               if (force ||
                         value == 0.0 ||
                         dw->setup_count == 0 ||
                         dw->setup_time_count == 0 ||
@@ -474,7 +477,7 @@ static DupeItem *dupe_item_find_fd_by_list_unused(FileData *fd, GList *work)
 {
        while (work)
                {
-               DupeItem *di = static_cast<DupeItem *>(work->data);
+               auto *di = static_cast<DupeItem *>(work->data);
 
                if (di->fd == fd) return di;
 
@@ -498,7 +501,7 @@ static DupeItem *dupe_item_find_path_by_list_unused(const gchar *path, GList *wo
 {
        while (work)
                {
-               DupeItem *di = static_cast<DupeItem *>(work->data);
+               auto *di = static_cast<DupeItem *>(work->data);
 
                if (strcmp(di->fd->path, path) == 0) return di;
 
@@ -1509,15 +1512,10 @@ static gboolean dupe_match(DupeItem *a, DupeItem *b, DupeMatchType mask, gdouble
                                {
                                return TRUE;
                                }
-                       else
-                               {
-                               return FALSE;
-                               }
-                       }
-               else
-                       {
+
                        return FALSE;
                        }
+               return FALSE;
                }
        if (mask & DUPE_MATCH_NAME_CI_CONTENT)
                {
@@ -1531,15 +1529,11 @@ static gboolean dupe_match(DupeItem *a, DupeItem *b, DupeMatchType mask, gdouble
                                {
                                return TRUE;
                                }
-                       else
-                               {
-                               return FALSE;
-                               }
-                       }
-               else
-                       {
+
                        return FALSE;
                        }
+               return FALSE;
+               
                }
        if (mask & DUPE_MATCH_SIZE)
                {
@@ -1817,10 +1811,8 @@ static gint dupe_match_sort_cb(gconstpointer a, gconstpointer b, gpointer data)
                    {
                        return -1;
                        }
-               else
-                       {
-                       return strcmp(di1->md5sum, di2->md5sum);
-                       }
+
+               return strcmp(di1->md5sum, di2->md5sum);
                }
        if (mask & DUPE_MATCH_DIM)
                {
@@ -2813,14 +2805,12 @@ static gboolean dupe_files_add_queue_cb(gpointer data)
                {
                return TRUE;
                }
-       else
-               {
-               dw->add_files_queue_id = 0;
-               dupe_destroy_list_cache(dw);
-               g_idle_add(dupe_check_start_cb, dw);
-               gtk_widget_set_sensitive(dw->controls_box, TRUE);
-               return FALSE;
-               }
+
+       dw->add_files_queue_id = 0;
+       dupe_destroy_list_cache(dw);
+       g_idle_add(dupe_check_start_cb, dw);
+       gtk_widget_set_sensitive(dw->controls_box, TRUE);
+       return FALSE;
 }
 
 static void dupe_files_add(DupeWindow *dw, CollectionData *, CollectInfo *info,
@@ -2881,10 +2871,8 @@ static void dupe_files_add(DupeWindow *dw, CollectionData *, CollectInfo *info,
                        {
                        return;
                        }
-               else
-                       {
-                       work = work->next;
-                       }
+
+               work = work->next;
                }
 
        if (dw->second_list)
@@ -2897,10 +2885,8 @@ static void dupe_files_add(DupeWindow *dw, CollectionData *, CollectInfo *info,
                                {
                                return;
                                }
-                       else
-                               {
-                               work = work->next;
-                               }
+
+                       work = work->next;
                        }
                }
 
@@ -3983,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)
 {