Ejemplo n.º 1
0
static void
ntf_libnotify_notification_closed_cb (DawatiNetbookNotifyStore *store,
                                      guint                     id,
                                      guint                     reason,
                                      gpointer                  data)
{
  NtfTray         *tray;
  NtfNotification *ntf;

  /*
   * Look first in the regular tray for this id, then the urgent one.
   */
  tray = ntf_overlay_get_tray (FALSE);

  if (!(ntf = ntf_tray_find_notification (tray, subsystem_id, id)))
    {
      tray = ntf_overlay_get_tray (TRUE);
      ntf  = ntf_tray_find_notification (tray, subsystem_id, id);
    }

  if (ntf && !ntf_notification_is_closed (ntf))
    {
      n_notifiers--;
      if (n_notifiers < 0)
        {
          g_warning ("Bug in notifier accounting, attempting to fix");
          n_notifiers = 0;
        }
      ntf_notification_close (ntf);
      ntf_libnotify_update_modal ();
    }
}
Ejemplo n.º 2
0
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);
}
Ejemplo n.º 3
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);
}
Ejemplo n.º 4
0
static void
ntf_wm_demands_attention_clear (MetaWindow *window)
{
  NtfTray         *tray;
  NtfNotification *ntf;
  gint             id = GPOINTER_TO_INT (window);

  /*
   * Look first in the regular tray for this id, then the urgent one.
   */
  tray = ntf_overlay_get_tray (FALSE);

  if ((ntf = ntf_tray_find_notification (tray, subsystem_id, id)) &&
      !ntf_notification_is_closed (ntf))
    {
      ntf_notification_close (ntf);
    }
}