[Tux4kids-commits] r1406 - in tuxtype/branches/gsoc-sarah: doc src
Sarah Frisk
fou_fou-guest at alioth.debian.org
Mon Aug 10 21:31:49 UTC 2009
Author: fou_fou-guest
Date: 2009-08-10 21:31:49 +0000 (Mon, 10 Aug 2009)
New Revision: 1406
Modified:
tuxtype/branches/gsoc-sarah/doc/ChangeLog
tuxtype/branches/gsoc-sarah/src/editor.c
Log:
Screen updated after adding/removing a file
Modified: tuxtype/branches/gsoc-sarah/doc/ChangeLog
===================================================================
--- tuxtype/branches/gsoc-sarah/doc/ChangeLog 2009-08-10 06:42:48 UTC (rev 1405)
+++ tuxtype/branches/gsoc-sarah/doc/ChangeLog 2009-08-10 21:31:49 UTC (rev 1406)
@@ -1,3 +1,7 @@
+10 Aug 2009 (svn.debian.org/tux4kids -revision 1406)
+[Sarah Frisk <ssfrisk at gmail.com> }
+ -Screen is redrawn properly after a wordlist is added/deleated
+
9 Aug 2009 (svn.debian.org/tux4kids -revision 1405)
[Sarah Frisk <ssfrisk at gmail.com> }
-Bus error bug is fixed. Final cosmetic issues should be fixed tomorrow.
Modified: tuxtype/branches/gsoc-sarah/src/editor.c
===================================================================
--- tuxtype/branches/gsoc-sarah/src/editor.c 2009-08-10 06:42:48 UTC (rev 1405)
+++ tuxtype/branches/gsoc-sarah/src/editor.c 2009-08-10 21:31:49 UTC (rev 1406)
@@ -43,6 +43,7 @@
int i;
int redraw = 0;
int delete = 0;
+ int change = 0;
//Arrays for the list of editable word lists:
@@ -218,10 +219,8 @@
case SDL_MOUSEBUTTONDOWN:
if (inRect(button_rect[New], event.button.x, event.button.y))
{
- CreateNewWordList();
- fprintf(stderr, "Check Four\n");
- redraw = 1;
- fprintf(stderr, "Check Five\n");
+ change = CreateNewWordList();
+
}
if (inRect(button_rect[Remove], event.button.x, event.button.y))
@@ -249,8 +248,8 @@
else
{
//do this bit of code
- delete = RemoveList(file_names[loc]);
- redraw = 1;
+ change = RemoveList(file_names[loc]);
+ delete = 0;
}
break;
}
@@ -302,8 +301,71 @@
}
} //End of user event handling
+ /* reload the list if it has been changed */
+ if (change)
+ {
+ num_lists = 0;
+ //Try to open directory for modifiable word lists:
+ sprintf(fn , "%s" , settings.var_data_path);
+ lists_dir = opendir(fn);
+ if (!lists_dir)
+ {
+ fprintf(stderr, "ChooseListToEdit() - cannot open custom word list directory!\n");
+ return;
+ }
+
+ //Now scan through directory and gather file names and list titles:
+ while (1)
+ {
+ list_dirent = readdir(lists_dir);
+ if (!list_dirent)
+ break;
+
+ /* we ignore any hidden file and CVS */
+
+ if (list_dirent->d_name[0] == '.')
+ continue;
+
+ if (strcmp("CVS", list_dirent->d_name) == 0)
+ continue;
+
+ snprintf(fn, FNLEN, "%s/%s" , settings.var_data_path, list_dirent->d_name);
+
+ /* CheckFile() returns 2 if dir, 1 if file, 0 if neither: */
+ if (CheckFile(fn) == 1)
+ {
+ /* We know it opens safely because CheckFile() returned 1 */
+ fp = fopen(fn,"r");
+ /* HACK: we should get the names from file :) */
+ if (EOF ==fscanf(fp, "%[^\n]\n", list_titles[num_lists]))
+ continue;
+ /* Make sure list title is capitalized: */
+ list_titles[num_lists][0] = toupper(list_titles[num_lists][0]);
+ fclose(fp);
+ strncpy(file_names[num_lists++], list_dirent->d_name, FNLEN-1);
+ }
+ }
+ closedir(lists_dir);
+
+
+ // white_titles_surf[MAX_WORD_LISTS] = {NULL};
+ // yellow_titles_surf[MAX_WORD_LISTS] = {NULL};
+
+
+ /* Render SDL_Surfaces of title text for later blitting: */
+ for (i = 0; i < num_lists; i++)
+ {
+ white_titles_surf[i] = BlackOutline(list_titles[i], DEFAULT_MENU_FONT_SIZE, &white);
+ yellow_titles_surf[i] = BlackOutline(list_titles[i], DEFAULT_MENU_FONT_SIZE, &yellow);
+ }
+ change = 0;
+ redraw = 1;
+ }
+
+
+
/* Redraw if a different menu entry is selected: */
if (old_loc != loc || redraw == 1)
{
@@ -729,7 +791,7 @@
/** Private functions **/
-void CreateNewWordList(void)
+int CreateNewWordList(void)
{
fprintf(stderr, "Creating a New Word List!!!");
int stop = 0;
@@ -959,7 +1021,7 @@
fprintf(stderr, "Check Three\n");
// OK = CANCEL = OK_button = CANCEL_button = NULL;
-//return 0;
+ return save;
}
int ChooseRemoveList(void)
@@ -1060,11 +1122,17 @@
if (remove(fn) != 0 )
+ {
fprintf(stderr, "Error deleting file\n");
+ return 0; //no change
+ }
else
+ {
fprintf(stderr, "File successfully deleted\n");
+ return 1; //change made
+ }
- return 0;
+
}
More information about the Tux4kids-commits
mailing list