Merge lp:~tuxator/midori/apple into lp:~kalikiana/midori/apple

Proposed by Paweł Forysiuk
Status: Merged
Merge reported by: Cris Dywan
Merged at revision: not available
Proposed branch: lp:~tuxator/midori/apple
Merge into: lp:~kalikiana/midori/apple
Diff against target: 174 lines (+86/-4)
6 files modified
extensions/apps.vala (+14/-3)
midori/midori.vapi (+3/-0)
midori/sokoke.c (+61/-0)
midori/sokoke.h (+5/-0)
midori/wscript_build (+1/-1)
wscript (+2/-0)
To merge this branch: bzr merge lp:~tuxator/midori/apple
Reviewer Review Type Date Requested Status
Cris Dywan Approve
Review via email: mp+171296@code.launchpad.net
To post a comment you must log in.
lp:~tuxator/midori/apple updated
6201. By Paweł Forysiuk

Use double backslash for folder delimiter in webapp destkop file on win32

6202. By Paweł Forysiuk

Merge lp:midori

6203. By Paweł Forysiuk

Add quote and double slashes unconditionally on win32 for webapp uris

6204. By Paweł Forysiuk

Check for launcher type when creating lnk file and set shortcut argument accordingly

6205. By Paweł Forysiuk

Revert merge lp:midori to make patch look sane again

6206. By Paweł Forysiuk

Read change from 6203 and 6204

6207. By Paweł Forysiuk

Revert accidental delete

Revision history for this message
Cris Dywan (kalikiana) wrote :

