[gthumb] desktop background: fixed style when using multiple monitors



commit 8127778d4a920553a32d4390999b6a5882691812
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Thu Jan 12 11:24:21 2017 +0100

    desktop background: fixed style when using multiple monitors
    
    use the primary monitor geometry to decide the background style

 extensions/desktop_background/actions.c |   40 +++++++++++++++++--------------
 1 files changed, 22 insertions(+), 18 deletions(-)
---
diff --git a/extensions/desktop_background/actions.c b/extensions/desktop_background/actions.c
index 10a54a7..af7a227 100644
--- a/extensions/desktop_background/actions.c
+++ b/extensions/desktop_background/actions.c
@@ -269,7 +269,10 @@ wallpaper_metadata_ready_cb (GObject      *source_object,
        WallpaperData *wdata = user_data;
        GList         *file_list;
        GError        *error = NULL;
-       GdkScreen     *screen;
+       GthFileData   *file_data;
+       int            image_width;
+       int            image_height;
+       GdkRectangle   monitor_geometry;
 
        file_list = _g_query_metadata_finish (result, &error);
        if (error != NULL) {
@@ -282,23 +285,24 @@ wallpaper_metadata_ready_cb (GObject      *source_object,
 
        wdata->new_style.background_style = BACKGROUND_STYLE_WALLPAPER;
 
-       screen = gtk_widget_get_screen (GTK_WIDGET (wdata->browser));
-       if (gdk_screen_get_n_monitors (screen) == 1) {
-               GthFileData *file_data;
-               int          image_width;
-               int          image_height;
-               int          screen_width;
-               int          screen_height;
-
-               file_data = file_list->data;
-               image_width = g_file_info_get_attribute_int32 (file_data->info, "image::width");
-               image_height = g_file_info_get_attribute_int32 (file_data->info, "image::height");
-               screen_width = gdk_screen_get_width (screen);
-               screen_height = gdk_screen_get_height (screen);
-
-               if ((image_width >= screen_width / 2) && (image_height >= screen_height / 2))
-                       wdata->new_style.background_style = BACKGROUND_STYLE_STRETCHED;
-       }
+       /* use ZOOM if the image has a size similar to the monitor's */
+
+#if GTK_CHECK_VERSION(3, 22, 0)
+
+       gdk_monitor_get_geometry (gdk_display_get_primary_monitor (gtk_widget_get_display (GTK_WIDGET 
(wdata->browser))), &monitor_geometry);
+
+#else
+
+       gdk_screen_get_monitor_geometry (gtk_widget_get_screen (GTK_WIDGET (wdata->browser)), 0, 
&monitor_geometry);
+
+#endif
+
+       file_data = file_list->data;
+       image_width = g_file_info_get_attribute_int32 (file_data->info, "image::width");
+       image_height = g_file_info_get_attribute_int32 (file_data->info, "image::height");
+
+       if ((image_width >= monitor_geometry.width / 2) && (image_height >= monitor_geometry.height / 2))
+               wdata->new_style.background_style = BACKGROUND_STYLE_ZOOM;
 
        wallpaper_data_set__step2 (wdata);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]