diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-07-01 15:34:25 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-07-01 15:34:25 +0000 |
commit | ad6d2a730d7b55915c52f41bfc6b95ddfc42404a (patch) | |
tree | b7ee19f4f107d98b55c2b92a9051023060ffba72 | |
parent | 1d0a75672744f75e1b36a573c92a71cedf971184 (diff) | |
download | gnunet-gtk-ad6d2a730d7b55915c52f41bfc6b95ddfc42404a.tar.gz gnunet-gtk-ad6d2a730d7b55915c52f41bfc6b95ddfc42404a.zip |
-fix scaling
-rw-r--r-- | src/setup/gnunet-setup-gns.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/setup/gnunet-setup-gns.c b/src/setup/gnunet-setup-gns.c index eb0a320f..f0ea2f04 100644 --- a/src/setup/gnunet-setup-gns.c +++ b/src/setup/gnunet-setup-gns.c | |||
@@ -226,11 +226,11 @@ static int iteration; | |||
226 | /** | 226 | /** |
227 | * Create the QR code image for our zone. | 227 | * Create the QR code image for our zone. |
228 | * | 228 | * |
229 | * @param size height and width of the image to create | 229 | * @param scale factor for scaling up the size of the image to create |
230 | * @return NULL on error | 230 | * @return NULL on error |
231 | */ | 231 | */ |
232 | static GdkPixbuf * | 232 | static GdkPixbuf * |
233 | create_qrcode (unsigned int size) | 233 | create_qrcode (unsigned int scale) |
234 | { | 234 | { |
235 | QRinput * qri; | 235 | QRinput * qri; |
236 | QRcode *qrc; | 236 | QRcode *qrc; |
@@ -246,6 +246,7 @@ create_qrcode (unsigned int size) | |||
246 | int c; | 246 | int c; |
247 | const char *dir; | 247 | const char *dir; |
248 | char *fn; | 248 | char *fn; |
249 | unsigned int size; | ||
249 | 250 | ||
250 | qri = QRinput_new2 (0, QR_ECLEVEL_Q); | 251 | qri = QRinput_new2 (0, QR_ECLEVEL_Q); |
251 | if (NULL == qri) | 252 | if (NULL == qri) |
@@ -284,6 +285,8 @@ create_qrcode (unsigned int size) | |||
284 | "%s%s", | 285 | "%s%s", |
285 | dir, | 286 | dir, |
286 | "qr_dummy.png"); | 287 | "qr_dummy.png"); |
288 | size = qrc->width * scale; | ||
289 | size += 8 - (size % 8); | ||
287 | pb = gdk_pixbuf_new_from_file_at_size (fn, | 290 | pb = gdk_pixbuf_new_from_file_at_size (fn, |
288 | size, size, | 291 | size, size, |
289 | NULL); | 292 | NULL); |
@@ -318,7 +321,7 @@ setup_qrcode () | |||
318 | GdkPixbuf *pb; | 321 | GdkPixbuf *pb; |
319 | GtkImage *image; | 322 | GtkImage *image; |
320 | 323 | ||
321 | pb = create_qrcode (QRCODE_IMAGE_SIZE); | 324 | pb = create_qrcode (2); |
322 | if (NULL == pb) | 325 | if (NULL == pb) |
323 | { | 326 | { |
324 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to initialize QR-code pixbuf")); | 327 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to initialize QR-code pixbuf")); |
@@ -411,6 +414,9 @@ add_new_records_after_removing_old_records (void *cls, | |||
411 | { | 414 | { |
412 | case GNUNET_OK: | 415 | case GNUNET_OK: |
413 | case GNUNET_NO: | 416 | case GNUNET_NO: |
417 | /* FIXME: should check continuation's return values; | ||
418 | also, need to keep 'struct GNUNET_NAMESTORE_QueueEntry' | ||
419 | around to cancel before disconnect upon termination... */ | ||
414 | for (c = 0; c < uc->rd_count; c++) | 420 | for (c = 0; c < uc->rd_count; c++) |
415 | GNUNET_NAMESTORE_record_create (namestore, pkey, | 421 | GNUNET_NAMESTORE_record_create (namestore, pkey, |
416 | uc->name, &uc->rd[c], | 422 | uc->name, &uc->rd[c], |
@@ -589,6 +595,7 @@ check_name_validity_and_commit (const gchar *path, const char * oldname) | |||
589 | uc->rd = rd; | 595 | uc->rd = rd; |
590 | uc->rd_count = records; | 596 | uc->rd_count = records; |
591 | uc->name = name; | 597 | uc->name = name; |
598 | // FIXME: need to keep 'struct GNUNET_NAMESTORE_QueueEntry' around... | ||
592 | GNUNET_NAMESTORE_record_remove (namestore, | 599 | GNUNET_NAMESTORE_record_remove (namestore, |
593 | pkey, | 600 | pkey, |
594 | (NULL != oldname) ? oldname : name, | 601 | (NULL != oldname) ? oldname : name, |
@@ -728,6 +735,7 @@ check_name_validity_and_remove (const gchar *path) | |||
728 | 735 | ||
729 | rcc = GNUNET_malloc(sizeof (struct RemoveContext)); | 736 | rcc = GNUNET_malloc(sizeof (struct RemoveContext)); |
730 | rcc->path = strdup (path); | 737 | rcc->path = strdup (path); |
738 | // FIXME: need to keep 'struct GNUNET_NAMESTORE_QueueEntry' around... | ||
731 | GNUNET_NAMESTORE_record_remove (namestore, pkey, name, &rd, &update_treemodel_after_remove, rcc); | 739 | GNUNET_NAMESTORE_record_remove (namestore, pkey, name, &rd, &update_treemodel_after_remove, rcc); |
732 | GNUNET_free ((void *) rd.data); | 740 | GNUNET_free ((void *) rd.data); |
733 | } | 741 | } |
@@ -747,6 +755,7 @@ check_name_validity_and_remove (const gchar *path) | |||
747 | /* Removing the whole name record */ | 755 | /* Removing the whole name record */ |
748 | rcc = GNUNET_malloc(sizeof (struct RemoveContext)); | 756 | rcc = GNUNET_malloc(sizeof (struct RemoveContext)); |
749 | rcc->path = strdup (path); | 757 | rcc->path = strdup (path); |
758 | // FIXME: need to keep 'struct GNUNET_NAMESTORE_QueueEntry' around... | ||
750 | GNUNET_NAMESTORE_record_remove (namestore, pkey, name, NULL, &update_treemodel_after_remove, rcc); | 759 | GNUNET_NAMESTORE_record_remove (namestore, pkey, name, NULL, &update_treemodel_after_remove, rcc); |
751 | } | 760 | } |
752 | g_free (name); | 761 | g_free (name); |
@@ -1458,7 +1467,7 @@ GNUNET_setup_qr_save_as_dialog_response_cb (GtkDialog *dialog, | |||
1458 | } | 1467 | } |
1459 | filename = | 1468 | filename = |
1460 | GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER (dialog)); | 1469 | GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER (dialog)); |
1461 | pb = create_qrcode (512); | 1470 | pb = create_qrcode (8); |
1462 | if (NULL == pb) | 1471 | if (NULL == pb) |
1463 | { | 1472 | { |
1464 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to initialize QR-code pixbuf")); | 1473 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to initialize QR-code pixbuf")); |
@@ -1643,7 +1652,7 @@ zone_iteration_proc (void *cls, | |||
1643 | GNUNET_free (val); | 1652 | GNUNET_free (val); |
1644 | } | 1653 | } |
1645 | 1654 | ||
1646 | GNUNET_NAMESTORE_zone_iterator_next(zc_ctx->it); | 1655 | GNUNET_NAMESTORE_zone_iterator_next (zc_ctx->it); |
1647 | } | 1656 | } |
1648 | 1657 | ||
1649 | 1658 | ||
@@ -1699,6 +1708,7 @@ GNUNET_setup_gns_pseu_entry_changed_cb (GtkEditable *editable, | |||
1699 | rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; | 1708 | rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; |
1700 | rd.data_size = strlen (pseu) + 1; | 1709 | rd.data_size = strlen (pseu) + 1; |
1701 | rd.data = strdup (pseu); | 1710 | rd.data = strdup (pseu); |
1711 | // FIXME: need to keep 'struct GNUNET_NAMESTORE_QueueEntry' around (to cancel on disconnect...) | ||
1702 | GNUNET_NAMESTORE_record_create (namestore, pkey, "+", &rd, &pseu_change_cont, NULL); | 1712 | GNUNET_NAMESTORE_record_create (namestore, pkey, "+", &rd, &pseu_change_cont, NULL); |
1703 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New Pseudonym is `%s' %u\n", (char *) rd.data, rd.data_size); | 1713 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New Pseudonym is `%s' %u\n", (char *) rd.data, rd.data_size); |
1704 | } | 1714 | } |
@@ -1825,7 +1835,8 @@ GNUNET_SETUP_gns_init () | |||
1825 | GNS_TREESTORE_COL_IS_RECORD_ROW, FALSE, | 1835 | GNS_TREESTORE_COL_IS_RECORD_ROW, FALSE, |
1826 | GNS_TREESTORE_COL_NOT_DUMMY_ROW, FALSE, | 1836 | GNS_TREESTORE_COL_NOT_DUMMY_ROW, FALSE, |
1827 | -1); | 1837 | -1); |
1828 | 1838 | ||
1839 | // FIXME: need to keep this handle for 'GNUNET_SETUP_gns_done' around! | ||
1829 | zc_ctx = GNUNET_malloc (sizeof (struct ZoneIteration_Context)); | 1840 | zc_ctx = GNUNET_malloc (sizeof (struct ZoneIteration_Context)); |
1830 | zc_ctx->zone = zone; | 1841 | zc_ctx->zone = zone; |
1831 | zc_ctx->it = GNUNET_NAMESTORE_zone_iteration_start (namestore, &zone, | 1842 | zc_ctx->it = GNUNET_NAMESTORE_zone_iteration_start (namestore, &zone, |
@@ -1846,6 +1857,8 @@ GNUNET_SETUP_gns_done () | |||
1846 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_status_label"))); | 1857 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_status_label"))); |
1847 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_main_scrolledwindow"))); | 1858 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_main_scrolledwindow"))); |
1848 | gtk_tree_store_clear (ts); | 1859 | gtk_tree_store_clear (ts); |
1860 | // FIXME: need to abort any pending zone iteration! | ||
1861 | // FIXME: need to cancel pending record operations! | ||
1849 | if (NULL != namestore) | 1862 | if (NULL != namestore) |
1850 | { | 1863 | { |
1851 | GNUNET_NAMESTORE_disconnect (namestore); | 1864 | GNUNET_NAMESTORE_disconnect (namestore); |