aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-06-26 19:22:39 +0000
committerChristian Grothoff <christian@grothoff.org>2012-06-26 19:22:39 +0000
commit1fa58da15c41b9cac03ff91de7cdb2f190c697ad (patch)
treeb33a836544695c520067a756f1190ab30f73a5a3
parentfef2d48426afccc0f121be68a91f6f723c41b1ef (diff)
downloadgnunet-gtk-1fa58da15c41b9cac03ff91de7cdb2f190c697ad.tar.gz
gnunet-gtk-1fa58da15c41b9cac03ff91de7cdb2f190c697ad.zip
-adding support for saving gns record qr code images
-rw-r--r--contrib/Makefile.am4
-rw-r--r--contrib/gnunet_setup_qr_save_as_dialog.glade74
-rw-r--r--src/setup/gnunet-setup-gns.c53
3 files changed, 127 insertions, 4 deletions
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index ce834e51..738d4305 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -40,14 +40,12 @@ pkgdata_DATA = \
40 gnunet_fs_gtk_select_pseudonym_dialog.glade \ 40 gnunet_fs_gtk_select_pseudonym_dialog.glade \
41 gnunet_fs_gtk_unindex.glade \ 41 gnunet_fs_gtk_unindex.glade \
42 gnunet_fs_gtk_progress_dialog.glade \ 42 gnunet_fs_gtk_progress_dialog.glade \
43 gnunet_gns_gtk_about_window.glade \
44 gnunet_gns_gtk_main_window.glade \
45 gnunet_gns_gtk_zone_open.glade \
46 gnunet_gtk_status_bar_menu.glade \ 43 gnunet_gtk_status_bar_menu.glade \
47 gnunet_peerinfo_gtk_about_window.glade \ 44 gnunet_peerinfo_gtk_about_window.glade \
48 gnunet_peerinfo_gtk_main_window.glade \ 45 gnunet_peerinfo_gtk_main_window.glade \
49 gnunet_statistics_gtk_about_window.glade \ 46 gnunet_statistics_gtk_about_window.glade \
50 gnunet_statistics_gtk_main_window.glade \ 47 gnunet_statistics_gtk_main_window.glade \
48 gnunet_setup_qr_save_as_dialog.glade \
51 gnunet_setup_gtk_main_window.glade 49 gnunet_setup_gtk_main_window.glade
52 50
53install-data-local: 51install-data-local:
diff --git a/contrib/gnunet_setup_qr_save_as_dialog.glade b/contrib/gnunet_setup_qr_save_as_dialog.glade
new file mode 100644
index 00000000..407f1a51
--- /dev/null
+++ b/contrib/gnunet_setup_qr_save_as_dialog.glade
@@ -0,0 +1,74 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<interface>
3 <requires lib="gtk+" version="2.24"/>
4 <!-- interface-naming-policy project-wide -->
5 <object class="GtkFileChooserDialog" id="GNUNET_setup_qr_save_as_dialog">
6 <property name="can_focus">False</property>
7 <property name="border_width">5</property>
8 <property name="modal">True</property>
9 <property name="destroy_with_parent">True</property>
10 <property name="icon_name">document-save-as</property>
11 <property name="type_hint">dialog</property>
12 <property name="skip_taskbar_hint">True</property>
13 <property name="skip_pager_hint">True</property>
14 <property name="action">save</property>
15 <signal name="response" handler="GNUNET_setup_qr_save_as_dialog_response_cb" swapped="no"/>
16 <child internal-child="vbox">
17 <object class="GtkVBox" id="GNUNET_setup_qr_save_as_dialog_dialog-vbox">
18 <property name="visible">True</property>
19 <property name="can_focus">False</property>
20 <property name="spacing">2</property>
21 <child internal-child="action_area">
22 <object class="GtkHButtonBox" id="GNUNET_setup_qr_save_as_dialog_dialog-action_area">
23 <property name="visible">True</property>
24 <property name="can_focus">False</property>
25 <property name="layout_style">end</property>
26 <child>
27 <object class="GtkButton" id="GNUNET_setup_qr_save_as_dialog_cancel_button">
28 <property name="label">gtk-cancel</property>
29 <property name="use_action_appearance">False</property>
30 <property name="visible">True</property>
31 <property name="can_focus">True</property>
32 <property name="receives_default">True</property>
33 <property name="use_stock">True</property>
34 </object>
35 <packing>
36 <property name="expand">False</property>
37 <property name="fill">False</property>
38 <property name="position">0</property>
39 </packing>
40 </child>
41 <child>
42 <object class="GtkButton" id="GNUNET_setup_qr_save_as_dialog_confirm_button">
43 <property name="label">gtk-save-as</property>
44 <property name="use_action_appearance">False</property>
45 <property name="visible">True</property>
46 <property name="can_focus">True</property>
47 <property name="receives_default">True</property>
48 <property name="use_stock">True</property>
49 </object>
50 <packing>
51 <property name="expand">False</property>
52 <property name="fill">False</property>
53 <property name="position">1</property>
54 </packing>
55 </child>
56 </object>
57 <packing>
58 <property name="expand">False</property>
59 <property name="fill">True</property>
60 <property name="pack_type">end</property>
61 <property name="position">0</property>
62 </packing>
63 </child>
64 <child>
65 <placeholder/>
66 </child>
67 </object>
68 </child>
69 <action-widgets>
70 <action-widget response="-6">GNUNET_setup_qr_save_as_dialog_cancel_button</action-widget>
71 <action-widget response="-5">GNUNET_setup_qr_save_as_dialog_confirm_button</action-widget>
72 </action-widgets>
73 </object>
74</interface>
diff --git a/src/setup/gnunet-setup-gns.c b/src/setup/gnunet-setup-gns.c
index 12399cb8..f141d156 100644
--- a/src/setup/gnunet-setup-gns.c
+++ b/src/setup/gnunet-setup-gns.c
@@ -1300,6 +1300,44 @@ GNUNET_setup_gns_main_treeview_key_press_event_cb (GtkWidget *widget, GdkEventKe
1300 1300
1301 1301
1302/** 1302/**
1303 * Function called upon completion of the qr-code 'save as' dialog.
1304 *
1305 * @param dialog the dialog
1306 * @param response_id reason for the dialog closing
1307 * @param user_data the 'GtkBuilder' we used to create the dialog
1308 */
1309void
1310GNUNET_setup_qr_save_as_dialog_response_cb (GtkDialog *dialog,
1311 gint response_id,
1312 gpointer user_data)
1313{
1314 GtkBuilder *builder = user_data;
1315 GtkImage *image;
1316 GdkPixbuf *pb;
1317 char *filename;
1318
1319 if (GTK_RESPONSE_OK != response_id)
1320 {
1321 gtk_widget_destroy (GTK_WIDGET (dialog));
1322 g_object_unref (G_OBJECT (builder));
1323 return;
1324 }
1325 filename =
1326 GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER (dialog));
1327 image = GTK_IMAGE (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_image"));
1328 pb = gtk_image_get_pixbuf (image);
1329
1330 gdk_pixbuf_save (pb,
1331 filename,
1332 "png",
1333 NULL, NULL);
1334 g_free (filename);
1335 gtk_widget_destroy (GTK_WIDGET (dialog));
1336 g_object_unref (G_OBJECT (builder));
1337}
1338
1339
1340/**
1303 * User clicked on 'save as' to extract the QR code. Open 'save as' 1341 * User clicked on 'save as' to extract the QR code. Open 'save as'
1304 * dialog to get the desired filename and file type. 1342 * dialog to get the desired filename and file type.
1305 */ 1343 */
@@ -1307,7 +1345,20 @@ void
1307GNUNET_setup_gns_qr_saveas_button_clicked_cb (GtkButton *button, 1345GNUNET_setup_gns_qr_saveas_button_clicked_cb (GtkButton *button,
1308 gpointer user_data) 1346 gpointer user_data)
1309{ 1347{
1310 GNUNET_break (0); // FIXME: not implemented 1348 GtkBuilder *builder;
1349 GtkWindow *dialog;
1350
1351 builder =
1352 GNUNET_GTK_get_new_builder ("gnunet_setup_qr_save_as_dialog.glade",
1353 NULL);
1354 if (NULL == builder)
1355 {
1356 GNUNET_break (0);
1357 return;
1358 }
1359 dialog = GTK_WINDOW (gtk_builder_get_object
1360 (builder, "GNUNET_setup_qr_save_as_dialog"));
1361 gtk_window_present (dialog);
1311} 1362}
1312 1363
1313 1364