ajwillia-ms pushed a commit to branch master.

http://git.enlightenment.org/tools/edi.git/commit/?id=d4670583dfdf9f42c8499b7c012b63476a2c9bf4

commit d4670583dfdf9f42c8499b7c012b63476a2c9bf4
Author: Andy Williams <a...@andywilliams.me>
Date:   Sun May 31 12:13:31 2015 +0100

    builds: Add a run button and the launch config to support.
    
    I expect we can support a list of these later so for now
    support passing around the launch config.
---
 ChangeLog                      |  4 +++
 src/bin/edi_config.c           |  2 ++
 src/bin/edi_config.h           | 10 +++++-
 src/bin/edi_main.c             | 57 +++++++++++++++++++++++--------
 src/bin/screens/edi_settings.c | 76 ++++++++++++++++++++++++++++++++++++++++--
 5 files changed, 133 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2bd5d60..84d1e79 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-05-31 ajwillia.ms (Andy Williams)
+
+       * Add launch configuration so we can run a built binary
+
 2015-05-30 ajwillia.ms (Andy Williams)
 
        * Added a monospaced font picker to settings
diff --git a/src/bin/edi_config.c b/src/bin/edi_config.c
index b61b15b..3153640 100644
--- a/src/bin/edi_config.c
+++ b/src/bin/edi_config.c
@@ -251,6 +251,8 @@ _edi_config_init(void)
    EDI_CONFIG_VAL(D, T, gui.toolbar_hidden, EET_T_UCHAR);
 
    EDI_CONFIG_LIST(D, T, tabs, _edi_proj_cfg_tab_edd);
+   EDI_CONFIG_VAL(D, T, launch.path, EET_T_STRING);
+   EDI_CONFIG_VAL(D, T, launch.args, EET_T_STRING);
 
    _edi_config_load();
 
diff --git a/src/bin/edi_config.h b/src/bin/edi_config.h
index 9f6fc69..68d868d 100644
--- a/src/bin/edi_config.h
+++ b/src/bin/edi_config.h
@@ -20,6 +20,7 @@ typedef struct _Edi_Config Edi_Config;
 
 typedef struct _Edi_Project_Config Edi_Project_Config;
 typedef struct _Edi_Project_Config_Tab Edi_Project_Config_Tab;
+typedef struct _Edi_Project_Config_Launch Edi_Project_Config_Launch;
 
 struct _Edi_Config_Project
 {
@@ -49,7 +50,13 @@ struct _Edi_Project_Config_Tab
    Eina_Bool windowed;
 };
 
-struct _Edi_Project_Config 
+struct _Edi_Project_Config_Launch
+{
+   char *path;
+   char *args;
+};
+
+struct _Edi_Project_Config
 {
    int version;
 
@@ -72,6 +79,7 @@ struct _Edi_Project_Config
      } gui;
 
    Eina_List *tabs;
+   Edi_Project_Config_Launch launch;
 };
 
 extern Edi_Config *_edi_config;
diff --git a/src/bin/edi_main.c b/src/bin/edi_main.c
index a22788d..ad09c23 100644
--- a/src/bin/edi_main.c
+++ b/src/bin/edi_main.c
@@ -440,6 +440,37 @@ edi_content_setup(Evas_Object *win, const char *path)
 }
 
 static void
