コード例 #1
0
ファイル: lxmusic-notify.c プロジェクト: nesciens/lxmusic
LXMusicNotification lxmusic_do_notify_prepare(const gchar *artist, const gchar *title, const char *summary, GtkStatusIcon *status_icon)
{
#if HAVE_LIBNOTIFY
    if (!notify_is_initted ())
	notify_init ("LXMusic");
    GString* message = g_string_new("");
    if ( (artist != NULL) && (title != NULL ) ) {	
	/* metadata available */
	g_string_append_printf(message, "<b>%s: </b><i>%s</i>", _("Artist"), artist );
	g_string_append_printf(message, "\n<b>%s: </b><i>%s</i>", _("Title"), title );
    }
    /* use filename without markup */
    else 			
	g_string_append( message, title );
    struct _LXMusicNotification *lxn = g_new ( struct _LXMusicNotification, 1);
#if !defined(NOTIFY_VERSION_MINOR) || (NOTIFY_VERSION_MAJOR == 0 && NOTIFY_VERSION_MINOR < 7)
    lxn->notify = notify_notification_new (summary, message->str, NULL, NULL);
#else
    lxn->notify = notify_notification_new (summary, message->str, NULL);
#endif
    notify_notification_set_urgency (lxn->notify, NOTIFY_URGENCY_NORMAL);
#if !defined(NOTIFY_VERSION_MINOR) || (NOTIFY_VERSION_MAJOR == 0 && NOTIFY_VERSION_MINOR < 7)
    notify_notification_attach_to_status_icon( lxn->notify, status_icon );
#endif
    notify_notification_set_timeout (lxn->notify, NOTIFY_EXPIRES_DEFAULT);
    g_string_free( message, TRUE );
    return lxn;
#endif	/* HAVE_LIBNOTIFY */
}
コード例 #2
0
ファイル: notifier.c プロジェクト: pedroarthur/profanity
static void _do_notify_message(
    const char * const source, const char * const message, int win) {
#ifdef HAVE_LIBNOTIFY
    if (notify_is_initted()) {
        GString *title = g_string_new("");
        g_string_append(title, source);
        g_string_append_printf(title, " (Profanity %d)", win);

        NotifyNotification *notification =
            notify_notification_new(title->str, message, NULL);
        notify_notification_set_timeout(notification, 3000);
        notify_notification_set_category(notification, "incoming message");
        notify_notification_set_urgency(notification, NOTIFY_URGENCY_NORMAL);

        GError *error = NULL;
        gboolean notify_success = notify_notification_show(notification, &error);

        if (!notify_success) {
            log_error("Error sending desktop notification:");
            log_error("  -> Message : %s", message);
            log_error("  -> Error   : %s", error->message);
        }

        g_string_free(title, TRUE);
    } else {
        log_error("Libnotify initialisation error.");
    }
#endif
}
コード例 #3
0
ファイル: gtk_mod.c プロジェクト: AlexMarlo/baresip
static int module_close(void)
{
	cmd_unregister(cmdv);
	if (mod_obj.run) {
		gdk_threads_enter();
		gtk_main_quit();
		gdk_threads_leave();
	}
	pthread_join(mod_obj.thread, NULL);
	mem_deref(mod_obj.mq);
	aufilt_unregister(&vumeter);
	message_close();

#ifdef USE_LIBNOTIFY
	if (notify_is_initted())
		notify_uninit();
#endif

	g_slist_free(mod_obj.accounts_menu_group);
	g_slist_free(mod_obj.call_windows);
	g_slist_free(mod_obj.incoming_call_menus);

	uag_event_unregister(ua_event_handler);

	return 0;
}
コード例 #4
0
ファイル: mynotify.c プロジェクト: crazyleen/mylib
int notification_show(char *title, char *body, char *icon)
{
	GError *error = NULL;
	NotifyNotification *notify_p;

	if (title == NULL)
		return -1;

	//you should init notify using app's name
	if(notify_is_initted() == FALSE)
		if(notify_init("argv[0]") == FALSE){
			return -1;
		}
	
    notify_p = notify_notification_new(title, body, icon, NULL);
	
    //miliseconds, NOTIFY_EXPIRES_DEFAULT NOTIFY_EXPIRES_NEVER
	notify_notification_set_timeout(notify_p, 1000);
   
	//NOTIFY_URGENCY_LOW,NOTIFY_URGENCY_NORMAL, NOTIFY_URGENCY_CRITICAL,
    notify_notification_set_urgency (notify_p,NOTIFY_URGENCY_NORMAL);

	//notify_notification_update(title, body, icon, NULL);
	//notify_notification_close(notify_p, &error);
    if (notify_notification_show(notify_p, &error) == FALSE)
		return -1;

	//notify_uninit();
	return 0;
}
コード例 #5
0
ファイル: notify.c プロジェクト: hyuni/pnmixer
/**
 * Initializes libnotify if it's not already
 * initialized.
 */
