gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r19609 - gnunet-gtk/src/fs


From: gnunet
Subject: [GNUnet-SVN] r19609 - gnunet-gtk/src/fs
Date: Wed, 1 Feb 2012 18:37:37 +0100

Author: grothoff
Date: 2012-02-01 18:37:37 +0100 (Wed, 01 Feb 2012)
New Revision: 19609

Modified:
   gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_namespace.c
   gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_search.c
   gnunet-gtk/src/fs/gnunet-fs-gtk.c
   gnunet-gtk/src/fs/gnunet-fs-gtk.h
Log:
-moving code around plus some DCE

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_namespace.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_namespace.c     2012-02-01 
17:37:16 UTC (rev 19608)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_namespace.c     2012-02-01 
17:37:37 UTC (rev 19609)
@@ -25,8 +25,12 @@
  */
 #include "gnunet-fs-gtk-common.h"
 #include <gdk/gdk.h>
+#include "gnunet-fs-gtk.h"
 
 
+static guint namespace_selector_window_leave_timeout_source;
+
+
 void
 main_window_search_namespace_dropdown_button_toggled_cb (GtkToggleButton *
                                                          togglebutton,
@@ -321,4 +325,153 @@
 
 
 
+/**
+ * Add pseudonym data to tree store
+ *
+ * @param cls closure (the 'GtkListStore')
+ * @param pseudonym hash code of public key of pseudonym
+ * @param md meta data known about the pseudonym
+ * @param rating the local rating of the pseudonym
+ * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort
+ */
+static int
+add_namespace_to_ts (void *cls, const GNUNET_HashCode * pseudonym,
+                     const struct GNUNET_CONTAINER_MetaData *md, int rating)
+{
+  GtkTreeStore *ts = cls;
+  char *root;
+  char *ns_name;
+  GNUNET_HashCode *nsid;
+  char *description;
+  char *uris;
+  char *emsg;
+  struct GNUNET_FS_Uri *uri;
+  GtkTreeIter iter;
+
+  ns_name =
+      GNUNET_PSEUDONYM_id_to_name (GNUNET_FS_GTK_get_configuration (),
+                                   pseudonym);
+  nsid = GNUNET_malloc (sizeof (GNUNET_HashCode));
+  *nsid = *pseudonym;
+  root = NULL;
+  uris = GNUNET_CONTAINER_meta_data_get_by_type (md, EXTRACTOR_METATYPE_URI);
+  if (uris != NULL)
+  {
+    emsg = NULL;
+    uri = GNUNET_FS_uri_parse (uris, &emsg);
+    if (uri == NULL)
+      GNUNET_free (emsg);
+    root = GNUNET_FS_uri_sks_get_content_id (uri);
+    GNUNET_FS_uri_destroy (uri);
+  }
+  description =
+      GNUNET_CONTAINER_meta_data_get_first_by_types (md,
+                                                     EXTRACTOR_METATYPE_TITLE,
+                                                     
EXTRACTOR_METATYPE_BOOK_TITLE,
+                                                     
EXTRACTOR_METATYPE_DESCRIPTION,
+                                                     
EXTRACTOR_METATYPE_SUMMARY,
+                                                     EXTRACTOR_METATYPE_ALBUM,
+                                                     
EXTRACTOR_METATYPE_COMMENT,
+                                                     
EXTRACTOR_METATYPE_SUBJECT,
+                                                     
EXTRACTOR_METATYPE_KEYWORDS,
+                                                     -1);
+  if (description == NULL)
+    description = g_strdup (_("no description supplied"));
+  else
+  {
+    char *utf8_desc = NULL;
+
+    utf8_desc =
+        GNUNET_FS_GTK_dubious_meta_to_utf8 (EXTRACTOR_METAFORMAT_UTF8,
+                                            description, strlen (description));
+    GNUNET_free (description);
+    if (utf8_desc != NULL)
+      description = utf8_desc;
+    else
+      description = NULL;
+  }
+  gtk_tree_store_insert_with_values (ts, &iter, NULL, G_MAXINT, 0, ns_name, 1,
+                                     nsid, 2, root, 3, description, -1);
+  GNUNET_free (ns_name);
+  GNUNET_free_non_null (root);
+  GNUNET_free_non_null (description);
+  return GNUNET_OK;
+}
+
+
+void
+GNUNET_GTK_main_window_realize_cb (GtkWidget * widget, gpointer user_data)
+{
+  GtkTreeIter iter;
+  GtkTreeView *namespace_tree;
+  GtkTreeStore *namespace_treestore;
+  GtkBuilder *builder;
+  GtkWidget *namespace_selector_window;
+
+  builder = GTK_BUILDER (user_data);
+
+  /* Make sure button class is realized */
+  g_type_class_unref (g_type_class_ref (GTK_TYPE_BUTTON));
+  /* GNUnet main window assumes that images on buttons are visible,
+   * override the theme's gtkrc setting
+   */
+  g_object_set (gtk_settings_get_default (), "gtk-button-images", TRUE, NULL);
+
+  namespace_treestore =
+      GTK_TREE_STORE (GNUNET_FS_GTK_get_main_window_object
+                      ("main_window_search_namespace_treestore"));
+  namespace_tree =
+      GTK_TREE_VIEW (GNUNET_FS_GTK_get_main_window_object
+                     ("namespace_selector_treeview"));
+
+  /* FIXME: find a way to manage pseudonyms.
+   * Right now the list will be filled with ALL and ANY pseudonyms that we
+   * find, these are held as files in a special directory.
+   * I don't see an easy way to ignore certain pseudonyms in that directory,
+   * and that require for pseudonym management. Also, pseudonyms are presented
+   * in arbitrary order. We must either sort them (by name?) or let the user
+   * drag them around to change the order in which they appear in the list.
+   * All that is not possible with a simple "files in a directory" concept.
+   */
+  gtk_tree_store_insert_with_values (namespace_treestore, &iter, NULL, 
G_MAXINT,
+                                     0, "Any", 1, NULL, 2, "", 3,
+                                     "Do not search in any particular 
namespace",
+                                     -1);
+  /*
+   * GNUNET_PSEUDONYM_list_all (GNUNET_FS_GTK_get_configuration (),
+   * &add_namespace_to_ts, namespace_treestore);
+   */
+  /* FIXME: when do we unregister? */
+  GNUNET_PSEUDONYM_discovery_callback_register 
(GNUNET_FS_GTK_get_configuration (), 
+                                               &add_namespace_to_ts,
+                                                namespace_treestore);
+
+  /* FIXME: read currently selected namespace from somewhere instead of 
selecting 0th item */
+  if (gtk_tree_model_get_iter_first
+      (GTK_TREE_MODEL (namespace_treestore), &iter))
+  {
+    gchar *value;
+    GtkLabel *sel_namespace_label;
+    GtkTreePath *treepath = gtk_tree_path_new_first ();
+
+    gtk_tree_selection_select_iter (gtk_tree_view_get_selection
+                                    (namespace_tree), &iter);
+    sel_namespace_label =
+        GTK_LABEL (gtk_builder_get_object
+                   (builder, "main_window_search_selected_namespace_label"));
+    if (GNUNET_GTK_get_tree_string (namespace_tree, treepath, 0, &value))
+      gtk_label_set_text (sel_namespace_label, value);
+    gtk_tree_path_free (treepath);
+  }
+
+  /* How the window (to trigger certain events) and immediately hide it */
+  namespace_selector_window =
+      GTK_WIDGET (gtk_builder_get_object
+                  (builder, "namespace_selector_window"));
+  gtk_widget_show (namespace_selector_window);
+  gtk_widget_hide (namespace_selector_window);
+
+}
+
+
 /* end of gnunet-fs-gtk-main_window_namespace.c */

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_search.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_search.c        2012-02-01 
17:37:16 UTC (rev 19608)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_search.c        2012-02-01 
17:37:37 UTC (rev 19609)
@@ -24,10 +24,11 @@
  * @brief event handlers for the search function in the main window
  */
 #include "gnunet-fs-gtk-common.h"
+#include "gnunet-fs-gtk.h"
 #include <gdk/gdk.h>
+#include "gnunet-fs-gtk-anonymity_spin_buttons.h"
 
 
-
 void
 main_window_search_button_clicked_cb (GtkButton * button, gpointer user_data)
 {

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk.c   2012-02-01 17:37:16 UTC (rev 19608)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk.c   2012-02-01 17:37:37 UTC (rev 19609)
@@ -25,7 +25,6 @@
  */
 #include "gnunet-fs-gtk-common.h"
 #include "gnunet-fs-gtk-event_handler.h"
-#include "gnunet-fs-gtk-anonymity_spin_buttons.h"
 #include <gdk/gdkkeysyms.h>
 
 /**
@@ -43,13 +42,7 @@
  */
 static struct GNUNET_FS_Handle *fs;
 
-/**
- * List of plugins for meta data extraction.
- */
-static struct EXTRACTOR_PluginList *plugins;
 
-guint namespace_selector_window_leave_timeout_source = 0;
-
 /**
  * Return handle for file-sharing operations.
  *
@@ -61,18 +54,7 @@
   return fs;
 }
 
-
 /**
- * Get LE plugin list.
- */
-struct EXTRACTOR_PluginList *
-GNUNET_FS_GTK_get_le_plugins ()
-{
-  return plugins;
-}
-
-
-/**
  * Get cfg.
  */
 const struct GNUNET_CONFIGURATION_Handle *
@@ -111,8 +93,6 @@
     GNUNET_FS_stop (fs);
     fs = NULL;
   }
-  EXTRACTOR_plugin_remove_all (plugins);
-  plugins = NULL;
 }
 
 
