In Files

Parent

Class/Module Index [+]

Quicksearch

Notify::Notification

Public Class Methods

new(summ, msg, icon) click to toggle source

summ = The summary text (required)

msg = The body text or nil

icon = The icon or nil

Creates and returns a new notification, throw an exception on error

static VALUE
_wrap_notification_init(VALUE self, VALUE summ, VALUE msg, VALUE icon)
{
  char *nsumm = NIL_P(summ) ? NULL : StringValuePtr(summ);
  NotifyNotification *n = NULL;

  if(nsumm == NULL || *nsumm == '\0')
    rb_raise(rb_eArgError, "You need to supply a valid summary string");

  n = notify_notification_new(nsumm,
                              NIL_P(msg) ? NULL : StringValuePtr(msg),
                              NIL_P(icon) ? NULL : StringValuePtr(icon));

  if(n == NULL)
    rb_raise(rb_eRuntimeError, "Can not create a new notification");

  G_INITIALIZE(self, n);

#ifdef DEBUG
  rb_warn("init, ok");
#endif

  return self;
}

Public Instance Methods

add_action(action, label, user_data) { |action, user_data| ... } click to toggle source

action = The action id

label = The action label

user_data = Custom data to pass into the block (optional)

Adds an action. When the action is invoked, the specified block will be called

Examples:

myinstance.add_action( “MyAction”, “MyLabel” ) do |action|

# something to do

end

Or

myinstance.add_action( “MyAction”, “MyLabel”, MyData ) do |action, mydata|

# something to do

end

static VALUE
_wrap_notification_add_action(int argc, VALUE *argv, VALUE self)
{
  NotifyNotification *n = NOTIFY_NOTIFICATION(RVAL2GOBJ(self));
  VALUE action, label, data, body;
  ActionData *actionData = NULL;

#ifdef DEBUG
  if(NOTIFY_IS_NOTIFICATION(n))
    rb_warn("add_action, ok");
  else
    rb_warn("add_action, no ok");
#endif

  if(!rb_block_given_p())
    rb_raise(rb_eRuntimeError, "This method requires a block");

  rb_scan_args(argc, argv, "21&", &action, &label, &data, &body);

  actionData = g_new0(ActionData, 1);
  actionData->callback = body;
  actionData->action = action;
  actionData->user_data = data;

  notify_notification_add_action(n,
                                 NIL_P(action) ? NULL : StringValuePtr(action),
                                 NIL_P(label) ? NULL : StringValuePtr(label),
                                 NOTIFY_ACTION_CALLBACK(_notification_action_cb),
                                 actionData, (GFreeFunc)_notification_action_free);

  return Qnil;
}
category=(category_name) click to toggle source

category_name = The category name

Sets the category

static VALUE
_wrap_notification_set_category(VALUE self, VALUE cat_name)
{
  char *cname = NIL_P(cat_name) ? NULL : StringValuePtr(cat_name);
  NotifyNotification *n = NOTIFY_NOTIFICATION(RVAL2GOBJ(self));

#ifdef DEBUG
  if(NOTIFY_IS_NOTIFICATION(n))
    rb_warn("set_category, ok");
  else
    rb_warn("set_category, not ok");
#endif

  notify_notification_set_category(n, cname);

  return Qnil;
}
clear_actions click to toggle source

Clears all actions from the notification. Remember to use this method before call the Notification#close method.

static VALUE
_wrap_notification_clear_actions(VALUE self)
{
  NotifyNotification *n = NOTIFY_NOTIFICATION(RVAL2GOBJ(self));

#ifdef DEBUG
  if(NOTIFY_IS_NOTIFICATION(n))
    rb_warn("clear_actions, ok");
  else
    rb_warn("clear_actions, no ok");
#endif

  notify_notification_clear_actions(n);

  return Qnil;
}
clear_hints click to toggle source

Clears all hints from the notification. Remember to use this method before call the Notification#close method.

static VALUE
_wrap_notification_clear_hints(VALUE self)
{
  NotifyNotification *n = NOTIFY_NOTIFICATION(RVAL2GOBJ(self));

#ifdef DEBUG
  if(NOTIFY_IS_NOTIFICATION(n))
    rb_warn("clear_hints, ok");
  else
    rb_warn("clear_hints, no ok");
#endif

  notify_notification_clear_hints(n);

  return Qnil;
}
close click to toggle source

Tells the notification server to hide the notification on the screen.

static VALUE
_wrap_notification_close(VALUE self)
{
  NotifyNotification *n = NOTIFY_NOTIFICATION(RVAL2GOBJ(self));

#ifdef DEBUG
  if(NOTIFY_IS_NOTIFICATION(n))
    rb_warn("close, ok");
  else
    rb_warn("close, no ok");
#endif

  if(notify_notification_close(n, NULL))
    return Qtrue;

  return Qfalse;
}
closed_reason click to toggle source

Returns the reason code why the notification was closed

static VALUE
_wrap_notification_get_closed_reason(VALUE self)
{
  NotifyNotification *n = NOTIFY_NOTIFICATION(RVAL2GOBJ(self));
  int reason = -1;

#ifdef DEBUG
  if(NOTIFY_IS_NOTIFICATION(n))
    rb_warn("closed_reason, ok");
  else
    rb_warn("closed_reason, no ok");
#endif

  reason = notify_notification_get_closed_reason(n);

  return INT2FIX(reason);
}
hint32(key, value) click to toggle source
*

key = The hint

value = The hint’s value

Sets a hint with a 32-bit integer value

static VALUE
_wrap_notification_set_hint32(VALUE self, VALUE key, VALUE value)
{
  char *vkey = NIL_P(key) ? NULL : StringValuePtr(key);
  NotifyNotification *n = NOTIFY_NOTIFICATION(RVAL2GOBJ(self));

#ifdef DEBUG
  if(NOTIFY_IS_NOTIFICATION(n))
    rb_warn("set_hint32, ok");
  else
    rb_warn("set_hint32, no ok");
#endif

  notify_notification_set_hint_int32(n, vkey, FIX2INT(value));

  return Qnil;
}
hint_byte(key, value) click to toggle source
*

key = The hint

value = The hint’s value

Sets a hint with a byte value

static VALUE
_wrap_notification_set_hint_byte(VALUE self, VALUE key, VALUE value)
{
  char *vkey = NIL_P(key) ? NULL : StringValuePtr(key);
  NotifyNotification *n = NOTIFY_NOTIFICATION(RVAL2GOBJ(self));

#ifdef DEBUG
  if(NOTIFY_IS_NOTIFICATION(n))
    rb_warn("set_hint_byte, ok");
  else
    rb_warn("set_hint_byte, no ok");
#endif

  notify_notification_set_hint_byte(n, vkey, FIX2INT(value));

  return Qnil;
}
hint_double(key, value) click to toggle source
*

key = The hint

value = The hint’s value

Sets a hint with a double value

static VALUE
_wrap_notification_set_hint_double(VALUE self, VALUE key, VALUE value)
{
  char *vkey = NIL_P(key) ? NULL : StringValuePtr(key);
  NotifyNotification *n = NOTIFY_NOTIFICATION(RVAL2GOBJ(self));

#ifdef DEBUG
  if(NOTIFY_IS_NOTIFICATION(n))
    rb_warn("set_hint_double, ok");
  else
    rb_warn("set_hint_double, no ok");
#endif

  notify_notification_set_hint_double(n, vkey, NUM2DBL(value));

  return Qnil;
}
hint_string(key, value) click to toggle source
*

key = The hint

value = The hint’s value

Sets a hint with a string value

static VALUE
_wrap_notification_set_hint_string(VALUE self, VALUE key, VALUE value)
{
  char *vkey = NIL_P(key) ? NULL : StringValuePtr(key);
  char *vvalue = NIL_P(value) ? NULL : StringValuePtr(value);
  NotifyNotification *n = NOTIFY_NOTIFICATION(RVAL2GOBJ(self));

#ifdef DEBUG
  if(NOTIFY_IS_NOTIFICATION(n))
    rb_warn("set_hint_string, ok");
  else
    rb_warn("set_hint_string, no ok");
#endif

  notify_notification_set_hint_string(n, vkey, vvalue);

  return Qnil;
}
name= new_name click to toggle source

if new_name is a valid string, sets the application name for the notification. otherwise nothing will be changed

** ONLY WHEN COMPILED AGAINST LIBNOTIFY >= 0.7.3 **

static VALUE
_wrap_notification_set_app_pname(VALUE self, VALUE notification_name)
{
  char *name = NIL_P(notification_name) ? NULL : StringValuePtr(notification_name);

  if(name != NULL || *name != '\0')
    notify_notification_set_app_name(name);

  return Qnil;
}
pixbuf_icon=(icon) click to toggle source

