summaryrefslogtreecommitdiff
path: root/src/caja-places-sidebar.c
diff options
context:
space:
mode:
authorJasmine Hassan <[email protected]>2012-10-27 11:33:02 +0200
committerJasmine Hassan <[email protected]>2012-11-16 09:45:50 +0200
commitbf89f7f0ec597cfc2458338643f9c6c00e80689b (patch)
treedf076124459d159d4177d97c7efc7c60b7a8359f /src/caja-places-sidebar.c
parent3434cb86b4a292da136bccd86d5ab9a10707b113 (diff)
downloadcaja-bf89f7f0ec597cfc2458338643f9c6c00e80689b.tar.bz2
caja-bf89f7f0ec597cfc2458338643f9c6c00e80689b.tar.xz
[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
Diffstat (limited to 'src/caja-places-sidebar.c')
-rw-r--r--src/caja-places-sidebar.c58
1 files 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