Sha256: a3e204d93ce1c4186de8d65509f85cce94eb6b0a65ad760b7795526ac2c2b3ad

Contents?: true

Size: 850 Bytes

Versions: 5

Compression:

Stored size: 850 Bytes

Contents

#
# Simple notification example.
#
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
require 'ffi-gtk3'

GirFFI.setup :Notify

# Both Gtk and Notify need to be init'ed.
Gtk.init
Notify.init "notification test"

# Basic set up of the notification.
nf = Notify::Notification.new "Hello!", "Hi there.", "gtk-dialog-info"
nf.set_timeout 3000
nf.set_urgency :critical

# Show a button 'Test' in the notification, with a callback function.
nf.add_action "test", "Test", Proc.new { |obj, action, user_data|
  puts "Action #{action} clicked."
}, nil, nil

# In this case, we want the program to end once the notification is gone,
# but not before.
GObject.signal_connect(nf, "closed") {
  puts "Notification closed."
  Gtk.main_quit
}

# Show the notification.
nf.show

# Start a main loop to wait for the notification to be closed.
Gtk.main

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gir_ffi-0.2.3 examples/05_notification.rb
gir_ffi-0.2.2 examples/05_notification.rb
gir_ffi-0.2.1 examples/05_notification.rb
gir_ffi-0.2.0 examples/05_notification.rb
gir_ffi-0.1.0 examples/05_notification.rb