diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-06-27 10:02:50 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-06-27 10:02:50 +0000 |
commit | c1320a6bb621148c5961fcc2f84de78aa71fe559 (patch) | |
tree | cac9cfe9e10fd94d9a57f4f49636e3aad42c7ae5 | |
parent | 13b6c09a4c4383b7b1c897ca20aa5d9cee558bb6 (diff) | |
download | gnunet-gtk-c1320a6bb621148c5961fcc2f84de78aa71fe559.tar.gz gnunet-gtk-c1320a6bb621148c5961fcc2f84de78aa71fe559.zip |
adding open-URI support, works for search, download URIs need more work
-rw-r--r-- | contrib/Makefile.am | 1 | ||||
-rw-r--r-- | contrib/Makefile.in | 1 | ||||
-rw-r--r-- | contrib/main-window.glade | 90 | ||||
-rw-r--r-- | contrib/open_url_dialog.glade | 151 | ||||
-rw-r--r-- | src/download.c | 34 | ||||
-rw-r--r-- | src/download.h | 4 | ||||
-rw-r--r-- | src/fs_event_handler.c | 6 | ||||
-rw-r--r-- | src/main_window_file_download.c | 96 | ||||
-rw-r--r-- | src/main_window_open_directory.c | 27 |
9 files changed, 350 insertions, 60 deletions
diff --git a/contrib/Makefile.am b/contrib/Makefile.am index 9acb20e4..cae5b417 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am | |||
@@ -13,6 +13,7 @@ pkgdata_DATA = \ | |||
13 | main_tab_new_frame.glade \ | 13 | main_tab_new_frame.glade \ |
14 | main-window.glade \ | 14 | main-window.glade \ |
15 | open_directory_dialog.glade \ | 15 | open_directory_dialog.glade \ |
16 | open_url_dialog.glade \ | ||
16 | publish_dialog.glade \ | 17 | publish_dialog.glade \ |
17 | publish-directory-dialog.glade \ | 18 | publish-directory-dialog.glade \ |
18 | publish_edit_dialog.glade \ | 19 | publish_edit_dialog.glade \ |
diff --git a/contrib/Makefile.in b/contrib/Makefile.in index f53c7052..b35a8e0e 100644 --- a/contrib/Makefile.in +++ b/contrib/Makefile.in | |||
@@ -264,6 +264,7 @@ pkgdata_DATA = \ | |||
264 | main_tab_new_frame.glade \ | 264 | main_tab_new_frame.glade \ |
265 | main-window.glade \ | 265 | main-window.glade \ |
266 | open_directory_dialog.glade \ | 266 | open_directory_dialog.glade \ |
267 | open_url_dialog.glade \ | ||
267 | publish_dialog.glade \ | 268 | publish_dialog.glade \ |
268 | publish-directory-dialog.glade \ | 269 | publish-directory-dialog.glade \ |
269 | publish_edit_dialog.glade \ | 270 | publish_edit_dialog.glade \ |
diff --git a/contrib/main-window.glade b/contrib/main-window.glade index 60244b3e..4f795f1b 100644 --- a/contrib/main-window.glade +++ b/contrib/main-window.glade | |||
@@ -2,25 +2,33 @@ | |||
2 | <interface> | 2 | <interface> |
3 | <requires lib="gtk+" version="2.20"/> | 3 | <requires lib="gtk+" version="2.20"/> |
4 | <!-- interface-naming-policy project-wide --> | 4 | <!-- interface-naming-policy project-wide --> |
5 | <object class="GtkImage" id="image5"> | 5 | <object class="GtkListStore" id="GNUNET_GTK_peer_info_list_store"> |
6 | <property name="visible">True</property> | 6 | <columns> |
7 | <property name="stock">gtk-go-down</property> | 7 | <!-- column-name peer_identity --> |
8 | </object> | 8 | <column type="gchararray"/> |
9 | <object class="GtkImage" id="image4"> | 9 | <!-- column-name trust --> |
10 | <property name="visible">True</property> | 10 | <column type="guint"/> |
11 | <property name="stock">gtk-find</property> | 11 | <!-- column-name number_of_known_addresses --> |
12 | </object> | 12 | <column type="guint"/> |
13 | <object class="GtkImage" id="image1"> | 13 | <!-- column-name country_name --> |
14 | <property name="visible">True</property> | 14 | <column type="gchararray"/> |
15 | <property name="stock">gtk-open</property> | 15 | <!-- column-name country_flag --> |
16 | </object> | 16 | <column type="GdkPixbuf"/> |
17 | <object class="GtkImage" id="image3"> | 17 | <!-- column-name bandwidth --> |
18 | <property name="visible">True</property> | 18 | <column type="guint64"/> |
19 | <property name="stock">gtk-new</property> | 19 | </columns> |
20 | </object> | 20 | </object> |
21 | <object class="GtkImage" id="image2"> | 21 | <object class="GtkListStore" id="GNUNET_GTK_meta_data_list_store"> |
22 | <property name="visible">True</property> | 22 | <columns> |
23 | <property name="stock">gtk-go-up</property> | 23 | <!-- column-name extractor_meta_type --> |
24 | <column type="guint"/> | ||
25 | <!-- column-name extractor_meta_format --> | ||
26 | <column type="guint"/> | ||
27 | <!-- column-name extractor_meta_type_string --> | ||
28 | <column type="gchararray"/> | ||
29 | <!-- column-name extracotr_meta_value --> | ||
30 | <column type="gchararray"/> | ||
31 | </columns> | ||
24 | </object> | 32 | </object> |
25 | <object class="GtkWindow" id="GNUNET_GTK_main_window"> | 33 | <object class="GtkWindow" id="GNUNET_GTK_main_window"> |
26 | <property name="title" translatable="yes">gnunet-gtk</property> | 34 | <property name="title" translatable="yes">gnunet-gtk</property> |
@@ -47,7 +55,6 @@ | |||
47 | <child> | 55 | <child> |
48 | <object class="GtkImageMenuItem" id="GNUNET_GTK_main_menu_file_create_pseudonym"> | 56 | <object class="GtkImageMenuItem" id="GNUNET_GTK_main_menu_file_create_pseudonym"> |
49 | <property name="label" translatable="yes">_Create pseudonym</property> | 57 | <property name="label" translatable="yes">_Create pseudonym</property> |
50 | <property name="visible">True</property> | ||
51 | <property name="tooltip_text" translatable="yes">Create a pseudonym for publishing content. Note that you can also publish content anonymously (without using a pseudonym).</property> | 58 | <property name="tooltip_text" translatable="yes">Create a pseudonym for publishing content. Note that you can also publish content anonymously (without using a pseudonym).</property> |
52 | <property name="use_action_appearance">False</property> | 59 | <property name="use_action_appearance">False</property> |
53 | <property name="accel_path"><gnunet-gtk>/File sharing/Create pseudonym</property> | 60 | <property name="accel_path"><gnunet-gtk>/File sharing/Create pseudonym</property> |
@@ -351,7 +358,6 @@ | |||
351 | </child> | 358 | </child> |
352 | <child> | 359 | <child> |
353 | <object class="GtkNotebook" id="GNUNET_GTK_statistics_notebook"> | 360 | <object class="GtkNotebook" id="GNUNET_GTK_statistics_notebook"> |
354 | <property name="visible">True</property> | ||
355 | <property name="can_focus">True</property> | 361 | <property name="can_focus">True</property> |
356 | <property name="scrollable">True</property> | 362 | <property name="scrollable">True</property> |
357 | </object> | 363 | </object> |
@@ -465,32 +471,24 @@ | |||
465 | </object> | 471 | </object> |
466 | </child> | 472 | </child> |
467 | </object> | 473 | </object> |
468 | <object class="GtkListStore" id="GNUNET_GTK_meta_data_list_store"> | 474 | <object class="GtkImage" id="image2"> |
469 | <columns> | 475 | <property name="visible">True</property> |
470 | <!-- column-name extractor_meta_type --> | 476 | <property name="stock">gtk-go-up</property> |
471 | <column type="guint"/> | ||
472 | <!-- column-name extractor_meta_format --> | ||
473 | <column type="guint"/> | ||
474 | <!-- column-name extractor_meta_type_string --> | ||
475 | <column type="gchararray"/> | ||
476 | <!-- column-name extracotr_meta_value --> | ||
477 | <column type="gchararray"/> | ||
478 | </columns> | ||
479 | </object> | 477 | </object> |
480 | <object class="GtkListStore" id="GNUNET_GTK_peer_info_list_store"> | 478 | <object class="GtkImage" id="image3"> |
481 | <columns> | 479 | <property name="visible">True</property> |
482 | <!-- column-name peer_identity --> | 480 | <property name="stock">gtk-new</property> |
483 | <column type="gchararray"/> | 481 | </object> |
484 | <!-- column-name trust --> | 482 | <object class="GtkImage" id="image1"> |
485 | <column type="guint"/> | 483 | <property name="visible">True</property> |
486 | <!-- column-name number_of_known_addresses --> | 484 | <property name="stock">gtk-open</property> |
487 | <column type="guint"/> | 485 | </object> |
488 | <!-- column-name country_name --> | 486 | <object class="GtkImage" id="image4"> |
489 | <column type="gchararray"/> | 487 | <property name="visible">True</property> |
490 | <!-- column-name country_flag --> | 488 | <property name="stock">gtk-find</property> |
491 | <column type="GdkPixbuf"/> | 489 | </object> |
492 | <!-- column-name bandwidth --> | 490 | <object class="GtkImage" id="image5"> |
493 | <column type="guint64"/> | 491 | <property name="visible">True</property> |
494 | </columns> | 492 | <property name="stock">gtk-go-down</property> |
495 | </object> | 493 | </object> |
496 | </interface> | 494 | </interface> |
diff --git a/contrib/open_url_dialog.glade b/contrib/open_url_dialog.glade new file mode 100644 index 00000000..64cecacb --- /dev/null +++ b/contrib/open_url_dialog.glade | |||
@@ -0,0 +1,151 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <interface> | ||
3 | <requires lib="gtk+" version="2.20"/> | ||
4 | <!-- interface-naming-policy project-wide --> | ||
5 | <object class="GtkDialog" id="GNUNET_GTK_open_url_dialog"> | ||
6 | <property name="width_request">500</property> | ||
7 | <property name="height_request">350</property> | ||
8 | <property name="border_width">5</property> | ||
9 | <property name="title" translatable="yes">Download from URI</property> | ||
10 | <property name="modal">True</property> | ||
11 | <property name="destroy_with_parent">True</property> | ||
12 | <property name="icon_name">dialog-password</property> | ||
13 | <property name="type_hint">dialog</property> | ||
14 | <property name="skip_taskbar_hint">True</property> | ||
15 | <property name="skip_pager_hint">True</property> | ||
16 | <property name="has_separator">False</property> | ||
17 | <child internal-child="vbox"> | ||
18 | <object class="GtkVBox" id="GNUNET_GTK_open_url_dialog_main_vbox"> | ||
19 | <property name="visible">True</property> | ||
20 | <property name="spacing">2</property> | ||
21 | <child> | ||
22 | <object class="GtkHBox" id="GNUNET_GTK_open_url_dialog_query_hbox"> | ||
23 | <property name="visible">True</property> | ||
24 | <child> | ||
25 | <object class="GtkLabel" id="GNUNET_GTK_open_url_dialog_url_label"> | ||
26 | <property name="visible">True</property> | ||
27 | <property name="label" translatable="yes">_URI:</property> | ||
28 | <property name="use_underline">True</property> | ||
29 | <property name="selectable">True</property> | ||
30 | <property name="mnemonic_widget">GNUNET_GTK_open_url_dialog_url_entry</property> | ||
31 | </object> | ||
32 | <packing> | ||
33 | <property name="expand">False</property> | ||
34 | <property name="fill">False</property> | ||
35 | <property name="position">0</property> | ||
36 | </packing> | ||
37 | </child> | ||
38 | <child> | ||
39 | <object class="GtkEntry" id="GNUNET_GTK_open_url_dialog_url_entry"> | ||
40 | <property name="visible">True</property> | ||
41 | <property name="can_focus">True</property> | ||
42 | <property name="invisible_char">●</property> | ||
43 | <property name="activates_default">True</property> | ||
44 | <property name="caps_lock_warning">False</property> | ||
45 | <property name="primary_icon_stock">gtk-dialog-authentication</property> | ||
46 | <property name="primary_icon_tooltip_text" translatable="yes">Separate multiple keywords with spaces, prefix mandatory keywords with "+"</property> | ||
47 | <signal name="changed" handler="GNUNET_GTK_open_url_dialog_url_entry_changed_cb" swapped="no"/> | ||
48 | <signal name="activate" handler="GNUNET_GTK_search_dialog_search_button_clicked_cb" swapped="no"/> | ||
49 | </object> | ||
50 | <packing> | ||
51 | <property name="position">1</property> | ||
52 | </packing> | ||
53 | </child> | ||
54 | <child> | ||
55 | <object class="GtkLabel" id="GNUNET_GTK_open_url_dialog_anonymity_label"> | ||
56 | <property name="visible">True</property> | ||
57 | <property name="label" translatable="yes">_Anonymity:</property> | ||
58 | <property name="use_underline">True</property> | ||
59 | <property name="selectable">True</property> | ||
60 | <property name="mnemonic_widget">GNUNET_GTK_open_url_dialog_anonymity_spin_button</property> | ||
61 | </object> | ||
62 | <packing> | ||
63 | <property name="expand">False</property> | ||
64 | <property name="fill">False</property> | ||
65 | <property name="position">2</property> | ||
66 | </packing> | ||
67 | </child> | ||
68 | <child> | ||
69 | <object class="GtkSpinButton" id="GNUNET_GTK_open_url_dialog_anonymity_spin_button"> | ||
70 | <property name="visible">True</property> | ||
71 | <property name="can_focus">True</property> | ||
72 | <property name="invisible_char">●</property> | ||
73 | <property name="caps_lock_warning">False</property> | ||
74 | <property name="adjustment">GNUNET_GTK_open_url_anonymity_adjustment</property> | ||
75 | <property name="climb_rate">1</property> | ||
76 | <property name="numeric">True</property> | ||
77 | <signal name="value-changed" handler="GNUNET_GTK_anonymity_spin_button_value_changed_cb" swapped="no"/> | ||
78 | </object> | ||
79 | <packing> | ||
80 | <property name="position">3</property> | ||
81 | </packing> | ||
82 | </child> | ||
83 | </object> | ||
84 | <packing> | ||
85 | <property name="expand">False</property> | ||
86 | <property name="fill">False</property> | ||
87 | <property name="padding">5</property> | ||
88 | <property name="position">0</property> | ||
89 | </packing> | ||
90 | </child> | ||
91 | <child internal-child="action_area"> | ||
92 | <object class="GtkHButtonBox" id="GNUNET_GTK_open_url_dialog_action_area"> | ||
93 | <property name="visible">True</property> | ||
94 | <property name="layout_style">end</property> | ||
95 | <child> | ||
96 | <object class="GtkButton" id="GNUNET_GTK_open_url_dialog_cancel_button"> | ||
97 | <property name="label">gtk-cancel</property> | ||
98 | <property name="visible">True</property> | ||
99 | <property name="can_focus">True</property> | ||
100 | <property name="receives_default">True</property> | ||
101 | <property name="use_action_appearance">False</property> | ||
102 | <property name="use_stock">True</property> | ||
103 | </object> | ||
104 | <packing> | ||
105 | <property name="expand">False</property> | ||
106 | <property name="fill">False</property> | ||
107 | <property name="position">0</property> | ||
108 | </packing> | ||
109 | </child> | ||
110 | <child> | ||
111 | <object class="GtkButton" id="GNUNET_GTK_open_url_dialog_execute_button"> | ||
112 | <property name="label">_Execute</property> | ||
113 | <property name="visible">True</property> | ||
114 | <property name="sensitive">False</property> | ||
115 | <property name="can_focus">True</property> | ||
116 | <property name="receives_default">True</property> | ||
117 | <property name="use_action_appearance">False</property> | ||
118 | <property name="image">execute_stock_image</property> | ||
119 | <property name="use_underline">True</property> | ||
120 | </object> | ||
121 | <packing> | ||
122 | <property name="expand">False</property> | ||
123 | <property name="fill">False</property> | ||
124 | <property name="position">1</property> | ||
125 | </packing> | ||
126 | </child> | ||
127 | </object> | ||
128 | <packing> | ||
129 | <property name="expand">False</property> | ||
130 | <property name="pack_type">end</property> | ||
131 | <property name="position">1</property> | ||
132 | </packing> | ||
133 | </child> | ||
134 | </object> | ||
135 | </child> | ||
136 | <action-widgets> | ||
137 | <action-widget response="-6">GNUNET_GTK_open_url_dialog_cancel_button</action-widget> | ||
138 | <action-widget response="-5">GNUNET_GTK_open_url_dialog_execute_button</action-widget> | ||
139 | </action-widgets> | ||
140 | </object> | ||
141 | <object class="GtkAdjustment" id="GNUNET_GTK_open_url_anonymity_adjustment"> | ||
142 | <property name="upper">100000</property> | ||
143 | <property name="value">1</property> | ||
144 | <property name="step_increment">1</property> | ||
145 | <property name="page_increment">10</property> | ||
146 | </object> | ||
147 | <object class="GtkImage" id="execute_stock_image"> | ||
148 | <property name="visible">True</property> | ||
149 | <property name="stock">gtk-execute</property> | ||
150 | </object> | ||
151 | </interface> | ||
diff --git a/src/download.c b/src/download.c index a260783d..73a3146c 100644 --- a/src/download.c +++ b/src/download.c | |||
@@ -88,15 +88,31 @@ GNUNET_GTK_open_download_as_dialog (struct DownloadContext *dc) | |||
88 | len = GNUNET_FS_uri_chk_get_file_size (dc->uri); | 88 | len = GNUNET_FS_uri_chk_get_file_size (dc->uri); |
89 | gtk_widget_destroy (ad); | 89 | gtk_widget_destroy (ad); |
90 | g_object_unref (G_OBJECT (builder)); | 90 | g_object_unref (G_OBJECT (builder)); |
91 | GNUNET_FS_download_start_from_search (fs, | 91 | if (dc->sr != NULL) |
92 | dc->sr, | 92 | GNUNET_break (NULL != |
93 | dc->filename, | 93 | GNUNET_FS_download_start_from_search (fs, |
94 | NULL /* tempname */, | 94 | dc->sr, |
95 | 0 /* offset */, | 95 | dc->filename, |
96 | len, | 96 | NULL /* tempname */, |
97 | anonymity, | 97 | 0 /* offset */, |
98 | opt, | 98 | len, |
99 | dc); | 99 | anonymity, |
100 | opt, | ||
101 | dc)); | ||
102 | else | ||
103 | GNUNET_break (NULL != | ||
104 | GNUNET_FS_download_start (fs, | ||
105 | dc->uri, | ||
106 | NULL, | ||
107 | dc->filename, | ||
108 | NULL /* tempname */, | ||
109 | 0 /* offset */, | ||
110 | len, | ||
111 | anonymity, | ||
112 | opt, | ||
113 | dc, | ||
114 | NULL)); | ||
115 | |||
100 | } | 116 | } |
101 | 117 | ||
102 | /* end of download.c */ | 118 | /* end of download.c */ |
diff --git a/src/download.h b/src/download.h index f1878e55..595d5c60 100644 --- a/src/download.h +++ b/src/download.h | |||
@@ -63,6 +63,10 @@ struct DownloadContext | |||
63 | */ | 63 | */ |
64 | int is_recursive; | 64 | int is_recursive; |
65 | 65 | ||
66 | /** | ||
67 | * Desired (default) anonymity level. | ||
68 | */ | ||
69 | int anonymity; | ||
66 | }; | 70 | }; |
67 | 71 | ||
68 | 72 | ||
diff --git a/src/fs_event_handler.c b/src/fs_event_handler.c index 9837ec98..b4cc9d13 100644 --- a/src/fs_event_handler.c +++ b/src/fs_event_handler.c | |||
@@ -259,9 +259,10 @@ setup_download (struct DownloadEntry *pde, | |||
259 | } | 259 | } |
260 | else | 260 | else |
261 | { | 261 | { |
262 | /* find or create tab with just download results and | 262 | /* FIXME: find or create tab with just download results and |
263 | create new entry! */ | 263 | create new entry! */ |
264 | GNUNET_break (0); | 264 | GNUNET_break (0); |
265 | return de; | ||
265 | } | 266 | } |
266 | path = gtk_tree_row_reference_get_path (de->rr); | 267 | path = gtk_tree_row_reference_get_path (de->rr); |
267 | if (TRUE != gtk_tree_model_get_iter (GTK_TREE_MODEL (de->ts), | 268 | if (TRUE != gtk_tree_model_get_iter (GTK_TREE_MODEL (de->ts), |
@@ -318,6 +319,7 @@ start_download (GtkTreeView *tree_view, | |||
318 | dlc->filename = GNUNET_FS_meta_data_suggest_filename (meta); | 319 | dlc->filename = GNUNET_FS_meta_data_suggest_filename (meta); |
319 | dlc->rr = gtk_tree_row_reference_new (tm, path); | 320 | dlc->rr = gtk_tree_row_reference_new (tm, path); |
320 | dlc->sr = sr->result; | 321 | dlc->sr = sr->result; |
322 | dlc->anonymity = 1; /* FIXME: grab from search? */ | ||
321 | GNUNET_GTK_open_download_as_dialog (dlc); | 323 | GNUNET_GTK_open_download_as_dialog (dlc); |
322 | } | 324 | } |
323 | 325 | ||
@@ -1115,6 +1117,8 @@ GNUNET_GTK_fs_event_handler (void *cls, | |||
1115 | GNUNET_YES); | 1117 | GNUNET_YES); |
1116 | break; | 1118 | break; |
1117 | case GNUNET_FS_STATUS_SEARCH_START: | 1119 | case GNUNET_FS_STATUS_SEARCH_START: |
1120 | fprintf (stderr, | ||
1121 | "Search started!\n"); | ||
1118 | if (info->value.search.pctx != NULL) | 1122 | if (info->value.search.pctx != NULL) |
1119 | { | 1123 | { |
1120 | GNUNET_break (0); | 1124 | GNUNET_break (0); |
diff --git a/src/main_window_file_download.c b/src/main_window_file_download.c index 0c4aa04b..b38bf513 100644 --- a/src/main_window_file_download.c +++ b/src/main_window_file_download.c | |||
@@ -23,16 +23,108 @@ | |||
23 | * @author Christian Grothoff | 23 | * @author Christian Grothoff |
24 | */ | 24 | */ |
25 | #include "common.h" | 25 | #include "common.h" |
26 | #include "download.h" | ||
27 | |||
28 | |||
29 | static GtkBuilder *builder; | ||
30 | |||
31 | void | ||
32 | GNUNET_GTK_open_url_dialog_url_entry_changed_cb (GtkEditable *editable, | ||
33 | gpointer user_data) | ||
34 | { | ||
35 | struct GNUNET_FS_Uri *uri; | ||
36 | char *perr; | ||
37 | const char *uris; | ||
38 | |||
39 | perr = NULL; | ||
40 | uris = gtk_entry_get_text (GTK_ENTRY (gtk_builder_get_object (builder, | ||
41 | "GNUNET_GTK_open_url_dialog_url_entry"))); | ||
42 | if (uris != NULL) | ||
43 | uri = GNUNET_FS_uri_parse (uris, &perr); | ||
44 | else | ||
45 | uri = NULL; | ||
46 | gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (builder, | ||
47 | "GNUNET_GTK_open_url_dialog_execute_button")), | ||
48 | (uri == NULL) ? FALSE : TRUE); | ||
49 | if (uri != NULL) | ||
50 | GNUNET_FS_uri_destroy (uri); | ||
51 | else | ||
52 | GNUNET_free_non_null (perr); | ||
53 | } | ||
54 | |||
26 | 55 | ||
27 | /** | 56 | /** |
28 | * Thumbnail view is toggled. | 57 | * User selected "Open URI" in main window. |
29 | */ | 58 | */ |
30 | void | 59 | void |
31 | GNUNET_GTK_main_menu_file_download_uri_activate_cb (GtkWidget * dummy, | 60 | GNUNET_GTK_main_menu_file_download_uri_activate_cb (GtkWidget * dummy, |
32 | gpointer data) | 61 | gpointer data) |
33 | { | 62 | { |
34 | /* not implemented */ | 63 | GtkWidget *ad; |
64 | const char *uris; | ||
65 | uint32_t anonymity; | ||
66 | struct GNUNET_FS_Uri *uri; | ||
67 | char *perr; | ||
68 | struct DownloadContext *dc; | ||
69 | |||
70 | GNUNET_assert (builder == NULL); | ||
71 | builder = GNUNET_GTK_get_new_builder ("open_url_dialog.glade"); | ||
72 | if (builder == NULL) | ||
73 | { | ||
74 | GNUNET_break (0); | ||
75 | return; | ||
76 | } | ||
77 | ad = GTK_WIDGET (gtk_builder_get_object (builder, | ||
78 | "GNUNET_GTK_open_url_dialog")); | ||
79 | if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad))) | ||
80 | { | ||
81 | gtk_widget_destroy (ad); | ||
82 | g_object_unref (G_OBJECT (builder)); | ||
83 | builder = NULL; | ||
84 | fprintf (stderr, | ||
85 | "Dialog closed!\n"); | ||
86 | return; | ||
87 | } | ||
88 | uris = gtk_entry_get_text (GTK_ENTRY (gtk_builder_get_object (builder, | ||
89 | "GNUNET_GTK_open_url_dialog_url_entry"))); | ||
90 | anonymity = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (builder, | ||
91 | "GNUNET_GTK_open_url_dialog_anonymity_spin_button"))); | ||
92 | uri = GNUNET_FS_uri_parse (uris, &perr); | ||
93 | gtk_widget_destroy (ad); | ||
94 | g_object_unref (G_OBJECT (builder)); | ||
95 | builder = NULL; | ||
96 | if (uri == NULL) | ||
97 | { | ||
98 | GNUNET_free (perr); | ||
99 | /* Why was "execute" button sensitive!? */ | ||
100 | GNUNET_break (0); | ||
101 | return; | ||
102 | } | ||
103 | if (GNUNET_FS_uri_test_sks (uri) || | ||
104 | GNUNET_FS_uri_test_ksk (uri)) | ||
105 | { | ||
106 | fprintf (stderr, | ||
107 | "Starting search!\n"); | ||
108 | GNUNET_break (NULL != | ||
109 | GNUNET_FS_search_start (GNUNET_GTK_get_fs_handle (), | ||
110 | uri, | ||
111 | anonymity, | ||
112 | GNUNET_FS_SEARCH_OPTION_NONE, | ||
113 | NULL)); | ||
114 | GNUNET_FS_uri_destroy (uri); | ||
115 | return; | ||
116 | } | ||
117 | if (GNUNET_FS_uri_test_chk (uri) || | ||
118 | GNUNET_FS_uri_test_loc (uri)) | ||
119 | { | ||
120 | dc = GNUNET_malloc (sizeof (struct DownloadContext)); | ||
121 | dc->uri = uri; | ||
122 | dc->anonymity = anonymity; | ||
123 | GNUNET_GTK_open_download_as_dialog (dc); | ||
124 | return; | ||
125 | } | ||
35 | GNUNET_break (0); | 126 | GNUNET_break (0); |
127 | GNUNET_FS_uri_destroy (uri); | ||
36 | } | 128 | } |
37 | 129 | ||
38 | /* end of main_window_file_download.c */ | 130 | /* end of main_window_file_download.c */ |
diff --git a/src/main_window_open_directory.c b/src/main_window_open_directory.c index 6f1c2df3..cd67adba 100644 --- a/src/main_window_open_directory.c +++ b/src/main_window_open_directory.c | |||
@@ -25,14 +25,37 @@ | |||
25 | #include "common.h" | 25 | #include "common.h" |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * Thumbnail view is toggled. | 28 | * User selected "Open directory" in menu. Display dialog, open |
29 | * file and then display a new tab with its contents. | ||
29 | */ | 30 | */ |
30 | void | 31 | void |
31 | GNUNET_GTK_main_menu_file_open_gnunet_directory_activate_cb (GtkWidget * dummy, | 32 | GNUNET_GTK_main_menu_file_open_gnunet_directory_activate_cb (GtkWidget * dummy, |
32 | gpointer data) | 33 | gpointer data) |
33 | { | 34 | { |
34 | /* not implemented */ | 35 | GtkWidget *ad; |
36 | GtkBuilder *builder; | ||
37 | char *filename; | ||
38 | |||
39 | builder = GNUNET_GTK_get_new_builder ("open_directory_dialog.glade"); | ||
40 | if (builder == NULL) | ||
41 | { | ||
42 | GNUNET_break (0); | ||
43 | return; | ||
44 | } | ||
45 | ad = GTK_WIDGET (gtk_builder_get_object (builder, | ||
46 | "GNUNET_GTK_open_directory_dialog")); | ||
47 | if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad))) | ||
48 | { | ||
49 | gtk_widget_destroy (ad); | ||
50 | g_object_unref (G_OBJECT (builder)); | ||
51 | return; | ||
52 | } | ||
53 | filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(ad)); | ||
54 | gtk_widget_destroy (ad); | ||
55 | g_object_unref (G_OBJECT (builder)); | ||
56 | |||
35 | GNUNET_break (0); | 57 | GNUNET_break (0); |
58 | g_free (filename); | ||
36 | } | 59 | } |
37 | 60 | ||
38 | /* end of main_window_open_directory.c */ | 61 | /* end of main_window_open_directory.c */ |