Commit 1458f650 authored by Yves Combe's avatar Yves Combe
Browse files

fix compilation error (GComprisProfile in py-gcompris-properties.c)

add label option in gcompris_configuration_window fix tuxpaint.py and colors.c for use it.
parent 7e539ad3
2005-07-25 Yves Combe <yves@ycombe.net>
fix compilation error (GComprisProfile in py-gcompris-properties.c)
add label option in gcompris_configuration_window fix tuxpaint.py and colors.c for use it.
* src/boards/colors.c: (colors_config_start):
* src/boards/py-gcompris-properties.c:
(pyGcomprisPropertiesType_getattr):
* src/boards/py-mod-gcompris.c: (py_gcompris_configuration_window),
(py_gcompris_boolean_box):
* src/boards/python/tuxpaint.py:
* src/gcompris/board_config.c: (gcompris_configuration_window),
(gcompris_boolean_box):
* src/gcompris/board_config.h:
2005-07-25 Bruno coudoin <bruno.coudoin@free.fr>
Implemented two new options from the command line:
......
......@@ -116,7 +116,14 @@ static void
colors_config_start(GcomprisBoard *agcomprisBoard,
GcomprisProfile *aProfile)
{
gcompris_configuration_window(conf_apply);
gchar *label;
label = g_strdup_printf("<b>%s</b> configuration\n for profile <b>%s</b>",
agcomprisBoard->name, aProfile->name);
gcompris_configuration_window(label, conf_apply);
g_free(label);
gcompris_boolean_box("Test Check Box", "key1", TRUE);
}
......
#include "py-gcompris-properties.h"
#include <pygobject.h>
#include "py-gcompris-profile.h"
staticforward PyTypeObject pyGcomprisPropertiesType;
......@@ -106,8 +107,26 @@ pyGcomprisPropertiesType_getattr(pyGcomprisPropertiesObject *self, char *name)
if(strcmp(name,"package_data_dir")==0) return Py_BuildValue("s", self->cdata->package_data_dir);
if(strcmp(name,"locale")==0) return Py_BuildValue("s", self->cdata->locale);
if(strcmp(name,"skin")==0) return Py_BuildValue("s", self->cdata->skin);
if(strcmp(name,"profil")==0) return Py_BuildValue("s", self->cdata->profil);
if(strcmp(name,"database")==0) return Py_BuildValue("s", self->cdata->database);
if(strcmp(name,"profile")==0){
if (self->cdata->profile)
return gcompris_new_pyGcomprisProfileObject(self->cdata->profile);
else {
Py_INCREF(Py_None);
return Py_None;
}
}
if(strcmp(name,"logged_user")==0) {
if (self->cdata->logged_user)
return gcompris_new_pyGcomprisUserObject(self->cdata->logged_user);
else {
Py_INCREF(Py_None);
return Py_None;
}
}
if(strcmp(name,"database")==0) return Py_BuildValue("s", self->cdata->database);
if(strcmp(name,"administration")==0){
if(self->cdata->administration){
Py_INCREF(Py_True);
......
......@@ -1066,16 +1066,18 @@ static GcomprisConfCallback pyGcomprisConfCallback(GHashTable* table){
static PyObject*
py_gcompris_configuration_window(PyObject* self, PyObject* args){
PyObject* pyCallback;
gchar *label;
/* Parse arguments */
if(!PyArg_ParseTuple(args,
"O:gcompris_configuration_window",
"sO:gcompris_configuration_window",
&label,
&pyCallback))
return NULL;
if(!PyCallable_Check(pyCallback))
{
PyErr_SetString(PyExc_TypeError,
"gcompris_configuration_window argument must be callable");
"gcompris_configuration_window second argument must be callable");
return NULL;
}
......@@ -1087,12 +1089,15 @@ py_gcompris_configuration_window(PyObject* self, PyObject* args){
Py_INCREF(pyGcomprisConfCallbackFunc);
return (PyObject *)pygobject_new((GObject*) gcompris_configuration_window((GcomprisConfCallback )pyGcomprisConfCallback));
return (PyObject *) \
pygobject_new((GObject*) \
gcompris_configuration_window( label,
(GcomprisConfCallback )pyGcomprisConfCallback));
}
/* void gcompris_boolean_box (label, key, init); */
/* GtkCheckButton *gcompris_boolean_box (label, key, init);*/
static PyObject*
py_gcompris_boolean_box(PyObject* self, PyObject* args)
{
......@@ -1105,11 +1110,8 @@ py_gcompris_boolean_box(PyObject* self, PyObject* args)
return NULL;
/* Call the corresponding C function */
gcompris_boolean_box((const gchar *)label, key, PyObject_IsTrue(py_bool));
return (PyObject *)pygobject_new(gcompris_boolean_box((const gchar *)label, key, PyObject_IsTrue(py_bool)));
/* Create and return the result */
Py_INCREF(Py_None);
return Py_None;
}
......
......@@ -27,6 +27,8 @@ import gcompris.admin
import gtk
import os
import pango
#import gobject
from gettext import gettext as _
......@@ -157,7 +159,8 @@ class Gcompris_tuxpaint:
self.configure_profile = profile
self.config_values = {}
self.main_vbox = gcompris.configuration_window(self.apply_callback)
self.main_vbox = gcompris.configuration_window(_('<b>%s</b> configuration\n for profile <b>%s</b>') % ('Tuxpaint', profile.name ),
self.apply_callback)
self.config_dict = gcompris.get_conf(profile, self.gcomprisBoard)
......
/* gcompris - board_config.c
*
* Time-stamp: <2005/07/24 09:48:33 yves>
* Time-stamp: <2005/07/25 16:23:19 yves>
*
* Copyright (C) 2001 Pascal Georges
*
......@@ -83,71 +83,84 @@ void gcompris_apply_board_conf (GtkButton *button,
Confcallback(hash_conf);
}
GtkVBox *gcompris_configuration_window(GcomprisConfCallback callback)
GtkVBox *gcompris_configuration_window(gchar *label, GcomprisConfCallback callback)
{
GtkButton *button;
GtkHBox *footer;
GtkLabel *header;
/* init static values or callbacks */
Confcallback = callback;
hash_conf = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
/* main configuration window */
conf_window = GTK_WINDOW(gtk_window_new (GTK_WINDOW_TOPLEVEL));
/* parameters */
gtk_window_set_default_size (conf_window,
320,
300);
gtk_window_set_transient_for(conf_window,
GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(get_current_gcompris_board()->canvas))));
gtk_window_set_modal(conf_window, TRUE);
gtk_widget_show(GTK_WIDGET(conf_window));
/* main vbox in window */
main_conf_box = GTK_VBOX(gtk_vbox_new ( FALSE, 0));
gtk_widget_show(GTK_WIDGET(main_conf_box));
gtk_container_add(GTK_CONTAINER(conf_window), GTK_WIDGET(main_conf_box));
/* hbox for apply and close buttons */
footer = GTK_HBOX(gtk_hbox_new (FALSE, 0));
gtk_widget_show(GTK_WIDGET(footer));
gtk_box_pack_end (GTK_BOX(main_conf_box),
GTK_WIDGET(footer),
FALSE,
FALSE,
0);
/* Close button */
button = GTK_BUTTON(gtk_button_new_from_stock(GTK_STOCK_CLOSE));
gtk_widget_show(GTK_WIDGET(button));
gtk_box_pack_end (GTK_BOX(footer),
GTK_WIDGET(button),
FALSE,
FALSE,
0);
g_signal_connect(G_OBJECT(button),
"clicked",
G_CALLBACK(gcompris_close_board_conf),
NULL);
/* Apply button */
button = GTK_BUTTON(gtk_button_new_from_stock(GTK_STOCK_APPLY));
gtk_widget_show(GTK_WIDGET(button));
gtk_box_pack_start (GTK_BOX(footer),
GTK_WIDGET(button),
FALSE,
FALSE,
0);
g_signal_connect (G_OBJECT(button),
"clicked",
G_CALLBACK(gcompris_apply_board_conf),
NULL);
/* Label header */
header = gtk_label_new (NULL);
gtk_widget_show(header);
gtk_box_pack_start (GTK_BOX(main_conf_box),
header,
FALSE,
FALSE,
0);
gtk_label_set_justify (GTK_LABEL(header),
GTK_JUSTIFY_CENTER);
gtk_label_set_markup (GTK_LABEL(header),
(const gchar *)label);
return main_conf_box;
}
......@@ -165,7 +178,7 @@ void gcompris_boolean_box_toggled (GtkToggleButton *togglebutton,
g_hash_table_replace(hash_conf, (gpointer) the_key, (gpointer) value);
}
void gcompris_boolean_box(const gchar *label, gchar *key, gboolean initial_value)
GtkCheckButton *gcompris_boolean_box(const gchar *label, gchar *key, gboolean initial_value)
{
GtkWidget *CheckBox = gtk_check_button_new_with_label (label);
......@@ -185,6 +198,7 @@ void gcompris_boolean_box(const gchar *label, gchar *key, gboolean initial_value
G_CALLBACK(gcompris_boolean_box_toggled),
key);
return GTK_CHECK_BUTTON(CheckBox);
}
/* Local Variables: */
......
/* gcompris - board_config.h
*
* Time-stamp: <2005/07/24 01:53:50 yves>
* Time-stamp: <2005/07/25 15:33:43 yves>
*
* Copyright (C) 2001 Pascal Georges
*
......@@ -37,9 +37,9 @@ void board_config_stop();
/* the callback type */
typedef void (*GcomprisConfCallback) (GHashTable *table);
GtkVBox *gcompris_configuration_window(GcomprisConfCallback callback);
GtkVBox *gcompris_configuration_window(gchar *label, GcomprisConfCallback callback);
void gcompris_boolean_box(const gchar *label, gchar *key, gboolean initial_value);
GtkCheckButton *gcompris_boolean_box(const gchar *label, gchar *key, gboolean initial_value);
#endif
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment