Merge lp:~kalikiana/midori/apps into lp:midori

Proposed by Cris Dywan
Status: Merged
Approved by: André Stösel
Approved revision: no longer in the source branch.
Merged at revision: 6178
Proposed branch: lp:~kalikiana/midori/apps
Merge into: lp:midori
Diff against target: 403 lines (+86/-37)
10 files modified
extensions/apps.vala (+41/-9)
katze/midori-paths.vala (+10/-1)
midori/main.c (+2/-2)
midori/midori-frontend.c (+7/-10)
midori/midori-frontend.h (+1/-3)
midori/midori-session.c (+8/-3)
midori/midori-session.h (+6/-0)
midori/midori-view.c (+2/-0)
midori/midori.vapi (+3/-3)
tests/app.vala (+6/-6)
To merge this branch: bzr merge lp:~kalikiana/midori/apps
Reviewer Review Type Date Requested Status
André Stösel Approve
Paweł Forysiuk Needs Fixing
Review via email: mp+165257@code.launchpad.net

Commit message

Store data of app mode based on URL in ~/.local/share/midori/apps

Description of the change

Store data of app mode based on URL in ~/.local/share/midori/apps

To post a comment you must log in.
Revision history for this message
Paweł Forysiuk (tuxator) wrote :

Seems like changes in midori_normal_app_new () arguments are not reflected in test
and in midori.vapi file

After changing this test will also fail with assert like below.

