Differenze tra le versioni di "Far mostrare sulla Scrivania i messaggi della specifica Desktop Notifications mediante le funzioni esterne del API di Libnotify"

Da Gambas-it.org - Wikipedia.
Riga 1: Riga 1:
 
La libreria ''Libnotify'' è un'implementazione della specifica ''Desktop Notifications''. Essa permette di mostrare le classiche piccole finestre popup passive sul desktop che informano l'utente di particolari eventi.
 
La libreria ''Libnotify'' è un'implementazione della specifica ''Desktop Notifications''. Essa permette di mostrare le classiche piccole finestre popup passive sul desktop che informano l'utente di particolari eventi.
  
Per poter fruire in Gambas delle sue risorse, è necessario installare ed utilizzare la libreria dinamica condivisa: "''libnotify.so.4.0.0''"
+
Per poter fruire in Gambas delle sue risorse, è necessario installare ed utilizzare la libreria condivisa: "''libnotify.so.4.0.0'' ".
 
 
  
 
Mostriamo un semplice esempio dimostrativo:
 
Mostriamo un semplice esempio dimostrativo:
Riga 35: Riga 34:
 
   Dim notify As Pointer
 
   Dim notify As Pointer
 
    
 
    
    nome = "Notifica"
+
  nome = "Notifica"
 
    
 
    
    notify_init(nome)
+
  notify_init(nome)
 
      
 
      
    notify = notify_notification_new(nome, "Testo della notifica", Null)
+
  notify = notify_notification_new(nome, "Testo della notifica", Null)
 +
  If notify == 0 Then Error.Raise("Errore !")
 
      
 
      
 
  <FONT Color=gray>' ''Imposta il livello di urgenza della notifica:''</font>
 
  <FONT Color=gray>' ''Imposta il livello di urgenza della notifica:''</font>
    notify_notification_set_urgency(notify, NOTIFY_URGENCY_NORMAL)
+
  notify_notification_set_urgency(notify, NOTIFY_URGENCY_NORMAL)
 +
  notify_notification_show(notify, 0)
 
      
 
      
    notify_notification_show(notify, 0)
+
  g_object_unref(notify)
   
 
    g_object_unref(notify)
 
 
   
 
   
 
  '''End'''
 
  '''End'''
 
  
  

Versione delle 17:20, 1 gen 2022

La libreria Libnotify è un'implementazione della specifica Desktop Notifications. Essa permette di mostrare le classiche piccole finestre popup passive sul desktop che informano l'utente di particolari eventi.

Per poter fruire in Gambas delle sue risorse, è necessario installare ed utilizzare la libreria condivisa: "libnotify.so.4.0.0 ".

Mostriamo un semplice esempio dimostrativo:

Library "libnotify:4.0.0"

Private Enum NOTIFY_URGENCY_LOW = 0, NOTIFY_URGENCY_NORMAL, NOTIFY_URGENCY_CRITICAL

' gboolean notify_init (const char *app_name)
' Initialized libnotify.
Private Extern notify_init(app_name As String) As Boolean

' NotifyNotification * notify_notification_new (const char *summary, const char *body, const char *icon)
' Creates a new NotifyNotification.
Private Extern notify_notification_new(summary As String, body As String, icon As String) As Pointer

' void notify_notification_set_urgency (NotifyNotification *notification, NotifyUrgency urgency)
' Sets the urgency level of this notification. 
Private Extern notify_notification_set_urgency(notification As Pointer, urgency As Integer)

' gboolean notify_notification_show (NotifyNotification *notification, GError **error)
' Tells the notification server to display the notification on the screen.
Private Extern notify_notification_show(notification As Pointer, gerror As Pointer)

' void g_object_unref (gpointer object)
' Decreases the reference count of object.
Private Extern g_object_unref(gobject As Pointer)


Public Sub Main()

 Dim nome As String
 Dim notify As Pointer
 
 nome = "Notifica"
 
 notify_init(nome)
   
 notify = notify_notification_new(nome, "Testo della notifica", Null)
 If notify == 0 Then Error.Raise("Errore !")
   
' Imposta il livello di urgenza della notifica:
 notify_notification_set_urgency(notify, NOTIFY_URGENCY_NORMAL)
 notify_notification_show(notify, 0)
   
 g_object_unref(notify)

End


Riferimenti