NotificationDevelopmentGuidelines

Differences between revisions 1 and 16 (spanning 15 versions)
Revision 1 as of 2009-02-20 17:15:20
Size: 1360
Editor: dslb-084-063-099-000
Comment:
Revision 16 as of 2009-02-25 17:38:24
Size: 7738
Editor: dslb-084-063-099-000
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
This is a place holder, please don't mess around with this <<TableOfContents>>
Line 11: Line 11:

'''Example code from VLC (broken):'''

{{{
notify_notification_add_action(notification, "previous",
                               _("Previous"), Prev,
                               (gpointer*) p_intf, NULL);
notify_notification_add_action(notification, "next",
                               _("Next"), Next,
                               (gpointer*) p_intf, NULL );
}}}

'''Example code (fixed):'''

{{{
caps = notify_get_server_caps();
if(caps != NULL) {
  for(c = caps; c != NULL; c = c->next) {
    if(strcmp((char*)c->data, "actions") == 0 ) {
      supports_actions = TRUE;
      break;
    }
  }

  g_list_foreach(caps, (GFunc)g_free, NULL);
  g_list_free(caps);
}

/* Adds previous and next buttons in the notification if actions are supported. */
if(supports_actions) {
  notify_notification_add_action(notification, "previous",
                                 _("Previous"), Prev,
                                 (gpointer*) p_intf, NULL);
  notify_notification_add_action(notification, "next",
                                 _("Next"), Next,
                                 (gpointer*) p_intf, NULL);
}
}}}

Line 12: Line 52:
 * C#  * C#:
Line 14: Line 54:
== Layout cases ==
 * Icon-Summary-Body - e.g. IM-message
In C# you should check the existence of "actions" in Notifications.Global.Capabilities. This is easy with Array.IndexOf such as:
Line 17: Line 56:
 * Icon-Summary - e.g. Wifi connection lost {{{
bool actions_supported = Notifications.Global.Capabilities != null &&
                    Array.IndexOf(Notifications.Global.Capabilities, "actions") > -1
}}}
Line 19: Line 61:
 * Icon-only - e.g. eject CD '''Example code from Banshee:'''
Line 21: Line 63:
 * Summary-Body - e.g. bla {{{
Notification nf = new Notification (Catalog.GetString("Now Playing"),
                                    message, image, notif_area.Widget);
if (interface_action_service.PlaybackActions["NextAction"].Sensitive) {
  nf.AddAction("skip-song", Catalog.GetString("Skip this item"), OnSongSkipped);
}
Line 23: Line 70:
 * Summary-only - works but is discouraged nf.Show();
}}}
Line 25: Line 73:
 * Icon-Value - e.g. keyboard-brightness '''After notification fixes:'''
Line 27: Line 75:
Everything else will give you an empty bubble (no-layout-case) or cause an ugly fallback-dialog done in GTK+ if non-supported capabilities are used {{{
Notification nf = new Notification (Catalog.GetString ("Now Playing"),
                                    message, image, notif_area.Widget);
bool actions_supported = Notifications.Global.Capabilities != null &&
                     Array.IndexOf (Notifications.Global.Capabilities, "actions") > -1;
if (interface_action_service.PlaybackActions["NextAction"].Sensitive &&
    actions_supported) {
  nf.AddAction ("skip-song", Catalog.GetString("Skip this item"), OnSongSkipped);
}
Line 29: Line 85:
== Synchronous vs. Asynchronous notifications ==
bla
nf.Show ();
}}}


