raster pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=f32ac2d1a9f083abeb520576fcce8248cb164954

commit f32ac2d1a9f083abeb520576fcce8248cb164954
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date:   Sat Jan 4 16:06:17 2020 +0000

    shot always save shots to your users new shots dir and show dir on save
    
    when you select save from shot now it always saves to your user shots
    dir (~/.e/e/shots) and then opens up this fir for you to browse/see/dnd
    out of etc. etc. for easier quick and fast access to what you just
    saved. also you keep a history of your shots (you do get to clean it up
    yourself when you save... no auto-cleaning - i decided not to bother
    as realistically it's just more config to swizzle and mystery deletion
    of files that some user has to figure out how and why it happens and
    where to go change the config - just delete the ones you don't want
    anymore - simple and easy.)
---
 TODO                                |   2 -
 src/modules/shot/data/meson.build   |   3 +-
 src/modules/shot/data/shots.desktop |   8 +++
 src/modules/shot/e_mod_main.c       |   3 +-
 src/modules/shot/e_mod_main.h       |   4 +-
 src/modules/shot/e_mod_preview.c    |   2 +-
 src/modules/shot/e_mod_save.c       | 111 ++++++++++--------------------------
 7 files changed, 42 insertions(+), 91 deletions(-)

diff --git a/TODO b/TODO
index 980333257..c0f2ef16a 100644
--- a/TODO
+++ b/TODO
@@ -151,8 +151,6 @@ TODO:
   * provide fuller status per line (reception and other info?)
   * massively flesh out connman vpn support in the gui
     * vpnmanager + create method support
-* shot: create special save dir for shots (~/.e/...) and keep last N
-* shot: use efm and offer save dir to dnd from
 * bz5: add icon set for actions/states per bt device (pair.unpair, etc.)
 * bz5: add obex agent support integrated with efm for sharing via bt
   and downloads when received via obex bt (~/Downloads/...)
diff --git a/src/modules/shot/data/meson.build 
b/src/modules/shot/data/meson.build
index 6f3133429..ab79433b6 100644
--- a/src/modules/shot/data/meson.build
+++ b/src/modules/shot/data/meson.build
@@ -15,5 +15,6 @@ out = join_paths(_dir, edc + '.edj')
 install_data(['BD_Cartoon_Shout.ttf',
               'ComiquitaSans.ttf',
               'FuturaHandwritten.ttf',
-              'Suplexmentary_Comic_NC.ttf'],
+              'Suplexmentary_Comic_NC.ttf',
+              'shots.desktop'],
              install_dir: _dir)
diff --git a/src/modules/shot/data/shots.desktop 
b/src/modules/shot/data/shots.desktop
new file mode 100644
index 000000000..0cfd7305e
--- /dev/null
+++ b/src/modules/shot/data/shots.desktop
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Name=Screenshots
+Comment=My saved screenshots
+Type=Link
+X-Enlightenment-Type=Mount
+URL=file:$E_HOME_DIR/shots
+Icon=user-bookmarks
+NotShowIn=GNOME;KDE;LXDE;ROX;XFCE;
diff --git a/src/modules/shot/e_mod_main.c b/src/modules/shot/e_mod_main.c
index 321bf497d..16bdbaf9b 100644
--- a/src/modules/shot/e_mod_main.c
+++ b/src/modules/shot/e_mod_main.c
@@ -86,7 +86,7 @@ static void
 _shot_now(E_Zone *zone, E_Client *ec, const char *params)
 {
    int x, y, w, h;
-   if (preview_have() || save_have() || share_have() || (snap)) return;
+   if (preview_have() || share_have() || (snap)) return;
    if ((!zone) && (!ec)) return;
    if (zone)
      {
@@ -377,7 +377,6 @@ E_API int
 e_modapi_shutdown(E_Module *m EINA_UNUSED)
 {
    share_abort();
-   save_abort();
    preview_abort();
    delay_abort();
    if (delfn_client)
diff --git a/src/modules/shot/e_mod_main.h b/src/modules/shot/e_mod_main.h
index 9158c6e60..279208f61 100644
--- a/src/modules/shot/e_mod_main.h
+++ b/src/modules/shot/e_mod_main.h
@@ -23,9 +23,7 @@ Eina_Bool    preview_have            (void);
 void         preview_abort           (void);
 Evas_Object *preview_image_get       (void);
 void         save_to                 (const char *file);
-void         save_dialog_show        (void);
-Eina_Bool    save_have               (void);
-void         save_abort              (void);
+void         save_show               (void);
 
 Evas_Object *ui_edit(Evas_Object *window, Evas_Object *o_bg, E_Zone *zone,
                      E_Client *ec, void *dst, int sx, int sy, int sw, int sh,
diff --git a/src/modules/shot/e_mod_preview.c b/src/modules/shot/e_mod_preview.c
index 37b65d32e..2240a85f0 100644
--- a/src/modules/shot/e_mod_preview.c
+++ b/src/modules/shot/e_mod_preview.c
@@ -9,7 +9,7 @@ Eina_Rectangle crop = { 0, 0, 0, 0 };
 static void
 _win_save_cb(void *data EINA_UNUSED, void *data2 EINA_UNUSED)
 {
-   save_dialog_show();
+   save_show();
 }
 
 static void
diff --git a/src/modules/shot/e_mod_save.c b/src/modules/shot/e_mod_save.c
index 11d4e47e4..cf9f6c925 100644
--- a/src/modules/shot/e_mod_save.c
+++ b/src/modules/shot/e_mod_save.c
@@ -1,11 +1,5 @@
 #include "e_mod_main.h"
 
-static Evas_Object *o_fsel = NULL;
-static E_Dialog    *fsel_dia = NULL;
-
-static void _file_select_ok_cb(void *data EINA_UNUSED, E_Dialog *dia);
-static void _file_select_cancel_cb(void *data EINA_UNUSED, E_Dialog *dia);
-
 typedef struct
 {
    char *path, *outfile;
@@ -174,91 +168,44 @@ save_to(const char *file)
    return;
 }
 
-static void
-_file_select_ok_cb(void *data EINA_UNUSED, E_Dialog *dia)
-{
-   const char *file;
-
-   dia = fsel_dia;
-   file = e_widget_fsel_selection_path_get(o_fsel);
-   if ((!file) || (!file[0]) ||
-       ((!eina_str_has_extension(file, ".jpg")) &&
-        (!eina_str_has_extension(file, ".png"))))
-     {
-        e_util_dialog_show
-        (_("Error - Unknown format"),
-            _("File has an unspecified extension.<ps/>"
-              "Please use '.jpg' or '.png' extensions<ps/>"
-              "only as other formats are not<ps/>"
-              "supported currently."));
-        return;
-     }
-   save_to(file);
-   if (dia) e_util_defer_object_del(E_OBJECT(dia));
-   preview_abort();
-   fsel_dia = NULL;
-}
-
-static void
-_file_select_cancel_cb(void *data EINA_UNUSED, E_Dialog *dia)
-{
-   if (dia) e_util_defer_object_del(E_OBJECT(dia));
-   preview_abort();
-   fsel_dia = NULL;
-}
-
-static void
-_file_select_del_cb(void *d EINA_UNUSED)
-{
-   preview_abort();
-   fsel_dia = NULL;
-}
-
 void
-save_dialog_show(void)
+save_show(void)
 {
-   E_Dialog *dia;
-   Evas_Object *o;
-   Evas_Coord mw, mh;
+   char path[PATH_MAX + 512];
+   char path2[PATH_MAX + 512];
+   char buf[256];
+   const char *dirs[] = { "shots", NULL };
    time_t tt;
    struct tm *tm;
-   char buf[PATH_MAX];
+   E_Action *a;
 
+   ecore_file_mksubdirs(e_user_dir_get(), dirs);
    time(&tt);
    tm = localtime(&tt);
    if (quality == 100)
      strftime(buf, sizeof(buf), "shot-%Y-%m-%d_%H-%M-%S.png", tm);
    else
      strftime(buf, sizeof(buf), "shot-%Y-%m-%d_%H-%M-%S.jpg", tm);
-   fsel_dia = dia = e_dialog_new(NULL, "E", "_e_shot_fsel");
-   e_dialog_resizable_set(dia, EINA_TRUE);
-   e_dialog_title_set(dia, _("Select screenshot save location"));
-   o = e_widget_fsel_add(evas_object_evas_get(dia->win), "desktop", "/", 
-                         buf, NULL, NULL, NULL, NULL, NULL, 1);
-   e_object_del_attach_func_set(E_OBJECT(dia), _file_select_del_cb);
-   e_widget_fsel_window_set(o, dia->win);
-   o_fsel = o;
-   evas_object_show(o);
-   e_widget_size_min_get(o, &mw, &mh);
-   e_dialog_content_set(dia, o, mw, mh);
-   e_dialog_button_add(dia, _("Save"), NULL,
-                       _file_select_ok_cb, NULL);
-   e_dialog_button_add(dia, _("Cancel"), NULL,
-                       _file_select_cancel_cb, NULL);
-   elm_win_center(dia->win, 1, 1);
-   o = evas_object_rectangle_add(evas_object_evas_get(dia->win));
-   e_dialog_show(dia);
-}
-
-Eina_Bool
-save_have(void)
-{
-   if (fsel_dia) return EINA_TRUE;
-   return EINA_FALSE;
-}
-
-void
-save_abort(void)
-{
-   E_FREE_FUNC(fsel_dia, e_object_del);
+   e_user_dir_snprintf(path, sizeof(path), "shots/%s", buf);
+   save_to(path);
+   snprintf(path, sizeof(path), "%s/shots.desktop",
+            e_module_dir_get(shot_module));
+   snprintf(path2, sizeof(path2), "%s/fileman/favorites/shots.desktop",
+            e_user_dir_get());
+   if (!ecore_file_exists(path2))
+     {
+        printf("CP [%s]->[%s]\n", path, path2);
+        ecore_file_cp(path, path2);
+     }
+   a = e_action_find("fileman");
+   if (a)
+     {
+        a->func.go(NULL, "$E_HOME_DIR/shots");
+     }
+   else
+     e_util_dialog_show
+       (_("Error - No Filemanager"),
+        _("No filemanager action and/or module was found.<br>"
+          "Cannot show the location of your screenshots."));
+   preview_abort();
 }

-- 


Reply via email to