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 597043 - unusual menubar behaviour
unusual menubar behaviour
Status: RESOLVED FIXED
Product: empathy
Classification: Core
Component: General
unspecified
Other Linux
: Normal minor
: ---
Assigned To: empathy-maint
empathy-maint
Depends on:
Blocks:
 
 
Reported: 2009-10-01 20:40 UTC by Matthias Clasen
Modified: 2010-11-26 02:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch (1.63 KB, patch)
2010-11-25 02:31 UTC, Chandni Verma
needs-work Details | Review
Reviews attended (2.51 KB, patch)
2010-11-25 07:30 UTC, Chandni Verma
needs-work Details | Review
Style Fixed (2.15 KB, patch)
2010-11-25 08:29 UTC, Chandni Verma
needs-work Details | Review
Room sub-menus updated (2.04 KB, patch)
2010-11-26 01:54 UTC, Chandni Verma
none Details | Review

Description Matthias Clasen 2009-10-01 20:40:50 UTC
I just started empathy without any configured accounts, and it came up with the Rooms menuitem in the menubar insensitive. Now, having no accounts might be an unusual situation, but the behaviour is not as expected for menubars. If a menu is entirely unavailable, it is customary to just hide/remove the menuitem from the menubar.
Comment 1 Guillaume Desmottes 2009-10-02 10:45:37 UTC
The menu is insensitive when your accounts are disconnected. But I agree, it could make sense to to manage favorites while being offline so we should just insensitive the join items.
Comment 2 Chandni Verma 2010-11-25 02:23:26 UTC
A proposed patch in my public branch http://gitorious.org/glassrose-gnome/empathy/commits/full_room_menu_never_insensitivated-597043
Comment 3 Chandni Verma 2010-11-25 02:31:20 UTC
Created attachment 175213 [details] [review]
Patch

Patch attached
Comment 4 Danielle Madeley 2010-11-25 02:37:45 UTC
Review of attachment 175213 [details] [review]:

In the commit message: insensitivated is not a word, rerquired is typoed, and the sentence doesn't really make sense.

::: src/empathy-main-window.c
@@ +627,3 @@
+	{
+		gtk_widget_set_sensitive (GTK_WIDGET (g_list_nth_data (children, i)), connected);
+	}

This is very wrong. You have made this loop O(n^2).

If you want to start at the 3rd item (which I don't like, is there any better way to identify the first favourite?), do this:

for (ptr = g_list_nth (children, 3); ptr != NULL; ptr = ptr->next)

I think however you need to find a better method to work out what items need to be (in)sensitive. Perhaps they are/can be marked as favourites in some way when they're created?
Comment 5 Chandni Verma 2010-11-25 07:30:12 UTC
Created attachment 175218 [details] [review]
Reviews attended

Complexity checked and commit message edited.
Comment 6 Danielle Madeley 2010-11-25 07:49:28 UTC
Review of attachment 175218 [details] [review]:

::: src/empathy-main-window.c
@@ +626,3 @@
+	children = g_list_first (children);
+	widget = GTK_WIDGET (children->data);
+	while (children != NULL)

A while-loop is the wrong pattern.

for (l = children; l != NULL; l = l->next)

@@ +1132,3 @@
 	menu_item = gtk_menu_item_new_with_label (name);
+	isFavorite = TRUE;
+	g_object_set_data (G_OBJECT (menu_item), "isFavorite", &isFavorite);

This is incorrect. You don't pass a ref, you just pass the value.

g_object_set_data (..., GUINT_TO_POINTER (TRUE));

Also, I refer "favorite" or "is-favorite" to "isFavorite". camelCase variables are not in our coding style.
Comment 7 Danielle Madeley 2010-11-25 07:51:00 UTC
Also you need to follow the coding-style of the rest of the file. It's the old Gossip coding style, not the Telepathy coding style.
Comment 8 Danielle Madeley 2010-11-25 07:52:39 UTC
(In reply to comment #6)

> Also, I PREFER "favorite" or "is-favorite" to "isFavorite". camelCase variables
> are not in our coding style.
Comment 9 Chandni Verma 2010-11-25 08:29:34 UTC
Created attachment 175223 [details] [review]
Style Fixed
Comment 10 Danielle Madeley 2010-11-25 10:41:04 UTC
You need to fix the review comments too.
Comment 11 Danielle Madeley 2010-11-25 11:07:33 UTC
Review of attachment 175223 [details] [review]:

::: src/empathy-main-window.c
@@ +604,3 @@
 	gboolean connected, connecting;
+	GList *l, *children;
+	GtkWidget *widget;

Move this inside the block where you use it.

@@ +620,3 @@
 	for (l = priv->actions_connected; l; l = l->next) {
 		gtk_action_set_sensitive (l->data, connected);
 	}

^^^ Have a look at how this list is iterated, that's how it's done ^^^

@@ +624,3 @@
+	/* Update favourite rooms sensitivity */
+	children = gtk_container_get_children (GTK_CONTAINER (priv->room_menu));
+	for (l = g_list_first (children); l != NULL; l = l->next) {

You don't need to call g_list_first(), @children is already the first element in the list.

@@ +625,3 @@
+	children = gtk_container_get_children (GTK_CONTAINER (priv->room_menu));
+	for (l = g_list_first (children); l != NULL; l = l->next) {
+		widget = GTK_WIDGET (children->data);

You want to use l->data. children->data is always the same variable.

Also you can probably just skip this assignment, since you have to cast is to both GObject and GtkWidget, use l->data both times?

@@ +626,3 @@
+	for (l = g_list_first (children); l != NULL; l = l->next) {
+		widget = GTK_WIDGET (children->data);
+		if (g_object_get_data(G_OBJECT (widget), "is_favorite") != NULL)	{

Missing space.

@@ +629,3 @@
+			gtk_widget_set_sensitive (GTK_WIDGET (widget), connected);
+		}
+		children = g_list_next (children);

If you call g_list_next() you're iterating through the loop two steps at a time.
Comment 12 Chandni Verma 2010-11-26 01:54:44 UTC
Created attachment 175285 [details] [review]
Room sub-menus updated
Comment 13 Danielle Madeley 2010-11-26 02:03:16 UTC
Merged. Thanks :)