From 8dfa393e051d0781d487b8bbeb0933a319f3135c Mon Sep 17 00:00:00 2001
From: twinaphex <libretro@gmail.com>
Date: Sun, 31 Jul 2016 01:20:00 +0200
Subject: [PATCH] Add screenshot to image history list too

---
 tasks/task_content.c    |  7 ++++---
 tasks/task_screenshot.c | 18 ++++++++++++++++--
 tasks/tasks_internal.h  |  6 ++++++
 3 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/tasks/task_content.c b/tasks/task_content.c
index a5ff9006da..d50ea3910e 100644
--- a/tasks/task_content.c
+++ b/tasks/task_content.c
@@ -793,13 +793,14 @@ static void check_default_dirs(void)
       check_defaults_dir_create_dir(g_defaults.dir.thumbnails);
 }
 
-static bool content_push_to_history_playlist(
-      playlist_t *playlist,
+bool content_push_to_history_playlist(
+      void *data,
       const char *path,
       const char *core_name,
       const char *core_path)
 {
-   settings_t *settings             = config_get_ptr();
+   playlist_t *playlist   = (playlist_t*)data;
+   settings_t *settings   = config_get_ptr();
 
    /* If the history list is not enabled, early return. */
    if (!settings->history_list_enable)
diff --git a/tasks/task_screenshot.c b/tasks/task_screenshot.c
index 527952f8c7..25504c905f 100644
--- a/tasks/task_screenshot.c
+++ b/tasks/task_screenshot.c
@@ -44,16 +44,20 @@
 #define IMG_EXT "bmp"
 #endif
 
+#include "../defaults.h"
 #include "../general.h"
 #include "../msg_hash.h"
 
 #include "../gfx/video_driver.h"
 #include "../gfx/video_frame.h"
 
+
 #ifdef HAVE_CONFIG_H
 #include "../config.h"
 #endif
 
+#include "tasks_internal.h"
+
 /* Take frame bottom-up. */
 static bool screenshot_dump(
       const char *global_name_base,
@@ -130,6 +134,13 @@ static bool screenshot_dump(
          bmp_type);
 #endif
 
+   if (ret == true)
+   {
+      if (content_push_to_history_playlist(g_defaults.image_history, filename,  
+               "imageviewer", "builtin"))
+         playlist_write_file(g_defaults.image_history);
+   }
+
    return ret;
 }
 
@@ -197,9 +208,12 @@ static bool take_screenshot_raw(const char *global_name_base)
    /* Negative pitch is needed as screenshot takes bottom-up,
     * but we use top-down.
     */
-   return screenshot_dump(global_name_base, screenshot_dir,
+   if (!screenshot_dump(global_name_base, screenshot_dir,
          (const uint8_t*)data + (height - 1) * pitch,
-         width, height, -pitch, false);
+         width, height, -pitch, false))
+      return false;
+
+   return true;
 }
 
 static bool take_screenshot_choice(const char *global_name_base)
diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h
index fa9266ca56..d264355f62 100644
--- a/tasks/tasks_internal.h
+++ b/tasks/tasks_internal.h
@@ -137,6 +137,12 @@ void task_image_load_free(retro_task_t *task);
 
 void task_file_load_handler(retro_task_t *task);
 
+bool content_push_to_history_playlist(
+      void *data,
+      const char *path,
+      const char *core_name,
+      const char *core_path);
+
 /* TODO/FIXME - turn this into actual task */
 bool take_screenshot(void);
 bool dump_to_file_desperate(const void *data,