void
init_libnotify()
{
	if (!notify_is_initted())
		if (!notify_init(PACKAGE))
			g_idle_add(idle_report_error, NULL);
}
コード例 #6
0
ファイル: thunar-notify.c プロジェクト: flipcoder/thunar
void
thunar_notify_uninit (void)
{
  if (thunar_notify_initted
      && notify_is_initted ())
    notify_uninit ();
}
コード例 #7
0
void
ring_notify_uninit()
{
#if USE_LIBNOTIFY
    if (notify_is_initted())
        notify_uninit();
#endif
}
コード例 #8
0
ファイル: notifier.c プロジェクト: kzmkv/indi
void notifier_destroy ()
{
	if (!notify_is_initted ())
		return;

	notify_notification_close (Notification, NULL);
	notify_uninit ();
}
コード例 #9
0
ファイル: notifier.c プロジェクト: pedroarthur/profanity
static void
_notifier_uninit(void)
{
#ifdef HAVE_LIBNOTIFY
    if (notify_is_initted()) {
        notify_uninit();
    }
#endif
}
コード例 #10
0
gboolean
ring_notify_is_initted()
{
#if USE_LIBNOTIFY
    return notify_is_initted();
#else
    return FALSE;
#endif
}
コード例 #11
0
ファイル: notifier.c プロジェクト: kzmkv/indi
void notifier_init ()
{
	if (notify_is_initted ())
		return;

	notify_init (Appname);
	Notification = notify_notification_new (Appname, NULL, NULL, NULL);
	notify_notification_set_timeout (Notification, TIMEOUT);
}
コード例 #12
0
ファイル: notifier.c プロジェクト: j2ko/profanity
void
notifier_uninit(void)
{
#ifdef HAVE_LIBNOTIFY
    if (notify_is_initted()) {
        notify_uninit();
    }
#endif
    g_timer_destroy(remind_timer);
}
コード例 #13
0
ファイル: notifmsg.cpp プロジェクト: AaronDP/wxWidgets
    // Do initialize the library.
    static bool Initialize()
    {
        if ( !notify_is_initted() )
        {
            if ( !notify_init(wxTheApp->GetAppName().utf8_str()) )
                return false;
        }

        return true;
    }
コード例 #14
0
ファイル: vino-prompt.c プロジェクト: cctsao1008/vino
static gboolean
vino_prompt_setup_dialog (VinoPrompt *prompt)
{
  if (!notify_is_initted () &&  !notify_init (g_get_application_name ()))
    {
      g_printerr (_("Error initializing libnotify\n"));
      return FALSE;
    }

  return TRUE;
}
コード例 #15
0
gboolean plugin_done(void)
{
  hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, hook_f_item);
  hooks_unregister_hook(FOLDER_UPDATE_HOOKLIST, hook_f);
  hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST, hook_m_info);
  hooks_unregister_hook(OFFLINE_SWITCH_HOOKLIST, hook_offline);
  hooks_unregister_hook(MAIN_WINDOW_CLOSE, hook_mw_close);
  hooks_unregister_hook(MAIN_WINDOW_GOT_ICONIFIED, hook_got_iconified);
  hooks_unregister_hook(ACCOUNT_LIST_CHANGED_HOOKLIST, hook_account);
  hooks_unregister_hook(THEME_CHANGED_HOOKLIST, hook_theme_changed);

  notify_save_config();

  notify_gtk_done();

  /* foldercheck cleanup */
  notification_foldercheck_write_array();
  notification_free_folder_specific_array();

