[pygtk/modernize-constructors] Modernize constructors of seven more types
- From: Paul Pogonyshev <paulp src gnome org>
- To: svn-commits-list gnome org
- Subject: [pygtk/modernize-constructors] Modernize constructors of seven more types
- Date: Fri, 12 Jun 2009 17:20:57 -0400 (EDT)
commit fc86afbcaab2f8403361962004a33647391ac0c3
Author: Paul Pogonyshev <pogonyshev gmx net>
Date: Sun May 31 19:10:08 2009 +0300
Modernize constructors of seven more types
Make and/or just mark constructors of gtk.ImageMenuItem,
gtk.LinkButton, gtk.TreeViewColumn, gtk.ListStore, gtk.TreeStore,
gtk.TextMark and gtk.MountOperation new-style. Part of bug #583777.
gtk/gtk-2.10.defs | 6 +++---
gtk/gtk-2.12.defs | 6 +++---
gtk/gtk-2.14.defs | 4 ++--
gtk/gtk.override | 22 ++++++++++------------
gtk/gtktreeview.override | 27 ++++++++++++++++-----------
5 files changed, 34 insertions(+), 31 deletions(-)
---
diff --git a/gtk/gtk-2.10.defs b/gtk/gtk-2.10.defs
index 3e354bd..69c7e0c 100644
--- a/gtk/gtk-2.10.defs
+++ b/gtk/gtk-2.10.defs
@@ -789,9 +789,9 @@
(c-name "gtk_link_button_new_with_label")
(is-constructor-of "GtkLinkButton")
(return-type "GtkWidget*")
- (parameters
- '("gchar*" "uri")
- '("gchar*" "label" (null-ok) (default "NULL"))
+ (properties
+ '("uri")
+ '("label" (default "NULL") (optional))
)
)
diff --git a/gtk/gtk-2.12.defs b/gtk/gtk-2.12.defs
index 6baea1a..564c5aa 100644
--- a/gtk/gtk-2.12.defs
+++ b/gtk/gtk-2.12.defs
@@ -898,9 +898,9 @@
(c-name "gtk_text_mark_new")
(is-constructor-of "GtkTextMark")
(return-type "GtkTextMark*")
- (parameters
- '("const-gchar*" "name")
- '("gboolean" "left_gravity")
+ (properties
+ '("name")
+ '("left_gravity")
)
)
diff --git a/gtk/gtk-2.14.defs b/gtk/gtk-2.14.defs
index e674fb6..5b46421 100644
--- a/gtk/gtk-2.14.defs
+++ b/gtk/gtk-2.14.defs
@@ -548,8 +548,8 @@
(c-name "gtk_mount_operation_new")
(is-constructor-of "GtkMountOperation")
(return-type "GMountOperation*")
- (parameters
- '("GtkWindow*" "parent" (null-ok) (default "NULL"))
+ (properties
+ '("parent" (default "NULL") (optional))
)
)
diff --git a/gtk/gtk.override b/gtk/gtk.override
index 8d7a0f5..d05239f 100644
--- a/gtk/gtk.override
+++ b/gtk/gtk.override
@@ -2048,6 +2048,8 @@ _wrap_gtk_radio_menu_item_new(PyGObject *self, PyObject *args,
%%
new-constructor GTK_TYPE_RADIO_MENU_ITEM
%%
+new-constructor GTK_TYPE_IMAGE_MENU_ITEM
+%%
override gtk_image_menu_item_new kwargs
static int
_wrap_gtk_image_menu_item_new(PyGObject *self, PyObject *args,PyObject *kwargs)
@@ -2064,24 +2066,20 @@ _wrap_gtk_image_menu_item_new(PyGObject *self, PyObject *args,PyObject *kwargs)
if (pygobject_check(py_accel_group, &PyGtkAccelGroup_Type))
accel_group = GTK_ACCEL_GROUP(pygobject_get(py_accel_group));
- if (stock_id)
- self->obj = (GObject *)gtk_image_menu_item_new_from_stock(stock_id,
- accel_group);
+ if (stock_id) {
+ pygobject_construct(self,
+ "label", stock_id,
+ "use-stock", TRUE,
+ "accel-group", accel_group,
+ NULL);
+ }
else
- self->obj = (GObject *)gtk_image_menu_item_new();
+ pygobject_construct(self, NULL);
if (!self->obj) {
PyErr_SetString(PyExc_RuntimeError, "could not create GtkImageMenuItem object");
return -1;
}
-
- if (pyg_type_from_object((PyObject *) self) != GTK_TYPE_IMAGE_MENU_ITEM) {
- PyErr_SetString(PyExc_RuntimeError, "__gobject_init__ must be used "
- "when subclassing gtk.ImageMenuItem");
- return -1;
- }
-
- pygobject_register_wrapper((PyObject *)self);
return 0;
}
%%
diff --git a/gtk/gtktreeview.override b/gtk/gtktreeview.override
index 05d93c9..2a101b1 100644
--- a/gtk/gtktreeview.override
+++ b/gtk/gtktreeview.override
@@ -72,6 +72,8 @@ ignore
gtk_tree_store_insert_with_values
gtk_tree_store_insert_with_valuesv
%%
+new-constructor GTK_TYPE_TREE_VIEW_COLUMN
+%%
override gtk_tree_view_column_new kwargs
static int
_wrap_gtk_tree_view_column_new(PyGObject *self, PyObject*args, PyObject*kwargs)
@@ -94,13 +96,13 @@ _wrap_gtk_tree_view_column_new(PyGObject *self, PyObject*args, PyObject*kwargs)
return -1;
}
}
- tvc = GTK_TREE_VIEW_COLUMN(
- g_object_new(pyg_type_from_object((PyObject *) self), NULL));
- if (title)
- gtk_tree_view_column_set_title(tvc, title);
+ pygobject_construct(self, "title", title, NULL);
+ tvc = GTK_TREE_VIEW_COLUMN(self->obj);
+
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);
@@ -111,6 +113,7 @@ _wrap_gtk_tree_view_column_new(PyGObject *self, PyObject*args, PyObject*kwargs)
"%s must be an integer column number", attr);
PyErr_SetString(PyExc_TypeError, err);
g_object_unref(tvc);
+ self->obj = NULL;
return -1;
}
@@ -123,8 +126,6 @@ _wrap_gtk_tree_view_column_new(PyGObject *self, PyObject*args, PyObject*kwargs)
PyInt_AsLong(item));
}
}
- self->obj = (GObject *)tvc;
- pygobject_register_wrapper((PyObject *)self);
return 0;
}
%%
@@ -1232,6 +1233,8 @@ _wrap_gtk_tree_sortable_set_default_sort_func(PyGObject *self, PyObject *args)
%%
ignore gtk_list_store_newv
%%
+new-constructor GTK_TYPE_LIST_STORE
+%%
override gtk_list_store_new
static int
_wrap_gtk_list_store_new(PyGObject *self, PyObject *args)
@@ -1256,15 +1259,16 @@ _wrap_gtk_list_store_new(PyGObject *self, PyObject *args)
return -1;
}
}
- self->obj = g_object_newv(pyg_type_from_object((PyObject *) self), 0, NULL);
+
+ pygobject_construct(self, NULL);
gtk_list_store_set_column_types(GTK_LIST_STORE(self->obj), 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;
}
%%
@@ -1631,6 +1635,8 @@ _wrap_gtk_list_store_reorder(PyGObject *self, PyObject *args)
%%
ignore gtk_tree_store_newv
%%
+new-constructor GTK_TYPE_TREE_STORE
+%%
override gtk_tree_store_new
static int
_wrap_gtk_tree_store_new(PyGObject *self, PyObject *args)
@@ -1655,16 +1661,15 @@ _wrap_gtk_tree_store_new(PyGObject *self, PyObject *args)
}
}
- self->obj = g_object_newv(pyg_type_from_object((PyObject *) self), 0, NULL);
+ pygobject_construct(self, NULL);
gtk_tree_store_set_column_types(GTK_TREE_STORE(self->obj), 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;
}
%%
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]