Enlightenment CVS committal

Author  : rephorm
Project : e17
Module  : apps/elicit

Dir     : e17/apps/elicit/src


Modified Files:
        callbacks.c callbacks.h conf.c conf.h elicit.c util.c util.h 


Log Message:

save the zoom and color out to the config.db (and use them next time)
new signal: elicit,copy,hex sets the primary selection to the hex val
update winter theme to use this signal (click on the hex val)

===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/elicit/src/callbacks.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- callbacks.c 7 Feb 2004 20:27:27 -0000       1.3
+++ callbacks.c 8 Feb 2004 04:02:09 -0000       1.4
@@ -45,12 +45,9 @@
   {
     if (el->flags.picking == 1)
     {
-      elicit_util_color_get(&(el->color.r), &(el->color.g), &(el->color.b));
+      elicit_util_color_at_pointer_get(&(el->color.r), &(el->color.g), 
&(el->color.b));
       evas_object_color_set(el->swatch, el->color.r, el->color.g, el->color.b, 255);
-      elicit_color_rgb_to_hsv(el->color.r, el->color.g, el->color.b,
-                              &(el->color.h), &(el->color.s), &(el->color.v));
-      if (el->color.hex) free (el->color.hex);
-      el->color.hex = elicit_color_rgb_to_hex(el->color.r, el->color.g, el->color.b);
+      elicit_util_colors_set_from_rgb(el);
       elicit_ui_update_text(el);
     }
   }
@@ -101,6 +98,15 @@
   }
 }
 
+void
+elicit_cb_copy(void *data, Evas_Object *o, const char *sig, const char *src)
+{
+  Elicit *el = data;
+  Ecore_X_Window win = ecore_evas_software_x11_window_get(el->ee);
+
+  ecore_x_selection_primary_set(win, el->color.hex, strlen(el->color.hex));
+}
+
 static int
 elicit_timer_color(void *data)
 {
@@ -141,10 +147,7 @@
     if (el->color.r > 255) el->color.r = 255;
     if (el->color.r < 0) el->color.r = 0;
 
-    elicit_color_rgb_to_hsv(el->color.r, el->color.g, el->color.b,
-                            &(el->color.h), &(el->color.s), &(el->color.v));
-    if (el->color.hex) free (el->color.hex);
-    el->color.hex = elicit_color_rgb_to_hex(el->color.r, el->color.g, el->color.b);
+    elicit_util_colors_set_from_rgb(el);
   }
 
   else if (elicit_glob_match(el->change_sig, "*,g,*"))
@@ -153,10 +156,7 @@
     if (el->color.g > 255) el->color.g = 255;
     if (el->color.g < 0) el->color.g = 0;
     
-    elicit_color_rgb_to_hsv(el->color.r, el->color.g, el->color.b,
-                            &(el->color.h), &(el->color.s), &(el->color.v));
-    if (el->color.hex) free (el->color.hex);
-    el->color.hex = elicit_color_rgb_to_hex(el->color.r, el->color.g, el->color.b);
+    elicit_util_colors_set_from_rgb(el);
   }
 
   else if (elicit_glob_match(el->change_sig, "*,b,*"))
@@ -165,10 +165,7 @@
     if (el->color.b > 255) el->color.b = 255;
     if (el->color.b < 0) el->color.b = 0;
     
-    elicit_color_rgb_to_hsv(el->color.r, el->color.g, el->color.b,
-                            &(el->color.h), &(el->color.s), &(el->color.v));
-    if (el->color.hex) free (el->color.hex);
-    el->color.hex = elicit_color_rgb_to_hex(el->color.r, el->color.g, el->color.b);
+    elicit_util_colors_set_from_rgb(el);
   }
 
   else if (elicit_glob_match(el->change_sig, "*,h,*"))
@@ -177,10 +174,7 @@
     if (el->color.h > 360) el->color.h = 360;
     if (el->color.h < 0) el->color.h = 0;
 
-    elicit_color_hsv_to_rgb(el->color.h, el->color.s, el->color.v,
-                            &(el->color.r), &(el->color.g), &(el->color.b));
-    if (el->color.hex) free (el->color.hex);
-    el->color.hex = elicit_color_rgb_to_hex(el->color.r, el->color.g, el->color.b);
+    elicit_util_colors_set_from_hsv(el);
   }
 
   else if (elicit_glob_match(el->change_sig, "*,s,*"))
@@ -189,10 +183,7 @@
     if (el->color.s > 1) el->color.s = 1;
     if (el->color.s < 0) el->color.s = 0;
 
-    elicit_color_hsv_to_rgb(el->color.h, el->color.s, el->color.v,
-                            &(el->color.r), &(el->color.g), &(el->color.b));
-    if (el->color.hex) free (el->color.hex);
-    el->color.hex = elicit_color_rgb_to_hex(el->color.r, el->color.g, el->color.b);
+    elicit_util_colors_set_from_hsv(el);
   }
 
   else if (elicit_glob_match(el->change_sig, "*,v,*"))