+_edi_popup_cancel_cb(void *data, Evas_Object *obj EINA_UNUSED,
+                     void *event_info EINA_UNUSED)
+{
+   evas_object_del((Evas_Object *)data);
+}
+
+static void
+_edi_launcher_run(Edi_Project_Config_Launch *launch)
+{
+   Evas_Object *popup, *button;
+
+   if (_edi_project_config->launch.path)
+     {
+        ecore_exe_run(launch->path, NULL);
+
+        return;
+     }
+
+   popup = elm_popup_add(_edi_main_win);
+   elm_object_part_text_set(popup, "title,text", "Unable to launch");
+   elm_object_text_set(popup, "No launch binary found, please configure in 
Settings");
+
+   button = elm_button_add(popup);
+   elm_object_text_set(button, "OK");
+   elm_object_part_content_set(popup, "button1", button);
+   evas_object_smart_callback_add(button, "clicked", _edi_popup_cancel_cb, 
popup);
+
+   evas_object_show(popup);
+}
+
+static void
 _tb_new_create_cb(void *data,
                              Evas_Object *obj EINA_UNUSED,
                              void *event_info EINA_UNUSED)
@@ -458,14 +489,6 @@ _tb_new_create_cb(void *data,
 }
 
 static void
-_tb_new_cancel_cb(void *data EINA_UNUSED,
-                                   Evas_Object *obj EINA_UNUSED,
-                                   void *event_info EINA_UNUSED)
-{
-   evas_object_del(_edi_new_popup);
-}
-
-static void
 _edi_file_new()
 {
    Evas_Object *popup, *input, *button;
@@ -483,7 +506,7 @@ _edi_file_new()
    elm_object_text_set(button, "cancel");
    elm_object_part_content_set(popup, "button1", button);
    evas_object_smart_callback_add(button, "clicked",
-                                       _tb_new_cancel_cb, NULL);
+                                       _edi_popup_cancel_cb, _edi_new_popup);
 
    button = elm_button_add(popup);
    elm_object_text_set(button, "create");
@@ -635,14 +658,14 @@ _tb_test_cb(void *data EINA_UNUSED, Evas_Object *obj, 
void *event_info EINA_UNUS
    if (_edi_build_prep(obj, EINA_TRUE))
      edi_builder_test();
 }
-/*
+
 static void
 _tb_run_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info 
EINA_UNUSED)
 {
    if (_edi_build_prep(obj, EINA_FALSE))
-     edi_builder_run();
+     _edi_launcher_run(&_edi_project_config->launch);
 }
-*/
+
 static void
 _tb_clean_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info 
EINA_UNUSED)
 {
@@ -754,6 +777,13 @@ _edi_menu_test_cb(void *data EINA_UNUSED, Evas_Object *obj 
EINA_UNUSED,
 }
 
 static void
+_edi_menu_run_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
+                 void *event_info EINA_UNUSED)
+{
+   _edi_launcher_run(&_edi_project_config->launch);
+}
+
+static void
 _edi_menu_clean_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
                    void *event_info EINA_UNUSED)
 {
@@ -803,6 +833,7 @@ _edi_menu_setup(Evas_Object *win)
    menu_it = elm_menu_item_add(menu, NULL, NULL, "Build", NULL, NULL);
    elm_menu_item_add(menu, menu_it, "system-run", "Build", _edi_menu_build_cb, 
NULL);
    elm_menu_item_add(menu, menu_it, "dialog-ok", "Test", _edi_menu_test_cb, 
NULL);
+   elm_menu_item_add(menu, menu_it, "stock_media-play", "Run", 
_edi_menu_run_cb, NULL);
    elm_menu_item_add(menu, menu_it, "edit-clear", "Clean", _edi_menu_clean_cb, 
NULL);
 
    menu_it = elm_menu_item_add(menu, NULL, NULL, "Help", NULL, NULL);
@@ -856,7 +887,7 @@ edi_toolbar_setup(Evas_Object *win)
 
    tb_it = elm_toolbar_item_append(tb, "system-run", "Build", _tb_build_cb, 
NULL);
    tb_it = elm_toolbar_item_append(tb, "dialog-ok", "Test", _tb_test_cb, NULL);
-//   tb_it = elm_toolbar_item_append(tb, "player-play", "Run", _tb_run_cb, 
NULL);
+   tb_it = elm_toolbar_item_append(tb, "stock_media-play", "Run", _tb_run_cb, 
NULL);
    tb_it = elm_toolbar_item_append(tb, "edit-clear", "Clean", _tb_clean_cb, 
NULL);
 
    elm_box_pack_end(box, tb);
diff --git a/src/bin/screens/edi_settings.c b/src/bin/screens/edi_settings.c
index 0e10587..7a94a63 100644
--- a/src/bin/screens/edi_settings.c
+++ b/src/bin/screens/edi_settings.c
@@ -11,7 +11,8 @@
 
 #include "edi_private.h"
 
-static Elm_Object_Item *_edi_settings_display, *_edi_settings_behaviour;
+static Elm_Object_Item *_edi_settings_display, *_edi_settings_builds,
+                       *_edi_settings_behaviour;
 
 static void
 _edi_settings_exit(void *data, Evas_Object *obj EINA_UNUSED, void *event_info 
EINA_UNUSED)
@@ -207,7 +208,7 @@ _edi_settings_display_create(Evas_Object *parent)
 
    label = elm_label_add(hbox);
    elm_object_text_set(label, "Tabstop");
-   evas_object_size_hint_align_set(label, EVAS_HINT_EXPAND, 0.5);
+   evas_object_size_hint_align_set(label, 0.0D, 0.5);
    elm_box_pack_end(hbox, label);
    evas_object_show(label);
 
