Enlightenment CVS committal

Author  : raster
Project : e17
Module  : apps/e

Dir     : e17/apps/e/src/bin


Modified Files:
        e_config.c e_config.h 


Log Message:


let people know when config changed and e17 auto-upgrades your config (the
old one is useless anyway)

===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_config.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -3 -r1.39 -r1.40
--- e_config.c  7 May 2005 13:50:38 -0000       1.39
+++ e_config.c  7 May 2005 17:26:54 -0000       1.40
@@ -18,6 +18,8 @@
 
 /* local subsystem functions */
 static void _e_config_save_cb(void *data);
+static void _e_config_free(void);
+static int  _e_config_cb_timer(void *data);
 
 /* local subsystem globals */
 static Ecore_Job *_e_config_save_job = NULL;
@@ -97,6 +99,7 @@
 #undef D
 #define T E_Config
 #define D _e_config_edd
+   E_CONFIG_VAL(D, T, config_version, INT);
    E_CONFIG_VAL(D, T, desktop_default_background, STR);
    E_CONFIG_VAL(D, T, menus_scroll_speed, DOUBLE);
    E_CONFIG_VAL(D, T, menus_fast_mouse_move_thresthold, DOUBLE);
@@ -118,10 +121,41 @@
    E_CONFIG_LIST(D, T, key_bindings, _e_config_bindings_key_edd);
 
    e_config = e_config_domain_load("e", _e_config_edd);
