コード例 #1
0
ファイル: ntf-libnotify.c プロジェクト: danni/dawati-shell
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 ();
    }
}
コード例 #2
0
ファイル: ntf-libnotify.c プロジェクト: danni/dawati-shell
static void
ntf_libnotify_update_modal (void)
{
  NtfTray      *tray = ntf_overlay_get_tray (TRUE);
  MetaPlugin *plugin = dawati_netbook_get_plugin_singleton ();

  if (ntf_tray_get_n_notifications (tray) > 0)
    {
      if (!overlay_focused)
        {
          MetaScreen   *screen = meta_plugin_get_screen (plugin);
          ClutterActor *stage = meta_get_stage_for_screen (screen);
          MxFocusManager *manager =
            mx_focus_manager_get_for_stage (CLUTTER_STAGE (stage));

          dawati_netbook_stash_window_focus (plugin, CurrentTime);
          mx_focus_manager_push_focus (manager, MX_FOCUSABLE (tray));
          overlay_focused = TRUE;
        }
    }
  else
    {
      if (overlay_focused)
        {
          dawati_netbook_unstash_window_focus (plugin, CurrentTime);
          overlay_focused = FALSE;
        }
    }
}
コード例 #3
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);
}
コード例 #4
0
ファイル: ntf-libnotify.c プロジェクト: danni/dawati-shell
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);
}
コード例 #5
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);
    }
}