Functions for UrgencyHint



The UrgencyHint specified in ICCCM section 4.1.2.4 is:

                 . . . useful for alarm dialog boxes or
     reminder windows, in cases where mapping the win­
     dow is not enough (e.g., in the presence of multi-
     workspace or virtual desktop window managers), and
     where using an override-redirect window is too
     intrusive.  For example, the window manager may
     attract attention to an urgent window by adding an
     indicator to its title bar or its icon.  Window
     managers may also take additional action for a
     window that is newly urgent, such as by flashing
     its icon (if the window is iconic) or by raising
     it to the top of the stack.

These functions could add X11 support to gdk for setting and getting
the hint, and the same for gtk+. (I'll submit in patch form to bugzilla
when I can.) GtkMessageDialog should set this hint so these might be used
internally until they can be added to the API. As they are of general
utility for chat and IM clients, they could be used in cut-n-paste
fashion.

(I'll probably soon have a similar set for input mode setting so that
 Nautilus doesn't need any special hackery.)

/*---- Gdk Functions ----*/

void     gdk_window_set_urgency_hint (GdkWindow *window,
				      gboolean   urgency_hint);
gboolean gdk_window_get_urgency_hint (GdkWindow *window);

void
gdk_window_set_urgency_hint (GdkWindow *window, gboolean urgency_hint)
{
  XWMHints *wm_hints;

  wm_hints = XGetWMHints (GDK_WINDOW_XDISPLAY (window),
			  GDK_WINDOW_XID (window));
  if (!wm_hints)
    wm_hints = XAllocWMHints ();

  if (urgency_hint)
    wm_hints->flags |= UrgencyHint;
  else
    wm_hints->flags &= ~UrgencyHint;

  XSetWMHints (GDK_WINDOW_XDISPLAY (window),
	       GDK_WINDOW_XID (window), wm_hints);
  XFree (wm_hints);
}

gboolean
gdk_window_get_urgency_hint (GdkWindow *window)
{
  XWMHints *wm_hints;
  gboolean result;

  wm_hints = XGetWMHints (GDK_WINDOW_XDISPLAY (window),
			  GDK_WINDOW_XID (window));

  if (wm_hints)
    {
      result = wm_hints->flags & UrgencyHint;
      XFree (wm_hints);
    }
  else
    result = FALSE;

  return result;
}

/*---- Gtk+ Functions ----*/
void     gtk_window_set_urgency_hint (GtkWindow *window,
				      gboolean   urgency_hint);
gboolean gtk_window_get_urgency_hint (GtkWindow *window);

void
gtk_window_set_urgency_hint (GtkWindow *window, gboolean urgency_hint)
{
  g_return_if_fail (GTK_IS_WINDOW (window));

  gdk_window_set_urgency_hint (GTK_WIDGET (window)->window, urgency_hint);
}

gboolean
gtk_window_get_urgency_hint (GtkWindow *window)
{
  g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE);

  return gdk_window_get_urgency_hint (GTK_WIDGET (window)->window);
}

/* */

Cheers,
Greg Merchan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]