icon = The icon

Sets the icon from a Gdk::Pixbuf

static VALUE
_wrap_notification_set_pixbuf_icon(VALUE self, VALUE icon)
{
  GdkPixbuf *pix = GDK_PIXBUF(RVAL2GOBJ(icon));
  NotifyNotification *n = NOTIFY_NOTIFICATION(RVAL2GOBJ(self));

#ifdef DEBUG
  if(NOTIFY_IS_NOTIFICATION(n) && GDK_IS_PIXBUF(pix))
    rb_warn("pixbuf_icon, ok");
  else
    rb_warn("pixbuf_icon, no ok");
#endif

  notify_notification_set_image_from_pixbuf(n, pix);

  return Qnil;
}
show click to toggle source

Tells the notification server to display the notification on the screen. if TRUE returns, show the notification otherwise returns FALSE

static VALUE
_wrap_notification_show(VALUE self)
{
  NotifyNotification *n = NOTIFY_NOTIFICATION(RVAL2GOBJ(self));

#ifdef DEBUG
  if(NOTIFY_IS_NOTIFICATION(n))
    rb_warn("show, ok");
  else
    rb_warn("show, no ok");
#endif

  if(notify_notification_show(n, NULL) == TRUE)
    return Qtrue;

  return Qfalse;
}
timeout=(milliseconds) click to toggle source

Sets the timeout in milliseconds.

static VALUE
_wrap_notification_set_timeout(VALUE self, VALUE ml)
{
  NotifyNotification *n = NOTIFY_NOTIFICATION(RVAL2GOBJ(self));

#ifdef DEBUG
  if(NOTIFY_IS_NOTIFICATION(n))
    rb_warn("timeout, ok");
  else
    rb_warn("timeout, no ok");
#endif

  notify_notification_set_timeout(n, FIX2INT(ml));

  return Qnil;
}
update(summ, msg, icon) click to toggle source

summ = The new summary text (required)

msg = The new body text or nil

icon = The new icon or nil

This won’t send the update out and display it on the screen. For that, you will need to call the Notification#show method.

Returns TRUE if ok, FALSE otherwise

static VALUE
_wrap_notification_update(VALUE self, VALUE summ, VALUE msg, VALUE icon)
{
  NotifyNotification *n = NOTIFY_NOTIFICATION(RVAL2GOBJ(self));
  char *nsumm = NIL_P(summ) ? NULL : StringValuePtr(summ);
  char *nmsg = NIL_P(msg) ? NULL : StringValuePtr(msg);
  char *nicon = NIL_P(icon) ? NULL : StringValuePtr(icon);

#ifdef DEBUG
  if(NOTIFY_IS_NOTIFICATION(n))
    rb_warn("update, ok");
  else
    rb_warn("update, no ok");
#endif

  if(nsumm == NULL || *nsumm == '\0')
    rb_raise(rb_eArgError, "You need to supply a valid summary string");

  if(notify_notification_update(n, nsumm, nmsg, nicon) == TRUE)
    return Qtrue;

  return Qfalse;
}
urgency=(urgency_level) click to toggle source

urgency_level = The urgency level

Sets the urgency level

static VALUE
_wrap_notification_set_urgency(VALUE self, VALUE urgency)
{
  NotifyNotification *n = NOTIFY_NOTIFICATION(RVAL2GOBJ(self));

#ifdef DEBUG
  if(NOTIFY_IS_NOTIFICATION(n))
    rb_warn("set_urgency, ok");
  else
    rb_warn("set_urgency, no ok");
#endif

  switch(FIX2INT(urgency))
  {
  case NOTIFY_URGENCY_LOW:
    notify_notification_set_urgency(n, NOTIFY_URGENCY_LOW);
    break;
  case NOTIFY_URGENCY_NORMAL:
    notify_notification_set_urgency(n, NOTIFY_URGENCY_NORMAL);
    break;
  case NOTIFY_URGENCY_CRITICAL:
    notify_notification_set_urgency(n, NOTIFY_URGENCY_CRITICAL);
    break;
  default:
    notify_notification_set_urgency(n, NOTIFY_URGENCY_NORMAL);
  }

  return Qnil;
}

[Validate]

Generated with the Darkfish Rdoc Generator 2.