Do

Merge lp:~ballogy/do/gio-gnomedesktop-port into lp:do

Proposed by Balló György
Status: Merged
Merged at revision: 1379
Proposed branch: lp:~ballogy/do/gio-gnomedesktop-port
Merge into: lp:do
Diff against target: 245 lines (+123/-14)
8 files modified
Do.Platform.Linux/Do.Platform.Linux.dll.config.in (+1/-0)
Do.Platform.Linux/Makefile.am (+3/-1)
Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/SystemService.cs (+2/-1)
Do.Platform.Linux/src/Do.Universe/Desktop.cs (+76/-0)
Do.Platform.Linux/src/Do.Universe/DesktopThumbnailSize.cs (+16/-0)
Do.Platform.Linux/src/Do.Universe/FileItem.cs (+7/-5)
Makefile.am (+5/-0)
configure.ac (+13/-7)
To merge this branch: bzr merge lp:~ballogy/do/gio-gnomedesktop-port
Reviewer Review Type Date Requested Status
Do Core Team Pending
Review via email: mp+95842@code.launchpad.net

Commit message

Port from gnome-sharp and gnome-vfs-sharp to gio-sharp and gnome-desktop. Do not check rsvg2-sharp and wnck-sharp

Description of the change

This change removes the old, deprecated gnome-sharp and gnome-vfs-sharp dependencies, and replaces them with gio-sharp and gnome-desktop.

The thumbnail handling code was moved from libgnomeui to libgnome-desktop, but gnome-desktop-sharp is outdated and it doesn't contain the required bindings, so I generated them by the Gtk# code generator and included in the source code.

Also, it removes dependency checks for rsvg2-sharp and wnck-sharp. These libraries are not really used by gnome-do.

To post a comment you must log in.
Revision history for this message
Chris Halse Rogers (raof) wrote :

Thanks for your work! Looks good.

I've got two niggles:
1) I'd copy the gio dlls from the Makefile, rather than configure; otherwise you'll need to re-run configure after “make clean”. I'll fix this up myself before merging.
2) It'd be nice there was some documentation (or even a makefile target) to regenerate the binding glue; that's lower priority, and you can provide it later if you want.

Revision history for this message
Balló György (ballogy) wrote :

1) I didn't know this, I simply copied this part of code from the docky project.
2) I don't know how to make a proper makefile, but I used this process to generate the binding: https://github.com/City-busz/gnomedesktop-sharp

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Do.Platform.Linux/Do.Platform.Linux.dll.config.in'
2--- Do.Platform.Linux/Do.Platform.Linux.dll.config.in 2009-07-23 07:17:00 +0000
3+++ Do.Platform.Linux/Do.Platform.Linux.dll.config.in 2012-03-05 04:42:21 +0000
4@@ -1,3 +1,4 @@
5 <configuration>
6 <dllmap dll="libdo" target="@expanded_libdir@/@PACKAGE@/libdo.so"/>
7+ <dllmap dll="gnome-desktop-2" target="libgnome-desktop-2.so.17"/>
8 </configuration>
9
10=== modified file 'Do.Platform.Linux/Makefile.am'
11--- Do.Platform.Linux/Makefile.am 2011-10-10 02:55:57 +0000
12+++ Do.Platform.Linux/Makefile.am 2012-03-05 04:42:21 +0000
13@@ -27,6 +27,8 @@
14 src/Do.Platform/Do.Platform.Linux/KeyBindingService.cs \
15 src/Do.Universe/ApplicationItem.cs \
16 src/Do.Universe/CategoryItem.cs \
17+ src/Do.Universe/Desktop.cs \
18+ src/Do.Universe/DesktopThumbnailSize.cs \
19 src/Do.Universe/NullApplicationItem.cs \
20 src/Do.Universe/FileItem.cs \
21 src/Do.Universe/ApplicationItemSource.cs \
22@@ -54,7 +56,7 @@
23 Mono.Posix \
24 $(GTK_SHARP_20_LIBS) \
25 $(GNOME_KEYRING_SHARP_LIBS) \
26- $(GNOME_SHARP_20_LIBS) \
27+ $(GIO_SHARP_LIBS) \
28 $(GNOME_DESKTOP_SHARP_20_LIBS) \
29 $(GCONF_SHARP_20_LIBS) \
30 $(MONO_ADDINS_LIBS) \
31
32=== modified file 'Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/SystemService.cs'
33--- Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/SystemService.cs 2011-10-10 02:55:57 +0000
34+++ Do.Platform.Linux/src/Do.Platform/Do.Platform.Linux/SystemService.cs 2012-03-05 04:42:21 +0000
35@@ -166,7 +166,8 @@
36
37 string AutoStartUri {
38 get {
39- return Gnome.Vfs.Uri.GetUriFromLocalPath (AutoStartFileName);
40+ var uri = new Uri(AutoStartFileName).ToString();
41+ return uri;
42 }
43 }
44
45
46=== added file 'Do.Platform.Linux/src/Do.Universe/Desktop.cs'
47--- Do.Platform.Linux/src/Do.Universe/Desktop.cs 1970-01-01 00:00:00 +0000
48+++ Do.Platform.Linux/src/Do.Universe/Desktop.cs 2012-03-05 04:42:21 +0000
49@@ -0,0 +1,76 @@
50+// This file was generated by the Gtk# code generator.
51+// Any changes made will be lost if regenerated.
52+
53+namespace Gnome {
54+
55+ using System;
56+ using System.Runtime.InteropServices;
57+
58+#region Autogenerated code
59+ public class Desktop {
60+
61+ [DllImport("gnome-desktop-2")]
62+ static extern void gnome_desktop_prepend_terminal_to_vector(out int argc, IntPtr argv);
63+
64+ public static int PrependTerminalToVector(string argv) {
65+ int argc;
66+ gnome_desktop_prepend_terminal_to_vector(out argc, GLib.Marshaller.StringToPtrGStrdup(argv));
67+ return argc;
68+ }
69+
70+ [DllImport("gnome-desktop-2")]
71+ static extern bool gnome_desktop_thumbnail_has_uri(IntPtr pixbuf, IntPtr uri);
72+
73+ public static bool ThumbnailHasUri(Gdk.Pixbuf pixbuf, string uri) {
74+ IntPtr native_uri = GLib.Marshaller.StringToPtrGStrdup (uri);
75+ bool raw_ret = gnome_desktop_thumbnail_has_uri(pixbuf == null ? IntPtr.Zero : pixbuf.Handle, native_uri);
76+ bool ret = raw_ret;
77+ GLib.Marshaller.Free (native_uri);
78+ return ret;
79+ }
80+
81+ [DllImport("gnome-desktop-2")]
82+ static extern IntPtr gnome_desktop_thumbnail_scale_down_pixbuf(IntPtr pixbuf, int dest_width, int dest_height);
83+
84+ public static Gdk.Pixbuf ThumbnailScaleDownPixbuf(Gdk.Pixbuf pixbuf, int dest_width, int dest_height) {
85+ IntPtr raw_ret = gnome_desktop_thumbnail_scale_down_pixbuf(pixbuf == null ? IntPtr.Zero : pixbuf.Handle, dest_width, dest_height);
86+ Gdk.Pixbuf ret = GLib.Object.GetObject(raw_ret) as Gdk.Pixbuf;
87+ return ret;
88+ }
89+
90+ [DllImport("gnome-desktop-2")]
91+ static extern IntPtr gnome_desktop_thumbnail_path_for_uri(IntPtr uri, int size);
92+
93+ public static string ThumbnailPathForUri(string uri, Gnome.DesktopThumbnailSize size) {
94+ IntPtr native_uri = GLib.Marshaller.StringToPtrGStrdup (uri);
95+ IntPtr raw_ret = gnome_desktop_thumbnail_path_for_uri(native_uri, (int) size);
96+ string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
97+ GLib.Marshaller.Free (native_uri);
98+ return ret;
99+ }
100+
101+ [DllImport("gnome-desktop-2")]
102+ static extern bool gnome_desktop_thumbnail_is_valid(IntPtr pixbuf, IntPtr uri, IntPtr mtime);
103+
104+ public static bool ThumbnailIsValid(Gdk.Pixbuf pixbuf, string uri, System.DateTime mtime) {
105+ IntPtr native_uri = GLib.Marshaller.StringToPtrGStrdup (uri);
106+ bool raw_ret = gnome_desktop_thumbnail_is_valid(pixbuf == null ? IntPtr.Zero : pixbuf.Handle, native_uri, GLib.Marshaller.DateTimeTotime_t (mtime));
107+ bool ret = raw_ret;
108+ GLib.Marshaller.Free (native_uri);
109+ return ret;
110+ }
111+
112+ [DllImport("gnome-desktop-2")]
113+ static extern IntPtr gnome_desktop_thumbnail_md5(IntPtr uri);
114+
115+ public static string ThumbnailMd5(string uri) {
116+ IntPtr native_uri = GLib.Marshaller.StringToPtrGStrdup (uri);
117+ IntPtr raw_ret = gnome_desktop_thumbnail_md5(native_uri);
118+ string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
119+ GLib.Marshaller.Free (native_uri);
120+ return ret;
121+ }
122+
123+#endregion
124+ }
125+}
126
127=== added file 'Do.Platform.Linux/src/Do.Universe/DesktopThumbnailSize.cs'
128--- Do.Platform.Linux/src/Do.Universe/DesktopThumbnailSize.cs 1970-01-01 00:00:00 +0000
129+++ Do.Platform.Linux/src/Do.Universe/DesktopThumbnailSize.cs 2012-03-05 04:42:21 +0000
130@@ -0,0 +1,16 @@
131+// This file was generated by the Gtk# code generator.
132+// Any changes made will be lost if regenerated.
133+
134+namespace Gnome {
135+
136+ using System;
137+ using System.Runtime.InteropServices;
138+
139+#region Autogenerated code
140+ public enum DesktopThumbnailSize {
141+
142+ Normal,
143+ Large,
144+ }
145+#endregion
146+}
147
148=== modified file 'Do.Platform.Linux/src/Do.Universe/FileItem.cs'
149--- Do.Platform.Linux/src/Do.Universe/FileItem.cs 2009-08-10 01:01:47 +0000
150+++ Do.Platform.Linux/src/Do.Universe/FileItem.cs 2012-03-05 04:42:21 +0000
151@@ -63,8 +63,6 @@
152
153 static FileItem ()
154 {
155- Gnome.Vfs.Vfs.Initialize ();
156-
157 // Initialize SpecialFolderIcons by expanding paths in
158 // SpecialFolderIconsXDG.
159 //
160@@ -130,7 +128,11 @@
161 }
162
163 public string MimeType {
164- get { return Gnome.Vfs.Global.GetMimeType (Path); }
165+ get {
166+ GLib.File file = GLib.FileFactory.NewFromCommandlineArg(Path);
167+ var info = file.QueryInfo ("standard::content-type", GLib.FileQueryInfoFlags.None, null);
168+ return info.ContentType;
169+ }
170 }
171
172 public override string Icon {
173@@ -142,8 +144,8 @@
174 icon = MaybeGetSpecialFolderIconForPath (Path);
175 if (icon != null) return icon;
176
177- string large_thumb = Thumbnail.PathForUri (Uri, ThumbnailSize.Large);
178- string normal_thumb = Thumbnail.PathForUri (Uri, ThumbnailSize.Normal);
179+ string large_thumb = Desktop.ThumbnailPathForUri (Uri, DesktopThumbnailSize.Large);
180+ string normal_thumb = Desktop.ThumbnailPathForUri (Uri, DesktopThumbnailSize.Normal);
181
182 // Generating the thumbnail ourself is too slow for large files.
183 // Suggestion: generate thumbnails asynchronously. Banshee's
184
185=== modified file 'Makefile.am'
186--- Makefile.am 2011-10-29 06:48:52 +0000
187+++ Makefile.am 2012-03-05 04:42:21 +0000
188@@ -2,6 +2,11 @@
189
190 ACLOCAL_AMFLAGS = -I m4 -I m4/shamrock
191
192+# Install copied assemblies to our libdir
193+copiedlibsdir = $(pkglibdir)
194+copiedlibs_DATA = \
195+ $(GIO_SHARP_ASSEMBLIES)
196+
197 SUBDIRS = \
198 . \
199 data \
200
201=== modified file 'configure.ac'
202--- configure.ac 2012-03-04 07:46:19 +0000
203+++ configure.ac 2012-03-05 04:42:21 +0000
204@@ -60,17 +60,26 @@
205 PKG_CHECK_MODULES([GCONF_SHARP_20], [gconf-sharp-2.0])
206 PKG_CHECK_MODULES([GLADE_SHARP_20], [glade-sharp-2.0])
207 PKG_CHECK_MODULES([GLIB_SHARP_20], [glib-sharp-2.0])
208+
209+dnl gio-sharp is an unstable api library
210+PKG_CHECK_MODULES([GIO_SHARP], [gio-sharp-2.0])
211+files="`$PKG_CONFIG --variable=Libraries gio-sharp-2.0`"
212+for file in $files; do
213+ [ mkdir -p $top_srcdir/build ] && [ cp -vu $file $top_srcdir/build/ ]
214+ GIO_SHARP_ASSEMBLIES="$GIO_SHARP_ASSEMBLIES $top_srcdir/build/$(basename $file)"
215+ GIO_SHARP_LIBS="$GIO_SHARP_LIBS -r:$top_srcdir/build/$(basename $file)"
216+ [[ -r "$file.config" ]] && [ mkdir -p $top_srcdir/build ] && [ cp -vu $file.config $top_srcdir/build/ ]
217+ [[ -r "$file.config" ]] && GIO_SHARP_ASSEMBLIES="$GIO_SHARP_ASSEMBLIES $top_srcdir/build/$(basename $file).config"
218+done
219+AC_SUBST([GIO_SHARP_ASSEMBLIES])
220+
221 PKG_CHECK_MODULES([GNOME_DESKTOP_SHARP_20], [gnome-desktop-sharp-2.0])
222 PKG_CHECK_MODULES([GNOME_KEYRING_SHARP], [gnome-keyring-sharp-1.0])
223-PKG_CHECK_MODULES([GNOME_SHARP_20], [gnome-sharp-2.0])
224-PKG_CHECK_MODULES([GNOME_VFS_SHARP_20], [gnome-vfs-sharp-2.0])
225 PKG_CHECK_MODULES([GTK_SHARP_20], [gtk-sharp-2.0])
226-PKG_CHECK_MODULES([LIBRSVG_SHARP], [rsvg2-sharp-2.0])
227 PKG_CHECK_MODULES([MONO_ADDINS], [mono-addins])
228 PKG_CHECK_MODULES([MONO_ADDINS_GUI], [mono-addins-gui])
229 PKG_CHECK_MODULES([MONO_ADDINS_SETUP], [mono-addins-setup])
230 PKG_CHECK_MODULES([NOTIFY_SHARP], [notify-sharp])
231-PKG_CHECK_MODULES([WNCK_SHARP_10], [wnck-sharp-1.0])
232
233
234 AC_SUBST([GCONF_SHARP_20_LIBS])
235@@ -78,10 +87,7 @@
236 AC_SUBST([GLIB_SHARP_20_LIBS])
237 AC_SUBST([GNOME_DESKTOP_SHARP_20_LIBS])
238 AC_SUBST([GNOME_KEYRING_SHARP_LIBS])
239-AC_SUBST([GNOME_SHARP_20_LIBS])
240-AC_SUBST([GNOME_VFS_SHARP_20_LIBS])
241 AC_SUBST([GTK_SHARP_20_LIBS])
242-AC_SUBST([LIBRSVG_SHARP_LIBS])
243 AC_SUBST([MONO_ADDINS_LIBS])
244 AC_SUBST([MONO_ADDINS_GUI_LIBS])
245 AC_SUBST([MONO_ADDINS_SETUP_LIBS])