On Mo, 2008-11-03 at 23:42 +1100, Carsten Haitzler wrote:
> 
> patches seem cool - i'll put them in svn. :) continue merrily with your work! 
> :)
> 
Thanks a lot!

I have extended the settings patch to use a eet-configfile now.
Also I have fixed a warning about evas_smart_new being deprecated by
replacing it with evas_smart_class_new as suggested in the warning.
Both patches apply cleanly here at revision 37444, compile and run fine
(as far as I've tested).
Please tell me what you think.

diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index d72c001..88793d4 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -35,7 +35,9 @@ e_table.h \
 e_layout.c \
 e_layout.h \
 e_flowlayout.c \
-e_flowlayout.h
+e_flowlayout.h \
+conf_options.c \
+conf_options.h
 
 rage_LDADD = @my_libs@ @EVAS_LIBS@ @ECORE_LIBS@ @EDJE_LIBS@ @EMOTION_LIBS@
 
diff --git a/src/bin/conf_options.c b/src/bin/conf_options.c
new file mode 100644
index 0000000..3161b8f
--- /dev/null
+++ b/src/bin/conf_options.c
@@ -0,0 +1,90 @@
+#include "conf_options.h"
+#include "main.h"
+
+void 
+config_option_fullscreen(void *data)
+{
+   Ecore_Evas *ee = (Ecore_Evas *)data;
+   int *i = malloc(sizeof(int));
+
+   if (ecore_evas_fullscreen_get(ee))
+   {
+      i[0] = 0;
+      ecore_evas_fullscreen_set(ee, 0);
+      ecore_evas_cursor_set(ee, NULL, 0, 0, 0);
+      eet_write(eet_config, "/config/fullscreen", i, sizeof(int), 0);
+   }
+   else 
+   {
+      i[0] = 1;
+      ecore_evas_fullscreen_set(ee, 1);
+      ecore_evas_cursor_set(ee, "", 999, 0, 0);
+      eet_write(eet_config, "/config/fullscreen", i, sizeof(int), 0);
+   }
+}
+
+void 
+config_option_themes(void *data)
+{
+}
+
+void
+config_option_modes_switch(void* data)
+{
+   int mode = (int)data;
+   eet_write(eet_config, "/config/mode", &mode, sizeof(int), 0);
+   main_reset();
+}
+
+void 
+config_option_modes(void *data)
+{
+   menu_push("menu", "Modes", NULL, NULL);
+   if (ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_X11))
+      menu_item_add("icon/x11", "Software",
+	    	    NULL, NULL, config_option_modes_switch,
+		    (void*)0, NULL, NULL, NULL);
+   if (ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_OPENGL_X11))
+      menu_item_add("icon/mesa", "Mesa OpenGL",
+	    	    NULL, NULL, config_option_modes_switch,
+		    (void*)1, NULL, NULL, NULL);
+   if (ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_FB))
+      menu_item_add("icon/fb", "Software Framebuffer",
+	    	    NULL, NULL, config_option_modes_switch,
+		    (void*)2, NULL, NULL, NULL);
+   if (ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_XRENDER_X11))
+      menu_item_add("icon/xr", "XRender Extension",
+	    	    NULL, NULL, config_option_modes_switch,
+		    (void*)3, NULL, NULL, NULL);
+   if (ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_DIRECTFB))
+      menu_item_add("icon/dfb", "DirectFB",
+	    	    NULL, NULL, config_option_modes_switch,
+		    (void*)4, NULL, NULL, NULL);
+   if (ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SDL))
+      menu_item_add("icon/sdl", "SDL Engine",
+	    	    NULL, NULL, config_option_modes_switch,
+		    (void*)5, NULL, NULL, NULL);
+   /* WINDOWS ENGINES - maybe later
+   if (ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_DDRAW)) 
+      menu_item_add("icon/x11", "Software",
+	    	    NULL, NULL, config_option_modes_switch,
+		    6, NULL, NULL, NULL);
+   if (ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_DIRECT3D))
+      menu_item_add("icon/x11", "Direct3D",
+	    	    NULL, NULL, config_option_modes_switch,
+		    7, NULL, NULL, NULL);
+   if (ecore_evas_engine_type_supported_get(ECORE_EVAS_ENGINE_SOFTWARE_16_WINCE))
+      menu_item_add("icon/x11", "Software",
+	    	    NULL, NULL, config_option_modes_switch,
+		    7, NULL, NULL, NULL);
+   */
+
+   menu_go();
+   menu_item_select("Software");
+}
+
+void 
+config_option_volumes(void *data)
+{
+}
+
diff --git a/src/bin/conf_options.h b/src/bin/conf_options.h
new file mode 100644
index 0000000..f991fae
--- /dev/null
+++ b/src/bin/conf_options.h
@@ -0,0 +1,10 @@
+#ifndef conf_options_h
+#define conf_options_h
+
+void config_option_fullscreen(void *data);
+void config_option_themes(void *data);
+void config_option_modes(void *data);
+void config_option_volumes(void *data);
+
+#endif
+
diff --git a/src/bin/main.c b/src/bin/main.c
index c366a4f..3a8d9bb 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -10,6 +10,7 @@ struct _Mode
 Evas        *evas = NULL;
 char        *theme = NULL;
 char        *config = NULL;
