Merge lp:~rodrigo-moya/libubuntuone/python-bindings into lp:libubuntuone

Proposed by Rodrigo Moya
Status: Merged
Approved by: Rodrigo Moya
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~rodrigo-moya/libubuntuone/python-bindings
Merge into: lp:libubuntuone
Diff against target: 268 lines (+186/-5)
9 files modified
Makefile.am (+1/-1)
bindings/Makefile.am (+1/-0)
bindings/python/Makefile.am (+32/-0)
bindings/python/ubuntuone.defs (+55/-0)
bindings/python/ubuntuone.override (+14/-0)
bindings/python/ubuntuonemodule.c (+21/-0)
configure.ac (+39/-0)
libubuntuone/u1-contacts-picker.c (+16/-0)
libubuntuone/u1-contacts-picker.h (+7/-4)
To merge this branch: bzr merge lp:~rodrigo-moya/libubuntuone/python-bindings
Reviewer Review Type Date Requested Status
Stuart Langridge (community) Approve
Review via email: mp+16543@code.launchpad.net

Commit message

Added python bindings for the 2 widgets in the library

To post a comment you must log in.
Revision history for this message
Rodrigo Moya (rodrigo-moya) wrote :

Added python bindings for the 2 widgets in the library

10. By Rodrigo Moya

Fixed copy/paste error

Revision history for this message
Stuart Langridge (sil) wrote :

Works for me! Adding compilation/running instructions might be useful.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile.am'
2--- Makefile.am 2009-11-26 12:12:21 +0000
3+++ Makefile.am 2009-12-24 15:40:25 +0000
4@@ -1,1 +1,1 @@
5-SUBDIRS = libubuntuone tests
6+SUBDIRS = libubuntuone tests bindings
7
8=== added directory 'bindings'
9=== added file 'bindings/Makefile.am'
10--- bindings/Makefile.am 1970-01-01 00:00:00 +0000
11+++ bindings/Makefile.am 2009-12-24 15:40:25 +0000
12@@ -0,0 +1,1 @@
13+SUBDIRS = python
14\ No newline at end of file
15
16=== added directory 'bindings/python'
17=== added file 'bindings/python/Makefile.am'
18--- bindings/python/Makefile.am 1970-01-01 00:00:00 +0000
19+++ bindings/python/Makefile.am 2009-12-24 15:40:25 +0000
20@@ -0,0 +1,32 @@
21+INCLUDES = \
22+ -I$(top_srcdir)/libubuntuone \
23+ $(LIBUBUNTUONE_CFLAGS) \
24+ $(PYGTK_CFLAGS) \
25+ $(PYTHON_CFLAGS)
26+
27+defsdir = $(datadir)/ubuntuone/1.0/defs
28+defs_DATA = ubuntuone.defs
29+
30+pythondir = $(libdir)/python2.5/site-packages
31+python_LTLIBRARIES = ubuntuone.la
32+
33+ubuntuone.c: ubuntuone.defs ubuntuone.override
34+ $(PYGNOME_CODEGEN) \
35+ --register $(PYGTK_DEFSDIR)/pango-types.defs \
36+ --register $(PYGTK_DEFSDIR)/gdk-types.defs \
37+ --register $(PYGTK_DEFSDIR)/gtk-types.defs \
38+ --prefix ubuntuone \
39+ --override ubuntuone.override \
40+ ubuntuone.defs > $@
41+
42+ubuntuone_la_SOURCES = \
43+ ubuntuone.c \
44+ ubuntuonemodule.c
45+ubuntuone_la_LDFLAGS = -module --avoid-version
46+ubuntuone_la_LIBADD = \
47+ $(LIBUBUNTUONE_LIBS) \
48+ $(PYGTK_LIBS) \
49+ $(PYTHON_LDFLAGS) \
50+ $(top_builddir)/libubuntuone/libubuntuone.la
51+
52+CLEANFILES = ubuntuone.c
53\ No newline at end of file
54
55=== added file 'bindings/python/ubuntuone.defs'
56--- bindings/python/ubuntuone.defs 1970-01-01 00:00:00 +0000
57+++ bindings/python/ubuntuone.defs 2009-12-24 15:40:25 +0000
58@@ -0,0 +1,55 @@
59+;; -*- scheme -*-
60+
61+; object definitions ...
62+(define-object ContactsPicker
63+ (in-module "U1")
64+ (parent "GtkVBox")
65+ (c-name "U1ContactsPicker")
66+ (gtype-id "U1_TYPE_CONTACTS_PICKER")
67+)
68+
69+(define-object MusicStore
70+ (in-module "U1")
71+ (parent "GtkVBox")
72+ (c-name "U1MusicStore")
73+ (gtype-id "U1_TYPE_MUSIC_STORE")
74+)
75+
76+;; Enumerations and flags ...
77+
78+
79+;; From u1-contacts-picker.h
80+
81+(define-function contacts_picker_get_type
82+ (c-name "u1_contacts_picker_get_type")
83+ (return-type "GType")
84+)
85+
86+(define-function u1_contacts_picker_new
87+ (c-name "u1_contacts_picker_new")
88+ (is-constructor-of "U1ContactsPicker")
89+ (return-type "GtkWidget*")
90+)
91+
92+(define-method get_contacts_count
93+ (of-object "U1ContactsPicker")
94+ (c-name "u1_contacts_picker_get_contacts_count")
95+ (return-type "guint")
96+)
97+
98+
99+
100+;; From u1-music-store.h
101+
102+(define-function music_store_get_type
103+ (c-name "u1_music_store_get_type")
104+ (return-type "GType")
105+)
106+
107+(define-function u1_music_store_new
108+ (c-name "u1_music_store_new")
109+ (is-constructor-of "U1MusicStore")
110+ (return-type "GtkWidget*")
111+)
112+
113+
114
115=== added file 'bindings/python/ubuntuone.override'
116--- bindings/python/ubuntuone.override 1970-01-01 00:00:00 +0000
117+++ bindings/python/ubuntuone.override 2009-12-24 15:40:25 +0000
118@@ -0,0 +1,14 @@
119+%%
120+headers
121+#include <Python.h>
122+#include "pygobject.h"
123+#include "u1-contacts-picker.h"
124+#include "u1-music-store.h"
125+%%
126+modulename ubuntuone
127+%%
128+import gtk.VBox as PyGtkVBox_Type
129+%%
130+ignore-glob
131+ *_get_type
132+%%
133
134=== added file 'bindings/python/ubuntuonemodule.c'
135--- bindings/python/ubuntuonemodule.c 1970-01-01 00:00:00 +0000
136+++ bindings/python/ubuntuonemodule.c 2009-12-24 15:40:25 +0000
137@@ -0,0 +1,21 @@
138+#include <pygobject.h>
139+
140+void trayicon_register_classes (PyObject *d);
141+extern PyMethodDef ubuntuone_functions[];
142+
143+DL_EXPORT(void)
144+initubuntuone(void)
145+{
146+ PyObject *m, *d;
147+
148+ init_pygobject ();
149+
150+ m = Py_InitModule ("ubuntuone", ubuntuone_functions);
151+ d = PyModule_GetDict (m);
152+
153+ ubuntuone_register_classes (d);
154+
155+ if (PyErr_Occurred ()) {
156+ Py_FatalError ("can't initialise module ubuntuone");
157+ }
158+}
159
160=== modified file 'configure.ac'
161--- configure.ac 2009-12-04 13:22:36 +0000
162+++ configure.ac 2009-12-24 15:40:25 +0000
163@@ -42,11 +42,50 @@
164 DISTCHECK_CONFIGURE_FLAGS="--enable-gtk-doc"
165 AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
166
167+dnl Checks for Python bindings
168+AM_PATH_PYTHON(2.5)
169+AC_PATH_PROG(PYTHON_CONFIG, python-config, no)
170+if test "x$PYTHON_CONFIG" = "xno"; then
171+ AC_MSG_ERROR(could not find python-config script)
172+else
173+ PYTHON_CFLAGS=`$PYTHON_CONFIG --cflags`
174+ PYTHON_LDFLAGS=`$PYTHON_CONFIG --ldflags`
175+ AC_SUBST(PYTHON_CFLAGS)
176+ AC_SUBST(PYTHON_LDFLAGS)
177+fi
178+
179+PKG_CHECK_MODULES(PYGTK, pygtk-2.0)
180+AC_SUBST(PYGTK_CFLAGS)
181+AC_SUBST(PYGTK_LIBS)
182+
183+dnl Check for .defs pygtk dir
184+AC_MSG_CHECKING(for pygtk defs)
185+PYGTK_DEFSDIR=`$PKG_CONFIG --variable=defsdir pygtk-2.0`
186+AC_SUBST(PYGTK_DEFSDIR)
187+AC_MSG_RESULT($PYGTK_DEFSDIR)
188+
189+dnl check for codegen script
190+AC_PATH_PROG(PYGOBJECT_CODEGEN, pygobject-codegen-2.0, no)
191+if test "x$PYGOBJECT_CODEGEN" = xno; then
192+ dnl This is for compat with older releases when codegen was shipped
193+ dnl in pygtk. It should be removed in future releases.
194+ AC_PATH_PROG(PYGTK_CODEGEN, pygtk-codegen-2.0, no)
195+ if test "x$PYGTK_CODEGEN" = xno; then
196+ AC_MSG_ERROR(could not find pygobject-codegen-2.0 script)
197+ else
198+ AC_SUBST(PYGNOME_CODEGEN, $PYGTK_CODEGEN)
199+ fi
200+else
201+ AC_SUBST(PYGNOME_CODEGEN, $PYGOBJECT_CODEGEN)
202+fi
203+
204 AC_OUTPUT([
205 Makefile
206 libubuntuone.pc
207 libubuntuone/Makefile
208 tests/Makefile
209+bindings/Makefile
210+bindings/python/Makefile
211 ])
212
213 AC_MSG_NOTICE([
214
215=== modified file 'libubuntuone/u1-contacts-picker.c'
216--- libubuntuone/u1-contacts-picker.c 2009-12-09 13:25:49 +0000
217+++ libubuntuone/u1-contacts-picker.c 2009-12-24 15:40:25 +0000
218@@ -145,3 +145,19 @@
219
220 return (GtkWidget *) picker;
221 }
222+
223+/**
224+ * u1_contacts_picker_get_contacts_count:
225+ * @picker: A #U1ContactsPicker widget
226+ *
227+ * Return the number of contacts being displayed by the contacts picker.
228+ *
229+ * Return value: Number of contacts being displayed.
230+ */
231+guint
232+u1_contacts_picker_get_contacts_count (U1ContactsPicker *picker)
233+{
234+ g_return_val_if_fail (U1_IS_CONTACTS_PICKER (picker), 0);
235+
236+ return gtk_tree_model_iter_n_children (gtk_icon_view_get_model (picker->priv->icon_view), NULL);
237+}
238
239=== modified file 'libubuntuone/u1-contacts-picker.h'
240--- libubuntuone/u1-contacts-picker.h 2009-12-04 13:22:36 +0000
241+++ libubuntuone/u1-contacts-picker.h 2009-12-24 15:40:25 +0000
242@@ -33,20 +33,23 @@
243 #define U1_IS_CONTACTS_PICKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), U1_TYPE_CONTACTS_PICKER))
244 #define U1_CONTACTS_PICKER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), U1_TYPE_CONTACTS_PICKER, U1ContactsPickerClass))
245
246+typedef struct _U1ContactsPicker U1ContactsPicker;
247+typedef struct _U1ContactsPickerClass U1ContactsPickerClass;
248 typedef struct _U1ContactsPickerPrivate U1ContactsPickerPrivate;
249
250-typedef struct {
251+struct _U1ContactsPicker {
252 GtkVBox parent;
253 U1ContactsPickerPrivate *priv;
254-} U1ContactsPicker;
255+};
256
257-typedef struct {
258+struct _U1ContactsPickerClass {
259 GtkVBoxClass parent_class;
260-} U1ContactsPickerClass;
261+};
262
263 GType u1_contacts_picker_get_type (void);
264
265 GtkWidget *u1_contacts_picker_new (void);
266+guint u1_contacts_picker_get_contacts_count (U1ContactsPicker *picker);
267
268 G_END_DECLS
269

Subscribers

People subscribed via source and target branches