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

Proposed by Paweł Forysiuk
Status: Merged
Merged at revision: 6208
Proposed branch: lp:~tuxator/midori/apple-2
Merge into: lp:~kalikiana/midori/apple
Diff against target: 113 lines (+19/-20)
4 files modified
extensions/apps.vala (+8/-6)
midori/midori.vapi (+2/-2)
midori/sokoke.c (+7/-10)
midori/sokoke.h (+2/-2)
To merge this branch: bzr merge lp:~tuxator/midori/apple-2
Reviewer Review Type Date Requested Status
Cris Dywan Needs Fixing
Review via email: mp+173028@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Cris Dywan (kalikiana) wrote :

../extensions/apps.vala:26.20-26.67: warning: local variable `filename' declared but never used

It'd be good to converge win32 and linux code to have a get_launcher_filename() function used in both places instead of sokoke. There's no win32 so it doesn't need to be in sokoke.

review: Needs Fixing
lp:~tuxator/midori/apple-2 updated
6208. By Paweł Forysiuk

Don't needlessly recompute filename from launcher title

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-29 22:12:13 +0000
3+++ extensions/apps.vala 2013-07-04 19:59:29 +0000
4@@ -74,7 +74,7 @@
5 yield stream.write_async (contents.data);
6 // Create a launcher/ menu
7 #if HAVE_WIN32
8- Midori.Sokoke.create_win32_desktop_lnk (prefix, title, uri);
9+ Midori.Sokoke.create_win32_desktop_lnk (prefix, filename, uri);
10 #else
11 var data_dir = File.new_for_path (Midori.Paths.get_user_data_dir ());
12 yield file.copy_async (data_dir.get_child ("applications").get_child (filename + ".desktop"),
13@@ -191,14 +191,16 @@
14 try {
15 launcher.file.trash (null);
16 store.remove (iter);
17+
18+ string filename = Midori.Download.clean_filename (launcher.name);
19 #if HAVE_WIN32
20- string filename = Midori.Download.clean_filename (launcher.name);
21- var lnk_filename = Midori.Sokoke.get_win32_desktop_lnk_path_from_title (filename);
22- var lnk_file = File.new_for_path (lnk_filename);
23- lnk_file.trash ();
24+ string lnk_filename = Midori.Sokoke.get_win32_desktop_lnk_path_for_filename (filename);
25+ if (Posix.access (lnk_filename, Posix.F_OK) == 0) {
26+ var lnk_file = File.new_for_path (lnk_filename);
27+ lnk_file.trash ();
28+ }
29 #else
30 var data_dir = File.new_for_path (Midori.Paths.get_user_data_dir ());
31- string filename = Midori.Download.clean_filename (launcher.name);
32 data_dir.get_child ("applications").get_child (filename + ".desktop").trash ();
33 #endif
34 }
35
36=== modified file 'midori/midori.vapi'
37--- midori/midori.vapi 2013-06-29 22:12:13 +0000
38+++ midori/midori.vapi 2013-07-04 19:59:29 +0000
39@@ -253,8 +253,8 @@
40 namespace Sokoke {
41 public static uint gtk_action_count_modifiers (Gtk.Action action);
42 #if HAVE_WIN32
43- public static string get_win32_desktop_lnk_path_from_title (string title);
44- public static void create_win32_desktop_lnk (string prefix, string title, string uri);
45+ public static string get_win32_desktop_lnk_path_for_filename (string filename);
46+ public static void create_win32_desktop_lnk (string prefix, string filename, string uri);
47 #endif
48 }
49 }
50
51=== modified file 'midori/sokoke.c'
52--- midori/sokoke.c 2013-06-29 22:12:13 +0000
53+++ midori/sokoke.c 2013-07-04 19:59:29 +0000
54@@ -1155,27 +1155,24 @@
55
56 #ifdef G_OS_WIN32
57 gchar*
58-sokoke_get_win32_desktop_lnk_path_from_title (gchar* title)
59+sokoke_get_win32_desktop_lnk_path_for_filename (gchar* filename)
60 {
61- WCHAR desktop_dir[MAX_PATH];
62- gchar* filename, *lnk_path, *lnk_file;
63+ const gchar* desktop_dir;
64+ gchar* lnk_path, *lnk_file;
65
66- /* Retrive current path of User's Desktop directory, could be moved / on different partition */
67- SHGetFolderPath (NULL, CSIDL_DESKTOPDIRECTORY, NULL, SHGFP_TYPE_CURRENT, (LPSTR)&desktop_dir);
68 /* CSIDL_PROGRAMS for "start menu -> programs" instead - needs saner/shorter filename */
69+ desktop_dir = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
70
71- filename = midori_download_clean_filename (title);
72 lnk_file = g_strconcat (filename, ".lnk", NULL);
73- lnk_path = g_build_filename ((gchar*)desktop_dir, lnk_file, NULL);
74+ lnk_path = g_build_filename (desktop_dir, lnk_file, NULL);
75
76- g_free (filename);
77 g_free (lnk_file);
78
79 return lnk_path;
80 }
81
82 void
83-sokoke_create_win32_desktop_lnk (gchar* prefix, gchar* title, gchar* uri)
84+sokoke_create_win32_desktop_lnk (gchar* prefix, gchar* filename, gchar* uri)
85 {
86 WCHAR w[MAX_PATH];
87
88@@ -1203,7 +1200,7 @@
89 /* pShellLink->lpVtbl->SetIconLocation (pShellLink, icon_path, icon_index); */
90
91 /* Save link */
92- lnk_path = sokoke_get_win32_desktop_lnk_path_from_title (title);
93+ lnk_path = sokoke_get_win32_desktop_lnk_path_for_filename (filename);
94 pShellLink->lpVtbl->QueryInterface (pShellLink, &IID_IPersistFile, (LPVOID *)&pPersistFile);
95 MultiByteToWideChar (CP_UTF8, 0, lnk_path, -1, w, MAX_PATH);
96 pPersistFile->lpVtbl->Save (pPersistFile, w, TRUE);
97
98=== modified file 'midori/sokoke.h'
99--- midori/sokoke.h 2013-06-29 22:12:13 +0000
100+++ midori/sokoke.h 2013-07-04 19:59:29 +0000
101@@ -130,10 +130,10 @@
102
103 #ifdef G_OS_WIN32
104 gchar*
105-sokoke_get_win32_desktop_lnk_path_from_title (gchar* title);
106+sokoke_get_win32_desktop_lnk_path_for_filename (gchar* filename);
107
108 void
109-sokoke_create_win32_desktop_lnk (gchar* prefix, gchar* title, gchar* uri);
110+sokoke_create_win32_desktop_lnk (gchar* prefix, gchar* filename, gchar* uri);
111 #endif
112
113 #endif /* !__SOKOKE_H__ */

Subscribers

People subscribed via source and target branches

to all changes: