billiob pushed a commit to branch master.

http://git.enlightenment.org/apps/terminology.git/commit/?id=33d20a1f988a31b66622ee33bedca585d2ebaa51

commit 33d20a1f988a31b66622ee33bedca585d2ebaa51
Author: Stanislav Baiduzhyi <baiduzhyi.de...@gmail.com>
Date:   Sat Dec 26 11:59:08 2015 +0100

    Option to disable cd to current tab dir.
    
    Summary: Adding option to disable cd to current tab dir.
    
    Test Plan:
    1. Start unpatched version of Terminology.
    2. Change some Behaviour options.
    3. Close unpatched version of Terminology.
    4. Start patched version of Terminology.
    5. cd /usr/bin
    6. Open new tab and verify that previous behaviour persists, new tab 
working directory is /usr/bin
    7. Go to Settings Behaviour and uncheck "Start in the same directory..." 
checkbox.
    8. Optn new tab and verify that new tab working directory is ~ (or any 
other directory from which the Terminology was launched).
    9. Restart Terminology.
    10. Go to Settings Behaviour and verify that options persisted.
    
    Reviewers: #terminology, billiob
    
    Subscribers: godfath3r, #terminology
    
    Projects: #terminology
    
    Differential Revision: https://phab.enlightenment.org/D3495
---
 src/bin/config.c           | 12 ++++++++--
 src/bin/config.h           |  1 +
 src/bin/options_behavior.c |  2 ++
 src/bin/win.c              | 55 +++++++++++++++++++++++++++++++---------------
 4 files changed, 50 insertions(+), 20 deletions(-)

diff --git a/src/bin/config.c b/src/bin/config.c
index 372ed24..4486f58 100644
--- a/src/bin/config.c
+++ b/src/bin/config.c
@@ -7,7 +7,7 @@
 #include "col.h"
 #include "utils.h"
 
-#define CONF_VER 6
+#define CONF_VER 7
 
 #define LIM(v, min, max) {if (v >= max) v = max; else if (v <= min) v = min;}
 
@@ -165,6 +165,8 @@ config_init(void)
      (edd_base, Config, "mv_always_show", mv_always_show, EET_T_UCHAR);
    EET_DATA_DESCRIPTOR_ADD_BASIC
      (edd_base, Config, "ty_escapes", ty_escapes, EET_T_UCHAR);
+   EET_DATA_DESCRIPTOR_ADD_BASIC
+     (edd_base, Config, "changedir_to_current", changedir_to_current, 
EET_T_UCHAR);
 }
 
 void
@@ -265,6 +267,7 @@ config_sync(const Config *config_src, Config *config)
    config->notabs = config_src->notabs;
    config->mv_always_show = config_src->mv_always_show;
    config->ty_escapes = config_src->ty_escapes;
+   config->changedir_to_current = config_src->changedir_to_current;
 }
 
 static void
@@ -480,6 +483,7 @@ config_new(void)
         config->notabs = EINA_FALSE;
         config->mv_always_show = EINA_FALSE;
         config->ty_escapes = EINA_TRUE;
+        config->changedir_to_current = EINA_TRUE;
         for (j = 0; j < 4; j++)
           {
              for (i = 0; i < 12; i++)
@@ -549,7 +553,10 @@ config_load(const char *key)
                 case 5:
                   config->ty_escapes = EINA_TRUE;
                   /*pass through*/
-                case CONF_VER: /* 6 */
+                case 6:
+                  config->changedir_to_current = EINA_TRUE;
+                  /*pass through*/
+                case CONF_VER: /* 7 */
                   config->version = CONF_VER;
                   break;
                 default:
@@ -645,6 +652,7 @@ config_fork(Config *config)
    CPY(notabs);
    CPY(mv_always_show);
    CPY(ty_escapes);
+   CPY(changedir_to_current);
 
    EINA_LIST_FOREACH(config->keys, l, key)
      {
diff --git a/src/bin/config.h b/src/bin/config.h
index d6a8a93..fb9e148 100644
--- a/src/bin/config.h
+++ b/src/bin/config.h
@@ -76,6 +76,7 @@ struct _Config
    Eina_Bool         notabs;
    Eina_Bool         mv_always_show;
    Eina_Bool         ty_escapes;
+   Eina_Bool         changedir_to_current;
    Config_Color      colors[(4 * 12)];
    Eina_List        *keys;
 
diff --git a/src/bin/options_behavior.c b/src/bin/options_behavior.c
index d889a46..bcff701 100644
--- a/src/bin/options_behavior.c
+++ b/src/bin/options_behavior.c
@@ -43,6 +43,7 @@ CB(gravatar,  0);
 CB(notabs,  1);
 CB(mv_always_show, 0);
 CB(ty_escapes, 0);
+CB(changedir_to_current, 0);
 
 #undef CB
 
@@ -193,6 +194,7 @@ options_behavior(Evas_Object *opbox, Evas_Object *term)
    CX(_("Show tabs"), notabs, 1);
    CX(_("Always show miniview"), mv_always_show, 0);
    CX(_("Enable special Terminology escape codes"), ty_escapes, 0);
+   CX(_("Open new terminals in current working directory"), 
changedir_to_current, 0);
 
 #undef CX
 
diff --git a/src/bin/win.c b/src/bin/win.c
index 23873d8..640d136 100644
--- a/src/bin/win.c
+++ b/src/bin/win.c
@@ -952,16 +952,22 @@ _win_split(Term_Container *tc, Term_Container *child,
      {
         Term *tm_new, *tm;
         Term_Container *tc_split, *tc_solo_new;
-        char buf[PATH_MAX], *wdir = NULL;
+        char *wdir = NULL;
         Evas_Object *base;
         Evas_Object *o;
 
-        if (from)
-          tm = from;
-        else
-          tm = tc->focused_term_get(tc);
-        if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf)))
-          wdir = buf;
+        // copy the current path to wdir if we should change the directory,
+        // passing wdir NULL otherwise:
+        if (wn->config->changedir_to_current)
+          {
+             if (from)
+               tm = from;
+             else
+               tm = tc->focused_term_get(tc);
+             char buf[PATH_MAX];
+             if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf)))
+               wdir = buf;
+          }
         tm_new = term_new(wn, wn->config,
                           cmd, wn->config->login_shell, wdir,
                           80, 24, EINA_FALSE);
@@ -1438,16 +1444,22 @@ _split_split(Term_Container *tc, Term_Container *child,
    if (_term_container_is_splittable(tc, is_horizontal))
      {
         Term *tm_new, *tm;
-        char buf[PATH_MAX], *wdir = NULL;
+        char *wdir = NULL;
         Term_Container *tc_split, *tc_solo_new;
         Evas_Object *obj_split;
 
-        if (from)
-          tm = from;
-        else
-          tm = child->focused_term_get(child);
-        if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf)))
-          wdir = buf;
+        // copy the current path to wdir if we should change the directory,
+        // passing wdir NULL otherwise:
+        if (wn->config->changedir_to_current)
+          {
+             if (from)
+               tm = from;
+             else
+               tm = child->focused_term_get(child);
+             char buf[PATH_MAX];
+             if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf)))
+               wdir = buf;
+          }
         tm_new = term_new(wn, wn->config,
                           cmd, wn->config->login_shell, wdir,
                           80, 24, EINA_FALSE);
@@ -2326,11 +2338,18 @@ _tab_new_cb(void *data,
                   *tc_new, *tc_parent, *tc_old;
    Term *tm, *tm_new;
    Win *wn = tc->wn;
-   char buf[PATH_MAX], *wdir = NULL;
+   char *wdir = NULL;
+
+   // copy the current path to wdir if we should change the directory,
+   // passing wdir NULL otherwise:
+   if (wn->config->changedir_to_current)
+     {
+        char buf[PATH_MAX];
+        tm = tc->focused_term_get(tc);
+        if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf)))
+          wdir = buf;
+     }
 
-   tm = tc->focused_term_get(tc);
-   if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf)))
-     wdir = buf;
    tm_new = term_new(wn, wn->config,
                      NULL, wn->config->login_shell, wdir,
                      80, 24, EINA_FALSE);

-- 


Reply via email to