+Eet_File    *eet_config = NULL;
 Ecore_Timer* mouse_timeout = NULL;
 
 static double       start_time = 0.0;
@@ -35,13 +36,14 @@ static void main_menu_audio(void *data);
 static void main_menu_photo(void *data);
 static void main_menu_scan(void *data);
 static void main_menu_tv(void *data);
+static void main_get_config(void);
 
 int
 main(int argc, char **argv)
 {
    Evas_Object *o;
-   int mode = 0, fullscreen = 0;
-   int i;
+   int fullscreen, mode;
+   int i, size;
 
    /* init ecore, eet, evas, edje etc. */
    start_time = ecore_time_get();
@@ -60,6 +62,10 @@ main(int argc, char **argv)
 	return -1;
      }
 
+   main_get_config();
+   mode = *(int*)eet_read(eet_config, "/config/mode", &size);
+   fullscreen = *(int*)eet_read(eet_config, "/config/fullscreen", &size);
+
    /* parse cmd-line options */
    for (i = 1; i < argc; i++)
      {
@@ -86,11 +92,6 @@ main(int argc, char **argv)
 	     theme = strdup(buf);
 	     i++;
 	  }
-	else if (!strcmp(argv[i], "-cf"))
-	  {
-	     config = strdup(argv[i + 1]);
-	     i++;
-	  }
 	else if (!strcmp(argv[i], "-x11"))
 	  mode = 0;
 	else if (!strcmp(argv[i], "-gl"))
@@ -109,24 +110,9 @@ main(int argc, char **argv)
 	  main_usage();
      }
 
-   /* load config */
-   if (!config)
-     {
-	char buf[4096];
-
-	if (getenv("HOME"))
-	  snprintf(buf, sizeof(buf), "%s/.rage", getenv("HOME"));
-	else if (getenv("TMPDIR"))
-	  snprintf(buf, sizeof(buf), "%s/.rage", getenv("TMPDIR"));
-	else
-	  snprintf(buf, sizeof(buf), "%s/.rage", "/tmp");
-	config = strdup(buf);
-     }
-   if (!ecore_file_is_dir(config)) ecore_file_mkpath(config);
-
    /* set up default theme if no custom theme is selected */
    if (!theme)
-     theme = strdup(PACKAGE_DATA_DIR"/default.edj");
+     theme = eet_read(eet_config, "/config/theme", &size);
    /* create the canvas based on engine mode */
    if (mode == 0)
      ecore_evas = ecore_evas_software_x11_new(NULL, 0,  0, 0, startw, starth);
@@ -269,11 +255,18 @@ main_usage(void)
    printf("Usage:\n");
    printf("  rage "
 	  "[-x11] [-gl] [-fb] [-dfb] [-sdl] [-xr] [-g WxH] [-fs] "
-	  "[-t theme] [-cf dir]\n"
+	  "[-t theme] \n"
 	  );
    exit(-1);
 }
 
