diff options
author | Johan Dahlin <zilch@src.gnome.org> | 2003-06-06 00:09:47 +0000 |
---|---|---|
committer | Johan Dahlin <zilch@src.gnome.org> | 2003-06-06 00:09:47 +0000 |
commit | 16b425f89526b4eda653d75c1a9a461444dd1adc (patch) | |
tree | be66756b5897de88369d6aeaef831bf1b49750a3 /gtk | |
parent | 80e0750d929fcaac005ed159046b056247facfcf (diff) | |
download | pygtk-16b425f89526b4eda653d75c1a9a461444dd1adc.tar.gz |
New files, splitted out from gtk.override
* gtk/gtk*.override: New files, splitted out from gtk.override
* gtk/Makefile.am (EXTRA_DIST): Add *.override here
* codegen/override.py (Overrides.__parse_override): Added
"include" keyword, to be able to include files in override files
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/Makefile.am | 22 | ||||
-rw-r--r-- | gtk/gtk.override | 5174 | ||||
-rw-r--r-- | gtk/gtkclist.override | 334 | ||||
-rw-r--r-- | gtk/gtkcontainer.override | 521 | ||||
-rw-r--r-- | gtk/gtkctree.override | 503 | ||||
-rw-r--r-- | gtk/gtkstyle.override | 238 | ||||
-rw-r--r-- | gtk/gtktextview.override | 1053 | ||||
-rw-r--r-- | gtk/gtktreeview.override | 1791 | ||||
-rw-r--r-- | gtk/gtkwidget.override | 132 | ||||
-rw-r--r-- | gtk/gtkwindow.override | 266 |
10 files changed, 5028 insertions, 5006 deletions
diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 1e3e7479..31057d50 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -52,9 +52,25 @@ gdk.c: $(srcdir)/gdk.defs $(COMMONDEFS) $(srcdir)/gdk.override gtk.c: $(srcdir)/gtk.defs $(COMMONDEFS) $(srcdir)/gtk.override $(srcdir)/gtk-extrafuncs.defs nodist__gtkmodule_la_SOURCES = gtk.c gdk.c CLEANFILES += gtk.c gdk.c -defs_DATA += gtk.defs gtk-types.defs gtk-extrafuncs.defs gdk.defs \ - gdk-types.defs -EXTRA_DIST += gtk.override gdk.override + +defs_DATA += \ + gtk.defs \ + gtk-types.defs \ + gtk-extrafuncs.defs \ + gdk.defs \ + gdk-types.defs + +EXTRA_DIST += \ + gdk.override \ + gtk.override \ + gtkclist.override \ + gtkwidget.override \ + gtkcontainer.override \ + gtkstyle.override \ + gtkwindow.override \ + gtkctree.override \ + gtktextview.override \ + gtktreeview.override # libglade module if BUILD_LIBGLADE diff --git a/gtk/gtk.override b/gtk/gtk.override index c0d8f8ed..2ffcf910 100644 --- a/gtk/gtk.override +++ b/gtk/gtk.override @@ -6,8 +6,6 @@ headers #include <gtk/gtk.h> #include <gdk-pixbuf/gdk-pixbuf.h> #include "pygtk-private.h" -#include "pygtktreemodel.h" -#include "pygtkcellrenderer.h" #define PYGTK_CONTAINER_FOREACH 0 #define PYGTK_CONTAINER_FORALL 1 @@ -22,18 +20,16 @@ extern PyTypeObject PyGdkImage_Type; extern PyTypeObject PyGdkPixbuf_Type; extern PyTypeObject PyGdkPixbufAnimation_Type; extern PyTypeObject PyGdkDragContext_Type; - %% -init - PyGtkListStore_Type.tp_as_number = PyGtkTreeModel_Type.tp_as_number; - PyGtkListStore_Type.tp_as_mapping = PyGtkTreeModel_Type.tp_as_mapping; - PyGtkListStore_Type.tp_iter = PyGtkTreeModel_Type.tp_iter; - PyGtkTreeStore_Type.tp_as_number = PyGtkTreeModel_Type.tp_as_number; - PyGtkTreeStore_Type.tp_as_mapping = PyGtkTreeModel_Type.tp_as_mapping; - PyGtkTreeStore_Type.tp_iter = PyGtkTreeModel_Type.tp_iter; - PyPyGtkGenericTreeModel_Type.tp_as_number = PyGtkTreeModel_Type.tp_as_number; - PyPyGtkGenericTreeModel_Type.tp_as_mapping = PyGtkTreeModel_Type.tp_as_mapping; - PyPyGtkGenericTreeModel_Type.tp_iter = PyGtkTreeModel_Type.tp_iter; +include + gtkclist.override + gtkcontainer.override + gtkctree.override + gtkstyle.override + gtktextview.override + gtktreeview.override + gtkwidget.override + gtkwindow.override %% modulename gtk %% @@ -43,248 +39,173 @@ import pango.Context as PyPangoContext_Type import pango.Font as PyPangoFont_Type import pango.Layout as PyPangoLayout_Type %% +ignore +%% +ignore + gtk_accel_group_add + gtk_accel_group_create_add + gtk_accel_group_create_remove + gtk_accel_group_entries_from_object + gtk_accel_group_get_entry + gtk_accel_group_handle_add + gtk_accel_group_handle_remove + gtk_accel_group_lock_entry + gtk_accel_group_ref + gtk_accel_group_remove + gtk_accel_groups_activate + gtk_accel_groups_from_object + gtk_accel_group_unlock_entry + gtk_accel_group_unref + gtk_binding_set_by_class + gtk_binding_set_clear + gtk_binding_set_find + gtk_binding_set_new + gtk_button_new_from_stock + gtk_button_new_with_label + gtk_button_new_with_mnemonic + gtk_check_button_new_with_label + gtk_check_button_new_with_mnemonic + gtk_check_menu_item_new_with_label + gtk_check_menu_item_new_with_mnemonic + gtk_dialog_new + gtk_drag_dest_handle_event + gtk_drag_source_handle_event + gtk_entry_new + gtk_entry_select_region + gtk_exit + gtk_false + gtk_gc_get + gtk_gc_release + gtk_get_current_event + gtk_get_event_widget + gtk_idle_add + gtk_idle_add_full + gtk_idle_add_priority + gtk_idle_remove + gtk_idle_remove_by_data + gtk_image_item_menu_new_with_label + gtk_image_menu_item_new_from_stock + gtk_image_menu_item_new_with_mnemonic + gtk_init + gtk_init_abi_check + gtk_init_check + gtk_init_check_abi_check + gtk_input_add_full + gtk_input_remove + gtk_item_factory_create_item + gtk_item_factory_create_items_ac + gtk_item_factory_create_menu_entries + gtk_item_factory_delete_entries + gtk_item_factory_delete_entry + gtk_item_factory_popup_data + gtk_item_factory_popup_with_data + gtk_item_factory_set_translate_func + gtk_key_snooper_install + gtk_key_snooper_remove + gtk_list_item_new_with_label + gtk_list_remove_items_no_unref + gtk_menu_append + gtk_menu_bar_append + gtk_menu_bar_insert + gtk_menu_bar_prepend + gtk_menu_insert + gtk_menu_item_new_with_label + gtk_menu_item_new_with_mnemonic + gtk_menu_prepend + gtk_object_add_arg_type + gtk_object_arg_get + gtk_object_arg_get_info + gtk_object_args_collect + gtk_object_arg_set + gtk_object_get + gtk_object_get_data + gtk_object_get_data_by_id + gtk_object_get_user_data + gtk_object_getv + gtk_object_new + gtk_object_newv + gtk_object_query_args + gtk_object_ref + gtk_object_remove_data_by_id + gtk_object_remove_no_notify_by_id + gtk_object_set + gtk_object_set_data + gtk_object_set_data_by_id + gtk_object_set_data_by_id_full + gtk_object_set_data_full + gtk_object_set_user_data + gtk_object_setv + gtk_object_sink + gtk_object_unref + gtk_object_weakref + gtk_object_weakunref + gtk_preview_uninit + gtk_progress_bar_new + gtk_propagate_event + gtk_quit_remove_by_data + gtk_radio_button_group + gtk_radio_menu_item_group + gtk_radio_menu_item_new_with_label + gtk_radio_menu_item_new_with_mnemonic + gtk_range_default_htrough_click + gtk_range_default_vtrough_click + gtk_range_trough_click + gtk_selection_clear + gtk_selection_data_copy + gtk_selection_data_free + gtk_selection_incr_event + gtk_selection_notify + gtk_selection_property_notify + gtk_selection_request + gtk_set_locale + gtk_timeout_remove + gtk_toggle_button_new_with_label + gtk_toggle_button_new_with_mnemonic + gtk_trace_referencing + gtk_tree_remove_items + gtk_true + gtk_type_check_class_cast + gtk_type_check_object_cast + gtk_type_register_enum + gtk_type_register_flags + gtk_widget_destroyed + gtk_widget_get + gtk_widget_getv + gtk_widget_new + gtk_widget_newv + gtk_widget_ref + gtk_widget_set + gtk_widget_setv + gtk_widget_style_get_valist + gtk_widget_unref +%% ignore-glob - *_get_type _* + *_get_type *_ref *_unref + gtk_arg_* + gtk_args_* + gtk_draw_* + gtk_init_add_* + gtk_marshal_* + gtk_pattern_* + gtk_radio_button_new_* + gtk_quit_add_* + gtk_signal_* + gtk_target_list_* + gtk_timeout_add* %% -override-attr GtkStyle.fg -static PyObject * -_wrap_gtk_style__get_fg(PyGObject *self, void *closure) -{ - GtkStyle *style = GTK_STYLE(self->obj); - - return _pygtk_style_helper_new(style, STYLE_COLOUR_ARRAY, style->fg); -} -%% -override-attr GtkStyle.bg -static PyObject * -_wrap_gtk_style__get_bg(PyGObject *self, void *closure) -{ - GtkStyle *style = GTK_STYLE(self->obj); - - return _pygtk_style_helper_new(style, STYLE_COLOUR_ARRAY, style->bg); -} -%% -override-attr GtkStyle.light -static PyObject * -_wrap_gtk_style__get_light(PyGObject *self, void *closure) -{ - GtkStyle *style = GTK_STYLE(self->obj); - - return _pygtk_style_helper_new(style, STYLE_COLOUR_ARRAY, style->light); -} -%% -override-attr GtkStyle.dark -static PyObject * -_wrap_gtk_style__get_dark(PyGObject *self, void *closure) -{ - GtkStyle *style = GTK_STYLE(self->obj); - - return _pygtk_style_helper_new(style, STYLE_COLOUR_ARRAY, style->dark); -} -%% -override-attr GtkStyle.mid -static PyObject * -_wrap_gtk_style__get_mid(PyGObject *self, void *closure) -{ - GtkStyle *style = GTK_STYLE(self->obj); - - return _pygtk_style_helper_new(style, STYLE_COLOUR_ARRAY, style->mid); -} -%% -override-attr GtkStyle.text -static PyObject * -_wrap_gtk_style__get_text(PyGObject *self, void *closure) -{ - GtkStyle *style = GTK_STYLE(self->obj); - - return _pygtk_style_helper_new(style, STYLE_COLOUR_ARRAY, style->text); -} -%% -override-attr GtkStyle.base -static PyObject * -_wrap_gtk_style__get_base(PyGObject *self, void *closure) -{ - GtkStyle *style = GTK_STYLE(self->obj); - - return _pygtk_style_helper_new(style, STYLE_COLOUR_ARRAY, style->base); -} -%% -override-attr GtkStyle.text_aa -static PyObject * -_wrap_gtk_style__get_text_aa(PyGObject *self, void *closure) -{ - GtkStyle *style = GTK_STYLE(self->obj); - - return _pygtk_style_helper_new(style, STYLE_COLOUR_ARRAY, style->text_aa); -} -%% -override-attr GtkStyle.white -static PyObject * -_wrap_gtk_style__get_white(PyGObject *self, void *closure) -{ - GtkStyle *style = GTK_STYLE(self->obj); - - return pyg_boxed_new(GDK_TYPE_COLOR, &style->white, TRUE, TRUE); -} -static int -_wrap_gtk_style__set_white(PyGObject *self, PyObject *value, void *closure) -{ - GtkStyle *style = GTK_STYLE(self->obj); - - if (!pyg_boxed_check(value, GDK_TYPE_COLOR)) { - PyErr_SetString(PyExc_TypeError, "can only assign a GdkColor"); - return -1; - } - style->white = *pyg_boxed_get(value, GdkColor); - return 0; -} -%% -override-attr GtkStyle.black -static PyObject * -_wrap_gtk_style__get_black(PyGObject *self, void *closure) -{ - GtkStyle *style = GTK_STYLE(self->obj); - - return pyg_boxed_new(GDK_TYPE_COLOR, &style->black, TRUE, TRUE); -} -static int -_wrap_gtk_style__set_black(PyGObject *self, PyObject *value, void *closure) -{ - GtkStyle *style = GTK_STYLE(self->obj); - - if (!pyg_boxed_check(value, GDK_TYPE_COLOR)) { - PyErr_SetString(PyExc_TypeError, "can only assign a GdkColor"); - return -1; - } - style->black = *pyg_boxed_get(value, GdkColor); - return 0; -} -%% -override-attr GtkStyle.fg_gc -static PyObject * -_wrap_gtk_style__get_fg_gc(PyGObject *self, void *closure) -{ - GtkStyle *style = GTK_STYLE(self->obj); - - return _pygtk_style_helper_new(style, STYLE_GC_ARRAY, style->fg_gc); -} -%% -override-attr GtkStyle.bg_gc -static PyObject * -_wrap_gtk_style__get_bg_gc(PyGObject *self, void *closure) -{ - GtkStyle *style = GTK_STYLE(self->obj); - - return _pygtk_style_helper_new(style, STYLE_GC_ARRAY, style->bg_gc); -} -%% -override-attr GtkStyle.light_gc -static PyObject * -_wrap_gtk_style__get_light_gc(PyGObject *self, void *closure) -{ - GtkStyle *style = GTK_STYLE(self->obj); - - return _pygtk_style_helper_new(style, STYLE_GC_ARRAY, style->light_gc); -} -%% -override-attr GtkStyle.dark_gc -static PyObject * -_wrap_gtk_style__get_dark_gc(PyGObject *self, void *closure) -{ - GtkStyle *style = GTK_STYLE(self->obj); - - return _pygtk_style_helper_new(style, STYLE_GC_ARRAY, style->dark_gc); -} -%% -override-attr GtkStyle.mid_gc -static PyObject * -_wrap_gtk_style__get_mid_gc(PyGObject *self, void *closure) -{ - GtkStyle *style = GTK_STYLE(self->obj); - - return _pygtk_style_helper_new(style, STYLE_GC_ARRAY, style->mid_gc); -} -%% -override-attr GtkStyle.text_gc -static PyObject * -_wrap_gtk_style__get_text_gc(PyGObject *self, void *closure) -{ - GtkStyle *style = GTK_STYLE(self->obj); - - return _pygtk_style_helper_new(style, STYLE_GC_ARRAY, style->text_gc); -} -%% -override-attr GtkStyle.base_gc -static PyObject * -_wrap_gtk_style__get_base_gc(PyGObject *self, void *closure) -{ - GtkStyle *style = GTK_STYLE(self->obj); - - return _pygtk_style_helper_new(style, STYLE_GC_ARRAY, style->base_gc); -} -%% -override-attr GtkStyle.text_aa_gc -static PyObject * -_wrap_gtk_style__get_text_aa_gc(PyGObject *self, void *closure) -{ - GtkStyle *style = GTK_STYLE(self->obj); - - return _pygtk_style_helper_new(style, STYLE_GC_ARRAY, style->text_aa_gc); -} -%% -override-attr GtkStyle.white_gc -static PyObject * -_wrap_gtk_style__get_white_gc(PyGObject *self, void *closure) -{ - GtkStyle *style = GTK_STYLE(self->obj); - - return pygobject_new((GObject *)style->white_gc); -} -static int -_wrap_gtk_style__set_white_gc(PyGObject *self, PyObject *value, void *closure) -{ - GtkStyle *style = GTK_STYLE(self->obj); - - if (!pygobject_check(value, &PyGdkGC_Type)) { - PyErr_SetString(PyExc_TypeError, "can only assign a GdkGC"); - return -1; - } - style->white_gc = GDK_GC(pygobject_get(value)); - return 0; -} -%% -override-attr GtkStyle.black_gc -static PyObject * -_wrap_gtk_style__get_black_gc(PyGObject *self, void *closure) -{ - GtkStyle *style = GTK_STYLE(self->obj); - - return pygobject_new((GObject *)style->black_gc); -} -static int -_wrap_gtk_style__set_black_gc(PyGObject *self, PyObject *value, void *closure) -{ - GtkStyle *style = GTK_STYLE(self->obj); - - if (!pygobject_check(value, &PyGdkGC_Type)) { - PyErr_SetString(PyExc_TypeError, "can only assign a GdkGC"); - return -1; - } - style->black_gc = GDK_GC(pygobject_get(value)); - return 0; -} -%% -override-attr GtkStyle.bg_pixmap -static PyObject * -_wrap_gtk_style__get_bg_pixmap(PyGObject *self, void *closure) -{ - GtkStyle *style = GTK_STYLE(self->obj); - - return _pygtk_style_helper_new(style, STYLE_PIXMAP_ARRAY, style->bg_pixmap); -} +ignore-win32 + GTK_TYPE_PLUG + GTK_TYPE_SOCKET + gtk_socket_new + gtk_socket_steal + gtk_socket_add_id + gtk_socket_get_id + gtk_plug_new + gtk_plug_construct + gtk_plug_get_id %% override gtk_paint_polygon kwargs static PyObject * @@ -357,8 +278,6 @@ _wrap_gtk_selection_data__get_data(PyGObject *self, void *closure) } } %% -ignore gtk_selection_data_copy gtk_selection_data_free -%% override gtk_selection_data_set kwargs static PyObject * _wrap_gtk_selection_data_set(PyGBoxed *self, PyObject *args, PyObject *kwargs) @@ -421,665 +340,6 @@ _wrap_gtk_selection_data_get_targets(PyObject *self) return Py_None; } %% -override gtk_tree_get_row_drag_data noargs -static PyObject * -_wrap_gtk_tree_get_row_drag_data(PyObject *self) -{ - GtkTreeModel *tree_model; - GtkTreePath *path; - - if (gtk_tree_get_row_drag_data(pyg_boxed_get(self, GtkSelectionData), - &tree_model, &path)) { - PyObject *ret = Py_BuildValue("(NN)", - pygobject_new((GObject *)tree_model), - pygtk_tree_path_to_pyobject(path)); - - gtk_tree_path_free(path); - return ret; - } - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_widget_translate_coordinates kwargs -static PyObject * -_wrap_gtk_widget_translate_coordinates(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "dest_widget", "src_x", "src_y", NULL }; - PyObject *py_dest_widget; - int src_x, src_y; - GtkWidget *dest_widget = NULL; - int dest_x, dest_y; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Oii:GtkWidget.translate_coordinates", - kwlist, &py_dest_widget, &src_x, &src_y)) { - return NULL; - } - - if (pygobject_check(py_dest_widget, &PyGtkWidget_Type)) { - dest_widget = GTK_WIDGET(pygobject_get(py_dest_widget)); - } else if (py_dest_widget != Py_None) { - PyErr_SetString(PyExc_TypeError, - "dest_widget must be a GtkWidget or None"); - return NULL; - } - - if (!gtk_widget_translate_coordinates(GTK_WIDGET(self->obj), - dest_widget, - src_x, - src_y, - &dest_x, - &dest_y)) { - return Py_BuildValue ("()"); - } - - return Py_BuildValue ("(ii)", &dest_x, &dest_y); -} -%% -override gtk_widget_size_request noargs -static PyObject * -_wrap_gtk_widget_size_request(PyGObject *self) -{ - GtkRequisition requisition; - - gtk_widget_size_request(GTK_WIDGET(self->obj), &requisition); - return Py_BuildValue("(ii)", requisition.width, requisition.height); -} -%% -override gtk_widget_get_child_requisition noargs -static PyObject * -_wrap_gtk_widget_get_child_requisition(PyGObject *self) -{ - GtkRequisition requisition; - - gtk_widget_get_child_requisition(GTK_WIDGET(self->obj), &requisition); - return Py_BuildValue("(ii)", requisition.width, requisition.height); -} -%% -override gtk_widget_get_allocation noargs -static PyObject * -_wrap_gtk_widget_get_allocation(PyGObject *self) -{ - GtkAllocation allocation; - - allocation = GTK_WIDGET(self->obj)->allocation; - return pyg_boxed_new(GDK_TYPE_RECTANGLE, &allocation, TRUE, TRUE); -} -%% -override gtk_widget_intersect kwargs -static PyObject * -_wrap_gtk_widget_intersect(PyGObject *self, PyObject *args, PyObject*kwargs) -{ - static char *kwlist[] = { "area", NULL }; - PyObject *py_area; - GdkRectangle area, intersect; - - if(!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GtkWidget.intersect", - kwlist, &py_area)) - return NULL; - if (!pygdk_rectangle_from_pyobject(py_area, &area)) - return NULL; - if (gtk_widget_intersect(GTK_WIDGET(self->obj), &area, &intersect)) - return pyg_boxed_new(GDK_TYPE_RECTANGLE, &intersect, TRUE, TRUE); - else { - Py_INCREF(Py_None); - return Py_None; - } -} -%% -override gtk_widget_get_pointer noargs -static PyObject * -_wrap_gtk_widget_get_pointer(PyGObject *self) -{ - int x, y; - - gtk_widget_get_pointer(GTK_WIDGET(self->obj), &x, &y); - return Py_BuildValue("(ii)", x, y); -} -%% -override gtk_widget_path noargs -static PyObject * -_wrap_gtk_widget_path(PyGObject *self) -{ - guint length; - gchar *path; - gchar *path_reversed; - PyObject *result; - - gtk_widget_path(GTK_WIDGET(self->obj), &length, &path, &path_reversed); - result = PyString_FromString(path); - g_free(path); - g_free(path_reversed); - - return result; -} -%% -override gtk_widget_class_path noargs -static PyObject * -_wrap_gtk_widget_class_path(PyGObject *self) -{ - guint length; - gchar *path; - gchar *path_reversed; - PyObject *result; - - gtk_widget_class_path(GTK_WIDGET(self->obj), &length, &path, - &path_reversed); - result = PyString_FromString(path); - g_free(path); - g_free(path_reversed); - - return result; -} -%% -override gtk_container_children noargs -static PyObject * -_wrap_gtk_container_children(PyGObject *self) -{ - if (PyErr_Warn(PyExc_DeprecationWarning, "use GtkContainer.get_children")) - return NULL; - return _wrap_gtk_container_get_children(self); -} -%% -override gtk_container_get_children noargs -static PyObject * -_wrap_gtk_container_get_children(PyGObject *self) -{ - GList *list, *tmp; - PyObject *py_list; - - list = gtk_container_get_children(GTK_CONTAINER(self->obj)); - - if ((py_list = PyList_New(0)) == NULL) { - g_list_free(list); - return NULL; - } - for (tmp = list; tmp != NULL; tmp = tmp->next) { - PyObject *gtk_obj = pygobject_new(G_OBJECT(tmp->data)); - - if (gtk_obj == NULL) { - g_list_free(list); - Py_DECREF(py_list); - return NULL; - } - PyList_Append(py_list, gtk_obj); - Py_DECREF(gtk_obj); - } - g_list_free(list); - return py_list; -} -%% -override gtk_container_set_focus_chain kwargs -static PyObject * -_wrap_gtk_container_set_focus_chain(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "focusable_widgets", NULL }; - PyObject *py_focusable_widgets; - gint len, i; - GList *focusable_widgets = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O:GtkContainer.set_focus_chain", kwlist, - &py_focusable_widgets)) - return NULL; - if (!PySequence_Check(py_focusable_widgets)) { - PyErr_SetString(PyExc_TypeError, - "focusable_widgets must be a sequence"); - return NULL; - } - len = PySequence_Length(py_focusable_widgets); - for (i = 0; i < len; i++) { - PyObject *item = PySequence_GetItem(py_focusable_widgets, i); - - if (!pygobject_check(item, &PyGtkWidget_Type)) { - PyErr_SetString(PyExc_TypeError, - "focusable_widgets members must be GtkWidgets"); - Py_DECREF(item); - return NULL; - } - focusable_widgets = g_list_prepend(focusable_widgets, - pygobject_get(item)); - Py_DECREF(item); - } - focusable_widgets = g_list_reverse(focusable_widgets); - gtk_container_set_focus_chain(GTK_CONTAINER(self->obj), focusable_widgets); - g_list_free(focusable_widgets); - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_container_get_focus_chain noargs -static PyObject * -_wrap_gtk_container_get_focus_chain(PyGObject *self) -{ - GList *list = NULL; - - if (gtk_container_get_focus_chain(GTK_CONTAINER(self->obj), &list)) { - PyObject *py_list; - GList *tmp; - - if ((py_list = PyList_New(0)) == NULL) { - g_list_free(list); - return NULL; - } - for (tmp = list; tmp != NULL; tmp = tmp->next) { - PyObject *gtk_obj = pygobject_new(G_OBJECT(tmp->data)); - - if (gtk_obj == NULL) { - g_list_free(list); - Py_DECREF(py_list); - return NULL; - } - PyList_Append(py_list, gtk_obj); - Py_DECREF(gtk_obj); - } - g_list_free(list); - return py_list; - } - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_container_child_get_property -static PyObject * -_wrap_gtk_container_child_get_property(PyGObject *self, PyObject *args) -{ - PyGObject *pychild; - gchar *property_name; - GtkContainer *container; - GtkWidget *child; - GList *children; - GObjectClass *class; - GParamSpec *pspec; - GValue value = { 0, } ; - PyObject *ret; - - if (!PyArg_ParseTuple(args, "O!s:GtkContainer.child_get_property", - &PyGtkWidget_Type, &pychild, - &property_name)) { - return NULL; - } - - container = GTK_CONTAINER(self->obj); - child = GTK_WIDGET(pychild->obj); - - children = gtk_container_get_children(container); - if (g_list_find(children, child) == NULL) { - PyErr_SetString(PyExc_TypeError, - "first argument must be a child"); - return NULL; - } - - class = G_OBJECT_GET_CLASS(container); - pspec = gtk_container_class_find_child_property(class, property_name); - if (!pspec) { - gchar buf[512]; - g_snprintf(buf, sizeof(buf), - "container does not support property `%s'", - property_name); - - PyErr_SetString(PyExc_TypeError, buf); - return NULL; - } - - g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec)); - - gtk_container_child_get_property(container, - child, - property_name, - &value); - - ret = pyg_value_as_pyobject(&value, TRUE); - g_value_unset(&value); - - return ret; -} -%% -override gtk_container_child_set_property -static PyObject * -_wrap_gtk_container_child_set_property(PyGObject *self, PyObject *args) -{ - gchar *property_name; - PyGObject *pychild; - GtkContainer *container; - GtkWidget *child; - GList *children; - PyGObject *pyvalue; - GObjectClass *class; - GParamSpec *pspec; - GValue value = { 0, } ; - - if (!PyArg_ParseTuple(args, "O!sO:GtkContainer.child_set_property", - &PyGtkWidget_Type, &pychild, - &property_name, &pyvalue)) { - return NULL; - } - - container = GTK_CONTAINER(self->obj); - child = GTK_WIDGET(pychild->obj); - - children = gtk_container_get_children(container); - if (g_list_find(children, child) == NULL) { - PyErr_SetString(PyExc_TypeError, - "first argument must be a child"); - return NULL; - } - - class = G_OBJECT_GET_CLASS(self->obj); - pspec = gtk_container_class_find_child_property(class, property_name); - if (!pspec) { - gchar buf[512]; - g_snprintf(buf, sizeof(buf), - "container does not support property `%s'", - property_name); - PyErr_SetString(PyExc_TypeError, buf); - - return NULL; - } - - g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec)); - - pyg_value_from_pyobject(&value, (PyObject*)pyvalue); - - gtk_container_child_set_property(container, - child, - property_name, - &value); - g_value_unset(&value); - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_container_child_set -static PyObject * -_wrap_gtk_container_child_set(PyGObject *self, PyObject *args) -{ - PyGObject *pychild; - GtkContainer *container; - GtkWidget *child; - GList *children; - GObjectClass *class; - int len, i; - - pychild = (PyGObject*)PyTuple_GetItem(args, 0); - if (!pygobject_check(pychild, &PyGtkWidget_Type)) { - PyErr_SetString(PyExc_TypeError, "first argument should be a GtkWidget"); - return NULL; - } - - container = GTK_CONTAINER(self->obj); - child = GTK_WIDGET(pychild->obj); - - children = gtk_container_get_children(container); - if (g_list_find(children, child) == NULL) { - PyErr_SetString(PyExc_TypeError, - "first argument must be a child"); - return NULL; - } - - len = PyTuple_Size(args); - if ((len - 1) % 2) { - PyErr_SetString(PyExc_TypeError, - "Argument list must be column, value pairs. No -1 " - "termination is needed."); - return NULL; - } - - class = G_OBJECT_GET_CLASS(self->obj); - for (i = 1; i < len; i+=2) { - PyObject *py_property = PyTuple_GetItem(args, i); - PyObject *py_value = PyTuple_GetItem(args, i + 1); - gchar *property_name; - GParamSpec *pspec; - GValue value = { 0 }; - - if (!PyString_Check(py_property)) { - PyErr_SetString(PyExc_TypeError, - "Expected string argument for property."); - return NULL; - } - - property_name = PyString_AsString(py_property); - - pspec = gtk_container_class_find_child_property(class, property_name); - if (!pspec) { - gchar buf[512]; - g_snprintf(buf, sizeof(buf), - "container does not support property `%s'", - property_name); - PyErr_SetString(PyExc_TypeError, buf); - - return NULL; - } - - g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec)); - - pyg_value_from_pyobject(&value, (PyObject*)py_value); - - gtk_container_child_set_property(container, child, property_name, &value); - - g_value_unset(&value); - } - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_container_child_get -static PyObject * -_wrap_gtk_container_child_get(PyGObject *self, PyObject *args) -{ - PyGObject *pychild; - GtkContainer *container; - GtkWidget *child; - GList *children; - GObjectClass *class; - int len, i; - PyObject *tuple; - - pychild = (PyGObject*)PyTuple_GetItem(args, 0); - if (!pygobject_check(pychild, &PyGtkWidget_Type)) { - PyErr_SetString(PyExc_TypeError, "first argument should be a GtkWidget"); - return NULL; - } - - container = GTK_CONTAINER(self->obj); - child = GTK_WIDGET(pychild->obj); - - children = gtk_container_get_children(container); - if (g_list_find(children, child) == NULL) { - PyErr_SetString(PyExc_TypeError, - "first argument must be a child"); - return NULL; - } - - len = PyTuple_Size(args); - tuple = PyTuple_New(len-1); - class = G_OBJECT_GET_CLASS(self->obj); - for (i = 1; i < len; i++) { - PyObject *py_property = PyTuple_GetItem(args, i); - gchar *property_name; - GParamSpec *pspec; - GValue value = { 0 }; - PyObject *item; - - if (!PyString_Check(py_property)) { - PyErr_SetString(PyExc_TypeError, - "Expected string argument for property."); - return NULL; - } - - property_name = PyString_AsString(py_property); - - pspec = gtk_container_class_find_child_property(class, property_name); - if (!pspec) { - gchar buf[512]; - g_snprintf(buf, sizeof(buf), - "container does not support property `%s'", - property_name); - PyErr_SetString(PyExc_TypeError, buf); - - return NULL; - } - - g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec)); - - gtk_container_child_get_property(container, child, property_name, &value); - - item = pyg_value_as_pyobject(&value, TRUE); - PyTuple_SetItem(tuple, i-1, item); - Py_INCREF(item); - - g_value_unset(&value); - } - - Py_INCREF(tuple); - return tuple; -} -%% -override gtk_container_add_with_properties -static PyObject * -_wrap_gtk_container_add_with_properties(PyGObject *self, PyObject *args) -{ - PyGObject *pychild; - GtkContainer *container; - GtkWidget *child; - GObjectClass *class; - int len, i; - - pychild = (PyGObject*)PyTuple_GetItem(args, 0); - if (!pygobject_check(pychild, &PyGtkWidget_Type)) { - PyErr_SetString(PyExc_TypeError, "first argument should be a GtkWidget"); - return NULL; - } - - container = GTK_CONTAINER(self->obj); - child = GTK_WIDGET(pychild->obj); - - len = PyTuple_Size(args); - if ((len - 1) % 2) { - PyErr_SetString(PyExc_TypeError, - "Argument list must be column, value pairs. No -1 " - "termination is needed."); - return NULL; - } - - gtk_widget_freeze_child_notify(child); - - gtk_container_add(container, child); - - class = G_OBJECT_GET_CLASS(self->obj); - for (i = 1; i < len; i+=2) { - PyObject *py_property = PyTuple_GetItem(args, i); - PyObject *py_value = PyTuple_GetItem(args, i + 1); - gchar *property_name; - GParamSpec *pspec; - GValue value = { 0 }; - - if (!PyString_Check(py_property)) { - PyErr_SetString(PyExc_TypeError, - "Expected string argument for property."); - return NULL; - } - - property_name = PyString_AsString(py_property); - - pspec = gtk_container_class_find_child_property(class, property_name); - if (!pspec) { - gchar buf[512]; - g_snprintf(buf, sizeof(buf), - "container does not support property `%s'", - property_name); - PyErr_SetString(PyExc_TypeError, buf); - - return NULL; - } - - g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec)); - - pyg_value_from_pyobject(&value, (PyObject*)py_value); - - gtk_container_child_set_property(container, child, property_name, &value); - - g_value_unset(&value); - } - - gtk_widget_thaw_child_notify(child); - - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_container_foreach -static void -pygtk_container_for_common_marshal(GtkWidget *widget, - gpointer data) -{ - PyGtkCustomNotify *cunote = data; - PyObject *py_widget, *retobj; - - g_assert(cunote->func); - - pyg_block_threads(); - - py_widget = pygobject_new((GObject*)widget); - if (cunote->data) - retobj = PyEval_CallFunction(cunote->func, "(NO)", - py_widget, cunote->data); - else - retobj = PyEval_CallFunction(cunote->func, "(N)", - py_widget); - - if (retobj == NULL) { - PyErr_Print(); - } - - Py_XDECREF(retobj); - - pyg_unblock_threads(); -} -static PyObject * -pygtk_container_for_common(PyGObject *self, PyObject *args, unsigned for_index) -{ - PyObject *pyfunc, *pyarg = NULL; - PyGtkCustomNotify cunote; - static struct { - char *parse_arg; - void (*for_func)(GtkContainer *container, GtkCallback callback, - gpointer callback_data); - } table[] = { - { "O|O:GtkContainer.foreach", gtk_container_foreach }, - { "O|O:GtkContainer.forall", gtk_container_forall } - }; - - g_assert(for_index < countof(table)); - - if (!PyArg_ParseTuple(args, table[for_index].parse_arg, - &pyfunc, &pyarg)) - return NULL; - - cunote.func = pyfunc; - cunote.data = pyarg; - table[for_index].for_func(GTK_CONTAINER(self->obj), - pygtk_container_for_common_marshal, - &cunote); - - Py_INCREF(Py_None); - return Py_None; -} -static PyObject * -_wrap_gtk_container_foreach(PyGObject *self, PyObject *args) -{ - return pygtk_container_for_common(self, args, PYGTK_CONTAINER_FOREACH); -} -%% -override gtk_container_forall -static PyObject * -_wrap_gtk_container_forall(PyGObject *self, PyObject *args) -{ - return pygtk_container_for_common(self, args, PYGTK_CONTAINER_FORALL); -} -%% override gtk_label_get noargs static PyObject * _wrap_gtk_label_get(PyGObject *self) @@ -1139,130 +399,6 @@ _wrap_gtk_spin_button_get_range(PyGObject *self) return Py_BuildValue("(dd)", min, max); } %% -override gtk_window_list_toplevels noargs -static PyObject * -_wrap_gtk_window_list_toplevels(PyGObject *self) -{ - GList *list, *tmp; - PyObject *py_list; - PyObject *gtk_obj; - - list = gtk_window_list_toplevels(); - - if ((py_list = PyList_New(0)) == NULL) { - g_list_free(list); - return NULL; - } - for (tmp = list; tmp != NULL; tmp = tmp->next) { - gtk_obj = pygobject_new(G_OBJECT(tmp->data)); - if (gtk_obj == NULL) { - g_list_free(list); - Py_DECREF(py_list); - return NULL; - } - PyList_Append(py_list, gtk_obj); - Py_DECREF(gtk_obj); - } - g_list_free(list); - return py_list; -} -%% -override gtk_window_set_geometry_hints kwargs -static PyObject * -_wrap_gtk_window_set_geometry_hints(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "geometry_widget", "min_width", "min_height", - "max_width", "max_height", "base_width", - "base_height", "width_inc", "height_inc", - "min_aspect", "max_aspect", NULL }; - PyObject *py_geometry_widget = Py_None; - GtkWidget *geometry_widget = NULL; - gint min_width = -1, min_height = -1, max_width = -1, max_height = -1; - gint base_width = -1, base_height = -1, width_inc = -1, height_inc = -1; - gdouble min_aspect = -1.0, max_aspect = -1.0; - GdkGeometry geometry = { 0 }; - GdkWindowHints geom_mask = 0; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "|Oiiiiiiiidd:GtkWindow.set_geometry_hints", kwlist, - &py_geometry_widget, &min_width, - &min_height, &max_width, &max_height, - &base_width, &base_height, &width_inc, - &height_inc, &min_aspect, &max_aspect)) - return NULL; - if (pygobject_check(py_geometry_widget, &PyGtkWidget_Type)) - geometry_widget = GTK_WIDGET(pygobject_get(py_geometry_widget)); - else if (py_geometry_widget != Py_None) { - PyErr_SetString(PyExc_TypeError, - "geometry_widget must be a GtkWidget or None"); - return NULL; - } - if (min_width >= 0 || min_height >= 0) { - geometry.min_width = MAX(min_width, 0); - geometry.min_height = MAX(min_height, 0); - geom_mask |= GDK_HINT_MIN_SIZE; - } - if (max_width >= 0 || max_height >= 0) { - geometry.max_width = MAX(max_width, 0); - geometry.max_height = MAX(max_height, 0); - geom_mask |= GDK_HINT_MAX_SIZE; - } - if (base_width >= 0 || base_height >= 0) { - geometry.base_width = MAX(base_width, 0); - geometry.base_height = MAX(base_height, 0); - geom_mask |= GDK_HINT_BASE_SIZE; - } - if (width_inc >= 0 || height_inc >= 0) { - geometry.width_inc = MAX(width_inc, 0); - geometry.height_inc = MAX(height_inc, 0); - geom_mask |= GDK_HINT_RESIZE_INC; - } - if (min_aspect >= 0.0 || max_aspect >= 0.0) { - if (min_aspect <= 0.0 || max_aspect <= 0.0) { - PyErr_SetString(PyExc_TypeError, "aspect ratios must be positive"); - return NULL; - } - geometry.min_aspect = min_aspect; - geometry.max_aspect = max_aspect; - geom_mask |= GDK_HINT_ASPECT; - } - gtk_window_set_geometry_hints(GTK_WINDOW(self->obj), geometry_widget, - &geometry, geom_mask); - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_window_get_position -static PyObject * -_wrap_gtk_window_get_position(PyGObject *self) -{ - gint root_x, root_y; - - gtk_window_get_position(GTK_WINDOW(self->obj), &root_x, &root_y); - return Py_BuildValue("(ii)", root_x, root_y); -} -%% -override gtk_window_get_size -static PyObject * -_wrap_gtk_window_get_size(PyGObject *self) -{ - gint width, height; - - gtk_window_get_size(GTK_WINDOW(self->obj), &width, &height); - return Py_BuildValue("(ii)", width, height); -} -%% -override gtk_window_get_default_size -static PyObject * -_wrap_gtk_window_get_default_size(PyGObject *self) -{ - gint width, height; - - gtk_window_get_default_size(GTK_WINDOW(self->obj), &width, &height); - return Py_BuildValue("(ii)", width, height); -} -%% override gtk_box_query_child_packing kwargs static PyObject * _wrap_gtk_box_query_child_packing(PyGObject *self, PyObject *args, @@ -1295,337 +431,6 @@ _wrap_gtk_box_query_child_packing(PyGObject *self, PyObject *args, return Py_BuildValue("(iiii)", (int)expand, (int)fill, padding, pack_type); } %% -ignore gtk_clist_new -%% -override gtk_clist_new_with_titles kwargs -static int -_wrap_gtk_clist_new_with_titles(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "count", "titles", NULL }; - int count = 1, i; - PyObject *py_list = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|iO:GtkCList.__init__", - kwlist, &count, &py_list)) - return -1; - if (py_list) { - gchar **list; - - if (!PySequence_Check(py_list)) { - PyErr_SetString(PyExc_TypeError,"2nd argument not a sequence"); - return -1; - } - if (PySequence_Length(py_list) < count) { - PyErr_SetString(PyExc_TypeError, "sequence not long enough"); - return -1; - } - list = g_new(gchar *, count); - for (i = 0; i < count; i++) { - PyObject *item = PySequence_GetItem(py_list, i); - - Py_DECREF(item); /* PySequence_GetItem INCREF's */ - if (!PyString_Check(item) && !PyUnicode_Check(item)) { - PyErr_SetString(PyExc_TypeError, - "sequence item not a string or unicode object"); - g_free(list); - return -1; - } - list[i] = PyString_AsString(item); - } - self->obj = (GObject *)gtk_clist_new_with_titles(count, list); - g_free(list); - } else - self->obj = (GObject *)gtk_clist_new(count); - if (!self->obj) { - PyErr_SetString(PyExc_RuntimeError,"could not create GtkCList object"); - return -1; - } - pygobject_register_wrapper((PyObject *)self); - return 0; -} -%% -override gtk_clist_get_text kwargs -static PyObject * -_wrap_gtk_clist_get_text(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "row", "column", NULL }; - int r, c; - char *text = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:GtkCList.get_text", - kwlist, &r, &c)) - return NULL; - if (!gtk_clist_get_text(GTK_CLIST(self->obj), r, c, &text) || text==NULL) { - PyErr_SetString(PyExc_ValueError, "can't get text value"); - return NULL; - } - return PyString_FromString(text); -} -%% -override gtk_clist_get_pixmap kwargs -static PyObject * -_wrap_gtk_clist_get_pixmap(PyGObject *self, PyObject *args, PyObject*kwargs) -{ - static char *kwlist[] = { "row", "column", NULL }; - int r, c; - GdkPixmap *pixmap; - GdkBitmap *mask; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:GtkCList.get_pixmap", - kwlist, &r, &c)) - return NULL; - if (!gtk_clist_get_pixmap(GTK_CLIST(self->obj), r, c, - &pixmap, &mask)) { - PyErr_SetString(PyExc_ValueError, "can't get pixmap value"); - return NULL; - } - return Py_BuildValue("(NN)", pygobject_new((GObject *)pixmap), - pygobject_new((GObject *)mask)); -} -%% -override gtk_clist_get_pixtext kwargs -static PyObject * -_wrap_gtk_clist_get_pixtext(PyGObject *self, PyObject *args, PyObject*kwargs) -{ - static char *kwlist[] = { "row", "column", NULL }; - int r, c; - gchar *text; - guint8 spacing; - GdkPixmap *pixmap; - GdkBitmap *mask; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:GtkCList.get_pixtext", - kwlist, &r, &c)) - return NULL; - if (!gtk_clist_get_pixtext(GTK_CLIST(self->obj), r, c, - &text, &spacing, &pixmap, &mask)) { - PyErr_SetString(PyExc_ValueError, "can't get pixtext value"); - return NULL; - } - return Py_BuildValue("(ziNN)", text, (gint)spacing, - pygobject_new((GObject *)pixmap), - pygobject_new((GObject *)mask)); -} -%% -override gtk_clist_prepend kwargs -static PyObject * -_wrap_gtk_clist_prepend(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "text", NULL }; - int col, i; - PyObject *py_list; - gchar **list; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GtkCList.prepend", - kwlist, &py_list)) - return NULL; - if (!PySequence_Check(py_list)) { - PyErr_SetString(PyExc_TypeError, "argument not a sequence"); - return NULL; - } - col = GTK_CLIST(self->obj)->columns; - if (PySequence_Length(py_list) < col) { - PyErr_SetString(PyExc_TypeError, "sequnce too short"); - return NULL; - } - list = g_new(gchar *, col); - for (i = 0; i < col; i++) { - PyObject *item = PySequence_GetItem(py_list, i); - - Py_DECREF(item); - if (!PyString_Check(item) && !PyUnicode_Check(item)) { - PyErr_SetString(PyExc_TypeError, - "sequence item not a string or unicode object"); - g_free(list); - return NULL; - } - list[i] = PyString_AsString(item); - } - i = gtk_clist_prepend(GTK_CLIST(self->obj), list); - g_free(list); - return PyInt_FromLong(i); -} -%% -override gtk_clist_append kwargs -static PyObject * -_wrap_gtk_clist_append(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "text", NULL }; - int col, i; - PyObject *py_list; - gchar **list; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GtkCList.append", - kwlist, &py_list)) - return NULL; - if (!PySequence_Check(py_list)) { - PyErr_SetString(PyExc_TypeError, "argument not a sequence"); - return NULL; - } - col = GTK_CLIST(self->obj)->columns; - if (PySequence_Length(py_list) < col) { - PyErr_SetString(PyExc_TypeError, "sequnce too short"); - return NULL; - } - list = g_new(gchar *, col); - for (i = 0; i < col; i++) { - PyObject *item = PySequence_GetItem(py_list, i); - - Py_DECREF(item); - if (!PyString_Check(item) && !PyUnicode_Check(item)) { - PyErr_SetString(PyExc_TypeError, - "sequence item not a string or unicode object"); - g_free(list); - return NULL; - } - list[i] = PyString_AsString(item); - } - i = gtk_clist_append(GTK_CLIST(self->obj), list); - g_free(list); - return PyInt_FromLong(i); -} -%% -override gtk_clist_insert kwargs -static PyObject * -_wrap_gtk_clist_insert(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "row", "text", NULL }; - int col, row, i; - PyObject *py_list; - gchar **list; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iO:GtkCList.insert", - kwlist, &row, &py_list)) - return NULL; - if (!PySequence_Check(py_list)) { - PyErr_SetString(PyExc_TypeError, "argument not a sequence"); - return NULL; - } - col = GTK_CLIST(self->obj)->columns; - if (PySequence_Length(py_list) < col) { - PyErr_SetString(PyExc_TypeError, "sequnce too short"); - return NULL; - } - list = g_new(gchar *, col); - for (i = 0; i < col; i++) { - PyObject *item = PySequence_GetItem(py_list, i); - - Py_DECREF(item); - if (!PyString_Check(item) && !PyUnicode_Check(item)) { - PyErr_SetString(PyExc_TypeError, - "sequence item not a string or unicode object"); - g_free(list); - return NULL; - } - list[i] = PyString_AsString(item); - } - i = gtk_clist_insert(GTK_CLIST(self->obj), row, list); - g_free(list); - return PyInt_FromLong(i); -} -%% -override gtk_clist_set_row_data kwargs -static PyObject * -_wrap_gtk_clist_set_row_data(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "row", "data", NULL }; - int row; - PyObject *data; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iO:GtkCList.set_row_data", - kwlist, &row, &data)) - return NULL; - Py_INCREF(data); - gtk_clist_set_row_data_full(GTK_CLIST(self->obj), row, data, - (GtkDestroyNotify)pyg_destroy_notify); - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_clist_get_row_data kwargs -static PyObject * -_wrap_gtk_clist_get_row_data(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "row", NULL }; - PyObject *ret; - int row; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:GtkCList.get_row_data", - kwlist, &row)) - return NULL; - ret = gtk_clist_get_row_data(GTK_CLIST(self->obj), row); - if (!ret) ret = Py_None; - Py_INCREF(ret); - return ret; -} -%% -override gtk_clist_find_row_from_data kwargs -static PyObject * -_wrap_gtk_clist_find_row_from_data(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "data", NULL }; - PyObject *data; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O:GtkCList.find_row_from_data", kwlist, - &data)) - return NULL; - return PyInt_FromLong(gtk_clist_find_row_from_data( - GTK_CLIST(self->obj), data)); -} -%% -override gtk_clist_get_selection_info kwargs -static PyObject * -_wrap_gtk_clist_get_selection_info(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "x", "y", NULL }; - gint x, y, row, column; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "ii:GtkCList.get_selection_info", kwlist, - &x, &y)) - return NULL; - if (gtk_clist_get_selection_info(GTK_CLIST(self->obj), x, y, - &row, &column)) - return Py_BuildValue("(ii)", row, column); - else { - Py_INCREF(Py_None); - return Py_None; - } -} -%% -override-attr GtkCList.selection -static PyObject * -_wrap_gtk_clist__get_selection(PyGObject *self, void *closure) -{ - guint row; - GList *selection; - PyObject *py_int, *ret = PyList_New(0); - - if (ret == NULL) - return NULL; - - for (selection = GTK_CLIST(self->obj)->selection; selection != NULL; - selection = selection->next) { - row = GPOINTER_TO_UINT(selection->data); - - py_int = PyInt_FromLong(row); - - if (!py_int) { - Py_DECREF(ret); - return NULL; - } - - PyList_Append(ret, py_int); - Py_DECREF(py_int); - } - return ret; -} -%% override gtk_combo_set_popdown_strings kwargs static PyObject * _wrap_gtk_combo_set_popdown_strings(PyGObject *self, PyObject *args, @@ -1724,1716 +529,7 @@ _wrap_gtk_curve_set_vector(PyGObject *self, PyObject *args, return Py_None; } %% -override gtk_tree_model_get_iter kwargs -static PyObject * -_wrap_gtk_tree_model_get_iter(PyGObject *self, PyObject *args,PyObject *kwargs) -{ - static char *kwlist[] = { "path", NULL }; - PyObject *py_path; - GtkTreeIter iter; - GtkTreePath *path; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GtkTreeModel.get_iter", - kwlist, &py_path)) - return NULL; - - path = pygtk_tree_path_from_pyobject(py_path); - if (!path) { - PyErr_SetString(PyExc_TypeError, "GtkTreeModel.get_iter requires a tree path as its argument"); - return NULL; - } - if (gtk_tree_model_get_iter(GTK_TREE_MODEL(self->obj), &iter, path)) { - gtk_tree_path_free(path); - return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); - } else { - gtk_tree_path_free(path); - PyErr_SetString(PyExc_ValueError, "invalid tree path"); - return NULL; - } -} -%% -override gtk_tree_model_get_iter_from_string kwargs -static PyObject * -_wrap_gtk_tree_model_get_iter_from_string(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "path_string", NULL }; - const gchar *path_string; - GtkTreeIter iter; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "s:GtkTreeModel.get_iter_from_string", - kwlist, &path_string)) - return NULL; - - if (gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(self->obj), &iter, - path_string)) { - return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); - } else { - PyErr_SetString(PyExc_ValueError, "invalid tree path"); - return NULL; - } -} -%% -override gtk_tree_model_get_value kwargs -static PyObject * -_wrap_gtk_tree_model_get_value(PyGObject *self, PyObject*args, PyObject*kwargs) -{ - static char *kwlist[] = { "iter", "column", NULL }; - PyObject *iter, *ret; - gint column; - GValue value = { 0, }; - - if (!PyArg_ParseTupleAndKeywords(args,kwargs, "Oi:GtkTreeModel.get_value", - kwlist, &iter, &column)) - return NULL; - if (column < 0 || - column >= gtk_tree_model_get_n_columns(GTK_TREE_MODEL(self->obj))) { - PyErr_SetString(PyExc_ValueError, "column number is out of range"); - return NULL; - } - if (!pyg_boxed_check(iter, GTK_TYPE_TREE_ITER)) { - PyErr_SetString(PyExc_TypeError, "iter must be a GtkTreeIter"); - return NULL; - } - gtk_tree_model_get_value(GTK_TREE_MODEL(self->obj), - pyg_boxed_get(iter, GtkTreeIter), column, &value); - ret = pyg_value_as_pyobject(&value, TRUE); - g_value_unset(&value); - return ret; -} -%% -override-slot GtkTreeModel.tp_as_number -static int -_wrap_gtk_tree_model_tp_nonzero(PyGObject *self) -{ - return TRUE; -} -static PyNumberMethods _wrap_gtk_tree_model_tp_as_number = { - (binaryfunc)0, - (binaryfunc)0, - (binaryfunc)0, - (binaryfunc)0, - (binaryfunc)0, - (binaryfunc)0, - (ternaryfunc)0, - (unaryfunc)0, - (unaryfunc)0, - (unaryfunc)0, - (inquiry)_wrap_gtk_tree_model_tp_nonzero, - (unaryfunc)0, - (binaryfunc)0, - (binaryfunc)0, - (binaryfunc)0, - (binaryfunc)0, - (binaryfunc)0, - (coercion)0, - (unaryfunc)0, - (unaryfunc)0, - (unaryfunc)0, - (unaryfunc)0, - (unaryfunc)0 -}; -%% -override-slot GtkTreeModel.tp_as_mapping -static int -_wrap_gtk_tree_model_tp_length(PyGObject *self) -{ - return gtk_tree_model_iter_n_children(GTK_TREE_MODEL(self->obj), NULL); -} -static PyObject * -_wrap_gtk_tree_model_tp_getitem(PyGObject *self, PyObject *item) -{ - GtkTreePath *path; - GtkTreeIter iter; - PyObject *ret = NULL; - - if (pyg_boxed_check(item, GTK_TYPE_TREE_ITER)) { - return _pygtk_tree_model_row_new(GTK_TREE_MODEL(self->obj), - pyg_boxed_get(item, GtkTreeIter)); - } - - path = pygtk_tree_path_from_pyobject(item); - if (!path) { - PyErr_SetString(PyExc_TypeError, - "could not parse subscript as a tree path"); - return NULL; - } - if (gtk_tree_model_get_iter(GTK_TREE_MODEL(self->obj), &iter, path)) { - ret = _pygtk_tree_model_row_new(GTK_TREE_MODEL(self->obj), &iter); - } else { - PyErr_SetString(PyExc_IndexError, "could not find tree path"); - ret = NULL; - } - gtk_tree_path_free(path); - return ret; -} -static int -_wrap_gtk_tree_model_tp_setitem(PyGObject *self, PyObject *item, - PyObject *value) -{ - GtkTreeIter *iter, iter2; - - if (pyg_boxed_check(item, GTK_TYPE_TREE_ITER)) { - iter = pyg_boxed_get(item, GtkTreeIter); - } else { - GtkTreePath *path = pygtk_tree_path_from_pyobject(item); - - if (!path) { - PyErr_SetString(PyExc_TypeError, - "could not parse subscript as a tree path"); - return -1; - } - if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(self->obj), &iter2,path)) { - PyErr_SetString(PyExc_TypeError, "could not find tree path"); - gtk_tree_path_free(path); - return -1; - } - iter = &iter2; - gtk_tree_path_free(path); - } - - if (value == NULL) { - if (GTK_IS_LIST_STORE(self->obj)) { - gtk_list_store_remove(GTK_LIST_STORE(self->obj), iter); - return 0; - } else if (GTK_IS_TREE_STORE(self->obj)) { - gtk_tree_store_remove(GTK_TREE_STORE(self->obj), iter); - return 0; - } else { - PyErr_SetString(PyExc_TypeError, - "don't know how to remove rows " - "from this type of tree model"); - return -1; - } - } else { - return _pygtk_tree_model_set_row(GTK_TREE_MODEL(self->obj), iter,value); - } -} - -static PyMappingMethods _wrap_gtk_tree_model_tp_as_mapping = { - (inquiry)_wrap_gtk_tree_model_tp_length, - (binaryfunc)_wrap_gtk_tree_model_tp_getitem, - (objobjargproc)_wrap_gtk_tree_model_tp_setitem -}; -%% -override-slot GtkTreeModel.tp_iter -static PyObject * -_wrap_gtk_tree_model_tp_iter(PyGObject *self) -{ - return _pygtk_tree_model_row_iter_new(GTK_TREE_MODEL(self->obj), NULL); -} -%% -override gtk_tree_sortable_get_sort_column_id noargs -static PyObject * -_wrap_gtk_tree_sortable_get_sort_column_id(PyGObject *self) -{ - gboolean ret; - gint sort_column_id; - GtkSortType order; - - ret = gtk_tree_sortable_get_sort_column_id(GTK_TREE_SORTABLE(self->obj), - &sort_column_id, &order); - - /* if we don't have a sort column set, return (None, None) */ - if (ret) - return Py_BuildValue("(ii)", sort_column_id, order); - else - return Py_BuildValue("(OO)", Py_None, Py_None); -} -%% -override gtk_tree_sortable_set_sort_func -static gint -pygtk_tree_sortable_sort_cb(GtkTreeModel *model, GtkTreeIter *iter1, - GtkTreeIter *iter2, gpointer user_data) -{ - PyGtkCustomNotify *cunote = user_data; - PyObject *py_model, *py_iter2, *py_iter1, *retobj; - gint ret = 0; - - g_assert(cunote->func); - - pyg_block_threads(); - - py_model = pygobject_new((GObject *)model); - py_iter1 = pyg_boxed_new(GTK_TYPE_TREE_ITER, iter1, TRUE, TRUE); - py_iter2 = pyg_boxed_new(GTK_TYPE_TREE_ITER, iter2, TRUE, TRUE); - - if (cunote->data) { - retobj = PyEval_CallFunction(cunote->func, "(NNNO)", py_model, - py_iter1, py_iter2, cunote->data); - } else { - retobj = PyEval_CallFunction(cunote->func, "(NNN)", py_model, - py_iter1, py_iter2); - } - - if (retobj) - ret = PyInt_AsLong(retobj); - if (PyErr_Occurred()) { - PyErr_Print(); - ret = 0; - } - Py_XDECREF(retobj); - - pyg_unblock_threads(); - return ret; -} -static PyObject * -_wrap_gtk_tree_sortable_set_sort_func(PyGObject *self, PyObject *args) -{ - gint column; - PyObject *callback, *data = NULL; - PyGtkCustomNotify *cunote; - - if (!PyArg_ParseTuple(args, "iO|O:GtkTreeSortable.set_sort_func", - &column, &callback, &data)) - return NULL; - - if (!PyCallable_Check(callback)) { - PyErr_SetString(PyExc_TypeError, "callback must be a callable object"); - return NULL; - } - cunote = g_new(PyGtkCustomNotify, 1); - Py_INCREF(callback); - cunote->func = callback; - Py_XINCREF(data); - cunote->data = data; - - gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(self->obj), column, - pygtk_tree_sortable_sort_cb, cunote, - pygtk_custom_destroy_notify); - - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_tree_sortable_set_default_sort_func -static PyObject * -_wrap_gtk_tree_sortable_set_default_sort_func(PyGObject *self, PyObject *args) -{ - PyObject *callback, *data = NULL; - PyGtkCustomNotify *cunote; - - if (!PyArg_ParseTuple(args, "O|O:GtkTreeSortable.set_default_sort_func", - &callback, &data)) - return NULL; - - if (!PyCallable_Check(callback)) { - PyErr_SetString(PyExc_TypeError, "callback must be a callable object"); - return NULL; - } - cunote = g_new(PyGtkCustomNotify, 1); - Py_INCREF(callback); - cunote->func = callback; - Py_XINCREF(data); - cunote->data = data; - - gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(self->obj), - pygtk_tree_sortable_sort_cb, - cunote, - pygtk_custom_destroy_notify); - - Py_INCREF(Py_None); - return Py_None; -} -%% -ignore gtk_list_store_newv -%% -override gtk_list_store_new -static int -_wrap_gtk_list_store_new(PyGObject *self, PyObject *args) -{ - guint len, i; - GType *column_types; - - len = PyTuple_Size(args); - if (len == 0) { - PyErr_SetString(PyExc_TypeError, - "GtkListStore requires at least one argument"); - return -1; - } - - column_types = g_new(GType, len); - for (i = 0; i < len; i++) { - PyObject *item = PyTuple_GetItem(args, i); - - column_types[i] = pyg_type_from_object(item); - if (column_types[i] == 0) { - g_free(column_types); - return -1; - } - } - self->obj = (GObject *)gtk_list_store_newv(len, column_types); - g_free(column_types); - if (!self->obj) { - PyErr_SetString(PyExc_RuntimeError, - "could not create GtkListStore object"); - return -1; - } - pygobject_register_wrapper((PyObject *)self); - return 0; -} -%% -ignore gtk_list_store_set_valist -%% -override gtk_list_store_set -static PyObject * -_wrap_gtk_list_store_set(PyGObject *self, PyObject *args) -{ - PyObject *iter; - int len, i; - - len = PyTuple_Size(args); - if (len == 0) { - PyErr_SetString(PyExc_TypeError, "GtkListStore.set requires at least three arguments"); - return NULL; - } - - iter = PyTuple_GetItem(args, 0); - if (!pyg_boxed_check(iter, GTK_TYPE_TREE_ITER)) { - PyErr_SetString(PyExc_TypeError, "iter must be a GtkTreeIter"); - return NULL; - } - - if ((len - 1) % 2) { - PyErr_SetString(PyExc_TypeError, - "Argument list must be column, value pairs. No -1 " - "termination is needed."); - return NULL; - } - for (i = 1; i < len; i+=2) { - gint column; - GValue value = { 0 }; - PyObject *py_column = PyTuple_GetItem(args, i); - PyObject *py_value = PyTuple_GetItem(args, i + 1); - - if (!PyInt_Check(py_column)) { - PyErr_SetString(PyExc_TypeError, - "Expected numeric argument for column."); - return NULL; - } - column = PyInt_AsLong(py_column); - if (column < 0 || - column >= gtk_tree_model_get_n_columns(GTK_TREE_MODEL(self->obj))) { - PyErr_SetString(PyExc_ValueError, "column number is out of range"); - return NULL; - } - g_value_init(&value, - gtk_tree_model_get_column_type(GTK_TREE_MODEL(self->obj), - column)); - if (pyg_value_from_pyobject(&value, py_value)) { - PyErr_SetString(PyExc_TypeError, - "value is of the wrong type for this column"); - return NULL; - } - gtk_list_store_set_value(GTK_LIST_STORE(self->obj), - pyg_boxed_get(iter, GtkTreeIter), column, &value); - g_value_unset(&value); - } - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_list_store_set_value kwargs -static PyObject * -_wrap_gtk_list_store_set_value(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "iter", "column", "value", NULL }; - PyObject *iter, *pyvalue; - gint column; - GValue value = { 0 }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "OiO:GtkListStore.set_value", - kwlist, &iter, &column, &pyvalue)) - return NULL; - if (column < 0 || - column >= gtk_tree_model_get_n_columns(GTK_TREE_MODEL(self->obj))) { - PyErr_SetString(PyExc_ValueError, "column number is out of range"); - return NULL; - } - if (!pyg_boxed_check(iter, GTK_TYPE_TREE_ITER)) { - PyErr_SetString(PyExc_TypeError, "iter must be a GtkTreeIter"); - return NULL; - } - g_value_init(&value, - gtk_tree_model_get_column_type(GTK_TREE_MODEL(self->obj), - column)); - if (pyg_value_from_pyobject(&value, pyvalue)) { - PyErr_SetString(PyExc_TypeError, - "value is of the wrong type for this column"); - return NULL; - } - gtk_list_store_set_value(GTK_LIST_STORE(self->obj), - pyg_boxed_get(iter, GtkTreeIter), column, &value); - g_value_unset(&value); - Py_INCREF(Py_None); - return Py_None; -} -%% -ignore - gtk_list_store_setv -%% - override gtk_list_store_insert kwargs -static PyObject * -_wrap_gtk_list_store_insert(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "position", "row", NULL }; - GtkTreeIter iter; - gint position; - PyObject *row = Py_None; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i|O:GtkListStore.insert", - kwlist, &position, &row)) { - return NULL; - } - gtk_list_store_insert(GTK_LIST_STORE(self->obj), &iter, position); - - /* optionally set items in the new row */ - if (row != Py_None && - _pygtk_tree_model_set_row(GTK_TREE_MODEL(self->obj), &iter, row) < 0) - return NULL; - - return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); -} -%% -override gtk_list_store_insert_before kwargs -static PyObject * -_wrap_gtk_list_store_insert_before(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "sibling", "row", NULL }; - PyObject *sibling; - GtkTreeIter iter; - PyObject *row = Py_None; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O|O:GtkListStore.insert_before", - kwlist, &sibling, &row)) { - return NULL; - } - - if (!pyg_boxed_check(sibling, GTK_TYPE_TREE_ITER)) { - PyErr_SetString(PyExc_TypeError, "iter must be a GtkTreeIter"); - return NULL; - } - gtk_list_store_insert_before(GTK_LIST_STORE(self->obj), &iter, - pyg_boxed_get(sibling, GtkTreeIter)); - - /* optionally set items in the new row */ - if (row != Py_None && - _pygtk_tree_model_set_row(GTK_TREE_MODEL(self->obj), &iter, row) < 0) - return NULL; - - return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); -} -%% -override gtk_list_store_insert_after kwargs -static PyObject * -_wrap_gtk_list_store_insert_after(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "sibling", "row", NULL }; - PyObject *sibling; - GtkTreeIter iter; - PyObject *row = Py_None; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O|O:GtkListStore.insert_after", - kwlist, &sibling, &row)) - return NULL; - if (!pyg_boxed_check(sibling, GTK_TYPE_TREE_ITER)) { - PyErr_SetString(PyExc_TypeError, "iter must be a GtkTreeIter"); - return NULL; - } - gtk_list_store_insert_after(GTK_LIST_STORE(self->obj), &iter, - pyg_boxed_get(sibling, GtkTreeIter)); - - /* optionally set items in the new row */ - if (row != Py_None && - _pygtk_tree_model_set_row(GTK_TREE_MODEL(self->obj), &iter, row) < 0) - return NULL; - - return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); -} -%% -override gtk_list_store_prepend kwargs -static PyObject * -_wrap_gtk_list_store_prepend(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "row", NULL }; - GtkTreeIter iter; - PyObject *row = Py_None; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:GtkListStore.prepend", - kwlist, &row)) - return NULL; - - gtk_list_store_prepend(GTK_LIST_STORE(self->obj), &iter); - - /* optionally set items in the new row */ - if (row != Py_None && - _pygtk_tree_model_set_row(GTK_TREE_MODEL(self->obj), &iter, row) < 0) - return NULL; - - return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); -} -%% -override gtk_list_store_append kwargs -static PyObject * -_wrap_gtk_list_store_append(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "row", NULL }; - GtkTreeIter iter; - PyObject *row = Py_None; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:GtkListStore.append", - kwlist, &row)) - return NULL; - - gtk_list_store_append(GTK_LIST_STORE(self->obj), &iter); - - /* optionally set items in the new row */ - if (row != Py_None && - _pygtk_tree_model_set_row(GTK_TREE_MODEL(self->obj), &iter, row) < 0) - return NULL; - - return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); -} -%% -ignore gtk_tree_store_newv -%% -override gtk_tree_store_new -static int -_wrap_gtk_tree_store_new(PyGObject *self, PyObject *args) -{ - guint len, i; - GType *column_types; - - len = PyTuple_Size(args); - if (len == 0) { - PyErr_SetString(PyExc_TypeError, "GtkTreeStore requires at least one argument"); - return -1; - } - - column_types = g_new(GType, len); - for (i = 0; i < len; i++) { - PyObject *item = PyTuple_GetItem(args, i); - - column_types[i] = pyg_type_from_object(item); - if (column_types[i] == 0) { - g_free(column_types); - return -1; - } - } - self->obj = (GObject *)gtk_tree_store_newv(len, column_types); - g_free(column_types); - if (!self->obj) { - PyErr_SetString(PyExc_RuntimeError, - "could not create GtkTreeStore object"); - return -1; - } - pygobject_register_wrapper((PyObject *)self); - return 0; -} -%% -ignore gtk_tree_store_set_valist -%% -override gtk_tree_store_set -static PyObject * -_wrap_gtk_tree_store_set(PyGObject *self, PyObject *args) -{ - PyObject *iter; - int len, i; - - len = PyTuple_Size(args); - if (len == 0) { - PyErr_SetString(PyExc_TypeError, "GtkTreeStore.set requires at least three arguments"); - return NULL; - } - - iter = PyTuple_GetItem(args, 0); - if (!pyg_boxed_check(iter, GTK_TYPE_TREE_ITER)) { - PyErr_SetString(PyExc_TypeError, "iter must be a GtkTreeIter"); - return NULL; - } - - if ((len - 1) % 2) { - PyErr_SetString(PyExc_TypeError, - "Argument list must be column, value pairs. No -1 " - "termination is needed."); - return NULL; - } - for (i = 1; i < len; i+=2) { - gint column; - GValue value = { 0 }; - PyObject *py_column = PyTuple_GetItem(args, i); - PyObject *py_value = PyTuple_GetItem(args, i + 1); - - if (!PyInt_Check(py_column)) { - PyErr_SetString(PyExc_TypeError, - "Expected numeric argument for column."); - return NULL; - } - column = PyInt_AsLong(py_column); - if (column < 0 || - column >= gtk_tree_model_get_n_columns(GTK_TREE_MODEL(self->obj))) { - PyErr_SetString(PyExc_ValueError, "column number is out of range"); - return NULL; - } - g_value_init(&value, - gtk_tree_model_get_column_type(GTK_TREE_MODEL(self->obj), - column)); - if (pyg_value_from_pyobject(&value, py_value)) { - PyErr_SetString(PyExc_TypeError, - "value is of the wrong type for this column"); - return NULL; - } - gtk_tree_store_set_value(GTK_TREE_STORE(self->obj), - pyg_boxed_get(iter, GtkTreeIter), column, - &value); - g_value_unset(&value); - } - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_tree_store_set_value kwargs -static PyObject * -_wrap_gtk_tree_store_set_value(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "iter", "column", "value", NULL }; - PyObject *iter, *pyvalue; - gint column; - GValue value = { 0 }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "OiO:GtkTreeStore.set_value", - kwlist, &iter, &column, &pyvalue)) - return NULL; - if (column < 0 || - column >= gtk_tree_model_get_n_columns(GTK_TREE_MODEL(self->obj))) { - PyErr_SetString(PyExc_ValueError, "column number is out of range"); - return NULL; - } - if (!pyg_boxed_check(iter, GTK_TYPE_TREE_ITER)) { - PyErr_SetString(PyExc_TypeError, "iter must be a GtkTreeIter"); - return NULL; - } - g_value_init(&value, - gtk_tree_model_get_column_type(GTK_TREE_MODEL(self->obj), - column)); - if (pyg_value_from_pyobject(&value, pyvalue)) { - PyErr_SetString(PyExc_TypeError, - "value is of the wrong type for this column"); - return NULL; - } - gtk_tree_store_set_value(GTK_TREE_STORE(self->obj), - pyg_boxed_get(iter, GtkTreeIter), column, &value); - g_value_unset(&value); - Py_INCREF(Py_None); - return Py_None; -} -%% -ignore - gtk_tree_store_setv -%% -override gtk_tree_store_insert kwargs -static PyObject * -_wrap_gtk_tree_store_insert(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "parent", "position", "row", NULL }; - PyObject *py_parent; - GtkTreeIter iter, *parent = NULL; - gint position; - PyObject *row = Py_None; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Oi|O:GtkTreeStore.insert", - kwlist, &py_parent, &position, &row)) - return NULL; - if (pyg_boxed_check(py_parent, GTK_TYPE_TREE_ITER)) - parent = pyg_boxed_get(py_parent, GtkTreeIter); - else if (py_parent != Py_None) { - PyErr_SetString(PyExc_TypeError, - "parent must be a GtkTreeIter or None"); - return NULL; - } - gtk_tree_store_insert(GTK_TREE_STORE(self->obj), &iter, parent, position); - - /* optionally set items in the new row */ - if (row != Py_None && - _pygtk_tree_model_set_row(GTK_TREE_MODEL(self->obj), &iter, row) < 0) - return NULL; - - return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); -} -%% -override gtk_tree_store_insert_before kwargs -static PyObject * -_wrap_gtk_tree_store_insert_before(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "parent", "sibling", "row", NULL }; - PyObject *py_parent, *py_sibling; - GtkTreeIter iter, *parent = NULL, *sibling = NULL; - PyObject *row = Py_None; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "OO|O:GtkTreeStore.insert_before", - kwlist, &py_parent, &py_sibling, &row)) - return NULL; - if (pyg_boxed_check(py_parent, GTK_TYPE_TREE_ITER)) - parent = pyg_boxed_get(py_parent, GtkTreeIter); - else if (py_parent != Py_None) { - PyErr_SetString(PyExc_TypeError, - "parent must be a GtkTreeIter or None"); - return NULL; - } - if (pyg_boxed_check(py_sibling, GTK_TYPE_TREE_ITER)) - sibling = pyg_boxed_get(py_sibling, GtkTreeIter); - else if (py_sibling != Py_None) { - PyErr_SetString(PyExc_TypeError, - "sibling must be a GtkTreeIter or None"); - return NULL; - } - gtk_tree_store_insert_before(GTK_TREE_STORE(self->obj), &iter, parent, - sibling); - - /* optionally set items in the new row */ - if (row != Py_None && - _pygtk_tree_model_set_row(GTK_TREE_MODEL(self->obj), &iter, row) < 0) - return NULL; - - return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); -} -%% -override gtk_tree_store_insert_after kwargs -static PyObject * -_wrap_gtk_tree_store_insert_after(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "parent", "sibling", "row", NULL }; - PyObject *py_parent, *py_sibling; - GtkTreeIter iter, *parent = NULL, *sibling = NULL; - PyObject *row = Py_None; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "OO|O:GtkTreeStore.insert_after", - kwlist, &py_parent, &py_sibling, &row)) - return NULL; - if (pyg_boxed_check(py_parent, GTK_TYPE_TREE_ITER)) - parent = pyg_boxed_get(py_parent, GtkTreeIter); - else if (py_parent != Py_None) { - PyErr_SetString(PyExc_TypeError, - "parent must be a GtkTreeIter or None"); - return NULL; - } - if (pyg_boxed_check(py_sibling, GTK_TYPE_TREE_ITER)) - sibling = pyg_boxed_get(py_sibling, GtkTreeIter); - else if (py_sibling != Py_None) { - PyErr_SetString(PyExc_TypeError, - "sibling must be a GtkTreeIter or None"); - return NULL; - } - gtk_tree_store_insert_after(GTK_TREE_STORE(self->obj), &iter, parent, - sibling); - - /* optionally set items in the new row */ - if (row != Py_None && - _pygtk_tree_model_set_row(GTK_TREE_MODEL(self->obj), &iter, row) < 0) - return NULL; - - return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); -} -%% -override gtk_tree_store_prepend kwargs -static PyObject * -_wrap_gtk_tree_store_prepend(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "parent", "row", NULL }; - PyObject *py_parent; - GtkTreeIter iter, *parent = NULL; - PyObject *row = Py_None; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:GtkTreeStore.prepend", - kwlist, &py_parent, &row)) - return NULL; - if (pyg_boxed_check(py_parent, GTK_TYPE_TREE_ITER)) - parent = pyg_boxed_get(py_parent, GtkTreeIter); - else if (py_parent != Py_None) { - PyErr_SetString(PyExc_TypeError, - "parent must be a GtkTreeIter or None"); - return NULL; - } - gtk_tree_store_prepend(GTK_TREE_STORE(self->obj), &iter, parent); - - /* optionally set items in the new row */ - if (row != Py_None && - _pygtk_tree_model_set_row(GTK_TREE_MODEL(self->obj), &iter, row) < 0) - return NULL; - - return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); -} -%% -override gtk_tree_store_append kwargs -static PyObject * -_wrap_gtk_tree_store_append(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "parent", "row", NULL }; - PyObject *py_parent; - GtkTreeIter iter, *parent = NULL; - PyObject *row = Py_None; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:GtkTreeStore.append", - kwlist, &py_parent, &row)) - return NULL; - if (pyg_boxed_check(py_parent, GTK_TYPE_TREE_ITER)) - parent = pyg_boxed_get(py_parent, GtkTreeIter); - else if (py_parent != Py_None) { - PyErr_SetString(PyExc_TypeError, - "parent must be a GtkTreeIter or None"); - return NULL; - } - gtk_tree_store_append(GTK_TREE_STORE(self->obj), &iter, parent); - - /* optionally set items in the new row */ - if (row != Py_None && - _pygtk_tree_model_set_row(GTK_TREE_MODEL(self->obj), &iter, row) < 0) - return NULL; - - return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); -} -%% -override gtk_tree_model_get_iter_first noargs -static PyObject * -_wrap_gtk_tree_model_get_iter_first(PyGObject *self) -{ - GtkTreeIter iter; - - if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(self->obj), &iter)) - return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); - else { - Py_INCREF(Py_None); - return Py_None; - } -} -%% -override gtk_tree_model_iter_next kwargs -static PyObject * -_wrap_gtk_tree_model_iter_next(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "iter", NULL }; - PyObject *py_iter; - GtkTreeIter iter; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O:GtkTreeModel.iter_next", kwlist, - &py_iter)) - return NULL; - if (pyg_boxed_check(py_iter, GTK_TYPE_TREE_ITER)) - iter = *pyg_boxed_get(py_iter, GtkTreeIter); - else { - PyErr_SetString(PyExc_TypeError, "iter should be a GtkTreeIter"); - return NULL; - } - - if (gtk_tree_model_iter_next(GTK_TREE_MODEL(self->obj), &iter)) - return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); - else { - Py_INCREF(Py_None); - return Py_None; - } -} -%% -override gtk_tree_model_iter_children kwargs -static PyObject * -_wrap_gtk_tree_model_iter_children(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "parent", NULL }; - PyObject *py_parent; - GtkTreeIter iter, *parent = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O:GtkTreeModel.iter_children", kwlist, - &py_parent)) - return NULL; - if (pyg_boxed_check(py_parent, GTK_TYPE_TREE_ITER)) - parent = pyg_boxed_get(py_parent, GtkTreeIter); - else { - PyErr_SetString(PyExc_TypeError, "parent should be a GtkTreeIter"); - return NULL; - } - - if (gtk_tree_model_iter_children(GTK_TREE_MODEL(self->obj), - &iter, parent)) - return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); - else { - Py_INCREF(Py_None); - return Py_None; - } -} -%% -override gtk_tree_model_iter_nth_child kwargs -static PyObject * -_wrap_gtk_tree_model_iter_nth_child(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "parent", "n", NULL }; - PyObject *py_parent; - gint n; - GtkTreeIter iter, *parent = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "Oi:GtkTreeModel.iter_nth_child", kwlist, - &py_parent, &n)) - return NULL; - if (pyg_boxed_check(py_parent, GTK_TYPE_TREE_ITER)) - parent = pyg_boxed_get(py_parent, GtkTreeIter); - else if (py_parent == Py_None) - parent = NULL; - else { - PyErr_SetString(PyExc_TypeError, "parent should be a GtkTreeIter or None"); - return NULL; - } - - if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(self->obj), - &iter, parent, n)) - return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); - else { - Py_INCREF(Py_None); - return Py_None; - } -} -%% -override gtk_tree_model_iter_parent kwargs -static PyObject * -_wrap_gtk_tree_model_iter_parent(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "child", NULL }; - PyObject *py_child; - GtkTreeIter iter, *child = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O:GtkTreeModel.iter_parent", kwlist, - &py_child)) - return NULL; - if (pyg_boxed_check(py_child, GTK_TYPE_TREE_ITER)) - child = pyg_boxed_get(py_child, GtkTreeIter); - else { - PyErr_SetString(PyExc_TypeError, "child should be a GtkTreeIter"); - return NULL; - } - - if (gtk_tree_model_iter_parent(GTK_TREE_MODEL(self->obj), - &iter, child)) - return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); - else { - Py_INCREF(Py_None); - return Py_None; - } -} -%% -override gtk_tree_model_foreach -static gboolean -pygtk_tree_foreach_marshal(GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer data) -{ - PyGtkCustomNotify *cunote = data; - PyObject *py_model, *py_path, *py_iter, *retobj; - gboolean ret; - - g_assert(cunote->func); - - pyg_block_threads(); - - py_model = pygobject_new((GObject *)model); - py_path = pygtk_tree_path_to_pyobject(path); - py_iter = pyg_boxed_new(GTK_TYPE_TREE_ITER, iter, TRUE, TRUE); - if (cunote->data) - retobj = PyEval_CallFunction(cunote->func, "(NNNO)", - py_model, py_path, py_iter, - cunote->data); - else - retobj = PyEval_CallFunction(cunote->func, "(NNN)", - py_model, py_path, py_iter); - - if (retobj != NULL) { - ret = PyObject_IsTrue(retobj); - Py_DECREF(retobj); - } else { - ret = TRUE; - } - - pyg_unblock_threads(); - return ret; -} -static PyObject * -_wrap_gtk_tree_model_foreach(PyGObject *self, PyObject *args) -{ - static gboolean pygtk_tree_foreach_marshal(GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer data); - PyObject *pyfunc, *pyarg = NULL; - PyGtkCustomNotify cunote; - - if(!PyArg_ParseTuple(args, "O|O:GtkTreeModel.foreach", - &pyfunc, &pyarg)) - return NULL; - - cunote.func = pyfunc; - cunote.data = pyarg; - gtk_tree_model_foreach(GTK_TREE_MODEL(self->obj), - pygtk_tree_foreach_marshal, &cunote); - - if (PyErr_Occurred()) - return NULL; - - Py_INCREF(Py_None); - return Py_None; -} -%% -ignore - gtk_tree_view_new -%% -override gtk_tree_view_get_visible_rect noargs -static PyObject * -_wrap_gtk_tree_view_get_visible_rect(PyGObject *self) -{ - GdkRectangle visible_rect; - - gtk_tree_view_get_visible_rect(GTK_TREE_VIEW(self->obj), &visible_rect); - return pyg_boxed_new(GDK_TYPE_RECTANGLE, &visible_rect, TRUE, TRUE); -} -%% -override gtk_tree_view_column_new kwargs -static int -_wrap_gtk_tree_view_column_new(PyGObject *self, PyObject*args, PyObject*kwargs) -{ - PyObject *py_cell = NULL, *key, *item; - GtkTreeViewColumn *tvc; - gchar *title = NULL; - GtkCellRenderer *cell = NULL; - gint i = 0; - - if (!PyArg_ParseTuple(args, "|zO:GtkTreeViewColumn.__init__", &title, - &py_cell)) - return -1; - if (py_cell != NULL) { - if (pygobject_check(py_cell, &PyGtkCellRenderer_Type)) - cell = GTK_CELL_RENDERER(pygobject_get(py_cell)); - else if (py_cell != Py_None) { - PyErr_SetString(PyExc_TypeError, - "cell must be a GtkCellRenderer or None"); - return -1; - } - } - tvc = gtk_tree_view_column_new(); - if (title) - gtk_tree_view_column_set_title(tvc, title); - if (cell) - gtk_tree_view_column_pack_start(tvc, cell, TRUE); - if (kwargs) { - while (PyDict_Next(kwargs, &i, &key, &item)) { - gchar *attr = PyString_AsString(key); - - if (!PyInt_Check(item)) { - gchar err[128]; - g_snprintf(err, sizeof(err), - "%s must be an integer column number", attr); - PyErr_SetString(PyExc_TypeError, err); - g_object_unref(G_OBJECT(tvc)); - return -1; - } - gtk_tree_view_column_add_attribute(tvc, cell, attr, - PyInt_AsLong(item)); - } - } - self->obj = (GObject *)tvc; - pygobject_register_wrapper((PyObject *)self); - return 0; -} -%% -override gtk_tree_view_column_cell_get_size noargs -static PyObject * -_wrap_gtk_tree_view_column_cell_get_size(PyGObject *self) -{ - GdkRectangle cell_area; - gint x_offset, y_offset, width, height; - - gtk_tree_view_column_cell_get_size(GTK_TREE_VIEW_COLUMN(self->obj), - &cell_area, - &x_offset, &y_offset, &width, &height); - - return Py_BuildValue("(Niiii)", - pyg_boxed_new(GDK_TYPE_RECTANGLE, - &cell_area, TRUE, TRUE), - x_offset, y_offset, width, height); -} -%% -override gtk_tree_view_column_get_cell_renderers noargs -static PyObject * -_wrap_gtk_tree_view_column_get_cell_renderers(PyGObject *self) -{ - GList *list, *tmp; - PyObject *ret; - - list = gtk_tree_view_column_get_cell_renderers( - GTK_TREE_VIEW_COLUMN(self->obj)); - - ret = PyList_New(0); - for (tmp = list; tmp != NULL; tmp = tmp->next) { - GtkWidget *renderer = tmp->data; - PyObject *item = pygobject_new((GObject *)renderer); - - PyList_Append(ret, item); - Py_DECREF(item); - } - g_list_free(list); - return ret; -} -%% -override gtk_tree_view_column_set_cell_data_func kwargs -static void -pygtk_cell_data_func_marshal (GtkTreeViewColumn *tree_column, - GtkCellRenderer *cell, - GtkTreeModel *tree_model, - GtkTreeIter *iter, gpointer data) -{ - PyGtkCustomNotify *cunote = data; - PyObject *retobj; - PyObject *pytreecolumn, *pycell, *pytreemodel, *pyiter; - - g_assert (cunote->func); - - pyg_block_threads(); - - pytreecolumn = pygobject_new((GObject *)tree_column); - pycell = pygobject_new((GObject *)cell); - pytreemodel = pygobject_new((GObject *)tree_model); - pyiter = pyg_boxed_new(GTK_TYPE_TREE_ITER, iter, - TRUE, TRUE); - if (cunote->data) - retobj = PyEval_CallFunction(cunote->func, "(OOOOO)", - pytreecolumn, pycell, - pytreemodel, pyiter, cunote->data); - else - retobj = PyEval_CallFunction(cunote->func, "(OOOO)", - pytreecolumn, pycell, - pytreemodel, pyiter, cunote->data); - - if (retobj == NULL) { - PyErr_Print(); - } else - Py_DECREF(retobj); - - pyg_unblock_threads(); -} - -static PyObject * -_wrap_gtk_tree_view_column_set_cell_data_func (PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - PyObject *pycell,*pyfunc, *pyarg = NULL; - GtkCellRenderer *cell; - PyGtkCustomNotify *cunote; - - if (!PyArg_ParseTuple(args, "OO|O:GtkTreeViewColumn.set_cell_data_func", - &pycell, &pyfunc, &pyarg)) - return NULL; - - if (pygobject_check(pycell, &PyGtkCellRenderer_Type)) - cell = GTK_CELL_RENDERER(pygobject_get(pycell)); - else { - PyErr_SetString(PyExc_TypeError, - "first argument must be a GtkCellRenderer"); - return NULL; - } - - cunote = g_new0(PyGtkCustomNotify, 1); - cunote->func = pyfunc; - cunote->data = pyarg; - Py_INCREF(cunote->func); - Py_XINCREF(cunote->data); - - gtk_tree_view_column_set_cell_data_func (GTK_TREE_VIEW_COLUMN (self->obj), cell, - pygtk_cell_data_func_marshal, - cunote, - pygtk_custom_destroy_notify); - - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_tree_view_insert_column_with_data_func kwargs -static PyObject * -_wrap_gtk_tree_view_insert_column_with_data_func (PyGObject *self, - PyObject *args, - PyObject *kwargs) -{ - int position; - gchar *title; - PyObject *pycell,*pyfunc, *pyarg = NULL; - GtkCellRenderer *cell; - PyGtkCustomNotify *cunote; - gint retval; - - if (!PyArg_ParseTuple(args, - "isOO|O:GtkTreeView.insert_column_with_data_func", - &position, &title, &pycell, &pyfunc, &pyarg)) - return NULL; - - if (pygobject_check(pycell, &PyGtkCellRenderer_Type)) - cell = GTK_CELL_RENDERER(pygobject_get(pycell)); - else { - PyErr_SetString(PyExc_TypeError, - "first argument must be a GtkCellRenderer"); - return NULL; - } - - cunote = g_new0(PyGtkCustomNotify, 1); - cunote->func = pyfunc; - cunote->data = pyarg; - Py_INCREF(cunote->func); - Py_XINCREF(cunote->data); - - retval = gtk_tree_view_insert_column_with_data_func ( - GTK_TREE_VIEW (self->obj), - position, - title, - cell, - pygtk_cell_data_func_marshal, - cunote, - pygtk_custom_destroy_notify); - return PyInt_FromLong(retval); -} -%% -override gtk_tree_view_column_set_attributes kwargs -static PyObject * -_wrap_gtk_tree_view_column_set_attributes(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - PyObject *py_cell, *key, *item; - GtkCellRenderer *cell; - gint i = 0; - - if (!PyArg_ParseTuple(args, "O!:GtkTreeViewColumn.set_attributes", - &PyGtkCellRenderer_Type, &py_cell)) - return NULL; - cell = GTK_CELL_RENDERER(pygobject_get(py_cell)); - gtk_tree_view_column_clear_attributes(GTK_TREE_VIEW_COLUMN(self->obj), - cell); - if (kwargs) { - while (PyDict_Next(kwargs, &i, &key, &item)) { - gchar *attr = PyString_AsString(key); - - if (!PyInt_Check(item)) { - gchar err[128]; - g_snprintf(err, sizeof(err), - "%s must be an integer column number", attr); - PyErr_SetString(PyExc_TypeError, err); - return NULL; - } - gtk_tree_view_column_add_attribute(GTK_TREE_VIEW_COLUMN(self->obj), - cell, attr, - PyInt_AsLong(item)); - } - } - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_tree_view_get_path_at_pos kwargs -static PyObject * -_wrap_gtk_tree_view_get_path_at_pos(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "x", "y", NULL }; - gint x, y; - GtkTreePath *path; - GtkTreeViewColumn *column; - gint cell_x, cell_y; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "ii:GtkTreeView.get_path_at_pos", - kwlist, &x, &y)) - return NULL; - if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(self->obj), x, y, - &path, &column, &cell_x, &cell_y)) { - PyObject *ret = PyTuple_New(4); - - if (path) { - PyTuple_SetItem(ret, 0, pygtk_tree_path_to_pyobject(path)); - gtk_tree_path_free(path); - } else { - Py_INCREF(Py_None); - PyTuple_SetItem(ret, 0, Py_None); - } - PyTuple_SetItem(ret, 1, pygobject_new((GObject *)column)); - PyTuple_SetItem(ret, 2, PyInt_FromLong(cell_x)); - PyTuple_SetItem(ret, 3, PyInt_FromLong(cell_y)); - return ret; - } else { - Py_INCREF(Py_None); - return Py_None; - } -} -%% -override gtk_tree_view_insert_column_with_attributes kwargs -static PyObject * -_wrap_gtk_tree_view_insert_column_with_attributes(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - gint position, columns, real_position; - GtkTreeViewColumn *column; - GtkCellRenderer *cell; - PyObject *py_cell, *key, *item; - const char *title; - gint i = 0; - - if (!PyArg_ParseTuple(args, - "isO!:GtkTreeView.insert_column_with_attributes", - &position, &title, &PyGtkCellRenderer_Type, &py_cell)) - return NULL; - - cell = GTK_CELL_RENDERER(pygobject_get(py_cell)); - - columns = - gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW(self->obj), - position, title, cell, - NULL); - if (position == -1) { - real_position = columns - 1; - } else { - real_position = position; - } - - column = gtk_tree_view_get_column (GTK_TREE_VIEW(self->obj), - real_position); - - if (kwargs) { - while (PyDict_Next(kwargs, &i, &key, &item)) { - gchar *attr = PyString_AsString(key); - - if (!PyInt_Check(item)) { - gchar err[128]; - g_snprintf(err, sizeof(err), - "%s must be an integer column number", attr); - PyErr_SetString(PyExc_TypeError, err); - return NULL; - } - gtk_tree_view_column_add_attribute(column, cell, attr, - PyInt_AsLong(item)); - } - } - return pygobject_new ((GObject *) column); -} -%% -override gtk_tree_view_get_visible_rect noargs -static PyObject * -_wrap_gtk_tree_view_get_visible_rect(PyGObject *self) -{ - GdkRectangle visible_rect; - - gtk_tree_view_get_visible_rect(GTK_TREE_VIEW(self->obj), &visible_rect); - - return pyg_boxed_new(GDK_TYPE_RECTANGLE, &visible_rect, TRUE, TRUE); -} -%% -override gtk_tree_view_get_cell_area kwargs -static PyObject * -_wrap_gtk_tree_view_get_cell_area(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "path", "column", NULL }; - PyObject *py_path; - PyGObject *column; - GdkRectangle rect; - GtkTreePath *path; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO!:GtkTreeView.get_cell_area", kwlist, &py_path, &PyGtkTreeViewColumn_Type, &column)) - return NULL; - path = pygtk_tree_path_from_pyobject(py_path); - if (!path) { - PyErr_SetString(PyExc_TypeError, "could not convert path to a GtkTreePath"); - return NULL; - } - gtk_tree_view_get_cell_area(GTK_TREE_VIEW(self->obj), path, GTK_TREE_VIEW_COLUMN(column->obj), &rect); - if (path) - gtk_tree_path_free(path); - return pyg_boxed_new(GDK_TYPE_RECTANGLE, &rect, TRUE, TRUE); -} -%% -override gtk_tree_view_get_background_area kwargs -static PyObject * -_wrap_gtk_tree_view_get_background_area(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "path", "column", NULL }; - PyObject *py_path; - PyGObject *column; - GdkRectangle rect; - GtkTreePath *path; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO!:GtkTreeView.get_background_area", kwlist, &py_path, &PyGtkTreeViewColumn_Type, &column)) - return NULL; - path = pygtk_tree_path_from_pyobject(py_path); - if (!path) { - PyErr_SetString(PyExc_TypeError, "could not convert path to a GtkTreePath"); - return NULL; - } - gtk_tree_view_get_background_area(GTK_TREE_VIEW(self->obj), path, GTK_TREE_VIEW_COLUMN(column->obj), &rect); - if (path) - gtk_tree_path_free(path); - return pyg_boxed_new(GDK_TYPE_RECTANGLE, &rect, TRUE, TRUE); -} -%% -override gtk_tree_view_widget_to_tree_coords args -static PyObject * -_wrap_gtk_tree_view_widget_to_tree_coords(PyGObject *self, PyObject *args) -{ - gint wx, wy, tx, ty; - - if (!PyArg_ParseTuple(args, "ii:GtkTreeView.widget_to_tree_coords", - &wx, &wy)) { - return NULL; - } - - gtk_tree_view_widget_to_tree_coords(GTK_TREE_VIEW(self->obj), wx, wy, &tx, &ty); - - return Py_BuildValue("(ii)", tx, ty); -} -%% -override gtk_tree_view_tree_to_widget_coords args -static PyObject * -_wrap_gtk_tree_view_tree_to_widget_coords(PyGObject *self, PyObject *args) -{ - gint tx, ty, wx, wy; - - if (!PyArg_ParseTuple(args, "ii:GtkTreeView.tree_to_widget_coords", - &tx, &ty)) { - return NULL; - } - - gtk_tree_view_tree_to_widget_coords(GTK_TREE_VIEW(self->obj), tx, ty, &wx, &wy); - - return Py_BuildValue("(ii)", wx, wy); -} -%% -override gtk_tree_view_get_cursor noargs -static PyObject * -_wrap_gtk_tree_view_get_cursor(PyGObject *self) -{ - PyObject *py_path; - PyObject *py_column; - GtkTreePath *path; - GtkTreeViewColumn *column; - - gtk_tree_view_get_cursor(GTK_TREE_VIEW(self->obj), - &path, &column); - - if (path != NULL) { - py_path = pygtk_tree_path_to_pyobject(path); - } else { - Py_INCREF(Py_None); - py_path = Py_None; - } - - if (column != NULL) { - py_column = pygobject_new((GObject*)column); - } else { - Py_INCREF(Py_None); - py_column = Py_None; - } - - return Py_BuildValue("(OO)", py_path, py_column); -} -%% -override gtk_tree_view_get_columns noargs -static PyObject * -_wrap_gtk_tree_view_get_columns(PyGObject *self) -{ - GList *list, *tmp; - PyObject *py_list; - - list = gtk_tree_view_get_columns(GTK_TREE_VIEW(self->obj)); - - if ((py_list = PyList_New(0)) == NULL) { - g_list_free(list); - return NULL; - } - for (tmp = list; tmp != NULL; tmp = tmp->next) { - PyObject *gtk_obj = pygobject_new(G_OBJECT(tmp->data)); - - if (gtk_obj == NULL) { - g_list_free(list); - Py_DECREF(py_list); - return NULL; - } - PyList_Append(py_list, gtk_obj); - Py_DECREF(gtk_obj); - } - g_list_free(list); - return py_list; -} -%% -override gtk_tree_selection_get_selected noargs -static PyObject * -_wrap_gtk_tree_selection_get_selected(PyGObject *self) -{ - GtkTreeModel *model; - GtkTreeIter iter; - GtkSelectionMode mode; - - mode = gtk_tree_selection_get_mode(GTK_TREE_SELECTION(self->obj)); - if (mode == GTK_SELECTION_MULTIPLE) { - PyErr_SetString(PyExc_TypeError, - "GtkTreeSelection.get_selected can not be used when" - " selection mode is gtk.SELECTION_MULTIPLE"); - return NULL; - } - - if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(self->obj), - &model, &iter)) { - return Py_BuildValue("(NN)", - pygobject_new((GObject *)model), - pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, - TRUE, TRUE)); - } else { - return Py_BuildValue ("(NN)", - pygobject_new((GObject *)model), - Py_None); - } -} -%% -override gtk_tree_selection_selected_foreach -static void -pygtk_tree_selection_foreach_marshal(GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer data) -{ - PyGtkCustomNotify *cunote = data; - PyObject *py_model, *py_path, *py_iter, *retobj; - - g_assert(cunote->func); - - pyg_block_threads(); - - py_model = pygobject_new((GObject *)model); - py_path = pygtk_tree_path_to_pyobject(path); - py_iter = pyg_boxed_new(GTK_TYPE_TREE_ITER, iter, TRUE, TRUE); - if (cunote->data) - retobj = PyEval_CallFunction(cunote->func, "(NNNO)", - py_model, py_path, py_iter, - cunote->data); - else - retobj = PyEval_CallFunction(cunote->func, "(NNN)", - py_model, py_path, py_iter); - - if (retobj == NULL) { - PyErr_Print(); - } - - Py_XDECREF(retobj); - - pyg_unblock_threads(); -} -static PyObject * -_wrap_gtk_tree_selection_selected_foreach(PyGObject *self, PyObject *args) -{ - PyObject *pyfunc, *pyarg = NULL; - PyGtkCustomNotify cunote; - - if(!PyArg_ParseTuple(args, "O|O:GtkTreeSelection.selected_foreach", - &pyfunc, &pyarg)) - return NULL; - - cunote.func = pyfunc; - cunote.data = pyarg; - gtk_tree_selection_selected_foreach(GTK_TREE_SELECTION(self->obj), - pygtk_tree_selection_foreach_marshal, - &cunote); - - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_tree_selection_set_select_function - -static gboolean -pygtk_tree_selection_marshal(GtkTreeSelection *selection, - GtkTreeModel *model, - GtkTreePath *path, - gboolean path_currently_selected, - gpointer data) -{ - gboolean retval = FALSE; - PyGtkCustomNotify *cunote = data; - PyObject *pypath, *retobj; - - g_assert(cunote->func); - - pyg_block_threads(); - - pypath = pygtk_tree_path_to_pyobject(path); - if (cunote->data) - retobj = PyEval_CallFunction(cunote->func, "(OO)", pypath, - cunote->data); - else - retobj = PyEval_CallFunction(cunote->func, "(O)", pypath); - - if (retobj == NULL) { - PyErr_Print(); - } - - Py_DECREF(pypath); - if (retobj) { - if(retobj == Py_None); - else if(PyInt_Check(retobj)) - retval = PyInt_AsLong(retobj) && TRUE; - else if(PyLong_Check(retobj)) - retval = PyLong_AsLongLong(retobj) && TRUE; - else if(PyString_Check(retobj)) - retval = PyString_GET_SIZE(retobj) && TRUE; - - Py_DECREF(retobj); - } - - pyg_unblock_threads(); - - return retval; -} -static PyObject * -_wrap_gtk_tree_selection_set_select_function(PyGObject *self, PyObject *args) -{ - PyObject *pyfunc, *pyarg = NULL; - PyGtkCustomNotify *cunote; - - if(!PyArg_ParseTuple(args, "O|O:GtkTreeSelection.set_select_function", - &pyfunc, &pyarg)) - return NULL; - - cunote = g_new0(PyGtkCustomNotify, 1); - cunote->func = pyfunc; - cunote->data = pyarg; - Py_INCREF(cunote->func); - Py_XINCREF(cunote->data); - gtk_tree_selection_set_select_function(GTK_TREE_SELECTION(self->obj), - pygtk_tree_selection_marshal, - cunote, - pygtk_custom_destroy_notify); - Py_INCREF(Py_None); - return Py_None; -} -%% override gtk_binding_entry_add_signal - static PyObject * _wrap_gtk_binding_entry_add_signal(PyGObject *self, PyObject *args) { @@ -3573,156 +669,6 @@ arg_error: } return NULL; } - -/* -------------- haven't updated stuff below this line -------------- */ -%% -ignore-glob - _* - *_get_type - gtk_arg_* - gtk_args_* - gtk_draw_* - gtk_gc_* - gtk_idle_add* - gtk_idle_remove - gtk_init_add_* - gtk_input_add* - gtk_input_remove - gtk_marshal_* - gtk_pattern_* - gtk_quit_add_* - gtk_signal_* - gtk_signal_add_emission_hook* - gtk_signal_connect* - gtk_signal_new* - gtk_target_list_* - gtk_text_view_new - gtk_timeout_add* - gtk_timeout_remove - gtk_tree_path_* -%% -ignore - gtk_binding_set_new - gtk_binding_set_by_class - gtk_binding_set_find - gtk_binding_set_clear - gtk_init - gtk_init_check - gtk_init_abi_check - gtk_init_check_abi_check - gtk_exit - gtk_set_locale - gtk_accel_group_ref - gtk_accel_group_unref - gtk_accel_groups_activate - gtk_accel_group_activate - gtk_accel_group_get_entry - gtk_accel_group_lock_entry - gtk_accel_group_unlock_entry - gtk_accel_group_add - gtk_accel_group_remove - gtk_accel_group_handle_add - gtk_accel_group_handle_remove - gtk_accel_group_create_add - gtk_accel_group_create_remove - gtk_accel_groups_from_object - gtk_accel_group_entries_from_object - gtk_signal_set_funcs - gtk_signal_lookup - gtk_signal_disconnect_by_func - gtk_signal_disconnect_by_data - gtk_signal_handler_block_by_func - gtk_signal_handler_block_by_data - gtk_signal_handler_unblock_by_func - gtk_signal_handler_unblock_by_data - gtk_signal_handler_pending_by_func - gtk_signal_n_emissions - gtk_signal_n_emissions_by_name - gtk_signal_name - gtk_signal_remove_emission_hook - gtk_signal_query - gtk_signal_emit - gtk_signal_emit_by_name - gtk_signal_emitv - gtk_signal_emitv_by_name - gtk_quit_remove_by_data - gtk_idle_remove_by_data - gtk_object_ref - gtk_object_unref - gtk_object_sink - gtk_object_weakref - gtk_object_weakunref - gtk_object_get - gtk_object_getv - gtk_object_set - gtk_object_setv - gtk_object_set_data - gtk_object_set_data_full - gtk_object_get_data - gtk_object_set_user_data - gtk_object_get_user_data - gtk_object_set_data_by_id - gtk_object_set_data_by_id_full - gtk_object_get_data_by_id - gtk_object_remove_data_by_id - gtk_object_remove_no_notify_by_id - gtk_object_arg_set - gtk_object_arg_get - gtk_trace_referencing - gtk_widget_ref - gtk_widget_unref - gtk_widget_get - gtk_widget_getv - gtk_widget_set - gtk_widget_setv - gtk_widget_style_get_valist - gtk_widget_destroyed - gtk_container_get_toplevels - gtk_container_add_child_arg_type - gtk_container_query_child_args - gtk_container_child_args_collect - gtk_container_child_arg_get_info - gtk_container_foreach_full - gtk_container_add_with_args - gtk_container_addv - gtk_container_child_set_valist - gtk_container_child_get_valist - gtk_clist_set_row_data_full - gtk_window_add_embedded_xid - gtk_window_remove_embedded_xid - gtk_range_trough_click - gtk_range_default_htrough_click - gtk_range_default_vtrough_click - gtk_type_check_object_cast - gtk_type_check_class_cast - gtk_type_register_enum - gtk_type_register_flags - gtk_preview_uninit - gtk_item_factory_create_item - gtk_item_factory_delete_entry - gtk_item_factory_delete_entries - gtk_item_factory_popup_with_data - gtk_item_factory_popup_data - gtk_item_factory_set_translate_func - gtk_item_factory_create_items_ac - gtk_item_factory_create_menu_entries - gtk_menu_bar_append - gtk_menu_bar_insert - gtk_menu_bar_prepend - gtk_menu_append - gtk_menu_insert - gtk_menu_prepend - gtk_radio_menu_item_group - gtk_radio_button_group - gtk_entry_new - gtk_entry_select_region -%% -ignore gtk_object_new gtk_object_newv gtk_object_query_args - gtk_object_add_arg_type gtk_object_args_collect gtk_object_arg_get_info - gtk_widget_new gtk_widget_newv -%% -ignore gtk_true gtk_false gtk_key_snooper_install gtk_key_snooper_remove - gtk_get_current_event gtk_get_event_widget gtk_propagate_event %% override gtk_main noargs static PyObject * @@ -4044,8 +990,6 @@ _wrap_gtk_pixmap_get(PyGObject *self) } %% -ignore gtk_button_new_with_label gtk_button_new_from_stock gtk_button_new_with_mnemonic -%% override gtk_button_new kwargs static int _wrap_gtk_button_new(PyGObject *self, PyObject *args, PyObject *kwargs) @@ -4092,8 +1036,6 @@ _wrap_gtk_button_box_get_child_ipadding(PyGObject *self) return Py_BuildValue("(ii)", ipad_x, ipad_y); } %% -ignore gtk_toggle_button_new_with_label gtk_toggle_button_new_with_mnemonic -%% override gtk_toggle_button_new kwargs static int _wrap_gtk_toggle_button_new(PyGObject *self, PyObject*args, PyObject*kwargs) @@ -4117,8 +1059,6 @@ _wrap_gtk_toggle_button_new(PyGObject *self, PyObject*args, PyObject*kwargs) return 0; } %% -ignore gtk_check_button_new_with_label gtk_check_button_new_with_mnemonic -%% override gtk_check_button_new kwargs static int _wrap_gtk_check_button_new(PyGObject *self, PyObject *args, PyObject*kwargs) @@ -4141,8 +1081,6 @@ _wrap_gtk_check_button_new(PyGObject *self, PyObject *args, PyObject*kwargs) return 0; } %% -ignore-glob gtk_radio_button_new_* -%% override gtk_radio_button_new kwargs static int _wrap_gtk_radio_button_new(PyGObject *self, PyObject *args, PyObject*kwargs) @@ -4229,8 +1167,6 @@ _wrap_gtk_radio_button_set_group(PyGObject *self, PyObject *args, return Py_None; } %% -ignore gtk_list_item_new_with_label -%% override gtk_list_item_new kwargs static int _wrap_gtk_list_item_new(PyGObject *self, PyObject *args, PyObject *kwargs) @@ -4253,8 +1189,6 @@ _wrap_gtk_list_item_new(PyGObject *self, PyObject *args, PyObject *kwargs) return 0; } %% -ignore gtk_menu_item_new_with_label gtk_menu_item_new_with_mnemonic -%% override gtk_menu_item_new kwargs static int _wrap_gtk_menu_item_new(PyGObject *self, PyObject *args, PyObject *kwargs) @@ -4342,8 +1276,6 @@ _wrap_gtk_menu_attach_to_widget (PyGObject *self, PyObject *args, return Py_None; } %% -ignore gtk_check_menu_item_new_with_label gtk_check_menu_item_new_with_mnemonic -%% override gtk_check_menu_item_new kwargs static int _wrap_gtk_check_menu_item_new(PyGObject *self, PyObject *args, @@ -4368,8 +1300,6 @@ _wrap_gtk_check_menu_item_new(PyGObject *self, PyObject *args, return 0; } %% -ignore gtk_radio_menu_item_new_with_label gtk_radio_menu_item_new_with_mnemonic -%% override gtk_radio_menu_item_new kwargs static int _wrap_gtk_radio_menu_item_new(PyGObject *self, PyObject *args, @@ -4415,11 +1345,6 @@ _wrap_gtk_radio_menu_item_new(PyGObject *self, PyObject *args, return 0; } %% -ignore - gtk_image_item_menu_new_with_label - gtk_image_menu_item_new_from_stock - gtk_image_menu_item_new_with_mnemonic -%% override gtk_image_menu_item_new kwargs static int _wrap_gtk_image_menu_item_new(PyGObject *self, PyObject *args,PyObject *kwargs) @@ -4450,509 +1375,6 @@ _wrap_gtk_image_menu_item_new(PyGObject *self, PyObject *args,PyObject *kwargs) return 0; } %% -ignore gtk_ctree_construct - gtk_ctree_insert_gnode - gtk_ctree_export_to_gnode - gtk_ctree_post_recursive - gtk_ctree_post_recursive_to_depth - gtk_ctree_pre_recursive - gtk_ctree_pre_recursive_to_depth - gtk_ctree_find_node_ptr -%% -ignore gtk_ctree_new -%% -override-attr GtkCTree.selection -static PyObject * -_wrap_gtk_ctree__get_selection(PyGObject *self, void *closure) -{ - GList *selection; - GtkCTreeNode *node; - PyObject *ret, *py_node; - if ((ret = PyList_New(0)) == NULL) - return NULL; - - for (selection = GTK_CLIST(self->obj)->selection; selection != NULL; - selection = selection->next) { - node = selection->data; - if ((py_node = pyg_pointer_new(GTK_TYPE_CTREE_NODE, node)) == NULL) { - Py_DECREF(ret); - return NULL; - } - PyList_Append(ret, py_node); - Py_DECREF(py_node); - } - - return ret; -} -%% -override gtk_ctree_new_with_titles kwargs -static int -_wrap_gtk_ctree_new_with_titles(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "columns", "tree_column", "titles", NULL }; - int columns = 1, tree_column = 0; - PyObject *py_titles = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|iiO:GtkCTree.__init__", - kwlist, &columns, &tree_column, - &py_titles)) - return -1; - if (py_titles) { - gchar **titles; - gint i; - - if (!PySequence_Check(py_titles)) { - PyErr_SetString(PyExc_TypeError, "titles must be a sequence"); - return -1; - } - if (PySequence_Length(py_titles) < columns) { - PyErr_SetString(PyExc_TypeError, "titles too short"); - return -1; - } - titles = g_new(gchar *, columns); - for (i = 0; i < columns; i++) { - PyObject *item = PySequence_GetItem(py_titles, i); - - Py_DECREF(item); - if (!PyString_Check(item) && !PyUnicode_Check(item)) { - PyErr_SetString(PyExc_TypeError, - "sequence item not a string or unicode object"); - g_free(titles); - return -1; - } - titles[i] = PyString_AsString(item); - } - self->obj = (GObject *)gtk_ctree_new_with_titles(columns, - tree_column, titles); - g_free(titles); - } else - self->obj = (GObject *)gtk_ctree_new(columns, tree_column); - if (!self->obj) { - PyErr_SetString(PyExc_RuntimeError,"could not create GtkCTree object"); - return -1; - } - pygobject_register_wrapper((PyObject *)self); - return 0; -} -%% -override gtk_ctree_base_nodes -static PyObject* -_wrap_gtk_ctree_base_nodes(PyGObject *self, PyObject *args) -{ - PyObject *ret; - GtkCTreeNode *node; - - /* the first row is always a base node */ - node = GTK_CTREE_NODE(GTK_CLIST(self->obj)->row_list); - if ((ret = PyList_New(0)) == NULL) - return NULL; - while (node) { - PyObject *obj = pyg_pointer_new(GTK_TYPE_CTREE_NODE, node); - if (obj == NULL) { - Py_DECREF(ret); - return NULL; - } - PyList_Append(ret, obj); - Py_DECREF(obj); - node = GTK_CTREE_ROW(node)->sibling; - } - return ret; -} -%% -override gtk_ctree_insert_node kwargs -static PyObject * -_wrap_gtk_ctree_insert_node(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "parent", "sibling", "text", "spacing", - "pixmap_closed", "mask_closed", "pixmap_opened", - "mask_opened", "is_leaf", "expanded", NULL }; - PyObject *py_text; - PyGPointer *py_parent, *py_sibling; - PyGObject *py_pixmap_closed = (PyGObject *) Py_None; - PyGObject *py_mask_closed = (PyGObject *) Py_None; - PyGObject *py_pixmap_opened = (PyGObject *) Py_None; - PyGObject *py_mask_opened = (PyGObject *) Py_None; - GtkCTreeNode *parent = NULL, *sibling = NULL, *ret; - gchar **text = NULL; - GdkPixmap *pixmap_closed = NULL, *pixmap_opened = NULL; - GdkBitmap *mask_closed = NULL, *mask_opened = NULL; - gint spacing = 5, is_leaf = 1, expanded = 0, columns, i; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "OOO|iOOOOii:GtkCTree.insert_node", - kwlist, - &py_parent, &py_sibling, &py_text, - &spacing, &py_pixmap_closed, - &py_mask_closed, &py_pixmap_opened, - &py_mask_opened, &is_leaf, &expanded)) - return NULL; - if (pyg_pointer_check(py_parent, GTK_TYPE_CTREE_NODE)) - parent = pyg_pointer_get(py_parent, GtkCTreeNode); - else if ((PyObject *)py_parent != Py_None) { - PyErr_SetString(PyExc_TypeError, "parent must be a CTreeNode or None"); - return NULL; - } - if (pyg_pointer_check(py_sibling, GTK_TYPE_CTREE_NODE)) - sibling = pyg_pointer_get(py_sibling, GtkCTreeNode); - else if ((PyObject *)py_sibling != Py_None) { - PyErr_SetString(PyExc_TypeError,"sibling must be a CTreeNode or None"); - return NULL; - } - if (pygobject_check(py_pixmap_closed, &PyGdkPixmap_Type)) - pixmap_closed = GDK_PIXMAP(py_pixmap_closed->obj); - else if ((PyObject *)py_pixmap_closed != Py_None) { - PyErr_SetString(PyExc_TypeError, - "pixmap_closed must be a GdkPixmap or None"); - return NULL; - } - if (pygobject_check(py_mask_closed, &PyGdkPixmap_Type)) - mask_closed = GDK_PIXMAP(py_mask_closed->obj); - else if ((PyObject *)py_mask_closed != Py_None) { - PyErr_SetString(PyExc_TypeError, - "mask_closed must be a GdkBitmap or None"); - return NULL; - } - if (pygobject_check(py_pixmap_opened, &PyGdkPixmap_Type)) - pixmap_opened = GDK_PIXMAP(py_pixmap_opened->obj); - else if ((PyObject *)py_pixmap_opened != Py_None) { - PyErr_SetString(PyExc_TypeError, - "pixmap_opened must be a GdkPixmap or None"); - return NULL; - } - if (pygobject_check(py_mask_opened, &PyGdkPixmap_Type)) - mask_opened = GDK_PIXMAP(py_mask_opened->obj); - else if ((PyObject *)py_mask_opened != Py_None) { - PyErr_SetString(PyExc_TypeError, - "mask_opened must be a GdkBitmap or None"); - return NULL; - } - if (!PySequence_Check(py_text)) { - PyErr_SetString(PyExc_TypeError, "text must be a sequence"); - return NULL; - } - columns = GTK_CLIST(self->obj)->columns; - if (PySequence_Length(py_text) < columns) { - PyErr_SetString(PyExc_TypeError, "text is too short"); - return NULL; - } - text = g_new(gchar *, columns); - for (i = 0; i < columns; i++) { - PyObject *item = PySequence_GetItem(py_text, i); - - Py_DECREF(item); - if (!PyString_Check(item) && !PyUnicode_Check(item)) { - PyErr_SetString(PyExc_TypeError, - "sequence item not a string or unicode object"); - g_free(text); - return NULL; - } - text[i] = PyString_AsString(item); - } - ret = gtk_ctree_insert_node(GTK_CTREE(self->obj), parent, sibling, text, - spacing, pixmap_closed, mask_closed, - pixmap_opened, mask_opened, is_leaf, expanded); - g_free(text); - return pyg_pointer_new(GTK_TYPE_CTREE_NODE, ret); -} -%% -ignore gtk_ctree_find_by_row_data_custom gtk_ctree_find_all_by_row_data_custom -%% -override gtk_ctree_find_by_row_data kwargs -static PyObject * -_wrap_gtk_ctree_find_by_row_data(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "node", "data", NULL }; - PyObject *data; - PyGPointer *py_node; - GtkCTreeNode *node = NULL, *ret; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "OO:GtkCTree.find_by_row_data", kwlist, - &py_node, &data)) - return NULL; - if (pyg_pointer_check(py_node, GTK_TYPE_CTREE_NODE)) - node = pyg_pointer_get(py_node, GtkCTreeNode); - else if ((PyObject *)py_node != Py_None) { - PyErr_SetString(PyExc_TypeError, "node must be a CTreeNode or None"); - return NULL; - } - ret = gtk_ctree_find_by_row_data(GTK_CTREE(self->obj), node, data); - if (ret) - return pyg_pointer_new(GTK_TYPE_CTREE_NODE, ret); - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_ctree_find_all_by_row_data kwargs -static PyObject * -_wrap_gtk_ctree_find_all_by_row_data(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "node", "data", NULL }; - PyGPointer *py_node; - PyObject *data, *list; - GtkCTreeNode *node = NULL; - GList *ret, *tmp; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "OO:GtkCTree.find_all_by_row_data",kwlist, - &py_node, &data)) - return NULL; - if (pyg_pointer_check(py_node, GTK_TYPE_CTREE_NODE)) - node = pyg_pointer_get(py_node, GtkCTreeNode); - else if ((PyObject *)py_node != Py_None) { - PyErr_SetString(PyExc_TypeError, "node must be a CTreeNode or None"); - return NULL; - } - ret = gtk_ctree_find_all_by_row_data(GTK_CTREE(self->obj), node, data); - if ((list = PyList_New(0)) == NULL) - return NULL; - for (tmp = ret; tmp != NULL; tmp = tmp->next) { - PyObject *item = pyg_pointer_new(GTK_TYPE_CTREE_NODE, - (GtkCTreeNode *) tmp->data); - if (item == NULL) { - Py_DECREF(list); - return NULL; - } - PyList_Append(list, item); - Py_DECREF(item); - } - g_list_free(ret); - return list; -} -%% -override gtk_ctree_node_get_text kwargs -static PyObject * -_wrap_gtk_ctree_node_get_text(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "node", "column", NULL }; - PyGPointer *node; - int column; - char *text = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "Oi:GtkCTree.node_get_text", kwlist, - &node, &column)) - return NULL; - - if (!pyg_pointer_check(node, GTK_TYPE_CTREE_NODE)) { - PyErr_SetString(PyExc_TypeError, "node must be a CTreeNode"); - return NULL; - } - - if (!gtk_ctree_node_get_text(GTK_CTREE(self->obj), - pyg_pointer_get(node, GtkCTreeNode), column, - &text)) { - PyErr_SetString(PyExc_ValueError, "can't get text value"); - return NULL; - } - return PyString_FromString(text); -} -%% -override gtk_ctree_node_get_pixmap kwargs -static PyObject * -_wrap_gtk_ctree_node_get_pixmap(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "node", "column", NULL }; - PyObject *node; - int column; - GdkPixmap *pixmap = NULL; - GdkBitmap *mask = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "Oi:GtkCTree.node_get_pixmap", kwlist, - &node, &column)) - return NULL; - - if (!pyg_pointer_check(node, GTK_TYPE_CTREE_NODE)) { - PyErr_SetString(PyExc_TypeError, "node must be a CTreeNode"); - return NULL; - } - - if (!gtk_ctree_node_get_pixmap(GTK_CTREE(self->obj), - pyg_pointer_get(node, GtkCTreeNode), column, - &pixmap, &mask)) { - PyErr_SetString(PyExc_ValueError, "can't get pixmap value"); - return NULL; - } - return Py_BuildValue("(NN)", pygobject_new((GObject *)pixmap), - pygobject_new((GObject *)mask)); -} -%% -override gtk_ctree_node_get_pixtext kwargs -static PyObject * -_wrap_gtk_ctree_node_get_pixtext(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "node", "column", NULL }; - PyObject *node; - int column; - gchar *text = NULL; - guint8 spacing; - GdkPixmap *pixmap = NULL; - GdkBitmap *mask = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "Oi:GtkCTree.node_get_pixtext", kwlist, - &node, &column)) - return NULL; - - if (!pyg_pointer_check(node, GTK_TYPE_CTREE_NODE)) { - PyErr_SetString(PyExc_TypeError, "node must be a CTreeNode"); - return NULL; - } - - if (!gtk_ctree_node_get_pixtext(GTK_CTREE(self->obj), - pyg_pointer_get(node, GtkCTreeNode), column, - &text, &spacing, &pixmap, &mask)) { - PyErr_SetString(PyExc_ValueError, "can't get pixtext value"); - return NULL; - } - return Py_BuildValue("(siNN)", text, (int)spacing, - pygobject_new((GObject *)pixmap), - pygobject_new((GObject *)mask)); -} -%% -override gtk_ctree_get_node_info kwargs -static PyObject * -_wrap_gtk_ctree_get_node_info(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "node", NULL }; - PyObject *node; - gchar *text; - guint8 spacing; - GdkPixmap *pixmap_closed, *pixmap_opened; - GdkBitmap *mask_closed, *mask_opened; - gboolean is_leaf, expanded; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GtkCTree.get_node_info", - kwlist, &node)) - return NULL; - - if (!pyg_pointer_check(node, GTK_TYPE_CTREE_NODE)) { - PyErr_SetString(PyExc_TypeError, "node must be a CTreeNode"); - return NULL; - } - - if (!gtk_ctree_get_node_info(GTK_CTREE(self->obj), pyg_pointer_get(node, GtkCTreeNode), - &text, &spacing, &pixmap_closed, &mask_closed, - &pixmap_opened, &mask_opened, - &is_leaf, &expanded)) { - PyErr_SetString(PyExc_ValueError, "can't get node info"); - return NULL; - } - return Py_BuildValue("(siNNNNii)", text, (int)spacing, - pygobject_new((GObject *)pixmap_opened), - pygobject_new((GObject *)mask_closed), - pygobject_new((GObject *)pixmap_opened), - pygobject_new((GObject *)mask_opened), - (int)is_leaf, (int)expanded); -} -%% -ignore gtk_ctree_node_set_row_data_full -%% -override gtk_ctree_node_set_row_data kwargs -static PyObject * -_wrap_gtk_ctree_node_set_row_data(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "node", "data", NULL }; - PyObject *node, *data; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "OO:GtkCTree.node_set_row_data", kwlist, - &node, &data)) - return NULL; - - if (!pyg_pointer_check(node, GTK_TYPE_CTREE_NODE)) { - PyErr_SetString(PyExc_TypeError, "node must be a CTreeNode"); - return NULL; - } - - Py_INCREF(data); - gtk_ctree_node_set_row_data_full(GTK_CTREE(self->obj), - pyg_pointer_get(node, GtkCTreeNode), data, - (GDestroyNotify)pyg_destroy_notify); - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_ctree_node_get_row_data kwargs -static PyObject * -_wrap_gtk_ctree_node_get_row_data(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "node", NULL }; - PyObject *node, *data; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O:GtkCTree.node_get_row_data", kwlist, - &node)) - return NULL; - - if (!pyg_pointer_check(node, GTK_TYPE_CTREE_NODE)) { - PyErr_SetString(PyExc_TypeError, "node must be a CTreeNode"); - return NULL; - } - - data = gtk_ctree_node_get_row_data(GTK_CTREE(self->obj), - pyg_pointer_get(node, GtkCTreeNode)); - if (!data) data = Py_None; - Py_INCREF(data); - return data; -} -%% -override-slot GtkCTreeNode.tp_getattr -static PyObject * -_wrap_gtk_ctree_node_tp_getattr(PyGPointer *self, char *attr) -{ - if (!strcmp(attr, "__members__")) - return Py_BuildValue("[ssssss]", "children", "expanded", "is_leaf", - "level", "parent", "sibling"); - if (!strcmp(attr, "parent")) { - GtkCTreeNode *node = GTK_CTREE_ROW(pyg_pointer_get(self, GtkCTreeNode))->parent; - if (node) - return pyg_pointer_new(GTK_TYPE_CTREE_NODE, node); - Py_INCREF(Py_None); - return Py_None; - } else if (!strcmp(attr, "sibling")) { - GtkCTreeNode *node = GTK_CTREE_ROW(pyg_pointer_get(self, GtkCTreeNode))->sibling; - if (node) - return pyg_pointer_new(GTK_TYPE_CTREE_NODE, node); - Py_INCREF(Py_None); - return Py_None; - } else if (!strcmp(attr, "children")) { - GtkCTreeNode *node = GTK_CTREE_ROW(pyg_pointer_get(self, GtkCTreeNode))->children; - PyObject *ret = PyList_New(0); - if (ret == NULL) - return NULL; - while (node) { - PyObject *py_node = pyg_pointer_new(GTK_TYPE_CTREE_NODE, node); - if (py_node == NULL) { - Py_DECREF(ret); - return NULL; - } - PyList_Append(ret, py_node); - Py_DECREF(py_node); - node = GTK_CTREE_ROW(node)->sibling; - } - return ret; - } else if (!strcmp(attr, "level")) - return PyInt_FromLong(GTK_CTREE_ROW(pyg_pointer_get(self, GtkCTreeNode))->level); - else if (!strcmp(attr, "is_leaf")) - return PyInt_FromLong(GTK_CTREE_ROW(pyg_pointer_get(self, GtkCTreeNode))->is_leaf); - else if (!strcmp(attr, "expanded")) - return PyInt_FromLong(GTK_CTREE_ROW(pyg_pointer_get(self, GtkCTreeNode))->expanded); - PyErr_SetString(PyExc_AttributeError, attr); - return NULL; -} -%% override-slot GtkRequisition.tp_as_sequence static int _wrap_gtk_requisition_length(PyGBoxed *self) @@ -5038,8 +1460,6 @@ _wrap_gtk_requisition__set_height(PyGBoxed *self, PyObject *value, void *closure return 0; } %% -ignore gtk_tree_remove_items -%% override gtk_toolbar_append_item kwargs static PyObject * _wrap_gtk_toolbar_append_item(PyGObject *self, PyObject *args, @@ -5498,8 +1918,6 @@ _wrap_gtk_list_remove_items(PyGObject *self, PyObject *args, return Py_None; } %% -ignore gtk_list_remove_items_no_unref -%% override-attr GtkList.selection static PyObject * _wrap_gtk_list__get_selection(PyGObject *self, void *closure) @@ -5824,12 +2242,6 @@ _wrap_gtk_drag_begin(PyGObject *self, PyObject *args, PyObject *kwargs) return pygobject_new((GObject *)context); } %% -ignore - gtk_drag_source_handle_event gtk_drag_dest_handle_event - gtk_selection_clear - gtk_selection_request gtk_selection_notify gtk_selection_property_notify - gtk_selection_incr_event -%% override gtk_selection_add_targets kwargs static PyObject * _wrap_gtk_selection_add_targets(PyGObject *self, PyObject *args, @@ -5874,684 +2286,6 @@ _wrap_gtk_selection_add_targets(PyGObject *self, PyObject *args, return Py_None; } %% -ignore gtk_text_iter_free -%% -override gtk_text_iter_copy noargs -static PyObject * -_wrap_gtk_text_iter_copy(PyGBoxed *self) -{ - return pyg_boxed_new(GTK_TYPE_TEXT_ITER, pyg_boxed_get(self, GtkTextIter), - TRUE, TRUE); -} -%% -override gtk_text_iter_get_slice kwargs -static PyObject * -_wrap_gtk_text_iter_get_slice(PyGBoxed *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "end", NULL }; - PyGBoxed *end; - gchar *text; - PyObject *pytext; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GtkTextIter.get_slice", - kwlist, &end)) - return NULL; - if (!pyg_boxed_check(end, GTK_TYPE_TEXT_ITER)) { - PyErr_SetString(PyExc_TypeError, "end must be a GtkTextIter"); - return NULL; - } - text = gtk_text_iter_get_slice(pyg_boxed_get(self, GtkTextIter), - pyg_boxed_get(end, GtkTextIter)); - pytext = PyUnicode_DecodeUTF8(text, strlen(text), "strict"); - g_free(text); - return pytext; -} -%% -override gtk_text_iter_get_text kwargs -static PyObject * -_wrap_gtk_text_iter_get_text(PyGBoxed *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "end", NULL }; - PyGBoxed *end; - gchar *text; - PyObject *pytext; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GtkTextIter.get_text", - kwlist, &end)) - return NULL; - if (!pyg_boxed_check(end, GTK_TYPE_TEXT_ITER)) { - PyErr_SetString(PyExc_TypeError, "end must be a GtkTextIter"); - return NULL; - } - text = gtk_text_iter_get_text(pyg_boxed_get(self, GtkTextIter), - pyg_boxed_get(end, GtkTextIter)); - pytext = PyUnicode_DecodeUTF8(text, strlen(text), "strict"); - g_free(text); - return pytext; -} -%% -override gtk_text_iter_get_visible_slice kwargs -static PyObject * -_wrap_gtk_text_iter_get_visible_slice(PyGBoxed *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "end", NULL }; - PyGBoxed *end; - gchar *text; - PyObject *pytext; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O:GtkTextIter.get_visible_slice", kwlist, - &end)) - return NULL; - if (!pyg_boxed_check(end, GTK_TYPE_TEXT_ITER)) { - PyErr_SetString(PyExc_TypeError, "end must be a GtkTextIter"); - return NULL; - } - text = gtk_text_iter_get_visible_slice(pyg_boxed_get(self, GtkTextIter), - pyg_boxed_get(end, GtkTextIter)); - pytext = PyUnicode_DecodeUTF8(text, strlen(text), "strict"); - g_free(text); - return pytext; -} -%% -override gtk_text_iter_get_visible_text kwargs -static PyObject * -_wrap_gtk_text_iter_get_visible_text(PyGBoxed *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "end", NULL }; - PyGBoxed *end; - gchar *text; - PyObject *pytext; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O:GtkTextIter.get_visible_text", kwlist, - &end)) - return NULL; - if (!pyg_boxed_check(end, GTK_TYPE_TEXT_ITER)) { - PyErr_SetString(PyExc_TypeError, "end must be a GtkTextIter"); - return NULL; - } - text = gtk_text_iter_get_visible_text(pyg_boxed_get(self, GtkTextIter), - pyg_boxed_get(end, GtkTextIter)); - pytext = PyUnicode_DecodeUTF8(text, strlen(text), "strict"); - g_free(text); - return pytext; -} -%% -override gtk_text_iter_get_marks noargs -static PyObject * -_wrap_gtk_text_iter_get_marks(PyGBoxed *self) -{ - GSList *ret, *tmp; - PyObject *pyret; - - ret = gtk_text_iter_get_marks(pyg_boxed_get(self, GtkTextIter)); - pyret = PyList_New(0); - for (tmp = ret; tmp != NULL; tmp = tmp->next) { - PyObject *mark = pygobject_new((GObject *)tmp->data); - PyList_Append(pyret, mark); - Py_DECREF(mark); - } - g_slist_free(ret); - return pyret; -} -%% -override gtk_text_iter_get_toggled_tags kwargs -static PyObject * -_wrap_gtk_text_iter_get_toggled_tags(PyGBoxed *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "toggled_on", NULL }; - GSList *ret, *tmp; - int toggled_on; - PyObject *pyret; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "i:GtkTextIter.get_toggled_tags", kwlist, - &toggled_on)) - return NULL; - ret = gtk_text_iter_get_toggled_tags(pyg_boxed_get(self, GtkTextIter), - toggled_on); - pyret = PyList_New(0); - for (tmp = ret; tmp != NULL; tmp = tmp->next) { - PyObject *tag = pygobject_new((GObject *)tmp->data); - PyList_Append(pyret, tag); - Py_DECREF(tag); - } - g_slist_free(ret); - return pyret; -} -%% -override gtk_text_iter_get_tags noargs -static PyObject * -_wrap_gtk_text_iter_get_tags(PyGBoxed *self) -{ - GSList *ret, *tmp; - PyObject *pyret; - - ret = gtk_text_iter_get_tags(pyg_boxed_get(self, GtkTextIter)); - pyret = PyList_New(0); - for (tmp = ret; tmp != NULL; tmp = tmp->next) { - PyObject *tag = pygobject_new((GObject *)tmp->data); - PyList_Append(pyret, tag); - Py_DECREF(tag); - } - g_slist_free(ret); - return pyret; -} -%% -override gtk_text_iter_forward_search kwargs -static PyObject * -_wrap_gtk_text_iter_forward_search(PyGBoxed *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "str", "flags", "limit", NULL }; - gchar *str; - PyObject *py_limit = Py_None; - GtkTextIter match_start, match_end, *limit = NULL; - GtkTextSearchFlags flags; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "si|O:GtkTextIter.forward_search", - kwlist, &str, &flags, &py_limit)) - return NULL; - if (pyg_boxed_check(py_limit, GTK_TYPE_TEXT_ITER)) - limit = pyg_boxed_get(py_limit, GtkTextIter); - else if (py_limit != Py_None) { - PyErr_SetString(PyExc_TypeError,"limit must be a GtkTextIter or None"); - return NULL; - } - if (gtk_text_iter_forward_search(pyg_boxed_get(self, GtkTextIter), str, - flags, &match_start, &match_end, limit)) - return Py_BuildValue("(NN)", - pyg_boxed_new(GTK_TYPE_TEXT_ITER, &match_start, - TRUE, TRUE), - pyg_boxed_new(GTK_TYPE_TEXT_ITER, &match_end, - TRUE, TRUE)); - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_text_iter_backward_search kwargs -static PyObject * -_wrap_gtk_text_iter_backward_search(PyGBoxed *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "str", "flags", "limit", NULL }; - gchar *str; - PyObject *py_limit = Py_None; - GtkTextIter match_start, match_end, *limit = NULL; - GtkTextSearchFlags flags; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "si|O:GtkTextIter.backward_search", - kwlist, &str, &flags, &py_limit)) - return NULL; - if (pyg_boxed_check(py_limit, GTK_TYPE_TEXT_ITER)) - limit = pyg_boxed_get(py_limit, GtkTextIter); - else if (py_limit != Py_None) { - PyErr_SetString(PyExc_TypeError,"limit must be a GtkTextIter or None"); - return NULL; - } - if (gtk_text_iter_backward_search(pyg_boxed_get(self, GtkTextIter), str, - flags, &match_start, &match_end, limit)) - return Py_BuildValue("(NN)", - pyg_boxed_new(GTK_TYPE_TEXT_ITER, &match_start, - TRUE, TRUE), - pyg_boxed_new(GTK_TYPE_TEXT_ITER, &match_end, - TRUE, TRUE)); - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_text_buffer_insert_with_tags -static PyObject * -_wrap_gtk_text_buffer_insert_with_tags(PyGObject *self, PyObject *args) -{ - PyObject *first, *py_iter; - gint len, i, text_len, start_offset; - gchar *text; - GtkTextIter *iter, start; - - len = PyTuple_Size(args); - if (len < 2) { - PyErr_SetString(PyExc_TypeError, - "GtkTextBuffer.insert_with_tags requires at least 2 arguments"); - return NULL; - } - first = PySequence_GetSlice(args, 0, 2); - if (!PyArg_ParseTuple(first, "Os#:GtkTextBuffer.insert_with_tags", - &py_iter, &text, &text_len)) { - Py_DECREF(first); - return NULL; - } - Py_DECREF(first); - if (!pyg_boxed_check(py_iter, GTK_TYPE_TEXT_ITER)) { - PyErr_SetString(PyExc_TypeError, "iter must be a GtkTextIter"); - return NULL; - } - iter = pyg_boxed_get(py_iter, GtkTextIter); - - /* check types */ - for (i = 2; i < len; i++) { - PyObject *item = PyTuple_GetItem(args, i); - - if (!pygobject_check(item, &PyGtkTextTag_Type)) { - PyErr_SetString(PyExc_TypeError, - "additional argument must be a GtkTextTag"); - return NULL; - } - } - - start_offset = gtk_text_iter_get_offset(iter); - gtk_text_buffer_insert(GTK_TEXT_BUFFER(self->obj), iter, text, text_len); - gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(self->obj), - &start, start_offset); - - for (i = 2; i < len; i++) { - PyObject *item = PyTuple_GetItem(args, i); - GtkTextTag *tag = GTK_TEXT_TAG(pygobject_get(item)); - - gtk_text_buffer_apply_tag(GTK_TEXT_BUFFER(self->obj), tag,&start,iter); - } - - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_text_buffer_insert_with_tags_by_name -static PyObject * -_wrap_gtk_text_buffer_insert_with_tags_by_name(PyGObject *self, PyObject *args) -{ - PyObject *first, *py_iter; - gint len, i, text_len, start_offset; - gchar *text; - GtkTextIter *iter, start; - - len = PyTuple_Size(args); - if (len < 2) { - PyErr_SetString(PyExc_TypeError, - "GtkTextBuffer.insert_with_tags_by_name " - "requires at least 2 arguments"); - return NULL; - } - first = PySequence_GetSlice(args, 0, 2); - if (!PyArg_ParseTuple(first, "Os#:GtkTextBuffer.insert_with_tags_by_name", - &py_iter, &text, &text_len)) { - Py_DECREF(first); - return NULL; - } - Py_DECREF(first); - if (!pyg_boxed_check(py_iter, GTK_TYPE_TEXT_ITER)) { - PyErr_SetString(PyExc_TypeError, "iter must be a GtkTextIter"); - return NULL; - } - iter = pyg_boxed_get(py_iter, GtkTextIter); - - /* check types */ - for (i = 2; i < len; i++) { - PyObject *item = PyTuple_GetItem(args, i); - - if (!PyString_Check(item)) { - PyErr_SetString(PyExc_TypeError, - "additional argument must be a string"); - return NULL; - } - } - - start_offset = gtk_text_iter_get_offset(iter); - gtk_text_buffer_insert(GTK_TEXT_BUFFER(self->obj), iter, text, text_len); - gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(self->obj), - &start, start_offset); - - for (i = 2; i < len; i++) { - PyObject *item = PyTuple_GetItem(args, i); - const gchar *tagname = PyString_AsString(item); - - gtk_text_buffer_apply_tag_by_name(GTK_TEXT_BUFFER(self->obj), - tagname, &start, iter); - } - - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_text_buffer_create_tag kwargs -static PyObject * -_wrap_gtk_text_buffer_create_tag(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - gchar *tag_name = NULL; - GtkTextTag *tag; - GtkTextTagTable *table; - - if (!PyArg_ParseTuple(args, "|z:GtkTextBuffer.create_tag", - &tag_name)) { - return NULL; - } - - table = GTK_TEXT_TAG_TABLE(GTK_TEXT_BUFFER(self->obj)->tag_table); - if (tag_name && table && g_hash_table_lookup(table->hash, tag_name)) { - gchar buf[512]; - g_snprintf(buf, sizeof(buf), - "A tag named '%s' is already in the tag table", - tag_name); - - PyErr_SetString(PyExc_TypeError, buf); - return NULL; - } - - tag = gtk_text_buffer_create_tag(GTK_TEXT_BUFFER(self->obj), - tag_name, NULL); - - /* set tag properties if any */ - if (kwargs) { - gint i = 0; - PyObject *prop, *val; - - while (PyDict_Next(kwargs, &i, &prop, &val)) { - GParamSpec *pspec; - GValue value = { 0, }; - gchar *prop_str = PyString_AsString(prop); - - pspec = g_object_class_find_property (G_OBJECT_GET_CLASS(tag), - prop_str); - if (!pspec) { - PyErr_Format(PyExc_TypeError, - "unsupported tag property `%s'", - prop_str); - /* XXX: Free tag? */ - return NULL; - } - - g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec)); - if (pyg_value_from_pyobject(&value, val) < 0) { - PyErr_Format(PyExc_TypeError, - "could not convert tag property '%s' to correct type", - prop_str); - /* XXX: Free tag? */ - return NULL; - } - g_object_set_property((GObject *)tag, prop_str, &value); - g_value_unset(&value); - } - } - return pygobject_new((GObject *)tag); -} -%% -override gtk_text_buffer_get_iter_at_line_offset kwargs -static PyObject * -_wrap_gtk_text_buffer_get_iter_at_line_offset(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "line_number", "char_offset", NULL }; - GtkTextIter iter; - int line_number, char_offset; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:GtkTextBuffer.get_iter_at_line_offset", kwlist, &line_number, &char_offset)) - return NULL; - - gtk_text_buffer_get_iter_at_line_offset(GTK_TEXT_BUFFER(self->obj), &iter, - line_number, char_offset); - return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE); -} -%% -override gtk_text_buffer_get_iter_at_line_index kwargs -static PyObject * -_wrap_gtk_text_buffer_get_iter_at_line_index(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "line_number", "byte_offset", NULL }; - GtkTextIter iter; - int line_number, byte_offset; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:GtkTextBuffer.get_iter_at_line_index", kwlist, &line_number, &byte_offset)) - return NULL; - - gtk_text_buffer_get_iter_at_line_index(GTK_TEXT_BUFFER(self->obj), &iter, - line_number, byte_offset); - return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE); -} -%% -override gtk_text_buffer_get_iter_at_offset kwargs -static PyObject * -_wrap_gtk_text_buffer_get_iter_at_offset(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - int char_offset; - static char *kwlist[] = { "char_offset", NULL }; - GtkTextIter iter; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:GtkTextBuffer.get_iter_at_offset", kwlist, &char_offset)) - return NULL; - - gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(self->obj), - &iter, char_offset); - return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE); -} -%% -override gtk_text_buffer_get_iter_at_line kwargs -static PyObject * -_wrap_gtk_text_buffer_get_iter_at_line(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - int line_number; - static char *kwlist[] = { "line_number", NULL }; - GtkTextIter iter; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:GtkTextBuffer.get_iter_at_line", kwlist, &line_number)) - return NULL; - - gtk_text_buffer_get_iter_at_line(GTK_TEXT_BUFFER(self->obj), - &iter, line_number); - return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE); -} -%% -override gtk_text_buffer_get_start_iter noargs -static PyObject * -_wrap_gtk_text_buffer_get_start_iter(PyGObject *self) -{ - GtkTextIter iter; - - gtk_text_buffer_get_start_iter(GTK_TEXT_BUFFER(self->obj), &iter); - return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE); -} -%% -override gtk_text_buffer_get_end_iter noargs -static PyObject * -_wrap_gtk_text_buffer_get_end_iter(PyGObject *self) -{ - GtkTextIter iter; - - gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(self->obj), &iter); - return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE); -} -%% -override gtk_text_buffer_get_bounds noargs -static PyObject * -_wrap_gtk_text_buffer_get_bounds(PyGObject *self) -{ - GtkTextIter start, end; - - gtk_text_buffer_get_bounds(GTK_TEXT_BUFFER(self->obj), &start, &end); - return Py_BuildValue("(NN)", - pyg_boxed_new(GTK_TYPE_TEXT_ITER, &start, TRUE, TRUE), - pyg_boxed_new(GTK_TYPE_TEXT_ITER, &end, TRUE, TRUE)); -} -%% -override gtk_text_buffer_get_iter_at_mark kwargs -static PyObject * -_wrap_gtk_text_buffer_get_iter_at_mark(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - PyGObject *mark; - static char *kwlist[] = { "mark", NULL }; - GtkTextIter iter; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GtkTextBuffer.get_iter_at_mark", kwlist, &mark)) - return NULL; - if (!pygobject_check(mark, &PyGtkTextMark_Type)) { - PyErr_SetString(PyExc_TypeError, "mark should be a GtkTextMark"); - return NULL; - } - - gtk_text_buffer_get_iter_at_mark(GTK_TEXT_BUFFER(self->obj), &iter, - GTK_TEXT_MARK(mark->obj)); - return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE); -} -%% -override gtk_text_buffer_set_text kwargs -static PyObject * -_wrap_gtk_text_buffer_set_text(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - char *text; - static char *kwlist[] = { "text", "len", NULL }; - int len, oldlen = -1; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "s#|i:GtkTextBuffer.set_text", kwlist, - &text, &len, &oldlen)) { - return NULL; - } - - if (oldlen > 0) { - len = oldlen; - } - - gtk_text_buffer_set_text(GTK_TEXT_BUFFER(self->obj), text, len); - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_text_buffer_get_selection_bounds noargs -static PyObject * -_wrap_gtk_text_buffer_get_selection_bounds(PyGObject *self, PyObject *args) -{ - GtkTextIter start, end; - - if (!gtk_text_buffer_get_selection_bounds(GTK_TEXT_BUFFER(self->obj), - &start, &end)) { - return Py_BuildValue ("()"); - } - - return Py_BuildValue("(NN)", - pyg_boxed_new(GTK_TYPE_TEXT_ITER, &start, TRUE, TRUE), - pyg_boxed_new(GTK_TYPE_TEXT_ITER, &end, TRUE, TRUE)); -} -%% -override gtk_text_buffer_insert kwargs -static PyObject * -_wrap_gtk_text_buffer_insert(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "iter", "text", "len", NULL }; - PyObject *py_iter; - char *text; - int len, oldlen = -1; - GtkTextIter *iter = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Os#|i:GtkTextBuffer.insert", - kwlist, &py_iter, &text, &len, &oldlen)) { - return NULL; - } - - if (oldlen > 0) { - len = oldlen; - } - - if (pyg_boxed_check(py_iter, GTK_TYPE_TEXT_ITER)) { - iter = pyg_boxed_get(py_iter, GtkTextIter); - } else { - PyErr_SetString(PyExc_TypeError, "iter should be a GtkTextIter"); - return NULL; - } - gtk_text_buffer_insert(GTK_TEXT_BUFFER(self->obj), iter, text, len); - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_text_buffer_insert_at_cursor kwargs -static PyObject * -_wrap_gtk_text_buffer_insert_at_cursor(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "text", "len", NULL }; - char *text; - int len, oldlen = -1; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "s#|i:GtkTextBuffer.insert_at_cursor", - kwlist, &text, &len, &oldlen)) { - return NULL; - } - - if (oldlen > 0) { - len = oldlen; - } - - gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(self->obj), text, len); - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_text_buffer_insert_interactive kwargs -static PyObject * -_wrap_gtk_text_buffer_insert_interactive(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "iter", "text", "default_editable", "len", NULL }; - PyObject *py_iter, *py_ret; - char *text; - int len, default_editable, ret, oldlen = -1; - GtkTextIter *iter = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "Os#i|i:GtkTextBuffer.insert_interactive", - kwlist, &py_iter, &text, &len, - &default_editable, &oldlen)) { - return NULL; - } - - if (oldlen > 0) { - len = oldlen; - } - - if (pyg_boxed_check(py_iter, GTK_TYPE_TEXT_ITER)) { - iter = pyg_boxed_get(py_iter, GtkTextIter); - } else { - PyErr_SetString(PyExc_TypeError, "iter should be a GtkTextIter"); - return NULL; - } - ret = gtk_text_buffer_insert_interactive(GTK_TEXT_BUFFER(self->obj), iter, - text, len, default_editable); - py_ret = ret ? Py_True : Py_False; - Py_INCREF(py_ret); - return py_ret; -} -%% -override gtk_text_buffer_insert_interactive_at_cursor kwargs -static PyObject * -_wrap_gtk_text_buffer_insert_interactive_at_cursor(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "text", "default_editable", "len", NULL }; - char *text; - int len, default_editable, ret, oldlen = -1; - PyObject *py_ret; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "s#i|i:GtkTextBuffer.insert_interactive_at_cursor", - kwlist, &text, &len, &default_editable, &oldlen)) { - return NULL; - } - - if (oldlen > 0) { - len = oldlen; - } - - ret = gtk_text_buffer_insert_interactive_at_cursor(GTK_TEXT_BUFFER(self->obj), - text, len, default_editable); - py_ret = ret ? Py_True : Py_False; - Py_INCREF(py_ret); - return py_ret; -} -%% override gtk_text_child_anchor_get_widgets noargs static PyObject * _wrap_gtk_text_child_anchor_get_widgets(PyGObject *self) @@ -6573,62 +2307,6 @@ _wrap_gtk_text_child_anchor_get_widgets(PyGObject *self) return ret; } %% -override gtk_text_view_get_visible_rect noargs -static PyObject * -_wrap_gtk_text_view_get_visible_rect(PyGObject *self) -{ - GdkRectangle visible_rect; - - gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(self->obj), &visible_rect); - return pyg_boxed_new(GDK_TYPE_RECTANGLE, &visible_rect, TRUE, TRUE); -} -%% -override gtk_text_view_buffer_to_window_coords kwargs -static PyObject * -_wrap_gtk_text_view_buffer_to_window_coords(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "win", "buffer_x", "buffer_y", NULL }; - GtkTextWindowType win; - gint buffer_x, buffer_y, window_x = 0, window_y = 0; - PyObject *py_win; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "Oii:GtkTextView.buffer_to_window_coords", - kwlist, &py_win, &buffer_x, &buffer_y)) - return NULL; - if (pyg_enum_get_value(GTK_TYPE_TEXT_WINDOW_TYPE, py_win, (gint *)&win)) - return NULL; - gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(self->obj), win, - buffer_x, buffer_y, - &window_x, &window_y); - return Py_BuildValue("(ii)", window_x, window_y); -} -%% -override gtk_text_view_window_to_buffer_coords kwargs -static PyObject * -_wrap_gtk_text_view_window_to_buffer_coords(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "win", "window_x", "window_y", NULL }; - GtkTextWindowType win; - gint window_x, window_y, buffer_x = 0, buffer_y = 0; - PyObject *py_win; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "Oii:GtkTextView.window_to_buffer_coords", - kwlist, &py_win, &window_x, &window_y)) - return NULL; - if (pyg_enum_get_value(GTK_TYPE_TEXT_WINDOW_TYPE, py_win, (gint *)&win)) - return NULL; - gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(self->obj), win, - window_x, window_y, - &buffer_x, &buffer_y); - return Py_BuildValue("(ii)", buffer_x, buffer_y); -} -%% -ignore gtk_dialog_new -%% override gtk_dialog_new_with_buttons kwargs static int _wrap_gtk_dialog_new_with_buttons(PyGObject *self, PyObject *args, @@ -6760,8 +2438,6 @@ _wrap_gtk_message_dialog_new(PyGObject *self, PyObject *args, PyObject *kwargs) return 0; } %% -ignore gtk_progress_bar_new -%% override gtk_progress_bar_new_with_adjustment kwargs static PyObject * _wrap_gtk_progress_bar_new_with_adjustment(PyGObject *self, PyObject *args, PyObject *kwargs) @@ -6898,50 +2574,6 @@ _wrap_gtk_icon_set_get_sizes(PyGObject *self) return ret; } %% -override gtk_cell_renderer_get_size kwargs -static PyObject * -_wrap_gtk_cell_renderer_get_size(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "widget", "cell_area", NULL }; - gint x_offset = 0, y_offset = 0, width = 0, height = 0; - GdkRectangle cell_area; - PyObject *py_widget, *py_cell_area = Py_None; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O|O:GtkCellRenderer.get_size", kwlist, - &py_widget, &py_cell_area)) - return NULL; - - if (!pygobject_check(py_widget, &PyGtkWidget_Type)) { - PyErr_SetString(PyExc_TypeError, "widget must be a GtkWidget"); - return NULL; - } - if (py_cell_area != Py_None) { - if (!pygdk_rectangle_from_pyobject(py_cell_area, &cell_area)) - return NULL; - } - - gtk_cell_renderer_get_size(GTK_CELL_RENDERER(self->obj), - GTK_WIDGET(pygobject_get(py_widget)), - (py_cell_area == Py_None) ? NULL : &cell_area, - &x_offset, &y_offset, &width, &height); - - return Py_BuildValue("(iiii)", x_offset, y_offset, width, height); -} -%% -override gtk_cell_renderer_get_fixed_size noargs -static PyObject * -_wrap_gtk_cell_renderer_get_fixed_size(PyGObject *self) -{ - gint width, height; - - gtk_cell_renderer_get_fixed_size(GTK_CELL_RENDERER(self->obj), - &width, &height); - - return Py_BuildValue("(ii)", width, height); -} -%% override gtk_stock_add kwargs static PyObject * _wrap_gtk_stock_add(PyGObject *self, PyObject *args, PyObject *kwargs) @@ -7328,93 +2960,6 @@ _wrap_gtk_adjustment_set_all(PyGObject *self, PyObject *args, return Py_None; } %% -override gtk_text_view_get_iter_location kwargs -static PyObject * -_wrap_gtk_text_view_get_iter_location(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "iter", NULL }; - PyObject *py_iter; - GdkRectangle location; - GtkTextIter *iter = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O:GtkTextView.get_iter_location", - kwlist, &py_iter)) - return NULL; - if (pyg_boxed_check(py_iter, GTK_TYPE_TEXT_ITER)) - iter = pyg_boxed_get(py_iter, GtkTextIter); - else { - PyErr_SetString(PyExc_TypeError, "iter should be a GtkTextIter"); - return NULL; - } - gtk_text_view_get_iter_location(GTK_TEXT_VIEW(self->obj), iter, &location); - return pyg_boxed_new(GDK_TYPE_RECTANGLE, &location, TRUE, TRUE); -} -%% -override gtk_text_view_get_line_at_y kwargs -static PyObject * -_wrap_gtk_text_view_get_line_at_y(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "y", NULL }; - GtkTextIter iter; - gint y, line_top; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "i:GtkTextView.get_line_at_y", - kwlist, &y)) - return NULL; - gtk_text_view_get_line_at_y(GTK_TEXT_VIEW(self->obj), - &iter, y, &line_top); - return Py_BuildValue("(Ni)", - pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE), - line_top); -} -%% -override gtk_text_view_get_line_yrange kwargs -static PyObject * -_wrap_gtk_text_view_get_line_yrange(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "iter", NULL }; - GtkTextIter *iter = NULL; - gint y = -1, height = -1; - PyObject *py_iter; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O:GtkTextView.get_line_yrange", - kwlist, &py_iter)) - return NULL; - if (pyg_boxed_check(py_iter, GTK_TYPE_TEXT_ITER)) - iter = pyg_boxed_get(py_iter, GtkTextIter); - else { - PyErr_SetString(PyExc_TypeError, "iter should be a GtkTextIter"); - return NULL; - } - gtk_text_view_get_line_yrange(GTK_TEXT_VIEW(self->obj), - iter, &y, &height); - return Py_BuildValue("(ii)", y, height); -} -%% -override gtk_text_view_get_iter_at_location kwargs -static PyObject * -_wrap_gtk_text_view_get_iter_at_location(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "x", "y", NULL }; - GtkTextIter iter; - gint x, y; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "ii:GtkTextView.get_iter_at_location", - kwlist, &x, &y)) - return NULL; - gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(self->obj), - &iter, x, y); - return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE); -} -%% override gtk_file_selection_get_selections noargs static PyObject * _wrap_gtk_file_selection_get_selections(PyGObject *self) @@ -7459,94 +3004,6 @@ _wrap_gtk_icon_size_lookup(PyGObject *self, PyObject *args, PyObject *kwargs) return Py_BuildValue("(ii)", width, height); } %% -override-attr GtkTextAttributes.bg_color -static PyObject * -_wrap_gtk_text_attributes__get_bg_color(PyObject *self, void *closure) -{ - GdkColor ret; - - ret = pyg_boxed_get(self, GtkTextAttributes)->appearance.bg_color; - /* pyg_boxed_new handles NULL checking */ - return pyg_boxed_new(GDK_TYPE_COLOR, &ret, TRUE, TRUE); -} -%% -override-attr GtkTextAttributes.fg_color -static PyObject * -_wrap_gtk_text_attributes__get_fg_color(PyObject *self, void *closure) -{ - GdkColor ret; - - ret = pyg_boxed_get(self, GtkTextAttributes)->appearance.fg_color; - /* pyg_boxed_new handles NULL checking */ - return pyg_boxed_new(GDK_TYPE_COLOR, &ret, TRUE, TRUE); -} -%% -override-attr GtkTextAttributes.bg_stipple -static PyObject * -_wrap_gtk_text_attributes__get_bg_stipple(PyObject *self, void *closure) -{ - GdkBitmap *ret; - - ret = pyg_boxed_get(self, GtkTextAttributes)->appearance.bg_stipple; - /* pygobject_new handles NULL checking */ - return pygobject_new((GObject *)ret); -} -%% -override-attr GtkTextAttributes.fg_stipple -static PyObject * -_wrap_gtk_text_attributes__get_fg_stipple(PyObject *self, void *closure) -{ - GdkBitmap *ret; - - ret = pyg_boxed_get(self, GtkTextAttributes)->appearance.fg_stipple; - /* pygobject_new handles NULL checking */ - return pygobject_new((GObject *)ret); -} -%% -override-attr GtkTextAttributes.rise -static PyObject * -_wrap_gtk_text_attributes__get_rise(PyObject *self, void *closure) -{ - int ret; - - ret = pyg_boxed_get(self, GtkTextAttributes)->appearance.rise; - return PyInt_FromLong(ret); -} -%% -override-attr GtkTextAttributes.underline -static PyObject * -_wrap_gtk_text_attributes__get_underline(PyObject *self, void *closure) -{ - int ret; - - ret = pyg_boxed_get(self, GtkTextAttributes)->appearance.underline; - return PyInt_FromLong(ret); -} -%% -override-attr GtkTextAttributes.strikethrough -static PyObject * -_wrap_gtk_text_attributes__get_strikethrough(PyObject *self, void *closure) -{ - PyObject *ret; - - ret = pyg_boxed_get(self, GtkTextAttributes)->appearance.strikethrough - ? Py_True : Py_False; - Py_INCREF(ret); - return ret; -} -%% -override-attr GtkTextAttributes.draw_bg -static PyObject * -_wrap_gtk_text_attributes__get_draw_bg(PyObject *self, void *closure) -{ - PyObject *ret; - - ret = pyg_boxed_get(self, GtkTextAttributes)->appearance.draw_bg - ? Py_True : Py_False; - Py_INCREF(ret); - return ret; -} -%% override gtk_image_get_pixmap noargs static PyObject * _wrap_gtk_image_get_pixmap(PyGObject *self) @@ -7752,147 +3209,6 @@ _wrap_gtk_scrolled_window_get_policy(PyGObject *self) return Py_BuildValue("(ii)", hscrollbar_policy, vscrollbar_policy); } %% -override gtk_text_buffer_get_iter_at_child_anchor kwargs -static PyObject * -_wrap_gtk_text_buffer_get_iter_at_child_anchor(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "anchor", NULL }; - PyGObject *anchor; - GtkTextIter iter; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:GtkTextBuffer.get_iter_at_child_anchor", kwlist, &PyGtkTextChildAnchor_Type, &anchor)) - return NULL; - - gtk_text_buffer_get_iter_at_child_anchor(GTK_TEXT_BUFFER(self->obj), - &iter, - GTK_TEXT_CHILD_ANCHOR(anchor->obj)); - return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE); -} -%% -override gtk_text_tag_table_add kwargs -static PyObject * -_wrap_gtk_text_tag_table_add(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = { "tag", NULL }; - GtkTextTag *tag; - GtkTextTagTable *table; - PyGObject *pytag; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:GtkTextTagTable.add", - kwlist, &PyGtkTextTag_Type, &pytag)) { - return NULL; - } - - tag = GTK_TEXT_TAG(pytag->obj); - table = GTK_TEXT_TAG_TABLE(self->obj); - - if (tag->table) { - gchar buf[512]; - g_snprintf(buf, sizeof(buf), - "The tag is already in a tag table"); - - PyErr_SetString(PyExc_ValueError, buf); - return NULL; - } - - if (tag->name && table && g_hash_table_lookup(table->hash, tag->name)) { - gchar buf[512]; - g_snprintf(buf, sizeof(buf), - "A tag named '%s' is already in the tag table", - tag->name); - - PyErr_SetString(PyExc_ValueError, buf); - return NULL; - } - - gtk_text_tag_table_add(table, tag); - - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_text_tag_table_remove kwargs -static PyObject * -_wrap_gtk_text_tag_table_remove(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "tag", NULL }; - GtkTextTag *tag; - GtkTextTagTable *table; - PyGObject *pytag; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O!:GtkTextTagTable.remove", - kwlist, &PyGtkTextTag_Type, &pytag)) { - return NULL; - } - - tag = GTK_TEXT_TAG(pytag->obj); - table = GTK_TEXT_TAG_TABLE(self->obj); - - if (tag->table != table) { - gchar buf[512]; - if (tag->name) - g_snprintf(buf, sizeof(buf), - "The tag named '%s' is not in the tag table", - tag->name); - else - g_snprintf(buf, sizeof(buf), - "The tag is not in the tag table"); - - PyErr_SetString(PyExc_ValueError, buf); - return NULL; - } - - gtk_text_tag_table_remove(table, tag); - - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_text_view_set_border_window_size kwargs -static PyObject * -_wrap_gtk_text_view_set_border_window_size(PyGObject *self, PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "type", "size", NULL }; - PyObject *py_type = NULL; - int size; - GtkTextWindowType type; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "Oi:GtkTextView.set_border_window_size", - kwlist, &py_type, &size)) - return NULL; - - if (size < 0) { - PyErr_SetString(PyExc_ValueError, "size must be >= 0"); - return NULL; - } - - if (pyg_enum_get_value(GTK_TYPE_TEXT_WINDOW_TYPE, py_type, (gint *)&type)) - return NULL; - - switch (type) - { - case GTK_TEXT_WINDOW_LEFT: - case GTK_TEXT_WINDOW_RIGHT: - case GTK_TEXT_WINDOW_TOP: - case GTK_TEXT_WINDOW_BOTTOM: - gtk_text_view_set_border_window_size(GTK_TEXT_VIEW(self->obj), type, - size); - default: - PyErr_SetString(PyExc_ValueError, "type must be one of: " - "gtk.TEXT_WINDOW_LEFT, gtk.TEXT_WINDOW_RIGHT, " - "gtk.TEXT_WINDOW_TOP or gtk.TEXT_WINDOW_BOTTOM"); - return NULL; - } - - Py_INCREF(Py_None); - return Py_None; -} -%% override gtk_tooltips_data_get kwargs static PyObject * _wrap_gtk_tooltips_data_get(PyGObject *self, PyObject *args, PyObject *kwargs) @@ -7920,151 +3236,3 @@ _wrap_gtk_tooltips_data_get(PyGObject *self, PyObject *args, PyObject *kwargs) data->tip_private); } %% -override gtk_window_get_frame_dimensions noargs -static PyObject * -_wrap_gtk_window_get_frame_dimensions(PyGObject *self) -{ - int left, top, right, bottom; - - gtk_window_get_frame_dimensions(GTK_WINDOW(self->obj), - &left, &top, &right, &bottom); - return Py_BuildValue("(iiii)", left, top, right, bottom); -} -%% -override gtk_widget_get_size_request noargs -static PyObject * -_wrap_gtk_widget_get_size_request(PyGObject *self) -{ - int width, height; - - gtk_widget_get_size_request(GTK_WIDGET(self->obj), &width, &height); - return Py_BuildValue("(ii)", width, height); -} -%% -override gtk_window_set_icon_list args -static PyObject * -_wrap_gtk_window_set_icon_list(PyGObject *self, PyObject *args) -{ - GList *icon_list = NULL; - PyObject *pyicon; - gint len, i; - - len = PyTuple_Size(args); - for (i = 0; i < len; i++) { - pyicon = PyTuple_GetItem(args, i); - if (!pygobject_check(pyicon, &PyGdkPixbuf_Type)) { - PyErr_SetString(PyExc_TypeError, - "icons must be GdkPixbufs"); - g_list_free(icon_list); - return NULL; - } - icon_list = g_list_prepend(icon_list, pygobject_get(pyicon)); - } - gtk_window_set_icon_list(GTK_WINDOW(self->obj), icon_list); - g_list_free(icon_list); - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_window_get_icon_list noargs -static PyObject * -_wrap_gtk_window_get_icon_list(PyGObject *self) -{ - GList *icon_list = NULL; - PyObject *pyicon; - - if ((icon_list = gtk_window_get_icon_list(GTK_WINDOW(self->obj)))) { - PyObject *py_list; - GList *tmp; - - if ((py_list = PyList_New(0)) == NULL) { - g_list_free(icon_list); - return NULL; - } - for (tmp = icon_list; tmp != NULL; tmp = tmp->next) { - pyicon = pygobject_new(G_OBJECT(tmp->data)); - - if (pyicon == NULL) { - g_list_free(icon_list); - Py_DECREF(py_list); - return NULL; - } - PyList_Append(py_list, pyicon); - Py_DECREF(pyicon); - } - g_list_free(icon_list); - return py_list; - } - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_window_set_default_icon_list args -static PyObject * -_wrap_gtk_window_set_default_icon_list(PyGObject *self, PyObject *args) -{ - GList *icon_list = NULL; - PyObject *pyicon; - gint len, i; - - len = PyTuple_Size(args); - for (i = 0; i < len; i++) { - pyicon = PyTuple_GetItem(args, i); - if (!pygobject_check(pyicon, &PyGdkPixbuf_Type)) { - PyErr_SetString(PyExc_TypeError, - "icons must be GdkPixbufs"); - g_list_free(icon_list); - return NULL; - } - icon_list = g_list_prepend(icon_list, pygobject_get(pyicon)); - } - gtk_window_set_default_icon_list(icon_list); - g_list_free(icon_list); - Py_INCREF(Py_None); - return Py_None; -} -%% -override gtk_window_get_default_icon_list noargs -static PyObject * -_wrap_gtk_window_get_default_icon_list(PyGObject *self) -{ - GList *icon_list = NULL; - PyObject *pyicon; - - if ((icon_list = gtk_window_get_default_icon_list())) { - PyObject *py_list; - GList *tmp; - - if ((py_list = PyList_New(0)) == NULL) { - g_list_free(icon_list); - return NULL; - } - for (tmp = icon_list; tmp != NULL; tmp = tmp->next) { - pyicon = pygobject_new(G_OBJECT(tmp->data)); - - if (pyicon == NULL) { - g_list_free(icon_list); - Py_DECREF(py_list); - return NULL; - } - PyList_Append(py_list, pyicon); - Py_DECREF(pyicon); - } - g_list_free(icon_list); - return py_list; - } - Py_INCREF(Py_None); - return Py_None; -} -%% -ignore-win32 - GTK_TYPE_PLUG - GTK_TYPE_SOCKET - gtk_socket_new - gtk_socket_steal - gtk_socket_add_id - gtk_socket_get_id - gtk_plug_new - gtk_plug_construct - gtk_plug_get_id -%% diff --git a/gtk/gtkclist.override b/gtk/gtkclist.override new file mode 100644 index 00000000..2a1da295 --- /dev/null +++ b/gtk/gtkclist.override @@ -0,0 +1,334 @@ +%% +ignore + gtk_clist_new + gtk_clist_set_row_data_full +%% +override gtk_clist_new_with_titles kwargs +static int +_wrap_gtk_clist_new_with_titles(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "count", "titles", NULL }; + int count = 1, i; + PyObject *py_list = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|iO:GtkCList.__init__", + kwlist, &count, &py_list)) + return -1; + if (py_list) { + gchar **list; + + if (!PySequence_Check(py_list)) { + PyErr_SetString(PyExc_TypeError,"2nd argument not a sequence"); + return -1; + } + if (PySequence_Length(py_list) < count) { + PyErr_SetString(PyExc_TypeError, "sequence not long enough"); + return -1; + } + list = g_new(gchar *, count); + for (i = 0; i < count; i++) { + PyObject *item = PySequence_GetItem(py_list, i); + + Py_DECREF(item); /* PySequence_GetItem INCREF's */ + if (!PyString_Check(item) && !PyUnicode_Check(item)) { + PyErr_SetString(PyExc_TypeError, + "sequence item not a string or unicode object"); + g_free(list); + return -1; + } + list[i] = PyString_AsString(item); + } + self->obj = (GObject *)gtk_clist_new_with_titles(count, list); + g_free(list); + } else + self->obj = (GObject *)gtk_clist_new(count); + if (!self->obj) { + PyErr_SetString(PyExc_RuntimeError,"could not create GtkCList object"); + return -1; + } + pygobject_register_wrapper((PyObject *)self); + return 0; +} +%% +override gtk_clist_get_text kwargs +static PyObject * +_wrap_gtk_clist_get_text(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "row", "column", NULL }; + int r, c; + char *text = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:GtkCList.get_text", + kwlist, &r, &c)) + return NULL; + if (!gtk_clist_get_text(GTK_CLIST(self->obj), r, c, &text) || text==NULL) { + PyErr_SetString(PyExc_ValueError, "can't get text value"); + return NULL; + } + return PyString_FromString(text); +} +%% +override gtk_clist_get_pixmap kwargs +static PyObject * +_wrap_gtk_clist_get_pixmap(PyGObject *self, PyObject *args, PyObject*kwargs) +{ + static char *kwlist[] = { "row", "column", NULL }; + int r, c; + GdkPixmap *pixmap; + GdkBitmap *mask; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:GtkCList.get_pixmap", + kwlist, &r, &c)) + return NULL; + if (!gtk_clist_get_pixmap(GTK_CLIST(self->obj), r, c, + &pixmap, &mask)) { + PyErr_SetString(PyExc_ValueError, "can't get pixmap value"); + return NULL; + } + return Py_BuildValue("(NN)", pygobject_new((GObject *)pixmap), + pygobject_new((GObject *)mask)); +} +%% +override gtk_clist_get_pixtext kwargs +static PyObject * +_wrap_gtk_clist_get_pixtext(PyGObject *self, PyObject *args, PyObject*kwargs) +{ + static char *kwlist[] = { "row", "column", NULL }; + int r, c; + gchar *text; + guint8 spacing; + GdkPixmap *pixmap; + GdkBitmap *mask; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:GtkCList.get_pixtext", + kwlist, &r, &c)) + return NULL; + if (!gtk_clist_get_pixtext(GTK_CLIST(self->obj), r, c, + &text, &spacing, &pixmap, &mask)) { + PyErr_SetString(PyExc_ValueError, "can't get pixtext value"); + return NULL; + } + return Py_BuildValue("(ziNN)", text, (gint)spacing, + pygobject_new((GObject *)pixmap), + pygobject_new((GObject *)mask)); +} +%% +override gtk_clist_prepend kwargs +static PyObject * +_wrap_gtk_clist_prepend(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "text", NULL }; + int col, i; + PyObject *py_list; + gchar **list; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GtkCList.prepend", + kwlist, &py_list)) + return NULL; + if (!PySequence_Check(py_list)) { + PyErr_SetString(PyExc_TypeError, "argument not a sequence"); + return NULL; + } + col = GTK_CLIST(self->obj)->columns; + if (PySequence_Length(py_list) < col) { + PyErr_SetString(PyExc_TypeError, "sequnce too short"); + return NULL; + } + list = g_new(gchar *, col); + for (i = 0; i < col; i++) { + PyObject *item = PySequence_GetItem(py_list, i); + + Py_DECREF(item); + if (!PyString_Check(item) && !PyUnicode_Check(item)) { + PyErr_SetString(PyExc_TypeError, + "sequence item not a string or unicode object"); + g_free(list); + return NULL; + } + list[i] = PyString_AsString(item); + } + i = gtk_clist_prepend(GTK_CLIST(self->obj), list); + g_free(list); + return PyInt_FromLong(i); +} +%% +override gtk_clist_append kwargs +static PyObject * +_wrap_gtk_clist_append(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "text", NULL }; + int col, i; + PyObject *py_list; + gchar **list; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GtkCList.append", + kwlist, &py_list)) + return NULL; + if (!PySequence_Check(py_list)) { + PyErr_SetString(PyExc_TypeError, "argument not a sequence"); + return NULL; + } + col = GTK_CLIST(self->obj)->columns; + if (PySequence_Length(py_list) < col) { + PyErr_SetString(PyExc_TypeError, "sequnce too short"); + return NULL; + } + list = g_new(gchar *, col); + for (i = 0; i < col; i++) { + PyObject *item = PySequence_GetItem(py_list, i); + + Py_DECREF(item); + if (!PyString_Check(item) && !PyUnicode_Check(item)) { + PyErr_SetString(PyExc_TypeError, + "sequence item not a string or unicode object"); + g_free(list); + return NULL; + } + list[i] = PyString_AsString(item); + } + i = gtk_clist_append(GTK_CLIST(self->obj), list); + g_free(list); + return PyInt_FromLong(i); +} +%% +override gtk_clist_insert kwargs +static PyObject * +_wrap_gtk_clist_insert(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "row", "text", NULL }; + int col, row, i; + PyObject *py_list; + gchar **list; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iO:GtkCList.insert", + kwlist, &row, &py_list)) + return NULL; + if (!PySequence_Check(py_list)) { + PyErr_SetString(PyExc_TypeError, "argument not a sequence"); + return NULL; + } + col = GTK_CLIST(self->obj)->columns; + if (PySequence_Length(py_list) < col) { + PyErr_SetString(PyExc_TypeError, "sequnce too short"); + return NULL; + } + list = g_new(gchar *, col); + for (i = 0; i < col; i++) { + PyObject *item = PySequence_GetItem(py_list, i); + + Py_DECREF(item); + if (!PyString_Check(item) && !PyUnicode_Check(item)) { + PyErr_SetString(PyExc_TypeError, + "sequence item not a string or unicode object"); + g_free(list); + return NULL; + } + list[i] = PyString_AsString(item); + } + i = gtk_clist_insert(GTK_CLIST(self->obj), row, list); + g_free(list); + return PyInt_FromLong(i); +} +%% +override gtk_clist_set_row_data kwargs +static PyObject * +_wrap_gtk_clist_set_row_data(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "row", "data", NULL }; + int row; + PyObject *data; + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iO:GtkCList.set_row_data", + kwlist, &row, &data)) + return NULL; + Py_INCREF(data); + gtk_clist_set_row_data_full(GTK_CLIST(self->obj), row, data, + (GtkDestroyNotify)pyg_destroy_notify); + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_clist_get_row_data kwargs +static PyObject * +_wrap_gtk_clist_get_row_data(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "row", NULL }; + PyObject *ret; + int row; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:GtkCList.get_row_data", + kwlist, &row)) + return NULL; + ret = gtk_clist_get_row_data(GTK_CLIST(self->obj), row); + if (!ret) ret = Py_None; + Py_INCREF(ret); + return ret; +} +%% +override gtk_clist_find_row_from_data kwargs +static PyObject * +_wrap_gtk_clist_find_row_from_data(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "data", NULL }; + PyObject *data; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O:GtkCList.find_row_from_data", kwlist, + &data)) + return NULL; + return PyInt_FromLong(gtk_clist_find_row_from_data( + GTK_CLIST(self->obj), data)); +} +%% +override gtk_clist_get_selection_info kwargs +static PyObject * +_wrap_gtk_clist_get_selection_info(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "x", "y", NULL }; + gint x, y, row, column; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "ii:GtkCList.get_selection_info", kwlist, + &x, &y)) + return NULL; + if (gtk_clist_get_selection_info(GTK_CLIST(self->obj), x, y, + &row, &column)) + return Py_BuildValue("(ii)", row, column); + else { + Py_INCREF(Py_None); + return Py_None; + } +} +%% +override-attr GtkCList.selection +static PyObject * +_wrap_gtk_clist__get_selection(PyGObject *self, void *closure) +{ + guint row; + GList *selection; + PyObject *py_int, *ret = PyList_New(0); + + if (ret == NULL) + return NULL; + + for (selection = GTK_CLIST(self->obj)->selection; selection != NULL; + selection = selection->next) { + row = GPOINTER_TO_UINT(selection->data); + + py_int = PyInt_FromLong(row); + + if (!py_int) { + Py_DECREF(ret); + return NULL; + } + + PyList_Append(ret, py_int); + Py_DECREF(py_int); + } + return ret; + +} diff --git a/gtk/gtkcontainer.override b/gtk/gtkcontainer.override new file mode 100644 index 00000000..b4656239 --- /dev/null +++ b/gtk/gtkcontainer.override @@ -0,0 +1,521 @@ +/* -*- Mode: C; c-basic-offset: 4 -*- */ +%% +ignore + gtk_container_get_toplevels + gtk_container_add_child_arg_type + gtk_container_query_child_args + gtk_container_child_args_collect + gtk_container_child_arg_get_info + gtk_container_foreach_full + gtk_container_add_with_args + gtk_container_addv + gtk_container_child_set_valist + gtk_container_child_get_valist +%% +override gtk_container_children noargs +static PyObject * +_wrap_gtk_container_children(PyGObject *self) +{ + if (PyErr_Warn(PyExc_DeprecationWarning, "use GtkContainer.get_children")) + return NULL; + return _wrap_gtk_container_get_children(self); +} +%% +override gtk_container_get_children noargs +static PyObject * +_wrap_gtk_container_get_children(PyGObject *self) +{ + GList *list, *tmp; + PyObject *py_list; + + list = gtk_container_get_children(GTK_CONTAINER(self->obj)); + + if ((py_list = PyList_New(0)) == NULL) { + g_list_free(list); + return NULL; + } + for (tmp = list; tmp != NULL; tmp = tmp->next) { + PyObject *gtk_obj = pygobject_new(G_OBJECT(tmp->data)); + + if (gtk_obj == NULL) { + g_list_free(list); + Py_DECREF(py_list); + return NULL; + } + PyList_Append(py_list, gtk_obj); + Py_DECREF(gtk_obj); + } + g_list_free(list); + return py_list; +} +%% +override gtk_container_set_focus_chain kwargs +static PyObject * +_wrap_gtk_container_set_focus_chain(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "focusable_widgets", NULL }; + PyObject *py_focusable_widgets; + gint len, i; + GList *focusable_widgets = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O:GtkContainer.set_focus_chain", kwlist, + &py_focusable_widgets)) + return NULL; + if (!PySequence_Check(py_focusable_widgets)) { + PyErr_SetString(PyExc_TypeError, + "focusable_widgets must be a sequence"); + return NULL; + } + len = PySequence_Length(py_focusable_widgets); + for (i = 0; i < len; i++) { + PyObject *item = PySequence_GetItem(py_focusable_widgets, i); + + if (!pygobject_check(item, &PyGtkWidget_Type)) { + PyErr_SetString(PyExc_TypeError, + "focusable_widgets members must be GtkWidgets"); + Py_DECREF(item); + return NULL; + } + focusable_widgets = g_list_prepend(focusable_widgets, + pygobject_get(item)); + Py_DECREF(item); + } + focusable_widgets = g_list_reverse(focusable_widgets); + gtk_container_set_focus_chain(GTK_CONTAINER(self->obj), focusable_widgets); + g_list_free(focusable_widgets); + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_container_get_focus_chain noargs +static PyObject * +_wrap_gtk_container_get_focus_chain(PyGObject *self) +{ + GList *list = NULL; + + if (gtk_container_get_focus_chain(GTK_CONTAINER(self->obj), &list)) { + PyObject *py_list; + GList *tmp; + + if ((py_list = PyList_New(0)) == NULL) { + g_list_free(list); + return NULL; + } + for (tmp = list; tmp != NULL; tmp = tmp->next) { + PyObject *gtk_obj = pygobject_new(G_OBJECT(tmp->data)); + + if (gtk_obj == NULL) { + g_list_free(list); + Py_DECREF(py_list); + return NULL; + } + PyList_Append(py_list, gtk_obj); + Py_DECREF(gtk_obj); + } + g_list_free(list); + return py_list; + } + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_container_child_get_property +static PyObject * +_wrap_gtk_container_child_get_property(PyGObject *self, PyObject *args) +{ + PyGObject *pychild; + gchar *property_name; + GtkContainer *container; + GtkWidget *child; + GList *children; + GObjectClass *class; + GParamSpec *pspec; + GValue value = { 0, } ; + PyObject *ret; + + if (!PyArg_ParseTuple(args, "O!s:GtkContainer.child_get_property", + &PyGtkWidget_Type, &pychild, + &property_name)) { + return NULL; + } + + container = GTK_CONTAINER(self->obj); + child = GTK_WIDGET(pychild->obj); + + children = gtk_container_get_children(container); + if (g_list_find(children, child) == NULL) { + PyErr_SetString(PyExc_TypeError, + "first argument must be a child"); + return NULL; + } + + class = G_OBJECT_GET_CLASS(container); + pspec = gtk_container_class_find_child_property(class, property_name); + if (!pspec) { + gchar buf[512]; + g_snprintf(buf, sizeof(buf), + "container does not support property `%s'", + property_name); + + PyErr_SetString(PyExc_TypeError, buf); + return NULL; + } + + g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec)); + + gtk_container_child_get_property(container, + child, + property_name, + &value); + + ret = pyg_value_as_pyobject(&value, TRUE); + g_value_unset(&value); + + return ret; +} +%% +override gtk_container_child_set_property +static PyObject * +_wrap_gtk_container_child_set_property(PyGObject *self, PyObject *args) +{ + gchar *property_name; + PyGObject *pychild; + GtkContainer *container; + GtkWidget *child; + GList *children; + PyGObject *pyvalue; + GObjectClass *class; + GParamSpec *pspec; + GValue value = { 0, } ; + + if (!PyArg_ParseTuple(args, "O!sO:GtkContainer.child_set_property", + &PyGtkWidget_Type, &pychild, + &property_name, &pyvalue)) { + return NULL; + } + + container = GTK_CONTAINER(self->obj); + child = GTK_WIDGET(pychild->obj); + + children = gtk_container_get_children(container); + if (g_list_find(children, child) == NULL) { + PyErr_SetString(PyExc_TypeError, + "first argument must be a child"); + return NULL; + } + + class = G_OBJECT_GET_CLASS(self->obj); + pspec = gtk_container_class_find_child_property(class, property_name); + if (!pspec) { + gchar buf[512]; + g_snprintf(buf, sizeof(buf), + "container does not support property `%s'", + property_name); + PyErr_SetString(PyExc_TypeError, buf); + + return NULL; + } + + g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec)); + + pyg_value_from_pyobject(&value, (PyObject*)pyvalue); + + gtk_container_child_set_property(container, + child, + property_name, + &value); + g_value_unset(&value); + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_container_child_set +static PyObject * +_wrap_gtk_container_child_set(PyGObject *self, PyObject *args) +{ + PyGObject *pychild; + GtkContainer *container; + GtkWidget *child; + GList *children; + GObjectClass *class; + int len, i; + + pychild = (PyGObject*)PyTuple_GetItem(args, 0); + if (!pygobject_check(pychild, &PyGtkWidget_Type)) { + PyErr_SetString(PyExc_TypeError, "first argument should be a GtkWidget"); + return NULL; + } + + container = GTK_CONTAINER(self->obj); + child = GTK_WIDGET(pychild->obj); + + children = gtk_container_get_children(container); + if (g_list_find(children, child) == NULL) { + PyErr_SetString(PyExc_TypeError, + "first argument must be a child"); + return NULL; + } + + len = PyTuple_Size(args); + if ((len - 1) % 2) { + PyErr_SetString(PyExc_TypeError, + "Argument list must be column, value pairs. No -1 " + "termination is needed."); + return NULL; + } + + class = G_OBJECT_GET_CLASS(self->obj); + for (i = 1; i < len; i+=2) { + PyObject *py_property = PyTuple_GetItem(args, i); + PyObject *py_value = PyTuple_GetItem(args, i + 1); + gchar *property_name; + GParamSpec *pspec; + GValue value = { 0 }; + + if (!PyString_Check(py_property)) { + PyErr_SetString(PyExc_TypeError, + "Expected string argument for property."); + return NULL; + } + + property_name = PyString_AsString(py_property); + + pspec = gtk_container_class_find_child_property(class, property_name); + if (!pspec) { + gchar buf[512]; + g_snprintf(buf, sizeof(buf), + "container does not support property `%s'", + property_name); + PyErr_SetString(PyExc_TypeError, buf); + + return NULL; + } + + g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec)); + + pyg_value_from_pyobject(&value, (PyObject*)py_value); + + gtk_container_child_set_property(container, child, property_name, &value); + + g_value_unset(&value); + } + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_container_child_get +static PyObject * +_wrap_gtk_container_child_get(PyGObject *self, PyObject *args) +{ + PyGObject *pychild; + GtkContainer *container; + GtkWidget *child; + GList *children; + GObjectClass *class; + int len, i; + PyObject *tuple; + + pychild = (PyGObject*)PyTuple_GetItem(args, 0); + if (!pygobject_check(pychild, &PyGtkWidget_Type)) { + PyErr_SetString(PyExc_TypeError, "first argument should be a GtkWidget"); + return NULL; + } + + container = GTK_CONTAINER(self->obj); + child = GTK_WIDGET(pychild->obj); + + children = gtk_container_get_children(container); + if (g_list_find(children, child) == NULL) { + PyErr_SetString(PyExc_TypeError, + "first argument must be a child"); + return NULL; + } + + len = PyTuple_Size(args); + tuple = PyTuple_New(len-1); + class = G_OBJECT_GET_CLASS(self->obj); + for (i = 1; i < len; i++) { + PyObject *py_property = PyTuple_GetItem(args, i); + gchar *property_name; + GParamSpec *pspec; + GValue value = { 0 }; + PyObject *item; + + if (!PyString_Check(py_property)) { + PyErr_SetString(PyExc_TypeError, + "Expected string argument for property."); + return NULL; + } + + property_name = PyString_AsString(py_property); + + pspec = gtk_container_class_find_child_property(class, property_name); + if (!pspec) { + gchar buf[512]; + g_snprintf(buf, sizeof(buf), + "container does not support property `%s'", + property_name); + PyErr_SetString(PyExc_TypeError, buf); + + return NULL; + } + + g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec)); + + gtk_container_child_get_property(container, child, property_name, &value); + + item = pyg_value_as_pyobject(&value, TRUE); + PyTuple_SetItem(tuple, i-1, item); + Py_INCREF(item); + + g_value_unset(&value); + } + + Py_INCREF(tuple); + return tuple; +} +%% +override gtk_container_add_with_properties +static PyObject * +_wrap_gtk_container_add_with_properties(PyGObject *self, PyObject *args) +{ + PyGObject *pychild; + GtkContainer *container; + GtkWidget *child; + GObjectClass *class; + int len, i; + + pychild = (PyGObject*)PyTuple_GetItem(args, 0); + if (!pygobject_check(pychild, &PyGtkWidget_Type)) { + PyErr_SetString(PyExc_TypeError, "first argument should be a GtkWidget"); + return NULL; + } + + container = GTK_CONTAINER(self->obj); + child = GTK_WIDGET(pychild->obj); + + len = PyTuple_Size(args); + if ((len - 1) % 2) { + PyErr_SetString(PyExc_TypeError, + "Argument list must be column, value pairs. No -1 " + "termination is needed."); + return NULL; + } + + gtk_widget_freeze_child_notify(child); + + gtk_container_add(container, child); + + class = G_OBJECT_GET_CLASS(self->obj); + for (i = 1; i < len; i+=2) { + PyObject *py_property = PyTuple_GetItem(args, i); + PyObject *py_value = PyTuple_GetItem(args, i + 1); + gchar *property_name; + GParamSpec *pspec; + GValue value = { 0 }; + + if (!PyString_Check(py_property)) { + PyErr_SetString(PyExc_TypeError, + "Expected string argument for property."); + return NULL; + } + + property_name = PyString_AsString(py_property); + + pspec = gtk_container_class_find_child_property(class, property_name); + if (!pspec) { + gchar buf[512]; + g_snprintf(buf, sizeof(buf), + "container does not support property `%s'", + property_name); + PyErr_SetString(PyExc_TypeError, buf); + + return NULL; + } + + g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec)); + + pyg_value_from_pyobject(&value, (PyObject*)py_value); + + gtk_container_child_set_property(container, child, property_name, &value); + + g_value_unset(&value); + } + + gtk_widget_thaw_child_notify(child); + + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_container_foreach +static void +pygtk_container_for_common_marshal(GtkWidget *widget, + gpointer data) +{ + PyGtkCustomNotify *cunote = data; + PyObject *py_widget, *retobj; + + g_assert(cunote->func); + + pyg_block_threads(); + + py_widget = pygobject_new((GObject*)widget); + if (cunote->data) + retobj = PyEval_CallFunction(cunote->func, "(NO)", + py_widget, cunote->data); + else + retobj = PyEval_CallFunction(cunote->func, "(N)", + py_widget); + + if (retobj == NULL) { + PyErr_Print(); + } + + Py_XDECREF(retobj); + + pyg_unblock_threads(); +} +static PyObject * +pygtk_container_for_common(PyGObject *self, PyObject *args, unsigned for_index) +{ + PyObject *pyfunc, *pyarg = NULL; + PyGtkCustomNotify cunote; + static struct { + char *parse_arg; + void (*for_func)(GtkContainer *container, GtkCallback callback, + gpointer callback_data); + } table[] = { + { "O|O:GtkContainer.foreach", gtk_container_foreach }, + { "O|O:GtkContainer.forall", gtk_container_forall } + }; + + g_assert(for_index < countof(table)); + + if (!PyArg_ParseTuple(args, table[for_index].parse_arg, + &pyfunc, &pyarg)) + return NULL; + + cunote.func = pyfunc; + cunote.data = pyarg; + table[for_index].for_func(GTK_CONTAINER(self->obj), + pygtk_container_for_common_marshal, + &cunote); + + Py_INCREF(Py_None); + return Py_None; +} +static PyObject * +_wrap_gtk_container_foreach(PyGObject *self, PyObject *args) +{ + return pygtk_container_for_common(self, args, PYGTK_CONTAINER_FOREACH); +} +%% +override gtk_container_forall +static PyObject * +_wrap_gtk_container_forall(PyGObject *self, PyObject *args) +{ + return pygtk_container_for_common(self, args, PYGTK_CONTAINER_FORALL); +} diff --git a/gtk/gtkctree.override b/gtk/gtkctree.override new file mode 100644 index 00000000..7aa490de --- /dev/null +++ b/gtk/gtkctree.override @@ -0,0 +1,503 @@ +%% +ignore gtk_ctree_construct + gtk_ctree_insert_gnode + gtk_ctree_export_to_gnode + gtk_ctree_post_recursive + gtk_ctree_post_recursive_to_depth + gtk_ctree_pre_recursive + gtk_ctree_pre_recursive_to_depth + gtk_ctree_find_node_ptr +%% +ignore gtk_ctree_new +%% +override-attr GtkCTree.selection +static PyObject * +_wrap_gtk_ctree__get_selection(PyGObject *self, void *closure) +{ + GList *selection; + GtkCTreeNode *node; + PyObject *ret, *py_node; + if ((ret = PyList_New(0)) == NULL) + return NULL; + + for (selection = GTK_CLIST(self->obj)->selection; selection != NULL; + selection = selection->next) { + node = selection->data; + if ((py_node = pyg_pointer_new(GTK_TYPE_CTREE_NODE, node)) == NULL) { + Py_DECREF(ret); + return NULL; + } + PyList_Append(ret, py_node); + Py_DECREF(py_node); + } + + return ret; +} +%% +override gtk_ctree_new_with_titles kwargs +static int +_wrap_gtk_ctree_new_with_titles(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "columns", "tree_column", "titles", NULL }; + int columns = 1, tree_column = 0; + PyObject *py_titles = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|iiO:GtkCTree.__init__", + kwlist, &columns, &tree_column, + &py_titles)) + return -1; + if (py_titles) { + gchar **titles; + gint i; + + if (!PySequence_Check(py_titles)) { + PyErr_SetString(PyExc_TypeError, "titles must be a sequence"); + return -1; + } + if (PySequence_Length(py_titles) < columns) { + PyErr_SetString(PyExc_TypeError, "titles too short"); + return -1; + } + titles = g_new(gchar *, columns); + for (i = 0; i < columns; i++) { + PyObject *item = PySequence_GetItem(py_titles, i); + + Py_DECREF(item); + if (!PyString_Check(item) && !PyUnicode_Check(item)) { + PyErr_SetString(PyExc_TypeError, + "sequence item not a string or unicode object"); + g_free(titles); + return -1; + } + titles[i] = PyString_AsString(item); + } + self->obj = (GObject *)gtk_ctree_new_with_titles(columns, + tree_column, titles); + g_free(titles); + } else + self->obj = (GObject *)gtk_ctree_new(columns, tree_column); + if (!self->obj) { + PyErr_SetString(PyExc_RuntimeError,"could not create GtkCTree object"); + return -1; + } + pygobject_register_wrapper((PyObject *)self); + return 0; +} +%% +override gtk_ctree_base_nodes +static PyObject* +_wrap_gtk_ctree_base_nodes(PyGObject *self, PyObject *args) +{ + PyObject *ret; + GtkCTreeNode *node; + + /* the first row is always a base node */ + node = GTK_CTREE_NODE(GTK_CLIST(self->obj)->row_list); + if ((ret = PyList_New(0)) == NULL) + return NULL; + while (node) { + PyObject *obj = pyg_pointer_new(GTK_TYPE_CTREE_NODE, node); + if (obj == NULL) { + Py_DECREF(ret); + return NULL; + } + PyList_Append(ret, obj); + Py_DECREF(obj); + node = GTK_CTREE_ROW(node)->sibling; + } + return ret; +} +%% +override gtk_ctree_insert_node kwargs +static PyObject * +_wrap_gtk_ctree_insert_node(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "parent", "sibling", "text", "spacing", + "pixmap_closed", "mask_closed", "pixmap_opened", + "mask_opened", "is_leaf", "expanded", NULL }; + PyObject *py_text; + PyGPointer *py_parent, *py_sibling; + PyGObject *py_pixmap_closed = (PyGObject *) Py_None; + PyGObject *py_mask_closed = (PyGObject *) Py_None; + PyGObject *py_pixmap_opened = (PyGObject *) Py_None; + PyGObject *py_mask_opened = (PyGObject *) Py_None; + GtkCTreeNode *parent = NULL, *sibling = NULL, *ret; + gchar **text = NULL; + GdkPixmap *pixmap_closed = NULL, *pixmap_opened = NULL; + GdkBitmap *mask_closed = NULL, *mask_opened = NULL; + gint spacing = 5, is_leaf = 1, expanded = 0, columns, i; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "OOO|iOOOOii:GtkCTree.insert_node", + kwlist, + &py_parent, &py_sibling, &py_text, + &spacing, &py_pixmap_closed, + &py_mask_closed, &py_pixmap_opened, + &py_mask_opened, &is_leaf, &expanded)) + return NULL; + if (pyg_pointer_check(py_parent, GTK_TYPE_CTREE_NODE)) + parent = pyg_pointer_get(py_parent, GtkCTreeNode); + else if ((PyObject *)py_parent != Py_None) { + PyErr_SetString(PyExc_TypeError, "parent must be a CTreeNode or None"); + return NULL; + } + if (pyg_pointer_check(py_sibling, GTK_TYPE_CTREE_NODE)) + sibling = pyg_pointer_get(py_sibling, GtkCTreeNode); + else if ((PyObject *)py_sibling != Py_None) { + PyErr_SetString(PyExc_TypeError,"sibling must be a CTreeNode or None"); + return NULL; + } + if (pygobject_check(py_pixmap_closed, &PyGdkPixmap_Type)) + pixmap_closed = GDK_PIXMAP(py_pixmap_closed->obj); + else if ((PyObject *)py_pixmap_closed != Py_None) { + PyErr_SetString(PyExc_TypeError, + "pixmap_closed must be a GdkPixmap or None"); + return NULL; + } + if (pygobject_check(py_mask_closed, &PyGdkPixmap_Type)) + mask_closed = GDK_PIXMAP(py_mask_closed->obj); + else if ((PyObject *)py_mask_closed != Py_None) { + PyErr_SetString(PyExc_TypeError, + "mask_closed must be a GdkBitmap or None"); + return NULL; + } + if (pygobject_check(py_pixmap_opened, &PyGdkPixmap_Type)) + pixmap_opened = GDK_PIXMAP(py_pixmap_opened->obj); + else if ((PyObject *)py_pixmap_opened != Py_None) { + PyErr_SetString(PyExc_TypeError, + "pixmap_opened must be a GdkPixmap or None"); + return NULL; + } + if (pygobject_check(py_mask_opened, &PyGdkPixmap_Type)) + mask_opened = GDK_PIXMAP(py_mask_opened->obj); + else if ((PyObject *)py_mask_opened != Py_None) { + PyErr_SetString(PyExc_TypeError, + "mask_opened must be a GdkBitmap or None"); + return NULL; + } + if (!PySequence_Check(py_text)) { + PyErr_SetString(PyExc_TypeError, "text must be a sequence"); + return NULL; + } + columns = GTK_CLIST(self->obj)->columns; + if (PySequence_Length(py_text) < columns) { + PyErr_SetString(PyExc_TypeError, "text is too short"); + return NULL; + } + text = g_new(gchar *, columns); + for (i = 0; i < columns; i++) { + PyObject *item = PySequence_GetItem(py_text, i); + + Py_DECREF(item); + if (!PyString_Check(item) && !PyUnicode_Check(item)) { + PyErr_SetString(PyExc_TypeError, + "sequence item not a string or unicode object"); + g_free(text); + return NULL; + } + text[i] = PyString_AsString(item); + } + ret = gtk_ctree_insert_node(GTK_CTREE(self->obj), parent, sibling, text, + spacing, pixmap_closed, mask_closed, + pixmap_opened, mask_opened, is_leaf, expanded); + g_free(text); + return pyg_pointer_new(GTK_TYPE_CTREE_NODE, ret); +} +%% +ignore gtk_ctree_find_by_row_data_custom gtk_ctree_find_all_by_row_data_custom +%% +override gtk_ctree_find_by_row_data kwargs +static PyObject * +_wrap_gtk_ctree_find_by_row_data(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "node", "data", NULL }; + PyObject *data; + PyGPointer *py_node; + GtkCTreeNode *node = NULL, *ret; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "OO:GtkCTree.find_by_row_data", kwlist, + &py_node, &data)) + return NULL; + if (pyg_pointer_check(py_node, GTK_TYPE_CTREE_NODE)) + node = pyg_pointer_get(py_node, GtkCTreeNode); + else if ((PyObject *)py_node != Py_None) { + PyErr_SetString(PyExc_TypeError, "node must be a CTreeNode or None"); + return NULL; + } + ret = gtk_ctree_find_by_row_data(GTK_CTREE(self->obj), node, data); + if (ret) + return pyg_pointer_new(GTK_TYPE_CTREE_NODE, ret); + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_ctree_find_all_by_row_data kwargs +static PyObject * +_wrap_gtk_ctree_find_all_by_row_data(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "node", "data", NULL }; + PyGPointer *py_node; + PyObject *data, *list; + GtkCTreeNode *node = NULL; + GList *ret, *tmp; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "OO:GtkCTree.find_all_by_row_data",kwlist, + &py_node, &data)) + return NULL; + if (pyg_pointer_check(py_node, GTK_TYPE_CTREE_NODE)) + node = pyg_pointer_get(py_node, GtkCTreeNode); + else if ((PyObject *)py_node != Py_None) { + PyErr_SetString(PyExc_TypeError, "node must be a CTreeNode or None"); + return NULL; + } + ret = gtk_ctree_find_all_by_row_data(GTK_CTREE(self->obj), node, data); + if ((list = PyList_New(0)) == NULL) + return NULL; + for (tmp = ret; tmp != NULL; tmp = tmp->next) { + PyObject *item = pyg_pointer_new(GTK_TYPE_CTREE_NODE, + (GtkCTreeNode *) tmp->data); + if (item == NULL) { + Py_DECREF(list); + return NULL; + } + PyList_Append(list, item); + Py_DECREF(item); + } + g_list_free(ret); + return list; +} +%% +override gtk_ctree_node_get_text kwargs +static PyObject * +_wrap_gtk_ctree_node_get_text(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "node", "column", NULL }; + PyGPointer *node; + int column; + char *text = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "Oi:GtkCTree.node_get_text", kwlist, + &node, &column)) + return NULL; + + if (!pyg_pointer_check(node, GTK_TYPE_CTREE_NODE)) { + PyErr_SetString(PyExc_TypeError, "node must be a CTreeNode"); + return NULL; + } + + if (!gtk_ctree_node_get_text(GTK_CTREE(self->obj), + pyg_pointer_get(node, GtkCTreeNode), column, + &text)) { + PyErr_SetString(PyExc_ValueError, "can't get text value"); + return NULL; + } + return PyString_FromString(text); +} +%% +override gtk_ctree_node_get_pixmap kwargs +static PyObject * +_wrap_gtk_ctree_node_get_pixmap(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "node", "column", NULL }; + PyObject *node; + int column; + GdkPixmap *pixmap = NULL; + GdkBitmap *mask = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "Oi:GtkCTree.node_get_pixmap", kwlist, + &node, &column)) + return NULL; + + if (!pyg_pointer_check(node, GTK_TYPE_CTREE_NODE)) { + PyErr_SetString(PyExc_TypeError, "node must be a CTreeNode"); + return NULL; + } + + if (!gtk_ctree_node_get_pixmap(GTK_CTREE(self->obj), + pyg_pointer_get(node, GtkCTreeNode), column, + &pixmap, &mask)) { + PyErr_SetString(PyExc_ValueError, "can't get pixmap value"); + return NULL; + } + return Py_BuildValue("(NN)", pygobject_new((GObject *)pixmap), + pygobject_new((GObject *)mask)); +} +%% +override gtk_ctree_node_get_pixtext kwargs +static PyObject * +_wrap_gtk_ctree_node_get_pixtext(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "node", "column", NULL }; + PyObject *node; + int column; + gchar *text = NULL; + guint8 spacing; + GdkPixmap *pixmap = NULL; + GdkBitmap *mask = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "Oi:GtkCTree.node_get_pixtext", kwlist, + &node, &column)) + return NULL; + + if (!pyg_pointer_check(node, GTK_TYPE_CTREE_NODE)) { + PyErr_SetString(PyExc_TypeError, "node must be a CTreeNode"); + return NULL; + } + + if (!gtk_ctree_node_get_pixtext(GTK_CTREE(self->obj), + pyg_pointer_get(node, GtkCTreeNode), column, + &text, &spacing, &pixmap, &mask)) { + PyErr_SetString(PyExc_ValueError, "can't get pixtext value"); + return NULL; + } + return Py_BuildValue("(siNN)", text, (int)spacing, + pygobject_new((GObject *)pixmap), + pygobject_new((GObject *)mask)); +} +%% +override gtk_ctree_get_node_info kwargs +static PyObject * +_wrap_gtk_ctree_get_node_info(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "node", NULL }; + PyObject *node; + gchar *text; + guint8 spacing; + GdkPixmap *pixmap_closed, *pixmap_opened; + GdkBitmap *mask_closed, *mask_opened; + gboolean is_leaf, expanded; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GtkCTree.get_node_info", + kwlist, &node)) + return NULL; + + if (!pyg_pointer_check(node, GTK_TYPE_CTREE_NODE)) { + PyErr_SetString(PyExc_TypeError, "node must be a CTreeNode"); + return NULL; + } + + if (!gtk_ctree_get_node_info(GTK_CTREE(self->obj), pyg_pointer_get(node, GtkCTreeNode), + &text, &spacing, &pixmap_closed, &mask_closed, + &pixmap_opened, &mask_opened, + &is_leaf, &expanded)) { + PyErr_SetString(PyExc_ValueError, "can't get node info"); + return NULL; + } + return Py_BuildValue("(siNNNNii)", text, (int)spacing, + pygobject_new((GObject *)pixmap_opened), + pygobject_new((GObject *)mask_closed), + pygobject_new((GObject *)pixmap_opened), + pygobject_new((GObject *)mask_opened), + (int)is_leaf, (int)expanded); +} +%% +ignore gtk_ctree_node_set_row_data_full +%% +override gtk_ctree_node_set_row_data kwargs +static PyObject * +_wrap_gtk_ctree_node_set_row_data(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "node", "data", NULL }; + PyObject *node, *data; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "OO:GtkCTree.node_set_row_data", kwlist, + &node, &data)) + return NULL; + + if (!pyg_pointer_check(node, GTK_TYPE_CTREE_NODE)) { + PyErr_SetString(PyExc_TypeError, "node must be a CTreeNode"); + return NULL; + } + + Py_INCREF(data); + gtk_ctree_node_set_row_data_full(GTK_CTREE(self->obj), + pyg_pointer_get(node, GtkCTreeNode), data, + (GDestroyNotify)pyg_destroy_notify); + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_ctree_node_get_row_data kwargs +static PyObject * +_wrap_gtk_ctree_node_get_row_data(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "node", NULL }; + PyObject *node, *data; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O:GtkCTree.node_get_row_data", kwlist, + &node)) + return NULL; + + if (!pyg_pointer_check(node, GTK_TYPE_CTREE_NODE)) { + PyErr_SetString(PyExc_TypeError, "node must be a CTreeNode"); + return NULL; + } + + data = gtk_ctree_node_get_row_data(GTK_CTREE(self->obj), + pyg_pointer_get(node, GtkCTreeNode)); + if (!data) data = Py_None; + Py_INCREF(data); + return data; +} +%% +override-slot GtkCTreeNode.tp_getattr +static PyObject * +_wrap_gtk_ctree_node_tp_getattr(PyGPointer *self, char *attr) +{ + if (!strcmp(attr, "__members__")) + return Py_BuildValue("[ssssss]", "children", "expanded", "is_leaf", + "level", "parent", "sibling"); + if (!strcmp(attr, "parent")) { + GtkCTreeNode *node = GTK_CTREE_ROW(pyg_pointer_get(self, GtkCTreeNode))->parent; + if (node) + return pyg_pointer_new(GTK_TYPE_CTREE_NODE, node); + Py_INCREF(Py_None); + return Py_None; + } else if (!strcmp(attr, "sibling")) { + GtkCTreeNode *node = GTK_CTREE_ROW(pyg_pointer_get(self, GtkCTreeNode))->sibling; + if (node) + return pyg_pointer_new(GTK_TYPE_CTREE_NODE, node); + Py_INCREF(Py_None); + return Py_None; + } else if (!strcmp(attr, "children")) { + GtkCTreeNode *node = GTK_CTREE_ROW(pyg_pointer_get(self, GtkCTreeNode))->children; + PyObject *ret = PyList_New(0); + if (ret == NULL) + return NULL; + while (node) { + PyObject *py_node = pyg_pointer_new(GTK_TYPE_CTREE_NODE, node); + if (py_node == NULL) { + Py_DECREF(ret); + return NULL; + } + PyList_Append(ret, py_node); + Py_DECREF(py_node); + node = GTK_CTREE_ROW(node)->sibling; + } + return ret; + } else if (!strcmp(attr, "level")) + return PyInt_FromLong(GTK_CTREE_ROW(pyg_pointer_get(self, GtkCTreeNode))->level); + else if (!strcmp(attr, "is_leaf")) + return PyInt_FromLong(GTK_CTREE_ROW(pyg_pointer_get(self, GtkCTreeNode))->is_leaf); + else if (!strcmp(attr, "expanded")) + return PyInt_FromLong(GTK_CTREE_ROW(pyg_pointer_get(self, GtkCTreeNode))->expanded); + PyErr_SetString(PyExc_AttributeError, attr); + return NULL; +} diff --git a/gtk/gtkstyle.override b/gtk/gtkstyle.override new file mode 100644 index 00000000..caf934cd --- /dev/null +++ b/gtk/gtkstyle.override @@ -0,0 +1,238 @@ +/* -*- Mode: C; c-basic-offset: 4 -*- */ +%% +override-attr GtkStyle.fg +static PyObject * +_wrap_gtk_style__get_fg(PyGObject *self, void *closure) +{ + GtkStyle *style = GTK_STYLE(self->obj); + + return _pygtk_style_helper_new(style, STYLE_COLOUR_ARRAY, style->fg); +} +%% +override-attr GtkStyle.bg +static PyObject * +_wrap_gtk_style__get_bg(PyGObject *self, void *closure) +{ + GtkStyle *style = GTK_STYLE(self->obj); + + return _pygtk_style_helper_new(style, STYLE_COLOUR_ARRAY, style->bg); +} +%% +override-attr GtkStyle.light +static PyObject * +_wrap_gtk_style__get_light(PyGObject *self, void *closure) +{ + GtkStyle *style = GTK_STYLE(self->obj); + + return _pygtk_style_helper_new(style, STYLE_COLOUR_ARRAY, style->light); +} +%% +override-attr GtkStyle.dark +static PyObject * +_wrap_gtk_style__get_dark(PyGObject *self, void *closure) +{ + GtkStyle *style = GTK_STYLE(self->obj); + + return _pygtk_style_helper_new(style, STYLE_COLOUR_ARRAY, style->dark); +} +%% +override-attr GtkStyle.mid +static PyObject * +_wrap_gtk_style__get_mid(PyGObject *self, void *closure) +{ + GtkStyle *style = GTK_STYLE(self->obj); + + return _pygtk_style_helper_new(style, STYLE_COLOUR_ARRAY, style->mid); +} +%% +override-attr GtkStyle.text +static PyObject * +_wrap_gtk_style__get_text(PyGObject *self, void *closure) +{ + GtkStyle *style = GTK_STYLE(self->obj); + + return _pygtk_style_helper_new(style, STYLE_COLOUR_ARRAY, style->text); +} +%% +override-attr GtkStyle.base +static PyObject * +_wrap_gtk_style__get_base(PyGObject *self, void *closure) +{ + GtkStyle *style = GTK_STYLE(self->obj); + + return _pygtk_style_helper_new(style, STYLE_COLOUR_ARRAY, style->base); +} +%% +override-attr GtkStyle.text_aa +static PyObject * +_wrap_gtk_style__get_text_aa(PyGObject *self, void *closure) +{ + GtkStyle *style = GTK_STYLE(self->obj); + + return _pygtk_style_helper_new(style, STYLE_COLOUR_ARRAY, style->text_aa); +} +%% +override-attr GtkStyle.white +static PyObject * +_wrap_gtk_style__get_white(PyGObject *self, void *closure) +{ + GtkStyle *style = GTK_STYLE(self->obj); + + return pyg_boxed_new(GDK_TYPE_COLOR, &style->white, TRUE, TRUE); +} +static int +_wrap_gtk_style__set_white(PyGObject *self, PyObject *value, void *closure) +{ + GtkStyle *style = GTK_STYLE(self->obj); + + if (!pyg_boxed_check(value, GDK_TYPE_COLOR)) { + PyErr_SetString(PyExc_TypeError, "can only assign a GdkColor"); + return -1; + } + style->white = *pyg_boxed_get(value, GdkColor); + return 0; +} +%% +override-attr GtkStyle.black +static PyObject * +_wrap_gtk_style__get_black(PyGObject *self, void *closure) +{ + GtkStyle *style = GTK_STYLE(self->obj); + + return pyg_boxed_new(GDK_TYPE_COLOR, &style->black, TRUE, TRUE); +} +static int +_wrap_gtk_style__set_black(PyGObject *self, PyObject *value, void *closure) +{ + GtkStyle *style = GTK_STYLE(self->obj); + + if (!pyg_boxed_check(value, GDK_TYPE_COLOR)) { + PyErr_SetString(PyExc_TypeError, "can only assign a GdkColor"); + return -1; + } + style->black = *pyg_boxed_get(value, GdkColor); + return 0; +} +%% +override-attr GtkStyle.fg_gc +static PyObject * +_wrap_gtk_style__get_fg_gc(PyGObject *self, void *closure) +{ + GtkStyle *style = GTK_STYLE(self->obj); + + return _pygtk_style_helper_new(style, STYLE_GC_ARRAY, style->fg_gc); +} +%% +override-attr GtkStyle.bg_gc +static PyObject * +_wrap_gtk_style__get_bg_gc(PyGObject *self, void *closure) +{ + GtkStyle *style = GTK_STYLE(self->obj); + + return _pygtk_style_helper_new(style, STYLE_GC_ARRAY, style->bg_gc); +} +%% +override-attr GtkStyle.light_gc +static PyObject * +_wrap_gtk_style__get_light_gc(PyGObject *self, void *closure) +{ + GtkStyle *style = GTK_STYLE(self->obj); + + return _pygtk_style_helper_new(style, STYLE_GC_ARRAY, style->light_gc); +} +%% +override-attr GtkStyle.dark_gc +static PyObject * +_wrap_gtk_style__get_dark_gc(PyGObject *self, void *closure) +{ + GtkStyle *style = GTK_STYLE(self->obj); + + return _pygtk_style_helper_new(style, STYLE_GC_ARRAY, style->dark_gc); +} +%% +override-attr GtkStyle.mid_gc +static PyObject * +_wrap_gtk_style__get_mid_gc(PyGObject *self, void *closure) +{ + GtkStyle *style = GTK_STYLE(self->obj); + + return _pygtk_style_helper_new(style, STYLE_GC_ARRAY, style->mid_gc); +} +%% +override-attr GtkStyle.text_gc +static PyObject * +_wrap_gtk_style__get_text_gc(PyGObject *self, void *closure) +{ + GtkStyle *style = GTK_STYLE(self->obj); + + return _pygtk_style_helper_new(style, STYLE_GC_ARRAY, style->text_gc); +} +%% +override-attr GtkStyle.base_gc +static PyObject * +_wrap_gtk_style__get_base_gc(PyGObject *self, void *closure) +{ + GtkStyle *style = GTK_STYLE(self->obj); + + return _pygtk_style_helper_new(style, STYLE_GC_ARRAY, style->base_gc); +} +%% +override-attr GtkStyle.text_aa_gc +static PyObject * +_wrap_gtk_style__get_text_aa_gc(PyGObject *self, void *closure) +{ + GtkStyle *style = GTK_STYLE(self->obj); + + return _pygtk_style_helper_new(style, STYLE_GC_ARRAY, style->text_aa_gc); +} +%% +override-attr GtkStyle.white_gc +static PyObject * +_wrap_gtk_style__get_white_gc(PyGObject *self, void *closure) +{ + GtkStyle *style = GTK_STYLE(self->obj); + + return pygobject_new((GObject *)style->white_gc); +} +static int +_wrap_gtk_style__set_white_gc(PyGObject *self, PyObject *value, void *closure) +{ + GtkStyle *style = GTK_STYLE(self->obj); + + if (!pygobject_check(value, &PyGdkGC_Type)) { + PyErr_SetString(PyExc_TypeError, "can only assign a GdkGC"); + return -1; + } + style->white_gc = GDK_GC(pygobject_get(value)); + return 0; +} +%% +override-attr GtkStyle.black_gc +static PyObject * +_wrap_gtk_style__get_black_gc(PyGObject *self, void *closure) +{ + GtkStyle *style = GTK_STYLE(self->obj); + + return pygobject_new((GObject *)style->black_gc); +} +static int +_wrap_gtk_style__set_black_gc(PyGObject *self, PyObject *value, void *closure) +{ + GtkStyle *style = GTK_STYLE(self->obj); + + if (!pygobject_check(value, &PyGdkGC_Type)) { + PyErr_SetString(PyExc_TypeError, "can only assign a GdkGC"); + return -1; + } + style->black_gc = GDK_GC(pygobject_get(value)); + return 0; +} +%% +override-attr GtkStyle.bg_pixmap +static PyObject * +_wrap_gtk_style__get_bg_pixmap(PyGObject *self, void *closure) +{ + GtkStyle *style = GTK_STYLE(self->obj); + + return _pygtk_style_helper_new(style, STYLE_PIXMAP_ARRAY, style->bg_pixmap); +} diff --git a/gtk/gtktextview.override b/gtk/gtktextview.override new file mode 100644 index 00000000..f2d6bff3 --- /dev/null +++ b/gtk/gtktextview.override @@ -0,0 +1,1053 @@ +/* -*- Mode: C; c-basic-offset: 4 -*- */ +%% +ignore-glob + gtk_text_view_new + +%% +override gtk_text_view_get_visible_rect noargs +static PyObject * +_wrap_gtk_text_view_get_visible_rect(PyGObject *self) +{ + GdkRectangle visible_rect; + + gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(self->obj), &visible_rect); + return pyg_boxed_new(GDK_TYPE_RECTANGLE, &visible_rect, TRUE, TRUE); +} +%% +override gtk_text_view_buffer_to_window_coords kwargs +static PyObject * +_wrap_gtk_text_view_buffer_to_window_coords(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "win", "buffer_x", "buffer_y", NULL }; + GtkTextWindowType win; + gint buffer_x, buffer_y, window_x = 0, window_y = 0; + PyObject *py_win; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "Oii:GtkTextView.buffer_to_window_coords", + kwlist, &py_win, &buffer_x, &buffer_y)) + return NULL; + if (pyg_enum_get_value(GTK_TYPE_TEXT_WINDOW_TYPE, py_win, (gint *)&win)) + return NULL; + gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(self->obj), win, + buffer_x, buffer_y, + &window_x, &window_y); + return Py_BuildValue("(ii)", window_x, window_y); +} +%% +override gtk_text_view_window_to_buffer_coords kwargs +static PyObject * +_wrap_gtk_text_view_window_to_buffer_coords(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "win", "window_x", "window_y", NULL }; + GtkTextWindowType win; + gint window_x, window_y, buffer_x = 0, buffer_y = 0; + PyObject *py_win; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "Oii:GtkTextView.window_to_buffer_coords", + kwlist, &py_win, &window_x, &window_y)) + return NULL; + if (pyg_enum_get_value(GTK_TYPE_TEXT_WINDOW_TYPE, py_win, (gint *)&win)) + return NULL; + gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(self->obj), win, + window_x, window_y, + &buffer_x, &buffer_y); + return Py_BuildValue("(ii)", buffer_x, buffer_y); +} +%% +override gtk_text_view_get_iter_location kwargs +static PyObject * +_wrap_gtk_text_view_get_iter_location(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "iter", NULL }; + PyObject *py_iter; + GdkRectangle location; + GtkTextIter *iter = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O:GtkTextView.get_iter_location", + kwlist, &py_iter)) + return NULL; + if (pyg_boxed_check(py_iter, GTK_TYPE_TEXT_ITER)) + iter = pyg_boxed_get(py_iter, GtkTextIter); + else { + PyErr_SetString(PyExc_TypeError, "iter should be a GtkTextIter"); + return NULL; + } + gtk_text_view_get_iter_location(GTK_TEXT_VIEW(self->obj), iter, &location); + return pyg_boxed_new(GDK_TYPE_RECTANGLE, &location, TRUE, TRUE); +} +%% +override gtk_text_view_get_line_at_y kwargs +static PyObject * +_wrap_gtk_text_view_get_line_at_y(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "y", NULL }; + GtkTextIter iter; + gint y, line_top; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "i:GtkTextView.get_line_at_y", + kwlist, &y)) + return NULL; + gtk_text_view_get_line_at_y(GTK_TEXT_VIEW(self->obj), + &iter, y, &line_top); + return Py_BuildValue("(Ni)", + pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE), + line_top); +} +%% +override gtk_text_view_get_line_yrange kwargs +static PyObject * +_wrap_gtk_text_view_get_line_yrange(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "iter", NULL }; + GtkTextIter *iter = NULL; + gint y = -1, height = -1; + PyObject *py_iter; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O:GtkTextView.get_line_yrange", + kwlist, &py_iter)) + return NULL; + if (pyg_boxed_check(py_iter, GTK_TYPE_TEXT_ITER)) + iter = pyg_boxed_get(py_iter, GtkTextIter); + else { + PyErr_SetString(PyExc_TypeError, "iter should be a GtkTextIter"); + return NULL; + } + gtk_text_view_get_line_yrange(GTK_TEXT_VIEW(self->obj), + iter, &y, &height); + return Py_BuildValue("(ii)", y, height); +} +%% +override gtk_text_view_get_iter_at_location kwargs +static PyObject * +_wrap_gtk_text_view_get_iter_at_location(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "x", "y", NULL }; + GtkTextIter iter; + gint x, y; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "ii:GtkTextView.get_iter_at_location", + kwlist, &x, &y)) + return NULL; + gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(self->obj), + &iter, x, y); + return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE); +} +%% +override gtk_text_view_set_border_window_size kwargs +static PyObject * +_wrap_gtk_text_view_set_border_window_size(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "type", "size", NULL }; + PyObject *py_type = NULL; + int size; + GtkTextWindowType type; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "Oi:GtkTextView.set_border_window_size", + kwlist, &py_type, &size)) + return NULL; + + if (size < 0) { + PyErr_SetString(PyExc_ValueError, "size must be >= 0"); + return NULL; + } + + if (pyg_enum_get_value(GTK_TYPE_TEXT_WINDOW_TYPE, py_type, (gint *)&type)) + return NULL; + + switch (type) + { + case GTK_TEXT_WINDOW_LEFT: + case GTK_TEXT_WINDOW_RIGHT: + case GTK_TEXT_WINDOW_TOP: + case GTK_TEXT_WINDOW_BOTTOM: + gtk_text_view_set_border_window_size(GTK_TEXT_VIEW(self->obj), type, + size); + default: + PyErr_SetString(PyExc_ValueError, "type must be one of: " + "gtk.TEXT_WINDOW_LEFT, gtk.TEXT_WINDOW_RIGHT, " + "gtk.TEXT_WINDOW_TOP or gtk.TEXT_WINDOW_BOTTOM"); + return NULL; + } + + Py_INCREF(Py_None); + return Py_None; +} +%% +ignore gtk_text_iter_free +%% +override gtk_text_iter_copy noargs +static PyObject * +_wrap_gtk_text_iter_copy(PyGBoxed *self) +{ + return pyg_boxed_new(GTK_TYPE_TEXT_ITER, pyg_boxed_get(self, GtkTextIter), + TRUE, TRUE); +} +%% +override gtk_text_iter_get_slice kwargs +static PyObject * +_wrap_gtk_text_iter_get_slice(PyGBoxed *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "end", NULL }; + PyGBoxed *end; + gchar *text; + PyObject *pytext; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GtkTextIter.get_slice", + kwlist, &end)) + return NULL; + if (!pyg_boxed_check(end, GTK_TYPE_TEXT_ITER)) { + PyErr_SetString(PyExc_TypeError, "end must be a GtkTextIter"); + return NULL; + } + text = gtk_text_iter_get_slice(pyg_boxed_get(self, GtkTextIter), + pyg_boxed_get(end, GtkTextIter)); + pytext = PyUnicode_DecodeUTF8(text, strlen(text), "strict"); + g_free(text); + return pytext; +} +%% +override gtk_text_iter_get_text kwargs +static PyObject * +_wrap_gtk_text_iter_get_text(PyGBoxed *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "end", NULL }; + PyGBoxed *end; + gchar *text; + PyObject *pytext; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GtkTextIter.get_text", + kwlist, &end)) + return NULL; + if (!pyg_boxed_check(end, GTK_TYPE_TEXT_ITER)) { + PyErr_SetString(PyExc_TypeError, "end must be a GtkTextIter"); + return NULL; + } + text = gtk_text_iter_get_text(pyg_boxed_get(self, GtkTextIter), + pyg_boxed_get(end, GtkTextIter)); + pytext = PyUnicode_DecodeUTF8(text, strlen(text), "strict"); + g_free(text); + return pytext; +} +%% +override gtk_text_iter_get_visible_slice kwargs +static PyObject * +_wrap_gtk_text_iter_get_visible_slice(PyGBoxed *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "end", NULL }; + PyGBoxed *end; + gchar *text; + PyObject *pytext; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O:GtkTextIter.get_visible_slice", kwlist, + &end)) + return NULL; + if (!pyg_boxed_check(end, GTK_TYPE_TEXT_ITER)) { + PyErr_SetString(PyExc_TypeError, "end must be a GtkTextIter"); + return NULL; + } + text = gtk_text_iter_get_visible_slice(pyg_boxed_get(self, GtkTextIter), + pyg_boxed_get(end, GtkTextIter)); + pytext = PyUnicode_DecodeUTF8(text, strlen(text), "strict"); + g_free(text); + return pytext; +} +%% +override gtk_text_iter_get_visible_text kwargs +static PyObject * +_wrap_gtk_text_iter_get_visible_text(PyGBoxed *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "end", NULL }; + PyGBoxed *end; + gchar *text; + PyObject *pytext; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O:GtkTextIter.get_visible_text", kwlist, + &end)) + return NULL; + if (!pyg_boxed_check(end, GTK_TYPE_TEXT_ITER)) { + PyErr_SetString(PyExc_TypeError, "end must be a GtkTextIter"); + return NULL; + } + text = gtk_text_iter_get_visible_text(pyg_boxed_get(self, GtkTextIter), + pyg_boxed_get(end, GtkTextIter)); + pytext = PyUnicode_DecodeUTF8(text, strlen(text), "strict"); + g_free(text); + return pytext; +} +%% +override gtk_text_iter_get_marks noargs +static PyObject * +_wrap_gtk_text_iter_get_marks(PyGBoxed *self) +{ + GSList *ret, *tmp; + PyObject *pyret; + + ret = gtk_text_iter_get_marks(pyg_boxed_get(self, GtkTextIter)); + pyret = PyList_New(0); + for (tmp = ret; tmp != NULL; tmp = tmp->next) { + PyObject *mark = pygobject_new((GObject *)tmp->data); + PyList_Append(pyret, mark); + Py_DECREF(mark); + } + g_slist_free(ret); + return pyret; +} +%% +override gtk_text_iter_get_toggled_tags kwargs +static PyObject * +_wrap_gtk_text_iter_get_toggled_tags(PyGBoxed *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "toggled_on", NULL }; + GSList *ret, *tmp; + int toggled_on; + PyObject *pyret; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "i:GtkTextIter.get_toggled_tags", kwlist, + &toggled_on)) + return NULL; + ret = gtk_text_iter_get_toggled_tags(pyg_boxed_get(self, GtkTextIter), + toggled_on); + pyret = PyList_New(0); + for (tmp = ret; tmp != NULL; tmp = tmp->next) { + PyObject *tag = pygobject_new((GObject *)tmp->data); + PyList_Append(pyret, tag); + Py_DECREF(tag); + } + g_slist_free(ret); + return pyret; +} +%% +override gtk_text_iter_get_tags noargs +static PyObject * +_wrap_gtk_text_iter_get_tags(PyGBoxed *self) +{ + GSList *ret, *tmp; + PyObject *pyret; + + ret = gtk_text_iter_get_tags(pyg_boxed_get(self, GtkTextIter)); + pyret = PyList_New(0); + for (tmp = ret; tmp != NULL; tmp = tmp->next) { + PyObject *tag = pygobject_new((GObject *)tmp->data); + PyList_Append(pyret, tag); + Py_DECREF(tag); + } + g_slist_free(ret); + return pyret; +} +%% +override gtk_text_iter_forward_search kwargs +static PyObject * +_wrap_gtk_text_iter_forward_search(PyGBoxed *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "str", "flags", "limit", NULL }; + gchar *str; + PyObject *py_limit = Py_None; + GtkTextIter match_start, match_end, *limit = NULL; + GtkTextSearchFlags flags; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "si|O:GtkTextIter.forward_search", + kwlist, &str, &flags, &py_limit)) + return NULL; + if (pyg_boxed_check(py_limit, GTK_TYPE_TEXT_ITER)) + limit = pyg_boxed_get(py_limit, GtkTextIter); + else if (py_limit != Py_None) { + PyErr_SetString(PyExc_TypeError,"limit must be a GtkTextIter or None"); + return NULL; + } + if (gtk_text_iter_forward_search(pyg_boxed_get(self, GtkTextIter), str, + flags, &match_start, &match_end, limit)) + return Py_BuildValue("(NN)", + pyg_boxed_new(GTK_TYPE_TEXT_ITER, &match_start, + TRUE, TRUE), + pyg_boxed_new(GTK_TYPE_TEXT_ITER, &match_end, + TRUE, TRUE)); + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_text_iter_backward_search kwargs +static PyObject * +_wrap_gtk_text_iter_backward_search(PyGBoxed *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "str", "flags", "limit", NULL }; + gchar *str; + PyObject *py_limit = Py_None; + GtkTextIter match_start, match_end, *limit = NULL; + GtkTextSearchFlags flags; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "si|O:GtkTextIter.backward_search", + kwlist, &str, &flags, &py_limit)) + return NULL; + if (pyg_boxed_check(py_limit, GTK_TYPE_TEXT_ITER)) + limit = pyg_boxed_get(py_limit, GtkTextIter); + else if (py_limit != Py_None) { + PyErr_SetString(PyExc_TypeError,"limit must be a GtkTextIter or None"); + return NULL; + } + if (gtk_text_iter_backward_search(pyg_boxed_get(self, GtkTextIter), str, + flags, &match_start, &match_end, limit)) + return Py_BuildValue("(NN)", + pyg_boxed_new(GTK_TYPE_TEXT_ITER, &match_start, + TRUE, TRUE), + pyg_boxed_new(GTK_TYPE_TEXT_ITER, &match_end, + TRUE, TRUE)); + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_text_buffer_insert_with_tags +static PyObject * +_wrap_gtk_text_buffer_insert_with_tags(PyGObject *self, PyObject *args) +{ + PyObject *first, *py_iter; + gint len, i, text_len, start_offset; + gchar *text; + GtkTextIter *iter, start; + + len = PyTuple_Size(args); + if (len < 2) { + PyErr_SetString(PyExc_TypeError, + "GtkTextBuffer.insert_with_tags requires at least 2 arguments"); + return NULL; + } + first = PySequence_GetSlice(args, 0, 2); + if (!PyArg_ParseTuple(first, "Os#:GtkTextBuffer.insert_with_tags", + &py_iter, &text, &text_len)) { + Py_DECREF(first); + return NULL; + } + Py_DECREF(first); + if (!pyg_boxed_check(py_iter, GTK_TYPE_TEXT_ITER)) { + PyErr_SetString(PyExc_TypeError, "iter must be a GtkTextIter"); + return NULL; + } + iter = pyg_boxed_get(py_iter, GtkTextIter); + + /* check types */ + for (i = 2; i < len; i++) { + PyObject *item = PyTuple_GetItem(args, i); + + if (!pygobject_check(item, &PyGtkTextTag_Type)) { + PyErr_SetString(PyExc_TypeError, + "additional argument must be a GtkTextTag"); + return NULL; + } + } + + start_offset = gtk_text_iter_get_offset(iter); + gtk_text_buffer_insert(GTK_TEXT_BUFFER(self->obj), iter, text, text_len); + gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(self->obj), + &start, start_offset); + + for (i = 2; i < len; i++) { + PyObject *item = PyTuple_GetItem(args, i); + GtkTextTag *tag = GTK_TEXT_TAG(pygobject_get(item)); + + gtk_text_buffer_apply_tag(GTK_TEXT_BUFFER(self->obj), tag,&start,iter); + } + + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_text_buffer_insert_with_tags_by_name +static PyObject * +_wrap_gtk_text_buffer_insert_with_tags_by_name(PyGObject *self, PyObject *args) +{ + PyObject *first, *py_iter; + gint len, i, text_len, start_offset; + gchar *text; + GtkTextIter *iter, start; + + len = PyTuple_Size(args); + if (len < 2) { + PyErr_SetString(PyExc_TypeError, + "GtkTextBuffer.insert_with_tags_by_name " + "requires at least 2 arguments"); + return NULL; + } + first = PySequence_GetSlice(args, 0, 2); + if (!PyArg_ParseTuple(first, "Os#:GtkTextBuffer.insert_with_tags_by_name", + &py_iter, &text, &text_len)) { + Py_DECREF(first); + return NULL; + } + Py_DECREF(first); + if (!pyg_boxed_check(py_iter, GTK_TYPE_TEXT_ITER)) { + PyErr_SetString(PyExc_TypeError, "iter must be a GtkTextIter"); + return NULL; + } + iter = pyg_boxed_get(py_iter, GtkTextIter); + + /* check types */ + for (i = 2; i < len; i++) { + PyObject *item = PyTuple_GetItem(args, i); + + if (!PyString_Check(item)) { + PyErr_SetString(PyExc_TypeError, + "additional argument must be a string"); + return NULL; + } + } + + start_offset = gtk_text_iter_get_offset(iter); + gtk_text_buffer_insert(GTK_TEXT_BUFFER(self->obj), iter, text, text_len); + gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(self->obj), + &start, start_offset); + + for (i = 2; i < len; i++) { + PyObject *item = PyTuple_GetItem(args, i); + const gchar *tagname = PyString_AsString(item); + + gtk_text_buffer_apply_tag_by_name(GTK_TEXT_BUFFER(self->obj), + tagname, &start, iter); + } + + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_text_buffer_create_tag kwargs +static PyObject * +_wrap_gtk_text_buffer_create_tag(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + gchar *tag_name = NULL; + GtkTextTag *tag; + GtkTextTagTable *table; + + if (!PyArg_ParseTuple(args, "|z:GtkTextBuffer.create_tag", + &tag_name)) { + return NULL; + } + + table = GTK_TEXT_TAG_TABLE(GTK_TEXT_BUFFER(self->obj)->tag_table); + if (tag_name && table && g_hash_table_lookup(table->hash, tag_name)) { + gchar buf[512]; + g_snprintf(buf, sizeof(buf), + "A tag named '%s' is already in the tag table", + tag_name); + + PyErr_SetString(PyExc_TypeError, buf); + return NULL; + } + + tag = gtk_text_buffer_create_tag(GTK_TEXT_BUFFER(self->obj), + tag_name, NULL); + + /* set tag properties if any */ + if (kwargs) { + gint i = 0; + PyObject *prop, *val; + + while (PyDict_Next(kwargs, &i, &prop, &val)) { + GParamSpec *pspec; + GValue value = { 0, }; + gchar *prop_str = PyString_AsString(prop); + + pspec = g_object_class_find_property (G_OBJECT_GET_CLASS(tag), + prop_str); + if (!pspec) { + PyErr_Format(PyExc_TypeError, + "unsupported tag property `%s'", + prop_str); + /* XXX: Free tag? */ + return NULL; + } + + g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec)); + if (pyg_value_from_pyobject(&value, val) < 0) { + PyErr_Format(PyExc_TypeError, + "could not convert tag property '%s' to correct type", + prop_str); + /* XXX: Free tag? */ + return NULL; + } + g_object_set_property((GObject *)tag, prop_str, &value); + g_value_unset(&value); + } + } + return pygobject_new((GObject *)tag); +} +%% +override gtk_text_buffer_get_iter_at_line_offset kwargs +static PyObject * +_wrap_gtk_text_buffer_get_iter_at_line_offset(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "line_number", "char_offset", NULL }; + GtkTextIter iter; + int line_number, char_offset; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:GtkTextBuffer.get_iter_at_line_offset", kwlist, &line_number, &char_offset)) + return NULL; + + gtk_text_buffer_get_iter_at_line_offset(GTK_TEXT_BUFFER(self->obj), &iter, + line_number, char_offset); + return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE); +} +%% +override gtk_text_buffer_get_iter_at_line_index kwargs +static PyObject * +_wrap_gtk_text_buffer_get_iter_at_line_index(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "line_number", "byte_offset", NULL }; + GtkTextIter iter; + int line_number, byte_offset; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:GtkTextBuffer.get_iter_at_line_index", kwlist, &line_number, &byte_offset)) + return NULL; + + gtk_text_buffer_get_iter_at_line_index(GTK_TEXT_BUFFER(self->obj), &iter, + line_number, byte_offset); + return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE); +} +%% +override gtk_text_buffer_get_iter_at_offset kwargs +static PyObject * +_wrap_gtk_text_buffer_get_iter_at_offset(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + int char_offset; + static char *kwlist[] = { "char_offset", NULL }; + GtkTextIter iter; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:GtkTextBuffer.get_iter_at_offset", kwlist, &char_offset)) + return NULL; + + gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(self->obj), + &iter, char_offset); + return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE); +} +%% +override gtk_text_buffer_get_iter_at_line kwargs +static PyObject * +_wrap_gtk_text_buffer_get_iter_at_line(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + int line_number; + static char *kwlist[] = { "line_number", NULL }; + GtkTextIter iter; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:GtkTextBuffer.get_iter_at_line", kwlist, &line_number)) + return NULL; + + gtk_text_buffer_get_iter_at_line(GTK_TEXT_BUFFER(self->obj), + &iter, line_number); + return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE); +} +%% +override gtk_text_buffer_get_start_iter noargs +static PyObject * +_wrap_gtk_text_buffer_get_start_iter(PyGObject *self) +{ + GtkTextIter iter; + + gtk_text_buffer_get_start_iter(GTK_TEXT_BUFFER(self->obj), &iter); + return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE); +} +%% +override gtk_text_buffer_get_end_iter noargs +static PyObject * +_wrap_gtk_text_buffer_get_end_iter(PyGObject *self) +{ + GtkTextIter iter; + + gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(self->obj), &iter); + return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE); +} +%% +override gtk_text_buffer_get_bounds noargs +static PyObject * +_wrap_gtk_text_buffer_get_bounds(PyGObject *self) +{ + GtkTextIter start, end; + + gtk_text_buffer_get_bounds(GTK_TEXT_BUFFER(self->obj), &start, &end); + return Py_BuildValue("(NN)", + pyg_boxed_new(GTK_TYPE_TEXT_ITER, &start, TRUE, TRUE), + pyg_boxed_new(GTK_TYPE_TEXT_ITER, &end, TRUE, TRUE)); +} +%% +override gtk_text_buffer_get_iter_at_mark kwargs +static PyObject * +_wrap_gtk_text_buffer_get_iter_at_mark(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + PyGObject *mark; + static char *kwlist[] = { "mark", NULL }; + GtkTextIter iter; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GtkTextBuffer.get_iter_at_mark", kwlist, &mark)) + return NULL; + if (!pygobject_check(mark, &PyGtkTextMark_Type)) { + PyErr_SetString(PyExc_TypeError, "mark should be a GtkTextMark"); + return NULL; + } + + gtk_text_buffer_get_iter_at_mark(GTK_TEXT_BUFFER(self->obj), &iter, + GTK_TEXT_MARK(mark->obj)); + return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE); +} +%% +override gtk_text_buffer_set_text kwargs +static PyObject * +_wrap_gtk_text_buffer_set_text(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + char *text; + static char *kwlist[] = { "text", "len", NULL }; + int len, oldlen = -1; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "s#|i:GtkTextBuffer.set_text", kwlist, + &text, &len, &oldlen)) { + return NULL; + } + + if (oldlen > 0) { + len = oldlen; + } + + gtk_text_buffer_set_text(GTK_TEXT_BUFFER(self->obj), text, len); + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_text_buffer_get_selection_bounds noargs +static PyObject * +_wrap_gtk_text_buffer_get_selection_bounds(PyGObject *self, PyObject *args) +{ + GtkTextIter start, end; + + if (!gtk_text_buffer_get_selection_bounds(GTK_TEXT_BUFFER(self->obj), + &start, &end)) { + return Py_BuildValue ("()"); + } + + return Py_BuildValue("(NN)", + pyg_boxed_new(GTK_TYPE_TEXT_ITER, &start, TRUE, TRUE), + pyg_boxed_new(GTK_TYPE_TEXT_ITER, &end, TRUE, TRUE)); +} +%% +override gtk_text_buffer_insert kwargs +static PyObject * +_wrap_gtk_text_buffer_insert(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "iter", "text", "len", NULL }; + PyObject *py_iter; + char *text; + int len, oldlen = -1; + GtkTextIter *iter = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Os#|i:GtkTextBuffer.insert", + kwlist, &py_iter, &text, &len, &oldlen)) { + return NULL; + } + + if (oldlen > 0) { + len = oldlen; + } + + if (pyg_boxed_check(py_iter, GTK_TYPE_TEXT_ITER)) { + iter = pyg_boxed_get(py_iter, GtkTextIter); + } else { + PyErr_SetString(PyExc_TypeError, "iter should be a GtkTextIter"); + return NULL; + } + gtk_text_buffer_insert(GTK_TEXT_BUFFER(self->obj), iter, text, len); + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_text_buffer_insert_at_cursor kwargs +static PyObject * +_wrap_gtk_text_buffer_insert_at_cursor(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "text", "len", NULL }; + char *text; + int len, oldlen = -1; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "s#|i:GtkTextBuffer.insert_at_cursor", + kwlist, &text, &len, &oldlen)) { + return NULL; + } + + if (oldlen > 0) { + len = oldlen; + } + + gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(self->obj), text, len); + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_text_buffer_insert_interactive kwargs +static PyObject * +_wrap_gtk_text_buffer_insert_interactive(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "iter", "text", "default_editable", "len", NULL }; + PyObject *py_iter, *py_ret; + char *text; + int len, default_editable, ret, oldlen = -1; + GtkTextIter *iter = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "Os#i|i:GtkTextBuffer.insert_interactive", + kwlist, &py_iter, &text, &len, + &default_editable, &oldlen)) { + return NULL; + } + + if (oldlen > 0) { + len = oldlen; + } + + if (pyg_boxed_check(py_iter, GTK_TYPE_TEXT_ITER)) { + iter = pyg_boxed_get(py_iter, GtkTextIter); + } else { + PyErr_SetString(PyExc_TypeError, "iter should be a GtkTextIter"); + return NULL; + } + ret = gtk_text_buffer_insert_interactive(GTK_TEXT_BUFFER(self->obj), iter, + text, len, default_editable); + py_ret = ret ? Py_True : Py_False; + Py_INCREF(py_ret); + return py_ret; +} +%% +override gtk_text_buffer_insert_interactive_at_cursor kwargs +static PyObject * +_wrap_gtk_text_buffer_insert_interactive_at_cursor(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "text", "default_editable", "len", NULL }; + char *text; + int len, default_editable, ret, oldlen = -1; + PyObject *py_ret; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "s#i|i:GtkTextBuffer.insert_interactive_at_cursor", + kwlist, &text, &len, &default_editable, &oldlen)) { + return NULL; + } + + if (oldlen > 0) { + len = oldlen; + } + + ret = gtk_text_buffer_insert_interactive_at_cursor(GTK_TEXT_BUFFER(self->obj), + text, len, default_editable); + py_ret = ret ? Py_True : Py_False; + Py_INCREF(py_ret); + return py_ret; +} +%% +override gtk_text_buffer_get_iter_at_child_anchor kwargs +static PyObject * +_wrap_gtk_text_buffer_get_iter_at_child_anchor(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "anchor", NULL }; + PyGObject *anchor; + GtkTextIter iter; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:GtkTextBuffer.get_iter_at_child_anchor", kwlist, &PyGtkTextChildAnchor_Type, &anchor)) + return NULL; + + gtk_text_buffer_get_iter_at_child_anchor(GTK_TEXT_BUFFER(self->obj), + &iter, + GTK_TEXT_CHILD_ANCHOR(anchor->obj)); + return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE); +} +%% +override gtk_text_tag_table_add kwargs +static PyObject * +_wrap_gtk_text_tag_table_add(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "tag", NULL }; + GtkTextTag *tag; + GtkTextTagTable *table; + PyGObject *pytag; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:GtkTextTagTable.add", + kwlist, &PyGtkTextTag_Type, &pytag)) { + return NULL; + } + + tag = GTK_TEXT_TAG(pytag->obj); + table = GTK_TEXT_TAG_TABLE(self->obj); + + if (tag->table) { + gchar buf[512]; + g_snprintf(buf, sizeof(buf), + "The tag is already in a tag table"); + + PyErr_SetString(PyExc_ValueError, buf); + return NULL; + } + + if (tag->name && table && g_hash_table_lookup(table->hash, tag->name)) { + gchar buf[512]; + g_snprintf(buf, sizeof(buf), + "A tag named '%s' is already in the tag table", + tag->name); + + PyErr_SetString(PyExc_ValueError, buf); + return NULL; + } + + gtk_text_tag_table_add(table, tag); + + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_text_tag_table_remove kwargs +static PyObject * +_wrap_gtk_text_tag_table_remove(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "tag", NULL }; + GtkTextTag *tag; + GtkTextTagTable *table; + PyGObject *pytag; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O!:GtkTextTagTable.remove", + kwlist, &PyGtkTextTag_Type, &pytag)) { + return NULL; + } + + tag = GTK_TEXT_TAG(pytag->obj); + table = GTK_TEXT_TAG_TABLE(self->obj); + + if (tag->table != table) { + gchar buf[512]; + if (tag->name) + g_snprintf(buf, sizeof(buf), + "The tag named '%s' is not in the tag table", + tag->name); + else + g_snprintf(buf, sizeof(buf), + "The tag is not in the tag table"); + + PyErr_SetString(PyExc_ValueError, buf); + return NULL; + } + + gtk_text_tag_table_remove(table, tag); + + Py_INCREF(Py_None); + return Py_None; +} +%% +override-attr GtkTextAttributes.bg_color +static PyObject * +_wrap_gtk_text_attributes__get_bg_color(PyObject *self, void *closure) +{ + GdkColor ret; + + ret = pyg_boxed_get(self, GtkTextAttributes)->appearance.bg_color; + /* pyg_boxed_new handles NULL checking */ + return pyg_boxed_new(GDK_TYPE_COLOR, &ret, TRUE, TRUE); +} +%% +override-attr GtkTextAttributes.fg_color +static PyObject * +_wrap_gtk_text_attributes__get_fg_color(PyObject *self, void *closure) +{ + GdkColor ret; + + ret = pyg_boxed_get(self, GtkTextAttributes)->appearance.fg_color; + /* pyg_boxed_new handles NULL checking */ + return pyg_boxed_new(GDK_TYPE_COLOR, &ret, TRUE, TRUE); +} +%% +override-attr GtkTextAttributes.bg_stipple +static PyObject * +_wrap_gtk_text_attributes__get_bg_stipple(PyObject *self, void *closure) +{ + GdkBitmap *ret; + + ret = pyg_boxed_get(self, GtkTextAttributes)->appearance.bg_stipple; + /* pygobject_new handles NULL checking */ + return pygobject_new((GObject *)ret); +} +%% +override-attr GtkTextAttributes.fg_stipple +static PyObject * +_wrap_gtk_text_attributes__get_fg_stipple(PyObject *self, void *closure) +{ + GdkBitmap *ret; + + ret = pyg_boxed_get(self, GtkTextAttributes)->appearance.fg_stipple; + /* pygobject_new handles NULL checking */ + return pygobject_new((GObject *)ret); +} +%% +override-attr GtkTextAttributes.rise +static PyObject * +_wrap_gtk_text_attributes__get_rise(PyObject *self, void *closure) +{ + int ret; + + ret = pyg_boxed_get(self, GtkTextAttributes)->appearance.rise; + return PyInt_FromLong(ret); +} +%% +override-attr GtkTextAttributes.underline +static PyObject * +_wrap_gtk_text_attributes__get_underline(PyObject *self, void *closure) +{ + int ret; + + ret = pyg_boxed_get(self, GtkTextAttributes)->appearance.underline; + return PyInt_FromLong(ret); +} +%% +override-attr GtkTextAttributes.strikethrough +static PyObject * +_wrap_gtk_text_attributes__get_strikethrough(PyObject *self, void *closure) +{ + PyObject *ret; + + ret = pyg_boxed_get(self, GtkTextAttributes)->appearance.strikethrough + ? Py_True : Py_False; + Py_INCREF(ret); + return ret; +} +%% +override-attr GtkTextAttributes.draw_bg +static PyObject * +_wrap_gtk_text_attributes__get_draw_bg(PyObject *self, void *closure) +{ + PyObject *ret; + + ret = pyg_boxed_get(self, GtkTextAttributes)->appearance.draw_bg + ? Py_True : Py_False; + Py_INCREF(ret); + return ret; +} diff --git a/gtk/gtktreeview.override b/gtk/gtktreeview.override new file mode 100644 index 00000000..169cbafd --- /dev/null +++ b/gtk/gtktreeview.override @@ -0,0 +1,1791 @@ +/* -*- Mode: C; c-basic-offset: 4 -*- */ +%% +headers +#include "pygtktreemodel.h" +#include "pygtkcellrenderer.h" +%% +init + PyGtkListStore_Type.tp_as_number = PyGtkTreeModel_Type.tp_as_number; + PyGtkListStore_Type.tp_as_mapping = PyGtkTreeModel_Type.tp_as_mapping; + PyGtkListStore_Type.tp_iter = PyGtkTreeModel_Type.tp_iter; + PyGtkTreeStore_Type.tp_as_number = PyGtkTreeModel_Type.tp_as_number; + PyGtkTreeStore_Type.tp_as_mapping = PyGtkTreeModel_Type.tp_as_mapping; + PyGtkTreeStore_Type.tp_iter = PyGtkTreeModel_Type.tp_iter; + PyPyGtkGenericTreeModel_Type.tp_as_number = PyGtkTreeModel_Type.tp_as_number; + PyPyGtkGenericTreeModel_Type.tp_as_mapping = PyGtkTreeModel_Type.tp_as_mapping; + PyPyGtkGenericTreeModel_Type.tp_iter = PyGtkTreeModel_Type.tp_iter; +%% +ignore-glob + gtk_tree_path_* +%% +ignore + gtk_tree_view_new +%% +override gtk_tree_view_get_visible_rect noargs +static PyObject * +_wrap_gtk_tree_view_get_visible_rect(PyGObject *self) +{ + GdkRectangle visible_rect; + + gtk_tree_view_get_visible_rect(GTK_TREE_VIEW(self->obj), &visible_rect); + return pyg_boxed_new(GDK_TYPE_RECTANGLE, &visible_rect, TRUE, TRUE); +} +%% +override gtk_tree_view_column_new kwargs +static int +_wrap_gtk_tree_view_column_new(PyGObject *self, PyObject*args, PyObject*kwargs) +{ + PyObject *py_cell = NULL, *key, *item; + GtkTreeViewColumn *tvc; + gchar *title = NULL; + GtkCellRenderer *cell = NULL; + gint i = 0; + + if (!PyArg_ParseTuple(args, "|zO:GtkTreeViewColumn.__init__", &title, + &py_cell)) + return -1; + if (py_cell != NULL) { + if (pygobject_check(py_cell, &PyGtkCellRenderer_Type)) + cell = GTK_CELL_RENDERER(pygobject_get(py_cell)); + else if (py_cell != Py_None) { + PyErr_SetString(PyExc_TypeError, + "cell must be a GtkCellRenderer or None"); + return -1; + } + } + tvc = gtk_tree_view_column_new(); + if (title) + gtk_tree_view_column_set_title(tvc, title); + if (cell) + gtk_tree_view_column_pack_start(tvc, cell, TRUE); + if (kwargs) { + while (PyDict_Next(kwargs, &i, &key, &item)) { + gchar *attr = PyString_AsString(key); + + if (!PyInt_Check(item)) { + gchar err[128]; + g_snprintf(err, sizeof(err), + "%s must be an integer column number", attr); + PyErr_SetString(PyExc_TypeError, err); + g_object_unref(G_OBJECT(tvc)); + return -1; + } + gtk_tree_view_column_add_attribute(tvc, cell, attr, + PyInt_AsLong(item)); + } + } + self->obj = (GObject *)tvc; + pygobject_register_wrapper((PyObject *)self); + return 0; +} +%% +override gtk_tree_view_column_cell_get_size noargs +static PyObject * +_wrap_gtk_tree_view_column_cell_get_size(PyGObject *self) +{ + GdkRectangle cell_area; + gint x_offset, y_offset, width, height; + + gtk_tree_view_column_cell_get_size(GTK_TREE_VIEW_COLUMN(self->obj), + &cell_area, + &x_offset, &y_offset, &width, &height); + + return Py_BuildValue("(Niiii)", + pyg_boxed_new(GDK_TYPE_RECTANGLE, + &cell_area, TRUE, TRUE), + x_offset, y_offset, width, height); +} +%% +override gtk_tree_view_column_get_cell_renderers noargs +static PyObject * +_wrap_gtk_tree_view_column_get_cell_renderers(PyGObject *self) +{ + GList *list, *tmp; + PyObject *ret; + + list = gtk_tree_view_column_get_cell_renderers( + GTK_TREE_VIEW_COLUMN(self->obj)); + + ret = PyList_New(0); + for (tmp = list; tmp != NULL; tmp = tmp->next) { + GtkWidget *renderer = tmp->data; + PyObject *item = pygobject_new((GObject *)renderer); + + PyList_Append(ret, item); + Py_DECREF(item); + } + g_list_free(list); + return ret; +} +%% +override gtk_tree_view_column_set_cell_data_func kwargs +static void +pygtk_cell_data_func_marshal (GtkTreeViewColumn *tree_column, + GtkCellRenderer *cell, + GtkTreeModel *tree_model, + GtkTreeIter *iter, gpointer data) +{ + PyGtkCustomNotify *cunote = data; + PyObject *retobj; + PyObject *pytreecolumn, *pycell, *pytreemodel, *pyiter; + + g_assert (cunote->func); + + pyg_block_threads(); + + pytreecolumn = pygobject_new((GObject *)tree_column); + pycell = pygobject_new((GObject *)cell); + pytreemodel = pygobject_new((GObject *)tree_model); + pyiter = pyg_boxed_new(GTK_TYPE_TREE_ITER, iter, + TRUE, TRUE); + if (cunote->data) + retobj = PyEval_CallFunction(cunote->func, "(OOOOO)", + pytreecolumn, pycell, + pytreemodel, pyiter, cunote->data); + else + retobj = PyEval_CallFunction(cunote->func, "(OOOO)", + pytreecolumn, pycell, + pytreemodel, pyiter, cunote->data); + + if (retobj == NULL) { + PyErr_Print(); + } else + Py_DECREF(retobj); + + pyg_unblock_threads(); +} + +static PyObject * +_wrap_gtk_tree_view_column_set_cell_data_func (PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + PyObject *pycell,*pyfunc, *pyarg = NULL; + GtkCellRenderer *cell; + PyGtkCustomNotify *cunote; + + if (!PyArg_ParseTuple(args, "OO|O:GtkTreeViewColumn.set_cell_data_func", + &pycell, &pyfunc, &pyarg)) + return NULL; + + if (pygobject_check(pycell, &PyGtkCellRenderer_Type)) + cell = GTK_CELL_RENDERER(pygobject_get(pycell)); + else { + PyErr_SetString(PyExc_TypeError, + "first argument must be a GtkCellRenderer"); + return NULL; + } + + cunote = g_new0(PyGtkCustomNotify, 1); + cunote->func = pyfunc; + cunote->data = pyarg; + Py_INCREF(cunote->func); + Py_XINCREF(cunote->data); + + gtk_tree_view_column_set_cell_data_func (GTK_TREE_VIEW_COLUMN (self->obj), cell, + pygtk_cell_data_func_marshal, + cunote, + pygtk_custom_destroy_notify); + + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_tree_view_insert_column_with_data_func kwargs +static PyObject * +_wrap_gtk_tree_view_insert_column_with_data_func (PyGObject *self, + PyObject *args, + PyObject *kwargs) +{ + int position; + gchar *title; + PyObject *pycell,*pyfunc, *pyarg = NULL; + GtkCellRenderer *cell; + PyGtkCustomNotify *cunote; + gint retval; + + if (!PyArg_ParseTuple(args, + "isOO|O:GtkTreeView.insert_column_with_data_func", + &position, &title, &pycell, &pyfunc, &pyarg)) + return NULL; + + if (pygobject_check(pycell, &PyGtkCellRenderer_Type)) + cell = GTK_CELL_RENDERER(pygobject_get(pycell)); + else { + PyErr_SetString(PyExc_TypeError, + "first argument must be a GtkCellRenderer"); + return NULL; + } + + cunote = g_new0(PyGtkCustomNotify, 1); + cunote->func = pyfunc; + cunote->data = pyarg; + Py_INCREF(cunote->func); + Py_XINCREF(cunote->data); + + retval = gtk_tree_view_insert_column_with_data_func ( + GTK_TREE_VIEW (self->obj), + position, + title, + cell, + pygtk_cell_data_func_marshal, + cunote, + pygtk_custom_destroy_notify); + return PyInt_FromLong(retval); +} +%% +override gtk_tree_view_column_set_attributes kwargs +static PyObject * +_wrap_gtk_tree_view_column_set_attributes(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + PyObject *py_cell, *key, *item; + GtkCellRenderer *cell; + gint i = 0; + + if (!PyArg_ParseTuple(args, "O!:GtkTreeViewColumn.set_attributes", + &PyGtkCellRenderer_Type, &py_cell)) + return NULL; + cell = GTK_CELL_RENDERER(pygobject_get(py_cell)); + gtk_tree_view_column_clear_attributes(GTK_TREE_VIEW_COLUMN(self->obj), + cell); + if (kwargs) { + while (PyDict_Next(kwargs, &i, &key, &item)) { + gchar *attr = PyString_AsString(key); + + if (!PyInt_Check(item)) { + gchar err[128]; + g_snprintf(err, sizeof(err), + "%s must be an integer column number", attr); + PyErr_SetString(PyExc_TypeError, err); + return NULL; + } + gtk_tree_view_column_add_attribute(GTK_TREE_VIEW_COLUMN(self->obj), + cell, attr, + PyInt_AsLong(item)); + } + } + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_tree_view_get_path_at_pos kwargs +static PyObject * +_wrap_gtk_tree_view_get_path_at_pos(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "x", "y", NULL }; + gint x, y; + GtkTreePath *path; + GtkTreeViewColumn *column; + gint cell_x, cell_y; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "ii:GtkTreeView.get_path_at_pos", + kwlist, &x, &y)) + return NULL; + if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(self->obj), x, y, + &path, &column, &cell_x, &cell_y)) { + PyObject *ret = PyTuple_New(4); + + if (path) { + PyTuple_SetItem(ret, 0, pygtk_tree_path_to_pyobject(path)); + gtk_tree_path_free(path); + } else { + Py_INCREF(Py_None); + PyTuple_SetItem(ret, 0, Py_None); + } + PyTuple_SetItem(ret, 1, pygobject_new((GObject *)column)); + PyTuple_SetItem(ret, 2, PyInt_FromLong(cell_x)); + PyTuple_SetItem(ret, 3, PyInt_FromLong(cell_y)); + return ret; + } else { + Py_INCREF(Py_None); + return Py_None; + } +} +%% +override gtk_tree_view_insert_column_with_attributes kwargs +static PyObject * +_wrap_gtk_tree_view_insert_column_with_attributes(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + gint position, columns, real_position; + GtkTreeViewColumn *column; + GtkCellRenderer *cell; + PyObject *py_cell, *key, *item; + const char *title; + gint i = 0; + + if (!PyArg_ParseTuple(args, + "isO!:GtkTreeView.insert_column_with_attributes", + &position, &title, &PyGtkCellRenderer_Type, &py_cell)) + return NULL; + + cell = GTK_CELL_RENDERER(pygobject_get(py_cell)); + + columns = + gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW(self->obj), + position, title, cell, + NULL); + if (position == -1) { + real_position = columns - 1; + } else { + real_position = position; + } + + column = gtk_tree_view_get_column (GTK_TREE_VIEW(self->obj), + real_position); + + if (kwargs) { + while (PyDict_Next(kwargs, &i, &key, &item)) { + gchar *attr = PyString_AsString(key); + + if (!PyInt_Check(item)) { + gchar err[128]; + g_snprintf(err, sizeof(err), + "%s must be an integer column number", attr); + PyErr_SetString(PyExc_TypeError, err); + return NULL; + } + gtk_tree_view_column_add_attribute(column, cell, attr, + PyInt_AsLong(item)); + } + } + return pygobject_new ((GObject *) column); +} +%% +override gtk_tree_view_get_visible_rect noargs +static PyObject * +_wrap_gtk_tree_view_get_visible_rect(PyGObject *self) +{ + GdkRectangle visible_rect; + + gtk_tree_view_get_visible_rect(GTK_TREE_VIEW(self->obj), &visible_rect); + + return pyg_boxed_new(GDK_TYPE_RECTANGLE, &visible_rect, TRUE, TRUE); +} +%% +override gtk_tree_view_get_cell_area kwargs +static PyObject * +_wrap_gtk_tree_view_get_cell_area(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "path", "column", NULL }; + PyObject *py_path; + PyGObject *column; + GdkRectangle rect; + GtkTreePath *path; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO!:GtkTreeView.get_cell_area", kwlist, &py_path, &PyGtkTreeViewColumn_Type, &column)) + return NULL; + path = pygtk_tree_path_from_pyobject(py_path); + if (!path) { + PyErr_SetString(PyExc_TypeError, "could not convert path to a GtkTreePath"); + return NULL; + } + gtk_tree_view_get_cell_area(GTK_TREE_VIEW(self->obj), path, GTK_TREE_VIEW_COLUMN(column->obj), &rect); + if (path) + gtk_tree_path_free(path); + return pyg_boxed_new(GDK_TYPE_RECTANGLE, &rect, TRUE, TRUE); +} +%% +override gtk_tree_view_get_background_area kwargs +static PyObject * +_wrap_gtk_tree_view_get_background_area(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "path", "column", NULL }; + PyObject *py_path; + PyGObject *column; + GdkRectangle rect; + GtkTreePath *path; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO!:GtkTreeView.get_background_area", kwlist, &py_path, &PyGtkTreeViewColumn_Type, &column)) + return NULL; + path = pygtk_tree_path_from_pyobject(py_path); + if (!path) { + PyErr_SetString(PyExc_TypeError, "could not convert path to a GtkTreePath"); + return NULL; + } + gtk_tree_view_get_background_area(GTK_TREE_VIEW(self->obj), path, GTK_TREE_VIEW_COLUMN(column->obj), &rect); + if (path) + gtk_tree_path_free(path); + return pyg_boxed_new(GDK_TYPE_RECTANGLE, &rect, TRUE, TRUE); +} +%% +override gtk_tree_view_widget_to_tree_coords args +static PyObject * +_wrap_gtk_tree_view_widget_to_tree_coords(PyGObject *self, PyObject *args) +{ + gint wx, wy, tx, ty; + + if (!PyArg_ParseTuple(args, "ii:GtkTreeView.widget_to_tree_coords", + &wx, &wy)) { + return NULL; + } + + gtk_tree_view_widget_to_tree_coords(GTK_TREE_VIEW(self->obj), wx, wy, &tx, &ty); + + return Py_BuildValue("(ii)", tx, ty); +} +%% +override gtk_tree_view_tree_to_widget_coords args +static PyObject * +_wrap_gtk_tree_view_tree_to_widget_coords(PyGObject *self, PyObject *args) +{ + gint tx, ty, wx, wy; + + if (!PyArg_ParseTuple(args, "ii:GtkTreeView.tree_to_widget_coords", + &tx, &ty)) { + return NULL; + } + + gtk_tree_view_tree_to_widget_coords(GTK_TREE_VIEW(self->obj), tx, ty, &wx, &wy); + + return Py_BuildValue("(ii)", wx, wy); +} +%% +override gtk_tree_view_get_cursor noargs +static PyObject * +_wrap_gtk_tree_view_get_cursor(PyGObject *self) +{ + PyObject *py_path; + PyObject *py_column; + GtkTreePath *path; + GtkTreeViewColumn *column; + + gtk_tree_view_get_cursor(GTK_TREE_VIEW(self->obj), + &path, &column); + + if (path != NULL) { + py_path = pygtk_tree_path_to_pyobject(path); + } else { + Py_INCREF(Py_None); + py_path = Py_None; + } + + if (column != NULL) { + py_column = pygobject_new((GObject*)column); + } else { + Py_INCREF(Py_None); + py_column = Py_None; + } + + return Py_BuildValue("(OO)", py_path, py_column); +} +%% +override gtk_tree_view_get_columns noargs +static PyObject * +_wrap_gtk_tree_view_get_columns(PyGObject *self) +{ + GList *list, *tmp; + PyObject *py_list; + + list = gtk_tree_view_get_columns(GTK_TREE_VIEW(self->obj)); + + if ((py_list = PyList_New(0)) == NULL) { + g_list_free(list); + return NULL; + } + for (tmp = list; tmp != NULL; tmp = tmp->next) { + PyObject *gtk_obj = pygobject_new(G_OBJECT(tmp->data)); + + if (gtk_obj == NULL) { + g_list_free(list); + Py_DECREF(py_list); + return NULL; + } + PyList_Append(py_list, gtk_obj); + Py_DECREF(gtk_obj); + } + g_list_free(list); + return py_list; +} +%% +override gtk_tree_selection_get_selected noargs +static PyObject * +_wrap_gtk_tree_selection_get_selected(PyGObject *self) +{ + GtkTreeModel *model; + GtkTreeIter iter; + GtkSelectionMode mode; + + mode = gtk_tree_selection_get_mode(GTK_TREE_SELECTION(self->obj)); + if (mode == GTK_SELECTION_MULTIPLE) { + PyErr_SetString(PyExc_TypeError, + "GtkTreeSelection.get_selected can not be used when" + " selection mode is gtk.SELECTION_MULTIPLE"); + return NULL; + } + + if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(self->obj), + &model, &iter)) { + return Py_BuildValue("(NN)", + pygobject_new((GObject *)model), + pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, + TRUE, TRUE)); + } else { + return Py_BuildValue ("(NN)", + pygobject_new((GObject *)model), + Py_None); + } +} +%% +override gtk_tree_selection_selected_foreach +static void +pygtk_tree_selection_foreach_marshal(GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer data) +{ + PyGtkCustomNotify *cunote = data; + PyObject *py_model, *py_path, *py_iter, *retobj; + + g_assert(cunote->func); + + pyg_block_threads(); + + py_model = pygobject_new((GObject *)model); + py_path = pygtk_tree_path_to_pyobject(path); + py_iter = pyg_boxed_new(GTK_TYPE_TREE_ITER, iter, TRUE, TRUE); + if (cunote->data) + retobj = PyEval_CallFunction(cunote->func, "(NNNO)", + py_model, py_path, py_iter, + cunote->data); + else + retobj = PyEval_CallFunction(cunote->func, "(NNN)", + py_model, py_path, py_iter); + + if (retobj == NULL) { + PyErr_Print(); + } + + Py_XDECREF(retobj); + + pyg_unblock_threads(); +} +static PyObject * +_wrap_gtk_tree_selection_selected_foreach(PyGObject *self, PyObject *args) +{ + PyObject *pyfunc, *pyarg = NULL; + PyGtkCustomNotify cunote; + + if(!PyArg_ParseTuple(args, "O|O:GtkTreeSelection.selected_foreach", + &pyfunc, &pyarg)) + return NULL; + + cunote.func = pyfunc; + cunote.data = pyarg; + gtk_tree_selection_selected_foreach(GTK_TREE_SELECTION(self->obj), + pygtk_tree_selection_foreach_marshal, + &cunote); + + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_tree_selection_set_select_function + +static gboolean +pygtk_tree_selection_marshal(GtkTreeSelection *selection, + GtkTreeModel *model, + GtkTreePath *path, + gboolean path_currently_selected, + gpointer data) +{ + gboolean retval = FALSE; + PyGtkCustomNotify *cunote = data; + PyObject *pypath, *retobj; + + g_assert(cunote->func); + + pyg_block_threads(); + + pypath = pygtk_tree_path_to_pyobject(path); + if (cunote->data) + retobj = PyEval_CallFunction(cunote->func, "(OO)", pypath, + cunote->data); + else + retobj = PyEval_CallFunction(cunote->func, "(O)", pypath); + + if (retobj == NULL) { + PyErr_Print(); + } + + Py_DECREF(pypath); + if (retobj) { + if(retobj == Py_None); + else if(PyInt_Check(retobj)) + retval = PyInt_AsLong(retobj) && TRUE; + else if(PyLong_Check(retobj)) + retval = PyLong_AsLongLong(retobj) && TRUE; + else if(PyString_Check(retobj)) + retval = PyString_GET_SIZE(retobj) && TRUE; + + Py_DECREF(retobj); + } + + pyg_unblock_threads(); + + return retval; +} +static PyObject * +_wrap_gtk_tree_selection_set_select_function(PyGObject *self, PyObject *args) +{ + PyObject *pyfunc, *pyarg = NULL; + PyGtkCustomNotify *cunote; + + if(!PyArg_ParseTuple(args, "O|O:GtkTreeSelection.set_select_function", + &pyfunc, &pyarg)) + return NULL; + + cunote = g_new0(PyGtkCustomNotify, 1); + cunote->func = pyfunc; + cunote->data = pyarg; + Py_INCREF(cunote->func); + Py_XINCREF(cunote->data); + gtk_tree_selection_set_select_function(GTK_TREE_SELECTION(self->obj), + pygtk_tree_selection_marshal, + cunote, + pygtk_custom_destroy_notify); + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_tree_get_row_drag_data noargs +static PyObject * +_wrap_gtk_tree_get_row_drag_data(PyObject *self) +{ + GtkTreeModel *tree_model; + GtkTreePath *path; + + if (gtk_tree_get_row_drag_data(pyg_boxed_get(self, GtkSelectionData), + &tree_model, &path)) { + PyObject *ret = Py_BuildValue("(NN)", + pygobject_new((GObject *)tree_model), + pygtk_tree_path_to_pyobject(path)); + + gtk_tree_path_free(path); + return ret; + } + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_tree_model_get_iter kwargs +static PyObject * +_wrap_gtk_tree_model_get_iter(PyGObject *self, PyObject *args,PyObject *kwargs) +{ + static char *kwlist[] = { "path", NULL }; + PyObject *py_path; + GtkTreeIter iter; + GtkTreePath *path; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GtkTreeModel.get_iter", + kwlist, &py_path)) + return NULL; + + path = pygtk_tree_path_from_pyobject(py_path); + if (!path) { + PyErr_SetString(PyExc_TypeError, "GtkTreeModel.get_iter requires a tree path as its argument"); + return NULL; + } + if (gtk_tree_model_get_iter(GTK_TREE_MODEL(self->obj), &iter, path)) { + gtk_tree_path_free(path); + return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); + } else { + gtk_tree_path_free(path); + PyErr_SetString(PyExc_ValueError, "invalid tree path"); + return NULL; + } +} +%% +override gtk_tree_model_get_iter_from_string kwargs +static PyObject * +_wrap_gtk_tree_model_get_iter_from_string(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "path_string", NULL }; + const gchar *path_string; + GtkTreeIter iter; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "s:GtkTreeModel.get_iter_from_string", + kwlist, &path_string)) + return NULL; + + if (gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(self->obj), &iter, + path_string)) { + return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); + } else { + PyErr_SetString(PyExc_ValueError, "invalid tree path"); + return NULL; + } +} +%% +override gtk_tree_model_get_value kwargs +static PyObject * +_wrap_gtk_tree_model_get_value(PyGObject *self, PyObject*args, PyObject*kwargs) +{ + static char *kwlist[] = { "iter", "column", NULL }; + PyObject *iter, *ret; + gint column; + GValue value = { 0, }; + + if (!PyArg_ParseTupleAndKeywords(args,kwargs, "Oi:GtkTreeModel.get_value", + kwlist, &iter, &column)) + return NULL; + if (column < 0 || + column >= gtk_tree_model_get_n_columns(GTK_TREE_MODEL(self->obj))) { + PyErr_SetString(PyExc_ValueError, "column number is out of range"); + return NULL; + } + if (!pyg_boxed_check(iter, GTK_TYPE_TREE_ITER)) { + PyErr_SetString(PyExc_TypeError, "iter must be a GtkTreeIter"); + return NULL; + } + gtk_tree_model_get_value(GTK_TREE_MODEL(self->obj), + pyg_boxed_get(iter, GtkTreeIter), column, &value); + ret = pyg_value_as_pyobject(&value, TRUE); + g_value_unset(&value); + return ret; +} +%% +override-slot GtkTreeModel.tp_as_number +static int +_wrap_gtk_tree_model_tp_nonzero(PyGObject *self) +{ + return TRUE; +} +static PyNumberMethods _wrap_gtk_tree_model_tp_as_number = { + (binaryfunc)0, + (binaryfunc)0, + (binaryfunc)0, + (binaryfunc)0, + (binaryfunc)0, + (binaryfunc)0, + (ternaryfunc)0, + (unaryfunc)0, + (unaryfunc)0, + (unaryfunc)0, + (inquiry)_wrap_gtk_tree_model_tp_nonzero, + (unaryfunc)0, + (binaryfunc)0, + (binaryfunc)0, + (binaryfunc)0, + (binaryfunc)0, + (binaryfunc)0, + (coercion)0, + (unaryfunc)0, + (unaryfunc)0, + (unaryfunc)0, + (unaryfunc)0, + (unaryfunc)0 +}; +%% +override-slot GtkTreeModel.tp_as_mapping +static int +_wrap_gtk_tree_model_tp_length(PyGObject *self) +{ + return gtk_tree_model_iter_n_children(GTK_TREE_MODEL(self->obj), NULL); +} +static PyObject * +_wrap_gtk_tree_model_tp_getitem(PyGObject *self, PyObject *item) +{ + GtkTreePath *path; + GtkTreeIter iter; + PyObject *ret = NULL; + + if (pyg_boxed_check(item, GTK_TYPE_TREE_ITER)) { + return _pygtk_tree_model_row_new(GTK_TREE_MODEL(self->obj), + pyg_boxed_get(item, GtkTreeIter)); + } + + path = pygtk_tree_path_from_pyobject(item); + if (!path) { + PyErr_SetString(PyExc_TypeError, + "could not parse subscript as a tree path"); + return NULL; + } + if (gtk_tree_model_get_iter(GTK_TREE_MODEL(self->obj), &iter, path)) { + ret = _pygtk_tree_model_row_new(GTK_TREE_MODEL(self->obj), &iter); + } else { + PyErr_SetString(PyExc_IndexError, "could not find tree path"); + ret = NULL; + } + gtk_tree_path_free(path); + return ret; +} +static int +_wrap_gtk_tree_model_tp_setitem(PyGObject *self, PyObject *item, + PyObject *value) +{ + GtkTreeIter *iter, iter2; + + if (pyg_boxed_check(item, GTK_TYPE_TREE_ITER)) { + iter = pyg_boxed_get(item, GtkTreeIter); + } else { + GtkTreePath *path = pygtk_tree_path_from_pyobject(item); + + if (!path) { + PyErr_SetString(PyExc_TypeError, + "could not parse subscript as a tree path"); + return -1; + } + if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(self->obj), &iter2,path)) { + PyErr_SetString(PyExc_TypeError, "could not find tree path"); + gtk_tree_path_free(path); + return -1; + } + iter = &iter2; + gtk_tree_path_free(path); + } + + if (value == NULL) { + if (GTK_IS_LIST_STORE(self->obj)) { + gtk_list_store_remove(GTK_LIST_STORE(self->obj), iter); + return 0; + } else if (GTK_IS_TREE_STORE(self->obj)) { + gtk_tree_store_remove(GTK_TREE_STORE(self->obj), iter); + return 0; + } else { + PyErr_SetString(PyExc_TypeError, + "don't know how to remove rows " + "from this type of tree model"); + return -1; + } + } else { + return _pygtk_tree_model_set_row(GTK_TREE_MODEL(self->obj), iter,value); + } +} + +static PyMappingMethods _wrap_gtk_tree_model_tp_as_mapping = { + (inquiry)_wrap_gtk_tree_model_tp_length, + (binaryfunc)_wrap_gtk_tree_model_tp_getitem, + (objobjargproc)_wrap_gtk_tree_model_tp_setitem +}; +%% +override-slot GtkTreeModel.tp_iter +static PyObject * +_wrap_gtk_tree_model_tp_iter(PyGObject *self) +{ + return _pygtk_tree_model_row_iter_new(GTK_TREE_MODEL(self->obj), NULL); +} +%% +override gtk_tree_sortable_get_sort_column_id noargs +static PyObject * +_wrap_gtk_tree_sortable_get_sort_column_id(PyGObject *self) +{ + gboolean ret; + gint sort_column_id; + GtkSortType order; + + ret = gtk_tree_sortable_get_sort_column_id(GTK_TREE_SORTABLE(self->obj), + &sort_column_id, &order); + + /* if we don't have a sort column set, return (None, None) */ + if (ret) + return Py_BuildValue("(ii)", sort_column_id, order); + else + return Py_BuildValue("(OO)", Py_None, Py_None); +} +%% +override gtk_tree_sortable_set_sort_func +static gint +pygtk_tree_sortable_sort_cb(GtkTreeModel *model, GtkTreeIter *iter1, + GtkTreeIter *iter2, gpointer user_data) +{ + PyGtkCustomNotify *cunote = user_data; + PyObject *py_model, *py_iter2, *py_iter1, *retobj; + gint ret = 0; + + g_assert(cunote->func); + + pyg_block_threads(); + + py_model = pygobject_new((GObject *)model); + py_iter1 = pyg_boxed_new(GTK_TYPE_TREE_ITER, iter1, TRUE, TRUE); + py_iter2 = pyg_boxed_new(GTK_TYPE_TREE_ITER, iter2, TRUE, TRUE); + + if (cunote->data) { + retobj = PyEval_CallFunction(cunote->func, "(NNNO)", py_model, + py_iter1, py_iter2, cunote->data); + } else { + retobj = PyEval_CallFunction(cunote->func, "(NNN)", py_model, + py_iter1, py_iter2); + } + + if (retobj) + ret = PyInt_AsLong(retobj); + if (PyErr_Occurred()) { + PyErr_Print(); + ret = 0; + } + Py_XDECREF(retobj); + + pyg_unblock_threads(); + return ret; +} +static PyObject * +_wrap_gtk_tree_sortable_set_sort_func(PyGObject *self, PyObject *args) +{ + gint column; + PyObject *callback, *data = NULL; + PyGtkCustomNotify *cunote; + + if (!PyArg_ParseTuple(args, "iO|O:GtkTreeSortable.set_sort_func", + &column, &callback, &data)) + return NULL; + + if (!PyCallable_Check(callback)) { + PyErr_SetString(PyExc_TypeError, "callback must be a callable object"); + return NULL; + } + cunote = g_new(PyGtkCustomNotify, 1); + Py_INCREF(callback); + cunote->func = callback; + Py_XINCREF(data); + cunote->data = data; + + gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(self->obj), column, + pygtk_tree_sortable_sort_cb, cunote, + pygtk_custom_destroy_notify); + + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_tree_sortable_set_default_sort_func +static PyObject * +_wrap_gtk_tree_sortable_set_default_sort_func(PyGObject *self, PyObject *args) +{ + PyObject *callback, *data = NULL; + PyGtkCustomNotify *cunote; + + if (!PyArg_ParseTuple(args, "O|O:GtkTreeSortable.set_default_sort_func", + &callback, &data)) + return NULL; + + if (!PyCallable_Check(callback)) { + PyErr_SetString(PyExc_TypeError, "callback must be a callable object"); + return NULL; + } + cunote = g_new(PyGtkCustomNotify, 1); + Py_INCREF(callback); + cunote->func = callback; + Py_XINCREF(data); + cunote->data = data; + + gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(self->obj), + pygtk_tree_sortable_sort_cb, + cunote, + pygtk_custom_destroy_notify); + + Py_INCREF(Py_None); + return Py_None; +} +%% +ignore gtk_list_store_newv +%% +override gtk_list_store_new +static int +_wrap_gtk_list_store_new(PyGObject *self, PyObject *args) +{ + guint len, i; + GType *column_types; + + len = PyTuple_Size(args); + if (len == 0) { + PyErr_SetString(PyExc_TypeError, + "GtkListStore requires at least one argument"); + return -1; + } + + column_types = g_new(GType, len); + for (i = 0; i < len; i++) { + PyObject *item = PyTuple_GetItem(args, i); + + column_types[i] = pyg_type_from_object(item); + if (column_types[i] == 0) { + g_free(column_types); + return -1; + } + } + self->obj = (GObject *)gtk_list_store_newv(len, column_types); + g_free(column_types); + if (!self->obj) { + PyErr_SetString(PyExc_RuntimeError, + "could not create GtkListStore object"); + return -1; + } + pygobject_register_wrapper((PyObject *)self); + return 0; +} +%% +ignore gtk_list_store_set_valist +%% +override gtk_list_store_set +static PyObject * +_wrap_gtk_list_store_set(PyGObject *self, PyObject *args) +{ + PyObject *iter; + int len, i; + + len = PyTuple_Size(args); + if (len == 0) { + PyErr_SetString(PyExc_TypeError, "GtkListStore.set requires at least three arguments"); + return NULL; + } + + iter = PyTuple_GetItem(args, 0); + if (!pyg_boxed_check(iter, GTK_TYPE_TREE_ITER)) { + PyErr_SetString(PyExc_TypeError, "iter must be a GtkTreeIter"); + return NULL; + } + + if ((len - 1) % 2) { + PyErr_SetString(PyExc_TypeError, + "Argument list must be column, value pairs. No -1 " + "termination is needed."); + return NULL; + } + for (i = 1; i < len; i+=2) { + gint column; + GValue value = { 0 }; + PyObject *py_column = PyTuple_GetItem(args, i); + PyObject *py_value = PyTuple_GetItem(args, i + 1); + + if (!PyInt_Check(py_column)) { + PyErr_SetString(PyExc_TypeError, + "Expected numeric argument for column."); + return NULL; + } + column = PyInt_AsLong(py_column); + if (column < 0 || + column >= gtk_tree_model_get_n_columns(GTK_TREE_MODEL(self->obj))) { + PyErr_SetString(PyExc_ValueError, "column number is out of range"); + return NULL; + } + g_value_init(&value, + gtk_tree_model_get_column_type(GTK_TREE_MODEL(self->obj), + column)); + if (pyg_value_from_pyobject(&value, py_value)) { + PyErr_SetString(PyExc_TypeError, + "value is of the wrong type for this column"); + return NULL; + } + gtk_list_store_set_value(GTK_LIST_STORE(self->obj), + pyg_boxed_get(iter, GtkTreeIter), column, &value); + g_value_unset(&value); + } + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_list_store_set_value kwargs +static PyObject * +_wrap_gtk_list_store_set_value(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "iter", "column", "value", NULL }; + PyObject *iter, *pyvalue; + gint column; + GValue value = { 0 }; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "OiO:GtkListStore.set_value", + kwlist, &iter, &column, &pyvalue)) + return NULL; + if (column < 0 || + column >= gtk_tree_model_get_n_columns(GTK_TREE_MODEL(self->obj))) { + PyErr_SetString(PyExc_ValueError, "column number is out of range"); + return NULL; + } + if (!pyg_boxed_check(iter, GTK_TYPE_TREE_ITER)) { + PyErr_SetString(PyExc_TypeError, "iter must be a GtkTreeIter"); + return NULL; + } + g_value_init(&value, + gtk_tree_model_get_column_type(GTK_TREE_MODEL(self->obj), + column)); + if (pyg_value_from_pyobject(&value, pyvalue)) { + PyErr_SetString(PyExc_TypeError, + "value is of the wrong type for this column"); + return NULL; + } + gtk_list_store_set_value(GTK_LIST_STORE(self->obj), + pyg_boxed_get(iter, GtkTreeIter), column, &value); + g_value_unset(&value); + Py_INCREF(Py_None); + return Py_None; +} +%% +ignore + gtk_list_store_setv +%% + override gtk_list_store_insert kwargs +static PyObject * +_wrap_gtk_list_store_insert(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "position", "row", NULL }; + GtkTreeIter iter; + gint position; + PyObject *row = Py_None; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i|O:GtkListStore.insert", + kwlist, &position, &row)) { + return NULL; + } + gtk_list_store_insert(GTK_LIST_STORE(self->obj), &iter, position); + + /* optionally set items in the new row */ + if (row != Py_None && + _pygtk_tree_model_set_row(GTK_TREE_MODEL(self->obj), &iter, row) < 0) + return NULL; + + return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); +} +%% +override gtk_list_store_insert_before kwargs +static PyObject * +_wrap_gtk_list_store_insert_before(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "sibling", "row", NULL }; + PyObject *sibling; + GtkTreeIter iter; + PyObject *row = Py_None; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O|O:GtkListStore.insert_before", + kwlist, &sibling, &row)) { + return NULL; + } + + if (!pyg_boxed_check(sibling, GTK_TYPE_TREE_ITER)) { + PyErr_SetString(PyExc_TypeError, "iter must be a GtkTreeIter"); + return NULL; + } + gtk_list_store_insert_before(GTK_LIST_STORE(self->obj), &iter, + pyg_boxed_get(sibling, GtkTreeIter)); + + /* optionally set items in the new row */ + if (row != Py_None && + _pygtk_tree_model_set_row(GTK_TREE_MODEL(self->obj), &iter, row) < 0) + return NULL; + + return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); +} +%% +override gtk_list_store_insert_after kwargs +static PyObject * +_wrap_gtk_list_store_insert_after(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "sibling", "row", NULL }; + PyObject *sibling; + GtkTreeIter iter; + PyObject *row = Py_None; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O|O:GtkListStore.insert_after", + kwlist, &sibling, &row)) + return NULL; + if (!pyg_boxed_check(sibling, GTK_TYPE_TREE_ITER)) { + PyErr_SetString(PyExc_TypeError, "iter must be a GtkTreeIter"); + return NULL; + } + gtk_list_store_insert_after(GTK_LIST_STORE(self->obj), &iter, + pyg_boxed_get(sibling, GtkTreeIter)); + + /* optionally set items in the new row */ + if (row != Py_None && + _pygtk_tree_model_set_row(GTK_TREE_MODEL(self->obj), &iter, row) < 0) + return NULL; + + return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); +} +%% +override gtk_list_store_prepend kwargs +static PyObject * +_wrap_gtk_list_store_prepend(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "row", NULL }; + GtkTreeIter iter; + PyObject *row = Py_None; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:GtkListStore.prepend", + kwlist, &row)) + return NULL; + + gtk_list_store_prepend(GTK_LIST_STORE(self->obj), &iter); + + /* optionally set items in the new row */ + if (row != Py_None && + _pygtk_tree_model_set_row(GTK_TREE_MODEL(self->obj), &iter, row) < 0) + return NULL; + + return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); +} +%% +override gtk_list_store_append kwargs +static PyObject * +_wrap_gtk_list_store_append(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "row", NULL }; + GtkTreeIter iter; + PyObject *row = Py_None; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O:GtkListStore.append", + kwlist, &row)) + return NULL; + + gtk_list_store_append(GTK_LIST_STORE(self->obj), &iter); + + /* optionally set items in the new row */ + if (row != Py_None && + _pygtk_tree_model_set_row(GTK_TREE_MODEL(self->obj), &iter, row) < 0) + return NULL; + + return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); +} +%% +ignore gtk_tree_store_newv +%% +override gtk_tree_store_new +static int +_wrap_gtk_tree_store_new(PyGObject *self, PyObject *args) +{ + guint len, i; + GType *column_types; + + len = PyTuple_Size(args); + if (len == 0) { + PyErr_SetString(PyExc_TypeError, "GtkTreeStore requires at least one argument"); + return -1; + } + + column_types = g_new(GType, len); + for (i = 0; i < len; i++) { + PyObject *item = PyTuple_GetItem(args, i); + + column_types[i] = pyg_type_from_object(item); + if (column_types[i] == 0) { + g_free(column_types); + return -1; + } + } + self->obj = (GObject *)gtk_tree_store_newv(len, column_types); + g_free(column_types); + if (!self->obj) { + PyErr_SetString(PyExc_RuntimeError, + "could not create GtkTreeStore object"); + return -1; + } + pygobject_register_wrapper((PyObject *)self); + return 0; +} +%% +ignore gtk_tree_store_set_valist +%% +override gtk_tree_store_set +static PyObject * +_wrap_gtk_tree_store_set(PyGObject *self, PyObject *args) +{ + PyObject *iter; + int len, i; + + len = PyTuple_Size(args); + if (len == 0) { + PyErr_SetString(PyExc_TypeError, "GtkTreeStore.set requires at least three arguments"); + return NULL; + } + + iter = PyTuple_GetItem(args, 0); + if (!pyg_boxed_check(iter, GTK_TYPE_TREE_ITER)) { + PyErr_SetString(PyExc_TypeError, "iter must be a GtkTreeIter"); + return NULL; + } + + if ((len - 1) % 2) { + PyErr_SetString(PyExc_TypeError, + "Argument list must be column, value pairs. No -1 " + "termination is needed."); + return NULL; + } + for (i = 1; i < len; i+=2) { + gint column; + GValue value = { 0 }; + PyObject *py_column = PyTuple_GetItem(args, i); + PyObject *py_value = PyTuple_GetItem(args, i + 1); + + if (!PyInt_Check(py_column)) { + PyErr_SetString(PyExc_TypeError, + "Expected numeric argument for column."); + return NULL; + } + column = PyInt_AsLong(py_column); + if (column < 0 || + column >= gtk_tree_model_get_n_columns(GTK_TREE_MODEL(self->obj))) { + PyErr_SetString(PyExc_ValueError, "column number is out of range"); + return NULL; + } + g_value_init(&value, + gtk_tree_model_get_column_type(GTK_TREE_MODEL(self->obj), + column)); + if (pyg_value_from_pyobject(&value, py_value)) { + PyErr_SetString(PyExc_TypeError, + "value is of the wrong type for this column"); + return NULL; + } + gtk_tree_store_set_value(GTK_TREE_STORE(self->obj), + pyg_boxed_get(iter, GtkTreeIter), column, + &value); + g_value_unset(&value); + } + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_tree_store_set_value kwargs +static PyObject * +_wrap_gtk_tree_store_set_value(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "iter", "column", "value", NULL }; + PyObject *iter, *pyvalue; + gint column; + GValue value = { 0 }; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "OiO:GtkTreeStore.set_value", + kwlist, &iter, &column, &pyvalue)) + return NULL; + if (column < 0 || + column >= gtk_tree_model_get_n_columns(GTK_TREE_MODEL(self->obj))) { + PyErr_SetString(PyExc_ValueError, "column number is out of range"); + return NULL; + } + if (!pyg_boxed_check(iter, GTK_TYPE_TREE_ITER)) { + PyErr_SetString(PyExc_TypeError, "iter must be a GtkTreeIter"); + return NULL; + } + g_value_init(&value, + gtk_tree_model_get_column_type(GTK_TREE_MODEL(self->obj), + column)); + if (pyg_value_from_pyobject(&value, pyvalue)) { + PyErr_SetString(PyExc_TypeError, + "value is of the wrong type for this column"); + return NULL; + } + gtk_tree_store_set_value(GTK_TREE_STORE(self->obj), + pyg_boxed_get(iter, GtkTreeIter), column, &value); + g_value_unset(&value); + Py_INCREF(Py_None); + return Py_None; +} +%% +ignore + gtk_tree_store_setv +%% +override gtk_tree_store_insert kwargs +static PyObject * +_wrap_gtk_tree_store_insert(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "parent", "position", "row", NULL }; + PyObject *py_parent; + GtkTreeIter iter, *parent = NULL; + gint position; + PyObject *row = Py_None; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Oi|O:GtkTreeStore.insert", + kwlist, &py_parent, &position, &row)) + return NULL; + if (pyg_boxed_check(py_parent, GTK_TYPE_TREE_ITER)) + parent = pyg_boxed_get(py_parent, GtkTreeIter); + else if (py_parent != Py_None) { + PyErr_SetString(PyExc_TypeError, + "parent must be a GtkTreeIter or None"); + return NULL; + } + gtk_tree_store_insert(GTK_TREE_STORE(self->obj), &iter, parent, position); + + /* optionally set items in the new row */ + if (row != Py_None && + _pygtk_tree_model_set_row(GTK_TREE_MODEL(self->obj), &iter, row) < 0) + return NULL; + + return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); +} +%% +override gtk_tree_store_insert_before kwargs +static PyObject * +_wrap_gtk_tree_store_insert_before(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "parent", "sibling", "row", NULL }; + PyObject *py_parent, *py_sibling; + GtkTreeIter iter, *parent = NULL, *sibling = NULL; + PyObject *row = Py_None; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "OO|O:GtkTreeStore.insert_before", + kwlist, &py_parent, &py_sibling, &row)) + return NULL; + if (pyg_boxed_check(py_parent, GTK_TYPE_TREE_ITER)) + parent = pyg_boxed_get(py_parent, GtkTreeIter); + else if (py_parent != Py_None) { + PyErr_SetString(PyExc_TypeError, + "parent must be a GtkTreeIter or None"); + return NULL; + } + if (pyg_boxed_check(py_sibling, GTK_TYPE_TREE_ITER)) + sibling = pyg_boxed_get(py_sibling, GtkTreeIter); + else if (py_sibling != Py_None) { + PyErr_SetString(PyExc_TypeError, + "sibling must be a GtkTreeIter or None"); + return NULL; + } + gtk_tree_store_insert_before(GTK_TREE_STORE(self->obj), &iter, parent, + sibling); + + /* optionally set items in the new row */ + if (row != Py_None && + _pygtk_tree_model_set_row(GTK_TREE_MODEL(self->obj), &iter, row) < 0) + return NULL; + + return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); +} +%% +override gtk_tree_store_insert_after kwargs +static PyObject * +_wrap_gtk_tree_store_insert_after(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "parent", "sibling", "row", NULL }; + PyObject *py_parent, *py_sibling; + GtkTreeIter iter, *parent = NULL, *sibling = NULL; + PyObject *row = Py_None; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "OO|O:GtkTreeStore.insert_after", + kwlist, &py_parent, &py_sibling, &row)) + return NULL; + if (pyg_boxed_check(py_parent, GTK_TYPE_TREE_ITER)) + parent = pyg_boxed_get(py_parent, GtkTreeIter); + else if (py_parent != Py_None) { + PyErr_SetString(PyExc_TypeError, + "parent must be a GtkTreeIter or None"); + return NULL; + } + if (pyg_boxed_check(py_sibling, GTK_TYPE_TREE_ITER)) + sibling = pyg_boxed_get(py_sibling, GtkTreeIter); + else if (py_sibling != Py_None) { + PyErr_SetString(PyExc_TypeError, + "sibling must be a GtkTreeIter or None"); + return NULL; + } + gtk_tree_store_insert_after(GTK_TREE_STORE(self->obj), &iter, parent, + sibling); + + /* optionally set items in the new row */ + if (row != Py_None && + _pygtk_tree_model_set_row(GTK_TREE_MODEL(self->obj), &iter, row) < 0) + return NULL; + + return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); +} +%% +override gtk_tree_store_prepend kwargs +static PyObject * +_wrap_gtk_tree_store_prepend(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "parent", "row", NULL }; + PyObject *py_parent; + GtkTreeIter iter, *parent = NULL; + PyObject *row = Py_None; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:GtkTreeStore.prepend", + kwlist, &py_parent, &row)) + return NULL; + if (pyg_boxed_check(py_parent, GTK_TYPE_TREE_ITER)) + parent = pyg_boxed_get(py_parent, GtkTreeIter); + else if (py_parent != Py_None) { + PyErr_SetString(PyExc_TypeError, + "parent must be a GtkTreeIter or None"); + return NULL; + } + gtk_tree_store_prepend(GTK_TREE_STORE(self->obj), &iter, parent); + + /* optionally set items in the new row */ + if (row != Py_None && + _pygtk_tree_model_set_row(GTK_TREE_MODEL(self->obj), &iter, row) < 0) + return NULL; + + return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); +} +%% +override gtk_tree_store_append kwargs +static PyObject * +_wrap_gtk_tree_store_append(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "parent", "row", NULL }; + PyObject *py_parent; + GtkTreeIter iter, *parent = NULL; + PyObject *row = Py_None; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:GtkTreeStore.append", + kwlist, &py_parent, &row)) + return NULL; + if (pyg_boxed_check(py_parent, GTK_TYPE_TREE_ITER)) + parent = pyg_boxed_get(py_parent, GtkTreeIter); + else if (py_parent != Py_None) { + PyErr_SetString(PyExc_TypeError, + "parent must be a GtkTreeIter or None"); + return NULL; + } + gtk_tree_store_append(GTK_TREE_STORE(self->obj), &iter, parent); + + /* optionally set items in the new row */ + if (row != Py_None && + _pygtk_tree_model_set_row(GTK_TREE_MODEL(self->obj), &iter, row) < 0) + return NULL; + + return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); +} +%% +override gtk_tree_model_get_iter_first noargs +static PyObject * +_wrap_gtk_tree_model_get_iter_first(PyGObject *self) +{ + GtkTreeIter iter; + + if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(self->obj), &iter)) + return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); + else { + Py_INCREF(Py_None); + return Py_None; + } +} +%% +override gtk_tree_model_iter_next kwargs +static PyObject * +_wrap_gtk_tree_model_iter_next(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "iter", NULL }; + PyObject *py_iter; + GtkTreeIter iter; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O:GtkTreeModel.iter_next", kwlist, + &py_iter)) + return NULL; + if (pyg_boxed_check(py_iter, GTK_TYPE_TREE_ITER)) + iter = *pyg_boxed_get(py_iter, GtkTreeIter); + else { + PyErr_SetString(PyExc_TypeError, "iter should be a GtkTreeIter"); + return NULL; + } + + if (gtk_tree_model_iter_next(GTK_TREE_MODEL(self->obj), &iter)) + return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); + else { + Py_INCREF(Py_None); + return Py_None; + } +} +%% +override gtk_tree_model_iter_children kwargs +static PyObject * +_wrap_gtk_tree_model_iter_children(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "parent", NULL }; + PyObject *py_parent; + GtkTreeIter iter, *parent = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O:GtkTreeModel.iter_children", kwlist, + &py_parent)) + return NULL; + if (pyg_boxed_check(py_parent, GTK_TYPE_TREE_ITER)) + parent = pyg_boxed_get(py_parent, GtkTreeIter); + else { + PyErr_SetString(PyExc_TypeError, "parent should be a GtkTreeIter"); + return NULL; + } + + if (gtk_tree_model_iter_children(GTK_TREE_MODEL(self->obj), + &iter, parent)) + return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); + else { + Py_INCREF(Py_None); + return Py_None; + } +} +%% +override gtk_tree_model_iter_nth_child kwargs +static PyObject * +_wrap_gtk_tree_model_iter_nth_child(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "parent", "n", NULL }; + PyObject *py_parent; + gint n; + GtkTreeIter iter, *parent = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "Oi:GtkTreeModel.iter_nth_child", kwlist, + &py_parent, &n)) + return NULL; + if (pyg_boxed_check(py_parent, GTK_TYPE_TREE_ITER)) + parent = pyg_boxed_get(py_parent, GtkTreeIter); + else if (py_parent == Py_None) + parent = NULL; + else { + PyErr_SetString(PyExc_TypeError, "parent should be a GtkTreeIter or None"); + return NULL; + } + + if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(self->obj), + &iter, parent, n)) + return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); + else { + Py_INCREF(Py_None); + return Py_None; + } +} +%% +override gtk_tree_model_iter_parent kwargs +static PyObject * +_wrap_gtk_tree_model_iter_parent(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "child", NULL }; + PyObject *py_child; + GtkTreeIter iter, *child = NULL; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O:GtkTreeModel.iter_parent", kwlist, + &py_child)) + return NULL; + if (pyg_boxed_check(py_child, GTK_TYPE_TREE_ITER)) + child = pyg_boxed_get(py_child, GtkTreeIter); + else { + PyErr_SetString(PyExc_TypeError, "child should be a GtkTreeIter"); + return NULL; + } + + if (gtk_tree_model_iter_parent(GTK_TREE_MODEL(self->obj), + &iter, child)) + return pyg_boxed_new(GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE); + else { + Py_INCREF(Py_None); + return Py_None; + } +} +%% +override gtk_tree_model_foreach +static gboolean +pygtk_tree_foreach_marshal(GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer data) +{ + PyGtkCustomNotify *cunote = data; + PyObject *py_model, *py_path, *py_iter, *retobj; + gboolean ret; + + g_assert(cunote->func); + + pyg_block_threads(); + + py_model = pygobject_new((GObject *)model); + py_path = pygtk_tree_path_to_pyobject(path); + py_iter = pyg_boxed_new(GTK_TYPE_TREE_ITER, iter, TRUE, TRUE); + if (cunote->data) + retobj = PyEval_CallFunction(cunote->func, "(NNNO)", + py_model, py_path, py_iter, + cunote->data); + else + retobj = PyEval_CallFunction(cunote->func, "(NNN)", + py_model, py_path, py_iter); + + if (retobj != NULL) { + ret = PyObject_IsTrue(retobj); + Py_DECREF(retobj); + } else { + ret = TRUE; + } + + pyg_unblock_threads(); + return ret; +} +static PyObject * +_wrap_gtk_tree_model_foreach(PyGObject *self, PyObject *args) +{ + static gboolean pygtk_tree_foreach_marshal(GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer data); + PyObject *pyfunc, *pyarg = NULL; + PyGtkCustomNotify cunote; + + if(!PyArg_ParseTuple(args, "O|O:GtkTreeModel.foreach", + &pyfunc, &pyarg)) + return NULL; + + cunote.func = pyfunc; + cunote.data = pyarg; + gtk_tree_model_foreach(GTK_TREE_MODEL(self->obj), + pygtk_tree_foreach_marshal, &cunote); + + if (PyErr_Occurred()) + return NULL; + + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_cell_renderer_get_size kwargs +static PyObject * +_wrap_gtk_cell_renderer_get_size(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "widget", "cell_area", NULL }; + gint x_offset = 0, y_offset = 0, width = 0, height = 0; + GdkRectangle cell_area; + PyObject *py_widget, *py_cell_area = Py_None; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "O|O:GtkCellRenderer.get_size", kwlist, + &py_widget, &py_cell_area)) + return NULL; + + if (!pygobject_check(py_widget, &PyGtkWidget_Type)) { + PyErr_SetString(PyExc_TypeError, "widget must be a GtkWidget"); + return NULL; + } + if (py_cell_area != Py_None) { + if (!pygdk_rectangle_from_pyobject(py_cell_area, &cell_area)) + return NULL; + } + + gtk_cell_renderer_get_size(GTK_CELL_RENDERER(self->obj), + GTK_WIDGET(pygobject_get(py_widget)), + (py_cell_area == Py_None) ? NULL : &cell_area, + &x_offset, &y_offset, &width, &height); + + return Py_BuildValue("(iiii)", x_offset, y_offset, width, height); +} +%% +override gtk_cell_renderer_get_fixed_size noargs +static PyObject * +_wrap_gtk_cell_renderer_get_fixed_size(PyGObject *self) +{ + gint width, height; + + gtk_cell_renderer_get_fixed_size(GTK_CELL_RENDERER(self->obj), + &width, &height); + + return Py_BuildValue("(ii)", width, height); +} diff --git a/gtk/gtkwidget.override b/gtk/gtkwidget.override new file mode 100644 index 00000000..18758c19 --- /dev/null +++ b/gtk/gtkwidget.override @@ -0,0 +1,132 @@ +/* -*- Mode: C; c-basic-offset: 4 -*- */ +%% +override gtk_widget_translate_coordinates kwargs +static PyObject * +_wrap_gtk_widget_translate_coordinates(PyGObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "dest_widget", "src_x", "src_y", NULL }; + PyObject *py_dest_widget; + int src_x, src_y; + GtkWidget *dest_widget = NULL; + int dest_x, dest_y; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Oii:GtkWidget.translate_coordinates", + kwlist, &py_dest_widget, &src_x, &src_y)) { + return NULL; + } + + if (pygobject_check(py_dest_widget, &PyGtkWidget_Type)) { + dest_widget = GTK_WIDGET(pygobject_get(py_dest_widget)); + } else if (py_dest_widget != Py_None) { + PyErr_SetString(PyExc_TypeError, + "dest_widget must be a GtkWidget or None"); + return NULL; + } + + if (!gtk_widget_translate_coordinates(GTK_WIDGET(self->obj), + dest_widget, + src_x, + src_y, + &dest_x, + &dest_y)) { + return Py_BuildValue ("()"); + } + + return Py_BuildValue ("(ii)", &dest_x, &dest_y); +} +%% +override gtk_widget_size_request noargs +static PyObject * +_wrap_gtk_widget_size_request(PyGObject *self) +{ + GtkRequisition requisition; + + gtk_widget_size_request(GTK_WIDGET(self->obj), &requisition); + return Py_BuildValue("(ii)", requisition.width, requisition.height); +} +%% +override gtk_widget_get_child_requisition noargs +static PyObject * +_wrap_gtk_widget_get_child_requisition(PyGObject *self) +{ + GtkRequisition requisition; + + gtk_widget_get_child_requisition(GTK_WIDGET(self->obj), &requisition); + return Py_BuildValue("(ii)", requisition.width, requisition.height); +} +%% +override gtk_widget_get_allocation noargs +static PyObject * +_wrap_gtk_widget_get_allocation(PyGObject *self) +{ + GtkAllocation allocation; + + allocation = GTK_WIDGET(self->obj)->allocation; + return pyg_boxed_new(GDK_TYPE_RECTANGLE, &allocation, TRUE, TRUE); +} +%% +override gtk_widget_intersect kwargs +static PyObject * +_wrap_gtk_widget_intersect(PyGObject *self, PyObject *args, PyObject*kwargs) +{ + static char *kwlist[] = { "area", NULL }; + PyObject *py_area; + GdkRectangle area, intersect; + + if(!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GtkWidget.intersect", + kwlist, &py_area)) + return NULL; + if (!pygdk_rectangle_from_pyobject(py_area, &area)) + return NULL; + if (gtk_widget_intersect(GTK_WIDGET(self->obj), &area, &intersect)) + return pyg_boxed_new(GDK_TYPE_RECTANGLE, &intersect, TRUE, TRUE); + else { + Py_INCREF(Py_None); + return Py_None; + } +} +%% +override gtk_widget_get_pointer noargs +static PyObject * +_wrap_gtk_widget_get_pointer(PyGObject *self) +{ + int x, y; + + gtk_widget_get_pointer(GTK_WIDGET(self->obj), &x, &y); + return Py_BuildValue("(ii)", x, y); +} +%% +override gtk_widget_path noargs +static PyObject * +_wrap_gtk_widget_path(PyGObject *self) +{ + guint length; + gchar *path; + gchar *path_reversed; + PyObject *result; + + gtk_widget_path(GTK_WIDGET(self->obj), &length, &path, &path_reversed); + result = PyString_FromString(path); + g_free(path); + g_free(path_reversed); + + return result; +} +%% +override gtk_widget_class_path noargs +static PyObject * +_wrap_gtk_widget_class_path(PyGObject *self) +{ + guint length; + gchar *path; + gchar *path_reversed; + PyObject *result; + + gtk_widget_class_path(GTK_WIDGET(self->obj), &length, &path, + &path_reversed); + result = PyString_FromString(path); + g_free(path); + g_free(path_reversed); + + return result; +} diff --git a/gtk/gtkwindow.override b/gtk/gtkwindow.override new file mode 100644 index 00000000..80d84c39 --- /dev/null +++ b/gtk/gtkwindow.override @@ -0,0 +1,266 @@ +/* -*- Mode: C; c-basic-offset: 4 -*- */ +%% +ignore + gtk_window_add_embedded_xid + gtk_window_remove_embedded_xid +%% +override gtk_window_list_toplevels noargs +static PyObject * +_wrap_gtk_window_list_toplevels(PyGObject *self) +{ + GList *list, *tmp; + PyObject *py_list; + PyObject *gtk_obj; + + list = gtk_window_list_toplevels(); + + if ((py_list = PyList_New(0)) == NULL) { + g_list_free(list); + return NULL; + } + for (tmp = list; tmp != NULL; tmp = tmp->next) { + gtk_obj = pygobject_new(G_OBJECT(tmp->data)); + if (gtk_obj == NULL) { + g_list_free(list); + Py_DECREF(py_list); + return NULL; + } + PyList_Append(py_list, gtk_obj); + Py_DECREF(gtk_obj); + } + g_list_free(list); + return py_list; +} +%% +override gtk_window_set_geometry_hints kwargs +static PyObject * +_wrap_gtk_window_set_geometry_hints(PyGObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "geometry_widget", "min_width", "min_height", + "max_width", "max_height", "base_width", + "base_height", "width_inc", "height_inc", + "min_aspect", "max_aspect", NULL }; + PyObject *py_geometry_widget = Py_None; + GtkWidget *geometry_widget = NULL; + gint min_width = -1, min_height = -1, max_width = -1, max_height = -1; + gint base_width = -1, base_height = -1, width_inc = -1, height_inc = -1; + gdouble min_aspect = -1.0, max_aspect = -1.0; + GdkGeometry geometry = { 0 }; + GdkWindowHints geom_mask = 0; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|Oiiiiiiiidd:GtkWindow.set_geometry_hints", kwlist, + &py_geometry_widget, &min_width, + &min_height, &max_width, &max_height, + &base_width, &base_height, &width_inc, + &height_inc, &min_aspect, &max_aspect)) + return NULL; + if (pygobject_check(py_geometry_widget, &PyGtkWidget_Type)) + geometry_widget = GTK_WIDGET(pygobject_get(py_geometry_widget)); + else if (py_geometry_widget != Py_None) { + PyErr_SetString(PyExc_TypeError, + "geometry_widget must be a GtkWidget or None"); + return NULL; + } + if (min_width >= 0 || min_height >= 0) { + geometry.min_width = MAX(min_width, 0); + geometry.min_height = MAX(min_height, 0); + geom_mask |= GDK_HINT_MIN_SIZE; + } + if (max_width >= 0 || max_height >= 0) { + geometry.max_width = MAX(max_width, 0); + geometry.max_height = MAX(max_height, 0); + geom_mask |= GDK_HINT_MAX_SIZE; + } + if (base_width >= 0 || base_height >= 0) { + geometry.base_width = MAX(base_width, 0); + geometry.base_height = MAX(base_height, 0); + geom_mask |= GDK_HINT_BASE_SIZE; + } + if (width_inc >= 0 || height_inc >= 0) { + geometry.width_inc = MAX(width_inc, 0); + geometry.height_inc = MAX(height_inc, 0); + geom_mask |= GDK_HINT_RESIZE_INC; + } + if (min_aspect >= 0.0 || max_aspect >= 0.0) { + if (min_aspect <= 0.0 || max_aspect <= 0.0) { + PyErr_SetString(PyExc_TypeError, "aspect ratios must be positive"); + return NULL; + } + geometry.min_aspect = min_aspect; + geometry.max_aspect = max_aspect; + geom_mask |= GDK_HINT_ASPECT; + } + gtk_window_set_geometry_hints(GTK_WINDOW(self->obj), geometry_widget, + &geometry, geom_mask); + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_window_get_position +static PyObject * +_wrap_gtk_window_get_position(PyGObject *self) +{ + gint root_x, root_y; + + gtk_window_get_position(GTK_WINDOW(self->obj), &root_x, &root_y); + return Py_BuildValue("(ii)", root_x, root_y); +} +%% +override gtk_window_get_size +static PyObject * +_wrap_gtk_window_get_size(PyGObject *self) +{ + gint width, height; + + gtk_window_get_size(GTK_WINDOW(self->obj), &width, &height); + return Py_BuildValue("(ii)", width, height); +} +%% +override gtk_window_get_default_size +static PyObject * +_wrap_gtk_window_get_default_size(PyGObject *self) +{ + gint width, height; + + gtk_window_get_default_size(GTK_WINDOW(self->obj), &width, &height); + return Py_BuildValue("(ii)", width, height); +} +%% +override gtk_window_get_frame_dimensions noargs +static PyObject * +_wrap_gtk_window_get_frame_dimensions(PyGObject *self) +{ + int left, top, right, bottom; + + gtk_window_get_frame_dimensions(GTK_WINDOW(self->obj), + &left, &top, &right, &bottom); + return Py_BuildValue("(iiii)", left, top, right, bottom); +} +%% +override gtk_widget_get_size_request noargs +static PyObject * +_wrap_gtk_widget_get_size_request(PyGObject *self) +{ + int width, height; + + gtk_widget_get_size_request(GTK_WIDGET(self->obj), &width, &height); + return Py_BuildValue("(ii)", width, height); +} +%% +override gtk_window_set_icon_list args +static PyObject * +_wrap_gtk_window_set_icon_list(PyGObject *self, PyObject *args) +{ + GList *icon_list = NULL; + PyObject *pyicon; + gint len, i; + + len = PyTuple_Size(args); + for (i = 0; i < len; i++) { + pyicon = PyTuple_GetItem(args, i); + if (!pygobject_check(pyicon, &PyGdkPixbuf_Type)) { + PyErr_SetString(PyExc_TypeError, + "icons must be GdkPixbufs"); + g_list_free(icon_list); + return NULL; + } + icon_list = g_list_prepend(icon_list, pygobject_get(pyicon)); + } + gtk_window_set_icon_list(GTK_WINDOW(self->obj), icon_list); + g_list_free(icon_list); + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_window_get_icon_list noargs +static PyObject * +_wrap_gtk_window_get_icon_list(PyGObject *self) +{ + GList *icon_list = NULL; + PyObject *pyicon; + + if ((icon_list = gtk_window_get_icon_list(GTK_WINDOW(self->obj)))) { + PyObject *py_list; + GList *tmp; + + if ((py_list = PyList_New(0)) == NULL) { + g_list_free(icon_list); + return NULL; + } + for (tmp = icon_list; tmp != NULL; tmp = tmp->next) { + pyicon = pygobject_new(G_OBJECT(tmp->data)); + + if (pyicon == NULL) { + g_list_free(icon_list); + Py_DECREF(py_list); + return NULL; + } + PyList_Append(py_list, pyicon); + Py_DECREF(pyicon); + } + g_list_free(icon_list); + return py_list; + } + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_window_set_default_icon_list args +static PyObject * +_wrap_gtk_window_set_default_icon_list(PyGObject *self, PyObject *args) +{ + GList *icon_list = NULL; + PyObject *pyicon; + gint len, i; + + len = PyTuple_Size(args); + for (i = 0; i < len; i++) { + pyicon = PyTuple_GetItem(args, i); + if (!pygobject_check(pyicon, &PyGdkPixbuf_Type)) { + PyErr_SetString(PyExc_TypeError, + "icons must be GdkPixbufs"); + g_list_free(icon_list); + return NULL; + } + icon_list = g_list_prepend(icon_list, pygobject_get(pyicon)); + } + gtk_window_set_default_icon_list(icon_list); + g_list_free(icon_list); + Py_INCREF(Py_None); + return Py_None; +} +%% +override gtk_window_get_default_icon_list noargs +static PyObject * +_wrap_gtk_window_get_default_icon_list(PyGObject *self) +{ + GList *icon_list = NULL; + PyObject *pyicon; + + if ((icon_list = gtk_window_get_default_icon_list())) { + PyObject *py_list; + GList *tmp; + + if ((py_list = PyList_New(0)) == NULL) { + g_list_free(icon_list); + return NULL; + } + for (tmp = icon_list; tmp != NULL; tmp = tmp->next) { + pyicon = pygobject_new(G_OBJECT(tmp->data)); + + if (pyicon == NULL) { + g_list_free(icon_list); + Py_DECREF(py_list); + return NULL; + } + PyList_Append(py_list, pyicon); + Py_DECREF(pyicon); + } + g_list_free(icon_list); + return py_list; + } + Py_INCREF(Py_None); + return Py_None; +} |