Index: applets/wncklet/ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-panel/applets/wncklet/ChangeLog,v
retrieving revision 1.542
diff -u -p -r1.542 ChangeLog
--- applets/wncklet/ChangeLog	23 Oct 2004 10:12:24 -0000	1.542
+++ applets/wncklet/ChangeLog	28 Oct 2004 03:56:36 -0000
@@ -1,3 +1,16 @@
+2004-10-27  Matt T. Proud  <khanreaper@nerp.net>
+	* window-menu.c (window_menu_get_window_name): This has become the 
+	universal function to get formatted window names.
+	(window_menu_window_name_changed): This serves as the callback 
+	function that updates the applet's list when a window's name
+	changes.
+	(window_menu_item_new): Now uses Gtk+'s ellipsizing label.
+	(window_menu_add_window): Removed original code that names windows;
+	it now uses window_menu_get_window_name.
+	(window_menu_connect_to_window): Now registers "name_changed" callback.
+	(window_menu_destroy_menu) and (window_menu_popup_menu): Added a new
+	hash table.
+	
 2004-10-23  Crispin Flowerday  <gnome@flowerday.cx>
 
 	* window-menu.c (window_menu_destroy), (window_menu_destroy_menu) 
Index: applets/wncklet/window-menu.c
===================================================================
RCS file: /cvs/gnome/gnome-panel/applets/wncklet/window-menu.c,v
retrieving revision 1.23
diff -u -p -r1.23 window-menu.c
--- applets/wncklet/window-menu.c	23 Oct 2004 10:12:24 -0000	1.23
+++ applets/wncklet/window-menu.c	28 Oct 2004 03:56:36 -0000
@@ -39,7 +39,6 @@
 #include <libwnck/libwnck.h>
 
 #include "inlinepixbufs.h"
