static void
ntf_wm_handle_demands_attention (MetaWindow *window)
{
  NtfTray         *tray;
  NtfNotification *ntf;
  NtfSource       *src = NULL;
  gint             pid;
  const gchar     *machine;
  gint             id;

  g_return_if_fail (META_IS_WINDOW (window));

  id      = GPOINTER_TO_INT (window);
  pid     = meta_window_get_pid (window);
  machine = meta_window_get_client_machine (window);

  tray = ntf_overlay_get_tray (FALSE);

  ntf = ntf_tray_find_notification (tray, subsystem_id, id);

  if (!ntf)
    {
      gchar *srcid = g_strdup_printf ("application-%d@%s", pid, machine);

      g_debug ("creating new notification for source %s", srcid);

      if (!(src = ntf_sources_find_for_id (srcid)))
        {
          if ((src = ntf_source_new_for_pid (machine, pid)))
            ntf_sources_add (src);
        }

      if (src)
        ntf = ntf_notification_new (src, subsystem_id, id, FALSE);

      if (ntf)
        {
          g_signal_connect (ntf, "closed",
                            G_CALLBACK (ntf_wm_ntf_closed_cb),
                            NULL);

          ntf_wm_update_notification (ntf, window);
          ntf_tray_add_notification (tray, ntf);
        }

      g_free (srcid);
    }
  else
    {
      g_debug ("updating existing notification");
      ntf_wm_update_notification (ntf, window);
    }

  g_signal_connect (window, "notify::demands-attention",
                    G_CALLBACK (ntf_wm_meta_window_demands_attention_cb),
                    NULL);
  g_signal_connect (window, "notify::urgent",
                    G_CALLBACK (ntf_wm_meta_window_demands_attention_cb),
                    NULL);
}
Exemple #2
0
static void
ntf_libnotify_notification_added_cb (DawatiNetbookNotifyStore *store,
                                     Notification             *notification,
                                     gpointer                  data)
{
  NtfTray         *tray;
  NtfNotification *ntf;
  NtfSource       *src = NULL;
  gint             pid = notification->pid;
  const gchar     *machine = "local";

  tray = ntf_overlay_get_tray (notification->is_urgent);

  ntf = ntf_tray_find_notification (tray, subsystem_id, notification->id);

  if (!ntf)
    {
      gchar *srcid = g_strdup_printf ("application-%d@%s", pid, machine);

      if (!(src = ntf_sources_find_for_id (srcid)))
        {
          if ((src = ntf_source_new_for_pid (machine, pid)))
            ntf_sources_add (src);
        }

      if (src)
        {
          gboolean no_dismiss = (notification->no_dismiss_button != 0);

          ntf = ntf_notification_new (src,
                                      subsystem_id,
                                      notification->id,
                                      no_dismiss);
        }


      if (ntf)
        {
          n_notifiers++;
          g_signal_connect_after (ntf, "closed",
                                  G_CALLBACK (ntf_libnotify_ntf_closed_cb),
                                  NULL);

          ntf_libnotify_update (ntf, notification);
          ntf_tray_add_notification (tray, ntf);
          ntf_libnotify_update_modal ();
        }

      g_free (srcid);
    }
  else
    ntf_libnotify_update (ntf, notification);
}