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