-#include "eel/eel-ellipsizing-label.h"
 #include "wncklet.h"
 
 typedef struct {
@@ -54,6 +53,7 @@ typedef struct {
 	GdkPixbuf    *icon_pixbuf;
 	WnckWindow   *icon_window;
 	GHashTable   *window_hash;
+	GHashTable   *label_hash;
 
 	int           size;
 
@@ -327,6 +327,46 @@ window_menu_window_icon_changed (WnckWin
 		window_menu_set_active_window (window_menu, window);
 }
 
+/* The returned value will need to be freed. */
+static const char *
+window_menu_get_window_name (WnckWindow *window)
+{
+	const char *return_value;
+	const char *name;
+
+       	name = wnck_window_get_name (window);
+	if (!name)
+		name = g_strdup(_("Unknown Window"));
+	else
+		name = g_strdup (name);
+	
+	if (wnck_window_is_shaded (window))
+		return_value = g_strdup_printf ("=%s=", name);
+	else if (wnck_window_is_minimized (window))
+		return_value = g_strdup_printf ("[%s]", name);
+	else
+		return_value = name;
+	return return_value;
+}
+
+static void
+window_menu_window_name_changed (WnckWindow *window,
+				 WindowMenu *window_menu)
+{
+	gpointer item;
+	const char *window_name;
+
+	item = NULL;
+	window_name = NULL;
+	item = g_hash_table_lookup (window_menu->label_hash, window);
+	if (item != NULL) {
+		window_name = window_menu_get_window_name (window);
+		gtk_label_set_text (GTK_LABEL (item), window_name);
+		if (window_name != NULL)
+			g_free ((char *)window_name);
+	}
+}
+
 static void
 window_menu_active_window_changed (WnckScreen *screen,
 				   WindowMenu *window_menu)
@@ -392,16 +432,25 @@ get_width (GtkWidget *widget, const char
 static GtkWidget*
 window_menu_item_new (WindowMenu  *window_menu,
 		      const gchar *label,
-		      gboolean make_bold)
+		      WnckWindow *window)
 {
 	GtkWidget *item;
 	GtkWidget *ellipsizing_label;
+	gboolean make_bold;
 
 	item = gtk_image_menu_item_new ();
 	
-	ellipsizing_label = eel_ellipsizing_label_new (label);
+	ellipsizing_label = gtk_label_new (label);
+	gtk_label_set_ellipsize (GTK_LABEL (ellipsizing_label), PANGO_ELLIPSIZE_MIDDLE);
+
 	gtk_misc_set_alignment (GTK_MISC (ellipsizing_label), 0.0, 0.5);
-	if (make_bold)
+	if (window == NULL)
+		make_bold = FALSE;
+	else {
+		make_bold = wnck_window_demands_attention (window);
+		g_hash_table_insert (window_menu->label_hash, window, ellipsizing_label);
+	}
+	if (make_bold == TRUE)
 		window_menu_make_label_bold (GTK_LABEL (ellipsizing_label));
 
 	gtk_container_add (GTK_CONTAINER (item), ellipsizing_label);
@@ -421,31 +470,17 @@ window_menu_add_window (WindowMenu *wind
 	GtkWidget     *item;
 	GtkWidget     *image;
 	const char    *name;
-	char          *label;
-	char          *freeme = NULL;
 
 	if (wnck_window_is_skip_tasklist (window))
 		return;
 
-	name = wnck_window_get_name (window);
-	if (!name)
-		name = _("Unknown Window");
-
-	if (wnck_window_is_shaded (window)) {
-		label = g_strdup_printf ("=%s=", name);
-		freeme = label;
-	} else if (wnck_window_is_minimized (window)) {
-		label = g_strdup_printf ("[%s]", name);
-		freeme = label;
-	} else {
-		label = (char *) name;
-	}
+	name = window_menu_get_window_name (window);
 
 	item = window_menu_item_new (window_menu,
-				     label,
-				     wnck_window_demands_attention (window));
-	if (freeme)
-		g_free (freeme);
+				     name,
+				     window);
+	if (name != NULL)
+		g_free ((char *)name);
 
 	image = gtk_image_new ();
 
@@ -516,6 +551,10 @@ window_menu_connect_to_window (WindowMen
 				     G_CALLBACK (window_menu_window_icon_changed),
 				     window_menu,
 				     window_menu->applet);
+	wncklet_connect_while_alive (window, "name_changed",
+				     G_CALLBACK (window_menu_window_name_changed),
+				     window_menu,
+				     window_menu->applet);
 }
 
 static void
@@ -546,7 +585,10 @@ window_menu_destroy_menu (GtkWidget  *wi
 
 	if (window_menu->window_hash)
 		g_hash_table_destroy (window_menu->window_hash);
+	if (window_menu->label_hash)
+		g_hash_table_destroy (window_menu->label_hash);
 	window_menu->window_hash = NULL;
+	window_menu->label_hash = NULL;
 	window_menu->no_windows_item = NULL;
 }
 
@@ -622,6 +664,9 @@ window_menu_popup_menu (WindowMenu *wind
 	if (window_menu->window_hash)
 		g_hash_table_destroy (window_menu->window_hash);
 	window_menu->window_hash = g_hash_table_new (g_direct_hash, g_direct_equal);
+	if (window_menu->label_hash)
+		g_hash_table_destroy (window_menu->label_hash);
+	window_menu->label_hash = g_hash_table_new (g_direct_hash, g_direct_equal);
 
 	for (l = windows; l; l = l->next)
 		window_menu_add_window (window_menu, l->data);
@@ -636,7 +681,7 @@ window_menu_popup_menu (WindowMenu *wind
 		window_menu->no_windows_item =
 			window_menu_item_new (window_menu,
 					      _("No Windows Open"),
-					      FALSE);
+					      NULL);
 
 		gtk_widget_set_sensitive (window_menu->no_windows_item, FALSE);
 		gtk_widget_show (window_menu->no_windows_item);	
