? mkinstalldirs
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libwnck/ChangeLog,v
retrieving revision 1.252
diff -p -u -r1.252 ChangeLog
--- ChangeLog	23 Jul 2004 07:59:44 -0000	1.252
+++ ChangeLog	25 Jul 2004 18:02:49 -0000
@@ -1,3 +1,32 @@
+2004-07-25  Rob Adams  <readams@gnome.org>
+
+	Add support for _NET_WM_STATE_DEMANDS_ATTENTION hint.  This makes
+	labels in the tasklist bold for windows with the hint set, and
+	adds API for reading the hint.
+	
+	* libwnck/window.c (COMPRESS_STATE): add demands attention hint
+	(wnck_window_demands_attention): new function, returns the state
+	of the demands attention flag
+	(update_state): include demands attention in the list of updated
+	state
+
+	* libwnck/window.h (WnckWindowState): Add
+	WNCK_WINDOW_STATE_DEMANDS_ATTENTION
+	(wnck_window_demands_attention): add prototype for new API
+	function
+
+	* libwnck/wnck-enum-types.c: add demands attention hint
+
+	* libwnck/tasklist.c (eel_gtk_label_make_bold): new function,
+	copy/paste from eel.
+	(wnck_gtk_label_make_normal): inverse of make_bold
+	(wnck_task_update_visible_state): If demands attention is set,
+	make bold, otherwise make normal.
+	(wnck_task_state_changed): demands attention changes require
+	updating the visible state
+	(wnck_task_create_widgets): If demands attention is set, make
+	bold.
+	
 2004-07-22  James M. Cape  <jcape@ignore-your.tv>
 
 	* libwnck/tasklist.c: (wnck_task_get_text):
Index: libwnck/tasklist.c
===================================================================
RCS file: /cvs/gnome/libwnck/libwnck/tasklist.c,v
retrieving revision 1.57
diff -p -u -r1.57 tasklist.c
--- libwnck/tasklist.c	23 Jul 2004 07:59:44 -0000	1.57
+++ libwnck/tasklist.c	25 Jul 2004 18:02:53 -0000
@@ -252,6 +252,52 @@ static void     wnck_tasklist_check_end_
 static gpointer task_parent_class;
 static gpointer tasklist_parent_class;
 
+/**
+ * eel_gtk_label_make_bold.
+ *
+ * Switches the font of label to a bold equivalent.
+ * @label: The label.
+ **/
+void
+eel_gtk_label_make_bold (GtkLabel *label)
+{
+  PangoFontDescription *font_desc;
+
+  font_desc = pango_font_description_new ();
+
+  pango_font_description_set_weight (font_desc,
+                                     PANGO_WEIGHT_BOLD);
+
+  /* This will only affect the weight of the font, the rest is
+   * from the current state of the widget, which comes from the
+   * theme or user prefs, since the font desc only has the
+   * weight flag turned on.
+   */
+  gtk_widget_modify_font (GTK_WIDGET (label), font_desc);
+
+  pango_font_description_free (font_desc);
+}
+
+void
+wnck_gtk_label_make_normal (GtkLabel *label)
+{
+  PangoFontDescription *font_desc;
+
+  font_desc = pango_font_description_new ();
+
+  pango_font_description_set_weight (font_desc,
+                                     PANGO_WEIGHT_NORMAL);
+
+  /* This will only affect the weight of the font, the rest is
+   * from the current state of the widget, which comes from the
+   * theme or user prefs, since the font desc only has the
+   * weight flag turned on.
+   */
+  gtk_widget_modify_font (GTK_WIDGET (label), font_desc);
+
+  pango_font_description_free (font_desc);
+}
+
 GType
 wnck_task_get_type (void)
 {
@@ -2149,6 +2195,11 @@ wnck_task_update_visible_state (WnckTask
   if (text != NULL)
     {
       gtk_label_set_text (GTK_LABEL (task->label), text);
+      if (wnck_window_get_state (task->window) &
+          WNCK_WINDOW_STATE_DEMANDS_ATTENTION)
+        eel_gtk_label_make_bold ((GTK_LABEL (task->label)));
+      else
+        wnck_gtk_label_make_normal ((GTK_LABEL (task->label)));
       gtk_tooltips_set_tip (task->tasklist->priv->tooltips, task->button, text, NULL);
       g_free (text);
     }
@@ -2171,7 +2222,8 @@ wnck_task_state_changed (WnckWindow     
       return;
     }
   
-  if (changed_mask & WNCK_WINDOW_STATE_MINIMIZED)
+  if ((changed_mask & WNCK_WINDOW_STATE_MINIMIZED) ||
+      (changed_mask & WNCK_WINDOW_STATE_DEMANDS_ATTENTION))
     {
       WnckTask *win_task;
 
@@ -2376,6 +2428,9 @@ wnck_task_create_widgets (WnckTask *task
 
   text = wnck_task_get_text (task);
   task->label = gtk_label_new (text);
+  if (wnck_window_get_state (task->window) &
+      WNCK_WINDOW_STATE_DEMANDS_ATTENTION)
+    eel_gtk_label_make_bold ((GTK_LABEL (task->label)));
   gtk_widget_show (task->label);
 
   gtk_table_attach (GTK_TABLE (table),
Index: libwnck/window.c
===================================================================
RCS file: /cvs/gnome/libwnck/libwnck/window.c,v
retrieving revision 1.43
diff -p -u -r1.43 window.c
--- libwnck/window.c	21 Jun 2004 16:48:12 -0000	1.43
+++ libwnck/window.c	25 Jul 2004 18:02:56 -0000
@@ -46,7 +46,8 @@ static GHashTable *window_hash = NULL;
     ((window)->priv->skip_taskbar        << 5) |        \
     ((window)->priv->is_sticky           << 6) |        \
     ((window)->priv->is_hidden           << 7) |        \
-    ((window)->priv->is_fullscreen       << 8) )
+    ((window)->priv->is_fullscreen       << 8) |        \
+    ((window)->priv->demands_attention   << 9) )
 
 struct _WnckWindowPrivate
 {
@@ -97,6 +98,7 @@ struct _WnckWindowPrivate
   guint is_sticky : 1;
   guint is_hidden : 1;
   guint is_fullscreen : 1;
+  guint demands_attention : 1;
 
   /* _NET_WM_STATE_HIDDEN doesn't map directly into an
    * externally-visible state (it determines the WM_STATE
@@ -583,6 +585,25 @@ wnck_window_is_minimized (WnckWindow *wi
   return window->priv->is_minimized;
 }
 
+/**
+ * wnck_window_demands_attention:
+ * @window: a #WnckWindow
+ *
+ * If the window is has the demands attention state set returns
+ * %TRUE. This state may change anytime a state_changed signal gets
+ * emitted.
+ *
+ * Return value: %TRUE if window is minimized
+ **/
+gboolean
+wnck_window_demands_attention (WnckWindow *window)
+{
+  g_return_val_if_fail (WNCK_IS_WINDOW (window), FALSE);
+
+  return window->priv->demands_attention;
+}
+
+
 gboolean
 wnck_window_is_maximized_horizontally (WnckWindow *window)
 {
@@ -1541,6 +1562,7 @@ update_state (WnckWindow *window)
       window->priv->skip_taskbar = FALSE;
       window->priv->skip_pager = FALSE;
       window->priv->net_wm_state_hidden = FALSE;
+      window->priv->demands_attention = FALSE;
       
       atoms = NULL;
       n_atoms = 0;
@@ -1567,6 +1589,8 @@ update_state (WnckWindow *window)
             window->priv->skip_taskbar = TRUE;
           else if (atoms[i] == _wnck_atom_get ("_NET_WM_STATE_SKIP_PAGER"))
             window->priv->skip_pager = TRUE;
+          else if (atoms[i] == _wnck_atom_get ("_NET_WM_STATE_DEMANDS_ATTENTION"))
+            window->priv->demands_attention = TRUE;
 
           ++i;
         }
Index: libwnck/window.h
===================================================================
RCS file: /cvs/gnome/libwnck/libwnck/window.h,v
retrieving revision 1.23
diff -p -u -r1.23 window.h
--- libwnck/window.h	21 Jun 2004 16:48:12 -0000	1.23
+++ libwnck/window.h	25 Jul 2004 18:02:57 -0000
@@ -42,7 +42,8 @@ typedef enum
   WNCK_WINDOW_STATE_SKIP_TASKLIST          = 1 << 5,
   WNCK_WINDOW_STATE_STICKY                 = 1 << 6,
   WNCK_WINDOW_STATE_HIDDEN                 = 1 << 7,
-  WNCK_WINDOW_STATE_FULLSCREEN             = 1 << 8
+  WNCK_WINDOW_STATE_FULLSCREEN             = 1 << 8,
+  WNCK_WINDOW_STATE_DEMANDS_ATTENTION      = 1 << 9
 } WnckWindowState;
 
 typedef enum
@@ -153,6 +154,7 @@ gboolean wnck_window_is_shaded          
 gboolean wnck_window_is_skip_pager             (WnckWindow *window);
 gboolean wnck_window_is_skip_tasklist          (WnckWindow *window);
 gboolean wnck_window_is_sticky                 (WnckWindow *window);
+gboolean wnck_window_demands_attention         (WnckWindow *window);
 
 void wnck_window_set_skip_pager    (WnckWindow *window,
                                     gboolean skip);
Index: libwnck/wnck-enum-types.c
===================================================================
RCS file: /cvs/gnome/libwnck/libwnck/wnck-enum-types.c,v
retrieving revision 1.2
diff -p -u -r1.2 wnck-enum-types.c
--- libwnck/wnck-enum-types.c	18 Oct 2001 19:32:39 -0000	1.2
+++ libwnck/wnck-enum-types.c	25 Jul 2004 18:02:57 -0000
@@ -17,6 +17,7 @@ wnck_window_state_get_type (void)
       { WNCK_WINDOW_STATE_SKIP_PAGER, "WNCK_WINDOW_STATE_SKIP_PAGER", "skip-pager" },
       { WNCK_WINDOW_STATE_SKIP_TASKLIST, "WNCK_WINDOW_STATE_SKIP_TASKLIST", "skip-tasklist" },
       { WNCK_WINDOW_STATE_STICKY, "WNCK_WINDOW_STATE_STICKY", "sticky" },
+      { WNCK_WINDOW_STATE_DEMANDS_ATTENTION, "WNCK_WINDOW_STATE_DEMANDS_ATTENTION", "demands-attention" },
       { 0, NULL, NULL }
     };
     etype = g_flags_register_static ("WnckWindowState", values);
