Merge lp:~indicator-applet-developers/indicator-messages/consolidate into lp:~indicator-applet-developers/indicator-messages/trunk.13.10

Proposed by Ted Gould
Status: Merged
Approved by: Pete Woods
Approved revision: 410
Merged at revision: 352
Proposed branch: lp:~indicator-applet-developers/indicator-messages/consolidate
Merge into: lp:~indicator-applet-developers/indicator-messages/trunk.13.10
Diff against target: 9486 lines (+4746/-3772)
53 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 (+22/-27)
data/Makefile.am (+4/-1)
data/com.canonical.indicator.messages (+10/-0)
debian/changelog (+103/-0)
debian/control (+7/-7)
debian/indicator-messages.install (+1/-1)
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 (+503/-270)
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)
po/POTFILES.in (+13/-1)
po/indicator-messages.pot (+0/-46)
src/Makefile.am (+11/-60)
src/app-section.c (+279/-175)
src/dbus-data.h (+16/-1)
src/gactionmuxer.c (+8/-0)
src/gactionmuxer.h (+3/-0)
src/gmenuutils.c (+1/-1)
src/ido-detail-label.c (+0/-401)
src/ido-detail-label.h (+0/-59)
src/ido-menu-item.c (+0/-439)
src/ido-menu-item.h (+0/-54)
src/im-app-menu-item.c (+0/-354)
src/im-app-menu-item.h (+0/-54)
src/im-application-list.c (+1139/-0)
src/im-application-list.h (+62/-0)
src/im-desktop-menu.c (+294/-0)
src/im-desktop-menu.h (+35/-0)
src/im-menu.c (+191/-0)
src/im-menu.h (+64/-0)
src/im-phone-menu.c (+317/-0)
src/im-phone-menu.h (+68/-0)
src/im-source-menu-item.c (+0/-407)
src/im-source-menu-item.h (+0/-54)
src/indicator-messages.c (+0/-382)
src/messages-service.c (+85/-550)
test/Makefile.am (+3/-2)
test/indicator-messages-service-activate.c (+4/-0)
test/test-gactionmuxer.cpp (+34/-0)
To merge this branch: bzr merge lp:~indicator-applet-developers/indicator-messages/consolidate
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Pete Woods (community) Approve
Review via email: mp+179964@code.launchpad.net

Commit message

Merge in phablet branch

Description of the change

Bring the messaging menu branches together. There can be only one. Still untested, getting Jenkins' comments.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ted Gould (ted) wrote :

If you have this branch you really want this GTK fix:

https://bugs.launchpad.net/ubuntu/+source/gtk+3.0/+bug/1212933

As the messaging menu will crash everything otherwise.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Allan LeSage (allanlesage) wrote :

This appears to have been a network hiccup, re-testing.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ted Gould (ted) wrote :

With r402 this works for me on the phone! Still needs the GTK patch to land before it can, but woot! \o/

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Pete Woods (pete-woods) wrote :

Installing and running on the desktop:
It seems to work to some degree. Empathy and Thunderbird have entries in the menu, but clicking on, e.g. "Inbox" doesn't seem to do anything.

Installing and running on the phone:
It seems to produce what seems like two messaging menus. One of them called "Messaging", and another called "indicator-messaging". The latter of the two doesn't have an icon. Also installing empathy / thunderbird doesn't seem to add anything to the menu.

I've also tried using the gir messaging API (taken from test/test-client.py) and the python example from libindicate to create a dummy messaging entry, but neither of those seem to work for me. It's totally possible I'm not using these correctly, though.

review: Needs Information
Revision history for this message
Ted Gould (ted) wrote :

On Mon, 2013-08-19 at 12:09 +0000, Pete Woods wrote:

> Installing and running on the desktop:
> It seems to work to some degree. Empathy and Thunderbird have entries
> in the menu, but clicking on, e.g. "Inbox" doesn't seem to do
> anything.

Hmm, I'll look into the activation, but I thought that was working.
Perhaps I broke it.

> Installing and running on the phone:
> It seems to produce what seems like two messaging menus. One of them
> called "Messaging", and another called "indicator-messaging". The
> latter of the two doesn't have an icon. Also installing empathy /
> thunderbird doesn't seem to add anything to the menu.

The two messaging menus is a Unity8 thing. That's expected, it'll go
away as we officially migrate to the new indicators. Also the design
doesn't allow for putting static items on the phone, they're only shown
with messages :-/

> I've also tried using the gir messaging API (taken from
> test/test-client.py) and the python example from libindicate to create
> a dummy messaging entry, but neither of those seem to work for me.
> It's totally possible I'm not using these correctly, though.

libindicate is deprecated, and but I'd expect the MessagingMenu-1.0 gir
file to work, though I haven't tested it. Is that what you used?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Pete Woods (pete-woods) wrote :

Well, this is a WFM type review. I've tested it with the app at (http://paste.ubuntu.com/6003296/).

This works both on the phone and the desktop (point the desktop file at an app that's already installed).

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

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

Subscribers

People subscribed via source and target branches

to all changes: