From f79ae5a34a725c8b5aa8266067d44a78397adc34 Mon Sep 17 00:00:00 2001 From: Stefano Karapetsas Date: Fri, 24 Jan 2014 17:17:33 +0100 Subject: Fix thumbnails sidebar resizing issues with GTK3 Closes #58 https://github.com/mate-desktop/atril/issues/58 https://git.gnome.org/browse/evince/commit/shell/ev-sidebar-thumbnails.c?id=a621f05b42468606c8a04446d54b637ecdd05c9b https://git.gnome.org/browse/evince/commit/shell/ev-sidebar-thumbnails.c?id=1e88e7fd7630c28453475e48b98941ce11b130a6 --- shell/ev-sidebar-thumbnails.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'shell/ev-sidebar-thumbnails.c') diff --git a/shell/ev-sidebar-thumbnails.c b/shell/ev-sidebar-thumbnails.c index 913d8504..ec03d998 100644 --- a/shell/ev-sidebar-thumbnails.c +++ b/shell/ev-sidebar-thumbnails.c @@ -669,12 +669,37 @@ static void ev_sidebar_init_icon_view (EvSidebarThumbnails *ev_sidebar_thumbnails) { EvSidebarThumbnailsPrivate *priv; +#if GTK_CHECK_VERSION (3, 0, 0) + GtkCellRenderer *renderer; +#endif priv = ev_sidebar_thumbnails->priv; priv->icon_view = gtk_icon_view_new_with_model (GTK_TREE_MODEL (priv->list_store)); +#if GTK_CHECK_VERSION (3, 0, 0) + renderer = g_object_new (GTK_TYPE_CELL_RENDERER_PIXBUF, + "xalign", 0.5, + "yalign", 1.0, + NULL); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (priv->icon_view), renderer, FALSE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (priv->icon_view), + renderer, "pixbuf", 1, NULL); + + renderer = g_object_new (GTK_TYPE_CELL_RENDERER_TEXT, + "alignment", PANGO_ALIGN_CENTER, + "wrap-mode", PANGO_WRAP_WORD_CHAR, + "xalign", 0.5, + "yalign", 0.0, + "width", THUMBNAIL_WIDTH, + "wrap-width", THUMBNAIL_WIDTH, + NULL); + gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (priv->icon_view), renderer, FALSE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (priv->icon_view), + renderer, "markup", 0, NULL); +#else gtk_icon_view_set_markup_column (GTK_ICON_VIEW (priv->icon_view), 0); gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (priv->icon_view), 1); +#endif g_signal_connect (priv->icon_view, "selection-changed", G_CALLBACK (ev_sidebar_icon_selection_changed), ev_sidebar_thumbnails); @@ -706,10 +731,14 @@ ev_sidebar_thumbnails_init (EvSidebarThumbnails *ev_sidebar_thumbnails) priv->swindow = gtk_scrolled_window_new (NULL, NULL); /* We actually don't want GTK_POLICY_AUTOMATIC for horizontal scrollbar here - * it's just a workaround for bug #449462 + * it's just a workaround for bug #449462 (GTK2 only) */ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->swindow), +#if GTK_CHECK_VERSION (3, 0, 0) + GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); +#else GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); +#endif gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (priv->swindow), GTK_SHADOW_IN); priv->vadjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->swindow)); -- cgit v1.2.1