~ubuntu-branches/ubuntu/precise/gcompris/precise

« back to all changes in this revision

Viewing changes to src/boards/py-mod-gcompris.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2012-01-10 01:37:41 UTC
  • mto: This revision was merged to the branch mainline in revision 48.
  • Revision ID: package-import@ubuntu.com-20120110013741-q90ulmfrj910igm3
Tags: upstream-12.01
ImportĀ upstreamĀ versionĀ 12.01

Show diffs side-by-side

added added

removed removed

Lines of Context:
368
368
  return Py_None;
369
369
}
370
370
 
 
371
/* void gc_locale_get_name(gchar *locale); */
 
372
static PyObject*
 
373
py_gc_locale_get_name(PyObject* self, PyObject* args)
 
374
{
 
375
  gchar* locale;
 
376
  /* Parse arguments */
 
377
  if(!PyArg_ParseTuple(args, "s:gc_locale_get_name", &locale))
 
378
    return NULL;
 
379
 
 
380
  /* Call the corresponding C function */
 
381
  const gchar *result = gc_locale_get_name(locale);
 
382
 
 
383
  /* Create and return the result */
 
384
  return Py_BuildValue("s", result);
 
385
}
 
386
 
371
387
 
372
388
/* char *gc_locale_get_user_default(void) */
373
389
static PyObject*
1072
1088
}
1073
1089
 
1074
1090
 
1075
 
/* Some functions and variables needed to get the file selector working */
 
1091
/* Some functions and variables needed to get the config dialog working */
1076
1092
static PyObject* pyGcomprisConfCallbackFunc = NULL;
1077
1093
 
1078
 
static void pyGcomprisConfCallback(GHashTable* table){
 
1094
static gboolean pyGcomprisConfCallback(GHashTable* table){
1079
1095
  PyObject* result;
1080
1096
 
1081
1097
  PyGILState_STATE gil;
1082
 
 
1083
 
 
1084
 
  if(pyGcomprisConfCallbackFunc==NULL) return;
 
1098
  gboolean retval = TRUE;
 
1099
 
 
1100
  if(pyGcomprisConfCallbackFunc==NULL) return TRUE;
1085
1101
 
1086
1102
  gil = pyg_gil_state_ensure();
1087
1103
 
1090
1106
  else
1091
1107
    result = PyObject_CallFunction(pyGcomprisConfCallbackFunc, "O", Py_None);
1092
1108
 
1093
 
  // This callback can be called multiple time ? not now
1094
 
 
1095
 
  Py_DECREF(pyGcomprisConfCallbackFunc);
1096
 
 
1097
1109
  if(result==NULL){
1098
1110
    PyErr_Print();
1099
1111
  } else {
 
1112
    if (PyObject_IsTrue(result))
 
1113
      retval = TRUE;
 
1114
    else
 
1115
      retval = FALSE;
1100
1116
    Py_DECREF(result);
1101
1117
  }
1102
1118
 
1103
1119
  pyg_gil_state_release(gil);
 
1120
  return retval;
1104
1121
 
1105
1122
}
1106
1123
 
1123
1140
      return NULL;
1124
1141
    }
1125
1142
 
1126
 
  //if (pyGcomprisConfCallbackFunc)
1127
 
  //  Py_DECREF(pyGcomprisConfCallbackFunc);
 
1143
  if (pyGcomprisConfCallbackFunc)
 
1144
    {
 
1145
      Py_DECREF(pyGcomprisConfCallbackFunc);
 
1146
    }
1128
1147
 
1129
1148
  pyGcomprisConfCallbackFunc = pyCallback;
1130
1149
 
1133
1152
 
1134
1153
  return gcompris_new_pyGcomprisBoardConfigObject(
1135
1154
                  gc_board_config_window_display( label,
1136
 
                          (GcomprisConfCallback )pyGcomprisConfCallback));
 
1155
                                                  pyGcomprisConfCallback));
1137
1156
 