@@ -201,10 +192,7 @@
     if (el->color.v > 1) el->color.v = 1;
     if (el->color.v < 0) el->color.v = 0;
     
-    elicit_color_hsv_to_rgb(el->color.h, el->color.s, el->color.v,
-                            &(el->color.r), &(el->color.g), &(el->color.b));
-    if (el->color.hex) free (el->color.hex);
-    el->color.hex = elicit_color_rgb_to_hex(el->color.r, el->color.g, el->color.b);
+    elicit_util_colors_set_from_hsv(el);
   }
 
   else if (elicit_glob_match(el->change_sig, "*,zoom,*"))
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/elicit/src/callbacks.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- callbacks.h 6 Feb 2004 06:32:58 -0000       1.1
+++ callbacks.h 8 Feb 2004 04:02:09 -0000       1.2
@@ -8,5 +8,6 @@
 void elicit_cb_pick(void *data, Evas_Object *o, const char *sig, const char *src);
 void elicit_cb_shoot(void *data, Evas_Object *o, const char *sig, const char *src);
 void elicit_cb_colors(void *data, Evas_Object *o, const char *sig, const char *src);
+void elicit_cb_copy(void *data, Evas_Object *o, const char *sig, const char *src);
 
 #endif
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/elicit/src/conf.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- conf.c      7 Feb 2004 20:27:27 -0000       1.2
+++ conf.c      8 Feb 2004 04:02:09 -0000       1.3
@@ -25,10 +25,16 @@
   snprintf(buf, sizeof(buf), "%s/.e/apps/%s/config.db", getenv("HOME"), __app_name);
   if (stat(buf, &st))
   {
-    printf("set default and save\n");
+  /*
+    ecore_config_set_int("/color/r", 255);
+    ecore_config_set_int("/color/g", 255);
+    ecore_config_set_int("/color/b", 255);
     ecore_config_set_string("/settings/theme", "winter");
+  */
+    elicit_config_color_set(255, 255, 255);
+    elicit_config_zoom_set(4.0);
+    elicit_config_theme_set("winter");
     ecore_config_save();
-//    ecore_config_save_file("test.db");
   }
   else
     ecore_config_load();
@@ -62,17 +68,15 @@
 }
 
 void
-elicit_config_size_get(int *w, int *h)
+elicit_config_zoom_set(double zoom)
 {
-  if (w) *w = ecore_config_get_int("/window/w");
-  if (h) *h = ecore_config_get_int("/window/h");
+  ecore_config_set_float("/settings/zoom", (float)zoom);
 }
 
-void
-elicit_config_size_set(int w, int h)
+double
+elicit_config_zoom_get()
 {
-  ecore_config_set_int("/window/w", w);
-  ecore_config_set_int("/window/h", h);
+  return (double)ecore_config_get_float("/settings/zoom");
 }
 
 void
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/elicit/src/conf.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- conf.h      7 Feb 2004 19:54:56 -0000       1.1
+++ conf.h      8 Feb 2004 04:02:09 -0000       1.2
@@ -17,5 +17,11 @@
 char *elicit_config_theme_get();
 void elicit_config_theme_set(char *name);
 
+void elicit_config_color_get(int *r, int *g, int *b);
+void elicit_config_color_set(int r, int g, int b);
+
+void elicit_config_zoom_set(double zoom);
+double elicit_config_zoom_get();
+
 #endif
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/elicit/src/elicit.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- elicit.c    7 Feb 2004 20:27:27 -0000       1.6
+++ elicit.c    8 Feb 2004 04:02:09 -0000       1.7
@@ -71,6 +71,8 @@
   ecore_main_loop_begin();
 
   /* shutdown the subsystems (when event loop exits, app is done) */
+  elicit_config_zoom_set(el->zoom);
+  elicit_config_color_set(el->color.r, el->color.g, el->color.b);
   elicit_config_shutdown(el);
   ecore_evas_shutdown();
   ecore_shutdown();
@@ -96,47 +98,21 @@
   evas_object_move(el->gui, 0, 0);
   evas_object_show(el->gui);
 
+  elicit_config_color_get(&el->color.r, &el->color.g, &el->color.b);
+  elicit_util_colors_set_from_rgb(el);
+  el->zoom = elicit_config_zoom_get();
+
   /* create the swatch and shot objects */
   el->shot = evas_object_image_add(el->evas);
   evas_object_name_set(el->shot, "shot");
   evas_object_show(el->shot);
   
   el->swatch = evas_object_rectangle_add(el->evas);
-  evas_object_color_set(el->swatch, 0, 0, 0, 255);
+  evas_object_color_set(el->swatch, el->color.r, el->color.g, el->color.b, 255);
   evas_object_name_set(el->swatch, "swatch");
   evas_object_show(el->swatch);
 
   elicit_ui_theme_set(el, elicit_config_theme_get(el));