@@ -129,160 +109,6 @@
 
 
 /**
- * Add pseudonym data to tree store
- *
- * @param cls closure (the 'GtkListStore')
- * @param pseudonym hash code of public key of pseudonym
- * @param md meta data known about the pseudonym
- * @param rating the local rating of the pseudonym
- * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort
- */
-static int
-add_namespace_to_ts (void *cls, const GNUNET_HashCode * pseudonym,
-                     const struct GNUNET_CONTAINER_MetaData *md, int rating)
-{
-  GtkTreeStore *ts = cls;
-  char *root;
-  char *ns_name;
-  GNUNET_HashCode *nsid;
-  char *description;
-  char *uris;
-  char *emsg;
-  struct GNUNET_FS_Uri *uri;
-  GtkTreeIter iter;
-
-  ns_name =
-      GNUNET_PSEUDONYM_id_to_name (GNUNET_FS_GTK_get_configuration (),
-                                   pseudonym);
-  nsid = GNUNET_malloc (sizeof (GNUNET_HashCode));
-  *nsid = *pseudonym;
-  root = NULL;
-  uris = GNUNET_CONTAINER_meta_data_get_by_type (md, EXTRACTOR_METATYPE_URI);
-  if (uris != NULL)
-  {
-    emsg = NULL;
-    uri = GNUNET_FS_uri_parse (uris, &emsg);
-    if (uri == NULL)
-      GNUNET_free (emsg);
-    root = GNUNET_FS_uri_sks_get_content_id (uri);
-    GNUNET_FS_uri_destroy (uri);
-  }
-  description =
-      GNUNET_CONTAINER_meta_data_get_first_by_types (md,
-                                                     EXTRACTOR_METATYPE_TITLE,
-                                                     
EXTRACTOR_METATYPE_BOOK_TITLE,
-                                                     
EXTRACTOR_METATYPE_DESCRIPTION,
-                                                     
EXTRACTOR_METATYPE_SUMMARY,
-                                                     EXTRACTOR_METATYPE_ALBUM,
-                                                     
EXTRACTOR_METATYPE_COMMENT,
-                                                     
EXTRACTOR_METATYPE_SUBJECT,
-                                                     
EXTRACTOR_METATYPE_KEYWORDS,
-                                                     -1);
-  if (description == NULL)
-    description = g_strdup (_("no description supplied"));
-  else
-  {
-    char *utf8_desc = NULL;
-
-    utf8_desc =
-        GNUNET_FS_GTK_dubious_meta_to_utf8 (EXTRACTOR_METAFORMAT_UTF8,
-                                            description, strlen (description));
-    GNUNET_free (description);
-    if (utf8_desc != NULL)
-      description = utf8_desc;
-    else
-      description = NULL;
-  }
-  gtk_tree_store_insert_with_values (ts, &iter, NULL, G_MAXINT, 0, ns_name, 1,
-                                     nsid, 2, root, 3, description, -1);
-  GNUNET_free (ns_name);
-  GNUNET_free_non_null (root);
-  GNUNET_free_non_null (description);
-  return GNUNET_OK;
-}
-
-void
-GNUNET_GTK_main_window_realize_cb (GtkWidget * widget, gpointer user_data)
-{
-  GtkTreeIter iter;
-  GtkTreeView *namespace_tree;
-  GtkTreeStore *namespace_treestore;
-  GtkBuilder *builder;
-  GtkWidget *namespace_selector_window;
-  GtkTreeView *metadata_tree;
-
-  builder = GTK_BUILDER (user_data);
-
-  /* Make sure button class is realized */
-  g_type_class_unref (g_type_class_ref (GTK_TYPE_BUTTON));
-  /* GNUnet main window assumes that images on buttons are visible,
-   * override the theme's gtkrc setting
-   */
-  g_object_set (gtk_settings_get_default (), "gtk-button-images", TRUE, NULL);
-
-  namespace_treestore =
-      GTK_TREE_STORE (GNUNET_FS_GTK_get_main_window_object
-                      ("main_window_search_namespace_treestore"));
-  namespace_tree =
-      GTK_TREE_VIEW (GNUNET_FS_GTK_get_main_window_object
-                     ("namespace_selector_treeview"));
-  metadata_tree =
-      GTK_TREE_VIEW (GNUNET_FS_GTK_get_main_window_object
-                     ("GNUNET_GTK_main_window_metadata_treeview"));
-
-  /* Allow multiple selection in metadata view */
-  gtk_tree_selection_set_mode (gtk_tree_view_get_selection (metadata_tree),
-                               GTK_SELECTION_MULTIPLE);
-
-  /* FIXME: find a way to manage pseudonyms.
-   * Right now the list will be filled with ALL and ANY pseudonyms that we
-   * find, these are held as files in a special directory.
-   * I don't see an easy way to ignore certain pseudonyms in that directory,
-   * and that require for pseudonym management. Also, pseudonyms are presented
-   * in arbitrary order. We must either sort them (by name?) or let the user
-   * drag them around to change the order in which they appear in the list.
-   * All that is not possible with a simple "files in a directory" concept.
-   */
-  gtk_tree_store_insert_with_values (namespace_treestore, &iter, NULL, 
G_MAXINT,
-                                     0, "Any", 1, NULL, 2, "", 3,
-                                     "Do not search in any particular 
namespace",
-                                     -1);
-  /*
-   * GNUNET_PSEUDONYM_list_all (GNUNET_FS_GTK_get_configuration (),
-   * &add_namespace_to_ts, namespace_treestore);
-   */
-  GNUNET_PSEUDONYM_discovery_callback_register (GNUNET_FS_GTK_get_configuration
-                                                (), &add_namespace_to_ts,
-                                                namespace_treestore);
-
-  /* FIXME: read currently selected namespace from somewhere instead of 
selecting 0th item */
-  if (gtk_tree_model_get_iter_first
-      (GTK_TREE_MODEL (namespace_treestore), &iter))
-  {
-    gchar *value;
-    GtkLabel *sel_namespace_label;
-    GtkTreePath *treepath = gtk_tree_path_new_first ();
-
-    gtk_tree_selection_select_iter (gtk_tree_view_get_selection
-                                    (namespace_tree), &iter);
-    sel_namespace_label =
-        GTK_LABEL (gtk_builder_get_object
-                   (builder, "main_window_search_selected_namespace_label"));
-    if (GNUNET_GTK_get_tree_string (namespace_tree, treepath, 0, &value))
-      gtk_label_set_text (sel_namespace_label, value);
-    gtk_tree_path_free (treepath);
-  }
-
-  /* How the window (to trigger certain events) and immediately hide it */
-  namespace_selector_window =
-      GTK_WIDGET (gtk_builder_get_object
-                  (builder, "namespace_selector_window"));
-  gtk_widget_show (namespace_selector_window);
-  gtk_widget_hide (namespace_selector_window);
-
-}
-
-/**
  * Actual main function run right after GNUnet's scheduler
  * is initialized.  Initializes up GTK and Glade.
  */
@@ -290,6 +116,7 @@
 run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   GtkWidget *main_window;
+  GtkTreeView *metadata_tree;
 
   ml = cls;
 
@@ -301,14 +128,23 @@
       GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object
                   ("GNUNET_GTK_main_window"));
   gtk_window_maximize (GTK_WINDOW (main_window));
+  
+  /* Allow multiple selection in metadata view; FIXME: can we do this with 
glade now? */
+  metadata_tree =
+      GTK_TREE_VIEW (GNUNET_FS_GTK_get_main_window_object
+                     ("GNUNET_GTK_main_window_metadata_treeview"));
+  gtk_tree_selection_set_mode (gtk_tree_view_get_selection (metadata_tree),
+                               GTK_SELECTION_MULTIPLE);
+
   GNUNET_GTK_tray_icon_create (GTK_WINDOW (main_window),
                                "gnunet-gtk" /* FIXME: rename icon? */ ,
                                "gnunet-fs-gtk");
 
   /* initialize file-sharing */
-  plugins = EXTRACTOR_plugin_add_defaults (EXTRACTOR_OPTION_DEFAULT_POLICY);
-  fs = GNUNET_FS_start (GNUNET_GTK_main_loop_get_configuration (ml), 
"gnunet-gtk", &GNUNET_GTK_fs_event_handler, NULL, GNUNET_FS_FLAGS_NONE     /* | 
GNUNET_FS_FLAGS_PERSISTENCE |
-                                                                               
                                                                  * 
GNUNET_FS_FLAGS_DO_PROBES */ ,
+  fs = GNUNET_FS_start (GNUNET_GTK_main_loop_get_configuration (ml), 
+                       "gnunet-gtk", &GNUNET_GTK_fs_event_handler, NULL, 
+                       GNUNET_FS_FLAGS_NONE     /* | 
GNUNET_FS_FLAGS_PERSISTENCE |
+                                                 * GNUNET_FS_FLAGS_DO_PROBES 
*/ ,
                         GNUNET_FS_OPTIONS_END);
   if (fs != NULL)
   {
@@ -346,6 +182,7 @@
 
 }
 
+
 int
 main (int argc, char *const *argv)
 {

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk.h
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk.h   2012-02-01 17:37:16 UTC (rev 19608)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk.h   2012-02-01 17:37:37 UTC (rev 19609)
@@ -32,13 +32,6 @@
 
 
 /**
- * Get GNU libextractor plugin list.
- */
-struct EXTRACTOR_PluginList *
-GNUNET_FS_GTK_get_le_plugins (void);
-
-
-/**
  * Get our configuration.
  */
 const struct GNUNET_CONFIGURATION_Handle *




reply via email to

[Prev in Thread] Current Thread [Next in Thread]