aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-01-07 10:25:13 +0100
committerChristian Grothoff <christian@grothoff.org>2019-01-07 10:25:23 +0100
commit590a22810efe6ad3c87b0e85dc8042c01f81e5e1 (patch)
tree430059ea188ec1965077acce968095dbab53192a
parenta99c1e21b689f94d4dd706acbacccda373c97721 (diff)
downloadgnunet-gtk-590a22810efe6ad3c87b0e85dc8042c01f81e5e1.tar.gz
gnunet-gtk-590a22810efe6ad3c87b0e85dc8042c01f81e5e1.zip
scale adjustment to dpi of screen for qr code
-rw-r--r--src/namestore/gnunet-namestore-gtk.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/namestore/gnunet-namestore-gtk.c b/src/namestore/gnunet-namestore-gtk.c
index 9732088a..3f87799a 100644
--- a/src/namestore/gnunet-namestore-gtk.c
+++ b/src/namestore/gnunet-namestore-gtk.c
@@ -613,20 +613,39 @@ setup_qrcode ()
613{ 613{
614 GdkPixbuf *pb; 614 GdkPixbuf *pb;
615 GtkImage *image; 615 GtkImage *image;
616 GdkScreen *screen;
617 GtkSettings *settings;
618 gint dpi;
619 int scale;
616 620
617 pb = create_qrcode (2);
618 if (NULL == pb)
619 {
620 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
621 _("Failed to initialize QR-code pixbuf\n"));
622 return;
623 }
624 image = GTK_IMAGE (get_object ("gnunet_namestore_gtk_qr_image")); 621 image = GTK_IMAGE (get_object ("gnunet_namestore_gtk_qr_image"));
625 if (NULL == image) 622 if (NULL == image)
626 { 623 {
627 GNUNET_break (0); 624 GNUNET_break (0);
628 return; 625 return;
629 } 626 }
627 /* adjust scale to screen resolution */
628 screen = gtk_widget_get_screen (GTK_WIDGET (image));
629 settings = gtk_settings_get_for_screen (screen);
630 g_object_get (G_OBJECT (settings),
631 "gtk-xft-dpi",
632 &dpi,
633 NULL);
634 if (-1 == dpi)
635 scale = 2;
636 else if (dpi >= 122800)
637 scale = 4;
638 else if (dpi >= 98304)
639 scale = 3;
640 else
641 scale = 2;
642 pb = create_qrcode (scale);
643 if (NULL == pb)
644 {
645 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
646 _("Failed to initialize QR-code pixbuf\n"));
647 return;
648 }
630 gtk_image_set_from_pixbuf (image, pb); 649 gtk_image_set_from_pixbuf (image, pb);
631 g_object_unref (pb); 650 g_object_unref (pb);
632} 651}