Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Coudoin <bcoudoin@src.gnome.org>2006-11-13 22:12:03 (GMT)
committer Bruno Coudoin <bcoudoin@src.gnome.org>2006-11-13 22:12:03 (GMT)
commit4e068d19067d89a5147bee67acddda79abbb0587 (patch)
tree635c4bfa97c3b606a7638d4515c5900337148bfe
parent6d199f6ac01d99782faa184fe79db704f229681c (diff)
changed to no more use open. open is not portable and it fails to open
* src/gcompris/properties.c: (gc_prop_config_file_get), (gc_prop_new): changed to no more use open. open is not portable and it fails to open file with utf8 characters on windows.
-rw-r--r--ChangeLog6
-rw-r--r--src/boards/python/melody.py25
-rw-r--r--src/gcompris/properties.c17
3 files changed, 26 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index a902c88..be25785 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-11-13 Bruno coudoin <bruno.coudoin@free.fr>
+
+ * src/gcompris/properties.c: (gc_prop_config_file_get),
+ (gc_prop_new): changed to no more use open. open is not portable
+ and it fails to open file with utf8 characters on windows.
+
2006-11-12 Bruno coudoin <bruno.coudoin@free.fr>
* src/gcompris/menu.c: (_add_xml_to_data): no more save translated text in the base.
diff --git a/src/boards/python/melody.py b/src/boards/python/melody.py
index 77f16f8..b7690fb 100644
--- a/src/boards/python/melody.py
+++ b/src/boards/python/melody.py
@@ -119,13 +119,14 @@ class Gcompris_melody:
def end(self):
self.cleanup()
- print("Gcompris_melody end.")
+ #print("Gcompris_melody end.")
gcompris.sound.policy_set(self.saved_policy)
gcompris.sound.resume()
def ok(self):
- print("Gcompris_melody ok.")
+ #print("Gcompris_melody ok.")
+ pass
def cleanup(self):
@@ -240,12 +241,12 @@ class Gcompris_melody:
def repeat(self):
- print("Gcompris_melody repeat.")
+ #print("Gcompris_melody repeat.")
# Important to use a timer here to keep self.timers up todate
self.timers.append(gtk.timeout_add(50, self.repeat_it))
def repeat_it(self):
- print("Gcompris_melody repeat it.")
+ #print("Gcompris_melody repeat it.")
if self.in_repeat:
return
@@ -268,11 +269,12 @@ class Gcompris_melody:
def config(self):
- print("Gcompris_melody config.")
+ #print("Gcompris_melody config.")
+ pass
#randomize the sequence and plays it one first time
def populate(self, sound_struct):
- print("Gcompris_melody populate.")
+ #print("Gcompris_melody populate.")
self.solution = []
for i in range(self.gcomprisBoard.level+2):
@@ -281,22 +283,18 @@ class Gcompris_melody:
self.timers.append(gtk.timeout_add(1300, self.repeat_it))
def key_press(self, keyval, commit_str, preedit_str):
- print("got key %i" % keyval)
+ #print("got key %i" % keyval)
# Play sounds with the keys
if ((keyval == gtk.keysyms.KP_1) or (keyval == gtk.keysyms._1)):
- print "son1"
self.sound_play(self.melodylist[self.theme][1][0])
return True
if ((keyval == gtk.keysyms.KP_2) or (keyval == gtk.keysyms._2)):
- print "son2"
self.sound_play(self.melodylist[self.theme][1][1])
return True
if ((keyval == gtk.keysyms.KP_3) or (keyval == gtk.keysyms._3)):
- print "son3"
self.sound_play(self.melodylist[self.theme][1][2])
return True
if ((keyval == gtk.keysyms.KP_4) or (keyval == gtk.keysyms._4)):
- print "son4"
self.sound_play(self.melodylist[self.theme][1][3])
return True
@@ -317,7 +315,7 @@ class Gcompris_melody:
def set_level(self, level):
- print("Gcompris_melody set level. %i" % level)
+ #print("Gcompris_melody set level. %i" % level)
self.gcomprisBoard.level=level;
self.gcomprisBoard.sublevel=1;
self.cleanup()
@@ -371,7 +369,7 @@ class Gcompris_melody:
else:
self.theme = 0
- print("New melody theme : " + self.melodylist[self.theme][0]['theme'] + ".")
+ #print("New melody theme : " + self.melodylist[self.theme][0]['theme'] + ".")
# Apply the changes
self.cleanup()
self.display_current_level()
@@ -381,6 +379,7 @@ class Gcompris_melody:
def sound_played(self, file):
#print "python sound played :", file
+ pass
def intro_cb(self, file):
#print "intro passed. go play"
diff --git a/src/gcompris/properties.c b/src/gcompris/properties.c
index 5a8d2d6..2946282 100644
--- a/src/gcompris/properties.c
+++ b/src/gcompris/properties.c
@@ -22,7 +22,6 @@
#include <glib/gstdio.h>
#include <fcntl.h>
#include <string.h>
-#include <unistd.h>
#include "gcompris.h"
@@ -126,7 +125,8 @@ gc_prop_new ()
GcomprisProperties *tmp;
char *config_file = gc_prop_config_file_get();
GScanner *scanner;
- int filefd;
+ gchar *content;
+ gsize length;
gchar *full_rootdir;
const gchar *locale;
gchar *user_dir;
@@ -197,15 +197,16 @@ gc_prop_new ()
g_warning("config_file %s", config_file);
- filefd = open(config_file, O_RDONLY);
-
- if(filefd > 0) {
+ if(g_file_get_contents(config_file,
+ &content,
+ &length,
+ NULL)) {
/* create a new scanner */
scanner = g_scanner_new(NULL);
/* set up the scanner to read from the file */
- g_scanner_input_file(scanner, filefd);
+ g_scanner_input_text(scanner, content, length);
/* while the next token is something else other than end of file */
while(g_scanner_peek_next_token(scanner) != G_TOKEN_EOF) {
@@ -279,9 +280,7 @@ gc_prop_new ()
/* destroy the scanner */
g_scanner_destroy(scanner);
-
- close(filefd);
-
+ g_free(content);
}
/*