From bf89f7f0ec597cfc2458338643f9c6c00e80689b Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 11:33:02 +0200 Subject: [places-sidebar] don't update the icon if it's not visible This greatly reduces the number of times we have to create a pixbuf (only once-per-highlight now). http://git.gnome.org/browse/nautilus/commit/?id=6f5777b81958ce6f3dbc6bac3323d423d3dcc20b --- src/caja-places-sidebar.c | 58 ++++++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/src/caja-places-sidebar.c b/src/caja-places-sidebar.c index 78837dd3..714fe6dd 100644 --- a/src/caja-places-sidebar.c +++ b/src/caja-places-sidebar.c @@ -2654,6 +2654,9 @@ update_eject_buttons (CajaPlacesSidebar *sidebar, GtkTreePath *path) { GtkTreeIter iter; + gboolean icon_visible; + + icon_visible = TRUE; if (!path && !sidebar->eject_highlight_path) { /* Both are null - highlight up to date */ @@ -2667,37 +2670,50 @@ update_eject_buttons (CajaPlacesSidebar *sidebar, return; } - /* Reset last path */ - if (sidebar->eject_highlight_path) { - gtk_tree_model_get_iter (GTK_TREE_MODEL (sidebar->store), - &iter, - sidebar->eject_highlight_path); - - gtk_list_store_set (GTK_LIST_STORE (sidebar->store), - &iter, - PLACES_SIDEBAR_COLUMN_EJECT_ICON, get_eject_icon (FALSE), - -1); - - gtk_tree_path_free (sidebar->eject_highlight_path); - } - - /* Update current path */ if (path) { gtk_tree_model_get_iter (GTK_TREE_MODEL (sidebar->store), &iter, path); - gtk_list_store_set (GTK_LIST_STORE (sidebar->store), + gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter, - PLACES_SIDEBAR_COLUMN_EJECT_ICON, get_eject_icon (TRUE), + PLACES_SIDEBAR_COLUMN_EJECT, &icon_visible, -1); } - if (path) { - sidebar->eject_highlight_path = gtk_tree_path_copy (path); - } else { - sidebar->eject_highlight_path = NULL; + if (!icon_visible || !path) { + /* remove highlighting and reset the saved path, as we are leaving + * an eject button area. + */ + if (sidebar->eject_highlight_path) { + gtk_tree_model_get_iter (GTK_TREE_MODEL (sidebar->store), + &iter, + sidebar->eject_highlight_path); + + gtk_list_store_set (sidebar->store, + &iter, + PLACES_SIDEBAR_COLUMN_EJECT_ICON, get_eject_icon (FALSE), + -1); + + gtk_tree_path_free (sidebar->eject_highlight_path); + sidebar->eject_highlight_path = NULL; + } + + return; } + + /* add highlighting to the selected path, as the icon is visible and + * we're hovering it. + */ + gtk_tree_model_get_iter (GTK_TREE_MODEL (sidebar->store), + &iter, + path); + + gtk_list_store_set (sidebar->store, + &iter, + PLACES_SIDEBAR_COLUMN_EJECT_ICON, get_eject_icon (TRUE), + -1); + sidebar->eject_highlight_path = gtk_tree_path_copy (path); } static gboolean -- cgit v1.2.1