#ifdef NOTIFICATION_BANNER
  notification_collected_msgs_free(banner_collected_msgs);
  banner_collected_msgs = NULL;
  notification_banner_destroy();
#endif
#ifdef NOTIFICATION_LCDPROC
  notification_lcdproc_disconnect();
#endif
#ifdef NOTIFICATION_TRAYICON
  notification_trayicon_destroy();
#endif
#ifdef NOTIFICATION_INDICATOR
  notification_indicator_destroy();
#endif
  notification_core_free();

#ifdef HAVE_LIBNOTIFY
  if(notify_is_initted())
    notify_uninit();
#endif

#ifdef NOTIFICATION_HOTKEYS
  notification_hotkeys_unbind_all();
#endif

  notification_pixbuf_free_all();

  debug_print("Notification plugin unloaded\n");

  /* Returning FALSE here means that g_module_close() will not be called on the plugin.
   * This is necessary, as needed libraries are not designed to be unloaded. */
  return FALSE;
}
コード例 #16
0
void sendNotify(const char *summary, const char *body, const char *icon)
{
    NotifyNotification *notification;

    if (!notify_is_initted())
        notify_init("waifu2x-converter-qt");

    notification = notify_notification_new(summary,
                                           body,
                                           icon);
    notify_notification_show(notification,
                             NULL);
}
コード例 #17
0
static void
notifyFiniCore (CompPlugin *p,
                CompCore   *c)
{
    NOTIFY_CORE (c);

    UNWRAP (nc, c, logMessage);

    if (notify_is_initted ())
        notify_uninit ();

    free (nc);
}
コード例 #18
0
ファイル: plugin-tray.c プロジェクト: amalmurali47/hexchat
void
fe_tray_set_balloon (const char *title, const char *text)
{
#ifndef WIN32
#if 0
	const char *argv[8];
	const char *path;
	char time[16];
#endif
	WinStatus ws;

	/* no balloons if the window is focused */
	ws = tray_get_window_status ();
	if ((prefs.hex_away_omit_alerts && hexchat_get_info(ph, "away")) ||
		(prefs.hex_gui_focus_omitalerts && ws == WS_FOCUSED))
		return;

	/* bit 1 of flags means "no balloons unless hidden/iconified" */
	if (ws != WS_HIDDEN && prefs.hex_gui_tray_quiet)
		return;

	/* FIXME: this should close the current balloon */
	if (!text)
		return;

#ifdef USE_LIBNOTIFY
	NotifyNotification *notification;
	char *notify_text, *notify_title;

	if (!notify_is_initted())
		notify_init(PACKAGE_NAME);

	notify_text = strip_color (text, -1, STRIP_ALL|STRIP_ESCMARKUP);
	notify_title = strip_color (title, -1, STRIP_ALL);

	notification = XC_NOTIFY_NEW (notify_title, notify_text, HEXCHATSHAREDIR "/icons/hicolor/scalable/apps/hexchat.svg", NULL);

#if NOTIFY_CHECK_VERSION(0,7,0)
	notify_notification_set_hint (notification, "desktop-entry", g_variant_new_string ("hexchat"));
#endif

	g_free ((char *)notify_title);
	g_free ((char *)notify_text);

	notify_notification_set_timeout (notification, prefs.hex_input_balloon_time*1000);
	notify_notification_show (notification, NULL);

	g_object_unref (notification);
#endif
#endif
}
コード例 #19
0
static void
xfce_accessibility_helper_notification_show (XfceAccessibilityHelper *helper,
                                             const gchar             *summary,
                                             const gchar             *body)
{
    /* early leave the avoid dbus errors, we already
     * told we were unable to connect during init */
    if (notify_is_initted () == FALSE)
        return;

    /* close the running notification */
    if (helper->notification == NULL)
    {
        /* create a new notification */
#ifdef NOTIFY_CHECK_VERSION
#if NOTIFY_CHECK_VERSION (0, 7, 0)
        helper->notification = notify_notification_new (summary, body, "keyboard");
#else
        helper->notification = notify_notification_new (summary, body, "keyboard", NULL);
#endif
#else
        helper->notification = notify_notification_new (summary, body, "keyboard", NULL);
#endif

        /* close signal */
        g_signal_connect (G_OBJECT (helper->notification), "closed", G_CALLBACK (xfce_accessibility_helper_notification_closed), helper);
    }
    else
    {
        /* update the current notification */
        notify_notification_update (helper->notification, summary, body, "keyboard");
    }

    if (G_LIKELY (helper->notification))
    {
        /* show the notification for (another) 2 seconds */
        notify_notification_set_timeout (helper->notification, 2000);

        /* show the notification */
        if (!notify_notification_show (helper->notification, NULL))
        {
            /* show warning with the notification information */
            g_warning ("Failed to show notification: %s (%s).", summary, body);

            /* failed to show the notification */
            notify_notification_close (helper->notification, NULL);
            helper->notification = NULL;
        }
    }
}
コード例 #20
0
ファイル: rookie-misc.c プロジェクト: trhura/rookie
void
rookie_misc_show_notification	(const gchar *summary,
								 const gchar *body,
								 const gchar *icon)
{
	if (notify_is_initted ()) {
		NotifyNotification *notification;
		GError *error = NULL;

		notification = notify_notification_new (summary, body, icon);
		notify_notification_set_timeout (notification, NOTIFY_EXPIRES_DEFAULT);
		notify_notification_show (notification, &error);
		handle_error (error);
	}
}
コード例 #21
0
ファイル: plugin-tray.c プロジェクト: aperson/hexchat
void
fe_tray_set_balloon (const char *title, const char *text)
{
#ifndef WIN32
#if 0
	const char *argv[8];
	const char *path;
	char time[16];
#endif
	WinStatus ws;

	/* no balloons if the window is focused */
	ws = tray_get_window_status ();
	if (ws == WS_FOCUSED)
		return;

	/* bit 1 of flags means "no balloons unless hidden/iconified" */
	if (ws != WS_HIDDEN && prefs.hex_gui_tray_quiet)
		return;

	/* FIXME: this should close the current balloon */
	if (!text)
		return;

#ifdef USE_LIBNOTIFY
	NotifyNotification *notification;
	char *notify_text, *notify_title;

	if (!notify_is_initted())
		notify_init(PACKAGE_NAME);

	notify_text = strip_color (text, -1, STRIP_ALL|STRIP_ESCMARKUP);
	notify_title = strip_color (title, -1, STRIP_ALL);

	notification = XC_NOTIFY_NEW (notify_title, notify_text, HEXCHATSHAREDIR "/pixmaps/hexchat.png", NULL);

	g_free ((char *)notify_title);
	g_free ((char *)notify_text);

	notify_notification_set_timeout (notification, prefs.hex_input_balloon_time*1000);
	notify_notification_show (notification, NULL);

	g_object_unref (notification);
#endif
#endif
}
コード例 #22
0
ファイル: notify.c プロジェクト: mcmihail/cinnamon-bluetooth
void show_notification(const gchar *summary, const gchar *message,
			const gchar *action, gint timeout, GCallback handler)
{
	NotifyActionCallback callback;
#ifndef HAVE_APP_INDICATOR
	GdkScreen *screen;
	GdkRectangle area;
#endif /* HAVE_APP_INDICATOR */

	if (notify_is_initted() == FALSE)
		return;

	if (notify) {
		g_signal_handlers_destroy(notify);
		notify_notification_close(notify, NULL);
	}

	notify = notify_notification_new(summary, message, ACTIVE_ICON_NAME);

	notify_notification_set_timeout(notify, timeout);

#ifndef HAVE_APP_INDICATOR
	if (gtk_status_icon_get_visible(statusicon) == TRUE) {
		gtk_status_icon_get_geometry(statusicon, &screen, &area, NULL);

		notify_notification_set_hint_int32(notify,
					"x", area.x + area.width / 2);
		notify_notification_set_hint_int32(notify,
					"y", area.y + area.height / 2);
	}
#endif /* HAVE_APP_INDICATOR */

	notify_notification_set_urgency(notify, NOTIFY_URGENCY_NORMAL);

	callback = handler ? NOTIFY_ACTION_CALLBACK(handler) : notify_action;

	notify_notification_add_action(notify, "default", "action",
						callback, NULL, NULL);
	if (action != NULL)
		notify_notification_add_action(notify, "button", action,
							callback, NULL, NULL);

	notify_notification_show(notify, NULL);
}
コード例 #23
0
ファイル: gtk_mod.c プロジェクト: Studio-Link/baresip
static void message_handler(struct ua *ua,
			    const struct pl *peer, const struct pl *ctype,
			    struct mbuf *body, void *arg)
{
	struct gtk_mod *mod = arg;
	char title[128];
	char msg[512];

#if GLIB_CHECK_VERSION(2,40,0)
	GNotification *notification;
#elif defined(USE_LIBNOTIFY)
	NotifyNotification *notification;
#endif

	(void)ua;
	(void)ctype;


	/* Display notification of chat */

	re_snprintf(title, sizeof title, "Chat from %r", peer);
	title[sizeof title - 1] = '\0';

	re_snprintf(msg, sizeof msg, "%b",
			mbuf_buf(body), mbuf_get_left(body));

#if GLIB_CHECK_VERSION(2,40,0)
	notification = g_notification_new(title);
	g_notification_set_body(notification, msg);
	g_application_send_notification(mod->app, NULL, notification);
	g_object_unref(notification);

#elif defined(USE_LIBNOTIFY)
	(void)mod;

	if (!notify_is_initted())
		return;
	notification = notify_notification_new(title, msg, "baresip");
	notify_notification_show(notification, NULL);
	g_object_unref(notification);
#endif
}
コード例 #24
0
static gboolean
plugin_load (PurplePlugin *plugin)
{
	void *conv_handle, *blist_handle, *conn_handle;

	construct_list();

	if (!notify_is_initted () && !notify_init ("Pidgin")) {
		purple_debug_error (PLUGIN_ID, "libnotify not running!\n");
		return FALSE;
	}

	conv_handle = purple_conversations_get_handle ();
	blist_handle = purple_blist_get_handle ();
	conn_handle = purple_connections_get_handle();

	buddy_hash = g_hash_table_new (NULL, NULL);

	purple_signal_connect (blist_handle, "buddy-signed-on", plugin,
						PURPLE_CALLBACK(notify_buddy_signon_cb), NULL);

	purple_signal_connect (blist_handle, "buddy-signed-off", plugin,
						PURPLE_CALLBACK(notify_buddy_signoff_cb), NULL);

	purple_signal_connect (conv_handle, "received-im-msg", plugin,
						PURPLE_CALLBACK(notify_new_message_cb), NULL);

	purple_signal_connect (conv_handle, "received-chat-msg", plugin,
						PURPLE_CALLBACK(notify_chat_nick), NULL);

	purple_signal_connect (conv_handle, "deleting-conversation", plugin,
						PURPLE_CALLBACK(notify_deleting_conversation_cb), NULL);

	purple_prefs_connect_callback(plugin, "/plugins/gtk/libnotify/triggerMessages",
					(PurplePrefCallback)construct_list, NULL);

	/* used just to not display the flood of guifications we'd get */
	purple_signal_connect (conn_handle, "signed-on", plugin,
						PURPLE_CALLBACK(event_connection_throttle), NULL);

	return TRUE;
}
コード例 #25
0
 void init() {
     if (!notify_is_initted()) {
         notify_init(QGSTRING(QCoreApplication::applicationName()));
     }
     
     Q_Q(QchNotification);
     notification = hildon_notification_new(QGSTRING(title), QGSTRING(text), QGSTRING(iconSource), NULL);
     notify_notification_add_action(NOTIFY_NOTIFICATION(notification), "default",
                                    QGSTRING(QCoreApplication::applicationName()),
                                    NOTIFY_ACTION_CALLBACK(onNotificationClicked), q, NULL);
     g_signal_connect(G_OBJECT(notification), "closed", G_CALLBACK(onNotificationClosed), q);
     
     setNotificationCategory();
     setNotificationHints();
     setNotificationSound();
     setNotificationTimeout();
     
     if (showOnInit) {
         showNotification();
     }
 }
