Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Coudoin <bruno.coudoin@free.fr>2009-10-25 17:39:39 (GMT)
committer Bruno Coudoin <bruno.coudoin@free.fr>2009-10-25 17:39:39 (GMT)
commit30891ec192e1b38a8844ce7cf50806a03677f4a1 (patch)
treee08a4574f5e84810b736c3baa3c274fea5fe5c09
parentb4a157d08a827335065029bd375a412eabd3d5c5 (diff)
Added a parameter to file selector to pass a user data.
Fixed file selector, ok case was not working.
-rw-r--r--src/anim-activity/anim.py14
-rw-r--r--src/boards/py-mod-gcompris.c49
-rw-r--r--src/gcompris/file_selector.c42
-rw-r--r--src/gcompris/gcompris.h17
-rw-r--r--src/goocanvas/src/goocanvassvg.c13
5 files changed, 77 insertions, 58 deletions
diff --git a/src/anim-activity/anim.py b/src/anim-activity/anim.py
index 9645545..c1229c8 100644
--- a/src/anim-activity/anim.py
+++ b/src/anim-activity/anim.py
@@ -224,11 +224,11 @@ class Gcompris_anim:
if (keyval == gtk.keysyms.F1):
gcompris.file_selector_save( self.gcomprisBoard,
self.selector_section, self.file_type,
- general_save)
+ general_save, self)
elif (keyval == gtk.keysyms.F2):
gcompris.file_selector_load( self.gcomprisBoard,
self.selector_section, self.file_type,
- general_restore)
+ general_restore, self)
elif (keyval == gtk.keysyms.Left):
self.timeline.previous()
return True
@@ -375,15 +375,16 @@ class Gcompris_anim:
gcompris.sound.play_ogg("sounds/bleep.wav")
# Some button have instant effects
if (self.tools[tool][0] == "SAVE"):
+ print "SAVE"
gcompris.file_selector_save( self.gcomprisBoard,
self.selector_section, self.file_type,
- general_save)
+ general_save, self)
return False
elif (self.tools[tool][0] == "LOAD"):
gcompris.file_selector_load( self.gcomprisBoard,
self.selector_section, self.file_type,
- general_restore)
+ general_restore, self)
return False
elif (self.tools[tool][0] == "IMAGE"):
@@ -741,12 +742,11 @@ class Gcompris_anim:
# GLOBAL functions
#
###############################################
-def general_save(filename, filetype):
- global fles
+def general_save(filename, filetype, fles):
print "filename=%s filetype=%s" %(filename, filetype)
-def general_restore(filename, filetype):
+def general_restore(filename, filetype, fles):
print "general_restore : ", filename, " type ",filetype
diff --git a/src/boards/py-mod-gcompris.c b/src/boards/py-mod-gcompris.c
index 368c1f4..cfa4044 100644
--- a/src/boards/py-mod-gcompris.c
+++ b/src/boards/py-mod-gcompris.c
@@ -528,15 +528,16 @@ py_gc_selector_images_stop(PyObject* self, PyObject* args)
/* Some functions and variables needed to get the file selector working */
static PyObject* pyFileSelectorCallBackFunc = NULL;
-void pyFileSelectorCallBack(gchar* file, char* file_type){
+void pyFileSelectorCallBack(gchar* file, char* file_type, void *user_context){
PyObject* args;
PyObject* result;
if(pyFileSelectorCallBackFunc==NULL) return;
/* Build arguments */
- args = PyTuple_New(2);
+ args = PyTuple_New(3);
PyTuple_SetItem(args, 0, Py_BuildValue("s", file));
PyTuple_SetItem(args, 1, Py_BuildValue("s", file_type));
+ PyTuple_SetItem(args, 2, Py_BuildValue("O", user_context));
result = PyObject_CallObject(pyFileSelectorCallBackFunc, args);
if(result==NULL){
PyErr_Print();
@@ -550,7 +551,8 @@ void pyFileSelectorCallBack(gchar* file, char* file_type){
/* void gc_selector_file_load(GcomprisBoard *gcomprisBoard,
gchar *rootdir,
gchar *file_types, (A Comma separated text explaining the different file types)
- FileSelectorCallBack fscb);
+ FileSelectorCallBack fscb,
+ void *pyUserContext);
*/
static PyObject*
py_gc_selector_file_load(PyObject* self, PyObject* args){
@@ -559,14 +561,16 @@ py_gc_selector_file_load(PyObject* self, PyObject* args){
PyObject* pyCallback;
gchar* rootdir;
gchar* file_types;
+ void *pyUserContext;
/* Parse arguments */
if(!PyArg_ParseTuple(args,
- "OssO:gc_selector_file_load",
+ "OssOO:gc_selector_file_load",
&pyGcomprisBoard,
&rootdir,
&file_types,
- &pyCallback))
+ &pyCallback,
+ &pyUserContext))
return NULL;
if(!PyCallable_Check(pyCallback)) return NULL;
cGcomprisBoard = ((pyGcomprisBoardObject*) pyGcomprisBoard)->cdata;
@@ -574,9 +578,10 @@ py_gc_selector_file_load(PyObject* self, PyObject* args){
/* Call the corresponding C function */
pyFileSelectorCallBackFunc = pyCallback;
gc_selector_file_load(cGcomprisBoard,
- rootdir,
- file_types,
- pyFileSelectorCallBack);
+ rootdir,
+ file_types,
+ pyFileSelectorCallBack,
+ pyUserContext);
/* Create and return the result */
Py_INCREF(Py_None);
@@ -585,9 +590,10 @@ py_gc_selector_file_load(PyObject* self, PyObject* args){
/* void gc_selector_file_save(GcomprisBoard *gcomprisBoard,
- gchar *rootdir,
- gchar *file_types, (A Comma separated text explaining the different file types)
- FileSelectorCallBack fscb);
+ gchar *rootdir,
+ gchar *file_types, (A Comma separated text explaining the different file types)
+ FileSelectorCallBack fscb,
+ void *user_context);
*/
static PyObject*
py_gc_selector_file_save(PyObject* self, PyObject* args){
@@ -596,14 +602,16 @@ py_gc_selector_file_save(PyObject* self, PyObject* args){
PyObject* pyCallback;
gchar* rootdir;
char* file_types;
+ void *pyUserContext;
/* Parse arguments */
if(!PyArg_ParseTuple(args,
- "OssO:gc_selector_file_save",
+ "OssOO:gc_selector_file_save",
&pyGcomprisBoard,
&rootdir,
&file_types,
- &pyCallback))
+ &pyCallback,
+ &pyUserContext))
return NULL;
if(!PyCallable_Check(pyCallback)) return NULL;
cGcomprisBoard = ((pyGcomprisBoardObject*) pyGcomprisBoard)->cdata;
@@ -611,9 +619,10 @@ py_gc_selector_file_save(PyObject* self, PyObject* args){
/* Call the corresponding C function */
pyFileSelectorCallBackFunc = pyCallback;
gc_selector_file_save(cGcomprisBoard,
- rootdir,
- file_types,
- pyFileSelectorCallBack);
+ rootdir,
+ file_types,
+ pyFileSelectorCallBack,
+ pyUserContext);
/* Create and return the result */
Py_INCREF(Py_None);
@@ -1286,9 +1295,9 @@ py_gc_board_config_spin_int(PyObject* self, PyObject* args)
/* Parse arguments */
if(!PyArg_ParseTuple(args, "Ossiiii:gc_board_config_radio_buttons", &py_bconf, &label, &key, &min, &max, &step, &init))
return NULL;
-
+
bconf = (pyGcomprisBoardConfigObject*)py_bconf;
-
+
return (PyObject *)pygobject_new((GObject*) \
gc_board_config_spin_int(bconf->cdata, (const gchar *)label,
key,
@@ -1305,7 +1314,7 @@ static PyObject*
py_gc_board_conf_separator(PyObject* self, PyObject* args)
{
PyObject *py_bconf;
- pyGcomprisBoardConfigObject * bconf;
+ pyGcomprisBoardConfigObject * bconf;
/* Parse arguments */
if(!PyArg_ParseTuple(args, "O:gc_board_conf_separator", &py_bconf))
@@ -1330,7 +1339,7 @@ py_gc_board_config_combo_locales(PyObject* self, PyObject* args)
if(!PyArg_ParseTuple(args, "Os:gc_board_config_combo_locales", &py_bconf, &init))
return NULL;
bconf = (pyGcomprisBoardConfigObject*)py_bconf;
-
+
return (PyObject *)pygobject_new((GObject*) \
gc_board_config_combo_locales(bconf->cdata, init));
}
diff --git a/src/gcompris/file_selector.c b/src/gcompris/file_selector.c
index f7fbd19..44f6b13 100644
--- a/src/gcompris/file_selector.c
+++ b/src/gcompris/file_selector.c
@@ -52,7 +52,8 @@ static int display_file_selector(int mode,
GcomprisBoard *gcomprisBoard,
gchar *rootdir,
gchar *file_types,
- FileSelectorCallBack iscb);
+ FileSelectorCallBack iscb,
+ void *user_context);
static void entry_enter_callback( GtkWidget *widget,
GtkWidget *entry );
static gboolean file_selector_displayed = FALSE;
@@ -64,6 +65,7 @@ static FileSelectorCallBack fileSelectorCallBack = NULL;
static GtkWidget *gtk_combo_filetypes = NULL;
static gchar *current_rootdir = NULL;
+static void *current_user_context = NULL;
static GtkWidget *widget_entry = NULL;
/* Represent the limits of control area */
@@ -96,19 +98,21 @@ static guint32 directory_label_y;
*/
void gc_selector_file_save (GcomprisBoard *gcomprisBoard, gchar *rootdir,
- gchar *file_exts,
- FileSelectorCallBack iscb)
+ gchar *file_exts,
+ FileSelectorCallBack iscb,
+ void *user_context)
{
display_file_selector(MODE_SAVE, gcomprisBoard, rootdir, file_exts,
- iscb);
+ iscb, user_context);
}
void gc_selector_file_load (GcomprisBoard *gcomprisBoard, gchar *rootdir,
- gchar *file_exts,
- FileSelectorCallBack iscb)
+ gchar *file_exts,
+ FileSelectorCallBack iscb,
+ void *user_context)
{
display_file_selector(MODE_LOAD, gcomprisBoard, rootdir, file_exts,
- iscb);
+ iscb, user_context);
}
/*
@@ -149,7 +153,8 @@ display_file_selector(int the_mode,
GcomprisBoard *gcomprisBoard,
gchar *rootdir,
gchar *file_exts,
- FileSelectorCallBack iscb)
+ FileSelectorCallBack iscb,
+ void *user_context)
{
GooCanvasItem *item;
gchar *name = NULL;
@@ -251,7 +256,7 @@ display_file_selector(int the_mode,
"#BUTTON_TEXT",
(mode==MODE_LOAD ? _("LOAD") : _("SAVE")),
(GtkSignalFunc) item_event_file_selector,
- "/cancel/");
+ "/ok/");
file_selector_displayed = TRUE;
@@ -259,6 +264,7 @@ display_file_selector(int the_mode,
gc_util_create_rootdir(full_rootdir);
current_rootdir = full_rootdir;
+ current_user_context = user_context;
display_files(rootitem, full_rootdir);
@@ -599,17 +605,17 @@ item_event_file_selector (GooCanvasItem *item,
gtk_entry_get_text(GTK_ENTRY(widget_entry)),
(file_type ? file_type : "") );
- /* Callback with the proper params */
- fileSelectorCallBack(result, file_type);
+ /* Callback with the proper params */
+ fileSelectorCallBack(result, file_type, current_user_context);
- if(file_type)
- g_free(file_type);
+ if(file_type)
+ g_free(file_type);
- /* DO NOT FREE RESULT OR PYTHON SIDE WILL BE IN TROUBLE */
- /* ADDENDUM: DOES NOT HURT ANYMORE, WHY ? */
- if(result)
- g_free(result);
- }
+ /* DO NOT FREE RESULT OR PYTHON SIDE WILL BE IN TROUBLE */
+ /* ADDENDUM: DOES NOT HURT ANYMORE, WHY ? */
+ if(result)
+ g_free(result);
+ }
gc_selector_file_stop();
}
else if(!strcmp(data, "/cancel/"))
diff --git a/src/gcompris/gcompris.h b/src/gcompris/gcompris.h
index 063e428..61819f7 100644
--- a/src/gcompris/gcompris.h
+++ b/src/gcompris/gcompris.h
@@ -174,15 +174,18 @@ void gc_selector_images_start (GcomprisBoard *gcomprisBoard,
ImageSelectorCallBack imscb);
void gc_selector_images_stop (void);
-typedef void (*FileSelectorCallBack) (gchar *file, gchar *file_type); /* file_type is one string from file_types in the save */
+typedef void (*FileSelectorCallBack) (gchar *file, gchar *file_type,
+ void *user_context); /* file_type is one string from file_types in the save */
void gc_selector_file_load (GcomprisBoard *gcomprisBoard,
- gchar *rootdir,
- gchar *file_types, /* A Comma separated text explaining the different file types */
- FileSelectorCallBack fscb);
+ gchar *rootdir, /* Relative to property->user_dir */
+ gchar *file_types, /* A Comma separated text explaining the different file types */
+ FileSelectorCallBack fscb,
+ void *user_contact);
void gc_selector_file_save (GcomprisBoard *gcomprisBoard,
- gchar *rootdir,
- gchar *file_types, /* A Comma separated text explaining the different file types */
- FileSelectorCallBack fscb);
+ gchar *rootdir, /* Relative to property->user_dir */
+ gchar *file_types, /* A Comma separated text explaining the different file types */
+ FileSelectorCallBack fscb,
+ void *user_context);
void gc_selector_file_stop (void);
gchar *gc_db_get_filename();
diff --git a/src/goocanvas/src/goocanvassvg.c b/src/goocanvas/src/goocanvassvg.c
index bd6701e..21ad7e3 100644
--- a/src/goocanvas/src/goocanvassvg.c
+++ b/src/goocanvas/src/goocanvassvg.c
@@ -111,13 +111,14 @@ _search_limits(GooCanvasSvg *canvas_svg,
}
static void _init_surface(GooCanvasSvg *canvas_svg,
- RsvgHandle *svg_handle)
+ RsvgHandle *svg_handle, double zoom)
{
+ zoom *= 2;
g_assert(svg_handle);
RsvgDimensionData dimension_data;
rsvg_handle_get_dimensions (svg_handle, &dimension_data);
- canvas_svg->width = dimension_data.width;
- canvas_svg->height = dimension_data.height;
+ canvas_svg->width = dimension_data.width * zoom;
+ canvas_svg->height = dimension_data.height * zoom;
canvas_svg->svg_handle = svg_handle;
g_object_ref(svg_handle);
@@ -213,7 +214,7 @@ goo_canvas_svg_new (GooCanvasItem *parent,
canvas_svg = (GooCanvasSvg*) item;
if(svg_handle)
- _init_surface(canvas_svg, svg_handle);
+ _init_surface(canvas_svg, svg_handle, 1.0);
if (parent)
{
@@ -300,7 +301,7 @@ goo_canvas_svg_set_common_property (GObject *object,
svg_handle = g_value_get_object (value);
if(canvas_svg->svg_handle)
g_object_unref (canvas_svg->svg_handle);
- _init_surface(canvas_svg, svg_handle);
+ _init_surface(canvas_svg, svg_handle, 1.0);
break;
case PROP_SVG_ID:
if(canvas_svg->id)
@@ -310,7 +311,7 @@ goo_canvas_svg_set_common_property (GObject *object,
else
canvas_svg->id = g_value_dup_string(value);
if (canvas_svg->svg_handle)
- _init_surface(canvas_svg, canvas_svg->svg_handle);
+ _init_surface(canvas_svg, canvas_svg->svg_handle, 1.0);
break;
case PROP_AUTOCROP:
canvas_svg->autocrop = g_value_get_boolean (value);