Merge lp:~ivaldi/midori/tabby-about-sessions into lp:midori

Proposed by André Stösel
Status: Work in progress
Proposed branch: lp:~ivaldi/midori/tabby-about-sessions
Merge into: lp:midori
Diff against target: 172 lines (+91/-2)
6 files modified
midori/marshal.list (+1/-0)
midori/midori-resource.vala (+17/-0)
midori/midori-view.c (+53/-2)
midori/midori.vapi (+1/-0)
midori/sokoke.c (+13/-0)
midori/sokoke.h (+6/-0)
To merge this branch: bzr merge lp:~ivaldi/midori/tabby-about-sessions
Reviewer Review Type Date Requested Status
Cris Dywan Needs Information
Review via email: mp+189940@code.launchpad.net

Commit message

Description of the change

To post a comment you must log in.
6435. By André Stösel

fix vapi

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

Did you consider making contents and mime_type properties rather than functions? That way they could be set and kept around, and used without subclassing.
Will resource-request replace about-content?
Will res:// and stock:// be implemented with resource-request? Then they wouldn't need their own #if for wk2 anymore.

And if I may suggest, this branch looks more like "refactor about: pages with new API" than about:sessions.

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

Hm... this branch isn't finished yet (@"refactor about: pages" (status "Work in progress "))
I tried to remove "about-content", but it dosn't work without removing the "about:" pages code first.
(And I'm not sure if it's still needed afterwards.) -> lp:~ivaldi/midori/outsource-about-pages (work in progress)

(I guess I could change it to properties, but it has to work first ;)

Unmerged revisions

6435. By André Stösel

fix vapi

6434. By André Stösel

emit RESOURCE_REQUEST

6433. By André Stösel

add Midori.Resource base class

6432. By André Stösel

add resource_request signal to vapi

6431. By André Stösel

new signal view:resource-request

6430. By André Stösel

new marshal object:string

6429. By André Stösel