コード例 #26
0
ファイル: notify.c プロジェクト: gabrield/lnotify
static int
newnotify (lua_State * L)
{
  NotifyNotification *notification = NULL;
  const char *summary, *body, *icon;
  GError *error = NULL;
  int top;

  if (!notify_is_initted() && !notify_init ("icon-summary-body")) {
    g_error_free (error);
    return luaL_error (L, "icon-summary-body");
  }

  top = lua_gettop(L);
  summary = luaL_checkstring (L, 1);

  body = (top > 1)
    ? luaL_checkstring (L, 2)
    : NULL;
  icon = (top > 2)
    ? luaL_checkstring (L, 3)
    : NULL;

  if (notification == (NotifyNotification *) 0) {
    notification = notify_notification_new (
      summary,
      body,
      icon
#if NOTIFY_CHECK_VERSION(0, 7, 0)
#else
      , NULL
#endif
    );
  }

  lua_pushlightuserdata (L, notification);

  return 1;
}
コード例 #27
0
ファイル: notify.c プロジェクト: gabrield/lnotify
static int
setappname (lua_State * L)
{
  const char *name;
  NotifyNotification *notify;

  if (lua_gettop(L) < 2) {
    /* if there are less than two args, assume we're trying to set the default app name */
    name = luaL_checkstring(L, 1);
    if (notify_is_initted())
      notify_set_app_name(name);
    else
      notify_init(name);
  }
  else {
    notify = (NotifyNotification *) lua_touserdata(L, 1);
    if (!notify) luaL_argerror(L, 1, "Unknown type");
    name = luaL_checkstring(L, 2);
    notify_notification_set_app_name(notify, name);
  }

  return 0;
}
コード例 #28
0
ファイル: drwright.c プロジェクト: GNOME/drwright
DrWright *
drwright_new (void)
{
	DrWright *dr = g_new0 (DrWright, 1);

	if (debug) {
		setup_debug_values (dr);
	}

	if (!notify_is_initted ()) {
		notify_init (g_get_application_name ());
	}

	dr->timer = drw_timer_new ();
	dr->idle_timer = drw_timer_new ();

	dr->state = STATE_START;

	dr->monitor = drw_monitor_new ();

	g_signal_connect (dr->monitor,
			  "activity",
			  G_CALLBACK (activity_detected_cb),
			  dr);

	g_timeout_add_seconds (1,
			       (GSourceFunc) maybe_change_state,
			       dr);

        dr->settings = g_settings_new (DRW_SETTINGS_SCHEMA_ID);
        settings_change_cb (dr->settings, NULL, dr);
        g_signal_connect (dr->settings, "changed",
                          G_CALLBACK (settings_change_cb), dr);

	return dr;
}
コード例 #29
0
nsresult
nsAlertsIconListener::InitAlertAsync(const nsAString & aImageUrl,
                                     const nsAString & aAlertTitle, 
                                     const nsAString & aAlertText,
                                     bool aAlertTextClickable,
                                     const nsAString & aAlertCookie,
                                     nsIObserver * aAlertListener)
{
  if (!notify_is_initted()) {
    // Give the name of this application to libnotify
    nsCOMPtr<nsIStringBundleService> bundleService = 
      do_GetService(NS_STRINGBUNDLE_CONTRACTID);

    nsCAutoString appShortName;
    if (bundleService) {
      nsCOMPtr<nsIStringBundle> bundle;
      bundleService->CreateBundle("chrome://branding/locale/brand.properties",
                                  getter_AddRefs(bundle));
      nsAutoString appName;

      if (bundle) {
        bundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(),
                                  getter_Copies(appName));
        appShortName = NS_ConvertUTF16toUTF8(appName);
      } else {
        NS_WARNING("brand.properties not present, using default application name");
        appShortName.AssignLiteral("Mozilla");
      }
    } else {
      appShortName.AssignLiteral("Mozilla");
    }

    if (!notify_init(appShortName.get()))
      return NS_ERROR_FAILURE;

    GList *server_caps = notify_get_server_caps();
    if (server_caps) {
      for (GList* cap = server_caps; cap != NULL; cap = cap->next) {
        if (!strcmp((char*) cap->data, "actions")) {
          gHasActions = true;
          break;
        }
      }
      g_list_foreach(server_caps, (GFunc)g_free, NULL);
      g_list_free(server_caps);
    }
  }

  if (!gHasActions && aAlertTextClickable)
    return NS_ERROR_FAILURE; // No good, fallback to XUL

  nsCOMPtr<nsIObserverService> obsServ =
      do_GetService("@mozilla.org/observer-service;1");
  if (obsServ)
    obsServ->AddObserver(this, "quit-application", true);

  // Workaround for a libnotify bug - blank titles aren't dealt with
  // properly so we use a space
  if (aAlertTitle.IsEmpty()) {
    mAlertTitle = NS_LITERAL_CSTRING(" ");
  } else {
    mAlertTitle = NS_ConvertUTF16toUTF8(aAlertTitle);
  }

  mAlertText = NS_ConvertUTF16toUTF8(aAlertText);
  mAlertHasAction = aAlertTextClickable;

  mAlertListener = aAlertListener;
  mAlertCookie = aAlertCookie;

  return StartRequest(aImageUrl);
}
コード例 #30
0
ファイル: notifier.c プロジェクト: pedroarthur/profanity
static void
_notify(const char * const message, int timeout,
    const char * const category)
{
#ifdef HAVE_LIBNOTIFY

    if (notify_is_initted()) {
        NotifyNotification *notification;
        notification = notify_notification_new("Profanity", message, NULL);
        notify_notification_set_timeout(notification, timeout);
        notify_notification_set_category(notification, category);
        notify_notification_set_urgency(notification, NOTIFY_URGENCY_NORMAL);

        GError *error = NULL;
        gboolean notify_success = notify_notification_show(notification, &error);

        if (!notify_success) {
            log_error("Error sending desktop notification:");
            log_error("  -> Message : %s", message);
            log_error("  -> Error   : %s", error->message);
        }
    } else {
        log_error("Libnotify initialisation error.");
    }
#endif
#ifdef PLATFORM_CYGWIN
    NOTIFYICONDATA nid;
    nid.cbSize = sizeof(NOTIFYICONDATA);
    //nid.hWnd = hWnd;
    nid.uID = 100;
    nid.uVersion = NOTIFYICON_VERSION;
    //nid.uCallbackMessage = WM_MYMESSAGE;
    nid.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    strncpy(nid.szTip, "Tray Icon", 10);
    nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
    Shell_NotifyIcon(NIM_ADD, &nid);

    // For a Ballon Tip
    nid.uFlags = NIF_INFO;
    strncpy(nid.szInfoTitle, "Profanity", 10); // Title
    strncpy(nid.szInfo, message, 256); // Copy Tip
    nid.uTimeout = timeout;  // 3 Seconds
    nid.dwInfoFlags = NIIF_INFO;

    Shell_NotifyIcon(NIM_MODIFY, &nid);
#endif
#ifdef HAVE_OSXNOTIFY
    GString *notify_command = g_string_new("terminal-notifier -title 'Profanity' -message '");
    g_string_append(notify_command, message);
    g_string_append(notify_command, "'");

    char *term_name = getenv("TERM_PROGRAM");
    char *app_id = NULL;
    if (g_strcmp0(term_name, "Apple_Terminal") == 0) {
        app_id = "com.apple.Terminal";
    } else if (g_strcmp0(term_name, "iTerm.app") == 0) {
        app_id = "com.googlecode.iterm2";
    }

    if (app_id != NULL) {
        g_string_append(notify_command, " -sender ");
        g_string_append(notify_command, app_id);
    }

    int res = system(notify_command->str);
    if (res == -1) {
        log_error("Could not send desktop notificaion.");
    }

    g_string_free(notify_command, TRUE);
#endif
}