Ejemplo n.º 1
0
static PyObject *
pygtk_style_helper_getitem(PyGtkStyleHelper_Object *self, Py_ssize_t pos)
{
    if (pos < 0) pos += NUM_STATES;
    if (pos < 0 || pos >= NUM_STATES) {
	PyErr_SetString(PyExc_IndexError, "index out of range");
	return NULL;
    }
    switch (self->type) {
    case STYLE_COLOUR_ARRAY:
	{
	    GdkColor *array = (GdkColor *)self->array;
	    return pyg_boxed_new(GDK_TYPE_COLOR, &array[pos], TRUE, TRUE);
	}
    case STYLE_GC_ARRAY:
	{
	    GdkGC **array = (GdkGC **)self->array;
	    return pygobject_new((GObject *)array[pos]);
	}
    case STYLE_PIXMAP_ARRAY:
	{
	    GdkPixmap **array = (GdkPixmap **)self->array;
	    if ((long)array[pos] == GDK_PARENT_RELATIVE)
		return PyLong_FromLong(GDK_PARENT_RELATIVE);
	    return pygobject_new((GObject *)array[pos]);
	}
    }
    g_assert_not_reached();
    return NULL;
}
Ejemplo n.º 2
0
static PyObject *
MainWidgets_get_property(MainWidgets *self, const gchar *prop_name)
{
	g_return_val_if_fail(self != NULL, NULL);
	g_return_val_if_fail(prop_name != NULL, NULL);

	if (!self->main_widgets)
	{
		PyErr_SetString(PyExc_RuntimeError,
			"MainWidgets instance not initialized properly");
		return NULL;
	}

	if (g_str_equal(prop_name, "editor_menu"))
		return pygobject_new(G_OBJECT(self->main_widgets->editor_menu));
	else if (g_str_equal(prop_name, "message_window_notebook"))
		return pygobject_new(G_OBJECT(self->main_widgets->message_window_notebook));
	else if (g_str_equal(prop_name, "notebook"))
		return pygobject_new(G_OBJECT(self->main_widgets->notebook));
	else if (g_str_equal(prop_name, "progressbar"))
		return pygobject_new(G_OBJECT(self->main_widgets->progressbar));
	else if (g_str_equal(prop_name, "project_menu"))
		return pygobject_new(G_OBJECT(self->main_widgets->project_menu));
	else if (g_str_equal(prop_name, "sidebar_notebook"))
		return pygobject_new(G_OBJECT(self->main_widgets->sidebar_notebook));
	else if (g_str_equal(prop_name, "toolbar"))
		return pygobject_new(G_OBJECT(self->main_widgets->toolbar));
	else if (g_str_equal(prop_name, "tools_menu"))
		return pygobject_new(G_OBJECT(self->main_widgets->tools_menu));
	else if (g_str_equal(prop_name, "window"))
		return pygobject_new(G_OBJECT(self->main_widgets->window));

	Py_RETURN_NONE;
}
static NemoOperationResult
nemo_python_object_update_file_info (NemoInfoProvider 		*provider,
										 NemoFile 				*file,
										 GClosure 					*update_complete,
										 NemoOperationHandle   **handle)
{
	NemoPythonObject *object = (NemoPythonObject*)provider;
    NemoOperationResult ret = NEMO_OPERATION_COMPLETE;
    PyObject *py_ret = NULL;
	PyGILState_STATE state = pyg_gil_state_ensure();
	PyObject *py_handle = nemo_python_boxed_new (_PyNemoOperationHandle_Type, *handle, FALSE);

  	debug_enter();

	CHECK_OBJECT(object);

	if (PyObject_HasAttrString(object->instance, "update_file_info_full"))
	{
		py_ret = PyObject_CallMethod(object->instance,
									 METHOD_PREFIX "update_file_info_full", "(NNNN)",
									 pygobject_new((GObject*)provider),
									 py_handle,
									 pyg_boxed_new(G_TYPE_CLOSURE, update_complete, TRUE, TRUE),
									 pygobject_new((GObject*)file));
	}
	else if (PyObject_HasAttrString(object->instance, "update_file_info"))
	{
		py_ret = PyObject_CallMethod(object->instance,
									 METHOD_PREFIX METHOD_NAME, "(N)",
									 pygobject_new((GObject*)file));
	}
	else
	{
		goto beach;
	}
	
	HANDLE_RETVAL(py_ret);

	if (!PyInt_Check(py_ret))
	{
		PyErr_SetString(PyExc_TypeError,
						METHOD_NAME " must return None or a int");
		goto beach;
	}

	ret = PyInt_AsLong(py_ret);
	
 beach:
 	free_pygobject_data(file, NULL);
	Py_XDECREF(py_ret);
	pyg_gil_state_release(state);
    return ret;
}
Ejemplo n.º 4
0
static void
python_plugin_execute (const gchar   *filename,
		       PlannerWindow *window,
		       GHashTable    *scripts)
{
	PlannerPythonEnv *env;
	FILE             *fp;
	PyObject         *pModule;
	PyObject         *py_object;

	env = planner_python_env_new (filename);

	pModule = PyRun_String ("import pygtk\n"
				"pygtk.require('2.0')\n"
				"import gtk\n"
				"import planner\n",
				Py_file_input, env->globals, env->globals);
	if (!pModule) {
		PyErr_Print ();
		planner_python_env_free (env);
		return;
	}

	pModule = PyImport_ImportModuleEx ("plannerui", env->globals, env->globals, Py_None);
	if (!pModule) {
		PyErr_Print ();
		planner_python_env_free (env);
		return;
	}

	py_object = pygobject_new (G_OBJECT (window));
	PyDict_SetItemString (env->globals, "window", py_object);
	Py_DECREF (py_object);

	py_object = pygobject_new (G_OBJECT (planner_window_get_application (window)));
	PyDict_SetItemString (env->globals, "application", py_object);
	Py_DECREF (py_object);

	fp = fopen (filename,"r");
	if (fp) {
		if (PyRun_File (fp, (gchar *) filename, Py_file_input, env->globals, env->globals) == NULL) {
			PyErr_Print ();
		}
		fclose (fp);
		g_hash_table_insert (scripts, env->filename, env);
	} else {
		planner_python_env_free (env);

		/* FIXME: do the free */
		g_warning ("Could not open python script: %s", filename);
	}
}
Ejemplo n.º 5
0
static void
gplp_func_file_save (G_GNUC_UNUSED GOFileSaver const *fs, GOPluginService *service,
		     GOIOContext *io_context, gconstpointer wb_view,
		     GsfOutput *output)
{
	ServiceLoaderDataFileSaver *saver_data;
	PyObject *py_workbook;
	PyObject *save_result = NULL;
	PyObject *output_wrapper;

	g_return_if_fail (GO_IS_PLUGIN_SERVICE_FILE_SAVER (service));
	g_return_if_fail (output != NULL);
	g_return_if_fail (_PyGObject_API != NULL);

	saver_data = g_object_get_data (G_OBJECT (service), "loader_data");
	SWITCH_TO_PLUGIN (go_plugin_service_get_plugin (service));
	py_workbook = py_new_Workbook_object (wb_view_get_workbook (wb_view));
	output_wrapper = pygobject_new (G_OBJECT (output));
	if (output_wrapper != NULL) {
		/* wrapping adds a reference */
		g_object_unref (output);
		save_result = PyObject_CallFunction
			(saver_data->python_func_file_save,
			 (char *) "NO", py_workbook, output_wrapper);
		Py_DECREF (output_wrapper);
	}
	if (save_result != NULL) {
		Py_DECREF (save_result);
	} else {
		go_io_error_string (io_context, py_exc_to_string ());
		gnm_python_clear_error_if_needed (SERVICE_GET_LOADER (service)->py_object);
	}
}
Ejemplo n.º 6
0
/* function to fill list of containers, for gwy_app_data_browser_get_containers
 */