+   if (e_config)
+     {
+       if (e_config->config_version < E_CONFIG_FILE_VERSION)
+         {
+            /* your config is too old - need new defaults */
+            _e_config_free();
+            ecore_timer_add(1.0, _e_config_cb_timer,
+                            "Configuration data needed upgrading. Your old 
configuration\n"
+                            "has been wiped and a new set of defaults 
initialized. This\n"
+                            "will happen regularly during development, so 
don't report a\n"
+                            "bug. This simply means Enlightenment needs new 
confiugration\n"
+                            "data by default for usable functionality that 
your old\n"
+                            "configuration simply lacks. This new set of 
defaults will fix\n"
+                            "that by adding it in. You can re-configure things 
now to your\n"
+                            "liking. Sorry for the hiccup in your 
confiugration.\n");
+         }
+       else if (e_config->config_version > E_CONFIG_FILE_VERSION)
+         {
+            /* your config is too new - what the fuck??? */
+            _e_config_free();
+            ecore_timer_add(1.0, _e_config_cb_timer,
+                            "Your configuration is NEWER than Enlightenment. 
This is very\n"
+                            "strange. This should not happen unless you 
downgraded\n"
+                            "Enlightenment or copied the configuration from a 
place where\n"
+                            "a newer version of Enlightenment was running. 
This is bad and\n"
+                            "as a precaution your confiugration has been now 
restored to\n"
+                            "defaults. Sorry for the inconvenience.\n");
+         }
+     }
+   
    if (!e_config)
      {
        /* DEFAULT CONFIG */
        e_config = E_NEW(E_Config, 1);
+       e_config->config_version = E_CONFIG_FILE_VERSION;
        e_config->desktop_default_background = 
strdup(PACKAGE_DATA_DIR"/data/themes/default.edj");
        e_config->menus_scroll_speed = 1000.0;
        e_config->menus_fast_mouse_move_thresthold = 300.0;
@@ -623,72 +657,6 @@
 int
 e_config_shutdown(void)
 {
-   if (e_config)
-     {
-       while (e_config->modules)
-         {
-            E_Config_Module *em;
-
-            em = e_config->modules->data;
-            e_config->modules = evas_list_remove_list(e_config->modules, 
e_config->modules);
-            E_FREE(em->name);
-            E_FREE(em);
-         }
-       while (e_config->font_fallbacks)
-         {
-            E_Font_Fallback *eff;
-            
-            eff = e_config->font_fallbacks->data;
-            e_config->font_fallbacks = 
evas_list_remove_list(e_config->font_fallbacks, e_config->font_fallbacks);
-            E_FREE(eff->name);
-            E_FREE(eff);
-         }
-       while (e_config->font_defaults)
-         {
-            E_Font_Default *efd;
-            
-            efd = e_config->font_defaults->data;
-            e_config->font_defaults = 
evas_list_remove_list(e_config->font_defaults, e_config->font_defaults);
-            E_FREE(efd->text_class);
-            E_FREE(efd->font);
-            E_FREE(efd);
-         }
-       while (e_config->themes)
-         {
-            E_Config_Theme *et;
-            
-            et = e_config->themes->data;
-            e_config->themes = evas_list_remove_list(e_config->themes, 
e_config->themes);
-            E_FREE(et->category);
-            E_FREE(et->file);
-            E_FREE(et);
-         }
-       while (e_config->mouse_bindings)
-         {
-            E_Config_Binding_Mouse *eb;
-            
-            eb = e_config->mouse_bindings->data;
-            e_config->mouse_bindings  = 
evas_list_remove_list(e_config->mouse_bindings, e_config->mouse_bindings);
-            E_FREE(eb->action);
-            E_FREE(eb->params);
-            E_FREE(eb);
-         }
-       while (e_config->key_bindings)
-         {
-            E_Config_Binding_Key *eb;
-            
-            eb = e_config->key_bindings->data;
-            e_config->key_bindings  = 
evas_list_remove_list(e_config->key_bindings, e_config->key_bindings);
-            E_FREE(eb->key);
-            E_FREE(eb->action);
-            E_FREE(eb->params);
-            E_FREE(eb);
-         }
-       
-       E_FREE(e_config->desktop_default_background);
-       E_FREE(e_config->language);
-       E_FREE(e_config);
-     }
    E_CONFIG_DD_FREE(_e_config_edd);
    E_CONFIG_DD_FREE(_e_config_module_edd);
    E_CONFIG_DD_FREE(_e_config_font_default_edd);
@@ -817,3 +785,82 @@
    e_config_domain_save("e", _e_config_edd, e_config);
    _e_config_save_job = NULL;
 }
+
+static void
+_e_config_free(void)
+{
+   if (e_config)
+     {
+       while (e_config->modules)
+         {
+            E_Config_Module *em;
+
+            em = e_config->modules->data;
+            e_config->modules = evas_list_remove_list(e_config->modules, 
e_config->modules);
+            E_FREE(em->name);
+            E_FREE(em);
+         }
+       while (e_config->font_fallbacks)
+         {
+            E_Font_Fallback *eff;
+            
+            eff = e_config->font_fallbacks->data;
+            e_config->font_fallbacks = 
evas_list_remove_list(e_config->font_fallbacks, e_config->font_fallbacks);
+            E_FREE(eff->name);
+            E_FREE(eff);
+         }
+       while (e_config->font_defaults)
+         {
+            E_Font_Default *efd;
+            
+            efd = e_config->font_defaults->data;
+            e_config->font_defaults = 
evas_list_remove_list(e_config->font_defaults, e_config->font_defaults);
+            E_FREE(efd->text_class);
+            E_FREE(efd->font);
+            E_FREE(efd);
+         }
+       while (e_config->themes)
+         {
+            E_Config_Theme *et;
+            
+            et = e_config->themes->data;
+            e_config->themes = evas_list_remove_list(e_config->themes, 
e_config->themes);
+            E_FREE(et->category);
+            E_FREE(et->file);
+            E_FREE(et);
+         }
+       while (e_config->mouse_bindings)
+         {
+            E_Config_Binding_Mouse *eb;
+            
+            eb = e_config->mouse_bindings->data;
+            e_config->mouse_bindings  = 
evas_list_remove_list(e_config->mouse_bindings, e_config->mouse_bindings);
+            E_FREE(eb->action);
+            E_FREE(eb->params);
+            E_FREE(eb);
+         }
+       while (e_config->key_bindings)
+         {
+            E_Config_Binding_Key *eb;
+            
+            eb = e_config->key_bindings->data;
+            e_config->key_bindings  = 
evas_list_remove_list(e_config->key_bindings, e_config->key_bindings);
+            E_FREE(eb->key);
+            E_FREE(eb->action);
+            E_FREE(eb->params);
+            E_FREE(eb);
+         }
+       
+       E_FREE(e_config->desktop_default_background);
+       E_FREE(e_config->language);
+       E_FREE(e_config);
+     }
+}
+
+static int
+_e_config_cb_timer(void *data)
+{
+   e_error_dialog_show(_("Configuration Upgraded"),
+                        _(data));
+   return 0;
+}
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_config.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -3 -r1.18 -r1.19
--- e_config.h  7 May 2005 13:50:38 -0000       1.18
+++ e_config.h  7 May 2005 17:27:03 -0000       1.19
@@ -42,12 +42,19 @@
 #ifndef E_CONFIG_H
 #define E_CONFIG_H
 
+/* increment this whenever we change config enough that you need new 
+ * defaults for e to work - started at 100 when we introduced this config
+ * versioning feature
+ */
+#define E_CONFIG_FILE_VERSION 100
+
 #define E_EVAS_ENGINE_DEFAULT      0
 #define E_EVAS_ENGINE_SOFTWARE_X11 1
 #define E_EVAS_ENGINE_GL_X11       2
 
 struct _E_Config
 {
+   int         config_version;
    char       *desktop_default_background;
    double      menus_scroll_speed;
    double      menus_fast_mouse_move_thresthold;




-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4
opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to