billiob pushed a commit to branch master.

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

commit a83bd06905d741b49c69d7a91f8eca68604129c3
Author: wonguk.jeong <wonguk.je...@samsung.com>
Date:   Thu Jul 17 12:50:04 2014 +0200

    tyalpha: support opacity level option
    
    Summary:
    support opacity level option for tyalpha.
    
    usage: tyalpha [-p] on|off|<opacity level>
    
    Test Plan: terminology -> tyalpha 60
    
    Reviewers: billiob, raster
    
    Subscribers: seoz
    
    Differential Revision: https://phab.enlightenment.org/D1197
---
 src/bin/main.c    | 69 +++++++++++++++++++++++++++++--------------------------
 src/bin/tyalpha.c |  6 ++---
 2 files changed, 39 insertions(+), 36 deletions(-)

diff --git a/src/bin/main.c b/src/bin/main.c
index 5e260ce..b9b5f43 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -1184,6 +1184,40 @@ _cb_popup_queue(void *data, Evas_Object *obj 
EINA_UNUSED, void *event)
 }
 
 static void
+_set_alpha(Config *config, const char *val, Eina_Bool save)
+{
+   int opacity;
+
+   if (!config || !val) return;
+
+   config->temporary = !save;
+
+   if (isdigit(*val))
+     {
+        opacity = atoi(val);
+        if (opacity >= 100)
+          {
+             config->translucent = EINA_FALSE;
+             config->opacity = 100;
+          }
+        else if (opacity >= 0)
+          {
+             config->translucent = EINA_TRUE;
+             config->opacity = opacity;
+          }
+     }
+   else if ((!strcasecmp(val, "on")) ||
+            (!strcasecmp(val, "true")) ||
+            (!strcasecmp(val, "yes")))
+     config->translucent = EINA_TRUE;
+   else
+     config->translucent = EINA_FALSE;
+   main_trans_update(config);
+
+   if (save) config_save(config, NULL);
+}
+
+static void
 _cb_command(void *data, Evas_Object *obj EINA_UNUSED, void *event)
 {
    Term *term = data;
@@ -1235,40 +1269,9 @@ _cb_command(void *data, Evas_Object *obj EINA_UNUSED, 
void *event)
    else if (cmd[0] == 'a') // set alpha
      {
         if (cmd[1] == 't') // temporary
-          {
-             Config *config = termio_config_get(term->term);
-
-             if (config)
-               {
-                  config->temporary = EINA_TRUE;
-                  if ((cmd[2] == '1') ||
-                      (!strcasecmp(cmd + 2, "on")) ||
-                      (!strcasecmp(cmd + 2, "true")) ||
-                      (!strcasecmp(cmd + 2, "yes")))
-                    config->translucent = EINA_TRUE;
-                  else
-                    config->translucent = EINA_FALSE;
-                  main_trans_update(config);
-               }
-          }
+          _set_alpha(termio_config_get(term->term), cmd + 2, EINA_FALSE);
         else if (cmd[1] == 'p') // permanent
-          {
-             Config *config = termio_config_get(term->term);
-
-             if (config)
-               {
-                  config->temporary = EINA_FALSE;
-                  if ((cmd[2] == '1') ||
-                      (!strcasecmp(cmd + 2, "on")) ||
-                      (!strcasecmp(cmd + 2, "true")) ||
-                      (!strcasecmp(cmd + 2, "yes")))
-                    config->translucent = EINA_TRUE;
-                  else
-                    config->translucent = EINA_FALSE;
-                  main_trans_update(config);
-                  config_save(config, NULL);
-               }
-          }
+          _set_alpha(termio_config_get(term->term), cmd + 2, EINA_TRUE);
      }
 }
 
diff --git a/src/bin/tyalpha.c b/src/bin/tyalpha.c
index d8e5f34..fe314bb 100644
--- a/src/bin/tyalpha.c
+++ b/src/bin/tyalpha.c
@@ -8,11 +8,11 @@ int
 main(int argc, char **argv)
 {
    int i, perm = 0;
-   
+
    if (!getenv("TERMINOLOGY")) return 0;
    if (argc <= 1)
      {
-        printf("Usage: %s [-p] on|off\n"
+        printf("Usage: %s [-p] on|off|<opacity level>\n"
                "  Change the terminal transparency on or off\n"
                "  -p  Make change permanent (stored in config)\n"
                "\n",
@@ -22,7 +22,7 @@ main(int argc, char **argv)
    for (i = 1; i < argc; i++)
      {
         char tbuf[PATH_MAX];
-        
+
         if (!strcmp(argv[i], "-p"))
           {
              perm = 1;

-- 


Reply via email to