Enlightenment CVS committal

Author  : urandom
Project : e17
Module  : libs/etk

Dir     : e17/libs/etk/src/lib


Modified Files:
        etk_argument.c etk_theme.c etk_theme.h 


Log Message:
fix a bug in the etk_argument
added default per-theme colors and a function to obtain them

===================================================================
RCS file: /cvs/e/e17/libs/etk/src/lib/etk_argument.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- etk_argument.c      28 Dec 2006 15:38:11 -0000      1.11
+++ etk_argument.c      1 Feb 2007 19:14:52 -0000       1.12
@@ -75,7 +75,8 @@
  * value, this function will return ETK_TRUE. You can set it to NULL to ignore 
it
  * @param remove if @a remove is ETK_TRUE, the argument and its value will be 
removed from @a argv
  * if they are found
- * @param value the location where to store the value of the argument. You'll 
have to free it when you no longer need it
+ * @param value the location where to store the value of the argument. You'll 
have to free it when you no longer need it.
+ * If NULL, it's expected that the agrument has no value
  * @return Returns ETK_TRUE if the argument has been found and was followed by 
a value, ETK_FALSE otherwise
  */
 Etk_Bool etk_argument_value_get(int *argc, char ***argv, const char 
*long_name, char short_name, Etk_Bool remove, char **value)
@@ -108,7 +109,10 @@
             /* -s value */
             if (arg_len == 2)
             {
-               if ((i + 1 < *argc) && (next = (*argv)[i + 1]) && next[0] != 
'-')
+              /* valueless */
+              if (!value)
+                  num_args = 1;
+              else if ((i + 1 < *argc) && (next = (*argv)[i + 1]) && next[0] 
!= '-')
                {
                   value_ptr = next;
                   num_args = 2;
@@ -127,8 +131,11 @@
       {
          if (strncmp(&arg[2], long_name, long_name_len) == 0)
          {
+           /* valueless */
+           if (!value && !((arg_len > long_name_len + 3) && (arg[long_name_len 
+ 2] == '=')))
+              num_args = 1;
             /* --long_name value */
-            if (arg_len == long_name_len + 2)
+           else if (arg_len == long_name_len + 2)
             {
                if ((i + 1 < *argc) && (next = (*argv)[i + 1]) && next[0] != 
'-')
                {
@@ -145,18 +152,18 @@
          }
       }
       
-      /* A value has been found */
-      if (value_ptr)
+      if (num_args)
       {
-         if (value)
-            *value = strdup(value_ptr);
+        /* A value has been found */
+        if (value_ptr)
+           if (value) *value = strdup(value_ptr);
          if (remove)
          {
-            for (j = i + num_args; j < *argc; j++)
-               (*argv)[j - num_args] = (*argv)[j];
-            (*argc)--;
+            for (j = i; j < *argc - num_args + 1; j++)
+              (*argv)[j] = (*argv)[j + num_args];
+           (*argc) -= num_args;
          }
-         return ETK_TRUE;
+        return ETK_TRUE;
       }
    }
    
===================================================================
RCS file: /cvs/e/e17/libs/etk/src/lib/etk_theme.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- etk_theme.c 20 Oct 2006 17:51:44 -0000      1.11
+++ etk_theme.c 1 Feb 2007 19:14:52 -0000       1.12
@@ -15,6 +15,7 @@
 static char *_etk_theme_widget_current = NULL;
 static char *_etk_theme_icon_default = NULL;
 static char *_etk_theme_icon_current = NULL;
+static char *_etk_theme_colors[ETK_COLOR_NUM_COLORS];
 
 /**
  * @internal
@@ -27,6 +28,25 @@
    
    etk_theme_widget_set(etk_config_widget_theme_get());
    etk_theme_icon_set("default");
+
+   _etk_theme_colors[ETK_COLOR_FOREGROUND] = strdup("etk/color/foreground");
+   _etk_theme_colors[ETK_COLOR_BACKGROUND] = strdup("etk/color/background");
+   _etk_theme_colors[ETK_COLOR_IMPORTANT_FG] = 
strdup("etk/color/important/fg");
+   _etk_theme_colors[ETK_COLOR_IMPORTANT_BG] = 
strdup("etk/color/important/bg");
+   _etk_theme_colors[ETK_COLOR_WARNING_FG] = strdup("etk/color/warning/fg");
+   _etk_theme_colors[ETK_COLOR_WARNING_BG] = strdup("etk/color/warning/bg");
+   _etk_theme_colors[ETK_COLOR_INFO_FG] = strdup("etk/color/info/fg");
+   _etk_theme_colors[ETK_COLOR_INFO_BG] = strdup("etk/color/info/bg");
+   _etk_theme_colors[ETK_COLOR_DEFAULT1_FG] = strdup("etk/color/default1/fg");
+   _etk_theme_colors[ETK_COLOR_DEFAULT1_BG] = strdup("etk/color/default1/bg");
+   _etk_theme_colors[ETK_COLOR_DEFAULT2_FG] = strdup("etk/color/default2/fg");
+   _etk_theme_colors[ETK_COLOR_DEFAULT2_BG] = strdup("etk/color/default2/bg");
+   _etk_theme_colors[ETK_COLOR_DEFAULT3_FG] = strdup("etk/color/default3/fg");
+   _etk_theme_colors[ETK_COLOR_DEFAULT3_BG] = strdup("etk/color/default3/bg");
+   _etk_theme_colors[ETK_COLOR_DEFAULT4_FG] = strdup("etk/color/default4/fg");
+   _etk_theme_colors[ETK_COLOR_DEFAULT4_BG] = strdup("etk/color/default4/bg");
+   _etk_theme_colors[ETK_COLOR_DEFAULT5_FG] = strdup("etk/color/default5/fg");
+   _etk_theme_colors[ETK_COLOR_DEFAULT5_BG] = strdup("etk/color/default5/bg");
 }
 
 /**
@@ -35,6 +55,8 @@
  */
 void etk_theme_shutdown()
 {
+   int i;
+
    free(_etk_theme_widget_default);
    free(_etk_theme_widget_current);
    free(_etk_theme_icon_default);
@@ -44,6 +66,12 @@
    _etk_theme_widget_current = NULL;
    _etk_theme_icon_default = NULL;
    _etk_theme_icon_current = NULL;
+
+   for (i = 0; i < ETK_COLOR_NUM_COLORS; i++)
+   {
+      if (_etk_theme_colors[i])
+        free(_etk_theme_colors[i]);
+   }
 }
 
 /**
@@ -320,6 +348,30 @@
    if (!object)
       return ETK_FALSE;
    return etk_theme_edje_object_set(object, etk_widget_theme_file_get(parent), 
group, etk_widget_theme_group_get(parent));
+}
+
+/**
+ * @brief Gets the color type from the theme-file.
+ * @param color_type an Etk_Color_Type
+ * @return Returns an Etk_Color with the color filled from the theme-file, or 
color with -1 if it wasn't found
+ */
+Etk_Color etk_theme_color_get(Etk_Color_Type color_type)
+{
+   Etk_Color color;
+   const char *file;
+   char *color_string;
+
+   file = _etk_theme_widget_current ? _etk_theme_widget_current : 
_etk_theme_widget_default;
+   color_string = edje_file_data_get(file, _etk_theme_colors[color_type]);
+   if (!color_string || sscanf(color_string, "%d %d %d %d", &color.r, 
&color.g, &color.b, &color.a) != 4)
+   {
+      Etk_Color color = { .r = -1, .g = -1, .b = -1, .a = -1 };
+      if (color_string) free(color_string);
+      return color;
+   }
+
+   if (color_string) free(color_string);
+   return color;
 }
 
 /**************************
===================================================================
RCS file: /cvs/e/e17/libs/etk/src/lib/etk_theme.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- etk_theme.h 6 Oct 2006 17:04:15 -0000       1.5
+++ etk_theme.h 1 Feb 2007 19:14:52 -0000       1.6
@@ -11,6 +11,30 @@
 #include <Evas.h>
 #include "etk_types.h"
 
+/** @brief The different types of colors */
+typedef enum Etk_Color_Type
+{
+   ETK_COLOR_FOREGROUND,          /**< The default foreground color */
+   ETK_COLOR_BACKGROUND,          /**< The default background color */
+   ETK_COLOR_IMPORTANT_FG,        /**< Foreground color to express importance 
*/
+   ETK_COLOR_IMPORTANT_BG,        /**< Background color to express importance 
*/
+   ETK_COLOR_WARNING_FG,          /**< Foreground color to express warning */
+   ETK_COLOR_WARNING_BG,          /**< Background color to express warning */
+   ETK_COLOR_INFO_FG,            /**< Foreground color to show informative 
areas */
+   ETK_COLOR_INFO_BG,            /**< Background color to show informative 
areas */
+   ETK_COLOR_DEFAULT1_FG,         /**< Default foreground color 1 */
+   ETK_COLOR_DEFAULT1_BG,         /**< Default background color 1 */
+   ETK_COLOR_DEFAULT2_FG,         /**< Default foreground color 2 */
+   ETK_COLOR_DEFAULT2_BG,         /**< Default background color 2 */
+   ETK_COLOR_DEFAULT3_FG,         /**< Default foreground color 3 */
+   ETK_COLOR_DEFAULT3_BG,         /**< Default background color 3 */
+   ETK_COLOR_DEFAULT4_FG,         /**< Default foreground color 4 */
+   ETK_COLOR_DEFAULT4_BG,         /**< Default background color 4 */
+   ETK_COLOR_DEFAULT5_FG,         /**< Default foreground color 5 */
+   ETK_COLOR_DEFAULT5_BG,         /**< Default background color 5 */
+   ETK_COLOR_NUM_COLORS
+} Etk_Color_Type;
+
 void etk_theme_init();
 void etk_theme_shutdown();
 
@@ -25,6 +49,8 @@
 Etk_Bool etk_theme_group_exists(const char *file, const char *group, const 
char *parent_group);
 Etk_Bool etk_theme_edje_object_set(Evas_Object *object, const char *file, 
const char *group, const char *parent_group);
 Etk_Bool etk_theme_edje_object_set_from_parent(Evas_Object *object, const char 
*group, Etk_Widget *parent);
+
+Etk_Color etk_theme_color_get(Etk_Color_Type color_type);
 
 /** @} */
 



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to