[easytag/wip/future-gtk: 37/42] Handle UI scale factor in images tree view
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/future-gtk: 37/42] Handle UI scale factor in images tree view
- Date: Thu, 12 Feb 2015 22:42:03 +0000 (UTC)
commit 8d65b70d3b1456bb59ba9293b4569dbd7b1df024
Author: David King <amigadave amigadave com>
Date: Fri Jan 9 18:58:54 2015 +0000
Handle UI scale factor in images tree view
configure.ac | 2 +-
data/tag_area.ui | 4 ++--
src/tag_area.c | 41 ++++++++++++++++++++++++++++-------------
3 files changed, 31 insertions(+), 16 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 146a42b..ad3b729 100644
--- a/configure.ac
+++ b/configure.ac
@@ -336,7 +336,7 @@ AM_CONDITIONAL([ENABLE_NAUTILUS_ACTIONS], [test x"$have_libnautilus_extension" !
dnl Check the pkg-config dependencies
GIO_DEPS="gio-2.0 >= 2.32.0" dnl For g_file_new_tmp()
GLIB_DEPRECATION_FLAGS="-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_32
-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32"
-GTK_DEPS="gtk+-3.0 >= 3.4.0"
+GTK_DEPS="gtk+-3.0 >= 3.10.0"
GTK_DEPRECATION_FLAGS="-DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_4 -DGDK_VERSION_MAX_ALLOWED=GDK_VERSION_3_4"
PKG_CHECK_MODULES([EASYTAG], [$GIO_DEPS $GTK_DEPS $OPUS_DEPS $OGG_DEPS $SPEEX_DEPS $FLAC_DEPS $ID3TAG_DEPS
$TAGLIB_DEPS $WAVPACK_DEPS])
diff --git a/data/tag_area.ui b/data/tag_area.ui
index f555fd6..6281f8d 100644
--- a/data/tag_area.ui
+++ b/data/tag_area.ui
@@ -7,7 +7,7 @@
</object>
<object class="GtkListStore" id="images_model">
<columns>
- <column type="GdkPixbuf"/>
+ <column type="CairoSurface"/>
<column type="gchararray"/>
<column type="EtPicture"/>
</columns>
@@ -534,7 +534,7 @@
<child>
<object class="GtkCellRendererPixbuf"
id="images_thumbnail_renderer"/>
<attributes>
- <attribute name="pixbuf">0</attribute>
+ <attribute name="surface">0</attribute>
</attributes>
</child>
<child>
diff --git a/src/tag_area.c b/src/tag_area.c
index fd19885..2ce23c0 100644
--- a/src/tag_area.c
+++ b/src/tag_area.c
@@ -115,7 +115,7 @@ enum
enum /* Columns for picture_entry_view. */
{
- PICTURE_COLUMN_PIC,
+ PICTURE_COLUMN_SURFACE,
PICTURE_COLUMN_TEXT,
PICTURE_COLUMN_DATA,
PICTURE_COLUMN_COUNT
@@ -1266,7 +1266,10 @@ PictureEntry_Update (EtTagArea *self,
if (pixbuf)
{
GtkTreeIter iter1;
+ gint scale_factor;
GdkPixbuf *scaled_pixbuf;
+ cairo_surface_t *surface;
+ GdkWindow *view_window;
gint scaled_pixbuf_width;
gint scaled_pixbuf_height;
gchar *pic_info;
@@ -1277,28 +1280,40 @@ PictureEntry_Update (EtTagArea *self,
// Keep aspect ratio of the picture
pic->width = gdk_pixbuf_get_width(pixbuf);
pic->height = gdk_pixbuf_get_height(pixbuf);
+ /* TODO: Connect to notify:scale-factor and update when the
+ * scale changes. */
+ scale_factor = gtk_widget_get_scale_factor (priv->picture_entry_view);
+
if (pic->width > pic->height)
{
- scaled_pixbuf_width = 96;
- scaled_pixbuf_height = 96 * pic->height / pic->width;
+ scaled_pixbuf_width = 96 * scale_factor;
+ scaled_pixbuf_height = 96 * scale_factor * pic->height
+ / pic->width;
}else
{
- scaled_pixbuf_width = 96 * pic->width / pic->height;
- scaled_pixbuf_height = 96;
+ scaled_pixbuf_width = 96 * scale_factor * pic->width
+ / pic->height;
+ scaled_pixbuf_height = 96 * scale_factor;
}
- scaled_pixbuf = gdk_pixbuf_scale_simple(pixbuf,
- scaled_pixbuf_width, scaled_pixbuf_height,
- //GDK_INTERP_NEAREST); // Lower quality but better speed
- GDK_INTERP_BILINEAR);
- g_object_unref(pixbuf);
-
+ scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf,
+ scaled_pixbuf_width,
+ scaled_pixbuf_height,
+ GDK_INTERP_BILINEAR);
+ g_object_unref (pixbuf);
+
+ /* This ties the model to the view, so if the model is to be
+ * shared in the future, the surface should be per-view. */
+ view_window = gtk_widget_get_window (priv->picture_entry_view);
+ surface = gdk_cairo_surface_create_from_pixbuf (scaled_pixbuf,
+ scale_factor,
+ view_window);
pic_info = et_picture_format_info (pic,
ETCore->ETFileDisplayed->ETFileDescription->TagType);
gtk_list_store_insert_with_values (priv->images_model, &iter1,
G_MAXINT,
- PICTURE_COLUMN_PIC,
- scaled_pixbuf,
+ PICTURE_COLUMN_SURFACE,
+ surface,
PICTURE_COLUMN_TEXT,
pic_info,
PICTURE_COLUMN_DATA,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]