/* -*- Mode: C; c-basic-offset: 4 -*- */
%%
headers
#include <Python.h>

#define NO_IMPORT_PYGOBJECT
#include <pygobject.h>

#include <libwnck/libwnck.h>
#include <libwnck/class-group.h>
#include <libwnck/window-action-menu.h>

#include "config.h"

%%
modulename wnck
%%
import gobject.GObject as PyGObject_Type
import gtk.Container as PyGtkContainer_Type
import gtk.Window as PyGtkWindow_Type
import gtk.MenuBar as PyGtkMenuBar_Type
%%
ignore-glob
 _*
 *_get_type
%%
override wnck_application_get_windows noargs
static PyObject*
_wrap_wnck_application_get_windows (PyGObject *self, PyObject args)
{
    GList *list, *tmp;
    PyObject *ret;

    list = wnck_application_get_windows(WNCK_APPLICATION(self->obj));

    ret = PyList_New(0);
    for (tmp = list; tmp != NULL; tmp = tmp->next) {
        GtkWidget *widget = tmp->data;
        PyObject *item = pygobject_new((GObject *)widget);

        PyList_Append(ret, item);
        Py_DECREF(item);
    }
    return ret;
}
%%
override wnck_screen_get_windows noargs
static PyObject*
_wrap_wnck_screen_get_windows (PyGObject *self, PyObject args)
{
    GList *list, *tmp;
    PyObject *ret;

    list = wnck_screen_get_windows(WNCK_SCREEN(self->obj));

    ret = PyList_New(0);
    for (tmp = list; tmp != NULL; tmp = tmp->next) {
        GtkWidget *widget = tmp->data;
        PyObject *item = pygobject_new((GObject *)widget);

        PyList_Append(ret, item);
        Py_DECREF(item);
    }
    return ret;
}
%%
override wnck_screen_get_windows_stacked noargs
static PyObject*
_wrap_wnck_screen_get_windows_stacked(PyGObject *self, PyObject args)
{
    GList *list, *tmp;
    PyObject *ret;

    list = wnck_screen_get_windows_stacked(WNCK_SCREEN(self->obj));

    ret = PyList_New(0);
    for (tmp = list; tmp != NULL; tmp = tmp->next) {
        GtkWidget *widget = tmp->data;
        PyObject *item = pygobject_new((GObject *)widget);

        PyList_Append(ret, item);
        Py_DECREF(item);
    }
    return ret;
}
%%
override wnck_class_group_get_windows noargs
static PyObject*
_wrap_wnck_class_group_get_windows(PyGObject *self, PyObject args)
{
    GList *list, *tmp;
    PyObject *ret;

    list = wnck_class_group_get_windows(WNCK_CLASS_GROUP(self->obj));

    ret = PyList_New(0);
    for (tmp = list; tmp != NULL; tmp = tmp->next) {
        GtkWidget *widget = tmp->data;
        PyObject *item = pygobject_new((GObject *)widget);

        PyList_Append(ret, item);
        Py_DECREF(item);
    }
    return ret;
}
%%
override wnck_tasklist_get_size_hint_list
static PyObject *
_wrap_wnck_tasklist_get_size_hint_list(PyGObject *self)
{
    const int *list;
    PyObject *pylist;
    int i, len = 0;

    list = wnck_tasklist_get_size_hint_list(WNCK_TASKLIST(self->obj), &len);
    pylist = PyList_New(len);
    for (i = 0; i < len; ++i)
        PyList_SET_ITEM(pylist, i, PyInt_FromLong(list[i]));
    return pylist;
}
%%
override wnck_window_get_geometry noargs
static PyObject *
_wrap_wnck_window_get_geometry(PyGObject *self)
{
    int x, y, width, height;

    wnck_window_get_geometry(WNCK_WINDOW(self->obj), &x, &y, &width, &height);
    return Py_BuildValue("iiii", x, y, width, height);
}
%%
override wnck_screen_get_workspaces noargs
static PyObject*
_wrap_wnck_screen_get_workspaces (PyGObject *self)
{
    GList *list, *tmp;
    PyObject *ret;

    list = wnck_screen_get_workspaces(WNCK_SCREEN(self->obj));

    ret = PyList_New(0);
    for (tmp = list; tmp != NULL; tmp = tmp->next) {
        GtkWidget *widget = tmp->data;
        PyObject *item = pygobject_new((GObject *)widget);

        PyList_Append(ret, item);
        Py_DECREF(item);
    }
    return ret;
}
%%
override wnck_window_get_client_window_geometry noargs
static PyObject *
_wrap_wnck_window_get_client_window_geometry(PyGObject *self)
{
    int x, y, width, height;

    wnck_window_get_client_window_geometry(WNCK_WINDOW(self->obj), &x, &y, &width, &height);
    return Py_BuildValue("iiii", x, y, width, height);
}
