Skip to content
API Documentation
BastionGuard™
OSDNotify Class Reference
Inheritance diagram for OSDNotify:

Static Public Member Functions

static int notify_send (string title, string message, int durationMillis, string urgency="low", string dialog_type="info")
static bool is_supported ()

Static Public Attributes

const int NOTIFICATION_INTERVAL = 3

Static Private Attributes

static DateTime dt_last_notification = null

Detailed Description

Definition at line 30 of file OSDNotify.vala.

Member Function Documentation

◆ is_supported()

bool OSDNotify.is_supported ( )
inlinestatic

Definition at line 83 of file OSDNotify.vala.

83 {
84 return cmd_exists("notify-send");
85 }

Referenced by notify_send().

◆ notify_send()

int OSDNotify.notify_send ( string title,
string message,
int durationMillis,
string urgency = "low",
string dialog_type = "info" )
inlinestatic

Definition at line 35 of file OSDNotify.vala.

39 {
40
41 /* Displays notification bubble on the desktop */
42
43 int retVal = 0;
44
45 switch (dialog_type){
46 case "error":
47 case "info":
48 case "warning":
49 //ok
50 break;
51 default:
52 dialog_type = "info";
53 break;
54 }
55
56 long seconds = 9999;
57
58 if (dt_last_notification != null){
59 DateTime dt_end = new DateTime.now_local();
60 TimeSpan elapsed = dt_end.difference(dt_last_notification);
61 seconds = (long)(elapsed * 1.0 / TimeSpan.SECOND);
62 }
63
64 if (seconds > NOTIFICATION_INTERVAL){
65
66 if (is_supported()){
67
68 string desktop_entry = "bastionguard-backup-gtk";
69 string hint = "string:desktop-entry:%s".printf(desktop_entry);
70
71 string s = "notify-send -t %d -u %s -i %s \"%s\" \"%s\" -h %s".printf(
72 durationMillis, urgency, "gtk-dialog-" + dialog_type, title, message, hint);
73
74 retVal = TeeJee.ProcessHelper.exec_user_async(s);
75
76 dt_last_notification = new DateTime.now_local();
77 }
78 }
79
80 return retVal;
81 }
const int NOTIFICATION_INTERVAL
static DateTime dt_last_notification
static bool is_supported()

References dt_last_notification, is_supported(), and NOTIFICATION_INTERVAL.

Referenced by Main.create_snapshot_for_tag(), and Main.delete_thread().

Member Data Documentation

◆ dt_last_notification

DateTime OSDNotify.dt_last_notification = null
staticprivate

Definition at line 32 of file OSDNotify.vala.

Referenced by notify_send().

◆ NOTIFICATION_INTERVAL

const int OSDNotify.NOTIFICATION_INTERVAL = 3
static

Definition at line 33 of file OSDNotify.vala.

Referenced by notify_send().


The documentation for this class was generated from the following file:
  • BastionGuard/thirdparty/bastionguard-backup/src/Utility/OSDNotify.vala