summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlukefromdc <[email protected]>2017-12-12 02:52:45 -0500
committerlukefromdc <[email protected]>2017-12-14 17:48:31 -0500
commitc6b81f64c4c4212e414c04e584380774d6ac83ca (patch)
tree10aa78ac4ec9792a075cbeb7596e3434b7b7c9a0
parentb7eac84c00bcfb41e066f0d2c538f8d3b17054e0 (diff)
downloadcaja-c6b81f64c4c4212e414c04e584380774d6ac83ca.tar.bz2
caja-c6b81f64c4c4212e414c04e584380774d6ac83ca.tar.xz
Fix #880 and fix refusal to unmount when sidebar is wide
caja-places-sidebar: revert all kludges for eject behavior: Revert https://github.com/mate-desktop/caja/commit/d14fef384a435471860130f7337d5dea5bb824a0 https://github.com/mate-desktop/caja/commit/9b2e152876067aaee3baa699c51c6c6174d4954e and https://github.com/mate-desktop/caja/commit/30f19d0aed3e40a3682f820059ebb8b3038ba84e the last being a subset of a commit we'll apply later caja-places-sidebar: fix eject button hover, eject behavior Apply https://github.com/GNOME/nautilus/commit/f294a4e80626793624d76d6002b094d1c0809de4 "Fix up eject button hover in places sidebar" We were calling gtk_tree_view_column_cell_get_position() without properly loading the cell attribute for the right row before. We fix this by calling gtk_tree_view_column_cell_set_cell_data(). With this in place we can also use the x_offset for the position and avoid the whole summing of widths. Due to a bug in Gtk which expands the eject icon cell renderer we have to right align it so that it lines up properly. https://bugzilla.gnome.org/show_bug.cgi?id=640741 caja-places-sidebar: disable overlay scrollbar disable overlay scrollbars as they force the use of too much padding
-rw-r--r--src/caja-places-sidebar.c67
1 files changed, 23 insertions, 44 deletions
diff --git a/src/caja-places-sidebar.c b/src/caja-places-sidebar.c
index 22652671..93c42e62 100644
--- a/src/caja-places-sidebar.c
+++ b/src/caja-places-sidebar.c
@@ -60,10 +60,7 @@ typedef struct
{
GtkScrolledWindow parent;
GtkTreeView *tree_view;
- GtkCellRenderer *eject_text_cell_renderer;
- GtkCellRenderer *icon_cell_renderer;
- GtkCellRenderer *icon_padding_cell_renderer;
- GtkCellRenderer *padding_cell_renderer;
+ GtkCellRenderer *eject_icon_cell_renderer;
char *uri;
GtkListStore *store;
GtkTreeModel *filter_model;
@@ -964,8 +961,7 @@ over_eject_button (CajaPlacesSidebar *sidebar,
GtkTreePath **path)
{
GtkTreeViewColumn *column;
- GtkTextDirection direction;
- int width, total_width;
+ int width, x_offset, hseparator;
int eject_button_size;
gboolean show_eject;
GtkTreeIter iter;
@@ -987,45 +983,26 @@ over_eject_button (CajaPlacesSidebar *sidebar,
goto out;
}
- total_width = 0;
-
gtk_widget_style_get (GTK_WIDGET (sidebar->tree_view),
- "horizontal-separator", &width,
+ "horizontal-separator",&hseparator,
NULL);
- total_width += width;
-
- direction = gtk_widget_get_direction (GTK_WIDGET (sidebar->tree_view));
- if (direction != GTK_TEXT_DIR_RTL) {
- gtk_tree_view_column_cell_get_position (column,
- sidebar->padding_cell_renderer,
- NULL, &width);
- total_width += width;
-
- gtk_tree_view_column_cell_get_position (column,
- sidebar->icon_padding_cell_renderer,
- NULL, &width);
- total_width += width;
-
- gtk_tree_view_column_cell_get_position (column,
- sidebar->icon_cell_renderer,
- NULL, &width);
- total_width += width;
-
- gtk_tree_view_column_cell_get_position (column,
- sidebar->eject_text_cell_renderer,
- NULL, &width);
- total_width += width;
- }
+ /* Reload cell attributes for this particular row */
+ gtk_tree_view_column_cell_set_cell_data (column,
+ model, &iter, FALSE, FALSE);
- total_width += EJECT_BUTTON_XPAD;
+ gtk_tree_view_column_cell_get_position (column,
+ sidebar->eject_icon_cell_renderer,
+ &x_offset, &width);
eject_button_size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU);
- if (x - total_width >= 0 &&
- /* fix unwanted unmount requests if clicking on the label */
- x >= total_width - eject_button_size &&
- x >= 80 &&
- x - total_width <= eject_button_size) {
+ /* This is kinda weird, but we have to do it to workaround gtk+ expanding
+ * the eject cell renderer (even thought we told it not to) and we then
+ * had to set it right-aligned */
+ x_offset += width - hseparator - EJECT_BUTTON_XPAD - eject_button_size;
+
+ if (x - x_offset >= 0 &&
+ x - x_offset <= eject_button_size) {
return TRUE;
}
}
@@ -3168,7 +3145,9 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar)
gtk_scrolled_window_set_hadjustment (GTK_SCROLLED_WINDOW (sidebar), NULL);
gtk_scrolled_window_set_vadjustment (GTK_SCROLLED_WINDOW (sidebar), NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sidebar), GTK_SHADOW_IN);
-
+#if GTK_CHECK_VERSION (3, 16, 0)
+ gtk_scrolled_window_set_overlay_scrolling(GTK_SCROLLED_WINDOW (sidebar), FALSE);
+#endif
/* tree view */
tree_view = GTK_TREE_VIEW (gtk_tree_view_new ());
gtk_tree_view_set_headers_visible (tree_view, FALSE);
@@ -3177,7 +3156,6 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar)
/* initial padding */
cell = gtk_cell_renderer_text_new ();
- sidebar->padding_cell_renderer = cell;
gtk_tree_view_column_pack_start (col, cell, FALSE);
g_object_set (cell,
"xpad", 6,
@@ -3201,7 +3179,6 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar)
/* icon padding */
cell = gtk_cell_renderer_text_new ();
- sidebar->icon_padding_cell_renderer = cell;
gtk_tree_view_column_pack_start (col, cell, FALSE);
gtk_tree_view_column_set_cell_data_func (col, cell,
padding_cell_renderer_func,
@@ -3209,7 +3186,6 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar)
/* icon renderer */
cell = gtk_cell_renderer_pixbuf_new ();
- sidebar->icon_cell_renderer = cell;
gtk_tree_view_column_pack_start (col, cell, FALSE);
gtk_tree_view_column_set_attributes (col, cell,
"pixbuf", PLACES_SIDEBAR_COLUMN_ICON,
@@ -3220,7 +3196,6 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar)
/* eject text renderer */
cell = gtk_cell_renderer_text_new ();
- sidebar->eject_text_cell_renderer = cell;
gtk_tree_view_column_pack_start (col, cell, TRUE);
gtk_tree_view_column_set_attributes (col, cell,
"text", PLACES_SIDEBAR_COLUMN_NAME,
@@ -3233,10 +3208,14 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar)
/* eject icon renderer */
cell = gtk_cell_renderer_pixbuf_new ();
+ sidebar->eject_icon_cell_renderer = cell;
g_object_set (cell,
"mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE,
"stock-size", GTK_ICON_SIZE_MENU,
"xpad", EJECT_BUTTON_XPAD,
+ /* align right, because for some reason gtk+ expands
+ this even though we tell it not to. */
+ "xalign", 1.0,
NULL);
gtk_tree_view_column_pack_start (col, cell, FALSE);
gtk_tree_view_column_set_attributes (col, cell,