new accumulator for objects

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'midori/marshal.list'
2--- midori/marshal.list 2013-09-03 14:45:17 +0000
3+++ midori/marshal.list 2013-10-08 19:49:14 +0000
4@@ -4,6 +4,7 @@
5 BOOLEAN:VOID
6 BOOLEAN:STRING
7 OBJECT:OBJECT
8+OBJECT:STRING
9 VOID:BOOLEAN,STRING
10 VOID:OBJECT,ENUM,BOOLEAN
11 VOID:OBJECT,INT,INT
12
13=== added file 'midori/midori-resource.vala'
14--- midori/midori-resource.vala 1970-01-01 00:00:00 +0000
15+++ midori/midori-resource.vala 2013-10-08 19:49:14 +0000
16@@ -0,0 +1,17 @@
17+/*
18+ Copyright (C) 2013 André Stösel <andre@stoesel.de>
19+
20+ This library is free software; you can redistribute it and/or
21+ modify it under the terms of the GNU Lesser General Public
22+ License as published by the Free Software Foundation; either
23+ version 2.1 of the License, or (at your option) any later version.
24+
25+ See the file COPYING for the full license text.
26+*/
27+
28+namespace Midori {
29+ public abstract class Resource : GLib.Object {
30+ public abstract string get_contents ();
31+ public abstract string get_mime_type ();
32+ }
33+}
34
35=== modified file 'midori/midori-view.c'
36--- midori/midori-view.c 2013-09-17 15:41:00 +0000
37+++ midori/midori-view.c 2013-10-08 19:49:14 +0000
38@@ -161,6 +161,7 @@
39 DOWNLOAD_REQUESTED,
40 ADD_BOOKMARK,
41 ABOUT_CONTENT,
42+ RESOURCE_REQUEST,
43
44 LAST_SIGNAL
45 };
46@@ -326,6 +327,28 @@
47 G_TYPE_BOOLEAN, 1,
48 G_TYPE_STRING);
49
50+ /**
51+ * MidoriView::resource-request:
52+ * @view: the object on which the signal is emitted
53+ * @uri: the resource URI
54+ *
55+ * Emitted for resource requests on special views
56+ *
57+ * Return value: Midori.Resource object
58+ *
59+ * Since: 0.5.6
60+ */
61+ signals[RESOURCE_REQUEST] = g_signal_new (
62+ "resource-request",
63+ G_TYPE_FROM_CLASS (class),
64+ (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
65+ 0,
66+ sokoke_signal_accumulator_object_handled,
67+ NULL,
68+ midori_cclosure_marshal_OBJECT__STRING,
69+ G_TYPE_OBJECT, 1,
70+ G_TYPE_STRING);
71+
72 gobject_class = G_OBJECT_CLASS (class);
73 gobject_class->constructor = midori_view_constructor;
74 gobject_class->finalize = midori_view_finalize;
75@@ -873,11 +896,35 @@
76 if (!midori_tab_get_special (MIDORI_TAB (view)))
77 return;
78
79- if (g_str_has_prefix (uri, "res://"))
80+ gchar* contents;
81+ MidoriResource* resource = NULL;
82+ g_signal_emit (view, signals[RESOURCE_REQUEST], 0, uri, &resource);
83+
84+ if (resource) {
85+ gchar* mime_type = midori_resource_get_mime_type (MIDORI_RESOURCE (resource));
86+ contents = midori_resource_get_contents (MIDORI_RESOURCE (resource));
87+
88+ #ifdef HAVE_WEBKIT2
89+ GInputStream* stream = g_memory_input_stream_new_from_data (contents, -1, g_free);
90+ webkit_uri_scheme_request_finish (request, stream, -1, mime_type);
91+ g_object_unref (stream);
92+ #else
93+ gchar* encoded;
94+ gchar* data_uri;
95+
96+ encoded = g_base64_encode (contents, strlen (contents));
97+ data_uri = g_strconcat ("data:", mime_type, ";base64,", encoded, NULL);
98+ g_free (encoded);
99+ webkit_network_request_set_uri (request, data_uri);
100+ g_free (data_uri);
101+ g_free (contents);
102+ #endif
103+ g_free (mime_type);
104+ }
105+ else if (g_str_has_prefix (uri, "res://"))
106 {
107 gchar* filepath = midori_paths_get_res_filename (&uri[6]);
108 #ifdef HAVE_WEBKIT2
109- gchar* contents;
110 gsize length;
111 if (g_file_get_contents (filepath, &contents, &length, NULL))
112 {
113@@ -3890,7 +3937,11 @@
114 g_signal_emit (view, signals[ABOUT_CONTENT], 0, uri, &handled);
115
116 if (handled)
117+ {
118+ midori_tab_set_uri (MIDORI_TAB (view), uri);
119+ midori_tab_set_special (MIDORI_TAB (view), TRUE);
120 return;
121+ }
122
123 if (!strcmp (uri, "about:new"))
124 uri = midori_settings_get_tabhome (MIDORI_SETTINGS (view->settings));
125
126=== modified file 'midori/midori.vapi'
127--- midori/midori.vapi 2013-09-17 12:59:39 +0000
128+++ midori/midori.vapi 2013-10-08 19:49:14 +0000
129@@ -207,6 +207,7 @@
130 [HasEmitter]
131 public signal bool download_requested (WebKit.Download download);
132 public signal bool about_content (string uri);
133+ public signal GLib.Object? resource_request (string uri);
134
135 }
136
137
138=== modified file 'midori/sokoke.c'
139--- midori/sokoke.c 2013-08-07 21:23:54 +0000
140+++ midori/sokoke.c 2013-10-08 19:49:14 +0000
141@@ -1119,3 +1119,16 @@
142 g_free (launcher_type);
143 }
144 #endif
145+
146+gboolean
147+sokoke_signal_accumulator_object_handled (GSignalInvocationHint* ihint,
148+ GValue* returnAccu,
149+ const GValue* handlerReturn,
150+ gpointer dummy)
151+{
152+ gpointer newObject = g_value_get_object(handlerReturn);
153+ g_value_set_object(returnAccu, newObject);
154+
155+ // Continue if we don't have a newObject
156+ return !newObject;
157+}
158
159=== modified file 'midori/sokoke.h'
160--- midori/sokoke.h 2013-08-02 16:40:27 +0000
161+++ midori/sokoke.h 2013-10-08 19:49:14 +0000
162@@ -133,4 +133,10 @@
163 sokoke_create_win32_desktop_lnk (gchar* prefix, gchar* filename, gchar* uri);
164 #endif
165
166+gboolean
167+sokoke_signal_accumulator_object_handled (GSignalInvocationHint* ihint,
168+ GValue* returnAccu,
169+ const GValue* handlerReturn,
170+ gpointer dummy);
171+
172 #endif /* !__SOKOKE_H__ */

Subscribers

People subscribed via source and target branches

to all changes: