GNOME Bugzilla – Bug 597043
unusual menubar behaviour
Last modified: 2010-11-26 02:03:16 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.
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.
A proposed patch in my public branch http://gitorious.org/glassrose-gnome/empathy/commits/full_room_menu_never_insensitivated-597043
Created attachment 175213 [details] [review] Patch Patch attached
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?
Created attachment 175218 [details] [review] Reviews attended Complexity checked and commit message edited.
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.
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.
(In reply to comment #6) > Also, I PREFER "favorite" or "is-favorite" to "isFavorite". camelCase variables > are not in our coding style.
Created attachment 175223 [details] [review] Style Fixed
You need to fix the review comments too.
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.
Created attachment 175285 [details] [review] Room sub-menus updated
Merged. Thanks :)