diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-02-05 19:36:09 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-02-05 19:36:09 +0000 |
commit | c1091136df7ac8da8fda551702f57b1a22535195 (patch) | |
tree | e4991cbce6f5cef8edfbaa8abe93cf3c029eb4a9 | |
parent | a60d897b4ae3727ecd9a1a4bcb4d2e66b92a2660 (diff) | |
download | gnunet-gtk-c1091136df7ac8da8fda551702f57b1a22535195.tar.gz gnunet-gtk-c1091136df7ac8da8fda551702f57b1a22535195.zip |
-attempting to fix 2132 -- untested
-rw-r--r-- | src/fs/gnunet-fs-gtk_common.c | 124 | ||||
-rw-r--r-- | src/fs/gnunet-fs-gtk_common.h | 10 | ||||
-rw-r--r-- | src/fs/gnunet-fs-gtk_event-handler.c | 10 | ||||
-rw-r--r-- | src/fs/gnunet-fs-gtk_open-uri.c | 3 |
4 files changed, 138 insertions, 9 deletions
diff --git a/src/fs/gnunet-fs-gtk_common.c b/src/fs/gnunet-fs-gtk_common.c index a987b25a..91858455 100644 --- a/src/fs/gnunet-fs-gtk_common.c +++ b/src/fs/gnunet-fs-gtk_common.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2010 Christian Grothoff (and other contributing authors) | 3 | (C) 2010, 2012 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -24,6 +24,9 @@ | |||
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
26 | #include "gnunet-fs-gtk_common.h" | 26 | #include "gnunet-fs-gtk_common.h" |
27 | #include "gnunet-fs-gtk_download-save-as.h" | ||
28 | #include "gnunet-fs-gtk.h" | ||
29 | #include "gnunet-fs-gtk_event-handler.h" | ||
27 | 30 | ||
28 | /** | 31 | /** |
29 | * Converts metadata specified by @data of size @data_len | 32 | * Converts metadata specified by @data of size @data_len |
@@ -284,5 +287,124 @@ GNUNET_FS_GTK_get_description_from_metadata (const struct GNUNET_CONTAINER_MetaD | |||
284 | } | 287 | } |
285 | 288 | ||
286 | 289 | ||
290 | /** | ||
291 | * A URI was selected (or pasted into the application). Run | ||
292 | * the appropriate action. | ||
293 | * | ||
294 | * @param uri the URI | ||
295 | */ | ||
296 | void | ||
297 | GNUNET_FS_GTK_handle_uri (const struct GNUNET_FS_Uri *uri) | ||
298 | { | ||
299 | GtkTreeIter iter; | ||
300 | GtkTreeModel *namespace_treestore; | ||
301 | GtkTreeView *namespace_tree; | ||
302 | gchar *value; | ||
303 | GtkLabel *sel_namespace_label; | ||
304 | GtkTreePath *treepath; | ||
305 | GtkEntry *query_entry; | ||
306 | GNUNET_HashCode *nsid; | ||
307 | GNUNET_HashCode want; | ||
308 | |||
309 | if (GNUNET_FS_uri_test_chk (uri) || GNUNET_FS_uri_test_loc (uri)) | ||
310 | { | ||
311 | struct DownloadEntry *de; | ||
312 | |||
313 | de = GNUNET_malloc (sizeof (struct DownloadEntry)); | ||
314 | de->uri = GNUNET_FS_uri_dup (uri); | ||
315 | GNUNET_FS_GTK_open_download_as_dialog (de); | ||
316 | return; | ||
317 | } | ||
318 | query_entry = GTK_ENTRY (GNUNET_FS_GTK_get_main_window_object ("main_window_search_entry")); | ||
319 | namespace_tree = | ||
320 | GTK_TREE_VIEW (GNUNET_FS_GTK_get_main_window_object | ||
321 | ("namespace_selector_treeview")); | ||
322 | namespace_treestore = | ||
323 | GTK_TREE_MODEL (GNUNET_FS_GTK_get_main_window_object | ||
324 | ("main_window_search_namespace_treestore")); | ||
325 | sel_namespace_label = | ||
326 | GTK_LABEL (GNUNET_FS_GTK_get_main_window_object ("main_window_search_selected_namespace_label")); | ||
327 | |||
328 | if (GNUNET_FS_uri_test_sks (uri)) | ||
329 | { | ||
330 | /* select the namespace */ | ||
331 | if (GNUNET_OK != | ||
332 | GNUNET_FS_uri_sks_get_namespace (uri, &want)) | ||
333 | { | ||
334 | GNUNET_break (0); | ||
335 | return; | ||
336 | } | ||
337 | if (! gtk_tree_model_get_iter_first (namespace_treestore, &iter)) | ||
338 | { | ||
339 | GNUNET_break (0); | ||
340 | return; | ||
341 | } | ||
342 | gtk_tree_model_get (namespace_treestore, &iter, | ||
343 | 1, &nsid, | ||
344 | -1); | ||
345 | while ( ( (NULL == nsid) || | ||
346 | (0 != memcmp (nsid, | ||
347 | &want, | ||
348 | sizeof (GNUNET_HashCode))) ) && | ||
349 | (gtk_tree_model_iter_next (namespace_treestore, &iter)) ) | ||
350 | gtk_tree_model_get (namespace_treestore, &iter, | ||
351 | 1, &nsid, | ||
352 | -1); | ||
353 | if ( (NULL == nsid) || | ||
354 | (0 != memcmp (nsid, | ||
355 | &want, | ||
356 | sizeof (GNUNET_HashCode))) ) | ||
357 | { | ||
358 | /* namespace unknown / not in list!? */ | ||
359 | GNUNET_break (0); | ||
360 | return; | ||
361 | } | ||
362 | gtk_tree_selection_select_iter (gtk_tree_view_get_selection | ||
363 | (namespace_tree), &iter); | ||
364 | treepath = gtk_tree_model_get_path (namespace_treestore, | ||
365 | &iter); | ||
366 | if (GNUNET_GTK_get_tree_string (namespace_tree, treepath, 0, &value)) | ||
367 | gtk_label_set_text (sel_namespace_label, value); | ||
368 | gtk_tree_path_free (treepath); | ||
369 | |||
370 | /* set search entry to the namespace identifier */ | ||
371 | { | ||
372 | char *query_string; | ||
373 | |||
374 | query_string = GNUNET_FS_uri_sks_get_content_id (uri); | ||
375 | gtk_entry_set_text (query_entry, | ||
376 | query_string); | ||
377 | GNUNET_free (query_string); | ||
378 | } | ||
379 | return; | ||
380 | } | ||
381 | |||
382 | if (GNUNET_FS_uri_test_ksk (uri)) | ||
383 | { | ||
384 | /* select "no" namespace, which should be the first entry | ||
385 | in the namespace */ | ||
386 | if (gtk_tree_model_get_iter_first (namespace_treestore, &iter)) | ||
387 | { | ||
388 | gtk_tree_selection_select_iter (gtk_tree_view_get_selection | ||
389 | (namespace_tree), &iter); | ||
390 | treepath = gtk_tree_model_get_path (namespace_treestore, &iter); | ||
391 | if (GNUNET_GTK_get_tree_string (namespace_tree, treepath, 0, &value)) | ||
392 | gtk_label_set_text (sel_namespace_label, value); | ||
393 | gtk_tree_path_free (treepath); | ||
394 | } | ||
395 | /* set search entry to the query string */ | ||
396 | { | ||
397 | char *query_string; | ||
398 | |||
399 | query_string = GNUNET_FS_uri_ksk_to_string_fancy (uri); | ||
400 | gtk_entry_set_text (query_entry, | ||
401 | query_string); | ||
402 | GNUNET_free (query_string); | ||
403 | } | ||
404 | return; | ||
405 | } | ||
406 | GNUNET_break (0); | ||
407 | } | ||
408 | |||
287 | 409 | ||
288 | /* end of gnunet-fs-gtk-common.c */ | 410 | /* end of gnunet-fs-gtk-common.c */ |
diff --git a/src/fs/gnunet-fs-gtk_common.h b/src/fs/gnunet-fs-gtk_common.h index 38e8154c..9b13a7bd 100644 --- a/src/fs/gnunet-fs-gtk_common.h +++ b/src/fs/gnunet-fs-gtk_common.h | |||
@@ -134,5 +134,15 @@ GNUNET_FS_GTK_dubious_meta_to_utf8 (enum EXTRACTOR_MetaFormat format, | |||
134 | char * | 134 | char * |
135 | GNUNET_FS_GTK_get_description_from_metadata (const struct GNUNET_CONTAINER_MetaData *meta); | 135 | GNUNET_FS_GTK_get_description_from_metadata (const struct GNUNET_CONTAINER_MetaData *meta); |
136 | 136 | ||
137 | |||
138 | /** | ||
139 | * A URI was selected (or pasted into the application). Run | ||
140 | * the appropriate action. | ||
141 | * | ||
142 | * @param uri the URI | ||
143 | */ | ||
144 | void | ||
145 | GNUNET_FS_GTK_handle_uri (const struct GNUNET_FS_Uri *uri); | ||
146 | |||
137 | #endif | 147 | #endif |
138 | /* end of gnunet-fs-gtk-common.h */ | 148 | /* end of gnunet-fs-gtk-common.h */ |
diff --git a/src/fs/gnunet-fs-gtk_event-handler.c b/src/fs/gnunet-fs-gtk_event-handler.c index dc313cd0..36e5432c 100644 --- a/src/fs/gnunet-fs-gtk_event-handler.c +++ b/src/fs/gnunet-fs-gtk_event-handler.c | |||
@@ -470,14 +470,10 @@ GNUNET_FS_GTK_search_treeview_row_activated (GtkTreeView * tree_view, | |||
470 | have no URI and downloading makes no sense. Ignore! */ | 470 | have no URI and downloading makes no sense. Ignore! */ |
471 | return; | 471 | return; |
472 | } | 472 | } |
473 | if (GNUNET_FS_uri_test_ksk (uri)) | 473 | if (GNUNET_FS_uri_test_ksk (uri) || |
474 | GNUNET_FS_uri_test_sks (uri)) | ||
474 | { | 475 | { |
475 | /* FIXME-FEATURE: copy keywords to search bar (and select 'no' namespace) */ | 476 | GNUNET_FS_GTK_handle_uri (uri); |
476 | return; | ||
477 | } | ||
478 | if (GNUNET_FS_uri_test_sks (uri)) | ||
479 | { | ||
480 | /* FIXME-FEATURE: select namespace and copy root to search bar */ | ||
481 | return; | 477 | return; |
482 | } | 478 | } |
483 | /* must be chk/loc URI, start download */ | 479 | /* must be chk/loc URI, start download */ |
diff --git a/src/fs/gnunet-fs-gtk_open-uri.c b/src/fs/gnunet-fs-gtk_open-uri.c index be0e0f86..7c0900fc 100644 --- a/src/fs/gnunet-fs-gtk_open-uri.c +++ b/src/fs/gnunet-fs-gtk_open-uri.c | |||
@@ -45,7 +45,8 @@ GNUNET_GTK_open_url_dialog_execute_button_clicked_cb (GtkButton * button, | |||
45 | GtkBuilder *builder = GTK_BUILDER (user_data); | 45 | GtkBuilder *builder = GTK_BUILDER (user_data); |
46 | GtkWidget *dialog; | 46 | GtkWidget *dialog; |
47 | GtkTextBuffer *tb; | 47 | GtkTextBuffer *tb; |
48 | GtkTextIter ti_start, ti_end; | 48 | GtkTextIter ti_start; |
49 | GtkTextIter ti_end; | ||
49 | guint anonymity_level; | 50 | guint anonymity_level; |
50 | char *perr; | 51 | char *perr; |
51 | char *uris; | 52 | char *uris; |