notify-osd

Attachment 'summary-body.cs'

Download

   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:
  10 //    gmcs -pkg:notify-sharp summary-body.cs -out:summary-body.exe
  11 //    mono summary-body.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 SummaryBody
  36 {
  37 	enum Capability {
  38 		CAP_ACTIONS = 0,
  39 		CAP_BODY,
  40 		CAP_BODY_HYPERLINKS,
  41 		CAP_BODY_IMAGES,
  42 		CAP_BODY_MARKUP,
  43 		CAP_ICON_MULTI,
  44 		CAP_ICON_STATIC,
  45 		CAP_SOUND,
  46 		CAP_IMAGE_SVG,
  47 		CAP_SYNCHRONOUS,
  48 		CAP_APPEND,
  49 		CAP_LAYOUT_ICON_ONLY,
  50 		CAP_MAX}
  51 
  52 	static bool[] m_capabilities = {false,  // actions
  53 					false,  // body
  54 					false,  // body-hyperlinks
  55 					false,  // body-imges
  56 					false,  // body-markup
  57 					false,  // icon-multi
  58 					false,  // icon-static
  59 					false,  // sound
  60 					false,  // image/svg+xml
  61 					false,  // synchronous-hint
  62 					false,  // append-hint
  63 					false}; // icon-only-hint
  64 
  65 	private static void InitCaps ()
  66 	{
  67 
  68 		if (Global.Capabilities == null)
  69 			return;
  70 
  71 		if (Array.IndexOf (Global.Capabilities, "actions") > -1)
  72 			m_capabilities[(int) Capability.CAP_ACTIONS] = true;
  73 
  74 		if (Array.IndexOf (Global.Capabilities, "body") > -1)
  75 			m_capabilities[(int) Capability.CAP_BODY] = true;
  76 
  77 		if (Array.IndexOf (Global.Capabilities, "body-hyperlinks") > -1)
  78 			m_capabilities[(int) Capability.CAP_BODY_HYPERLINKS] = true;
  79 
  80 		if (Array.IndexOf (Global.Capabilities, "body-images") > -1)
  81 			m_capabilities[(int) Capability.CAP_BODY_IMAGES] = true;
  82 
  83 		if (Array.IndexOf (Global.Capabilities, "body-markup") > -1)
  84 			m_capabilities[(int) Capability.CAP_BODY_MARKUP] = true;
  85 
  86 		if (Array.IndexOf (Global.Capabilities, "icon-multi") > -1)
  87 			m_capabilities[(int) Capability.CAP_ICON_MULTI] = true;
  88 
  89 		if (Array.IndexOf (Global.Capabilities, "icon-static") > -1)
  90 			m_capabilities[(int) Capability.CAP_ICON_STATIC] = true;
  91 
  92 		if (Array.IndexOf (Global.Capabilities, "sound") > -1)
  93 			m_capabilities[(int) Capability.CAP_SOUND] = true;
  94 
  95 		if (Array.IndexOf (Global.Capabilities, "image/svg+xml") > -1)
  96 			m_capabilities[(int) Capability.CAP_IMAGE_SVG] = true;
  97 
  98 		if (Array.IndexOf (Global.Capabilities, "private-synchronous") > -1)
  99 			m_capabilities[(int) Capability.CAP_SYNCHRONOUS] = true;
 100 
 101 		if (Array.IndexOf (Global.Capabilities, "append") > -1)
 102 			m_capabilities[(int) Capability.CAP_APPEND] = true;
 103 
 104 		if (Array.IndexOf (Global.Capabilities, "private-icon-only") > -1)
 105 			m_capabilities[(int) Capability.CAP_LAYOUT_ICON_ONLY] = true;
 106 	}
 107 
 108 	private static void PrintCaps ()
 109 	{
 110 		Console.WriteLine ("Name:          "
 111 		                   + Global.ServerInformation.Name);
 112 		Console.WriteLine ("Vendor:        "
 113 		                   + Global.ServerInformation.Vendor);
 114 		Console.WriteLine ("Version:       "
 115 		                   + Global.ServerInformation.Version);
 116 		Console.WriteLine ("Spec. Version: "
 117 		                   + Global.ServerInformation.SpecVersion);
 118 
 119 		Console.WriteLine ("Supported capabilities/hints:");
 120 		if (m_capabilities[(int) Capability.CAP_ACTIONS])
 121 			Console.WriteLine ("\tactions");
 122 		if (m_capabilities[(int) Capability.CAP_BODY])
 123 			Console.WriteLine ("\tbody");
 124 		if (m_capabilities[(int) Capability.CAP_BODY_HYPERLINKS])
 125 			Console.WriteLine ("\tbody-hyperlinks");
 126 		if (m_capabilities[(int) Capability.CAP_BODY_IMAGES])
 127 			Console.WriteLine ("\tbody-images");
 128 		if (m_capabilities[(int) Capability.CAP_BODY_MARKUP])
 129 			Console.WriteLine ("\tbody-markup");
 130 		if (m_capabilities[(int) Capability.CAP_ICON_MULTI])
 131 			Console.WriteLine ("\ticon-multi");
 132 		if (m_capabilities[(int) Capability.CAP_ICON_STATIC])
 133 			Console.WriteLine ("\ticon-static");
 134 		if (m_capabilities[(int) Capability.CAP_SOUND])
 135 			Console.WriteLine ("\tsound");
 136 		if (m_capabilities[(int) Capability.CAP_IMAGE_SVG])
 137 			Console.WriteLine ("\timage/svg+xml");
 138 		if (m_capabilities[(int) Capability.CAP_SYNCHRONOUS])
 139 			Console.WriteLine ("\tprivate-synchronous");
 140 		if (m_capabilities[(int) Capability.CAP_APPEND])
 141 			Console.WriteLine ("\tappend");
 142 		if (m_capabilities[(int) Capability.CAP_LAYOUT_ICON_ONLY])
 143 			Console.WriteLine ("\tprivate-icon-only");
 144 
 145 		Console.WriteLine ("Notes:");
 146 		if (Global.ServerInformation.Name == "notify-osd")
 147 		{
 148 			Console.WriteLine ("\tx- and y-coordinates hints are ignored");
 149 			Console.WriteLine ("\texpire-timeout is ignored");
 150 			Console.WriteLine ("\tbody-markup is accepted but filtered");			
 151 		}
 152 		else
 153 			Console.WriteLine ("\tnone");
 154 	}
 155 
 156 	public static void Main ()
 157 	{
 158 		// call this so we can savely use the m_capabilities array later
 159 		InitCaps ();
 160 
 161 		// show what's supported
 162 		PrintCaps ();
 163 
 164 		// try the summary-body case
 165 		Notification n = new Notification ("Totem",
 166 		                                   "This is a superfluous notification.");
 167 		n.Show ();
 168 	}
 169 }

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2009-02-25 22:40:59, 8.2 KB) [[attachment:append-hint-example.c]]
  • [get | view] (2009-02-25 22:41:05, 6.3 KB) [[attachment:append-hint-example.cs]]
  • [get | view] (2009-02-25 15:44:14, 931.0 KB) [[attachment:append-hint-example.ogg]]
  • [get | view] (2009-02-25 22:41:10, 4.1 KB) [[attachment:append-hint-example.py]]
  • [get | view] (2009-02-25 22:41:58, 6.8 KB) [[attachment:icon-summary-body.c]]
  • [get | view] (2009-02-25 22:42:06, 5.8 KB) [[attachment:icon-summary-body.cs]]
  • [get | view] (2009-02-25 23:32:31, 25.9 KB) [[attachment:icon-summary-body.png]]
  • [get | view] (2010-01-13 10:26:42, 3.6 KB) [[attachment:icon-summary-body.py]]
  • [get | view] (2009-02-25 22:41:37, 6.7 KB) [[attachment:icon-summary.c]]
  • [get | view] (2009-02-25 22:41:42, 5.7 KB) [[attachment:icon-summary.cs]]
  • [get | view] (2009-02-25 23:32:25, 21.8 KB) [[attachment:icon-summary.png]]
  • [get | view] (2009-02-25 22:41:48, 3.5 KB) [[attachment:icon-summary.py]]
  • [get | view] (2009-02-25 17:28:21, 39.8 KB) [[attachment:small_append-hint-example_ogg.png]]
  • [get | view] (2009-03-02 00:26:37, 31.5 KB) [[attachment:small_update-notifications_ogg.png]]
  • [get | view] (2009-02-25 22:42:54, 6.7 KB) [[attachment:summary-body.c]]
  • [get | view] (2009-02-25 22:43:06, 5.7 KB) [[attachment:summary-body.cs]]
  • [get | view] (2009-02-25 23:32:55, 22.4 KB) [[attachment:summary-body.png]]
  • [get | view] (2009-02-25 22:43:22, 3.5 KB) [[attachment:summary-body.py]]
  • [get | view] (2009-02-25 22:43:29, 6.7 KB) [[attachment:summary-only.c]]
  • [get | view] (2009-02-25 22:43:35, 5.6 KB) [[attachment:summary-only.cs]]
  • [get | view] (2009-02-25 23:33:04, 20.3 KB) [[attachment:summary-only.png]]
  • [get | view] (2009-02-25 22:43:42, 3.5 KB) [[attachment:summary-only.py]]
  • [get | view] (2009-03-01 07:01:45, 8.5 KB) [[attachment:update-notifications.c]]
  • [get | view] (2009-03-01 07:01:53, 6.6 KB) [[attachment:update-notifications.cs]]
  • [get | view] (2009-03-01 07:02:38, 1226.6 KB) [[attachment:update-notifications.ogg]]
  • [get | view] (2009-03-01 07:01:59, 4.3 KB) [[attachment:update-notifications.py]]
 All files | Selected Files: delete move to page

You are not allowed to attach a file to this page.