== Layout cases (with examples in C, Python and C#) ==
Everything not listed as a valid layout will lead to a "no-layout"-case (results in an empty notification-bubble). Also using non-existing (stock-)icon-names results in empty notification-bubbles. Common caues for the latter could be that the user has not set "Human" as the icon-theme and a notification is trying to use one of the new icon-name (see [[#icons|icons]]). The comment header of each sourcecode example contains compilation and run instructions. NOTE: The C#-examples don't format and display in thie MoinMoin wiki. You can only download them directly to your harddisk. Sorry for the inconvenience!

=== Icon-Summary-Body ===
{{attachment:icon-summary-body.png}}<<BR>>
example: IM-message
 * [[attachment:icon-summary-body.c|example in C]]
 * [[attachment:icon-summary-body.py|example in Python]]
 * [[attachment:icon-summary-body.cs|example in C#]]

=== Icon-Summary ===
{{attachment:icon-summary.png}}<<BR>>
example: Wifi connection lost
 * [[attachment:icon-summary.c|example in C]]
 * [[attachment:icon-summary.py|example in Python]]
 * [[attachment:icon-summary.cs|example in C#]]

=== Summary-Body ===
{{attachment:summary-body.png}}<<BR>>
example: a very simple notification-bubble
 * [[attachment:summary-body.c|example in C]]
 * [[attachment:summary-body.py|example in Python]]
 * [[attachment:summary-body.cs|example in C#]]

=== Summary-only ===
{{attachment:summary-only.png}}<<BR>>
This layout-case works, but is strongly discouraged. Avoid it if you can.
 * [[attachment:summary-only.c|example in C]]
 * [[attachment:summary-only.py|example in Python]]
 * [[attachment:summary-only.cs|example in C#]]
Line 33: Line 121:
You can use a special hint to... [[{{attachment:append-hint-example.ogg}}|{{attachment:small_append-hint-example_ogg.png}}]]<<BR>>
For IM-clients (like pidgin) you can use the append-hint ("append").
 * [[attachment:append-hint-example.c|example in C]]
 * [[attachment:append-hint-example.py|example in Python]]
 * [[attachment:append-hint-example.cs|example in C#]]
Line 35: Line 127:
== How to use the value-hint ==
For notifications like the volume-display...
Under/Overshoot
== How to update an existing notification-bubble ==
code

<<Anchor(icons)>>
Line 40: Line 133:
The use has to be using the Human icon-theme. The available icon-names are ... (might add the icon-matrix of the design team here). Otherwise GNOME's fallback icons are used The user has to be using the Human icon-theme. Have a look at the [[https://wiki.ubuntu.com/NotifyOSD#Icon|icon-matrix]]. Or if a different icon-theme is selected, default icons satisfying the new icon-names are used. These will look different of course. The available icon-names are...
 * notification-audio-next
 * notification-audio-play
 * notification-audio-previous
 * notification-audio-volume-high
 * notification-audio-volume-low
 * notification-audio-volume-medium
 * notification-audio-volume-muted
 * notification-audio-volume-off
 * notification-battery-low
 * notification-device-eject
 * notification-device-firewire
 * notification-display-brightness-full
 * notification-display-brightness-high
 * notification-display-brightness-low
 * notification-display-brightness-medium
 * notification-display-brightness-off
 * notification-GSM-3G-full
 * notification-GSM-3G-high
 * notification-GSM-3G-low
 * notification-GSM-3G-medium
 * notification-GSM-3G-none
 * notification-GSM-disconnected
 * notification-GSM-EDGE-full
 * notification-GSM-EDGE-high
 * notification-GSM-EDGE-low
 * notification-GSM-EDGE-medium
 * notification-GSM-EDGE-none
 * notification-GSM-full
 * notification-GSM-H-full
 * notification-GSM-H-high
 * notification-GSM-high
 * notification-GSM-H-low
 * notification-GSM-H-medium
 * notification-GSM-H-none
 * notification-GSM-low
 * notification-GSM-medium
 * notification-GSM-none
 * notification-keyboard-brightness-full
 * notification-keyboard-brightness-high
 * notification-keyboard-brightness-low
 * notification-keyboard-brightness-medium
 * notification-keyboard-brightness-off
 * notification-message-email
 * notification-message-IM
 * notification-network-ethernet-connected
 * notification-network-ethernet-disconnected
 * notification-network-wireless-disconnected
 * notification-network-wireless-full
 * notification-network-wireless-high
 * notification-network-wireless-low
 * notification-network-wireless-medium
 * notification-network-wireless-none
 * notification-power-disconnected
... and are located under [[file:///usr/share/icons/Human/scalable/status|/usr/share/icons/Human/scalable/status]]. Until symlinks or updated icons for other icon-themes are installed (provided by updated packages) using these without the icon-theme being set to Human will fail to display the intended icon. The result is an empty notification-bubble. You can still of course use full file paths to .svg/.png/.jpg icons.
Line 43: Line 190:
 * timeout Do not use any of these...
 * expire-timeout
Line 45: Line 193:
 * html-markup in you summary- or body-text  * html-markup (read: URL) in you summary- or body-text
If you do you'll either get a fallback GTK+-dialog or notification-bubble with no contents at all.

How to use libnotify

And comply to the new jaunty notifications spec at the same time

How to be a good citizen

Use all of libnotify's API ... query a notification-server's name and capabilities and don't just assume anything. If you don't -> no ponies for you

Target developer-audience

  • C

Example code from VLC (broken):

notify_notification_add_action(notification, "previous",
                               _("Previous"), Prev,
                               (gpointer*) p_intf, NULL);
notify_notification_add_action(notification, "next",
                               _("Next"), Next,
                               (gpointer*) p_intf, NULL );

Example code (fixed):

caps = notify_get_server_caps();
if(caps != NULL) {
  for(c = caps; c != NULL; c = c->next) {
    if(strcmp((char*)c->data, "actions") == 0 ) {
      supports_actions = TRUE;
      break;
    }
  }

  g_list_foreach(caps, (GFunc)g_free, NULL);
  g_list_free(caps);
}

/* Adds previous and next buttons in the notification if actions are supported. */
if(supports_actions) {
  notify_notification_add_action(notification, "previous",
                                 _("Previous"), Prev,
                                 (gpointer*) p_intf, NULL);
  notify_notification_add_action(notification, "next",
                                 _("Next"), Next,
                                 (gpointer*) p_intf, NULL);
}
  • Python
  • C#:

In C# you should check the existence of "actions" in Notifications.Global.Capabilities. This is easy with Array.IndexOf such as:

bool actions_supported = Notifications.Global.Capabilities != null &&
                    Array.IndexOf(Notifications.Global.Capabilities, "actions") > -1

Example code from Banshee:

Notification nf = new Notification (Catalog.GetString("Now Playing"),
                                    message, image, notif_area.Widget);
if (interface_action_service.PlaybackActions["NextAction"].Sensitive) {
  nf.AddAction("skip-song", Catalog.GetString("Skip this item"), OnSongSkipped);
}

nf.Show();

After notification fixes:

Notification nf = new Notification (Catalog.GetString ("Now Playing"),
                                    message, image, notif_area.Widget);
bool actions_supported = Notifications.Global.Capabilities != null &&
                     Array.IndexOf (Notifications.Global.Capabilities, "actions") > -1;
if (interface_action_service.PlaybackActions["NextAction"].Sensitive &&
    actions_supported) {
  nf.AddAction ("skip-song", Catalog.GetString("Skip this item"), OnSongSkipped);
}

nf.Show ();

Layout cases (with examples in C, Python and C#)

Everything not listed as a valid layout will lead to a "no-layout"-case (results in an empty notification-bubble). Also using non-existing (stock-)icon-names results in empty notification-bubbles. Common caues for the latter could be that the user has not set "Human" as the icon-theme and a notification is trying to use one of the new icon-name (see icons). The comment header of each sourcecode example contains compilation and run instructions. NOTE: The C#-examples don't format and display in thie MoinMoin wiki. You can only download them directly to your harddisk. Sorry for the inconvenience!

Icon-Summary-Body

icon-summary-body.png
example: IM-message

Icon-Summary

icon-summary.png
example: Wifi connection lost

Summary-Body

summary-body.png
example: a very simple notification-bubble

Summary-only

summary-only.png
This layout-case works, but is strongly discouraged. Avoid it if you can.

How to use the append-hint

{{attachment:append-hint-example.ogg}}
For IM-clients (like pidgin) you can use the append-hint ("append").

How to update an existing notification-bubble

code

How do I get these slick icons

The user has to be using the Human icon-theme. Have a look at the icon-matrix. Or if a different icon-theme is selected, default icons satisfying the new icon-names are used. These will look different of course. The available icon-names are...

  • notification-audio-next
  • notification-audio-play
  • notification-audio-previous
  • notification-audio-volume-high
  • notification-audio-volume-low
  • notification-audio-volume-medium
  • notification-audio-volume-muted
  • notification-audio-volume-off
  • notification-battery-low
  • notification-device-eject
  • notification-device-firewire
  • notification-display-brightness-full
  • notification-display-brightness-high
  • notification-display-brightness-low
  • notification-display-brightness-medium
  • notification-display-brightness-off
  • notification-GSM-3G-full
  • notification-GSM-3G-high
  • notification-GSM-3G-low
  • notification-GSM-3G-medium
  • notification-GSM-3G-none
  • notification-GSM-disconnected
  • notification-GSM-EDGE-full
  • notification-GSM-EDGE-high
  • notification-GSM-EDGE-low
  • notification-GSM-EDGE-medium
  • notification-GSM-EDGE-none
  • notification-GSM-full
  • notification-GSM-H-full
  • notification-GSM-H-high
  • notification-GSM-high
  • notification-GSM-H-low
  • notification-GSM-H-medium
  • notification-GSM-H-none
  • notification-GSM-low
  • notification-GSM-medium
  • notification-GSM-none
  • notification-keyboard-brightness-full
  • notification-keyboard-brightness-high
  • notification-keyboard-brightness-low
  • notification-keyboard-brightness-medium
  • notification-keyboard-brightness-off
  • notification-message-email
  • notification-message-IM
  • notification-network-ethernet-connected
  • notification-network-ethernet-disconnected
  • notification-network-wireless-disconnected
  • notification-network-wireless-full
  • notification-network-wireless-high
  • notification-network-wireless-low
  • notification-network-wireless-medium
  • notification-network-wireless-none
  • notification-power-disconnected

... and are located under /usr/share/icons/Human/scalable/status. Until symlinks or updated icons for other icon-themes are installed (provided by updated packages) using these without the icon-theme being set to Human will fail to display the intended icon. The result is an empty notification-bubble. You can still of course use full file paths to .svg/.png/.jpg icons.

What will get you burnt

Do not use any of these...

  • expire-timeout
  • actions
  • html-markup (read: URL) in you summary- or body-text

If you do you'll either get a fallback GTK+-dialog or notification-bubble with no contents at all.

NotificationDevelopmentGuidelines (last edited 2010-08-25 15:53:12 by 121)