static void
pygwy_create_py_list_of_containers(GwyContainer *data, gpointer list)
{
   if (PyList_Append((PyObject *) list, pygobject_new((GObject *)data)) < 0) {
      g_warning("Could not append container to python list of containers.");
   }
}
Ejemplo n.º 7
0
static PyObject *
_wrap_get_unknown (PyObject * self)
{
  GObject *obj;
  obj = g_object_new (TEST_TYPE_UNKNOWN, NULL);
  return pygobject_new(obj);
}
static GList *
nemo_python_object_get_file_items (NemoMenuProvider *provider,
									   GtkWidget 			*window,
									   GList 				*files)
{
	NemoPythonObject *object = (NemoPythonObject*)provider;
    GList *ret = NULL;
    PyObject *py_ret = NULL, *py_files;
	PyGILState_STATE state = pyg_gil_state_ensure();
	
  	debug_enter();

	CHECK_OBJECT(object);	

	if (PyObject_HasAttrString(object->instance, "get_file_items_full"))
	{
		CONVERT_LIST(py_files, files);
		py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX "get_file_items_full",
									 "(NNN)",
									 pygobject_new((GObject *)provider), 
									 pygobject_new((GObject *)window), 
									 py_files);
	}
	else if (PyObject_HasAttrString(object->instance, "get_file_items"))
	{
		CONVERT_LIST(py_files, files);
		py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX METHOD_NAME,
									 "(NN)", 
									 pygobject_new((GObject *)window), 
									 py_files);
	}
	else
	{
		goto beach;
	}

	HANDLE_RETVAL(py_ret);

	HANDLE_LIST(py_ret, NemoMenuItem, "Nemo.MenuItem");

 beach:
 	free_pygobject_data_list(files);
	Py_XDECREF(py_ret);
	pyg_gil_state_release(state);
    return ret;
}
Ejemplo n.º 9
0
static GList *
caja_python_object_get_background_items (CajaMenuProvider *provider,
											 GtkWidget 			  *window,
											 CajaFileInfo 	  *file)
{
	CajaPythonObject *object = (CajaPythonObject*)provider;
    GList *ret = NULL;
    PyObject *py_ret = NULL;
	PyGILState_STATE state = pyg_gil_state_ensure();
	
  	debug_enter();

	CHECK_OBJECT(object);

	if (PyObject_HasAttrString(object->instance, "get_background_items_full"))
	{
		py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX "get_background_items_full",
									 "(NNN)",
									 pygobject_new((GObject *)provider),
									 pygobject_new((GObject *)window),
									 pygobject_new((GObject *)file));
	}
	else if (PyObject_HasAttrString(object->instance, "get_background_items"))
	{
		py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX METHOD_NAME,
									 "(NN)",
									 pygobject_new((GObject *)window),
									 pygobject_new((GObject *)file));
	}
	else
	{
		goto beach;
	}

	HANDLE_RETVAL(py_ret);

	HANDLE_LIST(py_ret, CajaMenuItem, "Caja.MenuItem");
	
 beach:
	free_pygobject_data(file, NULL);
	Py_XDECREF(py_ret);
	pyg_gil_state_release(state);
    return ret;
}
Ejemplo n.º 10
0
static PyObject *
_wrap_create_test_type (PyObject * self)
{
    GObject *obj;
    PyObject *rv;
    obj = g_object_new(TYPE_TEST, NULL);
    rv = pygobject_new(obj);
    g_object_unref(obj);
    return rv;
}
Ejemplo n.º 11
0
static void
_wrap_TestInterface__proxy_do_iface_method(TestInterface *self)
{
    PyGILState_STATE __py_state;
    PyObject *py_self;
    PyObject *py_retval;
    PyObject *py_args;
    PyObject *py_method;
    
    __py_state = PyGILState_Ensure();
    py_self = pygobject_new((GObject *) self);
    if (!py_self) {
        if (PyErr_Occurred())
            PyErr_Print();
        PyGILState_Release(__py_state);
        return;
    }
    py_args = PyTuple_New(0);
    py_method = PyObject_GetAttrString(py_self, "do_iface_method");
    if (!py_method) {
        if (PyErr_Occurred())
            PyErr_Print();
        Py_DECREF(py_args);
        Py_DECREF(py_self);
        PyGILState_Release(__py_state);
        return;
    }
    py_retval = PyObject_CallObject(py_method, py_args);
    if (!py_retval) {
        if (PyErr_Occurred())
            PyErr_Print();
        Py_DECREF(py_method);
        Py_DECREF(py_args);
        Py_DECREF(py_self);
        PyGILState_Release(__py_state);
        return;
    }
    if (py_retval != Py_None) {
        if (PyErr_Occurred())
            PyErr_Print();
        PyErr_SetString(PyExc_TypeError, "retval should be None");
        Py_DECREF(py_retval);
        Py_DECREF(py_method);
        Py_DECREF(py_args);
        Py_DECREF(py_self);
        PyGILState_Release(__py_state);
        return;
    }
    
    Py_DECREF(py_retval);
    Py_DECREF(py_method);
    Py_DECREF(py_args);
    Py_DECREF(py_self);
    PyGILState_Release(__py_state);
}
Ejemplo n.º 12
0
static PyObject *
_wrap_gsm_session_create_global(PyObject *self)
{
    GsmSession *ret;

    
    ret = gsm_session_create_global();
    
    /* pygobject_new handles NULL checking */
    return pygobject_new((GObject *)ret);
}
Ejemplo n.º 13
0
static PyObject *
_wrap_get_object (PyObject * self)
{
  GObject *obj;
  obj = g_object_new (TEST_TYPE_OBJECT, NULL);
  if (!obj) {
    return NULL;
  }
  
  return pygobject_new(obj);
}
Ejemplo n.º 14
0
static PyObject *
_wrap_get_test_thread (PyObject * self)
{
  GObject *obj;

  test_thread_get_type();
  g_assert (g_type_is_a (TEST_TYPE_THREAD, G_TYPE_OBJECT));
  obj = g_object_new (TEST_TYPE_THREAD, NULL);
  g_assert (obj != NULL);
  
  return pygobject_new(obj);
}
Ejemplo n.º 15
0
static PyObject *m_new(PyObject *dummy, PyObject *args) 
{
    DeepinLunarObject *self = NULL;
    
    self = m_init_deepin_lunar_object();
    if (!self)
        return NULL;
    
    self->handle = lunar_calendar_new();
    
    return pygobject_new(G_OBJECT(self->handle));
}
Ejemplo n.º 16
0
static PeasExtension *
peas_plugin_loader_python_create_extension (PeasPluginLoader *loader,
                                            PeasPluginInfo   *info,
                                            GType             exten_type,
                                            guint             n_parameters,
                                            GParameter       *parameters)
{
  PyObject *pymodule = info->loader_data;
  GType the_type;
  GObject *object = NULL;
  PyObject *pyobject;
  PyObject *pyplinfo;
  PyGILState_STATE state = PyGILState_Ensure ();

  the_type = find_python_extension_type (exten_type, pymodule);
  if (the_type == G_TYPE_INVALID)
    goto out;

  object = g_object_newv (the_type, n_parameters, parameters);
  if (object == NULL)
    goto out;

  /* We have to remember which interface we are instantiating
   * for the deprecated peas_extension_get_extension_type().
   */
  g_object_set_qdata (object, quark_extension_type,
                      GSIZE_TO_POINTER (exten_type));

  pyobject = pygobject_new (object);
  pyplinfo = pyg_boxed_new (PEAS_TYPE_PLUGIN_INFO, info, TRUE, TRUE);

  /* Set the plugin info as an attribute of the instance */
  if (PyObject_SetAttrString (pyobject, "plugin_info", pyplinfo) != 0)
    {
      g_warning ("Failed to set 'plugin_info' for '%s'",
                 g_type_name (the_type));

      if (PyErr_Occurred ())
        PyErr_Print ();

      g_clear_object (&object);
    }

  Py_DECREF (pyplinfo);
  Py_DECREF (pyobject);

out:

  PyGILState_Release (state);
  return object;
}
static PyObject *
pymidgard_schema_object_factory_get_object_by_guid (PyGObject *self, PyObject *args)
{
    gchar *guid;

    if (!PyArg_ParseTuple (args, "s", &guid))
        return NULL;

    MidgardConnection *mgd = _py_midgard_connection_singleton_get ();
    MidgardObject *mobject = midgard_schema_object_factory_get_object_by_guid (mgd, guid);

    if (mobject)
        return Py_BuildValue ("O", pygobject_new (G_OBJECT (mobject)));

    Py_RETURN_NONE;
}
static PyObject *
pymidgard_schema_object_factory_get_object_by_path (PyGObject *self, PyObject *args)
{
    gchar *path;
    gchar *classname;

    if (!PyArg_ParseTuple (args, "ss", &classname, &path))
        return NULL;

    MidgardConnection *mgd = _py_midgard_connection_singleton_get ();
    MidgardObject *mobject = midgard_schema_object_factory_get_object_by_path (mgd, (const gchar *) classname, (const gchar *) path);

    if (mobject)
        return Py_BuildValue ("O", pygobject_new (G_OBJECT (mobject)));

    Py_RETURN_NONE;
}
Ejemplo n.º 19
0
static void
gplp_func_file_open (GOFileOpener const *fo,
		     GOPluginService *service,
		     GOIOContext *io_context,
		     gpointer wb_view,
		     GsfInput *input)
{
	ServiceLoaderDataFileOpener *loader_data;
	Sheet *sheet, *old_sheet;
	PyObject *open_result = NULL;
	PyObject *input_wrapper;

	printf("gplp_func_file_open(start)\n");

	g_return_if_fail (GO_IS_PLUGIN_SERVICE_FILE_OPENER (service));
	g_return_if_fail (input != NULL);
	g_return_if_fail (_PyGObject_API != NULL);

	old_sheet = wb_view_cur_sheet (wb_view);

	loader_data = g_object_get_data (G_OBJECT (service), "loader_data");
	SWITCH_TO_PLUGIN (go_plugin_service_get_plugin (service));
	sheet = sheet_new (wb_view_get_workbook (wb_view), _("Some name"),
			   gnm_sheet_get_max_cols (old_sheet),
			   gnm_sheet_get_max_rows (old_sheet));
	input_wrapper = pygobject_new (G_OBJECT (input));
	if (input_wrapper != NULL) {
		 /* wrapping adds a reference */
		g_object_unref (G_OBJECT (input));
		open_result = PyObject_CallFunction
			(loader_data->python_func_file_open,
			 (char *) "NO",
			 py_new_Sheet_object (sheet), input_wrapper);
		Py_DECREF (input_wrapper);
	}
	if (open_result != NULL) {
		Py_DECREF (open_result);
		workbook_sheet_attach (wb_view_get_workbook (wb_view), sheet);
	} else {
		go_io_error_string (io_context, py_exc_to_string ());
		gnm_python_clear_error_if_needed (SERVICE_GET_LOADER (service)->py_object);
		g_object_unref (sheet);
	}

	printf("gplp_func_file_open(end)\n");
}
Ejemplo n.º 20
0
initpygwy(GwyContainer *container) 
{ 
    PyObject *m, *d; 
    PyObject *py_container;
    init_pygobject (); 

    m = Py_InitModule ("gwy", (PyMethodDef*) pygwy_functions); 
    d = PyModule_GetDict (m); 
 
    pygwy_register_classes (d);
/*    pyatk_add_constants(m, "ATK_");     */

    /* Create accessible object GwyContainer (gwy.data) */
    py_container = pygobject_new((GObject*)container);
    PyDict_SetItemString(d, "data", py_container);

}
Ejemplo n.º 21
0
static PyObject *
Scintilla_get_property(Scintilla *self, const gchar *prop_name)
{
	g_return_val_if_fail(self != NULL, NULL);
	g_return_val_if_fail(prop_name != NULL, NULL);

	if (!self->sci)
	{
		PyErr_SetString(PyExc_RuntimeError,
			"Scintilla instance not initialized properly");
		return NULL;
	}

	if (g_str_equal(prop_name, "widget"))
		return pygobject_new(G_OBJECT(self->sci));

	Py_RETURN_NONE;
}
Ejemplo n.º 22
0
static gboolean
gplp_func_file_probe (GOFileOpener const *fo, GOPluginService *service,
		      GsfInput *input, GOFileProbeLevel pl)
{
	ServiceLoaderDataFileOpener *loader_data;
	PyObject *probe_result = NULL;
	PyObject *input_wrapper;
	gboolean result;

	printf("gplp_func_file_probe(start)\n");

	g_return_val_if_fail (GO_IS_PLUGIN_SERVICE_FILE_OPENER (service), FALSE);
	g_return_val_if_fail (input != NULL, FALSE);
	g_return_val_if_fail (_PyGObject_API != NULL, FALSE);

	loader_data = g_object_get_data (G_OBJECT (service), "loader_data");
	SWITCH_TO_PLUGIN (go_plugin_service_get_plugin (service));
	input_wrapper = pygobject_new (G_OBJECT (input));
	if (input_wrapper == NULL) {
		g_warning ("%s", py_exc_to_string ());
		gnm_python_clear_error_if_needed (SERVICE_GET_LOADER (service)->py_object);
	}
	if (input_wrapper != NULL &&
	    loader_data->python_func_file_probe != NULL) {
		/* wrapping adds a reference */
		g_object_unref (G_OBJECT (input));
		probe_result = PyObject_CallFunction
			(loader_data->python_func_file_probe,
			 (char *) "O", input_wrapper);
		Py_DECREF (input_wrapper);
	}
	if (probe_result != NULL) {
		result = PyObject_IsTrue (probe_result);
		Py_DECREF (probe_result);
	} else {
		PyErr_Clear ();
		result = FALSE;
	}

	printf("gplp_func_file_probe(end)\n");

	return result;
}
Ejemplo n.º 23
0
static PyObject *
wrap_gobj(PyObject *self, PyObject *args)
{
    void *addr;
    GObject *obj;

    if (!PyArg_ParseTuple(args, "l", &addr))
        return NULL;

    if (!G_IS_OBJECT(addr))
        return NULL; // XXX

    obj = G_OBJECT(addr);

    if (!obj)
        return NULL; // XXX

    return pygobject_new(obj);
}
Ejemplo n.º 24
0
/* GdkPixbuf *gc_skin_rsvg_get(); */
static PyObject*
py_gc_skin_rsvg_get(PyObject* self, PyObject* args)
{
  RsvgHandle* result;
  PyObject* pyresult;

  /* Parse arguments */
  if(!PyArg_ParseTuple(args, ":gc_skin_rsvg_get"))
    return NULL;

  /* Call the corresponding C function */
  result = gc_skin_rsvg_get();

  /* Create and return the result */
  pyresult = (PyObject*) pygobject_new((GObject*) result);

  // 'result' must not be freed, it is managed by gc_skin_rsvg_get()

  return(pyresult);
}
Ejemplo n.º 25
0
static void
nautilus_python_object_cancel_update (NautilusInfoProvider         *provider,
                                      NautilusOperationHandle     *handle) {
    NautilusPythonObject *object = (NautilusPythonObject*)provider;
    PyGILState_STATE state = pyg_gil_state_ensure();
    PyObject *py_handle = nautilus_python_boxed_new (_PyNautilusOperationHandle_Type, handle, FALSE);

    debug_enter();

    CHECK_OBJECT(object);
    CHECK_METHOD_NAME(object->instance);

    PyObject_CallMethod(object->instance,
                                 METHOD_PREFIX METHOD_NAME, "(NN)",
                                 pygobject_new((GObject*)provider),
                                 py_handle);

beach:
    pyg_gil_state_release(state);
}
PyObject *
pymidgard_object_create_attachment(PyGObject *self, PyObject *args) 
{
	ATTACHMENT_DEBUG("create_attachment");

	gchar *name = NULL;
	gchar *title = NULL;
	gchar *mimetype = NULL;

	if(!PyArg_ParseTuple(args, "|s|s|s", &name, &title, &mimetype))
		return NULL;
	
	MidgardObject *mobject = MIDGARD_OBJECT(self->obj);
	MidgardObject *att = midgard_object_create_attachment(mobject, name, title, mimetype);

	if(att)
		return Py_BuildValue("O", pygobject_new(G_OBJECT(att)));

	Py_RETURN_NONE;
}
Ejemplo n.º 27
0
PyObject *
_pygi_marshal_to_py_interface_object (PyGIInvokeState   *state,
                                      PyGICallableCache *callable_cache,
                                      PyGIArgCache      *arg_cache,
                                      GIArgument        *arg)
{
    PyObject *py_obj;

    if (arg->v_pointer == NULL) {
        py_obj = Py_None;
        Py_INCREF (py_obj);
        return py_obj;
    }

    py_obj = pygobject_new (arg->v_pointer);

    if (arg_cache->transfer == GI_TRANSFER_EVERYTHING)
        g_object_unref (arg->v_pointer);

    return py_obj;
}
Ejemplo n.º 28
0
static PyObject *
_wrap_gimp_thumbnail_load_thumb(PyGObject *self, PyObject *args, PyObject *kwargs)
{
    static char *kwlist[] = { "size", NULL };
    PyObject *py_size = NULL;
    GdkPixbuf *ret;
    GError *error = NULL;
    GimpThumbSize size;

    if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:Gimp.Thumbnail.load_thumb", kwlist, &py_size))
        return NULL;
    if (pyg_enum_get_value(GIMP_TYPE_THUMB_SIZE, py_size, (gpointer)&size))
        return NULL;
    
    ret = gimp_thumbnail_load_thumb(GIMP_THUMBNAIL(self->obj), size, &error);
    
    if (pyg_error_check(&error))
        return NULL;
    /* pygobject_new handles NULL checking */
    return pygobject_new((GObject *)ret);
}
Ejemplo n.º 29
0
PyObject *
_helper_wrap_gobject_glist (const GList *list)
{
    PyObject *py_list;
    const GList *tmp;

    if ((py_list = PyList_New(0)) == NULL) {
        return NULL;
    }
    for (tmp = list; tmp != NULL; tmp = tmp->next) {
        PyObject *py_obj = pygobject_new(G_OBJECT(tmp->data));

        if (py_obj == NULL) {
            Py_DECREF(py_list);
            return NULL;
        }
        PyList_Append(py_list, py_obj);
        Py_DECREF(py_obj);
    }
    return py_list;
}
Ejemplo n.º 30
0
/* GdkPixbuf *gc_skin_pixmap_load(char *pixmapfile); */
static PyObject*
py_gc_skin_pixmap_load(PyObject* self, PyObject* args)
{
  char* pixmapfile;
  GdkPixbuf* result;
  PyObject* pyresult;

  /* Parse arguments */
  if(!PyArg_ParseTuple(args, "s:gc_skin_pixmap_load", &pixmapfile))
    return NULL;

  /* Call the corresponding C function */
  result = gc_skin_pixmap_load(pixmapfile);

  /* Create and return the result */
  pyresult = (PyObject*) pygobject_new((GObject*) result);

  gdk_pixbuf_unref(result);

  return(pyresult);
}