Enlightenment CVS committal Author : kwo Project : e16 Module : e
Dir : e16/e/src Modified Files: E.h backgrounds.c buttons.c config.c desktops.c session.c Log Message: Fix button state saving. Save background and button configurations separately. =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/E.h,v retrieving revision 1.382 retrieving revision 1.383 diff -u -3 -r1.382 -r1.383 --- E.h 2 Mar 2005 23:23:43 -0000 1.382 +++ E.h 5 Mar 2005 12:19:46 -0000 1.383 @@ -1206,7 +1206,6 @@ /* backgrounds.c */ int BackgroundsConfigLoad(FILE * fs); -int BackgroundsConfigSave(FILE * fs); char *BackgroundGetUniqueString(Background * bg); void BackgroundPixmapFree(Background * bg); void BackgroundImagesFree(Background * bg, int free_pmap); @@ -1259,7 +1258,6 @@ /* buttons.c */ int ButtonsConfigLoad(FILE * fs); -int ButtonsConfigSave(FILE * fs); Button *ButtonCreate(const char *name, int id, ImageClass * ic, ActionClass * aclass, TextClass * tclass, char *label, char ontop, int flags, int minw, @@ -1332,8 +1330,8 @@ int pp); int ConfigFileLoad(const char *name, const char *themepath, int (*parse) (FILE * fs), int preparse); +int ConfigFileRead(FILE * fs); int ThemeConfigLoad(void); -void SaveUserControlConfig(void); void RecoverUserConfig(void); /* coords.c */ =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/backgrounds.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -3 -r1.17 -r1.18 --- backgrounds.c 26 Feb 2005 16:40:36 -0000 1.17 +++ backgrounds.c 5 Mar 2005 12:19:47 -0000 1.18 @@ -1113,16 +1113,38 @@ return err; } -int -BackgroundsConfigSave(FILE * fs) +static void +BackgroundsConfigLoadUser(void) { + char s[4096]; + + Esnprintf(s, sizeof(s), "%s.backgrounds", EGetSavePrefix()); + if (ConfigFileLoad(s, NULL, ConfigFileRead, 0)) + { + /* FIXME - Keep around a bit, and then remove */ + Esnprintf(s, sizeof(s), "%s.misc", EGetSavePrefix()); + Eprintf("Fallback - loading %s\n", s); + ConfigFileLoad(s, NULL, ConfigFileRead, 0); + } +} + +static void +BackgroundsConfigSave(void) +{ + char s[FILEPATH_LEN_MAX], st[FILEPATH_LEN_MAX]; + FILE *fs; int i, num; Background **bglist; int j, b, r, g; bglist = (Background **) ListItemType(&num, LIST_TYPE_BACKGROUND); if (num <= 0) - return 0; + return; + + Etmp(st); + fs = fopen(st, "w"); + if (!fs) + return; for (i = num - 1; i >= 0; i--) { @@ -1186,9 +1208,13 @@ fprintf(fs, "1000\n"); } - Efree(bglist); - return 0; + fclose(fs); + + Esnprintf(s, sizeof(s), "%s.backgrounds", EGetSavePrefix()); + E_mv(st, s); + + Efree(bglist); } /* @@ -1267,10 +1293,19 @@ BackgroundCreate("NONE", NULL, NULL, 0, 0, 0, 0, 0, 0, NULL, 0, 0, 0, 0, 0); break; + + case ESIGNAL_CONFIGURE: + BackgroundsConfigLoadUser(); + break; + case ESIGNAL_START: DoIn("BACKGROUND_ACCOUNTING_TIMEOUT", 30.0, BackgroundsTimeout, 0, NULL); break; + + case ESIGNAL_EXIT: + BackgroundsConfigSave(); + break; } } =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/buttons.c,v retrieving revision 1.50 retrieving revision 1.51 diff -u -3 -r1.50 -r1.51 --- buttons.c 27 Feb 2005 18:55:18 -0000 1.50 +++ buttons.c 5 Mar 2005 12:19:47 -0000 1.51 @@ -66,7 +66,8 @@ static struct { Button *button; -} Mode_button; + char loading_user; +} Mode_buttons; static void ButtonHandleEvents(XEvent * ev, void *btn); @@ -650,7 +651,7 @@ Window win = ev->xbutton.window; ActionClass *ac; - Mode_button.button = b; + Mode_buttons.button = b; GrabPointerSet(win, ECSR_GRAB, 0); @@ -695,8 +696,8 @@ b->left = 0; if (Mode.mode == MODE_BUTTONDRAG) - ButtonDragEnd(Mode_button.button); - Mode_button.button = NULL; + ButtonDragEnd(Mode_buttons.button); + Mode_buttons.button = NULL; GrabPointerRelease(); } @@ -860,7 +861,7 @@ switch (i1) { case CONFIG_CLOSE: - if (!pbt) + if (!pbt && !Mode_buttons.loading_user) { bt = ButtonCreate(name, 0, ic, ac, tc, label, ontop, flags, minw, maxw, minh, maxh, xo, yo, xa, xr, @@ -876,9 +877,13 @@ pbt->tclass = tc; break; case BUTTON_LABEL: + _EFREE(label); label = Estrdup(atword(s, 2)); if (pbt) - pbt->label = label; + { + _EFREE(pbt->label); + pbt->label = label; + } break; case BORDERPART_ONTOP: ontop = atoi(s2); @@ -887,8 +892,7 @@ break; case CONFIG_CLASSNAME: case BUTTON_NAME: - if (name) - Efree(name); + _EFREE(name); name = Estrdup(s2); pbt = FindItem(name, 0, LIST_FINDBY_NAME, LIST_TYPE_BUTTON); break; @@ -1011,23 +1015,41 @@ err = -1; done: - if (name) - Efree(name); + _EFREE(name); + _EFREE(label); return err; } -int -ButtonsConfigSave(FILE * fs) +static void +ButtonsConfigLoadUser(void) { -#if 0 + char s[4096]; + + Esnprintf(s, sizeof(s), "%s.buttons", EGetSavePrefix()); + + Mode_buttons.loading_user = 1; + ConfigFileLoad(s, NULL, ConfigFileRead, 0); + Mode_buttons.loading_user = 0; +} + +static void +ButtonsConfigSave(void) +{ + char s[FILEPATH_LEN_MAX], st[FILEPATH_LEN_MAX]; + FILE *fs; int i, num; Button **blst; int flags; blst = (Button **) ListItemTypeID(&num, LIST_TYPE_BUTTON, 0); if (!blst) - return 0; + return; + + Etmp(st); + fs = fopen(st, "w"); + if (!fs) + return; for (i = 0; i < num; i++) { @@ -1080,12 +1102,13 @@ } fprintf(fs, "1000\n"); } - Efree(blst); -#else - fs = NULL; -#endif - return 0; + fclose(fs); + + Esnprintf(s, sizeof(s), "%s.buttons", EGetSavePrefix()); + E_mv(st, s); + + Efree(blst); } /* @@ -1097,7 +1120,16 @@ { switch (sig) { - default: + case ESIGNAL_INIT: + memset(&Mode_buttons, 0, sizeof(Mode_buttons)); + break; + + case ESIGNAL_CONFIGURE: + ButtonsConfigLoadUser(); + break; + + case ESIGNAL_EXIT: + ButtonsConfigSave(); break; } } @@ -1222,8 +1254,8 @@ } else if (!strncmp(cmd, "move", 2)) { - if (Mode_button.button) - ButtonDragStart(Mode_button.button); + if (Mode_buttons.button) + ButtonDragStart(Mode_buttons.button); } } =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/config.c,v retrieving revision 1.128 retrieving revision 1.129 diff -u -3 -r1.128 -r1.129 --- config.c 27 Feb 2005 14:42:28 -0000 1.128 +++ config.c 5 Mar 2005 12:19:47 -0000 1.129 @@ -234,7 +234,7 @@ } /* Split the process of finding the file from the process of loading it */ -static int +int ConfigFileRead(FILE * fs) { int err; @@ -478,6 +478,7 @@ file = ConfigFileFind(name, themepath, preparse); if (!file) goto done; + fs = fopen(file, "r"); Efree(file); if (!fs) @@ -548,48 +549,16 @@ if (p) ProgressbarDestroy(p); - /* No longer needed */ + /* Font mappings no longer needed */ FontConfigUnload(); /* Loose ends... */ - Esnprintf(s, sizeof(s), "%s.misc", EGetSavePrefix()); - ConfigFileLoad(s, NULL, ConfigFileRead, 0); - BordersSetupFallback(); return 0; } void -SaveUserControlConfig(void) -{ - char s[4096], s2[4096]; - FILE *fs; - - /* Save the configuration parameters */ - ConfigurationSave(); - - /* Save odd bits */ - Etmp(s2); - fs = fopen(s2, "w"); - if (!fs) - return; - - fprintf(fs, "1001 0\n"); - - BackgroundsConfigSave(fs); - ButtonsConfigSave(fs); - - fclose(fs); - - Esnprintf(s, sizeof(s), "%s.misc", EGetSavePrefix()); - E_mv(s2, s); - if (!isfile(s)) - Alert(_("There was an error saving your autosave data - filing\n" - "system problems.\n")); -} - -void RecoverUserConfig(void) { int save; =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/desktops.c,v retrieving revision 1.127 retrieving revision 1.128 diff -u -3 -r1.127 -r1.128 --- desktops.c 27 Feb 2005 14:42:40 -0000 1.127 +++ desktops.c 5 Mar 2005 12:19:48 -0000 1.128 @@ -1666,8 +1666,10 @@ /* toss down the dragbar and related */ DesksControlsCreate(); DesksControlsShow(); + break; - /* then draw all the buttons that belong on the desktop */ + case ESIGNAL_START: + /* Draw all the buttons that belong on the desktop */ DeskShowButtons(); break; } =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/session.c,v retrieving revision 1.92 retrieving revision 1.93 diff -u -3 -r1.92 -r1.93 --- session.c 4 Mar 2005 17:59:27 -0000 1.92 +++ session.c 5 Mar 2005 12:19:48 -0000 1.93 @@ -304,7 +304,8 @@ Real_SaveSnapInfo(0, NULL); - SaveUserControlConfig(); + /* Save the configuration parameters */ + ConfigurationSave(); } #ifdef HAVE_X11_SM_SMLIB_H ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs