303
by Mirco Müller
added examples form development-guidelines |
1 |
////////////////////////////////////////////////////////////////////////////////
|
2 |
//3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
|
|
3 |
// 10 20 30 40 50 60 70 80
|
|
4 |
//
|
|
5 |
// Info:
|
|
6 |
// Example of how to use libnotify correctly and at the same time comply to
|
|
7 |
// the new jaunty notification spec (read: visual guidelines)
|
|
8 |
//
|
|
9 |
// Compile and run:
|
|
304
by Mirco Müller
use new utility class in all C#-examples |
10 |
// gmcs -pkg:notify-sharp example-util.cs icon-value.cs -out:icon-value.exe
|
303
by Mirco Müller
added examples form development-guidelines |
11 |
// mono icon-value.exe
|
12 |
//
|
|
13 |
// Copyright 2009 Canonical Ltd.
|
|
14 |
//
|
|
15 |
// Author:
|
|
16 |
// Mirco "MacSlow" Mueller <mirco.mueller@canonical.com>
|
|
17 |
//
|
|
18 |
// This program is free software: you can redistribute it and/or modify it
|
|
19 |
// under the terms of the GNU General Public License version 3, as published
|
|
20 |
// by the Free Software Foundation.
|
|
21 |
//
|
|
22 |
// This program is distributed in the hope that it will be useful, but
|
|
23 |
// WITHOUT ANY WARRANTY; without even the implied warranties of
|
|
24 |
// MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
|
|
25 |
// PURPOSE. See the GNU General Public License for more details.
|
|
26 |
//
|
|
27 |
// You should have received a copy of the GNU General Public License along
|
|
28 |
// with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
29 |
//
|
|
30 |
////////////////////////////////////////////////////////////////////////////////
|
|
31 |
||
32 |
using System; |
|
33 |
using Notifications; |
|
34 |
||
35 |
public class IconValue |
|
36 |
{
|
|
307
by Mirco Müller
under- and overshoot-effects for icon-value layout-case are now triggered for passed values -1 and 101, also updated examples and test-script to reflect this, fixes LP: #337820 |
37 |
public static void pushNotification (String icon, |
38 |
int val) |
|
39 |
{
|
|
40 |
Notification n = new Notification ("Brightness", // for a11y-reasons supply something meaning full |
|
41 |
"", // this needs to be empty! |
|
42 |
icon); |
|
43 |
n.AddHint ("value", val); |
|
44 |
n.AddHint ("x-canonical-private-synchronous", ""); |
|
45 |
n.Show (); |
|
46 |
Mono.Unix.Native.Syscall.sleep (1); |
|
47 |
}
|
|
48 |
||
303
by Mirco Müller
added examples form development-guidelines |
49 |
public static void Main () |
50 |
{
|
|
51 |
// call this so we can savely use the m_capabilities array later
|
|
304
by Mirco Müller
use new utility class in all C#-examples |
52 |
ExampleUtil.InitCaps (); |
303
by Mirco Müller
added examples form development-guidelines |
53 |
|
54 |
// show what's supported
|
|
304
by Mirco Müller
use new utility class in all C#-examples |
55 |
ExampleUtil.PrintCaps (); |
303
by Mirco Müller
added examples form development-guidelines |
56 |
|
57 |
// try the icon-value case, usually used for synchronous bubbles
|
|
304
by Mirco Müller
use new utility class in all C#-examples |
58 |
if (ExampleUtil.HasCap (ExampleUtil.Capability.CAP_SYNCHRONOUS)) |
303
by Mirco Müller
added examples form development-guidelines |
59 |
{
|
307
by Mirco Müller
under- and overshoot-effects for icon-value layout-case are now triggered for passed values -1 and 101, also updated examples and test-script to reflect this, fixes LP: #337820 |
60 |
pushNotification ("notification-keyboard-brightness-low", |
61 |
25); |
|
62 |
||
63 |
pushNotification ("notification-keyboard-brightness-medium", |
|
64 |
50); |
|
65 |
||
66 |
pushNotification ("notification-keyboard-brightness-high", |
|
67 |
75); |
|
68 |
||
69 |
pushNotification ("notification-keyboard-brightness-full", |
|
70 |
100); |
|
71 |
||
72 |
// trigger "overshoot"-effect
|
|
73 |
pushNotification ("notification-keyboard-brightness-full", |
|
74 |
101); |
|
75 |
||
76 |
pushNotification ("notification-keyboard-brightness-high", |
|
77 |
75); |
|
78 |
||
79 |
pushNotification ("notification-keyboard-brightness-medium", |
|
80 |
50); |
|
81 |
||
82 |
pushNotification ("notification-keyboard-brightness-low", |
|
83 |
25); |
|
84 |
||
85 |
pushNotification ("notification-keyboard-brightness-off", |
|
86 |
0); |
|
87 |
||
88 |
// trigger "undershoot"-effect
|
|
89 |
pushNotification ("notification-keyboard-brightness-off", |
|
90 |
-1); |
|
303
by Mirco Müller
added examples form development-guidelines |
91 |
}
|
92 |
else
|
|
93 |
Console.WriteLine ("The daemon does not support the x-canonical-private-synchronous hint!"); |
|
94 |
||
95 |
}
|
|
96 |
}
|