+void
+main_reset(void)
+{
+   eet_close(eet_config);
+   execlp("rage", "rage", NULL);
+}
+
 static int
 main_volume_add(void *data, int type, void *ev)
 {
@@ -293,7 +286,10 @@ main_key_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
 
    ev = (Evas_Event_Key_Down *)event_info;
    if      (!strcmp(ev->keyname, "Escape"))
-     ecore_main_loop_quit();
+     {
+	eet_close(eet_config);
+	ecore_main_loop_quit();
+     }
    else if (!strcmp(ev->keyname, "f"))
      {
 	if (!ecore_evas_fullscreen_get(ecore_evas))
@@ -345,24 +341,24 @@ static void
 main_menu_config(void *data)
 {
    menu_push("menu", "Settings", NULL, NULL);
-   menu_item_add("icon/config", "Option 1",
-		  "Option 1", NULL,
-		  NULL, NULL, NULL, NULL, NULL);
-   menu_item_add("icon/config", "Option 2",
-		  "Option 2", NULL,
-		  NULL, NULL, NULL, NULL, NULL);
-   menu_item_add("icon/config", "Option 3",
-		  "Option 3", NULL,
-		  NULL, NULL, NULL, NULL, NULL);
-   menu_item_add("icon/config", "Option 4",
-		  "Option 4", NULL,
-		  NULL, NULL, NULL, NULL, NULL);
-   menu_item_enabled_set("Settings", "Option 1", 1);
-   menu_item_enabled_set("Settings", "Option 2", 1);
-   menu_item_enabled_set("Settings", "Option 3", 1);
-   menu_item_enabled_set("Settings", "Option 4", 1);
+   menu_item_add("icon/fullscreen", "Fullscreen",
+		  "Fullscreen On/Off", NULL,
+		  config_option_fullscreen, ecore_evas, NULL, NULL, NULL);
+   menu_item_add("icon/themes", "Themes",
+		  "Select your theme", NULL,
+		  config_option_themes, NULL, NULL, NULL, NULL);
+   menu_item_add("icon/modes", "Modes",
+		  "Change the engine Rage uses", NULL,
+		  config_option_modes, ecore_evas, NULL, NULL, NULL);
+   menu_item_add("icon/volumes", "Volumes",
+		  "Edit your Volumes", NULL,
+		  config_option_volumes, NULL, NULL, NULL, NULL);
+   menu_item_enabled_set("Settings", "Fullscreen", 1);
+   menu_item_enabled_set("Settings", "Themes", 1);
+   menu_item_enabled_set("Settings", "Modes", 1);
+   menu_item_enabled_set("Settings", "Volumes", 1);
    menu_go();
-   menu_item_select("Option 1");
+   menu_item_select("Fullscreen");
 }
 
 typedef struct _Genre          Genre;
@@ -778,3 +774,40 @@ main_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info)
    }
 }
 
+static void
+main_get_config(void)
+{
+   /* load config */
+   char buf[4096];
+   char *eetfile;
+   int *i = malloc(sizeof(int));
+   i[0] = 0;
+
+   if (getenv("HOME"))
+      snprintf(buf, sizeof(buf), "%s/.rage", getenv("HOME"));
+   else if (getenv("TMPDIR"))
+      snprintf(buf, sizeof(buf), "%s/.rage", getenv("TMPDIR"));
+   else
+      snprintf(buf, sizeof(buf), "%s/.rage", "/tmp");
+   config = strdup(buf);
+
+   snprintf(buf, sizeof(buf), "%s/config.eet", config);
+   eetfile = strdup(buf);
+
+   if (!ecore_file_exists(eetfile))
+   {
+      if (!ecore_file_is_dir(config))
+	 ecore_file_mkpath(config);
+
+      eet_config = eet_open(eetfile, EET_FILE_MODE_WRITE);
+
+      /* write default config */
+      eet_write(eet_config, "/config/fullscreen", i, sizeof(int), 0);
+      eet_write(eet_config, "/config/theme", strdup(PACKAGE_DATA_DIR"/default.edj"), 
+	    	strlen(strdup(PACKAGE_DATA_DIR"/default.edj")), 1);
+      eet_write(eet_config, "/config/mode", i, sizeof(int), 0);
+      eet_close(eet_config);
+   }
+
+   eet_config = eet_open(eetfile, EET_FILE_MODE_READ_WRITE);
+}
diff --git a/src/bin/main.h b/src/bin/main.h
index c7be515..8cc79a0 100644
--- a/src/bin/main.h
+++ b/src/bin/main.h
@@ -9,10 +9,12 @@
 #include "mini.h"
 #include "minivid.h"
 #include "sha1.h"
+#include "conf_options.h"
 
 extern Evas *evas;
 extern char *theme;
 extern char *config;
+extern Eet_File *eet_config;
 
 #define NONE  0
 #define MENU  1
@@ -20,3 +22,4 @@ extern char *config;
 
 void main_mode_push(int mode);
 void main_mode_pop(void);
+void main_reset(void);
# Fix warning about evas_smart_new being due to be removed
# Replaced by evas_smart_class_new, as suggested
diff --git a/src/bin/e_box.c b/src/bin/e_box.c
index bdafdcd..0c9dda4 100644
--- a/src/bin/e_box.c
+++ b/src/bin/e_box.c
@@ -649,18 +649,22 @@ static void
 _e_box_smart_init(void)
 {
    if (_e_smart) return;
-   _e_smart = evas_smart_new("e_box",
-			     _e_box_smart_add,
-			     _e_box_smart_del,
-			     NULL, NULL, NULL, NULL, NULL,
-			     _e_box_smart_move,
-			     _e_box_smart_resize,
-			     _e_box_smart_show,
-			     _e_box_smart_hide,
-			     _e_box_smart_color_set,
-			     _e_box_smart_clip_set,
-			     _e_box_smart_clip_unset,
-			     NULL);
+
+   static Evas_Smart_Class _e_smart_class = {
+	"e_box",
+	2,
+	_e_box_smart_add,
+	_e_box_smart_del,
+	_e_box_smart_move,
+	_e_box_smart_resize,
+	_e_box_smart_show,
+	_e_box_smart_hide,
+	_e_box_smart_color_set,
+	_e_box_smart_clip_set,
+	_e_box_smart_clip_unset,
+	NULL, NULL };
+
+   _e_smart = evas_smart_class_new(&_e_smart_class);
 }
 
 static void
diff --git a/src/bin/e_flowlayout.c b/src/bin/e_flowlayout.c
index db51bd5..6d177b1 100644
--- a/src/bin/e_flowlayout.c
+++ b/src/bin/e_flowlayout.c
@@ -824,18 +824,22 @@ static void
 _e_flowlayout_smart_init(void)
 {
    if (_e_smart) return;
-   _e_smart = evas_smart_new("e_flowlayout",
-			     _e_flowlayout_smart_add,
-			     _e_flowlayout_smart_del,
-			     NULL, NULL, NULL, NULL, NULL,
-			     _e_flowlayout_smart_move,
-			     _e_flowlayout_smart_resize,
-			     _e_flowlayout_smart_show,
-			     _e_flowlayout_smart_hide,
-			     _e_flowlayout_smart_color_set,
-			     _e_flowlayout_smart_clip_set,
-			     _e_flowlayout_smart_clip_unset,
-			     NULL);
+
+   static Evas_Smart_Class _e_smart_class = {
+	"e_flowlayout",
+	2,
+	_e_flowlayout_smart_add,
+	_e_flowlayout_smart_del,
+	_e_flowlayout_smart_move,
+	_e_flowlayout_smart_resize,
+	_e_flowlayout_smart_show,
+	_e_flowlayout_smart_hide,
+	_e_flowlayout_smart_color_set,
+	_e_flowlayout_smart_clip_set,
+	_e_flowlayout_smart_clip_unset,
+	NULL, NULL };
+
+   _e_smart = evas_smart_class_new(&_e_smart_class);
 }
 
 static void
diff --git a/src/bin/e_layout.c b/src/bin/e_layout.c
index 7cb4dcc..0d05d0f 100644
--- a/src/bin/e_layout.c
+++ b/src/bin/e_layout.c
@@ -350,18 +350,22 @@ static void
 _e_layout_smart_init(void)
 {
    if (_e_smart) return;
-   _e_smart = evas_smart_new("e_layout",
-			     _e_layout_smart_add,
-			     _e_layout_smart_del,
-			     NULL, NULL, NULL, NULL, NULL,
-			     _e_layout_smart_move,
-			     _e_layout_smart_resize,
-			     _e_layout_smart_show,
-			     _e_layout_smart_hide,
-			     _e_layout_smart_color_set,
-			     _e_layout_smart_clip_set,
-			     _e_layout_smart_clip_unset,
-			     NULL);
+
+   static Evas_Smart_Class _e_smart_class = {
+	"e_layout",
+	2,
+	_e_layout_smart_add,
+	_e_layout_smart_del,
+	_e_layout_smart_move,
+	_e_layout_smart_resize,
+	_e_layout_smart_show,
+	_e_layout_smart_hide,
+	_e_layout_smart_color_set,
+	_e_layout_smart_clip_set,
+	_e_layout_smart_clip_unset,
+	NULL, NULL };
+
+   _e_smart = evas_smart_class_new(&_e_smart_class);
 }
 
 static void
diff --git a/src/bin/e_table.c b/src/bin/e_table.c
index c415071..f1b2bf5 100644
--- a/src/bin/e_table.c
+++ b/src/bin/e_table.c
@@ -825,18 +825,22 @@ static void
 _e_table_smart_init(void)
 {
    if (_e_smart) return;
-   _e_smart = evas_smart_new("e_table",
-			     _e_table_smart_add,
-			     _e_table_smart_del,
-			     NULL, NULL, NULL, NULL, NULL,
-			     _e_table_smart_move,
-			     _e_table_smart_resize,
-			     _e_table_smart_show,
-			     _e_table_smart_hide,
-			     _e_table_smart_color_set,
-			     _e_table_smart_clip_set,
-			     _e_table_smart_clip_unset,
-			     NULL);
+
+   static Evas_Smart_Class _e_smart_class = {
+	"e_table",
+	2,
+	_e_table_smart_add,
+	_e_table_smart_del,
+	_e_table_smart_move,
+	_e_table_smart_resize,
+	_e_table_smart_show,
+	_e_table_smart_hide,
+	_e_table_smart_color_set,
+	_e_table_smart_clip_set,
+	_e_table_smart_clip_unset,
+	NULL, NULL };
+
+   _e_smart = evas_smart_class_new(&_e_smart_class);
 }
 
 static void
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to