Merge lp:~sergiusens/indicator-messages/bump into lp:~indicator-applet-developers/indicator-messages/trunk.13.10
- bump
- Merge into trunk.13.10
Proposed by
Sergio Schvezov
Status: | Superseded |
---|---|
Proposed branch: | lp:~sergiusens/indicator-messages/bump |
Merge into: | lp:~indicator-applet-developers/indicator-messages/trunk.13.10 |
Diff against target: |
5952 lines (+3802/-1351) (has conflicts) 31 files modified
COPYING.GPLv3 (+674/-0) Makefile.am (+1/-0) common/Makefile.am (+32/-0) common/com.canonical.indicator.messages.application.xml (+39/-0) configure.ac (+1/-0) debian/changelog (+90/-0) debian/libmessaging-menu0.symbols (+15/-0) debian/source/format (+1/-0) doc/reference/Makefile.am (+1/-2) doc/reference/messaging-menu-docs.xml.in (+2/-1) libmessaging-menu/Makefile.am (+15/-22) libmessaging-menu/gtupleaction.c (+0/-354) libmessaging-menu/gtupleaction.h (+0/-40) libmessaging-menu/messaging-menu-app.c (+509/-194) libmessaging-menu/messaging-menu-app.h (+17/-2) libmessaging-menu/messaging-menu-message.c (+547/-0) libmessaging-menu/messaging-menu-message.h (+70/-0) libmessaging-menu/messaging-menu.h (+25/-0) src/Makefile.am (+11/-25) src/app-section.c (+274/-170) src/dbus-data.h (+16/-1) src/gactionmuxer.c (+8/-0) src/gactionmuxer.h (+3/-0) src/im-application-list.c (+880/-0) src/im-application-list.h (+52/-0) src/im-phone-menu.c (+331/-0) src/im-phone-menu.h (+70/-0) src/messages-service.c (+62/-538) test/Makefile.am (+3/-2) test/indicator-messages-service-activate.c (+7/-0) test/test-gactionmuxer.cpp (+46/-0) Text conflict in debian/changelog Text conflict in libmessaging-menu/messaging-menu-app.c Text conflict in src/messages-service.c Text conflict in test/indicator-messages-service-activate.c Text conflict in test/test-gactionmuxer.cpp |
To merge this branch: | bzr merge lp:~sergiusens/indicator-messages/bump |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Indicator Applet Developers | Pending | ||
Review via email:
|
This proposal has been superseded by a proposal from 2013-04-26.
Commit message
Version bump to not pull from archive
Description of the change
To post a comment you must log in.
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file 'COPYING.GPLv3' | |||
2 | --- COPYING.GPLv3 1970-01-01 00:00:00 +0000 | |||
3 | +++ COPYING.GPLv3 2013-04-26 16:57:25 +0000 | |||
4 | @@ -0,0 +1,674 @@ | |||
5 | 1 | GNU GENERAL PUBLIC LICENSE | ||
6 | 2 | Version 3, 29 June 2007 | ||
7 | 3 | |||
8 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> | ||
9 | 5 | Everyone is permitted to copy and distribute verbatim copies | ||
10 | 6 | of this license document, but changing it is not allowed. | ||
11 | 7 | |||
12 | 8 | Preamble | ||
13 | 9 | |||
14 | 10 | The GNU General Public License is a free, copyleft license for | ||
15 | 11 | software and other kinds of works. | ||
16 | 12 | |||
17 | 13 | The licenses for most software and other practical works are designed | ||
18 | 14 | to take away your freedom to share and change the works. By contrast, | ||
19 | 15 | the GNU General Public License is intended to guarantee your freedom to | ||
20 | 16 | share and change all versions of a program--to make sure it remains free | ||
21 | 17 | software for all its users. We, the Free Software Foundation, use the | ||
22 | 18 | GNU General Public License for most of our software; it applies also to | ||
23 | 19 | any other work released this way by its authors. You can apply it to | ||
24 | 20 | your programs, too. | ||
25 | 21 | |||
26 | 22 | When we speak of free software, we are referring to freedom, not | ||
27 | 23 | price. Our General Public Licenses are designed to make sure that you | ||
28 | 24 | have the freedom to distribute copies of free software (and charge for | ||
29 | 25 | them if you wish), that you receive source code or can get it if you | ||
30 | 26 | want it, that you can change the software or use pieces of it in new | ||
31 | 27 | free programs, and that you know you can do these things. | ||
32 | 28 | |||
33 | 29 | To protect your rights, we need to prevent others from denying you | ||
34 | 30 | these rights or asking you to surrender the rights. Therefore, you have | ||
35 | 31 | certain responsibilities if you distribute copies of the software, or if | ||
36 | 32 | you modify it: responsibilities to respect the freedom of others. | ||
37 | 33 | |||
38 | 34 | For example, if you distribute copies of such a program, whether | ||
39 | 35 | gratis or for a fee, you must pass on to the recipients the same | ||
40 | 36 | freedoms that you received. You must make sure that they, too, receive | ||
41 | 37 | or can get the source code. And you must show them these terms so they | ||
42 | 38 | know their rights. | ||
43 | 39 | |||
44 | 40 | Developers that use the GNU GPL protect your rights with two steps: | ||
45 | 41 | (1) assert copyright on the software, and (2) offer you this License | ||
46 | 42 | giving you legal permission to copy, distribute and/or modify it. | ||
47 | 43 | |||
48 | 44 | For the developers' and authors' protection, the GPL clearly explains | ||
49 | 45 | that there is no warranty for this free software. For both users' and | ||
50 | 46 | authors' sake, the GPL requires that modified versions be marked as | ||
51 | 47 | changed, so that their problems will not be attributed erroneously to | ||
52 | 48 | authors of previous versions. | ||
53 | 49 | |||
54 | 50 | Some devices are designed to deny users access to install or run | ||
55 | 51 | modified versions of the software inside them, although the manufacturer | ||
56 | 52 | can do so. This is fundamentally incompatible with the aim of | ||
57 | 53 | protecting users' freedom to change the software. The systematic | ||
58 | 54 | pattern of such abuse occurs in the area of products for individuals to | ||
59 | 55 | use, which is precisely where it is most unacceptable. Therefore, we | ||
60 | 56 | have designed this version of the GPL to prohibit the practice for those | ||
61 | 57 | products. If such problems arise substantially in other domains, we | ||
62 | 58 | stand ready to extend this provision to those domains in future versions | ||
63 | 59 | of the GPL, as needed to protect the freedom of users. | ||
64 | 60 | |||
65 | 61 | Finally, every program is threatened constantly by software patents. | ||
66 | 62 | States should not allow patents to restrict development and use of | ||
67 | 63 | software on general-purpose computers, but in those that do, we wish to | ||
68 | 64 | avoid the special danger that patents applied to a free program could | ||
69 | 65 | make it effectively proprietary. To prevent this, the GPL assures that | ||
70 | 66 | patents cannot be used to render the program non-free. | ||
71 | 67 | |||
72 | 68 | The precise terms and conditions for copying, distribution and | ||
73 | 69 | modification follow. | ||
74 | 70 | |||
75 | 71 | TERMS AND CONDITIONS | ||
76 | 72 | |||
77 | 73 | 0. Definitions. | ||
78 | 74 | |||
79 | 75 | "This License" refers to version 3 of the GNU General Public License. | ||
80 | 76 | |||
81 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of | ||
82 | 78 | works, such as semiconductor masks. | ||
83 | 79 | |||
84 | 80 | "The Program" refers to any copyrightable work licensed under this | ||
85 | 81 | License. Each licensee is addressed as "you". "Licensees" and | ||
86 | 82 | "recipients" may be individuals or organizations. | ||
87 | 83 | |||
88 | 84 | To "modify" a work means to copy from or adapt all or part of the work | ||
89 | 85 | in a fashion requiring copyright permission, other than the making of an | ||
90 | 86 | exact copy. The resulting work is called a "modified version" of the | ||
91 | 87 | earlier work or a work "based on" the earlier work. | ||
92 | 88 | |||
93 | 89 | A "covered work" means either the unmodified Program or a work based | ||
94 | 90 | on the Program. | ||
95 | 91 | |||
96 | 92 | To "propagate" a work means to do anything with it that, without | ||
97 | 93 | permission, would make you directly or secondarily liable for | ||
98 | 94 | infringement under applicable copyright law, except executing it on a | ||
99 | 95 | computer or modifying a private copy. Propagation includes copying, | ||
100 | 96 | distribution (with or without modification), making available to the | ||
101 | 97 | public, and in some countries other activities as well. | ||
102 | 98 | |||
103 | 99 | To "convey" a work means any kind of propagation that enables other | ||
104 | 100 | parties to make or receive copies. Mere interaction with a user through | ||
105 | 101 | a computer network, with no transfer of a copy, is not conveying. | ||
106 | 102 | |||
107 | 103 | An interactive user interface displays "Appropriate Legal Notices" | ||
108 | 104 | to the extent that it includes a convenient and prominently visible | ||
109 | 105 | feature that (1) displays an appropriate copyright notice, and (2) | ||
110 | 106 | tells the user that there is no warranty for the work (except to the | ||
111 | 107 | extent that warranties are provided), that licensees may convey the | ||
112 | 108 | work under this License, and how to view a copy of this License. If | ||
113 | 109 | the interface presents a list of user commands or options, such as a | ||
114 | 110 | menu, a prominent item in the list meets this criterion. | ||
115 | 111 | |||
116 | 112 | 1. Source Code. | ||
117 | 113 | |||
118 | 114 | The "source code" for a work means the preferred form of the work | ||
119 | 115 | for making modifications to it. "Object code" means any non-source | ||
120 | 116 | form of a work. | ||
121 | 117 | |||
122 | 118 | A "Standard Interface" means an interface that either is an official | ||
123 | 119 | standard defined by a recognized standards body, or, in the case of | ||
124 | 120 | interfaces specified for a particular programming language, one that | ||
125 | 121 | is widely used among developers working in that language. | ||
126 | 122 | |||
127 | 123 | The "System Libraries" of an executable work include anything, other | ||
128 | 124 | than the work as a whole, that (a) is included in the normal form of | ||
129 | 125 | packaging a Major Component, but which is not part of that Major | ||
130 | 126 | Component, and (b) serves only to enable use of the work with that | ||
131 | 127 | Major Component, or to implement a Standard Interface for which an | ||
132 | 128 | implementation is available to the public in source code form. A | ||
133 | 129 | "Major Component", in this context, means a major essential component | ||
134 | 130 | (kernel, window system, and so on) of the specific operating system | ||
135 | 131 | (if any) on which the executable work runs, or a compiler used to | ||
136 | 132 | produce the work, or an object code interpreter used to run it. | ||
137 | 133 | |||
138 | 134 | The "Corresponding Source" for a work in object code form means all | ||
139 | 135 | the source code needed to generate, install, and (for an executable | ||
140 | 136 | work) run the object code and to modify the work, including scripts to | ||
141 | 137 | control those activities. However, it does not include the work's | ||
142 | 138 | System Libraries, or general-purpose tools or generally available free | ||
143 | 139 | programs which are used unmodified in performing those activities but | ||
144 | 140 | which are not part of the work. For example, Corresponding Source | ||
145 | 141 | includes interface definition files associated with source files for | ||
146 | 142 | the work, and the source code for shared libraries and dynamically | ||
147 | 143 | linked subprograms that the work is specifically designed to require, | ||
148 | 144 | such as by intimate data communication or control flow between those | ||
149 | 145 | subprograms and other parts of the work. | ||
150 | 146 | |||
151 | 147 | The Corresponding Source need not include anything that users | ||
152 | 148 | can regenerate automatically from other parts of the Corresponding | ||
153 | 149 | Source. | ||
154 | 150 | |||
155 | 151 | The Corresponding Source for a work in source code form is that | ||
156 | 152 | same work. | ||
157 | 153 | |||
158 | 154 | 2. Basic Permissions. | ||
159 | 155 | |||
160 | 156 | All rights granted under this License are granted for the term of | ||
161 | 157 | copyright on the Program, and are irrevocable provided the stated | ||
162 | 158 | conditions are met. This License explicitly affirms your unlimited | ||
163 | 159 | permission to run the unmodified Program. The output from running a | ||
164 | 160 | covered work is covered by this License only if the output, given its | ||
165 | 161 | content, constitutes a covered work. This License acknowledges your | ||
166 | 162 | rights of fair use or other equivalent, as provided by copyright law. | ||
167 | 163 | |||
168 | 164 | You may make, run and propagate covered works that you do not | ||
169 | 165 | convey, without conditions so long as your license otherwise remains | ||
170 | 166 | in force. You may convey covered works to others for the sole purpose | ||
171 | 167 | of having them make modifications exclusively for you, or provide you | ||
172 | 168 | with facilities for running those works, provided that you comply with | ||
173 | 169 | the terms of this License in conveying all material for which you do | ||
174 | 170 | not control copyright. Those thus making or running the covered works | ||
175 | 171 | for you must do so exclusively on your behalf, under your direction | ||
176 | 172 | and control, on terms that prohibit them from making any copies of | ||
177 | 173 | your copyrighted material outside their relationship with you. | ||
178 | 174 | |||
179 | 175 | Conveying under any other circumstances is permitted solely under | ||
180 | 176 | the conditions stated below. Sublicensing is not allowed; section 10 | ||
181 | 177 | makes it unnecessary. | ||
182 | 178 | |||
183 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. | ||
184 | 180 | |||
185 | 181 | No covered work shall be deemed part of an effective technological | ||
186 | 182 | measure under any applicable law fulfilling obligations under article | ||
187 | 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or | ||
188 | 184 | similar laws prohibiting or restricting circumvention of such | ||
189 | 185 | measures. | ||
190 | 186 | |||
191 | 187 | When you convey a covered work, you waive any legal power to forbid | ||
192 | 188 | circumvention of technological measures to the extent such circumvention | ||
193 | 189 | is effected by exercising rights under this License with respect to | ||
194 | 190 | the covered work, and you disclaim any intention to limit operation or | ||
195 | 191 | modification of the work as a means of enforcing, against the work's | ||
196 | 192 | users, your or third parties' legal rights to forbid circumvention of | ||
197 | 193 | technological measures. | ||
198 | 194 | |||
199 | 195 | 4. Conveying Verbatim Copies. | ||
200 | 196 | |||
201 | 197 | You may convey verbatim copies of the Program's source code as you | ||
202 | 198 | receive it, in any medium, provided that you conspicuously and | ||
203 | 199 | appropriately publish on each copy an appropriate copyright notice; | ||
204 | 200 | keep intact all notices stating that this License and any | ||
205 | 201 | non-permissive terms added in accord with section 7 apply to the code; | ||
206 | 202 | keep intact all notices of the absence of any warranty; and give all | ||
207 | 203 | recipients a copy of this License along with the Program. | ||
208 | 204 | |||
209 | 205 | You may charge any price or no price for each copy that you convey, | ||
210 | 206 | and you may offer support or warranty protection for a fee. | ||
211 | 207 | |||
212 | 208 | 5. Conveying Modified Source Versions. | ||
213 | 209 | |||
214 | 210 | You may convey a work based on the Program, or the modifications to | ||
215 | 211 | produce it from the Program, in the form of source code under the | ||
216 | 212 | terms of section 4, provided that you also meet all of these conditions: | ||
217 | 213 | |||
218 | 214 | a) The work must carry prominent notices stating that you modified | ||
219 | 215 | it, and giving a relevant date. | ||
220 | 216 | |||
221 | 217 | b) The work must carry prominent notices stating that it is | ||
222 | 218 | released under this License and any conditions added under section | ||
223 | 219 | 7. This requirement modifies the requirement in section 4 to | ||
224 | 220 | "keep intact all notices". | ||
225 | 221 | |||
226 | 222 | c) You must license the entire work, as a whole, under this | ||
227 | 223 | License to anyone who comes into possession of a copy. This | ||
228 | 224 | License will therefore apply, along with any applicable section 7 | ||
229 | 225 | additional terms, to the whole of the work, and all its parts, | ||
230 | 226 | regardless of how they are packaged. This License gives no | ||
231 | 227 | permission to license the work in any other way, but it does not | ||
232 | 228 | invalidate such permission if you have separately received it. | ||
233 | 229 | |||
234 | 230 | d) If the work has interactive user interfaces, each must display | ||
235 | 231 | Appropriate Legal Notices; however, if the Program has interactive | ||
236 | 232 | interfaces that do not display Appropriate Legal Notices, your | ||
237 | 233 | work need not make them do so. | ||
238 | 234 | |||
239 | 235 | A compilation of a covered work with other separate and independent | ||
240 | 236 | works, which are not by their nature extensions of the covered work, | ||
241 | 237 | and which are not combined with it such as to form a larger program, | ||
242 | 238 | in or on a volume of a storage or distribution medium, is called an | ||
243 | 239 | "aggregate" if the compilation and its resulting copyright are not | ||
244 | 240 | used to limit the access or legal rights of the compilation's users | ||
245 | 241 | beyond what the individual works permit. Inclusion of a covered work | ||
246 | 242 | in an aggregate does not cause this License to apply to the other | ||
247 | 243 | parts of the aggregate. | ||
248 | 244 | |||
249 | 245 | 6. Conveying Non-Source Forms. | ||
250 | 246 | |||
251 | 247 | You may convey a covered work in object code form under the terms | ||
252 | 248 | of sections 4 and 5, provided that you also convey the | ||
253 | 249 | machine-readable Corresponding Source under the terms of this License, | ||
254 | 250 | in one of these ways: | ||
255 | 251 | |||
256 | 252 | a) Convey the object code in, or embodied in, a physical product | ||
257 | 253 | (including a physical distribution medium), accompanied by the | ||
258 | 254 | Corresponding Source fixed on a durable physical medium | ||
259 | 255 | customarily used for software interchange. | ||
260 | 256 | |||
261 | 257 | b) Convey the object code in, or embodied in, a physical product | ||
262 | 258 | (including a physical distribution medium), accompanied by a | ||
263 | 259 | written offer, valid for at least three years and valid for as | ||
264 | 260 | long as you offer spare parts or customer support for that product | ||
265 | 261 | model, to give anyone who possesses the object code either (1) a | ||
266 | 262 | copy of the Corresponding Source for all the software in the | ||
267 | 263 | product that is covered by this License, on a durable physical | ||
268 | 264 | medium customarily used for software interchange, for a price no | ||
269 | 265 | more than your reasonable cost of physically performing this | ||
270 | 266 | conveying of source, or (2) access to copy the | ||
271 | 267 | Corresponding Source from a network server at no charge. | ||
272 | 268 | |||
273 | 269 | c) Convey individual copies of the object code with a copy of the | ||
274 | 270 | written offer to provide the Corresponding Source. This | ||
275 | 271 | alternative is allowed only occasionally and noncommercially, and | ||
276 | 272 | only if you received the object code with such an offer, in accord | ||
277 | 273 | with subsection 6b. | ||
278 | 274 | |||
279 | 275 | d) Convey the object code by offering access from a designated | ||
280 | 276 | place (gratis or for a charge), and offer equivalent access to the | ||
281 | 277 | Corresponding Source in the same way through the same place at no | ||
282 | 278 | further charge. You need not require recipients to copy the | ||
283 | 279 | Corresponding Source along with the object code. If the place to | ||
284 | 280 | copy the object code is a network server, the Corresponding Source | ||
285 | 281 | may be on a different server (operated by you or a third party) | ||
286 | 282 | that supports equivalent copying facilities, provided you maintain | ||
287 | 283 | clear directions next to the object code saying where to find the | ||
288 | 284 | Corresponding Source. Regardless of what server hosts the | ||
289 | 285 | Corresponding Source, you remain obligated to ensure that it is | ||
290 | 286 | available for as long as needed to satisfy these requirements. | ||
291 | 287 | |||
292 | 288 | e) Convey the object code using peer-to-peer transmission, provided | ||
293 | 289 | you inform other peers where the object code and Corresponding | ||
294 | 290 | Source of the work are being offered to the general public at no | ||
295 | 291 | charge under subsection 6d. | ||
296 | 292 | |||
297 | 293 | A separable portion of the object code, whose source code is excluded | ||
298 | 294 | from the Corresponding Source as a System Library, need not be | ||
299 | 295 | included in conveying the object code work. | ||
300 | 296 | |||
301 | 297 | A "User Product" is either (1) a "consumer product", which means any | ||
302 | 298 | tangible personal property which is normally used for personal, family, | ||
303 | 299 | or household purposes, or (2) anything designed or sold for incorporation | ||
304 | 300 | into a dwelling. In determining whether a product is a consumer product, | ||
305 | 301 | doubtful cases shall be resolved in favor of coverage. For a particular | ||
306 | 302 | product received by a particular user, "normally used" refers to a | ||
307 | 303 | typical or common use of that class of product, regardless of the status | ||
308 | 304 | of the particular user or of the way in which the particular user | ||
309 | 305 | actually uses, or expects or is expected to use, the product. A product | ||
310 | 306 | is a consumer product regardless of whether the product has substantial | ||
311 | 307 | commercial, industrial or non-consumer uses, unless such uses represent | ||
312 | 308 | the only significant mode of use of the product. | ||
313 | 309 | |||
314 | 310 | "Installation Information" for a User Product means any methods, | ||
315 | 311 | procedures, authorization keys, or other information required to install | ||
316 | 312 | and execute modified versions of a covered work in that User Product from | ||
317 | 313 | a modified version of its Corresponding Source. The information must | ||
318 | 314 | suffice to ensure that the continued functioning of the modified object | ||
319 | 315 | code is in no case prevented or interfered with solely because | ||
320 | 316 | modification has been made. | ||
321 | 317 | |||
322 | 318 | If you convey an object code work under this section in, or with, or | ||
323 | 319 | specifically for use in, a User Product, and the conveying occurs as | ||
324 | 320 | part of a transaction in which the right of possession and use of the | ||
325 | 321 | User Product is transferred to the recipient in perpetuity or for a | ||
326 | 322 | fixed term (regardless of how the transaction is characterized), the | ||
327 | 323 | Corresponding Source conveyed under this section must be accompanied | ||
328 | 324 | by the Installation Information. But this requirement does not apply | ||
329 | 325 | if neither you nor any third party retains the ability to install | ||
330 | 326 | modified object code on the User Product (for example, the work has | ||
331 | 327 | been installed in ROM). | ||
332 | 328 | |||
333 | 329 | The requirement to provide Installation Information does not include a | ||
334 | 330 | requirement to continue to provide support service, warranty, or updates | ||
335 | 331 | for a work that has been modified or installed by the recipient, or for | ||
336 | 332 | the User Product in which it has been modified or installed. Access to a | ||
337 | 333 | network may be denied when the modification itself materially and | ||
338 | 334 | adversely affects the operation of the network or violates the rules and | ||
339 | 335 | protocols for communication across the network. | ||
340 | 336 | |||
341 | 337 | Corresponding Source conveyed, and Installation Information provided, | ||
342 | 338 | in accord with this section must be in a format that is publicly | ||
343 | 339 | documented (and with an implementation available to the public in | ||
344 | 340 | source code form), and must require no special password or key for | ||
345 | 341 | unpacking, reading or copying. | ||
346 | 342 | |||
347 | 343 | 7. Additional Terms. | ||
348 | 344 | |||
349 | 345 | "Additional permissions" are terms that supplement the terms of this | ||
350 | 346 | License by making exceptions from one or more of its conditions. | ||
351 | 347 | Additional permissions that are applicable to the entire Program shall | ||
352 | 348 | be treated as though they were included in this License, to the extent | ||
353 | 349 | that they are valid under applicable law. If additional permissions | ||
354 | 350 | apply only to part of the Program, that part may be used separately | ||
355 | 351 | under those permissions, but the entire Program remains governed by | ||
356 | 352 | this License without regard to the additional permissions. | ||
357 | 353 | |||
358 | 354 | When you convey a copy of a covered work, you may at your option | ||
359 | 355 | remove any additional permissions from that copy, or from any part of | ||
360 | 356 | it. (Additional permissions may be written to require their own | ||
361 | 357 | removal in certain cases when you modify the work.) You may place | ||
362 | 358 | additional permissions on material, added by you to a covered work, | ||
363 | 359 | for which you have or can give appropriate copyright permission. | ||
364 | 360 | |||
365 | 361 | Notwithstanding any other provision of this License, for material you | ||
366 | 362 | add to a covered work, you may (if authorized by the copyright holders of | ||
367 | 363 | that material) supplement the terms of this License with terms: | ||
368 | 364 | |||
369 | 365 | a) Disclaiming warranty or limiting liability differently from the | ||
370 | 366 | terms of sections 15 and 16 of this License; or | ||
371 | 367 | |||
372 | 368 | b) Requiring preservation of specified reasonable legal notices or | ||
373 | 369 | author attributions in that material or in the Appropriate Legal | ||
374 | 370 | Notices displayed by works containing it; or | ||
375 | 371 | |||
376 | 372 | c) Prohibiting misrepresentation of the origin of that material, or | ||
377 | 373 | requiring that modified versions of such material be marked in | ||
378 | 374 | reasonable ways as different from the original version; or | ||
379 | 375 | |||
380 | 376 | d) Limiting the use for publicity purposes of names of licensors or | ||
381 | 377 | authors of the material; or | ||
382 | 378 | |||
383 | 379 | e) Declining to grant rights under trademark law for use of some | ||
384 | 380 | trade names, trademarks, or service marks; or | ||
385 | 381 | |||
386 | 382 | f) Requiring indemnification of licensors and authors of that | ||
387 | 383 | material by anyone who conveys the material (or modified versions of | ||
388 | 384 | it) with contractual assumptions of liability to the recipient, for | ||
389 | 385 | any liability that these contractual assumptions directly impose on | ||
390 | 386 | those licensors and authors. | ||
391 | 387 | |||
392 | 388 | All other non-permissive additional terms are considered "further | ||
393 | 389 | restrictions" within the meaning of section 10. If the Program as you | ||
394 | 390 | received it, or any part of it, contains a notice stating that it is | ||
395 | 391 | governed by this License along with a term that is a further | ||
396 | 392 | restriction, you may remove that term. If a license document contains | ||
397 | 393 | a further restriction but permits relicensing or conveying under this | ||
398 | 394 | License, you may add to a covered work material governed by the terms | ||
399 | 395 | of that license document, provided that the further restriction does | ||
400 | 396 | not survive such relicensing or conveying. | ||
401 | 397 | |||
402 | 398 | If you add terms to a covered work in accord with this section, you | ||
403 | 399 | must place, in the relevant source files, a statement of the | ||
404 | 400 | additional terms that apply to those files, or a notice indicating | ||
405 | 401 | where to find the applicable terms. | ||
406 | 402 | |||
407 | 403 | Additional terms, permissive or non-permissive, may be stated in the | ||
408 | 404 | form of a separately written license, or stated as exceptions; | ||
409 | 405 | the above requirements apply either way. | ||
410 | 406 | |||
411 | 407 | 8. Termination. | ||
412 | 408 | |||
413 | 409 | You may not propagate or modify a covered work except as expressly | ||
414 | 410 | provided under this License. Any attempt otherwise to propagate or | ||
415 | 411 | modify it is void, and will automatically terminate your rights under | ||
416 | 412 | this License (including any patent licenses granted under the third | ||
417 | 413 | paragraph of section 11). | ||
418 | 414 | |||
419 | 415 | However, if you cease all violation of this License, then your | ||
420 | 416 | license from a particular copyright holder is reinstated (a) | ||
421 | 417 | provisionally, unless and until the copyright holder explicitly and | ||
422 | 418 | finally terminates your license, and (b) permanently, if the copyright | ||
423 | 419 | holder fails to notify you of the violation by some reasonable means | ||
424 | 420 | prior to 60 days after the cessation. | ||
425 | 421 | |||
426 | 422 | Moreover, your license from a particular copyright holder is | ||
427 | 423 | reinstated permanently if the copyright holder notifies you of the | ||
428 | 424 | violation by some reasonable means, this is the first time you have | ||
429 | 425 | received notice of violation of this License (for any work) from that | ||
430 | 426 | copyright holder, and you cure the violation prior to 30 days after | ||
431 | 427 | your receipt of the notice. | ||
432 | 428 | |||
433 | 429 | Termination of your rights under this section does not terminate the | ||
434 | 430 | licenses of parties who have received copies or rights from you under | ||
435 | 431 | this License. If your rights have been terminated and not permanently | ||
436 | 432 | reinstated, you do not qualify to receive new licenses for the same | ||
437 | 433 | material under section 10. | ||
438 | 434 | |||
439 | 435 | 9. Acceptance Not Required for Having Copies. | ||
440 | 436 | |||
441 | 437 | You are not required to accept this License in order to receive or | ||
442 | 438 | run a copy of the Program. Ancillary propagation of a covered work | ||
443 | 439 | occurring solely as a consequence of using peer-to-peer transmission | ||
444 | 440 | to receive a copy likewise does not require acceptance. However, | ||
445 | 441 | nothing other than this License grants you permission to propagate or | ||
446 | 442 | modify any covered work. These actions infringe copyright if you do | ||
447 | 443 | not accept this License. Therefore, by modifying or propagating a | ||
448 | 444 | covered work, you indicate your acceptance of this License to do so. | ||
449 | 445 | |||
450 | 446 | 10. Automatic Licensing of Downstream Recipients. | ||
451 | 447 | |||
452 | 448 | Each time you convey a covered work, the recipient automatically | ||
453 | 449 | receives a license from the original licensors, to run, modify and | ||
454 | 450 | propagate that work, subject to this License. You are not responsible | ||
455 | 451 | for enforcing compliance by third parties with this License. | ||
456 | 452 | |||
457 | 453 | An "entity transaction" is a transaction transferring control of an | ||
458 | 454 | organization, or substantially all assets of one, or subdividing an | ||
459 | 455 | organization, or merging organizations. If propagation of a covered | ||
460 | 456 | work results from an entity transaction, each party to that | ||
461 | 457 | transaction who receives a copy of the work also receives whatever | ||
462 | 458 | licenses to the work the party's predecessor in interest had or could | ||
463 | 459 | give under the previous paragraph, plus a right to possession of the | ||
464 | 460 | Corresponding Source of the work from the predecessor in interest, if | ||
465 | 461 | the predecessor has it or can get it with reasonable efforts. | ||
466 | 462 | |||
467 | 463 | You may not impose any further restrictions on the exercise of the | ||
468 | 464 | rights granted or affirmed under this License. For example, you may | ||
469 | 465 | not impose a license fee, royalty, or other charge for exercise of | ||
470 | 466 | rights granted under this License, and you may not initiate litigation | ||
471 | 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that | ||
472 | 468 | any patent claim is infringed by making, using, selling, offering for | ||
473 | 469 | sale, or importing the Program or any portion of it. | ||
474 | 470 | |||
475 | 471 | 11. Patents. | ||
476 | 472 | |||
477 | 473 | A "contributor" is a copyright holder who authorizes use under this | ||
478 | 474 | License of the Program or a work on which the Program is based. The | ||
479 | 475 | work thus licensed is called the contributor's "contributor version". | ||
480 | 476 | |||
481 | 477 | A contributor's "essential patent claims" are all patent claims | ||
482 | 478 | owned or controlled by the contributor, whether already acquired or | ||
483 | 479 | hereafter acquired, that would be infringed by some manner, permitted | ||
484 | 480 | by this License, of making, using, or selling its contributor version, | ||
485 | 481 | but do not include claims that would be infringed only as a | ||
486 | 482 | consequence of further modification of the contributor version. For | ||
487 | 483 | purposes of this definition, "control" includes the right to grant | ||
488 | 484 | patent sublicenses in a manner consistent with the requirements of | ||
489 | 485 | this License. | ||
490 | 486 | |||
491 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free | ||
492 | 488 | patent license under the contributor's essential patent claims, to | ||
493 | 489 | make, use, sell, offer for sale, import and otherwise run, modify and | ||
494 | 490 | propagate the contents of its contributor version. | ||
495 | 491 | |||
496 | 492 | In the following three paragraphs, a "patent license" is any express | ||
497 | 493 | agreement or commitment, however denominated, not to enforce a patent | ||
498 | 494 | (such as an express permission to practice a patent or covenant not to | ||
499 | 495 | sue for patent infringement). To "grant" such a patent license to a | ||
500 | 496 | party means to make such an agreement or commitment not to enforce a | ||
501 | 497 | patent against the party. | ||
502 | 498 | |||
503 | 499 | If you convey a covered work, knowingly relying on a patent license, | ||
504 | 500 | and the Corresponding Source of the work is not available for anyone | ||
505 | 501 | to copy, free of charge and under the terms of this License, through a | ||
506 | 502 | publicly available network server or other readily accessible means, | ||
507 | 503 | then you must either (1) cause the Corresponding Source to be so | ||
508 | 504 | available, or (2) arrange to deprive yourself of the benefit of the | ||
509 | 505 | patent license for this particular work, or (3) arrange, in a manner | ||
510 | 506 | consistent with the requirements of this License, to extend the patent | ||
511 | 507 | license to downstream recipients. "Knowingly relying" means you have | ||
512 | 508 | actual knowledge that, but for the patent license, your conveying the | ||
513 | 509 | covered work in a country, or your recipient's use of the covered work | ||
514 | 510 | in a country, would infringe one or more identifiable patents in that | ||
515 | 511 | country that you have reason to believe are valid. | ||
516 | 512 | |||
517 | 513 | If, pursuant to or in connection with a single transaction or | ||
518 | 514 | arrangement, you convey, or propagate by procuring conveyance of, a | ||
519 | 515 | covered work, and grant a patent license to some of the parties | ||
520 | 516 | receiving the covered work authorizing them to use, propagate, modify | ||
521 | 517 | or convey a specific copy of the covered work, then the patent license | ||
522 | 518 | you grant is automatically extended to all recipients of the covered | ||
523 | 519 | work and works based on it. | ||
524 | 520 | |||
525 | 521 | A patent license is "discriminatory" if it does not include within | ||
526 | 522 | the scope of its coverage, prohibits the exercise of, or is | ||
527 | 523 | conditioned on the non-exercise of one or more of the rights that are | ||
528 | 524 | specifically granted under this License. You may not convey a covered | ||
529 | 525 | work if you are a party to an arrangement with a third party that is | ||
530 | 526 | in the business of distributing software, under which you make payment | ||
531 | 527 | to the third party based on the extent of your activity of conveying | ||
532 | 528 | the work, and under which the third party grants, to any of the | ||
533 | 529 | parties who would receive the covered work from you, a discriminatory | ||
534 | 530 | patent license (a) in connection with copies of the covered work | ||
535 | 531 | conveyed by you (or copies made from those copies), or (b) primarily | ||
536 | 532 | for and in connection with specific products or compilations that | ||
537 | 533 | contain the covered work, unless you entered into that arrangement, | ||
538 | 534 | or that patent license was granted, prior to 28 March 2007. | ||
539 | 535 | |||
540 | 536 | Nothing in this License shall be construed as excluding or limiting | ||
541 | 537 | any implied license or other defenses to infringement that may | ||
542 | 538 | otherwise be available to you under applicable patent law. | ||
543 | 539 | |||
544 | 540 | 12. No Surrender of Others' Freedom. | ||
545 | 541 | |||
546 | 542 | If conditions are imposed on you (whether by court order, agreement or | ||
547 | 543 | otherwise) that contradict the conditions of this License, they do not | ||
548 | 544 | excuse you from the conditions of this License. If you cannot convey a | ||
549 | 545 | covered work so as to satisfy simultaneously your obligations under this | ||
550 | 546 | License and any other pertinent obligations, then as a consequence you may | ||
551 | 547 | not convey it at all. For example, if you agree to terms that obligate you | ||
552 | 548 | to collect a royalty for further conveying from those to whom you convey | ||
553 | 549 | the Program, the only way you could satisfy both those terms and this | ||
554 | 550 | License would be to refrain entirely from conveying the Program. | ||
555 | 551 | |||
556 | 552 | 13. Use with the GNU Affero General Public License. | ||
557 | 553 | |||
558 | 554 | Notwithstanding any other provision of this License, you have | ||
559 | 555 | permission to link or combine any covered work with a work licensed | ||
560 | 556 | under version 3 of the GNU Affero General Public License into a single | ||
561 | 557 | combined work, and to convey the resulting work. The terms of this | ||
562 | 558 | License will continue to apply to the part which is the covered work, | ||
563 | 559 | but the special requirements of the GNU Affero General Public License, | ||
564 | 560 | section 13, concerning interaction through a network will apply to the | ||
565 | 561 | combination as such. | ||
566 | 562 | |||
567 | 563 | 14. Revised Versions of this License. | ||
568 | 564 | |||
569 | 565 | The Free Software Foundation may publish revised and/or new versions of | ||
570 | 566 | the GNU General Public License from time to time. Such new versions will | ||
571 | 567 | be similar in spirit to the present version, but may differ in detail to | ||
572 | 568 | address new problems or concerns. | ||
573 | 569 | |||
574 | 570 | Each version is given a distinguishing version number. If the | ||
575 | 571 | Program specifies that a certain numbered version of the GNU General | ||
576 | 572 | Public License "or any later version" applies to it, you have the | ||
577 | 573 | option of following the terms and conditions either of that numbered | ||
578 | 574 | version or of any later version published by the Free Software | ||
579 | 575 | Foundation. If the Program does not specify a version number of the | ||
580 | 576 | GNU General Public License, you may choose any version ever published | ||
581 | 577 | by the Free Software Foundation. | ||
582 | 578 | |||
583 | 579 | If the Program specifies that a proxy can decide which future | ||
584 | 580 | versions of the GNU General Public License can be used, that proxy's | ||
585 | 581 | public statement of acceptance of a version permanently authorizes you | ||
586 | 582 | to choose that version for the Program. | ||
587 | 583 | |||
588 | 584 | Later license versions may give you additional or different | ||
589 | 585 | permissions. However, no additional obligations are imposed on any | ||
590 | 586 | author or copyright holder as a result of your choosing to follow a | ||
591 | 587 | later version. | ||
592 | 588 | |||
593 | 589 | 15. Disclaimer of Warranty. | ||
594 | 590 | |||
595 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY | ||
596 | 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT | ||
597 | 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY | ||
598 | 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, | ||
599 | 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
600 | 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM | ||
601 | 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF | ||
602 | 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. | ||
603 | 599 | |||
604 | 600 | 16. Limitation of Liability. | ||
605 | 601 | |||
606 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING | ||
607 | 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS | ||
608 | 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY | ||
609 | 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE | ||
610 | 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF | ||
611 | 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD | ||
612 | 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), | ||
613 | 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF | ||
614 | 610 | SUCH DAMAGES. | ||
615 | 611 | |||
616 | 612 | 17. Interpretation of Sections 15 and 16. | ||
617 | 613 | |||
618 | 614 | If the disclaimer of warranty and limitation of liability provided | ||
619 | 615 | above cannot be given local legal effect according to their terms, | ||
620 | 616 | reviewing courts shall apply local law that most closely approximates | ||
621 | 617 | an absolute waiver of all civil liability in connection with the | ||
622 | 618 | Program, unless a warranty or assumption of liability accompanies a | ||
623 | 619 | copy of the Program in return for a fee. | ||
624 | 620 | |||
625 | 621 | END OF TERMS AND CONDITIONS | ||
626 | 622 | |||
627 | 623 | How to Apply These Terms to Your New Programs | ||
628 | 624 | |||
629 | 625 | If you develop a new program, and you want it to be of the greatest | ||
630 | 626 | possible use to the public, the best way to achieve this is to make it | ||
631 | 627 | free software which everyone can redistribute and change under these terms. | ||
632 | 628 | |||
633 | 629 | To do so, attach the following notices to the program. It is safest | ||
634 | 630 | to attach them to the start of each source file to most effectively | ||
635 | 631 | state the exclusion of warranty; and each file should have at least | ||
636 | 632 | the "copyright" line and a pointer to where the full notice is found. | ||
637 | 633 | |||
638 | 634 | <one line to give the program's name and a brief idea of what it does.> | ||
639 | 635 | Copyright (C) <year> <name of author> | ||
640 | 636 | |||
641 | 637 | This program is free software: you can redistribute it and/or modify | ||
642 | 638 | it under the terms of the GNU General Public License as published by | ||
643 | 639 | the Free Software Foundation, either version 3 of the License, or | ||
644 | 640 | (at your option) any later version. | ||
645 | 641 | |||
646 | 642 | This program is distributed in the hope that it will be useful, | ||
647 | 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
648 | 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
649 | 645 | GNU General Public License for more details. | ||
650 | 646 | |||
651 | 647 | You should have received a copy of the GNU General Public License | ||
652 | 648 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
653 | 649 | |||
654 | 650 | Also add information on how to contact you by electronic and paper mail. | ||
655 | 651 | |||
656 | 652 | If the program does terminal interaction, make it output a short | ||
657 | 653 | notice like this when it starts in an interactive mode: | ||
658 | 654 | |||
659 | 655 | <program> Copyright (C) <year> <name of author> | ||
660 | 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. | ||
661 | 657 | This is free software, and you are welcome to redistribute it | ||
662 | 658 | under certain conditions; type `show c' for details. | ||
663 | 659 | |||
664 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate | ||
665 | 661 | parts of the General Public License. Of course, your program's commands | ||
666 | 662 | might be different; for a GUI interface, you would use an "about box". | ||
667 | 663 | |||
668 | 664 | You should also get your employer (if you work as a programmer) or school, | ||
669 | 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. | ||
670 | 666 | For more information on this, and how to apply and follow the GNU GPL, see | ||
671 | 667 | <http://www.gnu.org/licenses/>. | ||
672 | 668 | |||
673 | 669 | The GNU General Public License does not permit incorporating your program | ||
674 | 670 | into proprietary programs. If your program is a subroutine library, you | ||
675 | 671 | may consider it more useful to permit linking proprietary applications with | ||
676 | 672 | the library. If this is what you want to do, use the GNU Lesser General | ||
677 | 673 | Public License instead of this License. But first, please read | ||
678 | 674 | <http://www.gnu.org/philosophy/why-not-lgpl.html>. | ||
679 | 0 | 675 | ||
680 | === modified file 'Makefile.am' | |||
681 | --- Makefile.am 2012-08-29 11:27:54 +0000 | |||
682 | +++ Makefile.am 2013-04-26 16:57:25 +0000 | |||
683 | @@ -1,5 +1,6 @@ | |||
684 | 1 | 1 | ||
685 | 2 | SUBDIRS = \ | 2 | SUBDIRS = \ |
686 | 3 | common \ | ||
687 | 3 | src \ | 4 | src \ |
688 | 4 | libmessaging-menu \ | 5 | libmessaging-menu \ |
689 | 5 | data \ | 6 | data \ |
690 | 6 | 7 | ||
691 | === added directory 'common' | |||
692 | === added file 'common/Makefile.am' | |||
693 | --- common/Makefile.am 1970-01-01 00:00:00 +0000 | |||
694 | +++ common/Makefile.am 2013-04-26 16:57:25 +0000 | |||
695 | @@ -0,0 +1,32 @@ | |||
696 | 1 | |||
697 | 2 | noinst_LTLIBRARIES = libmessaging-common.la | ||
698 | 3 | |||
699 | 4 | indicator-messages-service.c: com.canonical.indicator.messages.service.xml | ||
700 | 5 | $(AM_V_GEN) gdbus-codegen \ | ||
701 | 6 | --interface-prefix com.canonical.indicator.messages. \ | ||
702 | 7 | --generate-c-code indicator-messages-service \ | ||
703 | 8 | --c-namespace IndicatorMessages \ | ||
704 | 9 | $^ | ||
705 | 10 | indicator-messages-service.h: indicator-messages-service.c | ||
706 | 11 | |||
707 | 12 | indicator-messages-application.c: com.canonical.indicator.messages.application.xml | ||
708 | 13 | $(AM_V_GEN) gdbus-codegen \ | ||
709 | 14 | --interface-prefix com.canonical.indicator.messages. \ | ||
710 | 15 | --generate-c-code indicator-messages-application \ | ||
711 | 16 | --c-namespace IndicatorMessages \ | ||
712 | 17 | $^ | ||
713 | 18 | indicator-messages-application.h: indicator-messages-application.c | ||
714 | 19 | |||
715 | 20 | BUILT_SOURCES = \ | ||
716 | 21 | indicator-messages-service.c \ | ||
717 | 22 | indicator-messages-service.h \ | ||
718 | 23 | indicator-messages-application.c \ | ||
719 | 24 | indicator-messages-application.h | ||
720 | 25 | |||
721 | 26 | libmessaging_common_la_SOURCES = \ | ||
722 | 27 | $(BUILT_SOURCES) | ||
723 | 28 | |||
724 | 29 | libmessaging_common_la_CFLAGS = $(GIO_CFLAGS) | ||
725 | 30 | libmessaging_common_la_LIBADD = $(GIO_LIBS) | ||
726 | 31 | |||
727 | 32 | CLEANFILES = $(BUILT_SOURCES) | ||
728 | 0 | 33 | ||
729 | === added file 'common/com.canonical.indicator.messages.application.xml' | |||
730 | --- common/com.canonical.indicator.messages.application.xml 1970-01-01 00:00:00 +0000 | |||
731 | +++ common/com.canonical.indicator.messages.application.xml 2013-04-26 16:57:25 +0000 | |||
732 | @@ -0,0 +1,39 @@ | |||
733 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
734 | 2 | <node name="/"> | ||
735 | 3 | <interface name="com.canonical.indicator.messages.application"> | ||
736 | 4 | <method name="ListSources"> | ||
737 | 5 | <arg type="a(sssuxsb)" name="sources" direction="out" /> | ||
738 | 6 | </method> | ||
739 | 7 | <method name="ListMessages"> | ||
740 | 8 | <arg type="a(sssssxaa{sv}b)" name="message" direction="out" /> | ||
741 | 9 | </method> | ||
742 | 10 | <method name="ActivateSource"> | ||
743 | 11 | <arg type="s" name="source_id" direction="in" /> | ||
744 | 12 | </method> | ||
745 | 13 | <method name="ActivateMessage"> | ||
746 | 14 | <arg type="s" name="message_id" direction="in" /> | ||
747 | 15 | <arg type="s" name="action_id" direction="in" /> | ||
748 | 16 | <arg type="av" name="parameter" direction="in" /> | ||
749 | 17 | </method> | ||
750 | 18 | <method name="Dismiss"> | ||
751 | 19 | <arg type="as" name="sources" direction="in" /> | ||
752 | 20 | <arg type="as" name="messages" direction="in" /> | ||
753 | 21 | </method> | ||
754 | 22 | <signal name="SourceAdded"> | ||
755 | 23 | <arg type="u" name="position" direction="in" /> | ||
756 | 24 | <arg type="(sssuxsb)" name="source" direction="in" /> | ||
757 | 25 | </signal> | ||
758 | 26 | <signal name="SourceChanged"> | ||
759 | 27 | <arg type="(sssuxsb)" name="source" direction="in" /> | ||
760 | 28 | </signal> | ||
761 | 29 | <signal name="SourceRemoved"> | ||
762 | 30 | <arg type="s" name="source_id" direction="in" /> | ||
763 | 31 | </signal> | ||
764 | 32 | <signal name="MessageAdded"> | ||
765 | 33 | <arg type="(sssssxaa{sv}b)" name="message" direction="in" /> | ||
766 | 34 | </signal> | ||
767 | 35 | <signal name="MessageRemoved"> | ||
768 | 36 | <arg type="s" name="message_id" direction="in" /> | ||
769 | 37 | </signal> | ||
770 | 38 | </interface> | ||
771 | 39 | </node> | ||
772 | 0 | 40 | ||
773 | === renamed file 'src/messages-service.xml' => 'common/com.canonical.indicator.messages.service.xml' | |||
774 | === modified file 'configure.ac' | |||
775 | --- configure.ac 2013-01-22 20:30:05 +0000 | |||
776 | +++ configure.ac 2013-04-26 16:57:25 +0000 | |||
777 | @@ -156,6 +156,7 @@ | |||
778 | 156 | AC_OUTPUT([ | 156 | AC_OUTPUT([ |
779 | 157 | Makefile | 157 | Makefile |
780 | 158 | src/Makefile | 158 | src/Makefile |
781 | 159 | common/Makefile | ||
782 | 159 | data/Makefile | 160 | data/Makefile |
783 | 160 | data/icons/Makefile | 161 | data/icons/Makefile |
784 | 161 | data/icons/16x16/Makefile | 162 | data/icons/16x16/Makefile |
785 | 162 | 163 | ||
786 | === modified file 'debian/changelog' | |||
787 | --- debian/changelog 2013-02-13 02:02:12 +0000 | |||
788 | +++ debian/changelog 2013-04-26 16:57:25 +0000 | |||
789 | @@ -1,3 +1,4 @@ | |||
790 | 1 | <<<<<<< TREE | ||
791 | 1 | indicator-messages (12.10.6daily13.02.13-0ubuntu1) raring; urgency=low | 2 | indicator-messages (12.10.6daily13.02.13-0ubuntu1) raring; urgency=low |
792 | 2 | 3 | ||
793 | 3 | [ Jason Conti ] | 4 | [ Jason Conti ] |
794 | @@ -33,6 +34,88 @@ | |||
795 | 33 | indicator-messages (12.10.6daily12.11.21.1-0ubuntu1) raring; urgency=low | 34 | indicator-messages (12.10.6daily12.11.21.1-0ubuntu1) raring; urgency=low |
796 | 34 | 35 | ||
797 | 35 | [ Mathieu Trudel-Lapierre ] | 36 | [ Mathieu Trudel-Lapierre ] |
798 | 37 | ======= | ||
799 | 38 | indicator-messages (13.10.0phablet1) raring; urgency=low | ||
800 | 39 | |||
801 | 40 | * Version bump to not pull from archives | ||
802 | 41 | |||
803 | 42 | -- Sergio Schvezov <sergio.schvezov@canonical.com> Fri, 26 Apr 2013 13:53:53 -0300 | ||
804 | 43 | |||
805 | 44 | indicator-messages (12.10.6phablet1) quantal; urgency=low | ||
806 | 45 | |||
807 | 46 | * Adding guards for g_type_init | ||
808 | 47 | |||
809 | 48 | -- Sergio Schvezov <sergio.schvezov@canonical.com> Fri, 22 Mar 2013 17:23:45 -0300 | ||
810 | 49 | |||
811 | 50 | indicator-messages (12.10.6-0ubuntu1phablet9) quantal; urgency=low | ||
812 | 51 | |||
813 | 52 | * add "remove-all" signal to imapplicationlist (temporarily) | ||
814 | 53 | |||
815 | 54 | -- Lars Uebernickel <lars.uebernickel@ubuntu.com> Thu, 20 Dec 2012 18:49:50 +0100 | ||
816 | 55 | |||
817 | 56 | indicator-messages (12.10.6-0ubuntu1phablet8) quantal; urgency=low | ||
818 | 57 | |||
819 | 58 | * Make messaging_menu_app_remove_message() work for messages with a ref count of 1 | ||
820 | 59 | * Make handling of multiple processes with the same desktop id more robust | ||
821 | 60 | * ImPhoneMenu: sort messages by time (fixes LP #1090266) | ||
822 | 61 | * Don't show message sources | ||
823 | 62 | |||
824 | 63 | -- Lars Uebernickel <lars.uebernickel@ubuntu.com> Mon, 17 Dec 2012 14:42:03 +0100 | ||
825 | 64 | |||
826 | 65 | indicator-messages (12.10.6-0ubuntu1phablet7) quantal; urgency=low | ||
827 | 66 | |||
828 | 67 | * Remove variant wrapper from 'parameter' argument of the "activate" signal | ||
829 | 68 | |||
830 | 69 | -- Lars Uebernickel <lars.uebernickel@ubuntu.com> Tue, 11 Dec 2012 14:28:15 +0100 | ||
831 | 70 | |||
832 | 71 | indicator-messages (12.10.6-0ubuntu1phablet6) quantal; urgency=low | ||
833 | 72 | |||
834 | 73 | * Don't show sources | ||
835 | 74 | * Always use the "messageitem" widget type for messages | ||
836 | 75 | |||
837 | 76 | -- Lars Uebernickel <lars.uebernickel@ubuntu.com> Mon, 10 Dec 2012 14:38:16 +0100 | ||
838 | 77 | |||
839 | 78 | indicator-messages (12.10.6-0ubuntu1phablet5) quantal; urgency=low | ||
840 | 79 | |||
841 | 80 | * Don't shorten the app id to seven characters (fixes LP #1086729) | ||
842 | 81 | * Add messaging_menu_app_get_message | ||
843 | 82 | |||
844 | 83 | -- Lars Uebernickel <lars.uebernickel@ubuntu.com> Thu, 06 Dec 2012 15:06:34 +0000 | ||
845 | 84 | |||
846 | 85 | indicator-messages (12.10.6-0ubuntu1phablet4) quantal; urgency=low | ||
847 | 86 | |||
848 | 87 | [Lars Uebernickel] | ||
849 | 88 | * Add the concept of actions to messages | ||
850 | 89 | * Stop using IndicatorService | ||
851 | 90 | * Reverse order of messages | ||
852 | 91 | * Expose symbolic application icon | ||
853 | 92 | * Change icon when there are any messages in the menu | ||
854 | 93 | |||
855 | 94 | -- Lars Uebernickel <lars.uebernickel@ubuntu.com> Tue, 04 Dec 2012 21:10:26 +0000 | ||
856 | 95 | |||
857 | 96 | indicator-messages (12.10.6-0ubuntu1phablet3) quantal; urgency=low | ||
858 | 97 | |||
859 | 98 | [Lars Uebernickel] | ||
860 | 99 | * expose root menu item of which the indicator menu is a submenu | ||
861 | 100 | * fix crash in im-application-list on arm | ||
862 | 101 | |||
863 | 102 | -- Lars Uebernickel <lars.uebernickel@ubuntu.com> Thu, 29 Nov 2012 21:44:19 +0100 | ||
864 | 103 | |||
865 | 104 | indicator-messages (12.10.6-0ubuntu1phablet2) quantal; urgency=low | ||
866 | 105 | |||
867 | 106 | [Lars Uebernickel] | ||
868 | 107 | * refactor messages-service.c | ||
869 | 108 | * notify applications about message and source activations | ||
870 | 109 | * add "Clear All" menu item | ||
871 | 110 | * allow dismissing of messages | ||
872 | 111 | * include application icons on message items | ||
873 | 112 | |||
874 | 113 | -- Lars Uebernickel <lars.uebernickel@ubuntu.com> Mon, 26 Nov 2012 22:19:51 +0100 | ||
875 | 114 | |||
876 | 115 | indicator-messages (12.10.6-0ubuntu1phablet1) quantal; urgency=low | ||
877 | 116 | |||
878 | 117 | [ Mathieu Trudel-Lapierre ] | ||
879 | 118 | >>>>>>> MERGE-SOURCE | ||
880 | 36 | * debian/rules: | 119 | * debian/rules: |
881 | 37 | - Use autogen.sh for dh_autoreconf. | 120 | - Use autogen.sh for dh_autoreconf. |
882 | 38 | - Drop the override for dh_makeshlibs. | 121 | - Drop the override for dh_makeshlibs. |
883 | @@ -45,10 +128,17 @@ | |||
884 | 45 | - Clear the detail (count or time) of a source when another type of detail | 128 | - Clear the detail (count or time) of a source when another type of detail |
885 | 46 | is set. (LP: #1071640) | 129 | is set. (LP: #1071640) |
886 | 47 | 130 | ||
887 | 131 | <<<<<<< TREE | ||
888 | 48 | [ Automatic PS uploader ] | 132 | [ Automatic PS uploader ] |
889 | 49 | * Automatic snapshot from revision 331 | 133 | * Automatic snapshot from revision 331 |
890 | 50 | 134 | ||
891 | 51 | -- Automatic PS uploader <ps-jenkins@lists.canonical.com> Wed, 21 Nov 2012 10:41:37 +0000 | 135 | -- Automatic PS uploader <ps-jenkins@lists.canonical.com> Wed, 21 Nov 2012 10:41:37 +0000 |
892 | 136 | ======= | ||
893 | 137 | [ Ricardo Mendoza ] | ||
894 | 138 | * Releasing upstream for phablet | ||
895 | 139 | |||
896 | 140 | -- Ricardo Mendoza <ricardo.mendoza@canonical.com> Tue, 20 Nov 2012 10:08:59 -0430 | ||
897 | 141 | >>>>>>> MERGE-SOURCE | ||
898 | 52 | 142 | ||
899 | 53 | indicator-messages (12.10.5-0ubuntu2) raring; urgency=low | 143 | indicator-messages (12.10.5-0ubuntu2) raring; urgency=low |
900 | 54 | 144 | ||
901 | 55 | 145 | ||
902 | === modified file 'debian/libmessaging-menu0.symbols' | |||
903 | --- debian/libmessaging-menu0.symbols 2012-09-01 10:35:36 +0000 | |||
904 | +++ debian/libmessaging-menu0.symbols 2013-04-26 16:57:25 +0000 | |||
905 | @@ -1,9 +1,11 @@ | |||
906 | 1 | libmessaging-menu.so.0 libmessaging-menu0 #MINVER# | 1 | libmessaging-menu.so.0 libmessaging-menu0 #MINVER# |
907 | 2 | messaging_menu_app_append_message@Base 12.10.6-0ubuntu1phablet1 | ||
908 | 2 | messaging_menu_app_append_source@Base 12.10.0 | 3 | messaging_menu_app_append_source@Base 12.10.0 |
909 | 3 | messaging_menu_app_append_source_with_count@Base 12.10.0 | 4 | messaging_menu_app_append_source_with_count@Base 12.10.0 |
910 | 4 | messaging_menu_app_append_source_with_string@Base 12.10.0 | 5 | messaging_menu_app_append_source_with_string@Base 12.10.0 |
911 | 5 | messaging_menu_app_append_source_with_time@Base 12.10.0 | 6 | messaging_menu_app_append_source_with_time@Base 12.10.0 |
912 | 6 | messaging_menu_app_draw_attention@Base 12.10.0 | 7 | messaging_menu_app_draw_attention@Base 12.10.0 |
913 | 8 | messaging_menu_app_get_message@Base 0replaceme | ||
914 | 7 | messaging_menu_app_get_type@Base 12.10.0 | 9 | messaging_menu_app_get_type@Base 12.10.0 |
915 | 8 | messaging_menu_app_has_source@Base 12.10.0 | 10 | messaging_menu_app_has_source@Base 12.10.0 |
916 | 9 | messaging_menu_app_insert_source@Base 12.10.0 | 11 | messaging_menu_app_insert_source@Base 12.10.0 |
917 | @@ -13,6 +15,8 @@ | |||
918 | 13 | messaging_menu_app_new@Base 12.10.0 | 15 | messaging_menu_app_new@Base 12.10.0 |
919 | 14 | messaging_menu_app_register@Base 12.10.0 | 16 | messaging_menu_app_register@Base 12.10.0 |
920 | 15 | messaging_menu_app_remove_attention@Base 12.10.0 | 17 | messaging_menu_app_remove_attention@Base 12.10.0 |
921 | 18 | messaging_menu_app_remove_message@Base 12.10.6-0ubuntu1phablet1 | ||
922 | 19 | messaging_menu_app_remove_message_by_id@Base 12.10.6-0ubuntu1phablet1 | ||
923 | 16 | messaging_menu_app_remove_source@Base 12.10.0 | 20 | messaging_menu_app_remove_source@Base 12.10.0 |
924 | 17 | messaging_menu_app_set_source_count@Base 12.10.0 | 21 | messaging_menu_app_set_source_count@Base 12.10.0 |
925 | 18 | messaging_menu_app_set_source_icon@Base 12.10.2 | 22 | messaging_menu_app_set_source_icon@Base 12.10.2 |
926 | @@ -21,3 +25,14 @@ | |||
927 | 21 | messaging_menu_app_set_source_time@Base 12.10.0 | 25 | messaging_menu_app_set_source_time@Base 12.10.0 |
928 | 22 | messaging_menu_app_set_status@Base 12.10.0 | 26 | messaging_menu_app_set_status@Base 12.10.0 |
929 | 23 | messaging_menu_app_unregister@Base 12.10.0 | 27 | messaging_menu_app_unregister@Base 12.10.0 |
930 | 28 | messaging_menu_message_add_action@Base 12.10.6-0ubuntu1phablet3 | ||
931 | 29 | messaging_menu_message_get_body@Base 12.10.6-0ubuntu1phablet1 | ||
932 | 30 | messaging_menu_message_get_draws_attention@Base 12.10.6-0ubuntu1phablet1 | ||
933 | 31 | messaging_menu_message_get_icon@Base 12.10.6-0ubuntu1phablet1 | ||
934 | 32 | messaging_menu_message_get_id@Base 12.10.6-0ubuntu1phablet1 | ||
935 | 33 | messaging_menu_message_get_subtitle@Base 12.10.6-0ubuntu1phablet1 | ||
936 | 34 | messaging_menu_message_get_time@Base 12.10.6-0ubuntu1phablet1 | ||
937 | 35 | messaging_menu_message_get_title@Base 12.10.6-0ubuntu1phablet1 | ||
938 | 36 | messaging_menu_message_get_type@Base 12.10.6-0ubuntu1phablet1 | ||
939 | 37 | messaging_menu_message_new@Base 12.10.6-0ubuntu1phablet1 | ||
940 | 38 | messaging_menu_message_set_draws_attention@Base 12.10.6-0ubuntu1phablet1 | ||
941 | 24 | 39 | ||
942 | === added directory 'debian/source' | |||
943 | === added file 'debian/source/format' | |||
944 | --- debian/source/format 1970-01-01 00:00:00 +0000 | |||
945 | +++ debian/source/format 2013-04-26 16:57:25 +0000 | |||
946 | @@ -0,0 +1,1 @@ | |||
947 | 1 | 1.0 | ||
948 | 0 | 2 | ||
949 | === modified file 'doc/reference/Makefile.am' | |||
950 | --- doc/reference/Makefile.am 2013-01-22 20:23:57 +0000 | |||
951 | +++ doc/reference/Makefile.am 2013-04-26 16:57:25 +0000 | |||
952 | @@ -11,8 +11,7 @@ | |||
953 | 11 | CFILE_GLOB = $(top_srcdir)/libmessaging-menu/*.c | 11 | CFILE_GLOB = $(top_srcdir)/libmessaging-menu/*.c |
954 | 12 | 12 | ||
955 | 13 | IGNORE_HFILES= \ | 13 | IGNORE_HFILES= \ |
958 | 14 | indicator-messages-service.h \ | 14 | indicator-messages-service.h |
957 | 15 | gtupleaction.h | ||
959 | 16 | 15 | ||
960 | 17 | INCLUDES=-I$(top_srcdir)/libmessaging-menu $(GIO_CFLAGS) | 16 | INCLUDES=-I$(top_srcdir)/libmessaging-menu $(GIO_CFLAGS) |
961 | 18 | GTKDOC_LIBS=$(top_builddir)/libmessaging-menu/libmessaging-menu.la | 17 | GTKDOC_LIBS=$(top_builddir)/libmessaging-menu/libmessaging-menu.la |
962 | 19 | 18 | ||
963 | === modified file 'doc/reference/messaging-menu-docs.xml.in' | |||
964 | --- doc/reference/messaging-menu-docs.xml.in 2012-08-29 11:27:54 +0000 | |||
965 | +++ doc/reference/messaging-menu-docs.xml.in 2013-04-26 16:57:25 +0000 | |||
966 | @@ -18,7 +18,8 @@ | |||
967 | 18 | 18 | ||
968 | 19 | <chapter> | 19 | <chapter> |
969 | 20 | <title>API Reference</title> | 20 | <title>API Reference</title> |
971 | 21 | <xi:include href="xml/messaging-menu.xml"/> | 21 | <xi:include href="xml/messaging-menu-app.xml" /> |
972 | 22 | <xi:include href="xml/messaging-menu-message.xml" /> | ||
973 | 22 | </chapter> | 23 | </chapter> |
974 | 23 | 24 | ||
975 | 24 | <chapter id="object-tree"> | 25 | <chapter id="object-tree"> |
976 | 25 | 26 | ||
977 | === modified file 'libmessaging-menu/Makefile.am' | |||
978 | --- libmessaging-menu/Makefile.am 2012-09-01 08:27:34 +0000 | |||
979 | +++ libmessaging-menu/Makefile.am 2013-04-26 16:57:25 +0000 | |||
980 | @@ -4,36 +4,25 @@ | |||
981 | 4 | libmessaging_menu_ladir = $(includedir)/messaging-menu | 4 | libmessaging_menu_ladir = $(includedir)/messaging-menu |
982 | 5 | 5 | ||
983 | 6 | libmessaging_menu_la_SOURCES = \ | 6 | libmessaging_menu_la_SOURCES = \ |
988 | 7 | messaging-menu.c \ | 7 | messaging-menu-app.c \ |
989 | 8 | gtupleaction.c \ | 8 | messaging-menu-message.c |
986 | 9 | gtupleaction.h \ | ||
987 | 10 | $(BUILT_SOURCES) | ||
990 | 11 | 9 | ||
991 | 12 | libmessaging_menu_la_HEADERS = \ | 10 | libmessaging_menu_la_HEADERS = \ |
993 | 13 | messaging-menu.h | 11 | messaging-menu-app.h \ |
994 | 12 | messaging-menu.h \ | ||
995 | 13 | messaging-menu-message.h | ||
996 | 14 | 14 | ||
998 | 15 | libmessaging_menu_la_LIBADD = $(GIO_LIBS) | 15 | libmessaging_menu_la_LIBADD = \ |
999 | 16 | $(GIO_LIBS) \ | ||
1000 | 17 | $(top_builddir)/common/libmessaging-common.la | ||
1001 | 16 | 18 | ||
1002 | 17 | libmessaging_menu_la_CFLAGS = \ | 19 | libmessaging_menu_la_CFLAGS = \ |
1003 | 20 | -I$(top_builddir)/common \ | ||
1004 | 18 | $(GIO_CFLAGS) \ | 21 | $(GIO_CFLAGS) \ |
1005 | 19 | -Wall | 22 | -Wall |
1006 | 20 | 23 | ||
1007 | 21 | libmessaging_menu_la_LDFLAGS = -export-symbols-regex "^messaging_menu_.*" | 24 | libmessaging_menu_la_LDFLAGS = -export-symbols-regex "^messaging_menu_.*" |
1008 | 22 | 25 | ||
1009 | 23 | BUILT_SOURCES = \ | ||
1010 | 24 | indicator-messages-service.c \ | ||
1011 | 25 | indicator-messages-service.h | ||
1012 | 26 | |||
1013 | 27 | CLEANFILES = $(BUILT_SOURCES) | ||
1014 | 28 | |||
1015 | 29 | indicator-messages-service.c: $(top_srcdir)/src/messages-service.xml | ||
1016 | 30 | $(AM_V_GEN) gdbus-codegen \ | ||
1017 | 31 | --interface-prefix com.canonical.indicator.messages. \ | ||
1018 | 32 | --generate-c-code indicator-messages-service \ | ||
1019 | 33 | --c-namespace IndicatorMessages \ | ||
1020 | 34 | $^ | ||
1021 | 35 | indicator-messages-service.h: indicator-messages-service.c | ||
1022 | 36 | |||
1023 | 37 | pkgconfigdir = $(libdir)/pkgconfig | 26 | pkgconfigdir = $(libdir)/pkgconfig |
1024 | 38 | pkgconfig_DATA = messaging-menu.pc | 27 | pkgconfig_DATA = messaging-menu.pc |
1025 | 39 | 28 | ||
1026 | @@ -52,7 +41,11 @@ | |||
1027 | 52 | MessagingMenu_1_0_gir_CFLAGS = $(INCLUDES) $(GIO_CFLAGS) | 41 | MessagingMenu_1_0_gir_CFLAGS = $(INCLUDES) $(GIO_CFLAGS) |
1028 | 53 | MessagingMenu_1_0_gir_SCANNERFLAGS = --c-include="messaging-menu.h" | 42 | MessagingMenu_1_0_gir_SCANNERFLAGS = --c-include="messaging-menu.h" |
1029 | 54 | MessagingMenu_1_0_gir_LIBS = libmessaging-menu.la | 43 | MessagingMenu_1_0_gir_LIBS = libmessaging-menu.la |
1031 | 55 | MessagingMenu_1_0_gir_FILES = messaging-menu.c messaging-menu.h | 44 | MessagingMenu_1_0_gir_FILES = \ |
1032 | 45 | messaging-menu-app.c \ | ||
1033 | 46 | messaging-menu-app.h \ | ||
1034 | 47 | messaging-menu-message.c \ | ||
1035 | 48 | messaging-menu-message.h | ||
1036 | 56 | MessagingMenu_1_0_gir_EXPORT_PACKAGES = messaging-menu | 49 | MessagingMenu_1_0_gir_EXPORT_PACKAGES = messaging-menu |
1037 | 57 | INTROSPECTION_GIRS += MessagingMenu-1.0.gir | 50 | INTROSPECTION_GIRS += MessagingMenu-1.0.gir |
1038 | 58 | 51 | ||
1039 | @@ -62,5 +55,5 @@ | |||
1040 | 62 | typelibdir = $(libdir)/girepository-1.0 | 55 | typelibdir = $(libdir)/girepository-1.0 |
1041 | 63 | typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) | 56 | typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) |
1042 | 64 | 57 | ||
1044 | 65 | CLEANFILES +=$(gir_DATA) $(typelib_DATA) | 58 | CLEANFILES = $(gir_DATA) $(typelib_DATA) |
1045 | 66 | endif | 59 | endif |
1046 | 67 | 60 | ||
1047 | === removed file 'libmessaging-menu/gtupleaction.c' | |||
1048 | --- libmessaging-menu/gtupleaction.c 2012-08-20 21:09:54 +0000 | |||
1049 | +++ libmessaging-menu/gtupleaction.c 1970-01-01 00:00:00 +0000 | |||
1050 | @@ -1,354 +0,0 @@ | |||
1051 | 1 | /* | ||
1052 | 2 | * Copyright 2012 Canonical Ltd. | ||
1053 | 3 | * | ||
1054 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
1055 | 5 | * under the terms of the GNU General Public License version 3, as | ||
1056 | 6 | * published by the Free Software Foundation. | ||
1057 | 7 | * | ||
1058 | 8 | * This program is distributed in the hope that it will be useful, but | ||
1059 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1060 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1061 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
1062 | 12 | * | ||
1063 | 13 | * You should have received a copy of the GNU General Public License along | ||
1064 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1065 | 15 | * | ||
1066 | 16 | * Authors: | ||
1067 | 17 | * Lars Uebernickel <lars.uebernickel@canonical.com> | ||
1068 | 18 | */ | ||
1069 | 19 | |||
1070 | 20 | #include "gtupleaction.h" | ||
1071 | 21 | |||
1072 | 22 | typedef GObjectClass GTupleActionClass; | ||
1073 | 23 | |||
1074 | 24 | struct _GTupleAction | ||
1075 | 25 | { | ||
1076 | 26 | GObject parent; | ||
1077 | 27 | |||
1078 | 28 | gchar *name; | ||
1079 | 29 | GVariantType *type; | ||
1080 | 30 | gboolean enabled; | ||
1081 | 31 | |||
1082 | 32 | gsize n_children; | ||
1083 | 33 | GVariant **children; | ||
1084 | 34 | }; | ||
1085 | 35 | |||
1086 | 36 | static void action_interface_init (GActionInterface *iface); | ||
1087 | 37 | |||
1088 | 38 | G_DEFINE_TYPE_WITH_CODE (GTupleAction, g_tuple_action, G_TYPE_OBJECT, | ||
1089 | 39 | G_IMPLEMENT_INTERFACE (G_TYPE_ACTION, action_interface_init)); | ||
1090 | 40 | |||
1091 | 41 | enum | ||
1092 | 42 | { | ||
1093 | 43 | PROP_0, | ||
1094 | 44 | PROP_NAME, | ||
1095 | 45 | PROP_PARAMETER_TYPE, | ||
1096 | 46 | PROP_ENABLED, | ||
1097 | 47 | PROP_STATE_TYPE, | ||
1098 | 48 | PROP_STATE, | ||
1099 | 49 | N_PROPERTIES | ||
1100 | 50 | }; | ||
1101 | 51 | |||
1102 | 52 | enum | ||
1103 | 53 | { | ||
1104 | 54 | SIGNAL_ACTIVATE, | ||
1105 | 55 | N_SIGNALS | ||
1106 | 56 | }; | ||
1107 | 57 | |||
1108 | 58 | static GParamSpec *properties[N_PROPERTIES]; | ||
1109 | 59 | static guint signal_ids[N_SIGNALS]; | ||
1110 | 60 | |||
1111 | 61 | static const gchar * | ||
1112 | 62 | g_tuple_action_get_name (GAction *action) | ||
1113 | 63 | { | ||
1114 | 64 | GTupleAction *tuple = G_TUPLE_ACTION (action); | ||
1115 | 65 | |||
1116 | 66 | return tuple->name; | ||
1117 | 67 | } | ||
1118 | 68 | |||
1119 | 69 | static const GVariantType * | ||
1120 | 70 | g_tuple_action_get_parameter_type (GAction *action) | ||
1121 | 71 | { | ||
1122 | 72 | return NULL; | ||
1123 | 73 | } | ||
1124 | 74 | |||
1125 | 75 | static const GVariantType * | ||
1126 | 76 | g_tuple_action_get_state_type (GAction *action) | ||
1127 | 77 | { | ||
1128 | 78 | GTupleAction *tuple = G_TUPLE_ACTION (action); | ||
1129 | 79 | |||
1130 | 80 | return tuple->type; | ||
1131 | 81 | } | ||
1132 | 82 | |||
1133 | 83 | static GVariant * | ||
1134 | 84 | g_tuple_action_get_state_hint (GAction *action) | ||
1135 | 85 | { | ||
1136 | 86 | return NULL; | ||
1137 | 87 | } | ||
1138 | 88 | |||
1139 | 89 | static gboolean | ||
1140 | 90 | g_tuple_action_get_enabled (GAction *action) | ||
1141 | 91 | { | ||
1142 | 92 | GTupleAction *tuple = G_TUPLE_ACTION (action); | ||
1143 | 93 | |||
1144 | 94 | return tuple->enabled; | ||
1145 | 95 | } | ||
1146 | 96 | |||
1147 | 97 | static GVariant * | ||
1148 | 98 | g_tuple_action_get_state (GAction *action) | ||
1149 | 99 | { | ||
1150 | 100 | GTupleAction *tuple = G_TUPLE_ACTION (action); | ||
1151 | 101 | GVariant *result; | ||
1152 | 102 | |||
1153 | 103 | result = g_variant_new_tuple (tuple->children, tuple->n_children); | ||
1154 | 104 | return g_variant_ref_sink (result); | ||
1155 | 105 | } | ||
1156 | 106 | |||
1157 | 107 | static void | ||
1158 | 108 | g_tuple_action_set_state (GTupleAction *tuple, | ||
1159 | 109 | GVariant *state) | ||
1160 | 110 | { | ||
1161 | 111 | int i; | ||
1162 | 112 | |||
1163 | 113 | g_return_if_fail (g_variant_type_is_tuple (g_variant_get_type (state))); | ||
1164 | 114 | |||
1165 | 115 | if (tuple->type == NULL) | ||
1166 | 116 | { | ||
1167 | 117 | tuple->type = g_variant_type_copy (g_variant_get_type (state)); | ||
1168 | 118 | tuple->n_children = g_variant_n_children (state); | ||
1169 | 119 | tuple->children = g_new0 (GVariant *, tuple->n_children); | ||
1170 | 120 | } | ||
1171 | 121 | |||
1172 | 122 | for (i = 0; i < tuple->n_children; i++) | ||
1173 | 123 | { | ||
1174 | 124 | if (tuple->children[i]) | ||
1175 | 125 | g_variant_unref (tuple->children[i]); | ||
1176 | 126 | tuple->children[i] = g_variant_get_child_value (state, i); | ||
1177 | 127 | } | ||
1178 | 128 | |||
1179 | 129 | g_object_notify_by_pspec (G_OBJECT (tuple), properties[PROP_STATE]); | ||
1180 | 130 | } | ||
1181 | 131 | |||
1182 | 132 | static void | ||
1183 | 133 | g_tuple_action_change_state (GAction *action, | ||
1184 | 134 | GVariant *value) | ||
1185 | 135 | { | ||
1186 | 136 | GTupleAction *tuple = G_TUPLE_ACTION (action); | ||
1187 | 137 | |||
1188 | 138 | g_return_if_fail (value != NULL); | ||
1189 | 139 | g_return_if_fail (g_variant_is_of_type (value, tuple->type)); | ||
1190 | 140 | |||
1191 | 141 | g_variant_ref_sink (value); | ||
1192 | 142 | |||
1193 | 143 | /* TODO add a change-state signal similar to GSimpleAction */ | ||
1194 | 144 | g_tuple_action_set_state (tuple, value); | ||
1195 | 145 | |||
1196 | 146 | g_variant_unref (value); | ||
1197 | 147 | } | ||
1198 | 148 | |||
1199 | 149 | static void | ||
1200 | 150 | g_tuple_action_activate (GAction *action, | ||
1201 | 151 | GVariant *parameter) | ||
1202 | 152 | { | ||
1203 | 153 | GTupleAction *tuple = G_TUPLE_ACTION (action); | ||
1204 | 154 | |||
1205 | 155 | g_return_if_fail (parameter == NULL); | ||
1206 | 156 | |||
1207 | 157 | if (tuple->enabled) | ||
1208 | 158 | g_signal_emit (tuple, signal_ids[SIGNAL_ACTIVATE], 0, NULL); | ||
1209 | 159 | } | ||
1210 | 160 | |||
1211 | 161 | static void | ||
1212 | 162 | g_tuple_action_get_property (GObject *object, | ||
1213 | 163 | guint prop_id, | ||
1214 | 164 | GValue *value, | ||
1215 | 165 | GParamSpec *pspec) | ||
1216 | 166 | { | ||
1217 | 167 | GAction *action = G_ACTION (object); | ||
1218 | 168 | |||
1219 | 169 | switch (prop_id) | ||
1220 | 170 | { | ||
1221 | 171 | case PROP_NAME: | ||
1222 | 172 | g_value_set_string (value, g_tuple_action_get_name (action)); | ||
1223 | 173 | break; | ||
1224 | 174 | |||
1225 | 175 | case PROP_PARAMETER_TYPE: | ||
1226 | 176 | g_value_set_boxed (value, g_tuple_action_get_parameter_type (action)); | ||
1227 | 177 | break; | ||
1228 | 178 | |||
1229 | 179 | case PROP_ENABLED: | ||
1230 | 180 | g_value_set_boolean (value, g_tuple_action_get_enabled (action)); | ||
1231 | 181 | break; | ||
1232 | 182 | |||
1233 | 183 | case PROP_STATE_TYPE: | ||
1234 | 184 | g_value_set_boxed (value, g_tuple_action_get_state_type (action)); | ||
1235 | 185 | break; | ||
1236 | 186 | |||
1237 | 187 | case PROP_STATE: | ||
1238 | 188 | g_value_take_variant (value, g_tuple_action_get_state (action)); | ||
1239 | 189 | break; | ||
1240 | 190 | |||
1241 | 191 | default: | ||
1242 | 192 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | ||
1243 | 193 | } | ||
1244 | 194 | } | ||
1245 | 195 | |||
1246 | 196 | static void | ||
1247 | 197 | g_tuple_action_set_property (GObject *object, | ||
1248 | 198 | guint prop_id, | ||
1249 | 199 | const GValue *value, | ||
1250 | 200 | GParamSpec *pspec) | ||
1251 | 201 | { | ||
1252 | 202 | GTupleAction *tuple = G_TUPLE_ACTION (object); | ||
1253 | 203 | |||
1254 | 204 | switch (prop_id) | ||
1255 | 205 | { | ||
1256 | 206 | case PROP_NAME: | ||
1257 | 207 | tuple->name = g_value_dup_string (value); | ||
1258 | 208 | g_object_notify_by_pspec (object, properties[PROP_NAME]); | ||
1259 | 209 | break; | ||
1260 | 210 | |||
1261 | 211 | case PROP_ENABLED: | ||
1262 | 212 | tuple->enabled = g_value_get_boolean (value); | ||
1263 | 213 | g_object_notify_by_pspec (object, properties[PROP_ENABLED]); | ||
1264 | 214 | break; | ||
1265 | 215 | |||
1266 | 216 | case PROP_STATE: | ||
1267 | 217 | g_tuple_action_set_state (tuple, g_value_get_variant (value)); | ||
1268 | 218 | break; | ||
1269 | 219 | |||
1270 | 220 | default: | ||
1271 | 221 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | ||
1272 | 222 | } | ||
1273 | 223 | } | ||
1274 | 224 | |||
1275 | 225 | static void | ||
1276 | 226 | g_tuple_action_finalize (GObject *object) | ||
1277 | 227 | { | ||
1278 | 228 | GTupleAction *tuple = G_TUPLE_ACTION (object); | ||
1279 | 229 | int i; | ||
1280 | 230 | |||
1281 | 231 | g_free (tuple->name); | ||
1282 | 232 | g_variant_type_free (tuple->type); | ||
1283 | 233 | |||
1284 | 234 | for (i = 0; i < tuple->n_children; i++) | ||
1285 | 235 | g_variant_unref (tuple->children[i]); | ||
1286 | 236 | |||
1287 | 237 | g_free (tuple->children); | ||
1288 | 238 | |||
1289 | 239 | G_OBJECT_CLASS (g_tuple_action_parent_class)->finalize (object); | ||
1290 | 240 | } | ||
1291 | 241 | |||
1292 | 242 | static void | ||
1293 | 243 | action_interface_init (GActionInterface *iface) | ||
1294 | 244 | { | ||
1295 | 245 | iface->get_name = g_tuple_action_get_name; | ||
1296 | 246 | iface->get_parameter_type = g_tuple_action_get_parameter_type; | ||
1297 | 247 | iface->get_state_type = g_tuple_action_get_state_type; | ||
1298 | 248 | iface->get_state_hint = g_tuple_action_get_state_hint; | ||
1299 | 249 | iface->get_enabled = g_tuple_action_get_enabled; | ||
1300 | 250 | iface->get_state = g_tuple_action_get_state; | ||
1301 | 251 | iface->change_state = g_tuple_action_change_state; | ||
1302 | 252 | iface->activate = g_tuple_action_activate; | ||
1303 | 253 | } | ||
1304 | 254 | |||
1305 | 255 | static void | ||
1306 | 256 | g_tuple_action_class_init (GTupleActionClass *class) | ||
1307 | 257 | { | ||
1308 | 258 | GObjectClass *object_class = G_OBJECT_CLASS (class); | ||
1309 | 259 | |||
1310 | 260 | object_class->get_property = g_tuple_action_get_property; | ||
1311 | 261 | object_class->set_property = g_tuple_action_set_property; | ||
1312 | 262 | object_class->finalize = g_tuple_action_finalize; | ||
1313 | 263 | |||
1314 | 264 | properties[PROP_NAME] = g_param_spec_string ("name", | ||
1315 | 265 | "Name", | ||
1316 | 266 | "The name of the action", | ||
1317 | 267 | NULL, | ||
1318 | 268 | G_PARAM_READWRITE | | ||
1319 | 269 | G_PARAM_CONSTRUCT_ONLY | | ||
1320 | 270 | G_PARAM_STATIC_STRINGS); | ||
1321 | 271 | |||
1322 | 272 | properties[PROP_PARAMETER_TYPE] = g_param_spec_boxed ("parameter-type", | ||
1323 | 273 | "Parameter Type", | ||
1324 | 274 | "The variant type passed to activate", | ||
1325 | 275 | G_TYPE_VARIANT_TYPE, | ||
1326 | 276 | G_PARAM_READABLE | | ||
1327 | 277 | G_PARAM_STATIC_STRINGS); | ||
1328 | 278 | |||
1329 | 279 | properties[PROP_ENABLED] = g_param_spec_boolean ("enabled", | ||
1330 | 280 | "Enabled", | ||
1331 | 281 | "Whether the action can be activated", | ||
1332 | 282 | TRUE, | ||
1333 | 283 | G_PARAM_READWRITE | | ||
1334 | 284 | G_PARAM_STATIC_STRINGS); | ||
1335 | 285 | |||
1336 | 286 | properties[PROP_STATE_TYPE] = g_param_spec_boxed ("state-type", | ||
1337 | 287 | "State Type", | ||
1338 | 288 | "The variant type of the state, must be a tuple", | ||
1339 | 289 | G_TYPE_VARIANT_TYPE, | ||
1340 | 290 | G_PARAM_READABLE | | ||
1341 | 291 | G_PARAM_STATIC_STRINGS); | ||
1342 | 292 | |||
1343 | 293 | properties[PROP_STATE] = g_param_spec_variant ("state", | ||
1344 | 294 | "State", | ||
1345 | 295 | "The state of the action", | ||
1346 | 296 | G_VARIANT_TYPE_TUPLE, | ||
1347 | 297 | NULL, | ||
1348 | 298 | G_PARAM_READWRITE | | ||
1349 | 299 | G_PARAM_STATIC_STRINGS); | ||
1350 | 300 | |||
1351 | 301 | g_object_class_install_properties (object_class, N_PROPERTIES, properties); | ||
1352 | 302 | |||
1353 | 303 | signal_ids[SIGNAL_ACTIVATE] = g_signal_new ("activate", | ||
1354 | 304 | G_TYPE_TUPLE_ACTION, | ||
1355 | 305 | G_SIGNAL_RUN_LAST | G_SIGNAL_MUST_COLLECT, | ||
1356 | 306 | 0, NULL, NULL, | ||
1357 | 307 | g_cclosure_marshal_VOID__VARIANT, | ||
1358 | 308 | G_TYPE_NONE, 1, | ||
1359 | 309 | G_TYPE_VARIANT); | ||
1360 | 310 | } | ||
1361 | 311 | |||
1362 | 312 | static void | ||
1363 | 313 | g_tuple_action_init (GTupleAction *action) | ||
1364 | 314 | { | ||
1365 | 315 | action->enabled = TRUE; | ||
1366 | 316 | } | ||
1367 | 317 | |||
1368 | 318 | GTupleAction * | ||
1369 | 319 | g_tuple_action_new (const gchar *name, | ||
1370 | 320 | GVariant *initial_state) | ||
1371 | 321 | { | ||
1372 | 322 | const GVariantType *type; | ||
1373 | 323 | |||
1374 | 324 | g_return_val_if_fail (name != NULL, NULL); | ||
1375 | 325 | g_return_val_if_fail (initial_state != NULL, NULL); | ||
1376 | 326 | |||
1377 | 327 | type = g_variant_get_type (initial_state); | ||
1378 | 328 | g_return_val_if_fail (g_variant_type_is_tuple (type), NULL); | ||
1379 | 329 | |||
1380 | 330 | return g_object_new (G_TYPE_TUPLE_ACTION, | ||
1381 | 331 | "name", name, | ||
1382 | 332 | "state", initial_state, | ||
1383 | 333 | NULL); | ||
1384 | 334 | } | ||
1385 | 335 | |||
1386 | 336 | void | ||
1387 | 337 | g_tuple_action_set_child (GTupleAction *action, | ||
1388 | 338 | gsize index, | ||
1389 | 339 | GVariant *value) | ||
1390 | 340 | { | ||
1391 | 341 | const GVariantType *type; | ||
1392 | 342 | |||
1393 | 343 | g_return_if_fail (G_IS_TUPLE_ACTION (action)); | ||
1394 | 344 | g_return_if_fail (index < action->n_children); | ||
1395 | 345 | g_return_if_fail (value != NULL); | ||
1396 | 346 | |||
1397 | 347 | type = g_variant_get_type (value); | ||
1398 | 348 | g_return_if_fail (g_variant_is_of_type (value, type)); | ||
1399 | 349 | |||
1400 | 350 | g_variant_unref (action->children[index]); | ||
1401 | 351 | action->children[index] = g_variant_ref_sink (value); | ||
1402 | 352 | |||
1403 | 353 | g_object_notify_by_pspec (G_OBJECT (action), properties[PROP_STATE]); | ||
1404 | 354 | } | ||
1405 | 355 | 0 | ||
1406 | === removed file 'libmessaging-menu/gtupleaction.h' | |||
1407 | --- libmessaging-menu/gtupleaction.h 2012-06-28 14:07:17 +0000 | |||
1408 | +++ libmessaging-menu/gtupleaction.h 1970-01-01 00:00:00 +0000 | |||
1409 | @@ -1,40 +0,0 @@ | |||
1410 | 1 | /* | ||
1411 | 2 | * Copyright 2012 Canonical Ltd. | ||
1412 | 3 | * | ||
1413 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
1414 | 5 | * under the terms of the GNU General Public License version 3, as | ||
1415 | 6 | * published by the Free Software Foundation. | ||
1416 | 7 | * | ||
1417 | 8 | * This program is distributed in the hope that it will be useful, but | ||
1418 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1419 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1420 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
1421 | 12 | * | ||
1422 | 13 | * You should have received a copy of the GNU General Public License along | ||
1423 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1424 | 15 | * | ||
1425 | 16 | * Authors: | ||
1426 | 17 | * Lars Uebernickel <lars.uebernickel@canonical.com> | ||
1427 | 18 | */ | ||
1428 | 19 | |||
1429 | 20 | #ifndef __g_tuple_action_h__ | ||
1430 | 21 | #define __g_tuple_action_h__ | ||
1431 | 22 | |||
1432 | 23 | #include <gio/gio.h> | ||
1433 | 24 | |||
1434 | 25 | #define G_TYPE_TUPLE_ACTION (g_tuple_action_get_type ()) | ||
1435 | 26 | #define G_TUPLE_ACTION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_TUPLE_ACTION, GTupleAction)) | ||
1436 | 27 | #define G_IS_TUPLE_ACTION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_TUPLE_ACTION)) | ||
1437 | 28 | |||
1438 | 29 | typedef struct _GTupleAction GTupleAction; | ||
1439 | 30 | |||
1440 | 31 | GType g_tuple_action_get_type (void) G_GNUC_CONST; | ||
1441 | 32 | |||
1442 | 33 | GTupleAction * g_tuple_action_new (const gchar *name, | ||
1443 | 34 | GVariant *initial_state); | ||
1444 | 35 | |||
1445 | 36 | void g_tuple_action_set_child (GTupleAction *action, | ||
1446 | 37 | gsize index, | ||
1447 | 38 | GVariant *value); | ||
1448 | 39 | |||
1449 | 40 | #endif | ||
1450 | 41 | 0 | ||
1451 | === renamed file 'libmessaging-menu/messaging-menu.c' => 'libmessaging-menu/messaging-menu-app.c' | |||
1452 | --- libmessaging-menu/messaging-menu.c 2013-02-12 19:41:16 +0000 | |||
1453 | +++ libmessaging-menu/messaging-menu-app.c 2013-04-26 16:57:25 +0000 | |||
1454 | @@ -17,10 +17,12 @@ | |||
1455 | 17 | * Lars Uebernickel <lars.uebernickel@canonical.com> | 17 | * Lars Uebernickel <lars.uebernickel@canonical.com> |
1456 | 18 | */ | 18 | */ |
1457 | 19 | 19 | ||
1459 | 20 | #include "messaging-menu.h" | 20 | #include "messaging-menu-app.h" |
1460 | 21 | #include "indicator-messages-service.h" | 21 | #include "indicator-messages-service.h" |
1461 | 22 | #include "indicator-messages-application.h" | ||
1462 | 22 | 23 | ||
1463 | 23 | #include <gio/gdesktopappinfo.h> | 24 | #include <gio/gdesktopappinfo.h> |
1464 | 25 | #include <string.h> | ||
1465 | 24 | 26 | ||
1466 | 25 | /** | 27 | /** |
1467 | 26 | * SECTION:messaging-menu | 28 | * SECTION:messaging-menu |
1468 | @@ -102,14 +104,14 @@ | |||
1469 | 102 | int registered; /* -1 for unknown */ | 104 | int registered; /* -1 for unknown */ |
1470 | 103 | MessagingMenuStatus status; | 105 | MessagingMenuStatus status; |
1471 | 104 | gboolean status_set; | 106 | gboolean status_set; |
1472 | 105 | GSimpleActionGroup *source_actions; | ||
1473 | 106 | GMenu *menu; | ||
1474 | 107 | GDBusConnection *bus; | 107 | GDBusConnection *bus; |
1475 | 108 | 108 | ||
1476 | 109 | GHashTable *messages; | ||
1477 | 110 | GList *sources; | ||
1478 | 111 | IndicatorMessagesApplication *app_interface; | ||
1479 | 112 | |||
1480 | 109 | IndicatorMessagesService *messages_service; | 113 | IndicatorMessagesService *messages_service; |
1481 | 110 | guint watch_id; | 114 | guint watch_id; |
1482 | 111 | guint action_export_id; | ||
1483 | 112 | guint menu_export_id; | ||
1484 | 113 | 115 | ||
1485 | 114 | GCancellable *cancellable; | 116 | GCancellable *cancellable; |
1486 | 115 | }; | 117 | }; |
1487 | @@ -133,10 +135,61 @@ | |||
1488 | 133 | 135 | ||
1489 | 134 | static const gchar *status_ids[] = { "available", "away", "busy", "invisible", "offline" }; | 136 | static const gchar *status_ids[] = { "available", "away", "busy", "invisible", "offline" }; |
1490 | 135 | 137 | ||
1491 | 138 | typedef struct | ||
1492 | 139 | { | ||
1493 | 140 | gchar *id; | ||
1494 | 141 | GIcon *icon; | ||
1495 | 142 | gchar *label; | ||
1496 | 143 | |||
1497 | 144 | guint32 count; | ||
1498 | 145 | gint64 time; | ||
1499 | 146 | gchar *string; | ||
1500 | 147 | gboolean draws_attention; | ||
1501 | 148 | } Source; | ||
1502 | 149 | |||
1503 | 136 | static void global_status_changed (IndicatorMessagesService *service, | 150 | static void global_status_changed (IndicatorMessagesService *service, |
1504 | 137 | const gchar *status_str, | 151 | const gchar *status_str, |
1505 | 138 | gpointer user_data); | 152 | gpointer user_data); |
1506 | 139 | 153 | ||
1507 | 154 | /* in messaging-menu-message.c */ | ||
1508 | 155 | GVariant * _messaging_menu_message_to_variant (MessagingMenuMessage *msg); | ||
1509 | 156 | |||
1510 | 157 | static void | ||
1511 | 158 | source_free (gpointer data) | ||
1512 | 159 | { | ||
1513 | 160 | Source *source = data; | ||
1514 | 161 | |||
1515 | 162 | if (source) | ||
1516 | 163 | { | ||
1517 | 164 | g_free (source->id); | ||
1518 | 165 | g_clear_object (&source->icon); | ||
1519 | 166 | g_free (source->label); | ||
1520 | 167 | g_free (source->string); | ||
1521 | 168 | g_slice_free (Source, source); | ||
1522 | 169 | } | ||
1523 | 170 | } | ||
1524 | 171 | |||
1525 | 172 | static GVariant * | ||
1526 | 173 | source_to_variant (Source *source) | ||
1527 | 174 | { | ||
1528 | 175 | GVariant *v; | ||
1529 | 176 | gchar *iconstr; | ||
1530 | 177 | |||
1531 | 178 | iconstr = source->icon ? g_icon_to_string (source->icon) : NULL; | ||
1532 | 179 | |||
1533 | 180 | v = g_variant_new ("(sssuxsb)", source->id, | ||
1534 | 181 | source->label, | ||
1535 | 182 | iconstr ? iconstr : "", | ||
1536 | 183 | source->count, | ||
1537 | 184 | source->time, | ||
1538 | 185 | source->string ? source->string : "", | ||
1539 | 186 | source->draws_attention); | ||
1540 | 187 | |||
1541 | 188 | g_free (iconstr); | ||
1542 | 189 | |||
1543 | 190 | return v; | ||
1544 | 191 | } | ||
1545 | 192 | |||
1546 | 140 | static gchar * | 193 | static gchar * |
1547 | 141 | messaging_menu_app_get_dbus_object_path (MessagingMenuApp *app) | 194 | messaging_menu_app_get_dbus_object_path (MessagingMenuApp *app) |
1548 | 142 | { | 195 | { |
1549 | @@ -155,18 +208,14 @@ | |||
1550 | 155 | } | 208 | } |
1551 | 156 | 209 | ||
1552 | 157 | static void | 210 | static void |
1556 | 158 | export_menus_and_actions (GObject *source, | 211 | messaging_menu_app_got_bus (GObject *source, |
1557 | 159 | GAsyncResult *res, | 212 | GAsyncResult *res, |
1558 | 160 | gpointer user_data) | 213 | gpointer user_data) |
1559 | 161 | { | 214 | { |
1560 | 162 | MessagingMenuApp *app = user_data; | 215 | MessagingMenuApp *app = user_data; |
1561 | 163 | GError *error = NULL; | 216 | GError *error = NULL; |
1562 | 164 | gchar *object_path; | 217 | gchar *object_path; |
1563 | 165 | 218 | ||
1564 | 166 | object_path = messaging_menu_app_get_dbus_object_path (app); | ||
1565 | 167 | if (!object_path) | ||
1566 | 168 | return; | ||
1567 | 169 | |||
1568 | 170 | app->bus = g_bus_get_finish (res, &error); | 219 | app->bus = g_bus_get_finish (res, &error); |
1569 | 171 | if (app->bus == NULL) | 220 | if (app->bus == NULL) |
1570 | 172 | { | 221 | { |
1571 | @@ -175,23 +224,13 @@ | |||
1572 | 175 | return; | 224 | return; |
1573 | 176 | } | 225 | } |
1574 | 177 | 226 | ||
1584 | 178 | app->action_export_id = g_dbus_connection_export_action_group (app->bus, | 227 | object_path = messaging_menu_app_get_dbus_object_path (app); |
1576 | 179 | object_path, | ||
1577 | 180 | G_ACTION_GROUP (app->source_actions), | ||
1578 | 181 | &error); | ||
1579 | 182 | if (!app->action_export_id) | ||
1580 | 183 | { | ||
1581 | 184 | g_warning ("unable to export action group: %s", error->message); | ||
1582 | 185 | g_clear_error (&error); | ||
1583 | 186 | } | ||
1585 | 187 | 228 | ||
1591 | 188 | app->menu_export_id = g_dbus_connection_export_menu_model (app->bus, | 229 | if (object_path && |
1592 | 189 | object_path, | 230 | !g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (app->app_interface), |
1593 | 190 | G_MENU_MODEL (app->menu), | 231 | app->bus, object_path, &error)) |
1589 | 191 | &error); | ||
1590 | 192 | if (!app->menu_export_id) | ||
1594 | 193 | { | 232 | { |
1596 | 194 | g_warning ("unable to export menu: %s", error->message); | 233 | g_warning ("unable to export application interface: %s", error->message); |
1597 | 195 | g_clear_error (&error); | 234 | g_clear_error (&error); |
1598 | 196 | } | 235 | } |
1599 | 197 | 236 | ||
1600 | @@ -214,7 +253,7 @@ | |||
1601 | 214 | 253 | ||
1602 | 215 | g_bus_get (G_BUS_TYPE_SESSION, | 254 | g_bus_get (G_BUS_TYPE_SESSION, |
1603 | 216 | app->cancellable, | 255 | app->cancellable, |
1605 | 217 | export_menus_and_actions, | 256 | messaging_menu_app_got_bus, |
1606 | 218 | app); | 257 | app); |
1607 | 219 | } | 258 | } |
1608 | 220 | 259 | ||
1609 | @@ -248,20 +287,6 @@ | |||
1610 | 248 | { | 287 | { |
1611 | 249 | MessagingMenuApp *app = MESSAGING_MENU_APP (object); | 288 | MessagingMenuApp *app = MESSAGING_MENU_APP (object); |
1612 | 250 | 289 | ||
1613 | 251 | if (app->bus) | ||
1614 | 252 | { | ||
1615 | 253 | if (app->action_export_id > 0) | ||
1616 | 254 | g_dbus_connection_unexport_action_group (app->bus, app->action_export_id); | ||
1617 | 255 | |||
1618 | 256 | if (app->menu_export_id > 0) | ||
1619 | 257 | g_dbus_connection_unexport_menu_model (app->bus, app->menu_export_id); | ||
1620 | 258 | |||
1621 | 259 | app->action_export_id = 0; | ||
1622 | 260 | app->menu_export_id = 0; | ||
1623 | 261 | g_object_unref (app->bus); | ||
1624 | 262 | app->bus = NULL; | ||
1625 | 263 | } | ||
1626 | 264 | |||
1627 | 265 | if (app->watch_id > 0) | 290 | if (app->watch_id > 0) |
1628 | 266 | { | 291 | { |
1629 | 267 | g_bus_unwatch_name (app->watch_id); | 292 | g_bus_unwatch_name (app->watch_id); |
1630 | @@ -283,9 +308,14 @@ | |||
1631 | 283 | g_clear_object (&app->messages_service); | 308 | g_clear_object (&app->messages_service); |
1632 | 284 | } | 309 | } |
1633 | 285 | 310 | ||
1634 | 311 | g_clear_pointer (&app->messages, g_hash_table_unref); | ||
1635 | 312 | |||
1636 | 313 | g_list_free_full (app->sources, source_free); | ||
1637 | 314 | app->sources = NULL; | ||
1638 | 315 | |||
1639 | 316 | g_clear_object (&app->app_interface); | ||
1640 | 286 | g_clear_object (&app->appinfo); | 317 | g_clear_object (&app->appinfo); |
1643 | 287 | g_clear_object (&app->source_actions); | 318 | g_clear_object (&app->bus); |
1642 | 288 | g_clear_object (&app->menu); | ||
1644 | 289 | 319 | ||
1645 | 290 | G_OBJECT_CLASS (messaging_menu_app_parent_class)->dispose (object); | 320 | G_OBJECT_CLASS (messaging_menu_app_parent_class)->dispose (object); |
1646 | 291 | } | 321 | } |
1647 | @@ -416,6 +446,168 @@ | |||
1648 | 416 | } | 446 | } |
1649 | 417 | } | 447 | } |
1650 | 418 | 448 | ||
1651 | 449 | static gboolean | ||
1652 | 450 | messaging_menu_app_list_sources (IndicatorMessagesApplication *app_interface, | ||
1653 | 451 | GDBusMethodInvocation *invocation, | ||
1654 | 452 | gpointer user_data) | ||
1655 | 453 | { | ||
1656 | 454 | MessagingMenuApp *app = user_data; | ||
1657 | 455 | GVariantBuilder builder; | ||
1658 | 456 | GList *it; | ||
1659 | 457 | |||
1660 | 458 | g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(sssuxsb)")); | ||
1661 | 459 | |||
1662 | 460 | for (it = app->sources; it; it = it->next) | ||
1663 | 461 | g_variant_builder_add_value (&builder, source_to_variant (it->data)); | ||
1664 | 462 | |||
1665 | 463 | indicator_messages_application_complete_list_sources (app_interface, | ||
1666 | 464 | invocation, | ||
1667 | 465 | g_variant_builder_end (&builder)); | ||
1668 | 466 | |||
1669 | 467 | return TRUE; | ||
1670 | 468 | } | ||
1671 | 469 | |||
1672 | 470 | static gint | ||
1673 | 471 | compare_source_id (gconstpointer a, | ||
1674 | 472 | gconstpointer b) | ||
1675 | 473 | { | ||
1676 | 474 | const Source *source = a; | ||
1677 | 475 | const gchar *id = b; | ||
1678 | 476 | |||
1679 | 477 | return strcmp (source->id, id); | ||
1680 | 478 | } | ||
1681 | 479 | |||
1682 | 480 | static gboolean | ||
1683 | 481 | messaging_menu_app_remove_source_internal (MessagingMenuApp *app, | ||
1684 | 482 | const gchar *source_id) | ||
1685 | 483 | { | ||
1686 | 484 | GList *node; | ||
1687 | 485 | |||
1688 | 486 | node = g_list_find_custom (app->sources, source_id, compare_source_id); | ||
1689 | 487 | if (node) | ||
1690 | 488 | { | ||
1691 | 489 | source_free (node->data); | ||
1692 | 490 | app->sources = g_list_delete_link (app->sources, node); | ||
1693 | 491 | return TRUE; | ||
1694 | 492 | } | ||
1695 | 493 | |||
1696 | 494 | return FALSE; | ||
1697 | 495 | } | ||
1698 | 496 | |||
1699 | 497 | static gboolean | ||
1700 | 498 | messaging_menu_app_remove_message_internal (MessagingMenuApp *app, | ||
1701 | 499 | const gchar *message_id) | ||
1702 | 500 | { | ||
1703 | 501 | return g_hash_table_remove (app->messages, message_id); | ||
1704 | 502 | } | ||
1705 | 503 | |||
1706 | 504 | static gboolean | ||
1707 | 505 | messaging_menu_app_activate_source (IndicatorMessagesApplication *app_interface, | ||
1708 | 506 | GDBusMethodInvocation *invocation, | ||
1709 | 507 | const gchar *source_id, | ||
1710 | 508 | gpointer user_data) | ||
1711 | 509 | { | ||
1712 | 510 | MessagingMenuApp *app = user_data; | ||
1713 | 511 | GQuark q = g_quark_from_string (source_id); | ||
1714 | 512 | |||
1715 | 513 | /* Activate implies removing the source, no need for SourceRemoved */ | ||
1716 | 514 | if (messaging_menu_app_remove_source_internal (app, source_id)) | ||
1717 | 515 | g_signal_emit (app, signals[ACTIVATE_SOURCE], q, source_id); | ||
1718 | 516 | |||
1719 | 517 | indicator_messages_application_complete_activate_source (app_interface, invocation); | ||
1720 | 518 | |||
1721 | 519 | return TRUE; | ||
1722 | 520 | } | ||
1723 | 521 | |||
1724 | 522 | static gboolean | ||
1725 | 523 | messaging_menu_app_list_messages (IndicatorMessagesApplication *app_interface, | ||
1726 | 524 | GDBusMethodInvocation *invocation, | ||
1727 | 525 | gpointer user_data) | ||
1728 | 526 | { | ||
1729 | 527 | MessagingMenuApp *app = user_data; | ||
1730 | 528 | GVariantBuilder builder; | ||
1731 | 529 | GHashTableIter iter; | ||
1732 | 530 | MessagingMenuMessage *message; | ||
1733 | 531 | |||
1734 | 532 | g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(sssssxaa{sv}b)")); | ||
1735 | 533 | |||
1736 | 534 | g_hash_table_iter_init (&iter, app->messages); | ||
1737 | 535 | while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &message)) | ||
1738 | 536 | g_variant_builder_add_value (&builder, _messaging_menu_message_to_variant (message)); | ||
1739 | 537 | |||
1740 | 538 | indicator_messages_application_complete_list_messages (app_interface, | ||
1741 | 539 | invocation, | ||
1742 | 540 | g_variant_builder_end (&builder)); | ||
1743 | 541 | |||
1744 | 542 | return TRUE; | ||
1745 | 543 | } | ||
1746 | 544 | |||
1747 | 545 | static gboolean | ||
1748 | 546 | messaging_menu_app_activate_message (IndicatorMessagesApplication *app_interface, | ||
1749 | 547 | GDBusMethodInvocation *invocation, | ||
1750 | 548 | const gchar *message_id, | ||
1751 | 549 | const gchar *action_id, | ||
1752 | 550 | GVariant *params, | ||
1753 | 551 | gpointer user_data) | ||
1754 | 552 | { | ||
1755 | 553 | MessagingMenuApp *app = user_data; | ||
1756 | 554 | MessagingMenuMessage *msg; | ||
1757 | 555 | |||
1758 | 556 | msg = g_hash_table_lookup (app->messages, message_id); | ||
1759 | 557 | if (msg) | ||
1760 | 558 | { | ||
1761 | 559 | if (*action_id) | ||
1762 | 560 | { | ||
1763 | 561 | gchar *signal; | ||
1764 | 562 | |||
1765 | 563 | signal = g_strconcat ("activate::", action_id, NULL); | ||
1766 | 564 | |||
1767 | 565 | if (g_variant_n_children (params)) | ||
1768 | 566 | { | ||
1769 | 567 | GVariant *param; | ||
1770 | 568 | |||
1771 | 569 | g_variant_get_child (params, 0, "v", ¶m); | ||
1772 | 570 | g_signal_emit_by_name (msg, signal, action_id, param); | ||
1773 | 571 | |||
1774 | 572 | g_variant_unref (param); | ||
1775 | 573 | } | ||
1776 | 574 | else | ||
1777 | 575 | g_signal_emit_by_name (msg, signal, action_id, NULL); | ||
1778 | 576 | |||
1779 | 577 | g_free (signal); | ||
1780 | 578 | } | ||
1781 | 579 | else | ||
1782 | 580 | g_signal_emit_by_name (msg, "activate", NULL, NULL); | ||
1783 | 581 | |||
1784 | 582 | |||
1785 | 583 | /* Activate implies removing the message, no need for MessageRemoved */ | ||
1786 | 584 | messaging_menu_app_remove_message_internal (app, message_id); | ||
1787 | 585 | } | ||
1788 | 586 | |||
1789 | 587 | indicator_messages_application_complete_activate_message (app_interface, invocation); | ||
1790 | 588 | |||
1791 | 589 | return TRUE; | ||
1792 | 590 | } | ||
1793 | 591 | |||
1794 | 592 | static gboolean | ||
1795 | 593 | messaging_menu_app_dismiss (IndicatorMessagesApplication *app_interface, | ||
1796 | 594 | GDBusMethodInvocation *invocation, | ||
1797 | 595 | const gchar * const *sources, | ||
1798 | 596 | const gchar * const *messages, | ||
1799 | 597 | gpointer user_data) | ||
1800 | 598 | { | ||
1801 | 599 | MessagingMenuApp *app = user_data; | ||
1802 | 600 | const gchar * const *it; | ||
1803 | 601 | |||
1804 | 602 | for (it = sources; *it; it++) | ||
1805 | 603 | messaging_menu_app_remove_source_internal (app, *it); | ||
1806 | 604 | |||
1807 | 605 | for (it = messages; *it; it++) | ||
1808 | 606 | messaging_menu_app_remove_message_internal (app, *it); | ||
1809 | 607 | |||
1810 | 608 | return TRUE; | ||
1811 | 609 | } | ||
1812 | 610 | |||
1813 | 419 | static void | 611 | static void |
1814 | 420 | messaging_menu_app_init (MessagingMenuApp *app) | 612 | messaging_menu_app_init (MessagingMenuApp *app) |
1815 | 421 | { | 613 | { |
1816 | @@ -423,15 +615,21 @@ | |||
1817 | 423 | app->status_set = FALSE; | 615 | app->status_set = FALSE; |
1818 | 424 | app->bus = NULL; | 616 | app->bus = NULL; |
1819 | 425 | 617 | ||
1829 | 426 | app->action_export_id = 0; | 618 | app->cancellable = g_cancellable_new (); |
1830 | 427 | app->menu_export_id = 0; | 619 | |
1831 | 428 | 620 | app->app_interface = indicator_messages_application_skeleton_new (); | |
1832 | 429 | app->cancellable = g_cancellable_new (); | 621 | g_signal_connect (app->app_interface, "handle-list-sources", |
1833 | 430 | 622 | G_CALLBACK (messaging_menu_app_list_sources), app); | |
1834 | 431 | app->source_actions = g_simple_action_group_new (); | 623 | g_signal_connect (app->app_interface, "handle-activate-source", |
1835 | 432 | app->menu = g_menu_new (); | 624 | G_CALLBACK (messaging_menu_app_activate_source), app); |
1836 | 433 | 625 | g_signal_connect (app->app_interface, "handle-list-messages", | |
1837 | 434 | app->cancellable = g_cancellable_new (); | 626 | G_CALLBACK (messaging_menu_app_list_messages), app); |
1838 | 627 | g_signal_connect (app->app_interface, "handle-activate-message", | ||
1839 | 628 | G_CALLBACK (messaging_menu_app_activate_message), app); | ||
1840 | 629 | g_signal_connect (app->app_interface, "handle-dismiss", | ||
1841 | 630 | G_CALLBACK (messaging_menu_app_dismiss), app); | ||
1842 | 631 | |||
1843 | 632 | app->messages = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); | ||
1844 | 435 | 633 | ||
1845 | 436 | app->watch_id = g_bus_watch_name (G_BUS_TYPE_SESSION, | 634 | app->watch_id = g_bus_watch_name (G_BUS_TYPE_SESSION, |
1846 | 437 | "com.canonical.indicator.messages", | 635 | "com.canonical.indicator.messages", |
1847 | @@ -604,49 +802,65 @@ | |||
1848 | 604 | g_signal_emit (app, signals[STATUS_CHANGED], 0, status); | 802 | g_signal_emit (app, signals[STATUS_CHANGED], 0, status); |
1849 | 605 | } | 803 | } |
1850 | 606 | 804 | ||
1875 | 607 | static void | 805 | static Source * |
1876 | 608 | source_action_activated (GSimpleAction *action, | 806 | messaging_menu_app_lookup_source (MessagingMenuApp *app, |
1877 | 609 | GVariant *parameter, | 807 | const gchar *id) |
1878 | 610 | gpointer user_data) | 808 | { |
1879 | 611 | { | 809 | GList *node; |
1880 | 612 | MessagingMenuApp *app = user_data; | 810 | |
1881 | 613 | const gchar *name = g_action_get_name (G_ACTION (action)); | 811 | node = g_list_find_custom (app->sources, id, compare_source_id); |
1882 | 614 | GQuark q = g_quark_from_string (name); | 812 | |
1883 | 615 | 813 | return node ? node->data : NULL; | |
1884 | 616 | messaging_menu_app_remove_source (app, name); | 814 | } |
1885 | 617 | 815 | ||
1886 | 618 | g_signal_emit (app, signals[ACTIVATE_SOURCE], q, name); | 816 | static Source * |
1887 | 619 | } | 817 | messaging_menu_app_get_source (MessagingMenuApp *app, |
1888 | 620 | 818 | const gchar *id) | |
1889 | 621 | static void | 819 | { |
1890 | 622 | messaging_menu_app_insert_source_action (MessagingMenuApp *app, | 820 | Source *source; |
1891 | 623 | gint position, | 821 | |
1892 | 624 | const gchar *id, | 822 | source = messaging_menu_app_lookup_source (app, id); |
1893 | 625 | GIcon *icon, | 823 | if (!source) |
1894 | 626 | const gchar *label, | 824 | g_warning ("a source with id '%s' doesn't exist", id); |
1895 | 627 | GVariant *state) | 825 | |
1896 | 628 | { | 826 | return source; |
1897 | 629 | GSimpleAction *action; | 827 | } |
1898 | 630 | GMenuItem *menuitem; | 828 | |
1899 | 829 | static void | ||
1900 | 830 | messaging_menu_app_notify_source_changed (MessagingMenuApp *app, | ||
1901 | 831 | Source *source) | ||
1902 | 832 | { | ||
1903 | 833 | indicator_messages_application_emit_source_changed (app->app_interface, | ||
1904 | 834 | source_to_variant (source)); | ||
1905 | 835 | } | ||
1906 | 836 | |||
1907 | 837 | static void | ||
1908 | 838 | messaging_menu_app_insert_source_internal (MessagingMenuApp *app, | ||
1909 | 839 | gint position, | ||
1910 | 840 | const gchar *id, | ||
1911 | 841 | GIcon *icon, | ||
1912 | 842 | const gchar *label, | ||
1913 | 843 | guint count, | ||
1914 | 844 | gint64 time, | ||
1915 | 845 | const gchar *string) | ||
1916 | 846 | { | ||
1917 | 847 | Source *source; | ||
1918 | 631 | 848 | ||
1919 | 632 | g_return_if_fail (MESSAGING_MENU_IS_APP (app)); | 849 | g_return_if_fail (MESSAGING_MENU_IS_APP (app)); |
1920 | 633 | g_return_if_fail (id != NULL); | 850 | g_return_if_fail (id != NULL); |
1921 | 851 | g_return_if_fail (label != NULL); | ||
1922 | 634 | 852 | ||
1924 | 635 | if (g_simple_action_group_lookup (app->source_actions, id)) | 853 | if (messaging_menu_app_lookup_source (app, id)) |
1925 | 636 | { | 854 | { |
1926 | 637 | g_warning ("a source with id '%s' already exists", id); | 855 | g_warning ("a source with id '%s' already exists", id); |
1927 | 638 | return; | 856 | return; |
1928 | 639 | } | 857 | } |
1929 | 640 | 858 | ||
1938 | 641 | action = g_simple_action_new_stateful (id, NULL, state); | 859 | source = g_slice_new0 (Source); |
1939 | 642 | g_signal_connect (action, "activate", | 860 | source->id = g_strdup (id); |
1940 | 643 | G_CALLBACK (source_action_activated), app); | 861 | source->label = g_strdup (label); |
1933 | 644 | g_simple_action_group_insert (app->source_actions, G_ACTION (action)); | ||
1934 | 645 | g_object_unref (action); | ||
1935 | 646 | |||
1936 | 647 | menuitem = g_menu_item_new (label, id); | ||
1937 | 648 | g_menu_item_set_attribute (menuitem, "x-canonical-type", "s", "ImSourceMenuItem"); | ||
1941 | 649 | if (icon) | 862 | if (icon) |
1942 | 863 | <<<<<<< TREE | ||
1943 | 650 | { | 864 | { |
1944 | 651 | gchar *iconstr = g_icon_to_string (icon); | 865 | gchar *iconstr = g_icon_to_string (icon); |
1945 | 652 | g_menu_item_set_attribute (menuitem, "x-canonical-icon", "s", iconstr); | 866 | g_menu_item_set_attribute (menuitem, "x-canonical-icon", "s", iconstr); |
1946 | @@ -721,6 +935,17 @@ | |||
1947 | 721 | g_simple_action_set_state (action, new_state); | 935 | g_simple_action_set_state (action, new_state); |
1948 | 722 | 936 | ||
1949 | 723 | g_variant_unref (state); | 937 | g_variant_unref (state); |
1950 | 938 | ======= | ||
1951 | 939 | source->icon = g_object_ref (icon); | ||
1952 | 940 | source->count = count; | ||
1953 | 941 | source->time = time; | ||
1954 | 942 | source->string = g_strdup (string); | ||
1955 | 943 | app->sources = g_list_insert (app->sources, source, position); | ||
1956 | 944 | |||
1957 | 945 | indicator_messages_application_emit_source_added (app->app_interface, | ||
1958 | 946 | position, | ||
1959 | 947 | source_to_variant (source)); | ||
1960 | 948 | >>>>>>> MERGE-SOURCE | ||
1961 | 724 | } | 949 | } |
1962 | 725 | 950 | ||
1963 | 726 | /** | 951 | /** |
1964 | @@ -797,8 +1022,7 @@ | |||
1965 | 797 | const gchar *label, | 1022 | const gchar *label, |
1966 | 798 | guint count) | 1023 | guint count) |
1967 | 799 | { | 1024 | { |
1970 | 800 | messaging_menu_app_insert_source_action (app, position, id, icon, label, | 1025 | messaging_menu_app_insert_source_internal (app, position, id, icon, label, count, 0, ""); |
1969 | 801 | g_variant_new ("(uxsb)", count, 0, "", FALSE)); | ||
1971 | 802 | } | 1026 | } |
1972 | 803 | 1027 | ||
1973 | 804 | /** | 1028 | /** |
1974 | @@ -852,8 +1076,7 @@ | |||
1975 | 852 | const gchar *label, | 1076 | const gchar *label, |
1976 | 853 | gint64 time) | 1077 | gint64 time) |
1977 | 854 | { | 1078 | { |
1980 | 855 | messaging_menu_app_insert_source_action (app, position, id, icon, label, | 1079 | messaging_menu_app_insert_source_internal (app, position, id, icon, label, 0, time, ""); |
1979 | 856 | g_variant_new ("(uxsb)", 0, time, "", FALSE)); | ||
1981 | 857 | } | 1080 | } |
1982 | 858 | 1081 | ||
1983 | 859 | /** | 1082 | /** |
1984 | @@ -909,8 +1132,7 @@ | |||
1985 | 909 | const gchar *label, | 1132 | const gchar *label, |
1986 | 910 | const gchar *str) | 1133 | const gchar *str) |
1987 | 911 | { | 1134 | { |
1990 | 912 | messaging_menu_app_insert_source_action (app, position, id, icon, label, | 1135 | messaging_menu_app_insert_source_internal (app, position, id, icon, label, 0, 0, str); |
1989 | 913 | g_variant_new ("(uxsb)", 0, 0, str, FALSE)); | ||
1991 | 914 | } | 1136 | } |
1992 | 915 | 1137 | ||
1993 | 916 | /** | 1138 | /** |
1994 | @@ -950,34 +1172,11 @@ | |||
1995 | 950 | messaging_menu_app_remove_source (MessagingMenuApp *app, | 1172 | messaging_menu_app_remove_source (MessagingMenuApp *app, |
1996 | 951 | const gchar *source_id) | 1173 | const gchar *source_id) |
1997 | 952 | { | 1174 | { |
1998 | 953 | int n_items; | ||
1999 | 954 | int i; | ||
2000 | 955 | |||
2001 | 956 | g_return_if_fail (MESSAGING_MENU_IS_APP (app)); | 1175 | g_return_if_fail (MESSAGING_MENU_IS_APP (app)); |
2002 | 957 | g_return_if_fail (source_id != NULL); | 1176 | g_return_if_fail (source_id != NULL); |
2003 | 958 | 1177 | ||
2026 | 959 | if (g_simple_action_group_lookup (app->source_actions, source_id) == NULL) | 1178 | if (messaging_menu_app_remove_source_internal (app, source_id)) |
2027 | 960 | return; | 1179 | indicator_messages_application_emit_source_removed (app->app_interface, source_id); |
2006 | 961 | |||
2007 | 962 | n_items = g_menu_model_get_n_items (G_MENU_MODEL (app->menu)); | ||
2008 | 963 | for (i = 0; i < n_items; i++) | ||
2009 | 964 | { | ||
2010 | 965 | gchar *action; | ||
2011 | 966 | |||
2012 | 967 | if (g_menu_model_get_item_attribute (G_MENU_MODEL (app->menu), i, | ||
2013 | 968 | "action", "s", &action)) | ||
2014 | 969 | { | ||
2015 | 970 | if (!g_strcmp0 (action, source_id)) | ||
2016 | 971 | { | ||
2017 | 972 | g_menu_remove (app->menu, i); | ||
2018 | 973 | break; | ||
2019 | 974 | } | ||
2020 | 975 | |||
2021 | 976 | g_free (action); | ||
2022 | 977 | } | ||
2023 | 978 | } | ||
2024 | 979 | |||
2025 | 980 | g_simple_action_group_remove (app->source_actions, source_id); | ||
2028 | 981 | } | 1180 | } |
2029 | 982 | 1181 | ||
2030 | 983 | /** | 1182 | /** |
2031 | @@ -994,46 +1193,7 @@ | |||
2032 | 994 | g_return_val_if_fail (MESSAGING_MENU_IS_APP (app), FALSE); | 1193 | g_return_val_if_fail (MESSAGING_MENU_IS_APP (app), FALSE); |
2033 | 995 | g_return_val_if_fail (source_id != NULL, FALSE); | 1194 | g_return_val_if_fail (source_id != NULL, FALSE); |
2034 | 996 | 1195 | ||
2075 | 997 | return g_simple_action_group_lookup (app->source_actions, source_id) != NULL; | 1196 | return messaging_menu_app_lookup_source (app, source_id) != NULL; |
2036 | 998 | } | ||
2037 | 999 | |||
2038 | 1000 | static GMenuItem * | ||
2039 | 1001 | g_menu_find_item_with_action (GMenu *menu, | ||
2040 | 1002 | const gchar *action, | ||
2041 | 1003 | gint *out_pos) | ||
2042 | 1004 | { | ||
2043 | 1005 | gint i; | ||
2044 | 1006 | gint n_elements; | ||
2045 | 1007 | GMenuItem *item = NULL; | ||
2046 | 1008 | |||
2047 | 1009 | n_elements = g_menu_model_get_n_items (G_MENU_MODEL (menu)); | ||
2048 | 1010 | |||
2049 | 1011 | for (i = 0; i < n_elements && item == NULL; i++) | ||
2050 | 1012 | { | ||
2051 | 1013 | GVariant *attr; | ||
2052 | 1014 | |||
2053 | 1015 | item = g_menu_item_new_from_model (G_MENU_MODEL (menu), i); | ||
2054 | 1016 | attr = g_menu_item_get_attribute_value (item, G_MENU_ATTRIBUTE_ACTION, G_VARIANT_TYPE_STRING); | ||
2055 | 1017 | |||
2056 | 1018 | if (!g_str_equal (action, g_variant_get_string (attr, NULL))) | ||
2057 | 1019 | g_clear_object (&item); | ||
2058 | 1020 | |||
2059 | 1021 | g_variant_unref (attr); | ||
2060 | 1022 | } | ||
2061 | 1023 | |||
2062 | 1024 | if (item && out_pos) | ||
2063 | 1025 | *out_pos = i - 1; | ||
2064 | 1026 | |||
2065 | 1027 | return item; | ||
2066 | 1028 | } | ||
2067 | 1029 | |||
2068 | 1030 | static void | ||
2069 | 1031 | g_menu_replace_item (GMenu *menu, | ||
2070 | 1032 | gint pos, | ||
2071 | 1033 | GMenuItem *item) | ||
2072 | 1034 | { | ||
2073 | 1035 | g_menu_remove (menu, pos); | ||
2074 | 1036 | g_menu_insert_item (menu, pos, item); | ||
2076 | 1037 | } | 1197 | } |
2077 | 1038 | 1198 | ||
2078 | 1039 | /** | 1199 | /** |
2079 | @@ -1049,21 +1209,19 @@ | |||
2080 | 1049 | const gchar *source_id, | 1209 | const gchar *source_id, |
2081 | 1050 | const gchar *label) | 1210 | const gchar *label) |
2082 | 1051 | { | 1211 | { |
2085 | 1052 | gint pos; | 1212 | Source *source; |
2084 | 1053 | GMenuItem *item; | ||
2086 | 1054 | 1213 | ||
2087 | 1055 | g_return_if_fail (MESSAGING_MENU_IS_APP (app)); | 1214 | g_return_if_fail (MESSAGING_MENU_IS_APP (app)); |
2088 | 1056 | g_return_if_fail (source_id != NULL); | 1215 | g_return_if_fail (source_id != NULL); |
2089 | 1057 | g_return_if_fail (label != NULL); | 1216 | g_return_if_fail (label != NULL); |
2090 | 1058 | 1217 | ||
2099 | 1059 | item = g_menu_find_item_with_action (app->menu, source_id, &pos); | 1218 | source = messaging_menu_app_get_source (app, source_id); |
2100 | 1060 | if (item == NULL) | 1219 | if (source) |
2101 | 1061 | return; | 1220 | { |
2102 | 1062 | 1221 | g_free (source->label); | |
2103 | 1063 | g_menu_item_set_attribute (item, G_MENU_ATTRIBUTE_LABEL, "s", label); | 1222 | source->label = g_strdup (label); |
2104 | 1064 | g_menu_replace_item (app->menu, pos, item); | 1223 | messaging_menu_app_notify_source_changed (app, source); |
2105 | 1065 | 1224 | } | |
2098 | 1066 | g_object_unref (item); | ||
2106 | 1067 | } | 1225 | } |
2107 | 1068 | 1226 | ||
2108 | 1069 | /** | 1227 | /** |
2109 | @@ -1079,33 +1237,19 @@ | |||
2110 | 1079 | const gchar *source_id, | 1237 | const gchar *source_id, |
2111 | 1080 | GIcon *icon) | 1238 | GIcon *icon) |
2112 | 1081 | { | 1239 | { |
2115 | 1082 | gint pos; | 1240 | Source *source; |
2114 | 1083 | GMenuItem *item; | ||
2116 | 1084 | 1241 | ||
2117 | 1085 | g_return_if_fail (MESSAGING_MENU_IS_APP (app)); | 1242 | g_return_if_fail (MESSAGING_MENU_IS_APP (app)); |
2118 | 1086 | g_return_if_fail (source_id != NULL); | 1243 | g_return_if_fail (source_id != NULL); |
2119 | 1087 | 1244 | ||
2141 | 1088 | item = g_menu_find_item_with_action (app->menu, source_id, &pos); | 1245 | source = messaging_menu_app_get_source (app, source_id); |
2142 | 1089 | if (item == NULL) | 1246 | if (source) |
2143 | 1090 | return; | 1247 | { |
2144 | 1091 | 1248 | g_clear_object (&source->icon); | |
2145 | 1092 | if (icon) | 1249 | if (icon) |
2146 | 1093 | { | 1250 | source->icon = g_object_ref (icon); |
2147 | 1094 | gchar *iconstr; | 1251 | messaging_menu_app_notify_source_changed (app, source); |
2148 | 1095 | 1252 | } | |
2128 | 1096 | iconstr = g_icon_to_string (icon); | ||
2129 | 1097 | g_menu_item_set_attribute (item, "x-canonical-icon", "s", iconstr); | ||
2130 | 1098 | |||
2131 | 1099 | g_free (iconstr); | ||
2132 | 1100 | } | ||
2133 | 1101 | else | ||
2134 | 1102 | { | ||
2135 | 1103 | g_menu_item_set_attribute_value (item, "x-canonical-icon", NULL); | ||
2136 | 1104 | } | ||
2137 | 1105 | |||
2138 | 1106 | g_menu_replace_item (app->menu, pos, item); | ||
2139 | 1107 | |||
2140 | 1108 | g_object_unref (item); | ||
2149 | 1109 | } | 1253 | } |
2150 | 1110 | 1254 | ||
2151 | 1111 | /** | 1255 | /** |
2152 | @@ -1120,7 +1264,17 @@ | |||
2153 | 1120 | const gchar *source_id, | 1264 | const gchar *source_id, |
2154 | 1121 | guint count) | 1265 | guint count) |
2155 | 1122 | { | 1266 | { |
2157 | 1123 | messaging_menu_app_set_source_action (app, source_id, count, 0, ""); | 1267 | Source *source; |
2158 | 1268 | |||
2159 | 1269 | g_return_if_fail (MESSAGING_MENU_IS_APP (app)); | ||
2160 | 1270 | g_return_if_fail (source_id != NULL); | ||
2161 | 1271 | |||
2162 | 1272 | source = messaging_menu_app_get_source (app, source_id); | ||
2163 | 1273 | if (source) | ||
2164 | 1274 | { | ||
2165 | 1275 | source->count = count; | ||
2166 | 1276 | messaging_menu_app_notify_source_changed (app, source); | ||
2167 | 1277 | } | ||
2168 | 1124 | } | 1278 | } |
2169 | 1125 | 1279 | ||
2170 | 1126 | /** | 1280 | /** |
2171 | @@ -1136,7 +1290,17 @@ | |||
2172 | 1136 | const gchar *source_id, | 1290 | const gchar *source_id, |
2173 | 1137 | gint64 time) | 1291 | gint64 time) |
2174 | 1138 | { | 1292 | { |
2176 | 1139 | messaging_menu_app_set_source_action (app, source_id, 0, time, ""); | 1293 | Source *source; |
2177 | 1294 | |||
2178 | 1295 | g_return_if_fail (MESSAGING_MENU_IS_APP (app)); | ||
2179 | 1296 | g_return_if_fail (source_id != NULL); | ||
2180 | 1297 | |||
2181 | 1298 | source = messaging_menu_app_get_source (app, source_id); | ||
2182 | 1299 | if (source) | ||
2183 | 1300 | { | ||
2184 | 1301 | source->time = time; | ||
2185 | 1302 | messaging_menu_app_notify_source_changed (app, source); | ||
2186 | 1303 | } | ||
2187 | 1140 | } | 1304 | } |
2188 | 1141 | 1305 | ||
2189 | 1142 | /** | 1306 | /** |
2190 | @@ -1152,7 +1316,18 @@ | |||
2191 | 1152 | const gchar *source_id, | 1316 | const gchar *source_id, |
2192 | 1153 | const gchar *str) | 1317 | const gchar *str) |
2193 | 1154 | { | 1318 | { |
2195 | 1155 | messaging_menu_app_set_source_action (app, source_id, 0, 0, str); | 1319 | Source *source; |
2196 | 1320 | |||
2197 | 1321 | g_return_if_fail (MESSAGING_MENU_IS_APP (app)); | ||
2198 | 1322 | g_return_if_fail (source_id != NULL); | ||
2199 | 1323 | |||
2200 | 1324 | source = messaging_menu_app_get_source (app, source_id); | ||
2201 | 1325 | if (source) | ||
2202 | 1326 | { | ||
2203 | 1327 | g_free (source->string); | ||
2204 | 1328 | source->string = g_strdup (str); | ||
2205 | 1329 | messaging_menu_app_notify_source_changed (app, source); | ||
2206 | 1330 | } | ||
2207 | 1156 | } | 1331 | } |
2208 | 1157 | 1332 | ||
2209 | 1158 | /** | 1333 | /** |
2210 | @@ -1170,7 +1345,17 @@ | |||
2211 | 1170 | messaging_menu_app_draw_attention (MessagingMenuApp *app, | 1345 | messaging_menu_app_draw_attention (MessagingMenuApp *app, |
2212 | 1171 | const gchar *source_id) | 1346 | const gchar *source_id) |
2213 | 1172 | { | 1347 | { |
2215 | 1173 | messaging_menu_app_set_draws_attention (app, source_id, TRUE); | 1348 | Source *source; |
2216 | 1349 | |||
2217 | 1350 | g_return_if_fail (MESSAGING_MENU_IS_APP (app)); | ||
2218 | 1351 | g_return_if_fail (source_id != NULL); | ||
2219 | 1352 | |||
2220 | 1353 | source = messaging_menu_app_get_source (app, source_id); | ||
2221 | 1354 | if (source) | ||
2222 | 1355 | { | ||
2223 | 1356 | source->draws_attention = TRUE; | ||
2224 | 1357 | messaging_menu_app_notify_source_changed (app, source); | ||
2225 | 1358 | } | ||
2226 | 1174 | } | 1359 | } |
2227 | 1175 | 1360 | ||
2228 | 1176 | /** | 1361 | /** |
2229 | @@ -1191,5 +1376,135 @@ | |||
2230 | 1191 | messaging_menu_app_remove_attention (MessagingMenuApp *app, | 1376 | messaging_menu_app_remove_attention (MessagingMenuApp *app, |
2231 | 1192 | const gchar *source_id) | 1377 | const gchar *source_id) |
2232 | 1193 | { | 1378 | { |
2233 | 1379 | <<<<<<< TREE | ||
2234 | 1194 | messaging_menu_app_set_draws_attention (app, source_id, FALSE); | 1380 | messaging_menu_app_set_draws_attention (app, source_id, FALSE); |
2235 | 1381 | ======= | ||
2236 | 1382 | Source *source; | ||
2237 | 1383 | |||
2238 | 1384 | g_return_if_fail (MESSAGING_MENU_IS_APP (app)); | ||
2239 | 1385 | g_return_if_fail (source_id != NULL); | ||
2240 | 1386 | |||
2241 | 1387 | source = messaging_menu_app_get_source (app, source_id); | ||
2242 | 1388 | if (source) | ||
2243 | 1389 | { | ||
2244 | 1390 | source->draws_attention = FALSE; | ||
2245 | 1391 | messaging_menu_app_notify_source_changed (app, source); | ||
2246 | 1392 | } | ||
2247 | 1393 | } | ||
2248 | 1394 | |||
2249 | 1395 | /** | ||
2250 | 1396 | * messaging_menu_app_append_message: | ||
2251 | 1397 | * @app: a #MessagingMenuApp | ||
2252 | 1398 | * @msg: the #MessagingMenuMessage to append | ||
2253 | 1399 | * @source_id: (allow-none): the source id to which @msg is added, or NULL | ||
2254 | 1400 | * @notify: whether a notification bubble should be shown for this | ||
2255 | 1401 | * message | ||
2256 | 1402 | * | ||
2257 | 1403 | * Appends @msg to the source with id @source_id of @app. The messaging | ||
2258 | 1404 | * menu might not display this message immediately if other messages are | ||
2259 | 1405 | * queued before this one. | ||
2260 | 1406 | * | ||
2261 | 1407 | * If @source_id has a count associated with it, that count will be | ||
2262 | 1408 | * increased by one. | ||
2263 | 1409 | * | ||
2264 | 1410 | * If @source_id is %NULL, @msg won't be associated with a source. | ||
2265 | 1411 | */ | ||
2266 | 1412 | void | ||
2267 | 1413 | messaging_menu_app_append_message (MessagingMenuApp *app, | ||
2268 | 1414 | MessagingMenuMessage *msg, | ||
2269 | 1415 | const gchar *source_id, | ||
2270 | 1416 | gboolean notify) | ||
2271 | 1417 | { | ||
2272 | 1418 | const gchar *id; | ||
2273 | 1419 | |||
2274 | 1420 | g_return_if_fail (MESSAGING_MENU_IS_APP (app)); | ||
2275 | 1421 | g_return_if_fail (MESSAGING_MENU_IS_MESSAGE (msg)); | ||
2276 | 1422 | |||
2277 | 1423 | id = messaging_menu_message_get_id (msg); | ||
2278 | 1424 | |||
2279 | 1425 | if (g_hash_table_lookup (app->messages, id)) | ||
2280 | 1426 | { | ||
2281 | 1427 | g_warning ("a message with id '%s' already exists", id); | ||
2282 | 1428 | return; | ||
2283 | 1429 | } | ||
2284 | 1430 | |||
2285 | 1431 | g_hash_table_insert (app->messages, g_strdup (id), g_object_ref (msg)); | ||
2286 | 1432 | indicator_messages_application_emit_message_added (app->app_interface, | ||
2287 | 1433 | _messaging_menu_message_to_variant (msg)); | ||
2288 | 1434 | |||
2289 | 1435 | if (source_id) | ||
2290 | 1436 | { | ||
2291 | 1437 | Source *source; | ||
2292 | 1438 | |||
2293 | 1439 | source = messaging_menu_app_get_source (app, source_id); | ||
2294 | 1440 | if (source && source->count >= 0) | ||
2295 | 1441 | { | ||
2296 | 1442 | source->count++; | ||
2297 | 1443 | messaging_menu_app_notify_source_changed (app, source); | ||
2298 | 1444 | } | ||
2299 | 1445 | } | ||
2300 | 1446 | } | ||
2301 | 1447 | |||
2302 | 1448 | /** | ||
2303 | 1449 | * messaging_menu_app_get_message: | ||
2304 | 1450 | * @app: a #MessagingMenuApp | ||
2305 | 1451 | * @id: id of the message to retrieve | ||
2306 | 1452 | * | ||
2307 | 1453 | * Retrieves the message with @id, that was added with | ||
2308 | 1454 | * messaging_menu_app_append_message(). | ||
2309 | 1455 | * | ||
2310 | 1456 | * Returns: (transfer none) (allow-none): the #MessagingMenuApp with | ||
2311 | 1457 | * @id, or %NULL | ||
2312 | 1458 | */ | ||
2313 | 1459 | MessagingMenuMessage * | ||
2314 | 1460 | messaging_menu_app_get_message (MessagingMenuApp *app, | ||
2315 | 1461 | const gchar *id) | ||
2316 | 1462 | { | ||
2317 | 1463 | g_return_val_if_fail (MESSAGING_MENU_IS_APP (app), NULL); | ||
2318 | 1464 | g_return_val_if_fail (id != NULL, NULL); | ||
2319 | 1465 | |||
2320 | 1466 | return g_hash_table_lookup (app->messages, id); | ||
2321 | 1467 | } | ||
2322 | 1468 | |||
2323 | 1469 | /** | ||
2324 | 1470 | * messaging_menu_app_remove_message: | ||
2325 | 1471 | * @app: a #MessagingMenuApp | ||
2326 | 1472 | * @msg: the #MessagingMenuMessage to remove | ||
2327 | 1473 | * | ||
2328 | 1474 | * Removes @msg from @app. | ||
2329 | 1475 | * | ||
2330 | 1476 | * If @source_id has a count associated with it, that count will be | ||
2331 | 1477 | * decreased by one. | ||
2332 | 1478 | */ | ||
2333 | 1479 | void | ||
2334 | 1480 | messaging_menu_app_remove_message (MessagingMenuApp *app, | ||
2335 | 1481 | MessagingMenuMessage *msg) | ||
2336 | 1482 | { | ||
2337 | 1483 | /* take a ref of @msg here to make sure the pointer returned by | ||
2338 | 1484 | * _get_id() is valid for the duration of remove_message_by_id. */ | ||
2339 | 1485 | g_object_ref (msg); | ||
2340 | 1486 | messaging_menu_app_remove_message_by_id (app, messaging_menu_message_get_id (msg)); | ||
2341 | 1487 | g_object_unref (msg); | ||
2342 | 1488 | } | ||
2343 | 1489 | |||
2344 | 1490 | /** | ||
2345 | 1491 | * messaging_menu_app_remove_message_by_id: | ||
2346 | 1492 | * @app: a #MessagingMenuApp | ||
2347 | 1493 | * @id: the unique id of @msg | ||
2348 | 1494 | * | ||
2349 | 1495 | * Removes the message with the id @id from @app. | ||
2350 | 1496 | * | ||
2351 | 1497 | * If @source_id has a count associated with it, that count will be | ||
2352 | 1498 | * decreased by one. | ||
2353 | 1499 | */ | ||
2354 | 1500 | void | ||
2355 | 1501 | messaging_menu_app_remove_message_by_id (MessagingMenuApp *app, | ||
2356 | 1502 | const gchar *id) | ||
2357 | 1503 | { | ||
2358 | 1504 | g_return_if_fail (MESSAGING_MENU_IS_APP (app)); | ||
2359 | 1505 | g_return_if_fail (id != NULL); | ||
2360 | 1506 | |||
2361 | 1507 | if (messaging_menu_app_remove_message_internal (app, id)) | ||
2362 | 1508 | indicator_messages_application_emit_message_removed (app->app_interface, id); | ||
2363 | 1509 | >>>>>>> MERGE-SOURCE | ||
2364 | 1195 | } | 1510 | } |
2365 | 1196 | 1511 | ||
2366 | === renamed file 'libmessaging-menu/messaging-menu.h' => 'libmessaging-menu/messaging-menu-app.h' | |||
2367 | --- libmessaging-menu/messaging-menu.h 2012-08-31 17:19:21 +0000 | |||
2368 | +++ libmessaging-menu/messaging-menu-app.h 2013-04-26 16:57:25 +0000 | |||
2369 | @@ -17,10 +17,11 @@ | |||
2370 | 17 | * Lars Uebernickel <lars.uebernickel@canonical.com> | 17 | * Lars Uebernickel <lars.uebernickel@canonical.com> |
2371 | 18 | */ | 18 | */ |
2372 | 19 | 19 | ||
2375 | 20 | #ifndef __messaging_menu_h__ | 20 | #ifndef __messaging_menu_app_h__ |
2376 | 21 | #define __messaging_menu_h__ | 21 | #define __messaging_menu_app_h__ |
2377 | 22 | 22 | ||
2378 | 23 | #include <gio/gio.h> | 23 | #include <gio/gio.h> |
2379 | 24 | #include "messaging-menu-message.h" | ||
2380 | 24 | 25 | ||
2381 | 25 | G_BEGIN_DECLS | 26 | G_BEGIN_DECLS |
2382 | 26 | 27 | ||
2383 | @@ -143,6 +144,20 @@ | |||
2384 | 143 | void messaging_menu_app_remove_attention (MessagingMenuApp *app, | 144 | void messaging_menu_app_remove_attention (MessagingMenuApp *app, |
2385 | 144 | const gchar *source_id); | 145 | const gchar *source_id); |
2386 | 145 | 146 | ||
2387 | 147 | void messaging_menu_app_append_message (MessagingMenuApp *app, | ||
2388 | 148 | MessagingMenuMessage *msg, | ||
2389 | 149 | const gchar *source_id, | ||
2390 | 150 | gboolean notify); | ||
2391 | 151 | |||
2392 | 152 | MessagingMenuMessage * messaging_menu_app_get_message (MessagingMenuApp *app, | ||
2393 | 153 | const gchar *id); | ||
2394 | 154 | |||
2395 | 155 | void messaging_menu_app_remove_message (MessagingMenuApp *app, | ||
2396 | 156 | MessagingMenuMessage *msg); | ||
2397 | 157 | |||
2398 | 158 | void messaging_menu_app_remove_message_by_id (MessagingMenuApp *app, | ||
2399 | 159 | const gchar *id); | ||
2400 | 160 | |||
2401 | 146 | G_END_DECLS | 161 | G_END_DECLS |
2402 | 147 | 162 | ||
2403 | 148 | #endif | 163 | #endif |
2404 | 149 | 164 | ||
2405 | === added file 'libmessaging-menu/messaging-menu-message.c' | |||
2406 | --- libmessaging-menu/messaging-menu-message.c 1970-01-01 00:00:00 +0000 | |||
2407 | +++ libmessaging-menu/messaging-menu-message.c 2013-04-26 16:57:25 +0000 | |||
2408 | @@ -0,0 +1,547 @@ | |||
2409 | 1 | /* | ||
2410 | 2 | * Copyright 2012 Canonical Ltd. | ||
2411 | 3 | * | ||
2412 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
2413 | 5 | * under the terms of the GNU General Public License version 3, as | ||
2414 | 6 | * published by the Free Software Foundation. | ||
2415 | 7 | * | ||
2416 | 8 | * This program is distributed in the hope that it will be useful, but | ||
2417 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
2418 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
2419 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
2420 | 12 | * | ||
2421 | 13 | * You should have received a copy of the GNU General Public License along | ||
2422 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2423 | 15 | * | ||
2424 | 16 | * Authors: | ||
2425 | 17 | * Lars Uebernickel <lars.uebernickel@canonical.com> | ||
2426 | 18 | */ | ||
2427 | 19 | |||
2428 | 20 | #include "messaging-menu-message.h" | ||
2429 | 21 | |||
2430 | 22 | typedef GObjectClass MessagingMenuMessageClass; | ||
2431 | 23 | |||
2432 | 24 | struct _MessagingMenuMessage | ||
2433 | 25 | { | ||
2434 | 26 | GObject parent; | ||
2435 | 27 | |||
2436 | 28 | gchar *id; | ||
2437 | 29 | GIcon *icon; | ||
2438 | 30 | gchar *title; | ||
2439 | 31 | gchar *subtitle; | ||
2440 | 32 | gchar *body; | ||
2441 | 33 | gint64 time; | ||
2442 | 34 | gboolean draws_attention; | ||
2443 | 35 | |||
2444 | 36 | GSList *actions; | ||
2445 | 37 | }; | ||
2446 | 38 | |||
2447 | 39 | G_DEFINE_TYPE (MessagingMenuMessage, messaging_menu_message, G_TYPE_OBJECT); | ||
2448 | 40 | |||
2449 | 41 | enum | ||
2450 | 42 | { | ||
2451 | 43 | PROP_0, | ||
2452 | 44 | PROP_ID, | ||
2453 | 45 | PROP_ICON, | ||
2454 | 46 | PROP_TITLE, | ||
2455 | 47 | PROP_SUBTITLE, | ||
2456 | 48 | PROP_BODY, | ||
2457 | 49 | PROP_TIME, | ||
2458 | 50 | PROP_DRAWS_ATTENTION, | ||
2459 | 51 | NUM_PROPERTIES | ||
2460 | 52 | }; | ||
2461 | 53 | |||
2462 | 54 | static GParamSpec *properties[NUM_PROPERTIES]; | ||
2463 | 55 | |||
2464 | 56 | typedef struct | ||
2465 | 57 | { | ||
2466 | 58 | gchar *id; | ||
2467 | 59 | gchar *label; | ||
2468 | 60 | GVariantType *parameter_type; | ||
2469 | 61 | GVariant *parameter_hint; | ||
2470 | 62 | } Action; | ||
2471 | 63 | |||
2472 | 64 | static void | ||
2473 | 65 | action_free (gpointer data) | ||
2474 | 66 | { | ||
2475 | 67 | Action *action = data; | ||
2476 | 68 | |||
2477 | 69 | g_free (action->id); | ||
2478 | 70 | g_free (action->label); | ||
2479 | 71 | |||
2480 | 72 | if (action->parameter_type) | ||
2481 | 73 | g_variant_type_free (action->parameter_type); | ||
2482 | 74 | |||
2483 | 75 | if (action->parameter_hint) | ||
2484 | 76 | g_variant_unref (action->parameter_hint); | ||
2485 | 77 | |||
2486 | 78 | g_slice_free (Action, action); | ||
2487 | 79 | } | ||
2488 | 80 | |||
2489 | 81 | static void | ||
2490 | 82 | messaging_menu_message_dispose (GObject *object) | ||
2491 | 83 | { | ||
2492 | 84 | MessagingMenuMessage *msg = MESSAGING_MENU_MESSAGE (object); | ||
2493 | 85 | |||
2494 | 86 | g_clear_object (&msg->icon); | ||
2495 | 87 | |||
2496 | 88 | G_OBJECT_CLASS (messaging_menu_message_parent_class)->dispose (object); | ||
2497 | 89 | } | ||
2498 | 90 | |||
2499 | 91 | static void | ||
2500 | 92 | messaging_menu_message_finalize (GObject *object) | ||
2501 | 93 | { | ||
2502 | 94 | MessagingMenuMessage *msg = MESSAGING_MENU_MESSAGE (object); | ||
2503 | 95 | |||
2504 | 96 | g_free (msg->id); | ||
2505 | 97 | g_free (msg->title); | ||
2506 | 98 | g_free (msg->subtitle); | ||
2507 | 99 | g_free (msg->body); | ||
2508 | 100 | |||
2509 | 101 | g_slist_free_full (msg->actions, action_free); | ||
2510 | 102 | msg->actions = NULL; | ||
2511 | 103 | |||
2512 | 104 | G_OBJECT_CLASS (messaging_menu_message_parent_class)->finalize (object); | ||
2513 | 105 | } | ||
2514 | 106 | |||
2515 | 107 | static void | ||
2516 | 108 | messaging_menu_message_get_property (GObject *object, | ||
2517 | 109 | guint property_id, | ||
2518 | 110 | GValue *value, | ||
2519 | 111 | GParamSpec *pspec) | ||
2520 | 112 | { | ||
2521 | 113 | MessagingMenuMessage *msg = MESSAGING_MENU_MESSAGE (object); | ||
2522 | 114 | |||
2523 | 115 | switch (property_id) | ||
2524 | 116 | { | ||
2525 | 117 | case PROP_ID: | ||
2526 | 118 | g_value_set_string (value, msg->id); | ||
2527 | 119 | break; | ||
2528 | 120 | |||
2529 | 121 | case PROP_ICON: | ||
2530 | 122 | g_value_set_object (value, msg->icon); | ||
2531 | 123 | break; | ||
2532 | 124 | |||
2533 | 125 | case PROP_TITLE: | ||
2534 | 126 | g_value_set_string (value, msg->title); | ||
2535 | 127 | break; | ||
2536 | 128 | |||
2537 | 129 | case PROP_SUBTITLE: | ||
2538 | 130 | g_value_set_string (value, msg->subtitle); | ||
2539 | 131 | break; | ||
2540 | 132 | |||
2541 | 133 | case PROP_BODY: | ||
2542 | 134 | g_value_set_string (value, msg->body); | ||
2543 | 135 | |||
2544 | 136 | case PROP_TIME: | ||
2545 | 137 | g_value_set_int64 (value, msg->time); | ||
2546 | 138 | break; | ||
2547 | 139 | |||
2548 | 140 | case PROP_DRAWS_ATTENTION: | ||
2549 | 141 | g_value_set_boolean (value, msg->draws_attention); | ||
2550 | 142 | break; | ||
2551 | 143 | |||
2552 | 144 | default: | ||
2553 | 145 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); | ||
2554 | 146 | } | ||
2555 | 147 | } | ||
2556 | 148 | |||
2557 | 149 | static void | ||
2558 | 150 | messaging_menu_message_set_property (GObject *object, | ||
2559 | 151 | guint property_id, | ||
2560 | 152 | const GValue *value, | ||
2561 | 153 | GParamSpec *pspec) | ||
2562 | 154 | { | ||
2563 | 155 | MessagingMenuMessage *msg = MESSAGING_MENU_MESSAGE (object); | ||
2564 | 156 | |||
2565 | 157 | switch (property_id) | ||
2566 | 158 | { | ||
2567 | 159 | case PROP_ID: | ||
2568 | 160 | msg->id = g_value_dup_string (value); | ||
2569 | 161 | break; | ||
2570 | 162 | |||
2571 | 163 | case PROP_ICON: | ||
2572 | 164 | msg->icon = g_value_dup_object (value); | ||
2573 | 165 | break; | ||
2574 | 166 | |||
2575 | 167 | case PROP_TITLE: | ||
2576 | 168 | msg->title = g_value_dup_string (value); | ||
2577 | 169 | break; | ||
2578 | 170 | |||
2579 | 171 | case PROP_SUBTITLE: | ||
2580 | 172 | msg->subtitle = g_value_dup_string (value); | ||
2581 | 173 | break; | ||
2582 | 174 | |||
2583 | 175 | case PROP_BODY: | ||
2584 | 176 | msg->body = g_value_dup_string (value); | ||
2585 | 177 | |||
2586 | 178 | case PROP_TIME: | ||
2587 | 179 | msg->time = g_value_get_int64 (value); | ||
2588 | 180 | break; | ||
2589 | 181 | |||
2590 | 182 | case PROP_DRAWS_ATTENTION: | ||
2591 | 183 | messaging_menu_message_set_draws_attention (msg, g_value_get_boolean (value)); | ||
2592 | 184 | break; | ||
2593 | 185 | |||
2594 | 186 | default: | ||
2595 | 187 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); | ||
2596 | 188 | } | ||
2597 | 189 | } | ||
2598 | 190 | |||
2599 | 191 | static void | ||
2600 | 192 | messaging_menu_message_class_init (MessagingMenuMessageClass *klass) | ||
2601 | 193 | { | ||
2602 | 194 | GObjectClass *object_class = G_OBJECT_CLASS (klass); | ||
2603 | 195 | |||
2604 | 196 | object_class->dispose = messaging_menu_message_dispose; | ||
2605 | 197 | object_class->finalize = messaging_menu_message_finalize; | ||
2606 | 198 | object_class->get_property = messaging_menu_message_get_property; | ||
2607 | 199 | object_class->set_property = messaging_menu_message_set_property; | ||
2608 | 200 | |||
2609 | 201 | properties[PROP_ID] = g_param_spec_string ("id", "Id", | ||
2610 | 202 | "Unique id of the message", | ||
2611 | 203 | NULL, | ||
2612 | 204 | G_PARAM_CONSTRUCT_ONLY | | ||
2613 | 205 | G_PARAM_READWRITE | | ||
2614 | 206 | G_PARAM_STATIC_STRINGS); | ||
2615 | 207 | |||
2616 | 208 | properties[PROP_ICON] = g_param_spec_object ("icon", "Icon", | ||
2617 | 209 | "Icon of the message", | ||
2618 | 210 | G_TYPE_ICON, | ||
2619 | 211 | G_PARAM_CONSTRUCT_ONLY | | ||
2620 | 212 | G_PARAM_READWRITE | | ||
2621 | 213 | G_PARAM_STATIC_STRINGS); | ||
2622 | 214 | |||
2623 | 215 | properties[PROP_TITLE] = g_param_spec_string ("title", "Title", | ||
2624 | 216 | "Title of the message", | ||
2625 | 217 | NULL, | ||
2626 | 218 | G_PARAM_CONSTRUCT_ONLY | | ||
2627 | 219 | G_PARAM_READWRITE | | ||
2628 | 220 | G_PARAM_STATIC_STRINGS); | ||
2629 | 221 | |||
2630 | 222 | properties[PROP_SUBTITLE] = g_param_spec_string ("subtitle", "Subtitle", | ||
2631 | 223 | "Subtitle of the message", | ||
2632 | 224 | NULL, | ||
2633 | 225 | G_PARAM_CONSTRUCT_ONLY | | ||
2634 | 226 | G_PARAM_READWRITE | | ||
2635 | 227 | G_PARAM_STATIC_STRINGS); | ||
2636 | 228 | |||
2637 | 229 | properties[PROP_BODY] = g_param_spec_string ("body", "Body", | ||
2638 | 230 | "First lines of the body of the message", | ||
2639 | 231 | NULL, | ||
2640 | 232 | G_PARAM_CONSTRUCT_ONLY | | ||
2641 | 233 | G_PARAM_READWRITE | | ||
2642 | 234 | G_PARAM_STATIC_STRINGS); | ||
2643 | 235 | |||
2644 | 236 | properties[PROP_TIME] = g_param_spec_int64 ("time", "Time", | ||
2645 | 237 | "Time the message was sent, in microseconds", 0, G_MAXINT64, 0, | ||
2646 | 238 | G_PARAM_CONSTRUCT_ONLY | | ||
2647 | 239 | G_PARAM_READWRITE | | ||
2648 | 240 | G_PARAM_STATIC_STRINGS); | ||
2649 | 241 | |||
2650 | 242 | properties[PROP_DRAWS_ATTENTION] = g_param_spec_boolean ("draws-attention", "Draws attention", | ||
2651 | 243 | "Whether the message should draw attention", | ||
2652 | 244 | FALSE, | ||
2653 | 245 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); | ||
2654 | 246 | |||
2655 | 247 | g_object_class_install_properties (klass, NUM_PROPERTIES, properties); | ||
2656 | 248 | |||
2657 | 249 | /** | ||
2658 | 250 | * MessagingMenuMessage::activate: | ||
2659 | 251 | * @msg: the #MessagingMenuMessage | ||
2660 | 252 | * @action: (allow-none): the id of activated action, or %NULL | ||
2661 | 253 | * @parameter: (allow-none): activation parameter, or %NULL | ||
2662 | 254 | * | ||
2663 | 255 | * Emitted when the user has activated the message. The message is | ||
2664 | 256 | * immediately removed from the application's menu, handlers of this | ||
2665 | 257 | * signal do not need to call messaging_menu_app_remove_message(). | ||
2666 | 258 | */ | ||
2667 | 259 | g_signal_new ("activate", | ||
2668 | 260 | MESSAGING_MENU_TYPE_MESSAGE, | ||
2669 | 261 | G_SIGNAL_RUN_FIRST | G_SIGNAL_DETAILED, | ||
2670 | 262 | 0, | ||
2671 | 263 | NULL, NULL, | ||
2672 | 264 | g_cclosure_marshal_generic, | ||
2673 | 265 | G_TYPE_NONE, 2, | ||
2674 | 266 | G_TYPE_STRING, | ||
2675 | 267 | G_TYPE_VARIANT); | ||
2676 | 268 | } | ||
2677 | 269 | |||
2678 | 270 | static void | ||
2679 | 271 | messaging_menu_message_init (MessagingMenuMessage *self) | ||
2680 | 272 | { | ||
2681 | 273 | } | ||
2682 | 274 | |||
2683 | 275 | /** | ||
2684 | 276 | * messaging_menu_message_new: | ||
2685 | 277 | * @id: unique id of the message | ||
2686 | 278 | * @icon: (transfer full) (allow-none): a #GIcon representing the message | ||
2687 | 279 | * @title: the title of the message | ||
2688 | 280 | * @subtitle: (allow-none): the subtitle of the message | ||
2689 | 281 | * @body: (allow-none): the message body | ||
2690 | 282 | * @time: the time the message was received | ||
2691 | 283 | * | ||
2692 | 284 | * Creates a new #MessagingMenuMessage. | ||
2693 | 285 | * | ||
2694 | 286 | * Returns: (transfer full): a new #MessagingMenuMessage | ||
2695 | 287 | */ | ||
2696 | 288 | MessagingMenuMessage * | ||
2697 | 289 | messaging_menu_message_new (const gchar *id, | ||
2698 | 290 | GIcon *icon, | ||
2699 | 291 | const gchar *title, | ||
2700 | 292 | const gchar *subtitle, | ||
2701 | 293 | const gchar *body, | ||
2702 | 294 | gint64 time) | ||
2703 | 295 | { | ||
2704 | 296 | g_return_val_if_fail (id != NULL, NULL); | ||
2705 | 297 | g_return_val_if_fail (title != NULL, NULL); | ||
2706 | 298 | |||
2707 | 299 | return g_object_new (MESSAGING_MENU_TYPE_MESSAGE, | ||
2708 | 300 | "id", id, | ||
2709 | 301 | "icon", icon, | ||
2710 | 302 | "title", title, | ||
2711 | 303 | "subtitle", subtitle, | ||
2712 | 304 | "body", body, | ||
2713 | 305 | "time", time, | ||
2714 | 306 | NULL); | ||
2715 | 307 | } | ||
2716 | 308 | |||
2717 | 309 | /** | ||
2718 | 310 | * messaging_menu_message_get_id: | ||
2719 | 311 | * @msg: a #MessagingMenuMessage | ||
2720 | 312 | * | ||
2721 | 313 | * Returns: the unique id of @msg | ||
2722 | 314 | */ | ||
2723 | 315 | const gchar * | ||
2724 | 316 | messaging_menu_message_get_id (MessagingMenuMessage *msg) | ||
2725 | 317 | { | ||
2726 | 318 | g_return_val_if_fail (MESSAGING_MENU_IS_MESSAGE (msg), NULL); | ||
2727 | 319 | |||
2728 | 320 | return msg->id; | ||
2729 | 321 | } | ||
2730 | 322 | |||
2731 | 323 | /** | ||
2732 | 324 | * messaging_menu_message_get_icon: | ||
2733 | 325 | * @msg: a #MessagingMenuMessage | ||
2734 | 326 | * | ||
2735 | 327 | * Returns: (transfer none): the icon of @msg | ||
2736 | 328 | */ | ||
2737 | 329 | GIcon * | ||
2738 | 330 | messaging_menu_message_get_icon (MessagingMenuMessage *msg) | ||
2739 | 331 | { | ||
2740 | 332 | g_return_val_if_fail (MESSAGING_MENU_IS_MESSAGE (msg), NULL); | ||
2741 | 333 | |||
2742 | 334 | return msg->icon; | ||
2743 | 335 | } | ||
2744 | 336 | |||
2745 | 337 | /** | ||
2746 | 338 | * messaging_menu_message_get_title: | ||
2747 | 339 | * @msg: a #MessagingMenuMessage | ||
2748 | 340 | * | ||
2749 | 341 | * Returns: the title of @msg | ||
2750 | 342 | */ | ||
2751 | 343 | const gchar * | ||
2752 | 344 | messaging_menu_message_get_title (MessagingMenuMessage *msg) | ||
2753 | 345 | { | ||
2754 | 346 | g_return_val_if_fail (MESSAGING_MENU_IS_MESSAGE (msg), NULL); | ||
2755 | 347 | |||
2756 | 348 | return msg->title; | ||
2757 | 349 | } | ||
2758 | 350 | |||
2759 | 351 | /** | ||
2760 | 352 | * messaging_menu_message_get_subtitle: | ||
2761 | 353 | * @msg: a #MessagingMenuMessage | ||
2762 | 354 | * | ||
2763 | 355 | * Returns: the subtitle of @msg | ||
2764 | 356 | */ | ||
2765 | 357 | const gchar * | ||
2766 | 358 | messaging_menu_message_get_subtitle (MessagingMenuMessage *msg) | ||
2767 | 359 | { | ||
2768 | 360 | g_return_val_if_fail (MESSAGING_MENU_IS_MESSAGE (msg), NULL); | ||
2769 | 361 | |||
2770 | 362 | return msg->subtitle; | ||
2771 | 363 | } | ||
2772 | 364 | |||
2773 | 365 | /** | ||
2774 | 366 | * messaging_menu_message_get_body: | ||
2775 | 367 | * @msg: a #MessagingMenuMessage | ||
2776 | 368 | * | ||
2777 | 369 | * Returns: the body of @msg | ||
2778 | 370 | */ | ||
2779 | 371 | const gchar * | ||
2780 | 372 | messaging_menu_message_get_body (MessagingMenuMessage *msg) | ||
2781 | 373 | { | ||
2782 | 374 | g_return_val_if_fail (MESSAGING_MENU_IS_MESSAGE (msg), NULL); | ||
2783 | 375 | |||
2784 | 376 | return msg->body; | ||
2785 | 377 | } | ||
2786 | 378 | |||
2787 | 379 | /** | ||
2788 | 380 | * messaging_menu_message_get_time: | ||
2789 | 381 | * @msg: a #MessagingMenuMessage | ||
2790 | 382 | * | ||
2791 | 383 | * Returns: the time at which @msg was received | ||
2792 | 384 | */ | ||
2793 | 385 | gint64 | ||
2794 | 386 | messaging_menu_message_get_time (MessagingMenuMessage *msg) | ||
2795 | 387 | { | ||
2796 | 388 | g_return_val_if_fail (MESSAGING_MENU_IS_MESSAGE (msg), 0); | ||
2797 | 389 | |||
2798 | 390 | return msg->time; | ||
2799 | 391 | } | ||
2800 | 392 | |||
2801 | 393 | /** | ||
2802 | 394 | * messaging_menu_message_get_draws_attention: | ||
2803 | 395 | * @msg: a #MessagingMenuMessage | ||
2804 | 396 | * | ||
2805 | 397 | * Returns: whether @msg is drawing attention | ||
2806 | 398 | */ | ||
2807 | 399 | gboolean | ||
2808 | 400 | messaging_menu_message_get_draws_attention (MessagingMenuMessage *msg) | ||
2809 | 401 | { | ||
2810 | 402 | g_return_val_if_fail (MESSAGING_MENU_IS_MESSAGE (msg), FALSE); | ||
2811 | 403 | |||
2812 | 404 | return msg->draws_attention; | ||
2813 | 405 | } | ||
2814 | 406 | |||
2815 | 407 | /** | ||
2816 | 408 | * messaging_menu_message_set_draws_attention: | ||
2817 | 409 | * @msg: a #MessagingMenuMessage | ||
2818 | 410 | * @draws_attention: whether @msg should draw attention | ||
2819 | 411 | * | ||
2820 | 412 | * Sets whether @msg is drawing attention. | ||
2821 | 413 | */ | ||
2822 | 414 | void | ||
2823 | 415 | messaging_menu_message_set_draws_attention (MessagingMenuMessage *msg, | ||
2824 | 416 | gboolean draws_attention) | ||
2825 | 417 | { | ||
2826 | 418 | g_return_if_fail (MESSAGING_MENU_IS_MESSAGE (msg)); | ||
2827 | 419 | |||
2828 | 420 | msg->draws_attention = draws_attention; | ||
2829 | 421 | g_object_notify_by_pspec (G_OBJECT (msg), properties[PROP_DRAWS_ATTENTION]); | ||
2830 | 422 | } | ||
2831 | 423 | |||
2832 | 424 | /** | ||
2833 | 425 | * messaging_menu_message_add_action: | ||
2834 | 426 | * @msg: a #MessagingMenuMessage | ||
2835 | 427 | * @id: unique id of the action | ||
2836 | 428 | * @label: (allow-none): label of the action | ||
2837 | 429 | * @parameter_type: (allow-none): a #GVariantType | ||
2838 | 430 | * @parameter_hint: (allow-none): a #GVariant suggesting a valid range | ||
2839 | 431 | * for parameters | ||
2840 | 432 | * | ||
2841 | 433 | * Adds an action with @id and @label to @message. Actions are an | ||
2842 | 434 | * alternative way for users to activate a message. Note that messages | ||
2843 | 435 | * can still be activated without an action. | ||
2844 | 436 | * | ||
2845 | 437 | * If @parameter_type is non-%NULL, the action is able to receive user | ||
2846 | 438 | * input in addition to simply activating the action. Currently, only | ||
2847 | 439 | * string parameters are supported. | ||
2848 | 440 | * | ||
2849 | 441 | * A list of predefined parameters can be supplied as a #GVariant array | ||
2850 | 442 | * of @parameter_type in @parameter_hint. If @parameter_hint is | ||
2851 | 443 | * floating, it will be consumed. | ||
2852 | 444 | * | ||
2853 | 445 | * It is recommended to add at most two actions to a message. | ||
2854 | 446 | */ | ||
2855 | 447 | void | ||
2856 | 448 | messaging_menu_message_add_action (MessagingMenuMessage *msg, | ||
2857 | 449 | const gchar *id, | ||
2858 | 450 | const gchar *label, | ||
2859 | 451 | const GVariantType *parameter_type, | ||
2860 | 452 | GVariant *parameter_hint) | ||
2861 | 453 | { | ||
2862 | 454 | Action *action; | ||
2863 | 455 | |||
2864 | 456 | g_return_if_fail (MESSAGING_MENU_IS_MESSAGE (msg)); | ||
2865 | 457 | g_return_if_fail (id != NULL); | ||
2866 | 458 | |||
2867 | 459 | action = g_slice_new (Action); | ||
2868 | 460 | action->id = g_strdup (id); | ||
2869 | 461 | action->label = g_strdup (label); | ||
2870 | 462 | action->parameter_type = parameter_type ? g_variant_type_copy (parameter_type) : NULL; | ||
2871 | 463 | action->parameter_hint = parameter_hint ? g_variant_ref_sink (parameter_hint) : NULL; | ||
2872 | 464 | |||
2873 | 465 | msg->actions = g_slist_append (msg->actions, action); | ||
2874 | 466 | } | ||
2875 | 467 | |||
2876 | 468 | static GVariant * | ||
2877 | 469 | action_to_variant (Action *action) | ||
2878 | 470 | { | ||
2879 | 471 | GVariantBuilder builder; | ||
2880 | 472 | |||
2881 | 473 | g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); | ||
2882 | 474 | |||
2883 | 475 | g_variant_builder_add (&builder, "{sv}", "name", g_variant_new_string (action->id)); | ||
2884 | 476 | |||
2885 | 477 | if (action->label) | ||
2886 | 478 | g_variant_builder_add (&builder, "{sv}", "label", g_variant_new_string (action->label)); | ||
2887 | 479 | |||
2888 | 480 | if (action->parameter_type) | ||
2889 | 481 | { | ||
2890 | 482 | gchar *type = g_variant_type_dup_string (action->parameter_type); | ||
2891 | 483 | g_variant_builder_add (&builder, "{sv}", "parameter-type", g_variant_new_signature (type)); | ||
2892 | 484 | g_free (type); | ||
2893 | 485 | } | ||
2894 | 486 | |||
2895 | 487 | if (action->parameter_hint) | ||
2896 | 488 | g_variant_builder_add (&builder, "{sv}", "parameter-hint", action->parameter_hint); | ||
2897 | 489 | |||
2898 | 490 | return g_variant_builder_end (&builder); | ||
2899 | 491 | } | ||
2900 | 492 | |||
2901 | 493 | /*<internal> | ||
2902 | 494 | * _messaging_menu_message_to_variant: | ||
2903 | 495 | * @msg: a #MessagingMenuMessage | ||
2904 | 496 | * | ||
2905 | 497 | * Serializes @msg to a #GVariant of the form (sssssxaa{sv}b): | ||
2906 | 498 | * | ||
2907 | 499 | * id | ||
2908 | 500 | * icon | ||
2909 | 501 | * title | ||
2910 | 502 | * subtitle | ||
2911 | 503 | * body | ||
2912 | 504 | * time | ||
2913 | 505 | * array of action dictionaries | ||
2914 | 506 | * draws_attention | ||
2915 | 507 | * | ||
2916 | 508 | * Returns: a new floating #GVariant instance | ||
2917 | 509 | */ | ||
2918 | 510 | GVariant * | ||
2919 | 511 | _messaging_menu_message_to_variant (MessagingMenuMessage *msg) | ||
2920 | 512 | { | ||
2921 | 513 | GVariantBuilder builder; | ||
2922 | 514 | GSList *it; | ||
2923 | 515 | |||
2924 | 516 | g_return_val_if_fail (MESSAGING_MENU_IS_MESSAGE (msg), NULL); | ||
2925 | 517 | |||
2926 | 518 | g_variant_builder_init (&builder, G_VARIANT_TYPE ("(sssssxaa{sv}b)")); | ||
2927 | 519 | |||
2928 | 520 | g_variant_builder_add (&builder, "s", msg->id); | ||
2929 | 521 | |||
2930 | 522 | if (msg->icon) | ||
2931 | 523 | { | ||
2932 | 524 | gchar *iconstr; | ||
2933 | 525 | |||
2934 | 526 | iconstr = g_icon_to_string (msg->icon); | ||
2935 | 527 | g_variant_builder_add (&builder, "s", iconstr); | ||
2936 | 528 | |||
2937 | 529 | g_free (iconstr); | ||
2938 | 530 | } | ||
2939 | 531 | else | ||
2940 | 532 | g_variant_builder_add (&builder, "s", ""); | ||
2941 | 533 | |||
2942 | 534 | g_variant_builder_add (&builder, "s", msg->title ? msg->title : ""); | ||
2943 | 535 | g_variant_builder_add (&builder, "s", msg->subtitle ? msg->subtitle : ""); | ||
2944 | 536 | g_variant_builder_add (&builder, "s", msg->body ? msg->body : ""); | ||
2945 | 537 | g_variant_builder_add (&builder, "x", msg->time); | ||
2946 | 538 | |||
2947 | 539 | g_variant_builder_open (&builder, G_VARIANT_TYPE ("aa{sv}")); | ||
2948 | 540 | for (it = msg->actions; it; it = it->next) | ||
2949 | 541 | g_variant_builder_add_value (&builder, action_to_variant (it->data)); | ||
2950 | 542 | g_variant_builder_close (&builder); | ||
2951 | 543 | |||
2952 | 544 | g_variant_builder_add (&builder, "b", msg->draws_attention); | ||
2953 | 545 | |||
2954 | 546 | return g_variant_builder_end (&builder); | ||
2955 | 547 | } | ||
2956 | 0 | 548 | ||
2957 | === added file 'libmessaging-menu/messaging-menu-message.h' | |||
2958 | --- libmessaging-menu/messaging-menu-message.h 1970-01-01 00:00:00 +0000 | |||
2959 | +++ libmessaging-menu/messaging-menu-message.h 2013-04-26 16:57:25 +0000 | |||
2960 | @@ -0,0 +1,70 @@ | |||
2961 | 1 | /* | ||
2962 | 2 | * Copyright 2012 Canonical Ltd. | ||
2963 | 3 | * | ||
2964 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
2965 | 5 | * under the terms of the GNU General Public License version 3, as | ||
2966 | 6 | * published by the Free Software Foundation. | ||
2967 | 7 | * | ||
2968 | 8 | * This program is distributed in the hope that it will be useful, but | ||
2969 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
2970 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
2971 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
2972 | 12 | * | ||
2973 | 13 | * You should have received a copy of the GNU General Public License along | ||
2974 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2975 | 15 | * | ||
2976 | 16 | * Authors: | ||
2977 | 17 | * Lars Uebernickel <lars.uebernickel@canonical.com> | ||
2978 | 18 | */ | ||
2979 | 19 | |||
2980 | 20 | #ifndef __messaging_menu_message_h__ | ||
2981 | 21 | #define __messaging_menu_message_h__ | ||
2982 | 22 | |||
2983 | 23 | #include <gio/gio.h> | ||
2984 | 24 | |||
2985 | 25 | G_BEGIN_DECLS | ||
2986 | 26 | |||
2987 | 27 | #define MESSAGING_MENU_TYPE_MESSAGE (messaging_menu_message_get_type ()) | ||
2988 | 28 | #define MESSAGING_MENU_MESSAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MESSAGING_MENU_TYPE_MESSAGE, MessagingMenuMessage)) | ||
2989 | 29 | #define MESSAGING_MENU_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MESSAGING_MENU_TYPE_MESSAGE, MessagingMenuMessageClass)) | ||
2990 | 30 | #define MESSAGING_MENU_IS_MESSAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MESSAGING_MENU_TYPE_MESSAGE)) | ||
2991 | 31 | #define MESSAGING_MENU_IS_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MESSAGING_MENU_TYPE_MESSAGE)) | ||
2992 | 32 | #define MESSAGING_MENU_MESSAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MESSAGING_MENU_TYPE_MESSAGE, MessagingMenuMessageClass)) | ||
2993 | 33 | |||
2994 | 34 | typedef struct _MessagingMenuMessage MessagingMenuMessage; | ||
2995 | 35 | |||
2996 | 36 | GType messaging_menu_message_get_type (void) G_GNUC_CONST; | ||
2997 | 37 | |||
2998 | 38 | MessagingMenuMessage * messaging_menu_message_new (const gchar *id, | ||
2999 | 39 | GIcon *icon, | ||
3000 | 40 | const gchar *title, | ||
3001 | 41 | const gchar *subtitle, | ||
3002 | 42 | const gchar *body, | ||
3003 | 43 | gint64 time); | ||
3004 | 44 | |||
3005 | 45 | const gchar * messaging_menu_message_get_id (MessagingMenuMessage *msg); | ||
3006 | 46 | |||
3007 | 47 | GIcon * messaging_menu_message_get_icon (MessagingMenuMessage *msg); | ||
3008 | 48 | |||
3009 | 49 | const gchar * messaging_menu_message_get_title (MessagingMenuMessage *msg); | ||
3010 | 50 | |||
3011 | 51 | const gchar * messaging_menu_message_get_subtitle (MessagingMenuMessage *msg); | ||
3012 | 52 | |||
3013 | 53 | const gchar * messaging_menu_message_get_body (MessagingMenuMessage *msg); | ||
3014 | 54 | |||
3015 | 55 | gint64 messaging_menu_message_get_time (MessagingMenuMessage *msg); | ||
3016 | 56 | |||
3017 | 57 | gboolean messaging_menu_message_get_draws_attention (MessagingMenuMessage *msg); | ||
3018 | 58 | |||
3019 | 59 | void messaging_menu_message_set_draws_attention (MessagingMenuMessage *msg, | ||
3020 | 60 | gboolean draws_attention); | ||
3021 | 61 | |||
3022 | 62 | void messaging_menu_message_add_action (MessagingMenuMessage *msg, | ||
3023 | 63 | const gchar *id, | ||
3024 | 64 | const gchar *label, | ||
3025 | 65 | const GVariantType *parameter_type, | ||
3026 | 66 | GVariant *parameter_hint); | ||
3027 | 67 | |||
3028 | 68 | G_END_DECLS | ||
3029 | 69 | |||
3030 | 70 | #endif | ||
3031 | 0 | 71 | ||
3032 | === added file 'libmessaging-menu/messaging-menu.h' | |||
3033 | --- libmessaging-menu/messaging-menu.h 1970-01-01 00:00:00 +0000 | |||
3034 | +++ libmessaging-menu/messaging-menu.h 2013-04-26 16:57:25 +0000 | |||
3035 | @@ -0,0 +1,25 @@ | |||
3036 | 1 | /* | ||
3037 | 2 | * Copyright 2012 Canonical Ltd. | ||
3038 | 3 | * | ||
3039 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
3040 | 5 | * under the terms of the GNU General Public License version 3, as | ||
3041 | 6 | * published by the Free Software Foundation. | ||
3042 | 7 | * | ||
3043 | 8 | * This program is distributed in the hope that it will be useful, but | ||
3044 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
3045 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
3046 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
3047 | 12 | * | ||
3048 | 13 | * You should have received a copy of the GNU General Public License along | ||
3049 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3050 | 15 | * | ||
3051 | 16 | * Authors: | ||
3052 | 17 | * Lars Uebernickel <lars.uebernickel@canonical.com> | ||
3053 | 18 | */ | ||
3054 | 19 | |||
3055 | 20 | #ifndef __messaging_menu_h__ | ||
3056 | 21 | #define __messaging_menu_h__ | ||
3057 | 22 | |||
3058 | 23 | #include "messaging-menu-app.h" | ||
3059 | 24 | |||
3060 | 25 | #endif | ||
3061 | 0 | 26 | ||
3062 | === modified file 'src/Makefile.am' | |||
3063 | --- src/Makefile.am 2012-09-03 13:37:23 +0000 | |||
3064 | +++ src/Makefile.am 2013-04-26 16:57:25 +0000 | |||
3065 | @@ -1,8 +1,5 @@ | |||
3066 | 1 | 1 | ||
3067 | 2 | BUILT_SOURCES = | ||
3068 | 3 | EXTRA_DIST = | 2 | EXTRA_DIST = |
3069 | 4 | CLEANFILES = | ||
3070 | 5 | DISTCLEANFILES = | ||
3071 | 6 | 3 | ||
3072 | 7 | libexec_PROGRAMS = indicator-messages-service | 4 | libexec_PROGRAMS = indicator-messages-service |
3073 | 8 | 5 | ||
3074 | @@ -23,19 +20,20 @@ | |||
3075 | 23 | im-source-menu-item.h \ | 20 | im-source-menu-item.h \ |
3076 | 24 | ido-detail-label.c \ | 21 | ido-detail-label.c \ |
3077 | 25 | ido-detail-label.h \ | 22 | ido-detail-label.h \ |
3078 | 26 | indicator-messages-service.c \ | ||
3079 | 27 | indicator-messages-service.h | ||
3080 | 28 | dbus-data.h | 23 | dbus-data.h |
3081 | 29 | libmessaging_la_CFLAGS = \ | 24 | libmessaging_la_CFLAGS = \ |
3082 | 30 | $(APPLET_CFLAGS) \ | 25 | $(APPLET_CFLAGS) \ |
3083 | 31 | $(COVERAGE_CFLAGS) \ | 26 | $(COVERAGE_CFLAGS) \ |
3084 | 27 | -I$(top_builddir)/common \ | ||
3085 | 32 | -Wall \ | 28 | -Wall \ |
3086 | 33 | -Wl,-Bsymbolic-functions \ | 29 | -Wl,-Bsymbolic-functions \ |
3087 | 34 | -Wl,-z,defs \ | 30 | -Wl,-z,defs \ |
3088 | 35 | -Wl,--as-needed \ | 31 | -Wl,--as-needed \ |
3089 | 36 | -Werror \ | 32 | -Werror \ |
3090 | 37 | -DG_LOG_DOMAIN=\"Indicator-Messages\" | 33 | -DG_LOG_DOMAIN=\"Indicator-Messages\" |
3092 | 38 | libmessaging_la_LIBADD = $(APPLET_LIBS) -lm | 34 | libmessaging_la_LIBADD = \ |
3093 | 35 | $(top_builddir)/common/libmessaging-common.la \ | ||
3094 | 36 | $(APPLET_LIBS) -lm | ||
3095 | 39 | libmessaging_la_LDFLAGS = \ | 37 | libmessaging_la_LDFLAGS = \ |
3096 | 40 | $(COVERAGE_LDFLAGS) \ | 38 | $(COVERAGE_LDFLAGS) \ |
3097 | 41 | -module -avoid-version | 39 | -module -avoid-version |
3098 | @@ -46,8 +44,6 @@ | |||
3099 | 46 | 44 | ||
3100 | 47 | indicator_messages_service_SOURCES = \ | 45 | indicator_messages_service_SOURCES = \ |
3101 | 48 | messages-service.c \ | 46 | messages-service.c \ |
3102 | 49 | indicator-messages-service.c \ | ||
3103 | 50 | indicator-messages-service.h \ | ||
3104 | 51 | app-section.c \ | 47 | app-section.c \ |
3105 | 52 | app-section.h \ | 48 | app-section.h \ |
3106 | 53 | dbus-data.h \ | 49 | dbus-data.h \ |
3107 | @@ -56,11 +52,16 @@ | |||
3108 | 56 | gsettingsstrv.c \ | 52 | gsettingsstrv.c \ |
3109 | 57 | gsettingsstrv.h \ | 53 | gsettingsstrv.h \ |
3110 | 58 | gmenuutils.c \ | 54 | gmenuutils.c \ |
3112 | 59 | gmenuutils.h | 55 | gmenuutils.h \ |
3113 | 56 | im-phone-menu.c \ | ||
3114 | 57 | im-phone-menu.h \ | ||
3115 | 58 | im-application-list.c \ | ||
3116 | 59 | im-application-list.h | ||
3117 | 60 | 60 | ||
3118 | 61 | indicator_messages_service_CFLAGS = \ | 61 | indicator_messages_service_CFLAGS = \ |
3119 | 62 | $(APPLET_CFLAGS) \ | 62 | $(APPLET_CFLAGS) \ |
3120 | 63 | $(COVERAGE_CFLAGS) \ | 63 | $(COVERAGE_CFLAGS) \ |
3121 | 64 | -I$(top_builddir)/common \ | ||
3122 | 64 | -Wall \ | 65 | -Wall \ |
3123 | 65 | -Wl,-Bsymbolic-functions \ | 66 | -Wl,-Bsymbolic-functions \ |
3124 | 66 | -Wl,-z,defs \ | 67 | -Wl,-z,defs \ |
3125 | @@ -69,26 +70,11 @@ | |||
3126 | 69 | -DG_LOG_DOMAIN=\"Indicator-Messages\" | 70 | -DG_LOG_DOMAIN=\"Indicator-Messages\" |
3127 | 70 | 71 | ||
3128 | 71 | indicator_messages_service_LDADD = \ | 72 | indicator_messages_service_LDADD = \ |
3129 | 73 | $(top_builddir)/common/libmessaging-common.la \ | ||
3130 | 72 | $(APPLET_LIBS) | 74 | $(APPLET_LIBS) |
3131 | 73 | 75 | ||
3132 | 74 | indicator_messages_service_LDFLAGS = \ | 76 | indicator_messages_service_LDFLAGS = \ |
3133 | 75 | $(COVERAGE_LDFLAGS) | 77 | $(COVERAGE_LDFLAGS) |
3134 | 76 | 78 | ||
3135 | 77 | indicator-messages-service.c: $(top_srcdir)/src/messages-service.xml | ||
3136 | 78 | $(AM_V_GEN) gdbus-codegen \ | ||
3137 | 79 | --interface-prefix com.canonical.indicator.messages. \ | ||
3138 | 80 | --generate-c-code indicator-messages-service \ | ||
3139 | 81 | --c-namespace IndicatorMessages \ | ||
3140 | 82 | $^ | ||
3141 | 83 | indicator-messages-service.h: indicator-messages-service.c | ||
3142 | 84 | |||
3143 | 85 | BUILT_SOURCES += \ | ||
3144 | 86 | indicator-messages-service.c \ | ||
3145 | 87 | indicator-messages-service.h | ||
3146 | 88 | |||
3147 | 89 | EXTRA_DIST += \ | 79 | EXTRA_DIST += \ |
3148 | 90 | messages-service.xml | 80 | messages-service.xml |
3149 | 91 | |||
3150 | 92 | CLEANFILES += \ | ||
3151 | 93 | $(BUILT_SOURCES) | ||
3152 | 94 | |||
3153 | 95 | 81 | ||
3154 | === modified file 'src/app-section.c' | |||
3155 | --- src/app-section.c 2013-04-22 08:45:52 +0000 | |||
3156 | +++ src/app-section.c 2013-04-26 16:57:25 +0000 | |||
3157 | @@ -34,6 +34,7 @@ | |||
3158 | 34 | #include "dbus-data.h" | 34 | #include "dbus-data.h" |
3159 | 35 | #include "gmenuutils.h" | 35 | #include "gmenuutils.h" |
3160 | 36 | #include "gactionmuxer.h" | 36 | #include "gactionmuxer.h" |
3161 | 37 | #include "indicator-messages-application.h" | ||
3162 | 37 | 38 | ||
3163 | 38 | struct _AppSectionPrivate | 39 | struct _AppSectionPrivate |
3164 | 39 | { | 40 | { |
3165 | @@ -42,11 +43,14 @@ | |||
3166 | 42 | 43 | ||
3167 | 43 | IndicatorDesktopShortcuts * ids; | 44 | IndicatorDesktopShortcuts * ids; |
3168 | 44 | 45 | ||
3169 | 46 | GCancellable *app_proxy_cancellable; | ||
3170 | 47 | IndicatorMessagesApplication *app_proxy; | ||
3171 | 48 | |||
3172 | 45 | GMenu *menu; | 49 | GMenu *menu; |
3174 | 46 | GMenuModel *source_menu; | 50 | GMenu *source_menu; |
3175 | 47 | 51 | ||
3176 | 48 | GSimpleActionGroup *static_shortcuts; | 52 | GSimpleActionGroup *static_shortcuts; |
3178 | 49 | GActionGroup *source_actions; | 53 | GSimpleActionGroup *source_actions; |
3179 | 50 | GActionMuxer *muxer; | 54 | GActionMuxer *muxer; |
3180 | 51 | 55 | ||
3181 | 52 | gboolean draws_attention; | 56 | gboolean draws_attention; |
3182 | @@ -90,19 +94,6 @@ | |||
3183 | 90 | gpointer user_data); | 94 | gpointer user_data); |
3184 | 91 | static void app_section_set_app_info (AppSection *self, | 95 | static void app_section_set_app_info (AppSection *self, |
3185 | 92 | GDesktopAppInfo *appinfo); | 96 | GDesktopAppInfo *appinfo); |
3186 | 93 | static gboolean any_action_draws_attention (GActionGroup *group, | ||
3187 | 94 | const gchar *ignored_action); | ||
3188 | 95 | static void action_added (GActionGroup *group, | ||
3189 | 96 | const gchar *action_name, | ||
3190 | 97 | gpointer user_data); | ||
3191 | 98 | static void action_state_changed (GActionGroup *group, | ||
3192 | 99 | const gchar *action_name, | ||
3193 | 100 | GVariant *value, | ||
3194 | 101 | gpointer user_data); | ||
3195 | 102 | static void action_removed (GActionGroup *group, | ||
3196 | 103 | const gchar *action_name, | ||
3197 | 104 | gpointer user_data); | ||
3198 | 105 | static gboolean action_draws_attention (GVariant *state); | ||
3199 | 106 | static void desktop_file_changed_cb (GFileMonitor *monitor, | 97 | static void desktop_file_changed_cb (GFileMonitor *monitor, |
3200 | 107 | GFile *file, | 98 | GFile *file, |
3201 | 108 | GFile *other_file, | 99 | GFile *other_file, |
3202 | @@ -170,6 +161,7 @@ | |||
3203 | 170 | app_section_init (AppSection *self) | 161 | app_section_init (AppSection *self) |
3204 | 171 | { | 162 | { |
3205 | 172 | AppSectionPrivate *priv; | 163 | AppSectionPrivate *priv; |
3206 | 164 | GMenuItem *item; | ||
3207 | 173 | 165 | ||
3208 | 174 | self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, | 166 | self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, |
3209 | 175 | APP_SECTION_TYPE, | 167 | APP_SECTION_TYPE, |
3210 | @@ -179,10 +171,19 @@ | |||
3211 | 179 | priv->appinfo = NULL; | 171 | priv->appinfo = NULL; |
3212 | 180 | 172 | ||
3213 | 181 | priv->menu = g_menu_new (); | 173 | priv->menu = g_menu_new (); |
3214 | 174 | |||
3215 | 175 | priv->source_menu = g_menu_new (); | ||
3216 | 176 | item = g_menu_item_new_section (NULL, G_MENU_MODEL (priv->source_menu)); | ||
3217 | 177 | g_menu_item_set_attribute (item, "action-namespace", "s", "source"); | ||
3218 | 178 | g_menu_append_item (priv->menu, item); | ||
3219 | 179 | g_object_unref (item); | ||
3220 | 180 | |||
3221 | 182 | priv->static_shortcuts = g_simple_action_group_new (); | 181 | priv->static_shortcuts = g_simple_action_group_new (); |
3222 | 182 | priv->source_actions = g_simple_action_group_new (); | ||
3223 | 183 | 183 | ||
3224 | 184 | priv->muxer = g_action_muxer_new (); | 184 | priv->muxer = g_action_muxer_new (); |
3225 | 185 | g_action_muxer_insert (priv->muxer, NULL, G_ACTION_GROUP (priv->static_shortcuts)); | 185 | g_action_muxer_insert (priv->muxer, NULL, G_ACTION_GROUP (priv->static_shortcuts)); |
3226 | 186 | g_action_muxer_insert (priv->muxer, "source", G_ACTION_GROUP (priv->source_actions)); | ||
3227 | 186 | 187 | ||
3228 | 187 | priv->draws_attention = FALSE; | 188 | priv->draws_attention = FALSE; |
3229 | 188 | 189 | ||
3230 | @@ -249,32 +250,30 @@ | |||
3231 | 249 | AppSection * self = APP_SECTION(object); | 250 | AppSection * self = APP_SECTION(object); |
3232 | 250 | AppSectionPrivate * priv = self->priv; | 251 | AppSectionPrivate * priv = self->priv; |
3233 | 251 | 252 | ||
3234 | 253 | if (priv->app_proxy_cancellable) { | ||
3235 | 254 | g_cancellable_cancel (priv->app_proxy_cancellable); | ||
3236 | 255 | g_clear_object (&priv->app_proxy_cancellable); | ||
3237 | 256 | } | ||
3238 | 257 | |||
3239 | 252 | if (priv->desktop_file_monitor) { | 258 | if (priv->desktop_file_monitor) { |
3240 | 253 | g_signal_handlers_disconnect_by_func (priv->desktop_file_monitor, desktop_file_changed_cb, self); | 259 | g_signal_handlers_disconnect_by_func (priv->desktop_file_monitor, desktop_file_changed_cb, self); |
3241 | 254 | g_clear_object (&priv->desktop_file_monitor); | 260 | g_clear_object (&priv->desktop_file_monitor); |
3242 | 255 | } | 261 | } |
3243 | 256 | 262 | ||
3244 | 263 | g_clear_object (&priv->app_proxy); | ||
3245 | 264 | |||
3246 | 257 | g_clear_object (&priv->menu); | 265 | g_clear_object (&priv->menu); |
3247 | 266 | g_clear_object (&priv->source_menu); | ||
3248 | 258 | g_clear_object (&priv->static_shortcuts); | 267 | g_clear_object (&priv->static_shortcuts); |
3249 | 268 | g_clear_object (&priv->source_actions); | ||
3250 | 259 | 269 | ||
3251 | 260 | if (priv->name_watch_id) { | 270 | if (priv->name_watch_id) { |
3252 | 261 | g_bus_unwatch_name (priv->name_watch_id); | 271 | g_bus_unwatch_name (priv->name_watch_id); |
3253 | 262 | priv->name_watch_id = 0; | 272 | priv->name_watch_id = 0; |
3254 | 263 | } | 273 | } |
3255 | 264 | 274 | ||
3256 | 265 | if (priv->source_actions) { | ||
3257 | 266 | g_action_muxer_remove (priv->muxer, "source"); | ||
3258 | 267 | g_object_disconnect (priv->source_actions, | ||
3259 | 268 | "any_signal::action-added", action_added, self, | ||
3260 | 269 | "any_signal::action-state-changed", action_state_changed, self, | ||
3261 | 270 | "any_signal::action-removed", action_removed, self, | ||
3262 | 271 | NULL); | ||
3263 | 272 | g_clear_object (&priv->source_actions); | ||
3264 | 273 | } | ||
3265 | 274 | |||
3266 | 275 | g_clear_object (&priv->muxer); | 275 | g_clear_object (&priv->muxer); |
3267 | 276 | 276 | ||
3268 | 277 | g_clear_object (&priv->source_menu); | ||
3269 | 278 | g_clear_object (&priv->ids); | 277 | g_clear_object (&priv->ids); |
3270 | 279 | g_clear_object (&priv->appinfo); | 278 | g_clear_object (&priv->appinfo); |
3271 | 280 | 279 | ||
3272 | @@ -430,6 +429,11 @@ | |||
3273 | 430 | g_free(name); | 429 | g_free(name); |
3274 | 431 | } | 430 | } |
3275 | 432 | 431 | ||
3276 | 432 | item = g_menu_item_new_section (NULL, G_MENU_MODEL (priv->source_menu)); | ||
3277 | 433 | g_menu_item_set_attribute (item, "action-namespace", "s", "source"); | ||
3278 | 434 | g_menu_append_item (priv->menu, item); | ||
3279 | 435 | g_object_unref (item); | ||
3280 | 436 | |||
3281 | 433 | keyfile = g_file_new_for_path (g_desktop_app_info_get_filename (priv->appinfo)); | 437 | keyfile = g_file_new_for_path (g_desktop_app_info_get_filename (priv->appinfo)); |
3282 | 434 | g_file_load_contents_async (keyfile, NULL, keyfile_loaded, self); | 438 | g_file_load_contents_async (keyfile, NULL, keyfile_loaded, self); |
3283 | 435 | 439 | ||
3284 | @@ -571,39 +575,8 @@ | |||
3285 | 571 | void | 575 | void |
3286 | 572 | app_section_clear_draws_attention (AppSection *self) | 576 | app_section_clear_draws_attention (AppSection *self) |
3287 | 573 | { | 577 | { |
3321 | 574 | AppSectionPrivate * priv = self->priv; | 578 | self->priv->draws_attention = FALSE; |
3322 | 575 | gchar **action_names; | 579 | g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DRAWS_ATTENTION]); |
3290 | 576 | gchar **it; | ||
3291 | 577 | |||
3292 | 578 | if (priv->source_actions == NULL) | ||
3293 | 579 | return; | ||
3294 | 580 | |||
3295 | 581 | action_names = g_action_group_list_actions (priv->source_actions); | ||
3296 | 582 | |||
3297 | 583 | for (it = action_names; *it; it++) { | ||
3298 | 584 | GVariant *state; | ||
3299 | 585 | |||
3300 | 586 | state = g_action_group_get_action_state (priv->source_actions, *it); | ||
3301 | 587 | if (!state) | ||
3302 | 588 | continue; | ||
3303 | 589 | |||
3304 | 590 | /* clear draws-attention while preserving other state */ | ||
3305 | 591 | if (action_draws_attention (state)) { | ||
3306 | 592 | guint32 count; | ||
3307 | 593 | gint64 time; | ||
3308 | 594 | const gchar *str; | ||
3309 | 595 | GVariant *new_state; | ||
3310 | 596 | |||
3311 | 597 | g_variant_get (state, "(ux&sb)", &count, &time, &str, NULL); | ||
3312 | 598 | |||
3313 | 599 | new_state = g_variant_new ("(uxsb)", count, time, str, FALSE); | ||
3314 | 600 | g_action_group_change_action_state (priv->source_actions, *it, new_state); | ||
3315 | 601 | } | ||
3316 | 602 | |||
3317 | 603 | g_variant_unref (state); | ||
3318 | 604 | } | ||
3319 | 605 | |||
3320 | 606 | g_strfreev (action_names); | ||
3323 | 607 | } | 580 | } |
3324 | 608 | 581 | ||
3325 | 609 | static void | 582 | static void |
3326 | @@ -616,6 +589,230 @@ | |||
3327 | 616 | app_section_unset_object_path (self); | 589 | app_section_unset_object_path (self); |
3328 | 617 | } | 590 | } |
3329 | 618 | 591 | ||
3330 | 592 | static void | ||
3331 | 593 | update_draws_attention (AppSection *self) | ||
3332 | 594 | { | ||
3333 | 595 | AppSectionPrivate *priv = self->priv; | ||
3334 | 596 | gchar **actions; | ||
3335 | 597 | gchar **it; | ||
3336 | 598 | gboolean draws_attention = FALSE; | ||
3337 | 599 | |||
3338 | 600 | actions = g_action_group_list_actions (G_ACTION_GROUP (priv->source_actions)); | ||
3339 | 601 | |||
3340 | 602 | for (it = actions; *it; it++) { | ||
3341 | 603 | GVariant *state; | ||
3342 | 604 | |||
3343 | 605 | state = g_action_group_get_action_state (G_ACTION_GROUP (priv->source_actions), *it); | ||
3344 | 606 | if (state) { | ||
3345 | 607 | gboolean b; | ||
3346 | 608 | g_variant_get (state, "(uxsb)", NULL, NULL, NULL, &b); | ||
3347 | 609 | draws_attention = b || draws_attention; | ||
3348 | 610 | g_variant_unref (state); | ||
3349 | 611 | } | ||
3350 | 612 | |||
3351 | 613 | if (draws_attention) | ||
3352 | 614 | break; | ||
3353 | 615 | } | ||
3354 | 616 | |||
3355 | 617 | if (draws_attention != priv->draws_attention) { | ||
3356 | 618 | priv->draws_attention = draws_attention; | ||
3357 | 619 | g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DRAWS_ATTENTION]); | ||
3358 | 620 | } | ||
3359 | 621 | |||
3360 | 622 | g_strfreev (actions); | ||
3361 | 623 | } | ||
3362 | 624 | |||
3363 | 625 | static void | ||
3364 | 626 | remove_source (AppSection *self, | ||
3365 | 627 | const gchar *id) | ||
3366 | 628 | { | ||
3367 | 629 | AppSectionPrivate *priv = self->priv; | ||
3368 | 630 | guint n_items; | ||
3369 | 631 | guint i; | ||
3370 | 632 | |||
3371 | 633 | n_items = g_menu_model_get_n_items (G_MENU_MODEL (priv->source_menu)); | ||
3372 | 634 | for (i = 0; i < n_items; i++) { | ||
3373 | 635 | gchar *action; | ||
3374 | 636 | gboolean found = FALSE; | ||
3375 | 637 | |||
3376 | 638 | if (g_menu_model_get_item_attribute (G_MENU_MODEL (priv->source_menu), i, | ||
3377 | 639 | G_MENU_ATTRIBUTE_ACTION, "s", &action)) { | ||
3378 | 640 | found = g_str_equal (action, id); | ||
3379 | 641 | g_free (action); | ||
3380 | 642 | } | ||
3381 | 643 | |||
3382 | 644 | if (found) { | ||
3383 | 645 | g_menu_remove (priv->source_menu, i); | ||
3384 | 646 | break; | ||
3385 | 647 | } | ||
3386 | 648 | } | ||
3387 | 649 | |||
3388 | 650 | g_simple_action_group_remove (priv->source_actions, id); | ||
3389 | 651 | update_draws_attention (self); | ||
3390 | 652 | } | ||
3391 | 653 | |||
3392 | 654 | static void | ||
3393 | 655 | source_action_activated (GSimpleAction *action, | ||
3394 | 656 | GVariant *parameter, | ||
3395 | 657 | gpointer user_data) | ||
3396 | 658 | { | ||
3397 | 659 | AppSection *self = APP_SECTION (user_data); | ||
3398 | 660 | AppSectionPrivate *priv = APP_SECTION (user_data)->priv; | ||
3399 | 661 | |||
3400 | 662 | g_return_if_fail (priv->app_proxy != NULL); | ||
3401 | 663 | |||
3402 | 664 | indicator_messages_application_call_activate_source (priv->app_proxy, | ||
3403 | 665 | g_action_get_name (G_ACTION (action)), | ||
3404 | 666 | priv->app_proxy_cancellable, | ||
3405 | 667 | NULL, NULL); | ||
3406 | 668 | |||
3407 | 669 | remove_source (self, g_action_get_name (G_ACTION (action))); | ||
3408 | 670 | } | ||
3409 | 671 | |||
3410 | 672 | static void | ||
3411 | 673 | sources_listed (GObject *source_object, | ||
3412 | 674 | GAsyncResult *result, | ||
3413 | 675 | gpointer user_data) | ||
3414 | 676 | { | ||
3415 | 677 | AppSection *self = user_data; | ||
3416 | 678 | AppSectionPrivate *priv = self->priv; | ||
3417 | 679 | GVariant *sources = NULL; | ||
3418 | 680 | GError *error = NULL; | ||
3419 | 681 | GVariantIter iter; | ||
3420 | 682 | const gchar *id; | ||
3421 | 683 | const gchar *label; | ||
3422 | 684 | const gchar *iconstr; | ||
3423 | 685 | guint32 count; | ||
3424 | 686 | gint64 time; | ||
3425 | 687 | const gchar *string; | ||
3426 | 688 | gboolean draws_attention; | ||
3427 | 689 | |||
3428 | 690 | if (!indicator_messages_application_call_list_sources_finish (INDICATOR_MESSAGES_APPLICATION (source_object), | ||
3429 | 691 | &sources, result, &error)) | ||
3430 | 692 | { | ||
3431 | 693 | g_warning ("could not fetch the list of sources: %s", error->message); | ||
3432 | 694 | g_error_free (error); | ||
3433 | 695 | return; | ||
3434 | 696 | } | ||
3435 | 697 | |||
3436 | 698 | g_menu_clear (priv->source_menu); | ||
3437 | 699 | g_simple_action_group_clear (priv->source_actions); | ||
3438 | 700 | priv->draws_attention = FALSE; | ||
3439 | 701 | |||
3440 | 702 | g_variant_iter_init (&iter, sources); | ||
3441 | 703 | while (g_variant_iter_next (&iter, "(&s&s&sux&sb)", &id, &label, &iconstr, | ||
3442 | 704 | &count, &time, &string, &draws_attention)) | ||
3443 | 705 | { | ||
3444 | 706 | GVariant *state; | ||
3445 | 707 | GSimpleAction *action; | ||
3446 | 708 | GMenuItem *item; | ||
3447 | 709 | |||
3448 | 710 | state = g_variant_new ("(uxsb)", count, time, string, draws_attention); | ||
3449 | 711 | action = g_simple_action_new_stateful (id, NULL, state); | ||
3450 | 712 | g_signal_connect (action, "activate", G_CALLBACK (source_action_activated), self); | ||
3451 | 713 | g_simple_action_group_insert (priv->source_actions, G_ACTION (action)); | ||
3452 | 714 | |||
3453 | 715 | item = g_menu_item_new (label, id); | ||
3454 | 716 | g_menu_item_set_attribute (item, "x-canonical-type", "s", "ImSourceMenuItem"); | ||
3455 | 717 | g_menu_append_item (priv->source_menu, item); | ||
3456 | 718 | |||
3457 | 719 | priv->draws_attention = priv->draws_attention || draws_attention; | ||
3458 | 720 | |||
3459 | 721 | g_object_unref (item); | ||
3460 | 722 | g_object_unref (action); | ||
3461 | 723 | } | ||
3462 | 724 | |||
3463 | 725 | g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DRAWS_ATTENTION]); | ||
3464 | 726 | |||
3465 | 727 | g_variant_unref (sources); | ||
3466 | 728 | } | ||
3467 | 729 | |||
3468 | 730 | static void | ||
3469 | 731 | source_added (IndicatorMessagesApplication *app, | ||
3470 | 732 | const gchar *id, | ||
3471 | 733 | const gchar *label, | ||
3472 | 734 | const gchar *iconstr, | ||
3473 | 735 | guint count, | ||
3474 | 736 | gint64 time, | ||
3475 | 737 | const gchar *string, | ||
3476 | 738 | gboolean draws_attention, | ||
3477 | 739 | gpointer user_data) | ||
3478 | 740 | { | ||
3479 | 741 | AppSection *self = user_data; | ||
3480 | 742 | AppSectionPrivate *priv = self->priv; | ||
3481 | 743 | GVariant *state; | ||
3482 | 744 | GSimpleAction *action; | ||
3483 | 745 | |||
3484 | 746 | /* TODO put label and icon into the action as well */ | ||
3485 | 747 | |||
3486 | 748 | state = g_variant_new ("(uxsb)", count, time, string, draws_attention); | ||
3487 | 749 | action = g_simple_action_new_stateful (id, NULL, state); | ||
3488 | 750 | |||
3489 | 751 | g_simple_action_group_insert (priv->source_actions, G_ACTION (action)); | ||
3490 | 752 | |||
3491 | 753 | if (draws_attention && !priv->draws_attention) { | ||
3492 | 754 | priv->draws_attention = TRUE; | ||
3493 | 755 | g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DRAWS_ATTENTION]); | ||
3494 | 756 | } | ||
3495 | 757 | |||
3496 | 758 | g_object_unref (action); | ||
3497 | 759 | } | ||
3498 | 760 | static void | ||
3499 | 761 | source_changed (IndicatorMessagesApplication *app, | ||
3500 | 762 | const gchar *id, | ||
3501 | 763 | const gchar *label, | ||
3502 | 764 | const gchar *iconstr, | ||
3503 | 765 | guint count, | ||
3504 | 766 | gint64 time, | ||
3505 | 767 | const gchar *string, | ||
3506 | 768 | gboolean draws_attention, | ||
3507 | 769 | gpointer user_data) | ||
3508 | 770 | { | ||
3509 | 771 | AppSection *self = user_data; | ||
3510 | 772 | AppSectionPrivate *priv = self->priv; | ||
3511 | 773 | GVariant *state; | ||
3512 | 774 | |||
3513 | 775 | /* TODO put label and icon into the action as well */ | ||
3514 | 776 | |||
3515 | 777 | state = g_variant_new ("(uxsb)", count, time, string, draws_attention); | ||
3516 | 778 | g_action_group_change_action_state (G_ACTION_GROUP (priv->source_actions), id, state); | ||
3517 | 779 | |||
3518 | 780 | update_draws_attention (self); | ||
3519 | 781 | } | ||
3520 | 782 | |||
3521 | 783 | static void | ||
3522 | 784 | source_removed (IndicatorMessagesApplication *app, | ||
3523 | 785 | const gchar *id, | ||
3524 | 786 | gpointer user_data) | ||
3525 | 787 | { | ||
3526 | 788 | AppSection *self = user_data; | ||
3527 | 789 | |||
3528 | 790 | remove_source (self, id); | ||
3529 | 791 | } | ||
3530 | 792 | |||
3531 | 793 | static void | ||
3532 | 794 | app_proxy_created (GObject *source_object, | ||
3533 | 795 | GAsyncResult *result, | ||
3534 | 796 | gpointer user_data) | ||
3535 | 797 | { | ||
3536 | 798 | AppSectionPrivate *priv = APP_SECTION (user_data)->priv; | ||
3537 | 799 | GError *error = NULL; | ||
3538 | 800 | |||
3539 | 801 | priv->app_proxy = indicator_messages_application_proxy_new_finish (result, &error); | ||
3540 | 802 | if (!priv->app_proxy) { | ||
3541 | 803 | g_warning ("could not create application proxy: %s", error->message); | ||
3542 | 804 | g_error_free (error); | ||
3543 | 805 | return; | ||
3544 | 806 | } | ||
3545 | 807 | |||
3546 | 808 | indicator_messages_application_call_list_sources (priv->app_proxy, priv->app_proxy_cancellable, | ||
3547 | 809 | sources_listed, user_data); | ||
3548 | 810 | |||
3549 | 811 | g_signal_connect (priv->app_proxy, "source-added", G_CALLBACK (source_added), user_data); | ||
3550 | 812 | g_signal_connect (priv->app_proxy, "source-changed", G_CALLBACK (source_changed), user_data); | ||
3551 | 813 | g_signal_connect (priv->app_proxy, "source-removed", G_CALLBACK (source_removed), user_data); | ||
3552 | 814 | } | ||
3553 | 815 | |||
3554 | 619 | /* | 816 | /* |
3555 | 620 | * app_section_set_object_path: | 817 | * app_section_set_object_path: |
3556 | 621 | * @self: an #AppSection | 818 | * @self: an #AppSection |
3557 | @@ -634,27 +831,20 @@ | |||
3558 | 634 | const gchar *object_path) | 831 | const gchar *object_path) |
3559 | 635 | { | 832 | { |
3560 | 636 | AppSectionPrivate *priv = self->priv; | 833 | AppSectionPrivate *priv = self->priv; |
3561 | 637 | GMenuItem *item; | ||
3562 | 638 | 834 | ||
3563 | 639 | g_object_freeze_notify (G_OBJECT (self)); | 835 | g_object_freeze_notify (G_OBJECT (self)); |
3564 | 640 | app_section_unset_object_path (self); | 836 | app_section_unset_object_path (self); |
3565 | 641 | 837 | ||
3582 | 642 | priv->source_actions = G_ACTION_GROUP (g_dbus_action_group_get (bus, bus_name, object_path)); | 838 | priv->app_proxy_cancellable = g_cancellable_new (); |
3583 | 643 | g_action_muxer_insert (priv->muxer, "source", priv->source_actions); | 839 | indicator_messages_application_proxy_new (bus, |
3584 | 644 | 840 | G_DBUS_PROXY_FLAGS_NONE, | |
3585 | 645 | priv->draws_attention = any_action_draws_attention (priv->source_actions, NULL); | 841 | bus_name, |
3586 | 646 | g_object_connect (priv->source_actions, | 842 | object_path, |
3587 | 647 | "signal::action-added", action_added, self, | 843 | priv->app_proxy_cancellable, |
3588 | 648 | "signal::action-state-changed", action_state_changed, self, | 844 | app_proxy_created, |
3589 | 649 | "signal::action-removed", action_removed, self, | 845 | self); |
3590 | 650 | NULL); | 846 | |
3591 | 651 | 847 | priv->draws_attention = FALSE; | |
3576 | 652 | priv->source_menu = G_MENU_MODEL (g_dbus_menu_model_get (bus, bus_name, object_path)); | ||
3577 | 653 | |||
3578 | 654 | item = g_menu_item_new_section (NULL, priv->source_menu); | ||
3579 | 655 | g_menu_item_set_attribute (item, "action-namespace", "s", "source"); | ||
3580 | 656 | g_menu_append_item (priv->menu, item); | ||
3581 | 657 | g_object_unref (item); | ||
3592 | 658 | 848 | ||
3593 | 659 | priv->name_watch_id = g_bus_watch_name_on_connection (bus, bus_name, 0, | 849 | priv->name_watch_id = g_bus_watch_name_on_connection (bus, bus_name, 0, |
3594 | 660 | NULL, application_vanished, | 850 | NULL, application_vanished, |
3595 | @@ -682,26 +872,19 @@ | |||
3596 | 682 | { | 872 | { |
3597 | 683 | AppSectionPrivate *priv = self->priv; | 873 | AppSectionPrivate *priv = self->priv; |
3598 | 684 | 874 | ||
3599 | 875 | if (priv->app_proxy_cancellable) { | ||
3600 | 876 | g_cancellable_cancel (priv->app_proxy_cancellable); | ||
3601 | 877 | g_clear_object (&priv->app_proxy_cancellable); | ||
3602 | 878 | } | ||
3603 | 879 | g_clear_object (&priv->app_proxy); | ||
3604 | 880 | |||
3605 | 685 | if (priv->name_watch_id) { | 881 | if (priv->name_watch_id) { |
3606 | 686 | g_bus_unwatch_name (priv->name_watch_id); | 882 | g_bus_unwatch_name (priv->name_watch_id); |
3607 | 687 | priv->name_watch_id = 0; | 883 | priv->name_watch_id = 0; |
3608 | 688 | } | 884 | } |
3609 | 689 | 885 | ||
3625 | 690 | if (priv->source_actions) { | 886 | g_simple_action_group_clear (priv->source_actions); |
3626 | 691 | g_object_disconnect (priv->source_actions, | 887 | g_menu_clear (priv->source_menu); |
3612 | 692 | "any_signal::action-added", action_added, self, | ||
3613 | 693 | "any_signal::action-state-changed", action_state_changed, self, | ||
3614 | 694 | "any_signal::action-removed", action_removed, self, | ||
3615 | 695 | NULL); | ||
3616 | 696 | g_clear_object (&priv->source_actions); | ||
3617 | 697 | } | ||
3618 | 698 | |||
3619 | 699 | if (priv->source_menu) { | ||
3620 | 700 | /* the last menu item points is linked to the app's menumodel */ | ||
3621 | 701 | gint n_items = g_menu_model_get_n_items (G_MENU_MODEL (priv->menu)); | ||
3622 | 702 | g_menu_remove (priv->menu, n_items -1); | ||
3623 | 703 | g_clear_object (&priv->source_menu); | ||
3624 | 704 | } | ||
3627 | 705 | 888 | ||
3628 | 706 | priv->draws_attention = FALSE; | 889 | priv->draws_attention = FALSE; |
3629 | 707 | g_clear_pointer (&priv->chat_status, g_free); | 890 | g_clear_pointer (&priv->chat_status, g_free); |
3630 | @@ -715,85 +898,6 @@ | |||
3631 | 715 | "launch", g_variant_new_boolean (FALSE)); | 898 | "launch", g_variant_new_boolean (FALSE)); |
3632 | 716 | } | 899 | } |
3633 | 717 | 900 | ||
3634 | 718 | static gboolean | ||
3635 | 719 | action_draws_attention (GVariant *state) | ||
3636 | 720 | { | ||
3637 | 721 | gboolean attention; | ||
3638 | 722 | |||
3639 | 723 | if (state && g_variant_is_of_type (state, G_VARIANT_TYPE ("(uxsb)"))) | ||
3640 | 724 | g_variant_get_child (state, 3, "b", &attention); | ||
3641 | 725 | else | ||
3642 | 726 | attention = FALSE; | ||
3643 | 727 | |||
3644 | 728 | return attention; | ||
3645 | 729 | } | ||
3646 | 730 | |||
3647 | 731 | static gboolean | ||
3648 | 732 | any_action_draws_attention (GActionGroup *group, | ||
3649 | 733 | const gchar *ignored_action) | ||
3650 | 734 | { | ||
3651 | 735 | gchar **actions; | ||
3652 | 736 | gchar **it; | ||
3653 | 737 | gboolean attention = FALSE; | ||
3654 | 738 | |||
3655 | 739 | actions = g_action_group_list_actions (group); | ||
3656 | 740 | |||
3657 | 741 | for (it = actions; *it && !attention; it++) { | ||
3658 | 742 | GVariant *state; | ||
3659 | 743 | |||
3660 | 744 | if (ignored_action && g_str_equal (ignored_action, *it)) | ||
3661 | 745 | continue; | ||
3662 | 746 | |||
3663 | 747 | state = g_action_group_get_action_state (group, *it); | ||
3664 | 748 | if (state) { | ||
3665 | 749 | attention = action_draws_attention (state); | ||
3666 | 750 | g_variant_unref (state); | ||
3667 | 751 | } | ||
3668 | 752 | } | ||
3669 | 753 | |||
3670 | 754 | g_strfreev (actions); | ||
3671 | 755 | return attention; | ||
3672 | 756 | } | ||
3673 | 757 | |||
3674 | 758 | static void | ||
3675 | 759 | action_added (GActionGroup *group, | ||
3676 | 760 | const gchar *action_name, | ||
3677 | 761 | gpointer user_data) | ||
3678 | 762 | { | ||
3679 | 763 | AppSection *self = user_data; | ||
3680 | 764 | GVariant *state; | ||
3681 | 765 | |||
3682 | 766 | state = g_action_group_get_action_state (group, action_name); | ||
3683 | 767 | if (state) { | ||
3684 | 768 | self->priv->draws_attention |= action_draws_attention (state); | ||
3685 | 769 | g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DRAWS_ATTENTION]); | ||
3686 | 770 | g_variant_unref (state); | ||
3687 | 771 | } | ||
3688 | 772 | } | ||
3689 | 773 | |||
3690 | 774 | static void | ||
3691 | 775 | action_state_changed (GActionGroup *group, | ||
3692 | 776 | const gchar *action_name, | ||
3693 | 777 | GVariant *value, | ||
3694 | 778 | gpointer user_data) | ||
3695 | 779 | { | ||
3696 | 780 | AppSection *self = user_data; | ||
3697 | 781 | |||
3698 | 782 | self->priv->draws_attention = any_action_draws_attention (group, NULL); | ||
3699 | 783 | g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DRAWS_ATTENTION]); | ||
3700 | 784 | } | ||
3701 | 785 | |||
3702 | 786 | static void | ||
3703 | 787 | action_removed (GActionGroup *group, | ||
3704 | 788 | const gchar *action_name, | ||
3705 | 789 | gpointer user_data) | ||
3706 | 790 | { | ||
3707 | 791 | AppSection *self = user_data; | ||
3708 | 792 | |||
3709 | 793 | self->priv->draws_attention = any_action_draws_attention (group, action_name); | ||
3710 | 794 | g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DRAWS_ATTENTION]); | ||
3711 | 795 | } | ||
3712 | 796 | |||
3713 | 797 | gboolean | 901 | gboolean |
3714 | 798 | app_section_get_uses_chat_status (AppSection *self) | 902 | app_section_get_uses_chat_status (AppSection *self) |
3715 | 799 | { | 903 | { |
3716 | 800 | 904 | ||
3717 | === modified file 'src/dbus-data.h' | |||
3718 | --- src/dbus-data.h 2012-08-21 09:40:47 +0000 | |||
3719 | +++ src/dbus-data.h 2013-04-26 16:57:25 +0000 | |||
3720 | @@ -1,9 +1,24 @@ | |||
3721 | 1 | /* | ||
3722 | 2 | * Copyright 2012-2013 Canonical Ltd. | ||
3723 | 3 | * | ||
3724 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
3725 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
3726 | 6 | * by the Free Software Foundation. | ||
3727 | 7 | * | ||
3728 | 8 | * This program is distributed in the hope that it will be useful, but | ||
3729 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
3730 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
3731 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
3732 | 12 | * | ||
3733 | 13 | * You should have received a copy of the GNU General Public License along | ||
3734 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3735 | 15 | */ | ||
3736 | 1 | 16 | ||
3737 | 2 | #ifndef __DBUS_DATA_H__ | 17 | #ifndef __DBUS_DATA_H__ |
3738 | 3 | #define __DBUS_DATA_H__ 1 | 18 | #define __DBUS_DATA_H__ 1 |
3739 | 4 | 19 | ||
3740 | 5 | #define INDICATOR_MESSAGES_DBUS_NAME "com.canonical.indicator.messages" | 20 | #define INDICATOR_MESSAGES_DBUS_NAME "com.canonical.indicator.messages" |
3742 | 6 | #define INDICATOR_MESSAGES_DBUS_OBJECT "/com/canonical/indicator/messages/menu" | 21 | #define INDICATOR_MESSAGES_DBUS_OBJECT "/com/canonical/indicator/messages" |
3743 | 7 | 22 | ||
3744 | 8 | #define INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT "/com/canonical/indicator/messages/service" | 23 | #define INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT "/com/canonical/indicator/messages/service" |
3745 | 9 | #define INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE "com.canonical.indicator.messages.service" | 24 | #define INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE "com.canonical.indicator.messages.service" |
3746 | 10 | 25 | ||
3747 | === modified file 'src/gactionmuxer.c' | |||
3748 | --- src/gactionmuxer.c 2012-06-04 21:43:56 +0000 | |||
3749 | +++ src/gactionmuxer.c 2013-04-26 16:57:25 +0000 | |||
3750 | @@ -483,3 +483,11 @@ | |||
3751 | 483 | g_clear_object (&muxer->global_actions); | 483 | g_clear_object (&muxer->global_actions); |
3752 | 484 | } | 484 | } |
3753 | 485 | 485 | ||
3754 | 486 | GActionGroup * | ||
3755 | 487 | g_action_muxer_get_group (GActionMuxer *muxer, | ||
3756 | 488 | const gchar *prefix) | ||
3757 | 489 | { | ||
3758 | 490 | g_return_val_if_fail (G_IS_ACTION_MUXER (muxer), NULL); | ||
3759 | 491 | |||
3760 | 492 | return prefix ? g_hash_table_lookup (muxer->groups, prefix) : muxer->global_actions; | ||
3761 | 493 | } | ||
3762 | 486 | 494 | ||
3763 | === modified file 'src/gactionmuxer.h' | |||
3764 | --- src/gactionmuxer.h 2012-06-03 06:33:31 +0000 | |||
3765 | +++ src/gactionmuxer.h 2013-04-26 16:57:25 +0000 | |||
3766 | @@ -40,5 +40,8 @@ | |||
3767 | 40 | void g_action_muxer_remove (GActionMuxer *muxer, | 40 | void g_action_muxer_remove (GActionMuxer *muxer, |
3768 | 41 | const gchar *prefix); | 41 | const gchar *prefix); |
3769 | 42 | 42 | ||
3770 | 43 | GActionGroup * g_action_muxer_get_group (GActionMuxer *muxer, | ||
3771 | 44 | const gchar *prefix); | ||
3772 | 45 | |||
3773 | 43 | #endif | 46 | #endif |
3774 | 44 | 47 | ||
3775 | 45 | 48 | ||
3776 | === added file 'src/im-application-list.c' | |||
3777 | --- src/im-application-list.c 1970-01-01 00:00:00 +0000 | |||
3778 | +++ src/im-application-list.c 2013-04-26 16:57:25 +0000 | |||
3779 | @@ -0,0 +1,880 @@ | |||
3780 | 1 | /* | ||
3781 | 2 | * Copyright 2012 Canonical Ltd. | ||
3782 | 3 | * | ||
3783 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
3784 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
3785 | 6 | * by the Free Software Foundation. | ||
3786 | 7 | * | ||
3787 | 8 | * This program is distributed in the hope that it will be useful, but | ||
3788 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
3789 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
3790 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
3791 | 12 | * | ||
3792 | 13 | * You should have received a copy of the GNU General Public License along | ||
3793 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3794 | 15 | * | ||
3795 | 16 | * Authors: | ||
3796 | 17 | * Lars Uebernickel <lars.uebernickel@canonical.com> | ||
3797 | 18 | */ | ||
3798 | 19 | |||
3799 | 20 | #include "im-application-list.h" | ||
3800 | 21 | |||
3801 | 22 | #include "indicator-messages-application.h" | ||
3802 | 23 | #include "gactionmuxer.h" | ||
3803 | 24 | |||
3804 | 25 | #include <gio/gdesktopappinfo.h> | ||
3805 | 26 | #include <string.h> | ||
3806 | 27 | |||
3807 | 28 | typedef GObjectClass ImApplicationListClass; | ||
3808 | 29 | |||
3809 | 30 | struct _ImApplicationList | ||
3810 | 31 | { | ||
3811 | 32 | GObject parent; | ||
3812 | 33 | |||
3813 | 34 | GHashTable *applications; | ||
3814 | 35 | GActionMuxer *muxer; | ||
3815 | 36 | }; | ||
3816 | 37 | |||
3817 | 38 | G_DEFINE_TYPE (ImApplicationList, im_application_list, G_TYPE_OBJECT); | ||
3818 | 39 | |||
3819 | 40 | enum | ||
3820 | 41 | { | ||
3821 | 42 | SOURCE_ADDED, | ||
3822 | 43 | SOURCE_CHANGED, | ||
3823 | 44 | SOURCE_REMOVED, | ||
3824 | 45 | MESSAGE_ADDED, | ||
3825 | 46 | MESSAGE_REMOVED, | ||
3826 | 47 | APP_STOPPED, | ||
3827 | 48 | REMOVE_ALL, | ||
3828 | 49 | N_SIGNALS | ||
3829 | 50 | }; | ||
3830 | 51 | |||
3831 | 52 | static guint signals[N_SIGNALS]; | ||
3832 | 53 | |||
3833 | 54 | typedef struct | ||
3834 | 55 | { | ||
3835 | 56 | ImApplicationList *list; | ||
3836 | 57 | GDesktopAppInfo *info; | ||
3837 | 58 | gchar *id; | ||
3838 | 59 | IndicatorMessagesApplication *proxy; | ||
3839 | 60 | GActionMuxer *actions; | ||
3840 | 61 | GSimpleActionGroup *source_actions; | ||
3841 | 62 | GSimpleActionGroup *message_actions; | ||
3842 | 63 | GActionMuxer *message_sub_actions; | ||
3843 | 64 | GCancellable *cancellable; | ||
3844 | 65 | } Application; | ||
3845 | 66 | |||
3846 | 67 | static void | ||
3847 | 68 | application_free (gpointer data) | ||
3848 | 69 | { | ||
3849 | 70 | Application *app = data; | ||
3850 | 71 | |||
3851 | 72 | if (!app) | ||
3852 | 73 | return; | ||
3853 | 74 | |||
3854 | 75 | g_object_unref (app->info); | ||
3855 | 76 | g_free (app->id); | ||
3856 | 77 | |||
3857 | 78 | if (app->cancellable) | ||
3858 | 79 | { | ||
3859 | 80 | g_cancellable_cancel (app->cancellable); | ||
3860 | 81 | g_clear_object (&app->cancellable); | ||
3861 | 82 | } | ||
3862 | 83 | |||
3863 | 84 | if (app->proxy) | ||
3864 | 85 | g_object_unref (app->proxy); | ||
3865 | 86 | |||
3866 | 87 | if (app->actions) | ||
3867 | 88 | { | ||
3868 | 89 | g_object_unref (app->actions); | ||
3869 | 90 | g_object_unref (app->source_actions); | ||
3870 | 91 | g_object_unref (app->message_actions); | ||
3871 | 92 | g_object_unref (app->message_sub_actions); | ||
3872 | 93 | } | ||
3873 | 94 | |||
3874 | 95 | g_slice_free (Application, app); | ||
3875 | 96 | } | ||
3876 | 97 | |||
3877 | 98 | static void | ||
3878 | 99 | im_application_list_source_removed (Application *app, | ||
3879 | 100 | const gchar *id) | ||
3880 | 101 | { | ||
3881 | 102 | g_simple_action_group_remove (app->source_actions, id); | ||
3882 | 103 | |||
3883 | 104 | g_signal_emit (app->list, signals[SOURCE_REMOVED], 0, app->id, id); | ||
3884 | 105 | } | ||
3885 | 106 | |||
3886 | 107 | static void | ||
3887 | 108 | im_application_list_source_activated (GSimpleAction *action, | ||
3888 | 109 | GVariant *parameter, | ||
3889 | 110 | gpointer user_data) | ||
3890 | 111 | { | ||
3891 | 112 | Application *app = user_data; | ||
3892 | 113 | const gchar *source_id; | ||
3893 | 114 | |||
3894 | 115 | source_id = g_action_get_name (G_ACTION (action)); | ||
3895 | 116 | |||
3896 | 117 | if (g_variant_get_boolean (parameter)) | ||
3897 | 118 | { | ||
3898 | 119 | indicator_messages_application_call_activate_source (app->proxy, | ||
3899 | 120 | source_id, | ||
3900 | 121 | app->cancellable, | ||
3901 | 122 | NULL, NULL); | ||
3902 | 123 | } | ||
3903 | 124 | else | ||
3904 | 125 | { | ||
3905 | 126 | const gchar *sources[] = { source_id, NULL }; | ||
3906 | 127 | const gchar *messages[] = { NULL }; | ||
3907 | 128 | indicator_messages_application_call_dismiss (app->proxy, sources, messages, | ||
3908 | 129 | app->cancellable, NULL, NULL); | ||
3909 | 130 | } | ||
3910 | 131 | |||
3911 | 132 | im_application_list_source_removed (app, source_id); | ||
3912 | 133 | } | ||
3913 | 134 | |||
3914 | 135 | static guint | ||
3915 | 136 | g_action_group_get_n_actions (GActionGroup *group) | ||
3916 | 137 | { | ||
3917 | 138 | guint len; | ||
3918 | 139 | gchar **actions; | ||
3919 | 140 | |||
3920 | 141 | actions = g_action_group_list_actions (group); | ||
3921 | 142 | len = g_strv_length (actions); | ||
3922 | 143 | |||
3923 | 144 | g_strfreev (actions); | ||
3924 | 145 | return len; | ||
3925 | 146 | } | ||
3926 | 147 | |||
3927 | 148 | static gboolean | ||
3928 | 149 | application_draws_attention (gpointer key, | ||
3929 | 150 | gpointer value, | ||
3930 | 151 | gpointer user_data) | ||
3931 | 152 | { | ||
3932 | 153 | Application *app = value; | ||
3933 | 154 | |||
3934 | 155 | return (g_action_group_get_n_actions (G_ACTION_GROUP (app->source_actions)) + | ||
3935 | 156 | g_action_group_get_n_actions (G_ACTION_GROUP (app->message_actions))) > 0; | ||
3936 | 157 | } | ||
3937 | 158 | |||
3938 | 159 | static void | ||
3939 | 160 | im_application_list_update_draws_attention (ImApplicationList *list) | ||
3940 | 161 | { | ||
3941 | 162 | const gchar *icon_name; | ||
3942 | 163 | GVariant *state; | ||
3943 | 164 | GActionGroup *main_actions; | ||
3944 | 165 | |||
3945 | 166 | if (g_hash_table_find (list->applications, application_draws_attention, NULL)) | ||
3946 | 167 | icon_name = "indicator-messages-new"; | ||
3947 | 168 | else | ||
3948 | 169 | icon_name = "indicator-messages"; | ||
3949 | 170 | |||
3950 | 171 | main_actions = g_action_muxer_get_group (list->muxer, NULL); | ||
3951 | 172 | state = g_variant_new ("(sssb)", "", icon_name, "Messages", TRUE); | ||
3952 | 173 | g_action_group_change_action_state (main_actions, "messages", state); | ||
3953 | 174 | } | ||
3954 | 175 | |||
3955 | 176 | static void | ||
3956 | 177 | im_application_list_message_removed (Application *app, | ||
3957 | 178 | const gchar *id) | ||
3958 | 179 | { | ||
3959 | 180 | g_simple_action_group_remove (app->message_actions, id); | ||
3960 | 181 | g_action_muxer_remove (app->message_sub_actions, id); | ||
3961 | 182 | |||
3962 | 183 | im_application_list_update_draws_attention (app->list); | ||
3963 | 184 | |||
3964 | 185 | g_signal_emit (app->list, signals[MESSAGE_REMOVED], 0, app->id, id); | ||
3965 | 186 | } | ||
3966 | 187 | |||
3967 | 188 | static void | ||
3968 | 189 | im_application_list_message_activated (GSimpleAction *action, | ||
3969 | 190 | GVariant *parameter, | ||
3970 | 191 | gpointer user_data) | ||
3971 | 192 | { | ||
3972 | 193 | Application *app = user_data; | ||
3973 | 194 | const gchar *message_id; | ||
3974 | 195 | |||
3975 | 196 | message_id = g_action_get_name (G_ACTION (action)); | ||
3976 | 197 | |||
3977 | 198 | if (g_variant_get_boolean (parameter)) | ||
3978 | 199 | { | ||
3979 | 200 | indicator_messages_application_call_activate_message (app->proxy, | ||
3980 | 201 | message_id, | ||
3981 | 202 | "", | ||
3982 | 203 | g_variant_new_array (G_VARIANT_TYPE_VARIANT, NULL, 0), | ||
3983 | 204 | app->cancellable, | ||
3984 | 205 | NULL, NULL); | ||
3985 | 206 | } | ||
3986 | 207 | else | ||
3987 | 208 | { | ||
3988 | 209 | const gchar *sources[] = { NULL }; | ||
3989 | 210 | const gchar *messages[] = { message_id, NULL }; | ||
3990 | 211 | indicator_messages_application_call_dismiss (app->proxy, sources, messages, | ||
3991 | 212 | app->cancellable, NULL, NULL); | ||
3992 | 213 | } | ||
3993 | 214 | |||
3994 | 215 | im_application_list_message_removed (app, message_id); | ||
3995 | 216 | } | ||
3996 | 217 | |||
3997 | 218 | static void | ||
3998 | 219 | im_application_list_sub_message_activated (GSimpleAction *action, | ||
3999 | 220 | GVariant *parameter, | ||
4000 | 221 | gpointer user_data) | ||
4001 | 222 | { | ||
4002 | 223 | Application *app = user_data; | ||
4003 | 224 | const gchar *message_id; | ||
4004 | 225 | const gchar *action_id; | ||
4005 | 226 | GVariantBuilder builder; | ||
4006 | 227 | |||
4007 | 228 | message_id = g_object_get_data (G_OBJECT (action), "message"); | ||
4008 | 229 | action_id = g_action_get_name (G_ACTION (action)); | ||
4009 | 230 | |||
4010 | 231 | g_variant_builder_init (&builder, G_VARIANT_TYPE ("av")); | ||
4011 | 232 | if (parameter) | ||
4012 | 233 | g_variant_builder_add (&builder, "v", parameter); | ||
4013 | 234 | |||
4014 | 235 | indicator_messages_application_call_activate_message (app->proxy, | ||
4015 | 236 | message_id, | ||
4016 | 237 | action_id, | ||
4017 | 238 | g_variant_builder_end (&builder), | ||
4018 | 239 | app->cancellable, | ||
4019 | 240 | NULL, NULL); | ||
4020 | 241 | |||
4021 | 242 | im_application_list_message_removed (app, message_id); | ||
4022 | 243 | } | ||
4023 | 244 | |||
4024 | 245 | |||
4025 | 246 | static void | ||
4026 | 247 | im_application_list_remove_all (GSimpleAction *action, | ||
4027 | 248 | GVariant *parameter, | ||
4028 | 249 | gpointer user_data) | ||
4029 | 250 | { | ||
4030 | 251 | ImApplicationList *list = user_data; | ||
4031 | 252 | GHashTableIter iter; | ||
4032 | 253 | Application *app; | ||
4033 | 254 | |||
4034 | 255 | g_signal_emit (list, signals[REMOVE_ALL], 0); | ||
4035 | 256 | |||
4036 | 257 | g_hash_table_iter_init (&iter, list->applications); | ||
4037 | 258 | while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &app)) | ||
4038 | 259 | { | ||
4039 | 260 | gchar **source_actions; | ||
4040 | 261 | gchar **message_actions; | ||
4041 | 262 | gchar **it; | ||
4042 | 263 | |||
4043 | 264 | source_actions = g_action_group_list_actions (G_ACTION_GROUP (app->source_actions)); | ||
4044 | 265 | for (it = source_actions; *it; it++) | ||
4045 | 266 | im_application_list_source_removed (app, *it); | ||
4046 | 267 | |||
4047 | 268 | message_actions = g_action_group_list_actions (G_ACTION_GROUP (app->message_actions)); | ||
4048 | 269 | for (it = message_actions; *it; it++) | ||
4049 | 270 | im_application_list_message_removed (app, *it); | ||
4050 | 271 | |||
4051 | 272 | indicator_messages_application_call_dismiss (app->proxy, | ||
4052 | 273 | (const gchar * const *) source_actions, | ||
4053 | 274 | (const gchar * const *) message_actions, | ||
4054 | 275 | app->cancellable, NULL, NULL); | ||
4055 | 276 | |||
4056 | 277 | g_strfreev (source_actions); | ||
4057 | 278 | g_strfreev (message_actions); | ||
4058 | 279 | } | ||
4059 | 280 | } | ||
4060 | 281 | |||
4061 | 282 | static void | ||
4062 | 283 | im_application_list_dispose (GObject *object) | ||
4063 | 284 | { | ||
4064 | 285 | ImApplicationList *list = IM_APPLICATION_LIST (object); | ||
4065 | 286 | |||
4066 | 287 | g_clear_pointer (&list->applications, g_hash_table_unref); | ||
4067 | 288 | g_clear_object (&list->muxer); | ||
4068 | 289 | |||
4069 | 290 | G_OBJECT_CLASS (im_application_list_parent_class)->dispose (object); | ||
4070 | 291 | } | ||
4071 | 292 | |||
4072 | 293 | static void | ||
4073 | 294 | im_application_list_finalize (GObject *object) | ||
4074 | 295 | { | ||
4075 | 296 | G_OBJECT_CLASS (im_application_list_parent_class)->finalize (object); | ||
4076 | 297 | } | ||
4077 | 298 | |||
4078 | 299 | static void | ||
4079 | 300 | im_application_list_class_init (ImApplicationListClass *klass) | ||
4080 | 301 | { | ||
4081 | 302 | GObjectClass *object_class = G_OBJECT_CLASS (klass); | ||
4082 | 303 | |||
4083 | 304 | object_class->dispose = im_application_list_dispose; | ||
4084 | 305 | object_class->finalize = im_application_list_finalize; | ||
4085 | 306 | |||
4086 | 307 | signals[SOURCE_ADDED] = g_signal_new ("source-added", | ||
4087 | 308 | IM_TYPE_APPLICATION_LIST, | ||
4088 | 309 | G_SIGNAL_RUN_FIRST, | ||
4089 | 310 | 0, | ||
4090 | 311 | NULL, NULL, | ||
4091 | 312 | g_cclosure_marshal_generic, | ||
4092 | 313 | G_TYPE_NONE, | ||
4093 | 314 | 4, | ||
4094 | 315 | G_TYPE_STRING, | ||
4095 | 316 | G_TYPE_STRING, | ||
4096 | 317 | G_TYPE_STRING, | ||
4097 | 318 | G_TYPE_STRING); | ||
4098 | 319 | |||
4099 | 320 | signals[SOURCE_CHANGED] = g_signal_new ("source-changed", | ||
4100 | 321 | IM_TYPE_APPLICATION_LIST, | ||
4101 | 322 | G_SIGNAL_RUN_FIRST, | ||
4102 | 323 | 0, | ||
4103 | 324 | NULL, NULL, | ||
4104 | 325 | g_cclosure_marshal_generic, | ||
4105 | 326 | G_TYPE_NONE, | ||
4106 | 327 | 4, | ||
4107 | 328 | G_TYPE_STRING, | ||
4108 | 329 | G_TYPE_STRING, | ||
4109 | 330 | G_TYPE_STRING, | ||
4110 | 331 | G_TYPE_STRING); | ||
4111 | 332 | |||
4112 | 333 | signals[SOURCE_REMOVED] = g_signal_new ("source-removed", | ||
4113 | 334 | IM_TYPE_APPLICATION_LIST, | ||
4114 | 335 | G_SIGNAL_RUN_FIRST, | ||
4115 | 336 | 0, | ||
4116 | 337 | NULL, NULL, | ||
4117 | 338 | g_cclosure_marshal_generic, | ||
4118 | 339 | G_TYPE_NONE, | ||
4119 | 340 | 2, | ||
4120 | 341 | G_TYPE_STRING, | ||
4121 | 342 | G_TYPE_STRING); | ||
4122 | 343 | |||
4123 | 344 | signals[MESSAGE_ADDED] = g_signal_new ("message-added", | ||
4124 | 345 | IM_TYPE_APPLICATION_LIST, | ||
4125 | 346 | G_SIGNAL_RUN_FIRST, | ||
4126 | 347 | 0, | ||
4127 | 348 | NULL, NULL, | ||
4128 | 349 | g_cclosure_marshal_generic, | ||
4129 | 350 | G_TYPE_NONE, | ||
4130 | 351 | 10, | ||
4131 | 352 | G_TYPE_STRING, | ||
4132 | 353 | G_TYPE_STRING, | ||
4133 | 354 | G_TYPE_STRING, | ||
4134 | 355 | G_TYPE_STRING, | ||
4135 | 356 | G_TYPE_STRING, | ||
4136 | 357 | G_TYPE_STRING, | ||
4137 | 358 | G_TYPE_STRING, | ||
4138 | 359 | G_TYPE_VARIANT, | ||
4139 | 360 | G_TYPE_INT64, | ||
4140 | 361 | G_TYPE_BOOLEAN); | ||
4141 | 362 | |||
4142 | 363 | signals[MESSAGE_REMOVED] = g_signal_new ("message-removed", | ||
4143 | 364 | IM_TYPE_APPLICATION_LIST, | ||
4144 | 365 | G_SIGNAL_RUN_FIRST, | ||
4145 | 366 | 0, | ||
4146 | 367 | NULL, NULL, | ||
4147 | 368 | g_cclosure_marshal_generic, | ||
4148 | 369 | G_TYPE_NONE, | ||
4149 | 370 | 2, | ||
4150 | 371 | G_TYPE_STRING, | ||
4151 | 372 | G_TYPE_STRING); | ||
4152 | 373 | |||
4153 | 374 | signals[APP_STOPPED] = g_signal_new ("app-stopped", | ||
4154 | 375 | IM_TYPE_APPLICATION_LIST, | ||
4155 | 376 | G_SIGNAL_RUN_FIRST, | ||
4156 | 377 | 0, | ||
4157 | 378 | NULL, NULL, | ||
4158 | 379 | g_cclosure_marshal_VOID__OBJECT, | ||
4159 | 380 | G_TYPE_NONE, | ||
4160 | 381 | 1, | ||
4161 | 382 | G_TYPE_STRING); | ||
4162 | 383 | |||
4163 | 384 | signals[REMOVE_ALL] = g_signal_new ("remove-all", | ||
4164 | 385 | IM_TYPE_APPLICATION_LIST, | ||
4165 | 386 | G_SIGNAL_RUN_FIRST, | ||
4166 | 387 | 0, | ||
4167 | 388 | NULL, NULL, | ||
4168 | 389 | g_cclosure_marshal_VOID__VOID, | ||
4169 | 390 | G_TYPE_NONE, | ||
4170 | 391 | 0); | ||
4171 | 392 | } | ||
4172 | 393 | |||
4173 | 394 | static void | ||
4174 | 395 | im_application_list_init (ImApplicationList *list) | ||
4175 | 396 | { | ||
4176 | 397 | const GActionEntry action_entries[] = { | ||
4177 | 398 | { "messages", NULL, NULL, "('', 'indicator-messages', 'Messages', true)", NULL }, | ||
4178 | 399 | { "remove-all", im_application_list_remove_all } | ||
4179 | 400 | }; | ||
4180 | 401 | |||
4181 | 402 | GSimpleActionGroup *actions; | ||
4182 | 403 | |||
4183 | 404 | list->applications = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, application_free); | ||
4184 | 405 | |||
4185 | 406 | actions = g_simple_action_group_new (); | ||
4186 | 407 | g_simple_action_group_add_entries (actions, action_entries, G_N_ELEMENTS (action_entries), list); | ||
4187 | 408 | |||
4188 | 409 | list->muxer = g_action_muxer_new (); | ||
4189 | 410 | g_action_muxer_insert (list->muxer, NULL, G_ACTION_GROUP (actions)); | ||
4190 | 411 | |||
4191 | 412 | g_object_unref (actions); | ||
4192 | 413 | } | ||
4193 | 414 | |||
4194 | 415 | ImApplicationList * | ||
4195 | 416 | im_application_list_new (void) | ||
4196 | 417 | { | ||
4197 | 418 | return g_object_new (IM_TYPE_APPLICATION_LIST, NULL); | ||
4198 | 419 | } | ||
4199 | 420 | |||
4200 | 421 | static gchar * | ||
4201 | 422 | im_application_list_canonical_id (const gchar *id) | ||
4202 | 423 | { | ||
4203 | 424 | gchar *str; | ||
4204 | 425 | gchar *p; | ||
4205 | 426 | int len; | ||
4206 | 427 | |||
4207 | 428 | len = strlen (id); | ||
4208 | 429 | if (g_str_has_suffix (id, ".desktop")) | ||
4209 | 430 | len -= 8; | ||
4210 | 431 | |||
4211 | 432 | str = g_strndup (id, len); | ||
4212 | 433 | |||
4213 | 434 | for (p = str; *p; p++) | ||
4214 | 435 | { | ||
4215 | 436 | if (*p == '.') | ||
4216 | 437 | *p = '_'; | ||
4217 | 438 | } | ||
4218 | 439 | |||
4219 | 440 | return str; | ||
4220 | 441 | } | ||
4221 | 442 | |||
4222 | 443 | static Application * | ||
4223 | 444 | im_application_list_lookup (ImApplicationList *list, | ||
4224 | 445 | const gchar *desktop_id) | ||
4225 | 446 | { | ||
4226 | 447 | gchar *id; | ||
4227 | 448 | Application *app; | ||
4228 | 449 | |||
4229 | 450 | id = im_application_list_canonical_id (desktop_id); | ||
4230 | 451 | app = g_hash_table_lookup (list->applications, id); | ||
4231 | 452 | |||
4232 | 453 | g_free (id); | ||
4233 | 454 | return app; | ||
4234 | 455 | } | ||
4235 | 456 | |||
4236 | 457 | void | ||
4237 | 458 | im_application_list_add (ImApplicationList *list, | ||
4238 | 459 | const gchar *desktop_id) | ||
4239 | 460 | { | ||
4240 | 461 | GDesktopAppInfo *info; | ||
4241 | 462 | Application *app; | ||
4242 | 463 | const gchar *id; | ||
4243 | 464 | |||
4244 | 465 | g_return_if_fail (IM_IS_APPLICATION_LIST (list)); | ||
4245 | 466 | g_return_if_fail (desktop_id != NULL); | ||
4246 | 467 | |||
4247 | 468 | if (im_application_list_lookup (list, desktop_id)) | ||
4248 | 469 | return; | ||
4249 | 470 | |||
4250 | 471 | info = g_desktop_app_info_new (desktop_id); | ||
4251 | 472 | if (!info) | ||
4252 | 473 | { | ||
4253 | 474 | g_warning ("an application with id '%s' is not installed", desktop_id); | ||
4254 | 475 | return; | ||
4255 | 476 | } | ||
4256 | 477 | |||
4257 | 478 | id = g_app_info_get_id (G_APP_INFO (info)); | ||
4258 | 479 | g_return_if_fail (id != NULL); | ||
4259 | 480 | |||
4260 | 481 | app = g_slice_new0 (Application); | ||
4261 | 482 | app->info = info; | ||
4262 | 483 | app->id = im_application_list_canonical_id (id); | ||
4263 | 484 | app->list = list; | ||
4264 | 485 | app->actions = g_action_muxer_new (); | ||
4265 | 486 | app->source_actions = g_simple_action_group_new (); | ||
4266 | 487 | app->message_actions = g_simple_action_group_new (); | ||
4267 | 488 | app->message_sub_actions = g_action_muxer_new (); | ||
4268 | 489 | |||
4269 | 490 | g_action_muxer_insert (app->actions, "src", G_ACTION_GROUP (app->source_actions)); | ||
4270 | 491 | g_action_muxer_insert (app->actions, "msg", G_ACTION_GROUP (app->message_actions)); | ||
4271 | 492 | g_action_muxer_insert (app->actions, "msg-actions", G_ACTION_GROUP (app->message_sub_actions)); | ||
4272 | 493 | |||
4273 | 494 | g_hash_table_insert (list->applications, (gpointer) app->id, app); | ||
4274 | 495 | g_action_muxer_insert (list->muxer, app->id, G_ACTION_GROUP (app->actions)); | ||
4275 | 496 | } | ||
4276 | 497 | |||
4277 | 498 | void | ||
4278 | 499 | im_application_list_remove (ImApplicationList *list, | ||
4279 | 500 | const gchar *id) | ||
4280 | 501 | { | ||
4281 | 502 | Application *app; | ||
4282 | 503 | |||
4283 | 504 | g_return_if_fail (IM_IS_APPLICATION_LIST (list)); | ||
4284 | 505 | |||
4285 | 506 | app = im_application_list_lookup (list, id); | ||
4286 | 507 | if (app) | ||
4287 | 508 | { | ||
4288 | 509 | if (app->proxy || app->cancellable) | ||
4289 | 510 | g_signal_emit (app->list, signals[APP_STOPPED], 0, app->id); | ||
4290 | 511 | |||
4291 | 512 | g_hash_table_remove (list->applications, id); | ||
4292 | 513 | g_action_muxer_remove (list->muxer, id); | ||
4293 | 514 | } | ||
4294 | 515 | } | ||
4295 | 516 | |||
4296 | 517 | static void | ||
4297 | 518 | im_application_list_source_added (Application *app, | ||
4298 | 519 | guint position, | ||
4299 | 520 | GVariant *source) | ||
4300 | 521 | { | ||
4301 | 522 | const gchar *id; | ||
4302 | 523 | const gchar *label; | ||
4303 | 524 | const gchar *iconstr; | ||
4304 | 525 | guint32 count; | ||
4305 | 526 | gint64 time; | ||
4306 | 527 | const gchar *string; | ||
4307 | 528 | gboolean draws_attention; | ||
4308 | 529 | GVariant *state; | ||
4309 | 530 | GSimpleAction *action; | ||
4310 | 531 | |||
4311 | 532 | g_variant_get (source, "(&s&s&sux&sb)", | ||
4312 | 533 | &id, &label, &iconstr, &count, &time, &string, &draws_attention); | ||
4313 | 534 | |||
4314 | 535 | state = g_variant_new ("(uxsb)", count, time, string, draws_attention); | ||
4315 | 536 | action = g_simple_action_new_stateful (id, G_VARIANT_TYPE_BOOLEAN, state); | ||
4316 | 537 | g_signal_connect (action, "activate", G_CALLBACK (im_application_list_source_activated), app); | ||
4317 | 538 | |||
4318 | 539 | g_simple_action_group_insert (app->source_actions, G_ACTION (action)); | ||
4319 | 540 | |||
4320 | 541 | g_signal_emit (app->list, signals[SOURCE_ADDED], 0, app->id, id, label, iconstr); | ||
4321 | 542 | |||
4322 | 543 | g_object_unref (action); | ||
4323 | 544 | } | ||
4324 | 545 | |||
4325 | 546 | static void | ||
4326 | 547 | im_application_list_source_changed (Application *app, | ||
4327 | 548 | GVariant *source) | ||
4328 | 549 | { | ||
4329 | 550 | const gchar *id; | ||
4330 | 551 | const gchar *label; | ||
4331 | 552 | const gchar *iconstr; | ||
4332 | 553 | guint32 count; | ||
4333 | 554 | gint64 time; | ||
4334 | 555 | const gchar *string; | ||
4335 | 556 | gboolean draws_attention; | ||
4336 | 557 | |||
4337 | 558 | g_variant_get (source, "(&s&s&sux&sb)", | ||
4338 | 559 | &id, &label, &iconstr, &count, &time, &string, &draws_attention); | ||
4339 | 560 | |||
4340 | 561 | g_action_group_change_action_state (G_ACTION_GROUP (app->source_actions), id, | ||
4341 | 562 | g_variant_new ("(uxsb)", count, time, string, draws_attention)); | ||
4342 | 563 | |||
4343 | 564 | g_signal_emit (app->list, signals[SOURCE_CHANGED], 0, app->id, id, label, iconstr); | ||
4344 | 565 | } | ||
4345 | 566 | |||
4346 | 567 | static void | ||
4347 | 568 | im_application_list_sources_listed (GObject *source_object, | ||
4348 | 569 | GAsyncResult *result, | ||
4349 | 570 | gpointer user_data) | ||
4350 | 571 | { | ||
4351 | 572 | Application *app = user_data; | ||
4352 | 573 | GVariant *sources; | ||
4353 | 574 | GError *error = NULL; | ||
4354 | 575 | |||
4355 | 576 | if (indicator_messages_application_call_list_sources_finish (app->proxy, &sources, result, &error)) | ||
4356 | 577 | { | ||
4357 | 578 | GVariantIter iter; | ||
4358 | 579 | GVariant *source; | ||
4359 | 580 | guint i = 0; | ||
4360 | 581 | |||
4361 | 582 | g_variant_iter_init (&iter, sources); | ||
4362 | 583 | while ((source = g_variant_iter_next_value (&iter))) | ||
4363 | 584 | { | ||
4364 | 585 | im_application_list_source_added (app, i++, source); | ||
4365 | 586 | g_variant_unref (source); | ||
4366 | 587 | } | ||
4367 | 588 | |||
4368 | 589 | g_variant_unref (sources); | ||
4369 | 590 | } | ||
4370 | 591 | else | ||
4371 | 592 | { | ||
4372 | 593 | g_warning ("could not fetch the list of sources: %s", error->message); | ||
4373 | 594 | g_error_free (error); | ||
4374 | 595 | } | ||
4375 | 596 | } | ||
4376 | 597 | |||
4377 | 598 | static gchar * | ||
4378 | 599 | get_symbolic_app_icon_string (GIcon *icon) | ||
4379 | 600 | { | ||
4380 | 601 | const gchar * const *names; | ||
4381 | 602 | gchar *symbolic_name; | ||
4382 | 603 | GIcon *symbolic_icon; | ||
4383 | 604 | gchar *str; | ||
4384 | 605 | |||
4385 | 606 | if (!G_IS_THEMED_ICON (icon)) | ||
4386 | 607 | return NULL; | ||
4387 | 608 | |||
4388 | 609 | names = g_themed_icon_get_names (G_THEMED_ICON (icon)); | ||
4389 | 610 | if (!names || !names[0]) | ||
4390 | 611 | return NULL; | ||
4391 | 612 | |||
4392 | 613 | symbolic_icon = g_themed_icon_new_from_names ((gchar **) names, -1); | ||
4393 | 614 | |||
4394 | 615 | symbolic_name = g_strconcat (names[0], "-symbolic", NULL); | ||
4395 | 616 | g_themed_icon_prepend_name (G_THEMED_ICON (symbolic_icon), symbolic_name); | ||
4396 | 617 | |||
4397 | 618 | str = g_icon_to_string (symbolic_icon); | ||
4398 | 619 | |||
4399 | 620 | g_free (symbolic_name); | ||
4400 | 621 | g_object_unref (symbolic_icon); | ||
4401 | 622 | return str; | ||
4402 | 623 | } | ||
4403 | 624 | |||
4404 | 625 | static void | ||
4405 | 626 | im_application_list_message_added (Application *app, | ||
4406 | 627 | GVariant *message) | ||
4407 | 628 | { | ||
4408 | 629 | const gchar *id; | ||
4409 | 630 | const gchar *iconstr; | ||
4410 | 631 | const gchar *title; | ||
4411 | 632 | const gchar *subtitle; | ||
4412 | 633 | const gchar *body; | ||
4413 | 634 | gint64 time; | ||
4414 | 635 | GVariantIter *action_iter; | ||
4415 | 636 | gboolean draws_attention; | ||
4416 | 637 | GSimpleAction *action; | ||
4417 | 638 | GIcon *app_icon; | ||
4418 | 639 | gchar *app_iconstr = NULL; | ||
4419 | 640 | GVariant *actions = NULL; | ||
4420 | 641 | |||
4421 | 642 | g_variant_get (message, "(&s&s&s&s&sxaa{sv}b)", | ||
4422 | 643 | &id, &iconstr, &title, &subtitle, &body, &time, &action_iter, &draws_attention); | ||
4423 | 644 | |||
4424 | 645 | app_icon = g_app_info_get_icon (G_APP_INFO (app->info)); | ||
4425 | 646 | if (app_icon) | ||
4426 | 647 | app_iconstr = get_symbolic_app_icon_string (app_icon); | ||
4427 | 648 | |||
4428 | 649 | action = g_simple_action_new (id, G_VARIANT_TYPE_BOOLEAN); | ||
4429 | 650 | g_signal_connect (action, "activate", G_CALLBACK (im_application_list_message_activated), app); | ||
4430 | 651 | g_simple_action_group_insert (app->message_actions, G_ACTION (action)); | ||
4431 | 652 | |||
4432 | 653 | { | ||
4433 | 654 | GVariant *entry; | ||
4434 | 655 | GSimpleActionGroup *action_group; | ||
4435 | 656 | GVariantBuilder actions_builder; | ||
4436 | 657 | |||
4437 | 658 | g_variant_builder_init (&actions_builder, G_VARIANT_TYPE ("aa{sv}")); | ||
4438 | 659 | action_group = g_simple_action_group_new (); | ||
4439 | 660 | |||
4440 | 661 | while ((entry = g_variant_iter_next_value (action_iter))) | ||
4441 | 662 | { | ||
4442 | 663 | const gchar *name; | ||
4443 | 664 | GSimpleAction *action; | ||
4444 | 665 | GVariant *label; | ||
4445 | 666 | const gchar *type = NULL; | ||
4446 | 667 | GVariant *hint; | ||
4447 | 668 | GVariantBuilder dict_builder; | ||
4448 | 669 | gchar *prefixed_name; | ||
4449 | 670 | |||
4450 | 671 | if (!g_variant_lookup (entry, "name", "&s", &name)) | ||
4451 | 672 | { | ||
4452 | 673 | g_warning ("action dictionary for message '%s' is missing 'name' key", id); | ||
4453 | 674 | continue; | ||
4454 | 675 | } | ||
4455 | 676 | |||
4456 | 677 | label = g_variant_lookup_value (entry, "label", G_VARIANT_TYPE_STRING); | ||
4457 | 678 | g_variant_lookup (entry, "parameter-type", "&g", &type); | ||
4458 | 679 | hint = g_variant_lookup_value (entry, "parameter-hint", NULL); | ||
4459 | 680 | |||
4460 | 681 | action = g_simple_action_new (name, type ? G_VARIANT_TYPE (type) : NULL); | ||
4461 | 682 | g_object_set_data_full (G_OBJECT (action), "message", g_strdup (id), g_free); | ||
4462 | 683 | g_signal_connect (action, "activate", G_CALLBACK (im_application_list_sub_message_activated), app); | ||
4463 | 684 | g_simple_action_group_insert (action_group, G_ACTION (action)); | ||
4464 | 685 | |||
4465 | 686 | g_variant_builder_init (&dict_builder, G_VARIANT_TYPE ("a{sv}")); | ||
4466 | 687 | |||
4467 | 688 | prefixed_name = g_strjoin (".", app->id, "msg-actions", id, name, NULL); | ||
4468 | 689 | g_variant_builder_add (&dict_builder, "{sv}", "name", g_variant_new_string (prefixed_name)); | ||
4469 | 690 | |||
4470 | 691 | if (label) | ||
4471 | 692 | { | ||
4472 | 693 | g_variant_builder_add (&dict_builder, "{sv}", "label", label); | ||
4473 | 694 | g_variant_unref (label); | ||
4474 | 695 | } | ||
4475 | 696 | |||
4476 | 697 | if (type) | ||
4477 | 698 | g_variant_builder_add (&dict_builder, "{sv}", "parameter-type", g_variant_new_string (type)); | ||
4478 | 699 | |||
4479 | 700 | if (hint) | ||
4480 | 701 | { | ||
4481 | 702 | g_variant_builder_add (&dict_builder, "{sv}", "parameter-hint", hint); | ||
4482 | 703 | g_variant_unref (hint); | ||
4483 | 704 | } | ||
4484 | 705 | |||
4485 | 706 | g_variant_builder_add (&actions_builder, "a{sv}", &dict_builder); | ||
4486 | 707 | |||
4487 | 708 | g_object_unref (action); | ||
4488 | 709 | g_variant_unref (entry); | ||
4489 | 710 | g_free (prefixed_name); | ||
4490 | 711 | } | ||
4491 | 712 | |||
4492 | 713 | g_action_muxer_insert (app->message_sub_actions, id, G_ACTION_GROUP (action_group)); | ||
4493 | 714 | actions = g_variant_builder_end (&actions_builder); | ||
4494 | 715 | |||
4495 | 716 | g_object_unref (action_group); | ||
4496 | 717 | } | ||
4497 | 718 | |||
4498 | 719 | im_application_list_update_draws_attention (app->list); | ||
4499 | 720 | |||
4500 | 721 | g_signal_emit (app->list, signals[MESSAGE_ADDED], 0, | ||
4501 | 722 | app->id, app_iconstr, id, iconstr, title, | ||
4502 | 723 | subtitle, body, actions, time, draws_attention); | ||
4503 | 724 | |||
4504 | 725 | g_variant_iter_free (action_iter); | ||
4505 | 726 | g_free (app_iconstr); | ||
4506 | 727 | g_object_unref (action); | ||
4507 | 728 | } | ||
4508 | 729 | |||
4509 | 730 | static void | ||
4510 | 731 | im_application_list_messages_listed (GObject *source_object, | ||
4511 | 732 | GAsyncResult *result, | ||
4512 | 733 | gpointer user_data) | ||
4513 | 734 | { | ||
4514 | 735 | Application *app = user_data; | ||
4515 | 736 | GVariant *messages; | ||
4516 | 737 | GError *error = NULL; | ||
4517 | 738 | |||
4518 | 739 | if (indicator_messages_application_call_list_messages_finish (app->proxy, &messages, result, &error)) | ||
4519 | 740 | { | ||
4520 | 741 | GVariantIter iter; | ||
4521 | 742 | GVariant *message; | ||
4522 | 743 | |||
4523 | 744 | g_variant_iter_init (&iter, messages); | ||
4524 | 745 | while ((message = g_variant_iter_next_value (&iter))) | ||
4525 | 746 | { | ||
4526 | 747 | im_application_list_message_added (app, message); | ||
4527 | 748 | g_variant_unref (message); | ||
4528 | 749 | } | ||
4529 | 750 | |||
4530 | 751 | g_variant_unref (messages); | ||
4531 | 752 | } | ||
4532 | 753 | else | ||
4533 | 754 | { | ||
4534 | 755 | g_warning ("could not fetch the list of messages: %s", error->message); | ||
4535 | 756 | g_error_free (error); | ||
4536 | 757 | } | ||
4537 | 758 | } | ||
4538 | 759 | |||
4539 | 760 | static void | ||
4540 | 761 | im_application_list_unset_remote (Application *app) | ||
4541 | 762 | { | ||
4542 | 763 | gboolean was_running; | ||
4543 | 764 | |||
4544 | 765 | was_running = app->proxy || app->cancellable; | ||
4545 | 766 | |||
4546 | 767 | if (app->cancellable) | ||
4547 | 768 | { | ||
4548 | 769 | g_cancellable_cancel (app->cancellable); | ||
4549 | 770 | g_clear_object (&app->cancellable); | ||
4550 | 771 | } | ||
4551 | 772 | g_clear_object (&app->proxy); | ||
4552 | 773 | |||
4553 | 774 | /* clear actions by creating a new action group and overriding it in | ||
4554 | 775 | * the muxer */ | ||
4555 | 776 | g_object_unref (app->source_actions); | ||
4556 | 777 | g_object_unref (app->message_actions); | ||
4557 | 778 | g_object_unref (app->message_sub_actions); | ||
4558 | 779 | app->source_actions = g_simple_action_group_new (); | ||
4559 | 780 | app->message_actions = g_simple_action_group_new (); | ||
4560 | 781 | app->message_sub_actions = g_action_muxer_new (); | ||
4561 | 782 | g_action_muxer_insert (app->actions, "src", G_ACTION_GROUP (app->source_actions)); | ||
4562 | 783 | g_action_muxer_insert (app->actions, "msg", G_ACTION_GROUP (app->message_actions)); | ||
4563 | 784 | g_action_muxer_insert (app->actions, "msg-actions", G_ACTION_GROUP (app->message_sub_actions)); | ||
4564 | 785 | |||
4565 | 786 | im_application_list_update_draws_attention (app->list); | ||
4566 | 787 | |||
4567 | 788 | if (was_running) | ||
4568 | 789 | g_signal_emit (app->list, signals[APP_STOPPED], 0, app->id); | ||
4569 | 790 | } | ||
4570 | 791 | |||
4571 | 792 | static void | ||
4572 | 793 | im_application_list_app_vanished (GDBusConnection *connection, | ||
4573 | 794 | const gchar *name, | ||
4574 | 795 | gpointer user_data) | ||
4575 | 796 | { | ||
4576 | 797 | Application *app = user_data; | ||
4577 | 798 | |||
4578 | 799 | im_application_list_unset_remote (app); | ||
4579 | 800 | } | ||
4580 | 801 | |||
4581 | 802 | static void | ||
4582 | 803 | im_application_list_proxy_created (GObject *source_object, | ||
4583 | 804 | GAsyncResult *result, | ||
4584 | 805 | gpointer user_data) | ||
4585 | 806 | { | ||
4586 | 807 | Application *app = user_data; | ||
4587 | 808 | GError *error = NULL; | ||
4588 | 809 | |||
4589 | 810 | app->proxy = indicator_messages_application_proxy_new_finish (result, &error); | ||
4590 | 811 | if (!app->proxy) | ||
4591 | 812 | { | ||
4592 | 813 | if (error->code != G_IO_ERROR_CANCELLED) | ||
4593 | 814 | g_warning ("could not create application proxy: %s", error->message); | ||
4594 | 815 | g_error_free (error); | ||
4595 | 816 | return; | ||
4596 | 817 | } | ||
4597 | 818 | |||
4598 | 819 | indicator_messages_application_call_list_sources (app->proxy, app->cancellable, | ||
4599 | 820 | im_application_list_sources_listed, app); | ||
4600 | 821 | indicator_messages_application_call_list_messages (app->proxy, app->cancellable, | ||
4601 | 822 | im_application_list_messages_listed, app); | ||
4602 | 823 | |||
4603 | 824 | g_signal_connect_swapped (app->proxy, "source-added", G_CALLBACK (im_application_list_source_added), app); | ||
4604 | 825 | g_signal_connect_swapped (app->proxy, "source-changed", G_CALLBACK (im_application_list_source_changed), app); | ||
4605 | 826 | g_signal_connect_swapped (app->proxy, "source-removed", G_CALLBACK (im_application_list_source_removed), app); | ||
4606 | 827 | g_signal_connect_swapped (app->proxy, "message-added", G_CALLBACK (im_application_list_message_added), app); | ||
4607 | 828 | g_signal_connect_swapped (app->proxy, "message-removed", G_CALLBACK (im_application_list_message_removed), app); | ||
4608 | 829 | |||
4609 | 830 | g_bus_watch_name_on_connection (g_dbus_proxy_get_connection (G_DBUS_PROXY (app->proxy)), | ||
4610 | 831 | g_dbus_proxy_get_name (G_DBUS_PROXY (app->proxy)), | ||
4611 | 832 | G_BUS_NAME_WATCHER_FLAGS_NONE, | ||
4612 | 833 | NULL, im_application_list_app_vanished, | ||
4613 | 834 | app, NULL); | ||
4614 | 835 | } | ||
4615 | 836 | |||
4616 | 837 | void | ||
4617 | 838 | im_application_list_set_remote (ImApplicationList *list, | ||
4618 | 839 | const gchar *id, | ||
4619 | 840 | GDBusConnection *connection, | ||
4620 | 841 | const gchar *unique_bus_name, | ||
4621 | 842 | const gchar *object_path) | ||
4622 | 843 | { | ||
4623 | 844 | Application *app; | ||
4624 | 845 | |||
4625 | 846 | g_return_if_fail (IM_IS_APPLICATION_LIST (list)); | ||
4626 | 847 | |||
4627 | 848 | app = im_application_list_lookup (list, id); | ||
4628 | 849 | if (!app) | ||
4629 | 850 | { | ||
4630 | 851 | g_warning ("'%s' is not a registered application", id); | ||
4631 | 852 | return; | ||
4632 | 853 | } | ||
4633 | 854 | |||
4634 | 855 | if (app->cancellable) | ||
4635 | 856 | { | ||
4636 | 857 | gchar *name_owner = NULL; | ||
4637 | 858 | |||
4638 | 859 | if (app->proxy) | ||
4639 | 860 | name_owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (app->proxy)); | ||
4640 | 861 | g_warning ("replacing '%s' at %s with %s", id, name_owner, unique_bus_name); | ||
4641 | 862 | |||
4642 | 863 | im_application_list_unset_remote (app); | ||
4643 | 864 | |||
4644 | 865 | g_free (name_owner); | ||
4645 | 866 | } | ||
4646 | 867 | |||
4647 | 868 | app->cancellable = g_cancellable_new (); | ||
4648 | 869 | indicator_messages_application_proxy_new (connection, G_DBUS_PROXY_FLAGS_NONE, | ||
4649 | 870 | unique_bus_name, object_path, app->cancellable, | ||
4650 | 871 | im_application_list_proxy_created, app); | ||
4651 | 872 | } | ||
4652 | 873 | |||
4653 | 874 | GActionGroup * | ||
4654 | 875 | im_application_list_get_action_group (ImApplicationList *list) | ||
4655 | 876 | { | ||
4656 | 877 | g_return_val_if_fail (IM_IS_APPLICATION_LIST (list), NULL); | ||
4657 | 878 | |||
4658 | 879 | return G_ACTION_GROUP (list->muxer); | ||
4659 | 880 | } | ||
4660 | 0 | 881 | ||
4661 | === added file 'src/im-application-list.h' | |||
4662 | --- src/im-application-list.h 1970-01-01 00:00:00 +0000 | |||
4663 | +++ src/im-application-list.h 2013-04-26 16:57:25 +0000 | |||
4664 | @@ -0,0 +1,52 @@ | |||
4665 | 1 | /* | ||
4666 | 2 | * Copyright 2012 Canonical Ltd. | ||
4667 | 3 | * | ||
4668 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
4669 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
4670 | 6 | * by the Free Software Foundation. | ||
4671 | 7 | * | ||
4672 | 8 | * This program is distributed in the hope that it will be useful, but | ||
4673 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
4674 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
4675 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
4676 | 12 | * | ||
4677 | 13 | * You should have received a copy of the GNU General Public License along | ||
4678 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4679 | 15 | * | ||
4680 | 16 | * Authors: | ||
4681 | 17 | * Lars Uebernickel <lars.uebernickel@canonical.com> | ||
4682 | 18 | */ | ||
4683 | 19 | |||
4684 | 20 | #ifndef __IM_APPLICATION_LIST_H__ | ||
4685 | 21 | #define __IM_APPLICATION_LIST_H__ | ||
4686 | 22 | |||
4687 | 23 | #include <gio/gio.h> | ||
4688 | 24 | |||
4689 | 25 | #define IM_TYPE_APPLICATION_LIST (im_application_list_get_type ()) | ||
4690 | 26 | #define IM_APPLICATION_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IM_TYPE_APPLICATION_LIST, ImApplicationList)) | ||
4691 | 27 | #define IM_APPLICATION_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IM_TYPE_APPLICATION_LIST, ImApplicationListClass)) | ||
4692 | 28 | #define IM_IS_APPLICATION_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IM_TYPE_APPLICATION_LIST)) | ||
4693 | 29 | #define IM_IS_APPLICATION_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IM_TYPE_APPLICATION_LIST)) | ||
4694 | 30 | #define IM_APPLICATION_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IM_TYPE_APPLICATION_LIST, ImApplicationListClass)) | ||
4695 | 31 | |||
4696 | 32 | typedef struct _ImApplicationList ImApplicationList; | ||
4697 | 33 | |||
4698 | 34 | GType im_application_list_get_type (void); | ||
4699 | 35 | |||
4700 | 36 | ImApplicationList * im_application_list_new (void); | ||
4701 | 37 | |||
4702 | 38 | void im_application_list_add (ImApplicationList *list, | ||
4703 | 39 | const gchar *desktop_id); | ||
4704 | 40 | |||
4705 | 41 | void im_application_list_remove (ImApplicationList *list, | ||
4706 | 42 | const gchar *id); | ||
4707 | 43 | |||
4708 | 44 | void im_application_list_set_remote (ImApplicationList *list, | ||
4709 | 45 | const gchar *id, | ||
4710 | 46 | GDBusConnection *connection, | ||
4711 | 47 | const gchar *unique_bus_name, | ||
4712 | 48 | const gchar *object_path); | ||
4713 | 49 | |||
4714 | 50 | GActionGroup * im_application_list_get_action_group (ImApplicationList *list); | ||
4715 | 51 | |||
4716 | 52 | #endif | ||
4717 | 0 | 53 | ||
4718 | === added file 'src/im-phone-menu.c' | |||
4719 | --- src/im-phone-menu.c 1970-01-01 00:00:00 +0000 | |||
4720 | +++ src/im-phone-menu.c 2013-04-26 16:57:25 +0000 | |||
4721 | @@ -0,0 +1,331 @@ | |||
4722 | 1 | /* | ||
4723 | 2 | * Copyright 2012 Canonical Ltd. | ||
4724 | 3 | * | ||
4725 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
4726 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
4727 | 6 | * by the Free Software Foundation. | ||
4728 | 7 | * | ||
4729 | 8 | * This program is distributed in the hope that it will be useful, but | ||
4730 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
4731 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
4732 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
4733 | 12 | * | ||
4734 | 13 | * You should have received a copy of the GNU General Public License along | ||
4735 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4736 | 15 | * | ||
4737 | 16 | * Authors: | ||
4738 | 17 | * Lars Uebernickel <lars.uebernickel@canonical.com> | ||
4739 | 18 | */ | ||
4740 | 19 | |||
4741 | 20 | #include "im-phone-menu.h" | ||
4742 | 21 | |||
4743 | 22 | #include <string.h> | ||
4744 | 23 | |||
4745 | 24 | typedef GObjectClass ImPhoneMenuClass; | ||
4746 | 25 | |||
4747 | 26 | struct _ImPhoneMenu | ||
4748 | 27 | { | ||
4749 | 28 | GObject parent; | ||
4750 | 29 | |||
4751 | 30 | GMenu *toplevel_menu; | ||
4752 | 31 | GMenu *message_section; | ||
4753 | 32 | GMenu *source_section; | ||
4754 | 33 | |||
4755 | 34 | }; | ||
4756 | 35 | |||
4757 | 36 | G_DEFINE_TYPE (ImPhoneMenu, im_phone_menu, G_TYPE_OBJECT); | ||
4758 | 37 | |||
4759 | 38 | typedef void (*ImMenuForeachFunc) (GMenuModel *menu, gint pos); | ||
4760 | 39 | |||
4761 | 40 | static void | ||
4762 | 41 | im_phone_menu_foreach_item_with_action (GMenuModel *menu, | ||
4763 | 42 | const gchar *action, | ||
4764 | 43 | ImMenuForeachFunc func) | ||
4765 | 44 | { | ||
4766 | 45 | gint n_items; | ||
4767 | 46 | gint i; | ||
4768 | 47 | |||
4769 | 48 | n_items = g_menu_model_get_n_items (menu); | ||
4770 | 49 | for (i = 0; i < n_items; i++) | ||
4771 | 50 | { | ||
4772 | 51 | gchar *item_action; | ||
4773 | 52 | |||
4774 | 53 | g_menu_model_get_item_attribute (menu, i, G_MENU_ATTRIBUTE_ACTION, "s", &item_action); | ||
4775 | 54 | |||
4776 | 55 | if (g_str_equal (action, item_action)) | ||
4777 | 56 | func (menu, i); | ||
4778 | 57 | |||
4779 | 58 | g_free (item_action); | ||
4780 | 59 | } | ||
4781 | 60 | } | ||
4782 | 61 | |||
4783 | 62 | static void | ||
4784 | 63 | im_phone_menu_update_toplevel (ImPhoneMenu *menu) | ||
4785 | 64 | { | ||
4786 | 65 | if (g_menu_model_get_n_items (G_MENU_MODEL (menu->message_section)) || | ||
4787 | 66 | g_menu_model_get_n_items (G_MENU_MODEL (menu->source_section))) | ||
4788 | 67 | { | ||
4789 | 68 | if (g_menu_model_get_n_items (G_MENU_MODEL (menu->toplevel_menu)) == 0) | ||
4790 | 69 | { | ||
4791 | 70 | GMenuItem *item; | ||
4792 | 71 | |||
4793 | 72 | g_menu_append_section (menu->toplevel_menu, NULL, G_MENU_MODEL (menu->message_section)); | ||
4794 | 73 | g_menu_append_section (menu->toplevel_menu, NULL, G_MENU_MODEL (menu->source_section)); | ||
4795 | 74 | |||
4796 | 75 | item = g_menu_item_new ("Clear All", "remove-all"); | ||
4797 | 76 | g_menu_item_set_attribute (item, "x-canonical-type", "s", "com.canonical.indicator.button"); | ||
4798 | 77 | g_menu_append_item (menu->toplevel_menu, item); | ||
4799 | 78 | |||
4800 | 79 | g_object_unref (item); | ||
4801 | 80 | } | ||
4802 | 81 | } | ||
4803 | 82 | else | ||
4804 | 83 | { | ||
4805 | 84 | while (g_menu_model_get_n_items (G_MENU_MODEL (menu->toplevel_menu))) | ||
4806 | 85 | g_menu_remove (menu->toplevel_menu, 0); | ||
4807 | 86 | } | ||
4808 | 87 | } | ||
4809 | 88 | |||
4810 | 89 | static void | ||
4811 | 90 | im_phone_menu_dispose (GObject *object) | ||
4812 | 91 | { | ||
4813 | 92 | ImPhoneMenu *menu = IM_PHONE_MENU (object); | ||
4814 | 93 | |||
4815 | 94 | g_clear_object (&menu->toplevel_menu); | ||
4816 | 95 | g_clear_object (&menu->message_section); | ||
4817 | 96 | g_clear_object (&menu->source_section); | ||
4818 | 97 | |||
4819 | 98 | G_OBJECT_CLASS (im_phone_menu_parent_class)->dispose (object); | ||
4820 | 99 | } | ||
4821 | 100 | |||
4822 | 101 | static void | ||
4823 | 102 | im_phone_menu_finalize (GObject *object) | ||
4824 | 103 | { | ||
4825 | 104 | G_OBJECT_CLASS (im_phone_menu_parent_class)->finalize (object); | ||
4826 | 105 | } | ||
4827 | 106 | |||
4828 | 107 | static void | ||
4829 | 108 | im_phone_menu_class_init (ImPhoneMenuClass *klass) | ||
4830 | 109 | { | ||
4831 | 110 | GObjectClass *object_class = G_OBJECT_CLASS (klass); | ||
4832 | 111 | |||
4833 | 112 | object_class->dispose = im_phone_menu_dispose; | ||
4834 | 113 | object_class->finalize = im_phone_menu_finalize; | ||
4835 | 114 | } | ||
4836 | 115 | |||
4837 | 116 | static void | ||
4838 | 117 | im_phone_menu_init (ImPhoneMenu *menu) | ||
4839 | 118 | { | ||
4840 | 119 | menu->toplevel_menu = g_menu_new (); | ||
4841 | 120 | menu->message_section = g_menu_new (); | ||
4842 | 121 | menu->source_section = g_menu_new (); | ||
4843 | 122 | |||
4844 | 123 | g_signal_connect_swapped (menu->message_section, "items-changed", | ||
4845 | 124 | G_CALLBACK (im_phone_menu_update_toplevel), menu); | ||
4846 | 125 | g_signal_connect_swapped (menu->source_section, "items-changed", | ||
4847 | 126 | G_CALLBACK (im_phone_menu_update_toplevel), menu); | ||
4848 | 127 | |||
4849 | 128 | im_phone_menu_update_toplevel (menu); | ||
4850 | 129 | } | ||
4851 | 130 | |||
4852 | 131 | ImPhoneMenu * | ||
4853 | 132 | im_phone_menu_new (void) | ||
4854 | 133 | { | ||
4855 | 134 | return g_object_new (IM_TYPE_PHONE_MENU, NULL); | ||
4856 | 135 | } | ||
4857 | 136 | |||
4858 | 137 | GMenuModel * | ||
4859 | 138 | im_phone_menu_get_model (ImPhoneMenu *menu) | ||
4860 | 139 | { | ||
4861 | 140 | g_return_val_if_fail (IM_IS_PHONE_MENU (menu), NULL); | ||
4862 | 141 | |||
4863 | 142 | return G_MENU_MODEL (menu->toplevel_menu); | ||
4864 | 143 | } | ||
4865 | 144 | |||
4866 | 145 | static gint64 | ||
4867 | 146 | im_phone_menu_get_message_time (GMenuModel *model, | ||
4868 | 147 | gint i) | ||
4869 | 148 | { | ||
4870 | 149 | gint64 time; | ||
4871 | 150 | |||
4872 | 151 | g_menu_model_get_item_attribute (model, i, "x-canonical-time", "x", &time); | ||
4873 | 152 | |||
4874 | 153 | return time; | ||
4875 | 154 | } | ||
4876 | 155 | |||
4877 | 156 | void | ||
4878 | 157 | im_phone_menu_add_message (ImPhoneMenu *menu, | ||
4879 | 158 | const gchar *app_id, | ||
4880 | 159 | const gchar *app_icon, | ||
4881 | 160 | const gchar *id, | ||
4882 | 161 | const gchar *iconstr, | ||
4883 | 162 | const gchar *title, | ||
4884 | 163 | const gchar *subtitle, | ||
4885 | 164 | const gchar *body, | ||
4886 | 165 | GVariant *actions, | ||
4887 | 166 | gint64 time) | ||
4888 | 167 | { | ||
4889 | 168 | GMenuItem *item; | ||
4890 | 169 | gchar *action_name; | ||
4891 | 170 | gint n_messages; | ||
4892 | 171 | gint pos; | ||
4893 | 172 | |||
4894 | 173 | g_return_if_fail (IM_IS_PHONE_MENU (menu)); | ||
4895 | 174 | g_return_if_fail (app_id); | ||
4896 | 175 | |||
4897 | 176 | action_name = g_strconcat (app_id, ".msg.", id, NULL); | ||
4898 | 177 | |||
4899 | 178 | item = g_menu_item_new (title, action_name); | ||
4900 | 179 | |||
4901 | 180 | g_menu_item_set_attribute (item, "x-canonical-type", "s", "com.canonical.indicator.messages.messageitem"); | ||
4902 | 181 | g_menu_item_set_attribute (item, "x-canonical-message-id", "s", id); | ||
4903 | 182 | g_menu_item_set_attribute (item, "x-canonical-subtitle", "s", subtitle); | ||
4904 | 183 | g_menu_item_set_attribute (item, "x-canonical-text", "s", body); | ||
4905 | 184 | g_menu_item_set_attribute (item, "x-canonical-time", "x", time); | ||
4906 | 185 | |||
4907 | 186 | if (iconstr) | ||
4908 | 187 | g_menu_item_set_attribute (item, "x-canonical-icon", "s", iconstr); | ||
4909 | 188 | |||
4910 | 189 | if (app_icon) | ||
4911 | 190 | g_menu_item_set_attribute (item, "x-canonical-app-icon", "s", app_icon); | ||
4912 | 191 | |||
4913 | 192 | if (actions) | ||
4914 | 193 | g_menu_item_set_attribute (item, "x-canonical-message-actions", "v", actions); | ||
4915 | 194 | |||
4916 | 195 | n_messages = g_menu_model_get_n_items (G_MENU_MODEL (menu->message_section)); | ||
4917 | 196 | pos = 0; | ||
4918 | 197 | while (pos < n_messages && | ||
4919 | 198 | time < im_phone_menu_get_message_time (G_MENU_MODEL (menu->message_section), pos)) | ||
4920 | 199 | pos++; | ||
4921 | 200 | |||
4922 | 201 | g_menu_insert_item (menu->message_section, pos, item); | ||
4923 | 202 | |||
4924 | 203 | g_free (action_name); | ||
4925 | 204 | g_object_unref (item); | ||
4926 | 205 | } | ||
4927 | 206 | |||
4928 | 207 | void | ||
4929 | 208 | im_phone_menu_remove_message (ImPhoneMenu *menu, | ||
4930 | 209 | const gchar *app_id, | ||
4931 | 210 | const gchar *id) | ||
4932 | 211 | { | ||
4933 | 212 | gchar *action_name; | ||
4934 | 213 | |||
4935 | 214 | g_return_if_fail (IM_IS_PHONE_MENU (menu)); | ||
4936 | 215 | g_return_if_fail (app_id != NULL); | ||
4937 | 216 | |||
4938 | 217 | action_name = g_strconcat (app_id, ".msg.", id, NULL); | ||
4939 | 218 | im_phone_menu_foreach_item_with_action (G_MENU_MODEL (menu->message_section), | ||
4940 | 219 | action_name, | ||
4941 | 220 | (ImMenuForeachFunc) g_menu_remove); | ||
4942 | 221 | |||
4943 | 222 | g_free (action_name); | ||
4944 | 223 | } | ||
4945 | 224 | |||
4946 | 225 | void | ||
4947 | 226 | im_phone_menu_add_source (ImPhoneMenu *menu, | ||
4948 | 227 | const gchar *app_id, | ||
4949 | 228 | const gchar *id, | ||
4950 | 229 | const gchar *label, | ||
4951 | 230 | const gchar *iconstr) | ||
4952 | 231 | { | ||
4953 | 232 | GMenuItem *item; | ||
4954 | 233 | gchar *action_name; | ||
4955 | 234 | |||
4956 | 235 | g_return_if_fail (IM_IS_PHONE_MENU (menu)); | ||
4957 | 236 | g_return_if_fail (app_id != NULL); | ||
4958 | 237 | |||
4959 | 238 | action_name = g_strconcat (app_id, ".src.", id, NULL); | ||
4960 | 239 | |||
4961 | 240 | item = g_menu_item_new (label, action_name); | ||
4962 | 241 | g_menu_item_set_attribute (item, "x-canonical-type", "s", "com.canonical.indicator.messages.sourceitem"); | ||
4963 | 242 | |||
4964 | 243 | if (iconstr) | ||
4965 | 244 | g_menu_item_set_attribute (item, "x-canonical-icon", "s", iconstr); | ||
4966 | 245 | |||
4967 | 246 | g_menu_prepend_item (menu->source_section, item); | ||
4968 | 247 | |||
4969 | 248 | g_free (action_name); | ||
4970 | 249 | g_object_unref (item); | ||
4971 | 250 | } | ||
4972 | 251 | |||
4973 | 252 | void | ||
4974 | 253 | im_phone_menu_remove_source (ImPhoneMenu *menu, | ||
4975 | 254 | const gchar *app_id, | ||
4976 | 255 | const gchar *id) | ||
4977 | 256 | { | ||
4978 | 257 | gchar *action_name; | ||
4979 | 258 | |||
4980 | 259 | g_return_if_fail (IM_IS_PHONE_MENU (menu)); | ||
4981 | 260 | g_return_if_fail (app_id != NULL); | ||
4982 | 261 | |||
4983 | 262 | action_name = g_strconcat (app_id, ".src.", id, NULL); | ||
4984 | 263 | im_phone_menu_foreach_item_with_action (G_MENU_MODEL (menu->source_section), | ||
4985 | 264 | action_name, | ||
4986 | 265 | (ImMenuForeachFunc) g_menu_remove); | ||
4987 | 266 | |||
4988 | 267 | g_free (action_name); | ||
4989 | 268 | } | ||
4990 | 269 | |||
4991 | 270 | static void | ||
4992 | 271 | im_phone_menu_remove_all_for_app (GMenu *menu, | ||
4993 | 272 | const gchar *app_id) | ||
4994 | 273 | { | ||
4995 | 274 | gchar *prefix; | ||
4996 | 275 | gint n_items; | ||
4997 | 276 | gint i = 0; | ||
4998 | 277 | |||
4999 | 278 | prefix = g_strconcat (app_id, ".", NULL); | ||
5000 | 279 |
The diff has been truncated for viewing.