rimmed pushed a commit to branch eflete-1.18.

http://git.enlightenment.org/tools/eflete.git/commit/?id=d133cf89815276bf1cd354231f17465463519fba

commit d133cf89815276bf1cd354231f17465463519fba
Author: Andrii Kroitor <an.kroi...@samsung.com>
Date:   Fri Sep 2 15:04:12 2016 +0300

    main_window: use async popup on project close
---
 src/bin/eflete.h           |  4 ++++
 src/bin/ui/main_window.c   |  1 +
 src/bin/ui/project_close.c | 52 +++++++++++++++++++++++++++++++---------------
 3 files changed, 40 insertions(+), 17 deletions(-)

diff --git a/src/bin/eflete.h b/src/bin/eflete.h
index 6ada2be..bcf38ba 100644
--- a/src/bin/eflete.h
+++ b/src/bin/eflete.h
@@ -143,6 +143,10 @@ struct _App_Data
    } path;
    Project *project;
    Shortcut_Module *shortcuts; /**< Structure with data from shortcuts module 
*/
+   Eina_Bool exit_in_progress : 1; /**< is set to true when 
ui_main_window_del() is called.
+                                       This is needed to continue closing 
application after
+                                       clicking in save/don't save buttons in 
project close
+                                       popup */
 #ifdef HAVE_ENVENTOR
    Evas_Object *enventor;
    Eina_Bool enventor_mode : 1;
diff --git a/src/bin/ui/main_window.c b/src/bin/ui/main_window.c
index ac9ecab..c96c090 100644
--- a/src/bin/ui/main_window.c
+++ b/src/bin/ui/main_window.c
@@ -57,6 +57,7 @@ _help(void *data __UNUSED__,
 Eina_Bool
 ui_main_window_del(void)
 {
+   ap.exit_in_progress = true;
    if (ap.project)
      if (!project_close())
        return false;
diff --git a/src/bin/ui/project_close.c b/src/bin/ui/project_close.c
index bf3ce32..ef95cd8 100644
--- a/src/bin/ui/project_close.c
+++ b/src/bin/ui/project_close.c
@@ -140,11 +140,38 @@ project_save(void)
      ui_menu_disable_set(ap.menu, MENU_FILE_SAVE, true);
 }
 
+static void
+_popup_close_cb(void *data __UNUSED__,
+                Evas_Object *obj __UNUSED__,
+                void *ei)
+{
+   Popup_Button btn_res = (Popup_Button) ei;
+
+   switch (btn_res)
+     {
+      case BTN_OK:
+         project_save();
+         break;
+      case BTN_DONT_SAVE:
+         ap.project->changed = false;
+         break;
+      case BTN_CANCEL:
+         ap.exit_in_progress = false;
+         return;
+      default:
+         ERR("Popup return wrong value. Go fix it!");
+         abort(); /* it's wrong value need to fix popup code or popup call */
+     }
+   if (ap.exit_in_progress)
+     ui_main_window_del();
+   else
+     project_close();
+}
 
 Eina_Bool
 project_close(void)
 {
-   Popup_Button btn_res;
+   Evas_Object *popup;
    Eina_Stringshare *title;
 
    assert(ap.project != NULL);
@@ -152,23 +179,14 @@ project_close(void)
    if (ap.project->changed)
      {
         title = eina_stringshare_printf(_("Close project %s"), 
ap.project->name);
-        btn_res = popup_want_action(title, _("Do you want to save changes?"), 
NULL,
-                                    BTN_OK|BTN_DONT_SAVE|BTN_CANCEL,
-                                    NULL, NULL);
-        switch (btn_res)
-          {
-           case BTN_OK:
-              project_save();
-              break;
-           case BTN_DONT_SAVE:
-              break;
-           case BTN_CANCEL:
-              return false;
-           default:
-              ERR("Popup return wrong value. Go to fix it!");
-              abort(); /* it's wrong value need to fix popup code or popup 
call */
-          }
+        popup = popup_add(title,
+                          _("Do you want to save changes?"),
+                          BTN_OK|BTN_DONT_SAVE|BTN_CANCEL,
+                          NULL,
+                          NULL);
+        evas_object_smart_callback_add(popup, POPUP_CLOSE_CB, _popup_close_cb, 
NULL);
         eina_stringshare_del(title);
+        return false;
      }
 
    ui_menu_items_list_disable_set(ap.menu, MENU_ITEMS_LIST_BASE, true);

-- 


Reply via email to