/* * call-seq: * new(summ, msg, icon, widget) * * summ = The summary text (required) * * msg = The body text or nil * * icon = The icon or nil * * widget = The widget (or a Gtk::StatusIcon, when compiled against GTK+ >= 2.9.2 and libnotify >= 0.4.1) to attach to 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, VALUE widget) { GObject *obj = G_OBJECT(RVAL2GOBJ(widget)); char *nsumm = NIL_P(summ) ? NULL : StringValuePtr(summ); NotifyNotification *n = NULL; if(nsumm == NULL || *nsumm == '\0') rb_raise( rb_eArgError, "REQUIRED: the `summ` field" ); #ifdef HAVE_STATUS_ICON if(GTK_IS_STATUS_ICON(obj)) n = notify_notification_new_with_status_icon(nsumm, NIL_P(msg) ? NULL : StringValuePtr(msg), NIL_P(icon) ? NULL : StringValuePtr(icon), GTK_STATUS_ICON(obj)); else n = notify_notification_new(nsumm, NIL_P(msg) ? NULL : StringValuePtr(msg), NIL_P(icon) ? NULL : StringValuePtr(icon), GTK_WIDGET(obj)); #else n = notify_notification_new(nsumm, NIL_P(msg) ? NULL : StringValuePtr(msg), NIL_P(icon) ? NULL : StringValuePtr(icon), GTK_WIDGET(obj)); #endif 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; }