1138
1157
}
1139
1158
 
1393
1412
    return NULL;
1394
1413
  bconf = (pyGcomprisBoardConfigObject*)py_bconf;
1395
1414
  return (PyObject *)pygobject_new((GObject*) \
1396
 
                                   gc_board_config_combo_locales_asset(bconf->cdata, label, init, file ));
 
1415
                                   gc_board_config_combo_locales_asset(bconf->cdata,
 
1416
                                                                       label, init, file,
 
1417
                                                                       NULL));
1397
1418
}
1398
1419
 
1399
1420
 
1438
1459
 
1439
1460
 
1440
1461
 
1441
 
/* void gc_locale_change(gchar *locale); */
1442
 
static PyObject*
1443
 
py_gc_locale_change(PyObject* self, PyObject* args)
1444
 
{
1445
 
  gchar *locale;
1446
 
 
1447
 
  /* Parse arguments */
1448
 
  if(!PyArg_ParseTuple(args, "s:gc_locale_change", &locale))
1449
 
    return NULL;
1450
 
 
1451
 
  /* Call the corresponding C function */
1452
 
  gc_locale_set(locale);
1453
 
 
1454
 
  /* Create and return the result */
1455
 
  Py_INCREF(Py_None);
1456
 
  return Py_None;
1457
 
}
1458
 
 
1459
 
 
1460
 
/* void gc_locale_reset(gchar *locale); */
1461
 
static PyObject*
1462
 
py_gc_locale_reset(PyObject* self, PyObject* args)
1463
 
{
1464
 
  /* Parse arguments */
1465
 
  if(!PyArg_ParseTuple(args, ":gc_locale_reset"))
1466
 
    return NULL;
1467
 
 
1468
 
  /* Call the corresponding C function */
1469
 
  gc_locale_reset();
1470
 
 
1471
 
  /* Create and return the result */
1472
 
  Py_INCREF(Py_None);
1473
 
  return Py_None;
1474
 
}
1475
 
 
1476
 
 
1477
1462
/* How can i free that ? */
1478
1463
static GHashTable *text_callbacks = NULL;
1479
1464
 
1633
1618
  { "get_locale",  py_gc_locale_get, METH_VARARGS, "gc_locale_get" },
1634
1619
  { "get_user_default_locale",  py_gc_locale_get_user_default, METH_VARARGS, "gc_locale_get_user_default" },
1635
1620
  { "set_locale",  py_gc_locale_set, METH_VARARGS, "gc_locale_set" },
 
1621
  { "get_locale_name",  py_gc_locale_get_name, METH_VARARGS, "gc_locale_get_name" },
1636
1622
  { "set_cursor",  py_gc_cursor_set, METH_VARARGS, "gc_cursor_set" },
1637
1623
  { "images_selector_start",  py_gc_selector_images_start,
1638
1624
    METH_VARARGS, "gc_selector_images_start" },
1665
1651
  { "combo_locales",  py_gc_board_config_combo_locales, METH_VARARGS, "gc_board_config_combo_locales" },
1666
1652
  { "get_locales_list",  py_gc_locale_gets_list, METH_VARARGS, "gc_locale_gets_list" },
1667
1653
  { "gcompris_gettext",  py_gcompris_gettext, METH_VARARGS, "gcompris_gettext" },
1668
 
  { "change_locale",  py_gc_locale_change, METH_VARARGS, "gc_locale_change" },
1669
 
  { "reset_locale",  py_gc_locale_reset, METH_VARARGS, "gc_locale_reset" },
1670
1654
  { "combo_locales_asset",  py_gc_board_config_combo_locales_asset, METH_VARARGS, "gc_board_config_combo_locales_asset" },
1671
1655
  { "get_locales_asset_list",  py_gc_locale_gets_asset_list, METH_VARARGS, "gc_locale_gets_asset_list" },
1672
1656
  { "textview",  py_gc_board_config_textview, METH_VARARGS, "gc_board_config_textview" },