Nice stuff! Merged.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'extensions/apps.vala'
2--- extensions/apps.vala 2013-06-27 21:37:27 +0000
3+++ extensions/apps.vala 2013-06-28 14:20:33 +0000
4@@ -22,10 +22,16 @@
5
6 internal static async void create (string prefix, GLib.File folder, string uri, string title, Gtk.Widget proxy) {
7 /* Strip LRE leading character and / */
8- string exec = prefix + uri;
9 string name = title.delimit ("‪/", ' ').strip();
10 string filename = Midori.Download.clean_filename (name);
11-
12+ string exec;
13+#if HAVE_WIN32
14+ string doubleslash_uri = uri.replace ("\\", "\\\\");
15+ string quoted_uri = GLib.Shell.quote (doubleslash_uri);
16+ exec = prefix + quoted_uri;
17+#else
18+ exec = prefix + uri;
19+#endif
20 try {
21 folder.make_directory_with_parents (null);
22 }
23@@ -39,7 +45,12 @@
24 var pixbuf = Midori.Paths.get_icon (uri, null);
25 string icon_filename = folder.get_child ("icon.png").get_path ();
26 pixbuf.save (icon_filename, "png", null, "compression", "7", null);
27+#if HAVE_WIN32
28+ string doubleslash_icon = icon_filename.replace ("\\", "\\\\");
29+ icon_name = doubleslash_icon;
30+#else
31 icon_name = icon_filename;
32+#endif
33 }
34 catch (Error error) {
35 GLib.warning (_("Failed to fetch application icon in %s: %s"), folder.get_path (), error.message);
36@@ -61,7 +72,7 @@
37 yield stream.write_async (contents.data);
38 // Create a launcher/ menu
39 #if HAVE_WIN32
40- // TODO: implement Win32 version
41+ Midori.Sokoke.create_win32_desktop_lnk (prefix, title, uri);
42 #else
43 var data_dir = File.new_for_path (Midori.Paths.get_user_data_dir ());
44 yield file.copy_async (data_dir.get_child ("applications").get_child (filename + ".desktop"),
45
46=== modified file 'midori/midori.vapi'
47--- midori/midori.vapi 2013-05-28 20:02:29 +0000
48+++ midori/midori.vapi 2013-06-28 14:20:33 +0000
49@@ -252,6 +252,9 @@
50 [CCode (cheader_filename = "midori/sokoke.h", lower_case_cprefix = "sokoke_")]
51 namespace Sokoke {
52 public static uint gtk_action_count_modifiers (Gtk.Action action);
53+ #if HAVE_WIN32
54+ public static void create_win32_desktop_lnk (string prefix, string title, string uri);
55+ #endif
56 }
57 }
58
59
60=== modified file 'midori/sokoke.c'
61--- midori/sokoke.c 2013-05-27 00:00:58 +0000
62+++ midori/sokoke.c 2013-06-28 14:20:33 +0000
63@@ -34,6 +34,11 @@
64 #include <glib/gstdio.h>
65 #include "katze/katze.h"
66
67+#ifdef G_OS_WIN32
68+#include <windows.h>
69+#include <shlobj.h>
70+#endif
71+
72 static gchar*
73 sokoke_js_string_utf8 (JSStringRef js_string)
74 {
75@@ -1148,3 +1153,59 @@
76 return entry;
77 }
78
79+#ifdef G_OS_WIN32
80+void
81+sokoke_create_win32_desktop_lnk (gchar* prefix, gchar* title, gchar* uri)
82+{
83+ gchar* exec_dir, *exec_path, *argument;
84+ gchar* filename, *lnk_file, *lnk_path;
85+ gchar* launcher_type;
86+
87+ WCHAR desktop_dir[MAX_PATH];
88+ WCHAR w[MAX_PATH];
89+
90+ IShellLink* pShellLink;
91+ IPersistFile* pPersistFile;
92+
93+ /* Retrive current path of User's Desktop directory, could be moved / on different partition */
94+ SHGetFolderPath (NULL, CSIDL_DESKTOPDIRECTORY, NULL, SHGFP_TYPE_CURRENT, &desktop_dir);
95+ /* CSIDL_PROGRAMS for "start menu -> programs" instead - needs saner/shorter filename */
96+
97+ filename = midori_download_clean_filename (title);
98+ lnk_file = g_strconcat (filename, ".lnk", NULL);
99+ lnk_path = g_build_filename (desktop_dir, lnk_file, NULL);
100+
101+ exec_dir = g_win32_get_package_installation_directory_of_module (NULL);
102+ exec_path = g_build_filename (exec_dir, "bin", "midori.exe", NULL);
103+
104+ if (g_str_has_suffix (prefix, " -a "))
105+ launcher_type = "-a";
106+ else if (g_str_has_suffix (prefix, " -c "))
107+ launcher_type = "-c";
108+
109+ argument = g_strdup_printf ("%s \"%s\"", launcher_type, uri);
110+
111+ /* Create link */
112+ CoCreateInstance (&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLink, (LPVOID *)&pShellLink);
113+ pShellLink->lpVtbl->SetPath (pShellLink, exec_path);
114+ pShellLink->lpVtbl->SetArguments (pShellLink, argument);
115+ /* TODO: support adding site favicon as webapp icon */
116+ /* pShellLink->lpVtbl->SetIconLocation (pShellLink, icon_path, icon_index); */
117+
118+ /* Save link */
119+ pShellLink->lpVtbl->QueryInterface (pShellLink, &IID_IPersistFile, (LPVOID *)&pPersistFile);
120+ MultiByteToWideChar (CP_UTF8, 0, lnk_path, -1, w, MAX_PATH);
121+ pPersistFile->lpVtbl->Save (pPersistFile, w, TRUE);
122+
123+ pPersistFile->lpVtbl->Release (pPersistFile);
124+ pShellLink->lpVtbl->Release (pShellLink);
125+
126+ g_free (exec_dir);
127+ g_free (exec_path);
128+ g_free (argument);
129+ g_free (filename);
130+ g_free (lnk_file);
131+ g_free (lnk_path);
132+ g_free (launcher_type);
133+}
134+#endif
135
136=== modified file 'midori/sokoke.h'
137--- midori/sokoke.h 2013-04-11 20:38:19 +0000
138+++ midori/sokoke.h 2013-06-28 14:20:33 +0000
139@@ -128,4 +128,9 @@
140 GtkWidget*
141 sokoke_search_entry_new (const gchar* placeholder_text);
142
143+#ifdef G_OS_WIN32
144+void
145+sokoke_create_win32_desktop_lnk (gchar* prefix, gchar* title, gchar* uri);
146+#endif
147+
148 #endif /* !__SOKOKE_H__ */
149
150=== modified file 'midori/wscript_build'
151--- midori/wscript_build 2013-05-14 17:52:15 +0000
152+++ midori/wscript_build 2013-06-28 14:20:33 +0000
153@@ -9,7 +9,7 @@
154 progressive = True
155 libs = 'M UNIQUE LIBSOUP GMODULE GTHREAD LIBIDN GIO GTK SQLITE ' \
156 'LIBNOTIFY WEBKIT JAVASCRIPTCOREGTK LIBXML X11 XSS WS2_32 ' \
157- 'GCR GRANITE ZEITGEIST'
158+ 'GCR GRANITE ZEITGEIST OLE32 UUID '
159
160 if Options.commands['build'] or Options.commands['check']:
161 blddir = str (bld.bldnode)[6:] # dir:// + absolute path
162
163=== modified file 'wscript'
164--- wscript 2013-06-03 19:37:36 +0000
165+++ wscript 2013-06-28 14:20:33 +0000
166@@ -326,6 +326,8 @@
167 conf.check (function_name='inet_addr', header_name='sys/types.h sys/socket.h netinet/in.h arpa/inet.h')
168 conf.define ('HAVE_OSX', int(sys.platform == 'darwin'))
169 if Options.platform == 'win32':
170+ conf.check (lib='ole32')
171+ conf.check (lib='uuid')
172 conf.env.append_value ('LINKFLAGS', '-mwindows')
173 conf.env.append_value ('program_LINKFLAGS', ['-Wl,--out-implib=default/midori/libmidori.a', '-Wl,--export-all-symbols'])
174 else:

Subscribers

People subscribed via source and target branches

to all changes: