[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r19705 - gnunet-gtk/src/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r19705 - gnunet-gtk/src/fs |
Date: |
Sun, 5 Feb 2012 20:36:09 +0100 |
Author: grothoff
Date: 2012-02-05 20:36:09 +0100 (Sun, 05 Feb 2012)
New Revision: 19705
Modified:
gnunet-gtk/src/fs/gnunet-fs-gtk_common.c
gnunet-gtk/src/fs/gnunet-fs-gtk_common.h
gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
gnunet-gtk/src/fs/gnunet-fs-gtk_open-uri.c
Log:
-attempting to fix 2132 -- untested
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_common.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_common.c 2012-02-05 18:59:26 UTC (rev
19704)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_common.c 2012-02-05 19:36:09 UTC (rev
19705)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2010 Christian Grothoff (and other contributing authors)
+ (C) 2010, 2012 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -24,6 +24,9 @@
* @author Christian Grothoff
*/
#include "gnunet-fs-gtk_common.h"
+#include "gnunet-fs-gtk_download-save-as.h"
+#include "gnunet-fs-gtk.h"
+#include "gnunet-fs-gtk_event-handler.h"
/**
* Converts metadata specified by @data of size @data_len
@@ -284,5 +287,124 @@
}
+/**
+ * A URI was selected (or pasted into the application). Run
+ * the appropriate action.
+ *
+ * @param uri the URI
+ */
+void
+GNUNET_FS_GTK_handle_uri (const struct GNUNET_FS_Uri *uri)
+{
+ GtkTreeIter iter;
+ GtkTreeModel *namespace_treestore;
+ GtkTreeView *namespace_tree;
+ gchar *value;
+ GtkLabel *sel_namespace_label;
+ GtkTreePath *treepath;
+ GtkEntry *query_entry;
+ GNUNET_HashCode *nsid;
+ GNUNET_HashCode want;
+
+ if (GNUNET_FS_uri_test_chk (uri) || GNUNET_FS_uri_test_loc (uri))
+ {
+ struct DownloadEntry *de;
+ de = GNUNET_malloc (sizeof (struct DownloadEntry));
+ de->uri = GNUNET_FS_uri_dup (uri);
+ GNUNET_FS_GTK_open_download_as_dialog (de);
+ return;
+ }
+ query_entry = GTK_ENTRY (GNUNET_FS_GTK_get_main_window_object
("main_window_search_entry"));
+ namespace_tree =
+ GTK_TREE_VIEW (GNUNET_FS_GTK_get_main_window_object
+ ("namespace_selector_treeview"));
+ namespace_treestore =
+ GTK_TREE_MODEL (GNUNET_FS_GTK_get_main_window_object
+ ("main_window_search_namespace_treestore"));
+ sel_namespace_label =
+ GTK_LABEL (GNUNET_FS_GTK_get_main_window_object
("main_window_search_selected_namespace_label"));
+
+ if (GNUNET_FS_uri_test_sks (uri))
+ {
+ /* select the namespace */
+ if (GNUNET_OK !=
+ GNUNET_FS_uri_sks_get_namespace (uri, &want))
+ {
+ GNUNET_break (0);
+ return;
+ }
+ if (! gtk_tree_model_get_iter_first (namespace_treestore, &iter))
+ {
+ GNUNET_break (0);
+ return;
+ }
+ gtk_tree_model_get (namespace_treestore, &iter,
+ 1, &nsid,
+ -1);
+ while ( ( (NULL == nsid) ||
+ (0 != memcmp (nsid,
+ &want,
+ sizeof (GNUNET_HashCode))) ) &&
+ (gtk_tree_model_iter_next (namespace_treestore, &iter)) )
+ gtk_tree_model_get (namespace_treestore, &iter,
+ 1, &nsid,
+ -1);
+ if ( (NULL == nsid) ||
+ (0 != memcmp (nsid,
+ &want,
+ sizeof (GNUNET_HashCode))) )
+ {
+ /* namespace unknown / not in list!? */
+ GNUNET_break (0);
+ return;
+ }
+ gtk_tree_selection_select_iter (gtk_tree_view_get_selection
+ (namespace_tree), &iter);
+ treepath = gtk_tree_model_get_path (namespace_treestore,
+ &iter);
+ if (GNUNET_GTK_get_tree_string (namespace_tree, treepath, 0, &value))
+ gtk_label_set_text (sel_namespace_label, value);
+ gtk_tree_path_free (treepath);
+
+ /* set search entry to the namespace identifier */
+ {
+ char *query_string;
+
+ query_string = GNUNET_FS_uri_sks_get_content_id (uri);
+ gtk_entry_set_text (query_entry,
+ query_string);
+ GNUNET_free (query_string);
+ }
+ return;
+ }
+
+ if (GNUNET_FS_uri_test_ksk (uri))
+ {
+ /* select "no" namespace, which should be the first entry
+ in the namespace */
+ if (gtk_tree_model_get_iter_first (namespace_treestore, &iter))
+ {
+ gtk_tree_selection_select_iter (gtk_tree_view_get_selection
+ (namespace_tree), &iter);
+ treepath = gtk_tree_model_get_path (namespace_treestore, &iter);
+ if (GNUNET_GTK_get_tree_string (namespace_tree, treepath, 0, &value))
+ gtk_label_set_text (sel_namespace_label, value);
+ gtk_tree_path_free (treepath);
+ }
+ /* set search entry to the query string */
+ {
+ char *query_string;
+
+ query_string = GNUNET_FS_uri_ksk_to_string_fancy (uri);
+ gtk_entry_set_text (query_entry,
+ query_string);
+ GNUNET_free (query_string);
+ }
+ return;
+ }
+ GNUNET_break (0);
+}
+
+
/* end of gnunet-fs-gtk-common.c */
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_common.h
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_common.h 2012-02-05 18:59:26 UTC (rev
19704)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_common.h 2012-02-05 19:36:09 UTC (rev
19705)
@@ -134,5 +134,15 @@
char *
GNUNET_FS_GTK_get_description_from_metadata (const struct
GNUNET_CONTAINER_MetaData *meta);
+
+/**
+ * A URI was selected (or pasted into the application). Run
+ * the appropriate action.
+ *
+ * @param uri the URI
+ */
+void
+GNUNET_FS_GTK_handle_uri (const struct GNUNET_FS_Uri *uri);
+
#endif
/* end of gnunet-fs-gtk-common.h */
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c 2012-02-05 18:59:26 UTC
(rev 19704)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c 2012-02-05 19:36:09 UTC
(rev 19705)
@@ -470,16 +470,12 @@
have no URI and downloading makes no sense. Ignore! */
return;
}
- if (GNUNET_FS_uri_test_ksk (uri))
+ if (GNUNET_FS_uri_test_ksk (uri) ||
+ GNUNET_FS_uri_test_sks (uri))
{
- /* FIXME-FEATURE: copy keywords to search bar (and select 'no' namespace)
*/
+ GNUNET_FS_GTK_handle_uri (uri);
return;
}
- if (GNUNET_FS_uri_test_sks (uri))
- {
- /* FIXME-FEATURE: select namespace and copy root to search bar */
- return;
- }
/* must be chk/loc URI, start download */
start_download (tree_view, path, tab, GNUNET_NO, GNUNET_NO);
}
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_open-uri.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_open-uri.c 2012-02-05 18:59:26 UTC (rev
19704)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_open-uri.c 2012-02-05 19:36:09 UTC (rev
19705)
@@ -45,7 +45,8 @@
GtkBuilder *builder = GTK_BUILDER (user_data);
GtkWidget *dialog;
GtkTextBuffer *tb;
- GtkTextIter ti_start, ti_end;
+ GtkTextIter ti_start;
+ GtkTextIter ti_end;
guint anonymity_level;
char *perr;
char *uris;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r19705 - gnunet-gtk/src/fs,
gnunet <=