/app/web:
(/home/pawel/src/midori/_build/default/tests/test-app:20359): GLib-CRITICAL **: g_compute_checksum_for_string: assertion `length == 0 || str != NULL' failed

Could be also wise to add this new path to about:paths maybe?

review: Needs Fixing
Revision history for this message
André Stösel (ivaldi) wrote :

I proposed merging a small patch into this branch before committing.

review: Needs Fixing
Revision history for this message
André Stösel (ivaldi) wrote :

IMHO the leading whitespace in every line of the .desktop file isn't a nice solution, but I don't know if joining the lines would actually be a better one.

Revision history for this message
Cody Garver (codygarver) wrote :
lp:~kalikiana/midori/apps updated
6173. By Cris Dywan

Replace .gitignore with a .bzrignore

6174. By gue5t <email address hidden>

Compare uri schemes case-insensitively.

6175. By gue5t <email address hidden>

make commandline download-manager handle parameters more consistently, fixing nullable strings

6176. By André Stösel

Fix History List memory leak when closing Midori window.

6177. By Paweł Forysiuk

Split colorful tabs code into helper functions and add unit tests

Revision history for this message
André Stösel (ivaldi) :
review: Approve
lp:~kalikiana/midori/apps updated
6178. By Cris Dywan

Store data of app mode based on URL in ~/.local/share/midori/apps

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-04-20 00:46:39 +0000
3+++ extensions/apps.vala 2013-05-27 21:17:24 +0000
4@@ -10,7 +10,8 @@
5 */
6
7 namespace Apps {
8- const string EXEC_PREFIX = PACKAGE_NAME + " -a ";
9+ const string APP_PREFIX = PACKAGE_NAME + " -a ";
10+ const string PROFILE_PREFIX = PACKAGE_NAME + " -c ";
11
12 private class Launcher : GLib.Object, GLib.Initable {
13 internal GLib.File file;
14@@ -19,10 +20,10 @@
15 internal string exec;
16 internal string uri;
17
18- internal static async void create (GLib.File folder, string uri, string title) {
19+ internal static async void create (string prefix, GLib.File folder, string uri, string title) {
20 /* Strip LRE leading character and / */
21- string filename = title.delimit ("‪/", ' ') + ".desktop";
22- string exec = EXEC_PREFIX + uri;
23+ string filename = title.delimit ("‪/", ' ').strip() + ".desktop";
24+ string exec = prefix + uri;
25 string name = title;
26 // TODO: Midori.Paths.get_icon save to png
27 string icon_name = Midori.Stock.WEB_BROWSER;
28@@ -58,12 +59,12 @@
29 var keyfile = new GLib.KeyFile ();
30 keyfile.load_from_file (file.get_path (), GLib.KeyFileFlags.NONE);
31 exec = keyfile.get_string ("Desktop Entry", "Exec");
32- if (!exec.has_prefix (EXEC_PREFIX))
33+ if (!exec.has_prefix (APP_PREFIX) && !exec.has_prefix (PROFILE_PREFIX))
34 return false;
35
36 name = keyfile.get_string ("Desktop Entry", "Name");
37 icon_name = keyfile.get_string ("Desktop Entry", "Icon");
38- uri = exec.replace (EXEC_PREFIX, "");
39+ uri = exec.replace (APP_PREFIX, "").replace (PROFILE_PREFIX, "");
40 return true;
41 }
42 }
43@@ -73,6 +74,7 @@
44 Gtk.ListStore store = new Gtk.ListStore (1, typeof (Launcher));
45 Gtk.TreeView treeview;
46 Katze.Array array;
47+ GLib.File app_folder;
48
49 public unowned string get_stock_id () {
50 return Midori.Stock.WEB_BROWSER;
51@@ -86,11 +88,39 @@
52 if (toolbar == null) {
53 toolbar = new Gtk.Toolbar ();
54 toolbar.set_icon_size (Gtk.IconSize.BUTTON);
55+
56+ var profile = new Gtk.ToolButton.from_stock (Gtk.STOCK_ADD);
57+ profile.label = _("New _Profile");
58+ profile.tooltip_text = _("Creates a new, independant profile and a launcher");
59+ profile.use_underline = true;
60+ profile.is_important = true;
61+ profile.show ();
62+ profile.clicked.connect (() => {
63+ string uuid = GLib.DBus.generate_guid ();
64+ string config = Path.build_path (Path.DIR_SEPARATOR_S,
65+ Midori.Paths.get_user_data_dir (), PACKAGE_NAME, "profiles", uuid);
66+ Launcher.create.begin (PROFILE_PREFIX, app_folder,
67+ config, _("Midori (%s)").printf (uuid));
68+ });
69+ toolbar.insert (profile, -1);
70+
71+ var app = new Gtk.ToolButton.from_stock (Gtk.STOCK_ADD);
72+ app.label = _("New _App");
73+ app.tooltip_text = _("Creates a new app for a specific site");
74+ app.use_underline = true;
75+ app.is_important = true;
76+ app.show ();
77+ app.clicked.connect (() => {
78+ var view = (get_toplevel () as Midori.Browser).tab as Midori.View;
79+ Launcher.create.begin (APP_PREFIX, app_folder,
80+ view.get_display_uri (), view.get_display_title ());
81+ });
82+ toolbar.insert (app, -1);
83 }
84 return toolbar;
85 }
86
87- public Sidebar (Katze.Array array) {
88+ public Sidebar (Katze.Array array, GLib.File app_folder) {
89 Gtk.TreeViewColumn column;
90
91 treeview = new Gtk.TreeView.with_model (store);
92@@ -121,6 +151,8 @@
93 array.remove_item.connect (launcher_removed);
94 foreach (GLib.Object item in array.get_items ())
95 launcher_added (item);
96+
97+ this.app_folder = app_folder;
98 }
99
100 private int tree_sort_func (Gtk.TreeModel model, Gtk.TreeIter a, Gtk.TreeIter b) {
101@@ -238,13 +270,13 @@
102 menu.append (menuitem);
103 menuitem.activate.connect (() => {
104 var view = browser.tab as Midori.View;
105- Launcher.create.begin (app_folder,
106+ Launcher.create.begin (APP_PREFIX, app_folder,
107 view.get_display_uri (), view.get_display_title ());
108 });
109 }
110
111 void browser_added (Midori.Browser browser) {
112- var viewable = new Sidebar (array);
113+ var viewable = new Sidebar (array, app_folder);
114 viewable.show ();
115 browser.panel.append_page (viewable);
116 browser.populate_tool_menu.connect (tool_menu_populated);
117
118=== modified file 'katze/midori-paths.vala'
119--- katze/midori-paths.vala 2013-04-07 19:54:36 +0000
120+++ katze/midori-paths.vala 2013-05-27 21:17:24 +0000
121@@ -113,7 +113,16 @@
122 tmp_dir = Path.build_path (Path.DIR_SEPARATOR_S,
123 exec_path, "profile", "tmp");
124 }
125- else if (mode == RuntimeMode.PRIVATE || mode == RuntimeMode.APP) {
126+ else if (mode == RuntimeMode.APP) {
127+ config_dir = Path.build_path (Path.DIR_SEPARATOR_S,
128+ Environment.get_user_data_dir (), PACKAGE_NAME, "apps",
129+ Checksum.compute_for_string (ChecksumType.MD5, config, -1));
130+ cache_dir = Path.build_path (Path.DIR_SEPARATOR_S,
131+ Environment.get_user_cache_dir (), PACKAGE_NAME);
132+ user_data_dir_for_reading = Environment.get_user_data_dir ();
133+ tmp_dir = get_runtime_dir ();
134+ }
135+ else if (mode == RuntimeMode.PRIVATE) {
136 string? real_config = config != null && !Path.is_absolute (config)
137 ? Path.build_filename (Environment.get_current_dir (), config) : config;
138 readonly_dir = real_config ?? Path.build_path (Path.DIR_SEPARATOR_S,
139
140=== modified file 'midori/main.c'
141--- midori/main.c 2013-05-19 09:33:02 +0000
142+++ midori/main.c 2013-05-27 21:17:24 +0000
143@@ -398,7 +398,7 @@
144
145 if (webapp)
146 {
147- MidoriBrowser* browser = midori_web_app_new (config, webapp,
148+ MidoriBrowser* browser = midori_web_app_new (webapp,
149 uris, execute, inactivity_reset, block_uris);
150 g_signal_connect (browser, "destroy", G_CALLBACK (gtk_main_quit), NULL);
151 g_signal_connect (browser, "quit", G_CALLBACK (gtk_main_quit), NULL);
152@@ -407,7 +407,7 @@
153 }
154
155 MidoriApp* app = midori_normal_app_new (config,
156- portable ? "portable" : "normal", diagnostic_dialog, webapp,
157+ portable ? "portable" : "normal", diagnostic_dialog,
158 uris, execute, inactivity_reset, block_uris);
159 if (app == NULL)
160 return 0;
161
162=== modified file 'midori/midori-frontend.c'
163--- midori/midori-frontend.c 2013-05-19 15:50:18 +0000
164+++ midori/midori-frontend.c 2013-05-27 21:17:24 +0000
165@@ -37,19 +37,16 @@
166 }
167
168 MidoriBrowser*
169-midori_web_app_new (const gchar* config,
170- const gchar* webapp,
171+midori_web_app_new (const gchar* webapp,
172 gchar** open_uris,
173 gchar** execute_commands,
174 gint inactivity_reset,
175 const gchar* block_uris)
176 {
177 guint i;
178+ g_return_val_if_fail (webapp != NULL, NULL);
179
180- midori_paths_init (MIDORI_RUNTIME_MODE_APP, config);
181-#ifndef HAVE_WEBKIT2
182- g_object_set_data (G_OBJECT (webkit_get_default_session ()), "pass-through-console", (void*)1);
183-#endif
184+ midori_paths_init (MIDORI_RUNTIME_MODE_APP, webapp);
185 MidoriBrowser* browser = midori_browser_new ();
186 g_signal_connect (browser, "new-window",
187 G_CALLBACK (midori_frontend_browser_new_window_cb), NULL);
188@@ -57,18 +54,18 @@
189 midori_browser_set_action_visible (browser, "Menubar", FALSE);
190 midori_browser_set_action_visible (browser, "CompactMenu", FALSE);
191
192- MidoriWebSettings* settings = midori_browser_get_settings (browser);
193+ MidoriWebSettings* settings = midori_settings_new_full (NULL);
194 g_object_set (settings,
195 "show-menubar", FALSE,
196 "show-navigationbar", FALSE,
197- "toolbar-items", "Back,Forward,ReloadStop,Location,Homepage",
198+ "toolbar-items", "Back,Forward,ReloadStop,Location,Homepage,Preferences",
199 "show-statusbar", FALSE,
200 "show-panel", FALSE,
201 "last-window-state", MIDORI_WINDOW_NORMAL,
202 "inactivity-reset", inactivity_reset,
203 "block-uris", block_uris,
204 NULL);
205- midori_load_soup_session (settings);
206+ midori_load_soup_session_full (settings);
207
208 KatzeArray* search_engines = midori_search_engines_new_from_folder (NULL);
209 g_object_set (browser,
210@@ -101,6 +98,7 @@
211 midori_browser_assert_action (browser, execute_commands[i]);
212 midori_browser_activate_action (browser, execute_commands[i]);
213 }
214+ midori_session_persistent_settings (settings, NULL);
215 return browser;
216 }
217
218@@ -426,7 +424,6 @@
219 midori_normal_app_new (const gchar* config,
220 gchar* nickname,
221 gboolean diagnostic_dialog,
222- const gchar* webapp,
223 gchar** open_uris,
224 gchar** execute_commands,
225 gint inactivity_reset,
226
227=== modified file 'midori/midori-frontend.h'
228--- midori/midori-frontend.h 2013-05-19 09:43:05 +0000
229+++ midori/midori-frontend.h 2013-05-27 21:17:24 +0000
230@@ -15,8 +15,7 @@
231 #include "midori/midori-app.h"
232
233 MidoriBrowser*
234-midori_web_app_new (const gchar* config,
235- const gchar* webapp,
236+midori_web_app_new (const gchar* webapp,
237 gchar** open_uris,
238 gchar** execute_commands,
239 gint inactivity_reset,
240@@ -34,7 +33,6 @@
241 midori_normal_app_new (const gchar* config,
242 gchar* nickname,
243 gboolean diagnostic_dialog,
244- const gchar* webapp,
245 gchar** open_uris,
246 gchar** execute_commands,
247 gint inactivity_reset,
248
249=== modified file 'midori/midori-session.c'
250--- midori/midori-session.c 2013-05-19 09:33:02 +0000
251+++ midori/midori-session.c 2013-05-27 21:17:24 +0000
252@@ -12,9 +12,7 @@
253 #include "midori/midori-session.h"
254
255 #include <midori/midori-core.h>
256-#include "midori-app.h"
257 #include "midori-array.h"
258-#include "midori-websettings.h"
259 #include "midori-extension.h"
260 #include "sokoke.h"
261
262@@ -371,6 +369,13 @@
263 g_free (config_file);
264 }
265
266+void
267+midori_session_persistent_settings (MidoriWebSettings* settings,
268+ MidoriApp* app)
269+{
270+ g_signal_connect_after (settings, "notify", G_CALLBACK (settings_notify_cb), app);
271+}
272+
273 static void
274 midori_browser_action_last_session_activate_cb (GtkAction* action,
275 MidoriBrowser* browser)
276@@ -470,7 +475,7 @@
277 #endif
278
279 browser = midori_app_create_browser (app);
280- g_signal_connect_after (settings, "notify", G_CALLBACK (settings_notify_cb), app);
281+ midori_session_persistent_settings (settings, app);
282
283 config_file = midori_paths_get_config_filename_for_reading ("session.old.xbel");
284 if (g_access (config_file, F_OK) == 0)
285
286=== modified file 'midori/midori-session.h'
287--- midori/midori-session.h 2013-05-19 09:33:02 +0000
288+++ midori/midori-session.h 2013-05-27 21:17:24 +0000
289@@ -13,6 +13,8 @@
290 #define __MIDORI_SESSION_H__
291
292 #include <glib/gstdio.h>
293+#include "midori-app.h"
294+#include "midori-websettings.h"
295
296 gboolean
297 midori_load_soup_session (gpointer settings);
298@@ -26,5 +28,9 @@
299 gboolean
300 midori_load_session (gpointer data);
301
302+void
303+midori_session_persistent_settings (MidoriWebSettings* settings,
304+ MidoriApp* app);
305+
306 #endif /* __MIDORI_SESSION_H__ */
307
308
309=== modified file 'midori/midori-view.c'
310--- midori/midori-view.c 2013-05-08 00:51:02 +0000
311+++ midori/midori-view.c 2013-05-27 21:17:24 +0000
312@@ -4431,11 +4431,13 @@
313 data = g_markup_printf_escaped ("<body><h1>%s</h1>"
314 "<p>config: <code>%s</code></p>"
315 "<p>res: <code>%s</code></p>"
316+ "<p>data: <code>%s/%s</code></p>"
317 "<p>lib: <code>%s</code></p>"
318 "<p>cache: <code>%s</code></p>"
319 "<p>tmp: <code>%s</code></p>"
320 "</body>",
321 uri, midori_paths_get_config_dir_for_reading (), res_dir,
322+ midori_paths_get_user_data_dir_for_reading (), PACKAGE_NAME,
323 lib_dir, midori_paths_get_cache_dir_for_reading (), midori_paths_get_tmp_dir ());
324 g_free (res_dir);
325 g_free (lib_dir);
326
327=== modified file 'midori/midori.vapi'
328--- midori/midori.vapi 2013-04-22 23:01:10 +0000
329+++ midori/midori.vapi 2013-05-27 21:17:24 +0000
330@@ -13,12 +13,12 @@
331 }
332
333 [CCode (cheader_filename = "midori/midori.h")]
334- public static unowned Midori.Browser web_app_new (string? config,
335- string? webapp, [CCode (array_length = false)] string[]? uris, [CCode (array_length = false)] string[]? commands, int reset, string? block);
336+ public static unowned Midori.Browser web_app_new (
337+ string webapp, [CCode (array_length = false)] string[]? uris, [CCode (array_length = false)] string[]? commands, int reset, string? block);
338 public static unowned Midori.Browser private_app_new (string? config,
339 string? webapp, [CCode (array_length = false)] string[]? uris, [CCode (array_length = false)] string[]? commands, int reset, string? block);
340 public static unowned App normal_app_new (string? config, string nickname, bool diagnostic,
341- string? webapp, [CCode (array_length = false)] string[]? uris, [CCode (array_length = false)] string[]? commands, int reset, string? block);
342+ [CCode (array_length = false)] string[]? uris, [CCode (array_length = false)] string[]? commands, int reset, string? block);
343 public static void normal_app_on_quit (App app);
344
345 [CCode (cheader_filename = "midori/midori.h")]
346
347=== modified file 'tests/app.vala'
348--- tests/app.vala 2013-04-11 21:57:51 +0000
349+++ tests/app.vala 2013-05-27 21:17:24 +0000
350@@ -23,7 +23,7 @@
351 Midori.Test.log_set_fatal_handler_for_icons ();
352 Midori.Paths.Test.reset_runtime_mode ();
353 Midori.App.set_instance_is_running (false);
354- var app = Midori.normal_app_new (null, "test-normal", false, null, null, null, -1, null);
355+ var app = Midori.normal_app_new (null, "test-normal", false, null, null, -1, null);
356 var loop = MainContext.default ();
357 do { loop.iteration (true); } while (loop.pending ());
358 for (var i = 0 ; i < 7; i++) {
359@@ -47,7 +47,7 @@
360 Midori.Paths.Test.reset_runtime_mode ();
361 Midori.App.set_instance_is_running (false);
362 var app = Midori.normal_app_new (Midori.Paths.make_tmp_dir ("custom-configXXXXXX"),
363- "test-custom-config-normal", false, null, null, null, -1, null);
364+ "test-custom-config-normal", false, null, null, -1, null);
365 var loop = MainContext.default ();
366 do { loop.iteration (true); } while (loop.pending ());
367 assert (check_sensible_window_size (app.browser, app.settings));
368@@ -67,7 +67,7 @@
369 void app_web () {
370 Midori.Paths.Test.reset_runtime_mode ();
371 Midori.App.set_instance_is_running (false);
372- var browser = Midori.web_app_new (null, null, null, null, -1, null);
373+ var browser = Midori.web_app_new ("https://mail.google.com", null, null, -1, null);
374 var loop = MainContext.default ();
375 do { loop.iteration (true); } while (loop.pending ());
376 assert (check_sensible_window_size (browser, browser.settings));
377@@ -76,7 +76,7 @@
378 void app_web_custom_config () {
379 Midori.Paths.Test.reset_runtime_mode ();
380 Midori.App.set_instance_is_running (false);
381- var browser = Midori.web_app_new (Midori.Paths.make_tmp_dir ("custom-configXXXXXX"), null, null, null, -1, null);
382+ var browser = Midori.web_app_new ("https://mail.google.com", null, null, -1, null);
383 var loop = MainContext.default ();
384 do { loop.iteration (true); } while (loop.pending ());
385 assert (check_sensible_window_size (browser, browser.settings));
386@@ -90,7 +90,7 @@
387 Midori.Test.log_set_fatal_handler_for_icons ();
388 Midori.Paths.Test.reset_runtime_mode ();
389 Midori.App.set_instance_is_running (false);
390- var app = Midori.normal_app_new (null, "test-extensions-normal", false, null, null, null, -1, null);
391+ var app = Midori.normal_app_new (null, "test-extensions-normal", false, null, null, -1, null);
392 var loop = MainContext.default ();
393 do { loop.iteration (true); } while (loop.pending ());
394 /* No extensions loaded */
395@@ -136,7 +136,7 @@
396 Midori.Test.log_set_fatal_handler_for_icons ();
397 Midori.Paths.Test.reset_runtime_mode ();
398 Midori.App.set_instance_is_running (false);
399- var app = Midori.normal_app_new (null, "test-extensions-normal", false, null, null, null, -1, null);
400+ var app = Midori.normal_app_new (null, "test-extensions-normal", false, null, null, -1, null);
401 var loop = MainContext.default ();
402 do { loop.iteration (true); } while (loop.pending ());
403 Midori.Extension.load_from_folder (app, null, false);

Subscribers

People subscribed via source and target branches

to all changes: