ajwillia-ms pushed a commit to branch master.

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

commit bd55404b42723ba267d1b02f0715d19a1003622d
Author: Andy Williams <a...@andywilliams.me>
Date:   Mon May 18 23:17:24 2015 +0100

    Allow hiding of the toolbar
---
 src/bin/edi_config.c           |  2 ++
 src/bin/edi_config.h           |  2 ++
 src/bin/edi_main.c             | 29 ++++++++++++++++++++++++++---
 src/bin/screens/edi_settings.c | 23 ++++++++++++++++++++++-
 4 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/src/bin/edi_config.c b/src/bin/edi_config.c
index 319b00e..4d7cd6d 100644
--- a/src/bin/edi_config.c
+++ b/src/bin/edi_config.c
@@ -244,6 +244,7 @@ _edi_config_init(void)
    EDI_CONFIG_VAL(D, T, gui.show_whitespace, EET_T_UCHAR);
    EDI_CONFIG_VAL(D, T, gui.width_marker, EET_T_UINT);
    EDI_CONFIG_VAL(D, T, gui.tabstop, EET_T_UINT);
+   EDI_CONFIG_VAL(D, T, gui.toolbar_hidden, EET_T_UCHAR);
 
    EDI_CONFIG_LIST(D, T, tabs, _edi_proj_cfg_tab_edd);
 
@@ -444,6 +445,7 @@ _edi_project_config_load()
 
    _edi_project_config->gui.width_marker = 80;
    _edi_project_config->gui.tabstop = 8;
+   _edi_project_config->gui.toolbar_hidden = EINA_FALSE;
 
    _edi_project_config->tabs = NULL;
    IFPCFGEND;
diff --git a/src/bin/edi_config.h b/src/bin/edi_config.h
index 7d07cce..a03a0e4 100644
--- a/src/bin/edi_config.h
+++ b/src/bin/edi_config.h
@@ -63,6 +63,8 @@ struct _Edi_Project_Config
         Eina_Bool leftopen, bottomopen;
         Eina_Bool show_whitespace;
         unsigned int width_marker, tabstop;
+
+        Eina_Bool toolbar_hidden;
      } gui;
 
    Eina_List *tabs;
diff --git a/src/bin/edi_main.c b/src/bin/edi_main.c
index d012ee1..f9a1eb7 100644
--- a/src/bin/edi_main.c
+++ b/src/bin/edi_main.c
@@ -36,13 +36,13 @@ typedef struct _Edi_Panel_Slide_Effect
 
 #define COPYRIGHT "Copyright © 2014 Andy Williams <a...@andyilliams.me> and 
various contributors (see AUTHORS)."
 
-static Evas_Object *_edi_leftpanes, *_edi_bottompanes;
+static Evas_Object *_edi_toolbar, *_edi_leftpanes, *_edi_bottompanes;
 static Evas_Object *_edi_logpanel, *_edi_consolepanel, *_edi_testpanel;
 static Elm_Object_Item *_edi_logpanel_item, *_edi_consolepanel_item, 
*_edi_testpanel_item;
 static Elm_Object_Item *_edi_selected_bottompanel;
 static Evas_Object *_edi_filepanel, *_edi_filepanel_icon;
 
-static Evas_Object *_edi_main_win, *_edi_new_popup, 
*_edi_goto_popup,*_edi_message_popup;
+static Evas_Object *_edi_main_win, *_edi_main_box, *_edi_new_popup, 
*_edi_goto_popup,*_edi_message_popup;
 int _edi_log_dom = -1;
 
 static void
@@ -760,6 +760,26 @@ _edi_resize_cb(void *data EINA_UNUSED, Evas *e 
EINA_UNUSED, Evas_Object *obj,
    _edi_project_config_save();
 }
 
+static void
+_edi_toolbar_set_visible(Eina_Bool visible)
+{
+   elm_box_unpack(_edi_main_box, _edi_toolbar);
+   if (visible)
+     evas_object_show(_edi_toolbar);
+   else
+     evas_object_hide(_edi_toolbar);
+
+   if (visible)
+     elm_box_pack_start(_edi_main_box, _edi_toolbar);
+}
+
+static Eina_Bool
+_edi_config_changed(void *data EINA_UNUSED, int type EINA_UNUSED, void *event 
EINA_UNUSED)
+{
+   _edi_toolbar_set_visible(!_edi_project_config->gui.toolbar_hidden);
+   return ECORE_CALLBACK_RENEW;
+}
+
 void
 _edi_open_tabs()
 {
@@ -804,12 +824,14 @@ edi_open(const char *inputpath)
    evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, _edi_resize_cb, 
NULL);
 
    vbx = elm_box_add(win);
+   _edi_main_box = vbx;
    evas_object_size_hint_weight_set(vbx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    elm_win_resize_object_add(win, vbx);
    evas_object_show(vbx);
 
    tb = edi_toolbar_setup(win);
-   elm_box_pack_end(vbx, tb);
+   _edi_toolbar = tb;
+   _edi_toolbar_set_visible(!_edi_project_config->gui.toolbar_hidden);
 
    content = edi_content_setup(vbx, path);
    evas_object_size_hint_weight_set(content, EVAS_HINT_EXPAND, 
EVAS_HINT_EXPAND);
@@ -823,6 +845,7 @@ edi_open(const char *inputpath)
 
    _edi_config_project_add(path);
    _edi_open_tabs();
+   ecore_event_handler_add(EDI_EVENT_CONFIG_CHANGED, _edi_config_changed, 
NULL);
 
    free(path);
    return win;
diff --git a/src/bin/screens/edi_settings.c b/src/bin/screens/edi_settings.c
index e54bf39..3602ae0 100644
--- a/src/bin/screens/edi_settings.c
+++ b/src/bin/screens/edi_settings.c
@@ -90,6 +90,17 @@ _edi_settings_display_tabstop_cb(void *data EINA_UNUSED, 
Evas_Object *obj,
    _edi_project_config_save();
 }
 
+static void
+_edi_settings_toolbar_hidden_cb(void *data EINA_UNUSED, Evas_Object *obj,
+                                void *event EINA_UNUSED)
+{
+   Evas_Object *check;
+
+   check = (Evas_Object *)obj;
+   _edi_project_config->gui.toolbar_hidden = elm_check_state_get(check);
+   _edi_project_config_save();
+}
+
 static Evas_Object *
 _edi_settings_display_create(Evas_Object *parent)
 {
@@ -163,7 +174,7 @@ _edi_settings_display_create(Evas_Object *parent)
 
    hbox = elm_box_add(parent);
    elm_box_horizontal_set(hbox, EINA_TRUE);
-   evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, 0.5);
+   evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, 0.0);
    evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, 0.05);
    elm_box_pack_end(box, hbox);
    evas_object_show(hbox);
@@ -187,6 +198,16 @@ _edi_settings_display_create(Evas_Object *parent)
    elm_box_pack_end(hbox, spinner);
    evas_object_show(spinner);
 
+   check = elm_check_add(box);
+   elm_object_text_set(check, "Hide Toolbar");
+   elm_check_state_set(check, _edi_project_config->gui.toolbar_hidden);
+   elm_box_pack_end(box, check);
+   evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, 0.5);
+   evas_object_size_hint_align_set(check, 0.0, 0.5);
+   evas_object_smart_callback_add(check, "changed",
+                                  _edi_settings_toolbar_hidden_cb, NULL);
+   evas_object_show(check);
+
    return frame;
 }
 

-- 


Reply via email to