After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 156439 - Patch Submission: wnck-applet will rename windows in its list if the window name changes
Patch Submission: wnck-applet will rename windows in its list if the window n...
Status: RESOLVED FIXED
Product: gnome-panel
Classification: Other
Component: window selector
git master
Other Linux
: Normal normal
: ---
Assigned To: Panel Maintainers
Panel Maintainers
: 157895 158050 158597 159591 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2004-10-25 23:48 UTC by Matt T. Proud
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: 2.9/2.10


Attachments
Feature Patch (4.49 KB, patch)
2004-10-25 23:49 UTC, Matt T. Proud
needs-work Details | Review
New Feature Patch (4.48 KB, patch)
2004-10-27 04:43 UTC, Matt T. Proud
none Details | Review
Updated Patch (6.24 KB, patch)
2004-10-28 03:58 UTC, Matt T. Proud
needs-work Details | Review
Updated Patch (6.53 KB, patch)
2004-10-28 17:08 UTC, Matt T. Proud
needs-work Details | Review
2004-10-29 (7.00 KB, patch)
2004-10-29 22:10 UTC, Matt T. Proud
committed Details | Review

Description Matt T. Proud 2004-10-25 23:48:38 UTC
This patch for the Window Menu takes advantage of WNCK's "name_changed" message
when it connects to windows.
Comment 1 Matt T. Proud 2004-10-25 23:49:10 UTC
Created attachment 33050 [details] [review]
Feature Patch
Comment 2 Havoc Pennington 2004-10-27 03:55:39 UTC
Comment on attachment 33050 [details] [review]
Feature Patch

Some suggestions:
 - a separate useful change 
   would be that latest gtk 
   has ellipsization, so we 
   could clean out the Eel 
   stuff
 - braces should be on a line by themselves, indentation should be 2 spaces (in
emacs, set style to GNU)
 - I prefer "char" to "gchar" though I don't remember what most libwnck code
uses
 - it's nicer to avoid 
   assignment in the same 
   line as variable declaration
 - casting the const off of wnck_window_get_name isn't ideal, suggest instead
freeme = g_strdup() then window_name = freeme
 - it may be OK already, I'm too lazy to open the full source file, but should
be sure destroying a window while the menu is up won't hose us somehow

Thanks! Certainly seems like a good patch in all but nitpick aspects.
Comment 3 Matt T. Proud 2004-10-27 04:43:42 UTC
Created attachment 33102 [details] [review]
New Feature Patch

This patch should fix what you have mentioned, with the exception of
integrating Gtk's new ellipsizing features. The only thing I should is that I
changed my Emacs style to GNU, but I just followed the indentation and bracket
styles used throughout the rest of this file, as exemplified by lines 197-200.

I hope this works.
Comment 4 Matt T. Proud 2004-10-28 03:58:21 UTC
Created attachment 33154 [details] [review]
Updated Patch

This patch has better division of labor than the prior ones and makes use of
Gtk's new ellipsizing label.
Comment 5 Vincent Untz 2004-10-28 07:44:20 UTC
Comment on attachment 33154 [details] [review]
Updated Patch

Thanks for the patch!
I read the patch quickly, but it looks good.

>+/* 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;
>+}

It seems you're leaking name when the window is minimized or shaded.

>+	gtk_label_set_ellipsize (GTK_LABEL (ellipsizing_label), PANGO_ELLIPSIZE_MIDDLE);

Why PANGO_ELLIPSIZE_MIDDLE? Does it look better than PANGO_ELLIPSIZE_END?
Comment 6 Matt T. Proud 2004-10-28 17:08:54 UTC
Created attachment 33172 [details] [review]
Updated Patch

This patch should fix all of the aforementioned problems. I set it to use
PANGO_ELLIPSIZE_END, but I personally think that PANGO_ELLIPSIZE_MIDDLE would
be better. This is open to discussion, though I will be fine with whatever is
chosen.

The reason that I say that I am fine with whatever is chosen is that I am
working on a large patch set to contribute to this applet that provides a
configuration dialog; so I thought that users could be given a choice, once I
submit that larger patch set
(http://www.nerp.net/~khanreaper/window-menu-patch/).
Comment 7 Vincent Untz 2004-10-29 10:44:37 UTC
Comment on attachment 33172 [details] [review]
Updated Patch

>@@ -54,6 +53,7 @@ typedef struct {
> 	GdkPixbuf    *icon_pixbuf;
> 	WnckWindow   *icon_window;
> 	GHashTable   *window_hash;
>+	GHashTable   *label_hash;

It'd be nice to use one hash instead of these two. Not sure if it's easily
doable,
though

>+/* The results of this function will need to be freed. */
>+static const char *

You can reomve the const from here and so we'll have less casts later :-)

>+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);
>+		g_free ((char *)name);
>+	} else if (wnck_window_is_minimized (window)) {
>+		return_value = g_strdup_printf ("[%s]", name);
>+		g_free ((char *)name);
>+	} else
>+		return_value = name;
>+
>+	return return_value;
>+}
>+

Ok, I suggest something like:

	const char *const_name;
	char	   *name;
	char	   *return_value;

	const_name = wnck_window_get_name (window);
	if (!name)
		name = g_strdup (_("Unknown Window"));
	else
		name = g_strdup (const_name);

	if (wnck_window_is_shaded (window)) {
		return_value = g_strdup_printf ("=%s=", name);
		g_free (name);
	} else if (wnck_window_is_minimized (window)) {
		return_value = g_strdup_printf ("[%s]", name);
		g_free (name);
	} else
		return_value = name;

	return return_value;

Easier to understand this way (well, at least for me)

>+	if (make_bold == TRUE)

"if (make_bold)" will be enough :-)

Do you have CVS access?
Comment 8 Elijah Newren 2004-10-29 19:22:51 UTC
See also bug 155868; I'm not sure whether the ellipsization belongs in libwnck
or wnck-applet, but it appears there's competing requests...
Comment 9 Matt T. Proud 2004-10-29 22:10:26 UTC
Created attachment 33224 [details] [review]
2004-10-29

Vincent, this patch should address what you have mentioned. I appreciated your
advice and employed a new structure, getting rid of that extra hash-table.

With regard to your question about CVS access, I do not have write access to
the tree.
Comment 10 Havoc Pennington 2004-10-30 15:51:42 UTC
fwiw I don't think making ellipsization style configurable is a good idea. ;-)
But I guess that can be discussed on a separate bug about separate patches.
Comment 11 Vincent Untz 2004-10-30 16:12:57 UTC
Matt: I committed your patch to HEAD. Oh, and I agree with Havoc, but we can
discuss about this in another bug
Comment 12 Elijah Newren 2004-11-10 21:51:03 UTC
*** Bug 157895 has been marked as a duplicate of this bug. ***
Comment 13 Elijah Newren 2004-11-12 15:07:18 UTC
*** Bug 158050 has been marked as a duplicate of this bug. ***
Comment 14 Elijah Newren 2004-11-18 02:24:42 UTC
*** Bug 158597 has been marked as a duplicate of this bug. ***
Comment 15 Elijah Newren 2004-11-27 03:34:28 UTC
*** Bug 159591 has been marked as a duplicate of this bug. ***