Remove redundant GdkRGBA memcpy
[geeqie.git] / src / image-overlay.cc
index 3892b75..7dfd5a7 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "main.h"
 #include "image-overlay.h"
 
+#include <config.h>
+
+#include "collect.h"
+#include "debug.h"
 #include "filedata.h"
 #include "histogram.h"
+#include "image-load.h"
 #include "image.h"
 #include "img-view.h"
+#include "intl.h"
 #include "layout.h"
+#include "main-defines.h"
 #include "osd.h"
 #include "pixbuf-renderer.h"
 #include "pixbuf-util.h"
+#include "slideshow.h"
 #include "ui-fileops.h"
-#include "image-load.h"
 
 /*
  *----------------------------------------------------------------------------
@@ -40,8 +46,7 @@
  */
 
 
-typedef struct _OverlayStateData OverlayStateData;
-struct _OverlayStateData {
+struct OverlayStateData {
        ImageWindow *imd;
        ImageState changed_states;
        NotifyType notify;
@@ -65,8 +70,7 @@ struct _OverlayStateData {
 };
 
 
-typedef struct _OSDIcon OSDIcon;
-struct _OSDIcon {
+struct OSDIcon {
        gboolean reset; /* reset on new image */
        gint x;         /* x, y offset */
        gint y;
@@ -86,10 +90,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);
 
@@ -210,23 +218,22 @@ void image_osd_toggle(ImageWindow *imd)
                image_osd_set(imd, static_cast<OsdShowFlags>(OSD_SHOW_INFO | OSD_SHOW_STATUS));
                return;
                }
+
+       if (show & OSD_SHOW_HISTOGRAM)
+               {
+               image_osd_set(imd, OSD_SHOW_NOTHING);
+               }
        else
                {
-               if (show & OSD_SHOW_HISTOGRAM)
-                       {
-                       image_osd_set(imd, OSD_SHOW_NOTHING);
-                       }
-               else
-                       {
-                       image_osd_set(imd, static_cast<OsdShowFlags>(show | OSD_SHOW_HISTOGRAM));
-                       }
+               image_osd_set(imd, static_cast<OsdShowFlags>(show | OSD_SHOW_HISTOGRAM));
                }
 }
 
 static GdkPixbuf *image_osd_info_render(OverlayStateData *osd)
 {
        GdkPixbuf *pixbuf = nullptr;
-       gint width, height;
+       gint width;
+       gint height;
        PangoLayout *layout;
        const gchar *name;
        gchar *text;
@@ -241,7 +248,8 @@ static GdkPixbuf *image_osd_info_render(OverlayStateData *osd)
        name = image_get_name(imd);
        if (name)
                {
-               gint n, t;
+               gint n;
+               gint t;
                CollectionData *cd;
                CollectInfo *info;
                GHashTable *vars;
@@ -308,7 +316,8 @@ static GdkPixbuf *image_osd_info_render(OverlayStateData *osd)
 
                if (!imd->unknown)
                        {
-                       gint w, h;
+                       gint w;
+                       gint h;
                        GdkPixbuf *load_pixbuf = image_loader_get_pixbuf(imd->il);
 
                        if (imd->delay_flip &&
@@ -367,20 +376,20 @@ static GdkPixbuf *image_osd_info_render(OverlayStateData *osd)
 
                if (active_marks > 0)
                        {
-                       GString *buf = g_string_sized_new(FILEDATA_MARKS_SIZE * 2);
+                       GString *buf = g_string_sized_new(strlen(text) + 1 + FILEDATA_MARKS_SIZE * 2);
+
+                       if (*text)
+                               {
+                               g_string_append_printf(buf, "%s\n", text);
+                               }
 
                        for (mark = 0; mark < FILEDATA_MARKS_SIZE; mark++)
                                {
                                g_string_append_printf(buf, file_data_get_mark(fd, mark) ? " <span background='#FF00FF'>%c</span>" : " %c", '1' + (mark < 9 ? mark : -1) );
                                }
 
-                       if (*text)
-                               text2 = g_strdup_printf("%s\n%s", text, buf->str);
-                       else
-                               text2 = g_strdup(buf->str);
-                       g_string_free(buf, TRUE);
                        g_free(text);
-                       text = text2;
+                       text = g_string_free(buf, FALSE);
                        }
 
                if (with_hist)
@@ -449,6 +458,23 @@ static GdkPixbuf *image_osd_info_render(OverlayStateData *osd)
        return pixbuf;
 }
 
+/**
+ * @brief Create non-standard icons for the OSD
+ * @param flag
+ * @returns
+ *
+ * IMAGE_OSD_COLOR
+ * \image html image-osd-color.png
+ * IMAGE_OSD_FIRST
+ * \image html image-osd-first.png
+ * IMAGE_OSD_ICON
+ * \image html image-osd-icon.png
+ * IMAGE_OSD_LAST
+ * \image html image-osd-last.png
+ * IMAGE_OSD_ROTATE_AUTO
+ * \image html image-osd-rotate-auto.png
+ *
+ */
 static GdkPixbuf *image_osd_icon_pixbuf(ImageOSDFlag flag)
 {
        static GdkPixbuf **icons = nullptr;
@@ -740,7 +766,7 @@ static void image_osd_timer_schedule(OverlayStateData *osd)
                }
 }
 
-static void image_osd_state_cb(ImageWindow *UNUSED(imd), ImageState state, gpointer data)
+static void image_osd_state_cb(ImageWindow *, ImageState state, gpointer data)
 {
        auto osd = static_cast<OverlayStateData *>(data);
 
@@ -786,7 +812,7 @@ static void image_osd_free(OverlayStateData *osd)
        g_free(osd);
 }
 
-static void image_osd_destroy_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void image_osd_destroy_cb(GtkWidget *, gpointer data)
 {
        auto osd = static_cast<OverlayStateData *>(data);
 
@@ -849,7 +875,8 @@ Histogram *image_osd_get_histogram(ImageWindow *imd)
 
 void image_osd_copy_status(ImageWindow *src, ImageWindow *dest)
 {
-       Histogram *h_src, *h_dest;
+       Histogram *h_src;
+       Histogram *h_dest;
        image_osd_set(dest, image_osd_get(src));
 
        h_src = image_osd_get_histogram(src);