-#if 0
-  if (!edje_object_file_set(el->gui, DATADIR"/themes/winter.eet", "elicit"))
-  {
-    fprintf(stderr, "can't load theme eet: %s, %s\n", DATADIR"/themes/elicit.eet", 
"elicit");
-    return 0;
-  }
-  edje_object_size_min_get(el->gui, &mw, &mh);
-  ecore_evas_size_min_set(el->ee, mw, mh);
-  ecore_evas_resize(el->ee, mw, mh);
-  evas_object_resize(el->gui, mw, mh);
-
-  /* swallow them */
-  edje_object_part_swallow(el->gui, "shot", el->shot);
-  edje_object_part_swallow(el->gui, "swatch", el->swatch);
- 
-  /* set up edje callbacks */
-  edje_object_signal_callback_add(el->gui, "elicit,pick,*", "*", elicit_cb_pick, el);
-  edje_object_signal_callback_add(el->gui, "mouse,move", "*", elicit_cb_pick, el);
-  edje_object_signal_callback_add(el->gui, "mouse,move", "*", elicit_cb_shoot, el);
-  edje_object_signal_callback_add(el->gui, "elicit,shoot,*", "*", elicit_cb_shoot, 
el);
-  edje_object_signal_callback_add(el->gui, "elicit,quit", "*", elicit_cb_exit, el);
-  edje_object_signal_callback_add(el->gui, "elicit,color,*", "*", elicit_cb_colors, 
el);
-  edje_object_signal_callback_add(el->gui, "elicit,zoom,*", "*", elicit_cb_colors, 
el);
-#endif
-
-  /* some defaults */
-  /* FIXME: use a config db */
-  el->zoom = 4;
-  el->color.hex = strdup("#000000");
-
   elicit_ui_update_text(el);
   return 0;
 }
@@ -181,6 +157,7 @@
   edje_object_signal_callback_add(el->gui, "elicit,quit", "*", elicit_cb_exit, el);
   edje_object_signal_callback_add(el->gui, "elicit,color,*", "*", elicit_cb_colors, 
el);
   edje_object_signal_callback_add(el->gui, "elicit,zoom,*", "*", elicit_cb_colors, 
el);
+  edje_object_signal_callback_add(el->gui, "elicit,copy,*", "*", elicit_cb_copy, el);
 
 }
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/elicit/src/util.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- util.c      7 Feb 2004 20:27:27 -0000       1.4
+++ util.c      8 Feb 2004 04:02:09 -0000       1.5
@@ -3,8 +3,12 @@
 #include "Elicit.h"
 #include "util.h"
 
+void elicit_color_rgb_to_hsv(int rr, int gg, int bb, double *hh, double *ss, double 
*vv);
+void elicit_color_hsv_to_rgb(double hh, double ss, double vv, int *rr, int *gg, int 
*bb);
+char * elicit_color_rgb_to_hex(int rr, int gg, int bb);
+
 void
-elicit_util_color_get(int *r, int *g, int *b)
+elicit_util_color_at_pointer_get(int *r, int *g, int *b)
 {
   Imlib_Image *im;
   Imlib_Color col;
@@ -92,8 +96,23 @@
   imlib_free_image();
 }
 
+void
+elicit_util_colors_set_from_rgb(Elicit *el)
+{
+    elicit_color_rgb_to_hsv(el->color.r, el->color.g, el->color.b,
+                            &(el->color.h), &(el->color.s), &(el->color.v));
+    if (el->color.hex) free (el->color.hex);
+    el->color.hex = elicit_color_rgb_to_hex(el->color.r, el->color.g, el->color.b);
+}
 
-
+void
+elicit_util_colors_set_from_hsv(Elicit *el)
+{
+    elicit_color_hsv_to_rgb(el->color.h, el->color.s, el->color.v,
+                            &(el->color.r), &(el->color.g), &(el->color.b));
+    if (el->color.hex) free (el->color.hex);
+    el->color.hex = elicit_color_rgb_to_hex(el->color.r, el->color.g, el->color.b);
+}
 
 void
 elicit_color_rgb_to_hsv(int rr, int gg, int bb, double *hh, double *ss, double *vv)
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/elicit/src/util.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- util.h      7 Feb 2004 20:27:27 -0000       1.2
+++ util.h      8 Feb 2004 04:02:09 -0000       1.3
@@ -1,12 +1,12 @@
 #ifndef ELICIT_UTIL_H
 #define ELICIT_UTIL_H
 
-void elicit_color_rgb_to_hsv(int rr, int gg, int bb, double *hh, double *ss, double 
*vv);
-void elicit_color_hsv_to_rgb(double hh, double ss, double vv, int *rr, int *gg, int 
*bb);
-char * elicit_color_rgb_to_hex(int rr, int gg, int bb);
+void elicit_util_colors_set_from_hsv(Elicit *el);
+void elicit_util_colors_set_from_rgb(Elicit *el);
+
 int elicit_glob_match(const char *str, const char *glob);
 
-void elicit_util_color_get(int *r, int *g, int *b);
+void elicit_util_color_at_pointer_get(int *r, int *g, int *b);
 void elicit_util_shoot(Evas_Object *shot, int w, int h);
 
 char *elicit_theme_find(const char *name);




-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to