@@ -238,6 +239,72 @@ _edi_settings_display_create(Evas_Object *parent)
 }
 
 static void
+_edi_settings_builds_binary_chosen_cb(void *data, Evas_Object *obj EINA_UNUSED,
+                                      void *event_info)
+{
+   Evas_Object *label = data;
+   const char *file = event_info;
+
+   if (!file)
+     return;
+
+   if (_edi_project_config->launch.path)
+     eina_stringshare_del(_edi_project_config->launch.path);
+
+   elm_object_text_set(label, file);
+   _edi_project_config->launch.path = eina_stringshare_add(file);
+   _edi_project_config_save();
+}
+
+static Evas_Object *
+_edi_settings_builds_create(Evas_Object *parent)
+{
+   Evas_Object *box, *frame, *hbox, *label, *ic, *selector, *file;
+
+   frame = _edi_settings_panel_create(parent, "Builds");
+   box = elm_object_part_content_get(frame, "default");
+
+   hbox = elm_box_add(parent);
+   elm_box_horizontal_set(hbox, EINA_TRUE);
+   evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, 0.0);
+   evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   elm_box_pack_end(box, hbox);
+   evas_object_show(hbox);
+
+   label = elm_label_add(hbox);
+   elm_object_text_set(label, "Runtime binary");
+   evas_object_size_hint_weight_set(label, 0.0, 0.0);
+   evas_object_size_hint_align_set(label, 0.0, EVAS_HINT_FILL);
+   elm_box_pack_end(hbox, label);
+   evas_object_show(label);
+
+   ic = elm_icon_add(hbox);
+   elm_icon_standard_set(ic, "file");
+   evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
+
+   selector = elm_fileselector_button_add(box);
+   elm_object_text_set(selector, "Select");
+   elm_object_part_content_set(selector, "icon", ic);
+   elm_fileselector_path_set(selector, edi_project_get());
+   evas_object_size_hint_weight_set(selector, 0.25, 0.0);
+   evas_object_size_hint_align_set(selector, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   elm_box_pack_end(hbox, selector);
+   evas_object_show(selector);
+
+   file = elm_label_add(hbox);
+   elm_object_text_set(file, _edi_project_config->launch.path);
+   evas_object_size_hint_weight_set(file, 0.75, 0.0);
+   evas_object_size_hint_align_set(file, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   elm_box_pack_end(hbox, file);
+   evas_object_show(file);
+
+   evas_object_smart_callback_add(selector, "file,chosen",
+                                  _edi_settings_builds_binary_chosen_cb, file);
+
+   return frame;
+}
+
+static void
 _edi_settings_behaviour_autosave_cb(void *data EINA_UNUSED, Evas_Object *obj,
                                     void *event EINA_UNUSED)
 {
@@ -313,6 +380,9 @@ edi_settings_show(Evas_Object *mainwin)
    _edi_settings_display = elm_naviframe_item_push(naviframe, "", NULL, NULL,
                                                    
_edi_settings_display_create(naviframe), NULL);
    elm_naviframe_item_title_enabled_set(_edi_settings_display, EINA_FALSE, 
EINA_FALSE);
+   _edi_settings_builds = elm_naviframe_item_push(naviframe, "", NULL, NULL,
+                                                   
_edi_settings_builds_create(naviframe), NULL);
+   elm_naviframe_item_title_enabled_set(_edi_settings_builds, EINA_FALSE, 
EINA_FALSE);
    _edi_settings_behaviour = elm_naviframe_item_push(naviframe, "", NULL, NULL,
                                                    
_edi_settings_behaviour_create(naviframe), NULL);
    elm_naviframe_item_title_enabled_set(_edi_settings_behaviour, EINA_FALSE, 
EINA_FALSE);
@@ -320,6 +390,8 @@ edi_settings_show(Evas_Object *mainwin)
    elm_toolbar_item_append(tb, NULL, "Project", NULL, NULL);
    default_it = elm_toolbar_item_append(tb, "preferences-desktop", "Display",
                                         _edi_settings_category_cb, 
_edi_settings_display);
+   elm_toolbar_item_append(tb, "system-run", "Builds",
+                           _edi_settings_category_cb, _edi_settings_builds);
 
    tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL);
    elm_toolbar_item_separator_set(tb_it, EINA_TRUE);

-- 


Reply via email to