gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r29043 - gnunet-gtk/src/fs
Date: Thu, 5 Sep 2013 18:39:39 +0200

Author: grothoff
Date: 2013-09-05 18:39:39 +0200 (Thu, 05 Sep 2013)
New Revision: 29043

Added:
   gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c
Removed:
   gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c
Modified:
   gnunet-gtk/src/fs/Makefile.am
Log:
-oops, removed wrong file

Modified: gnunet-gtk/src/fs/Makefile.am
===================================================================
--- gnunet-gtk/src/fs/Makefile.am       2013-09-05 16:36:00 UTC (rev 29042)
+++ gnunet-gtk/src/fs/Makefile.am       2013-09-05 16:39:39 UTC (rev 29043)
@@ -20,7 +20,7 @@
   gnunet-fs-gtk_download-save-as.c gnunet-fs-gtk_download-save-as.h \
   gnunet-fs-gtk_event-handler.c gnunet-fs-gtk_event-handler.h \
   gnunet-fs-gtk_main-window-connection.c \
-  gnunet-fs-gtk_main-window-namespace-dropdown.c \
+  gnunet-fs-gtk_main-window-meta-data-context-menu.c \
   gnunet-fs-gtk_main-window-search.c \
   gnunet-fs-gtk_main-window-view-toggles.c \
   gnunet-fs-gtk_open-directory.c \

Added: gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c        
                        (rev 0)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c        
2013-09-05 16:39:39 UTC (rev 29043)
@@ -0,0 +1,193 @@
+/*
+     This file is part of GNUnet.
+     (C) 2010, 2011, 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
+     by the Free Software Foundation; either version 2, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c
+ * @brief context menu for the 'meta data' tree view in the main window
+ * @author Christian Grothoff
+ */
+#include "gnunet-fs-gtk.h"
+#include "gnunet-fs-gtk_download-save-as.h"
+#include "gnunet-fs-gtk_event-handler.h"
+#include <string.h>
+
+
+
+/**
+ * Helper function of GNUNET_GTK_FS_metadata_copy_selection_activated
+ * which copies the (selected) entries from the tree view to the
+ * GList.
+ *
+ * @param model the tree model with the data
+ * @param path unused
+ * @param iter position in the model to access
+ * @param user_data 'GList**' where we should store the types and values found
+ */ 
+static void
+copy_metadata_to_clipboard (GtkTreeModel * model, GtkTreePath * path,
+                            GtkTreeIter * iter, gpointer user_data)
+{
+  GList **l = user_data;
+  gchar *type;
+  gchar *value;
+
+  gtk_tree_model_get (model, iter,
+                      GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_TYPE_STRING,
+                      &type,
+                      GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_VALUE,
+                      &value,
+                      -1);
+  *l = g_list_prepend (*l, type);
+  *l = g_list_prepend (*l, value);
+}
+
+
+/**
+ * User activated metadata pop up menu "Copy selection" entry.
+ *
+ * @param menuitem the 'copy selection' menu item
+ * @param user_data the GtkBuilder of the main window
+ */
+void
+GNUNET_GTK_FS_metadata_copy_selection_activated (GtkMenuItem * menuitem, 
+                                                gpointer user_data)
+{
+  struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
+  GtkTreeView *tree;
+  GtkClipboard *cb;
+  GList *pairs;
+  GList *pos;
+  GList *value;
+  GList *type;
+  guint total_len;
+  gchar *s;
+  gchar *p;
+
+  tree = main_ctx->md_treeview;
+  pairs = NULL;
+  gtk_tree_selection_selected_foreach (gtk_tree_view_get_selection (tree),
+                                       &copy_metadata_to_clipboard, &pairs);
+  if (NULL == pairs)
+    return; /* nothing selected */
+  total_len = 0;
+  pairs = g_list_reverse (pairs);
+  for (pos = pairs; NULL != pos; pos = value->next)
+  {
+    type = pos;
+    value = pos->next;
+    GNUNET_assert (NULL != value);
+    total_len +=
+      strlen ((gchar *) type->data) + strlen ((gchar *) value->data) +
+      2 /* ": " */  + ((NULL != value->next) ? 1 : 0) /* "\n" */ ;
+  }
+  GNUNET_assert (total_len > 0);
+  total_len++;             /* "\0" */
+  s = g_new0 (gchar, total_len);
+  if (NULL == s)
+  {
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "malloc");
+    return;
+  }
+  p = s;
+  for (pos = pairs; NULL != pos; pos = value->next)
+  {
+    type = pos;
+    value = pos->next;
+    GNUNET_assert (NULL != value);
+    p = g_stpcpy (p, (gchar *) type->data);
+    p = g_stpcpy (p, ": ");
+    p = g_stpcpy (p, (gchar *) value->data);
+    if (NULL != value->next)
+      p = g_stpcpy (p, "\n");        
+  }
+  g_list_foreach (pairs, (GFunc) &g_free, NULL);
+  g_list_free (pairs);
+  cb = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
+  gtk_clipboard_set_text (cb, s, -1);
+  gtk_clipboard_store (cb);
+  g_free (s);  
+}
+
+
+/**
+ * Got asked to pop up the context menu in the metadata treeview in
+ * the main window.  Do it.
+ *
+ * @param button which button caused the event (0 for none)
+ * @param event_time time of the event (current time or 'event->time')
+ * @param user_data the context of the main window
+ */
+static void
+do_metadata_popup_menu (int button,
+                       int event_time,
+                        gpointer user_data)
+{
+  GtkMenu *menu;
+  struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
+
+  menu = GTK_MENU (gtk_builder_get_object (main_ctx->builder, 
"metadata_popup_menu"));
+  gtk_menu_popup (menu, NULL, NULL, NULL, main_ctx, button, event_time);
+}
+
+
+/**
+ * Got a button press event on the metadata treeview in the main window.
+ * If it was a right click, pop up the context menu.
+ *
+ * @param widget the tree view widget
+ * @param user_data the gtk builder of the main window
+ */
+gboolean
+GNUNET_GTK_main_window_metadata_treeview_button_press_event_cb (GtkWidget *
+                                                                widget,
+                                                                GdkEventButton 
*
+                                                                event,
+                                                                gpointer
+                                                                user_data)
+{
+  /* Ignore double-clicks and triple-clicks */
+  if ( (event->button != 3) || (event->type != GDK_BUTTON_PRESS) )
+    return FALSE;
+  do_metadata_popup_menu (event->button,
+                         event->time,
+                         user_data);
+  return FALSE;
+}
+
+
+/**
+ * Metadata treeview in the main window got the 'popup-menu' signal.
+ * Pop up the menu.
+ *
+ * @param widget the tree view widget
+ * @param user_data the gtk builder of the main window
+ * @return TRUE we did it
+ */
+gboolean
+GNUNET_GTK_main_window_metadata_treeview_popup_menu_cb (GtkWidget * widget,
+                                                        gpointer user_data)
+{
+  do_metadata_popup_menu (0 /* no button */,
+                         gtk_get_current_event_time (),
+                         user_data);
+  return TRUE;
+}
+
+/* end of gnunet-fs-gtk_meta-data-context-menu.c */

Deleted: gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c    
2013-09-05 16:36:00 UTC (rev 29042)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c    
2013-09-05 16:39:39 UTC (rev 29043)
@@ -1,467 +0,0 @@
-/*
-     This file is part of GNUnet
-     (C) 2011-2013 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
-     by the Free Software Foundation; either version 3, or (at your
-     option) any later version.
-
-     GNUnet is distributed in the hope that it will be useful, but
-     WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
-
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
-*/
-
-/**
- * @file src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c
- * @author LRN
- * @brief event handlers for the namespace selection dropdown box in the main 
window
- */
-#include "gnunet-fs-gtk_common.h"
-#include "gnunet-fs-gtk.h"
-#include "gnunet-fs-gtk_event-handler.h"
-
-/**
- * How long until we automatically hide the drop-down if the cursor is outside 
the bounds?
- */
-#define AUTO_HIDE_TIMEOUT_MS 100
-
-
-/**
- * ID of a timeout task which we schedule to close the drop-down automatically
- * if the mouse leaves the area for a while.  0 for no such task.
- *
- * FIXME-BUG-MINOR: this task is not cancelled if the main window is closed 
while
- *        the drop-down is down.
- */
-static guint namespace_selector_window_leave_timeout_source;
-
-
-/**
- * The mouse has re-entered the dropdown window.  Stop the 
- * timeout task that would hide the dropdown.
- *
- * @param widget the dropdown widget
- * @param event the mouse-enter event
- * @param user_data the context for the main window
- */
-gboolean
-GNUNET_FS_GTK_search_namespace_dropdown_button_enter_notify_event_cb 
(GtkWidget *widget,
-                                                                     GdkEvent 
*event,
-                                                                     gpointer 
user_data)
-{
-  if (namespace_selector_window_leave_timeout_source > 0)
-    g_source_remove (namespace_selector_window_leave_timeout_source);
-  namespace_selector_window_leave_timeout_source = 0;
-  return FALSE;
-}
-
-
-/**
- * Run when the timeout has expired.  Hides the drop down window.
- *
- * @param user_data the toggle button which we will use to hide the dropdown
- * @return FALSE
- */
-static gboolean
-namespace_selector_window_leave_timeout_cb (gpointer user_data)
-{
-  GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (user_data);
-
-  /* This will eventually hide the namespace selector */
-  namespace_selector_window_leave_timeout_source = 0;
-  gtk_toggle_button_set_active (toggle_button, FALSE);
-  return FALSE;
-}
-
-
-/**
- * The cursor has left the window.  Place a timeout to hide the
- * window. It will be cancelled if the cursor re-enters the namespace
- * selector window or the toggle button within 100ms
- *
- * @param user_data the context for the main window
- */
-gboolean
-GNUNET_FS_GTK_search_namespace_selector_window_leave_notify_event_cb 
(GtkWidget * widget,
-                                                                     GdkEvent 
* event,
-                                                                     gpointer 
user_data)
-{
-  struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
-
-  if (namespace_selector_window_leave_timeout_source > 0)
-    g_source_remove (namespace_selector_window_leave_timeout_source);
-  namespace_selector_window_leave_timeout_source 
-    = g_timeout_add (AUTO_HIDE_TIMEOUT_MS, 
-                    &namespace_selector_window_leave_timeout_cb,
-                    main_ctx->ns_dropdown_button);
-  return FALSE;
-}
-
-
-/**
- * Given a tree view, find out which row is currently selected.
- * 
- * @param tree a tree view instance
- * @return a reference to the currently selected row, or NULL for none
- */
-static GtkTreeRowReference *
-get_selected_row_from_treeview (GtkTreeView * tree)
-{
-  GtkTreeSelection *sel;
-  GtkTreeModel *model;
-  GtkTreePath *path;
-  GtkTreeIter iter;
-  GtkTreeRowReference *ref;
-
-  sel = gtk_tree_view_get_selection (tree);
-  if (! gtk_tree_selection_get_selected (sel, &model, &iter))
-    return NULL;
-  path = gtk_tree_model_get_path (model, &iter);
-  ref = gtk_tree_row_reference_new (model, path);  
-  gtk_tree_path_free (path);
-  return ref;
-}
-
-
-/**
- * Changes were made to the selected entry in the tree view and the
- * user clicked to confirm.  Hide the drop down and display the
- * selected entry as the new namespace label.
- *
- * @param main_ctx the context for the main window
- * @param tv the tree view that was updated
- */
-static void
-commit_changes (struct GNUNET_GTK_MainWindowContext *main_ctx,
-               GtkTreeView *tv)
-{
-  GtkTreePath *treepath;
-  gchar *value;
-
-  if (NULL != main_ctx->selected_ns_row)
-    gtk_tree_row_reference_free (main_ctx->selected_ns_row);
-  main_ctx->selected_ns_row = get_selected_row_from_treeview (tv);
-
-  treepath = gtk_tree_row_reference_get_path (main_ctx->selected_ns_row);
-  if (GNUNET_GTK_get_tree_string (tv, treepath,
-                                  
GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_NAME,
-                                  &value))
-  {
-    gtk_label_set_text (main_ctx->search_ns_label, (NULL != value) ? value : 
"");
-    g_free (value);
-  }
-  if (GNUNET_GTK_get_tree_string (tv, treepath,
-                                  
GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_ROOT,
-                                  &value))
-  {
-    gtk_entry_set_text (main_ctx->search_entry, (NULL != value) ? value : "");
-    g_free (value);
-  }
-  gtk_tree_path_free (treepath);
-
-  /* hide the namespace selector */
-  gtk_toggle_button_set_active (main_ctx->ns_dropdown_button, FALSE);  
-}
-
-
-/**
- * User pushed the button in the treeview.  Get the selected entry
- * and remember it in the "pushed-rowreference" of the widget.
- * This way, we can use it when the button is released.
- *
- * @param widget the tree view widget
- * @param event the push event
- * @param user_data the context for the main window
- * @return FALSE
- */
-gboolean
-GNUNET_FS_GTK_namespace_selector_treeview_button_press_event_cb (GtkWidget * 
widget,
-                                                                GdkEvent * 
event,
-                                                                gpointer 
user_data)
-{
-  struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
-
-  if (NULL != main_ctx->ns_selector_pushed_row)
-      gtk_tree_row_reference_free (main_ctx->ns_selector_pushed_row);
-  main_ctx->ns_selector_pushed_row = get_selected_row_from_treeview 
(GTK_TREE_VIEW (widget));
-  return FALSE;
-}
-
-
-/**
- * User released the button in the treeview.  Get the selected entry
- * and update the cursor accordingly, but only if the user pushed the
- * button down and released it in the same row.
- *
- * @param widget the tree view widget
- * @param event the release event
- * @param user_data the context for the main window
- * @return FALSE
- */
-gboolean
-GNUNET_FS_GTK_namespace_selector_treeview_button_release_event_cb (GtkWidget * 
widget,
-                                                                  GdkEvent * 
event,
-                                                                  gpointer 
user_data)
-{
-  struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
-  GtkTreeRowReference *ref;
-
-  ref = get_selected_row_from_treeview (GTK_TREE_VIEW (widget));
-  if ( (NULL != ref) && (NULL != main_ctx->ns_selector_pushed_row))
-  {
-    GtkTreePath *path_ref;
-    GtkTreePath *path_old;
-
-    path_ref = gtk_tree_row_reference_get_path (ref);
-    path_old = gtk_tree_row_reference_get_path 
(main_ctx->ns_selector_pushed_row);
-    if (0 == gtk_tree_path_compare (path_ref, path_old))
-      commit_changes (main_ctx, GTK_TREE_VIEW (widget));
-    if (path_ref)
-      gtk_tree_path_free (path_ref);
-    if (path_old)
-      gtk_tree_path_free (path_old);
-  }
-  if (NULL != ref)
-    gtk_tree_row_reference_free (ref);
-  if (NULL != main_ctx->ns_selector_pushed_row)
-    gtk_tree_row_reference_free (main_ctx->ns_selector_pushed_row);
-  main_ctx->ns_selector_pushed_row = NULL;
-  return FALSE;
-}
-
-
-/**
- * The toggle button that changes the visibility of the namespace dropdown
- * list was toggled.
- *
- * @param togglebutton the button that toggles the namespace dropdown list
- * @param user_data the contexxt for the main window
- */
-void
-GNUNET_FS_GTK_search_namespace_dropdown_button_toggled_cb (GtkToggleButton *
-                                                          togglebutton,
-                                                          gpointer user_data)
-{
-  struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
-  gboolean active;
-  GtkAllocation togglebutton_allocation;
-  GdkWindow *main_window_gdk;
-  gint mwg_x;
-  gint mwg_y;
-  gint tgb_x;
-  gint tgb_y;
-  gint popup_x;
-  gint popup_y;
-
-  g_object_get (G_OBJECT (togglebutton), "active", &active, NULL);
-  if (! active)
-  {
-    gtk_widget_hide (main_ctx->ns_selector_window);
-    gtk_widget_grab_focus (GTK_WIDGET (togglebutton));
-    return;
-  }
-  gtk_widget_get_allocation (GTK_WIDGET (togglebutton),
-                            &togglebutton_allocation);
-  main_window_gdk = gtk_widget_get_window (GTK_WIDGET (togglebutton));
-  gdk_window_get_origin (main_window_gdk, &mwg_x, &mwg_y);
-  /* show the window below the button */
-  tgb_x = mwg_x + togglebutton_allocation.x;
-  tgb_y = mwg_y + togglebutton_allocation.y;
-  popup_x = tgb_x;
-  popup_y = tgb_y + togglebutton_allocation.height;  
-  gtk_window_move (GTK_WINDOW (main_ctx->ns_selector_window), popup_x, 
popup_y);
-  gtk_widget_show_all (main_ctx->ns_selector_window);
-  gtk_widget_grab_focus (GTK_WIDGET (main_ctx->ns_selector_treeview));
-}
-
-
-/**
- * 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 struct GNUNET_CRYPTO_EccPublicKey *pseudonym,
-                     const char *name, 
-                    const char *unique_name,
-                     const struct GNUNET_CONTAINER_MetaData *md, 
-                    int rating)
-{
-  GtkTreeStore *ts = cls;
-  char *root;
-  char *ns_name;
-  char *unique_ns_name;
-  struct GNUNET_CRYPTO_EccPublicKey *nsid;
-  char *description;
-  int desc_is_a_dup;
-  char *uris;
-  char *emsg;
-  struct GNUNET_FS_Uri *uri;
-  GtkTreeIter iter;
-
-  if (rating < 0)
-    return GNUNET_OK;
-
-  GNUNET_FS_pseudonym_get_info (GNUNET_FS_GTK_get_configuration (),
-                               pseudonym, NULL, NULL, 
-                               &ns_name, NULL);
-  unique_ns_name = GNUNET_FS_pseudonym_name_uniquify 
(GNUNET_FS_GTK_get_configuration (),
-                                                     pseudonym, ns_name, NULL);
-  GNUNET_free (ns_name);
-  nsid = GNUNET_new (struct GNUNET_CRYPTO_EccPublicKey);
-  *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_FS_GTK_get_description_from_metadata (md, 
&desc_is_a_dup);
-  gtk_tree_store_insert_with_values (ts, &iter, NULL, G_MAXINT,
-                                     
GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_NAME,
-                                     unique_ns_name,
-                                     
GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_KEY,
-                                     nsid,
-                                     
GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_ROOT,
-                                     root,
-                                     
GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_TOOLTIP,
-                                     description,
-                                     -1);
-  GNUNET_free (unique_ns_name);
-  GNUNET_free_non_null (root);
-  GNUNET_free (description);
-  return GNUNET_OK;
-}
-
-
-void
-GNUNET_GTK_main_window_refresh_ns_list (struct GNUNET_GTK_MainWindowContext 
*main_ctx)
-{
-  GtkTreeIter iter;
-  GtkTreePath *treepath;
-  GtkTreeModel *model;
-  struct GNUNET_CRYPTO_EccPublicKey *key;
-  struct GNUNET_CRYPTO_EccPublicKey *selected_ns_id;
-  gboolean found;
-  gchar *value;
-    
-  key = NULL;
-  if (NULL != main_ctx->selected_ns_row)
-  {
-    treepath = gtk_tree_row_reference_get_path (main_ctx->selected_ns_row);
-    model = gtk_tree_view_get_model (main_ctx->ns_selector_treeview);
-    if (gtk_tree_model_get_iter (model, &iter, treepath))
-      gtk_tree_model_get (model, &iter,
-                         GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_KEY,
-                         &key,
-                         -1);
-    gtk_tree_path_free (treepath);
-    gtk_tree_row_reference_free (main_ctx->selected_ns_row);
-    main_ctx->selected_ns_row = NULL;
-  }
-  selected_ns_id = NULL;
-  if (NULL != key)
-  {
-    selected_ns_id = GNUNET_new (struct GNUNET_CRYPTO_EccPublicKey);
-    *selected_ns_id = *key;
-  }
-
-  if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL 
(main_ctx->search_ns_treestore),
-                                    &iter))
-  {
-    do 
-    {
-      gtk_tree_model_get (GTK_TREE_MODEL (main_ctx->search_ns_treestore), 
&iter,
-                          GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_KEY,
-                          &key,
-                          -1);
-      GNUNET_free_non_null (key);
-    } while (gtk_tree_model_iter_next (GTK_TREE_MODEL 
(main_ctx->search_ns_treestore), 
-                                      &iter));
-  }
-  gtk_tree_store_clear (main_ctx->search_ns_treestore);
-  gtk_tree_store_insert_with_values (main_ctx->search_ns_treestore, &iter, 
NULL, G_MAXINT,
-                                     
GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_NAME,
-                                     "Any",
-                                     
GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_KEY,
-                                     NULL,
-                                     
GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_ROOT,
-                                     "",
-                                     
GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_TOOLTIP,
-                                     "Do not search in any particular 
namespace",
-                                     -1);
-
-  if (NULL != main_ctx->ns_discovery_handle)
-    GNUNET_FS_pseudonym_discovery_callback_unregister 
(main_ctx->ns_discovery_handle);
-  main_ctx->ns_discovery_handle 
-    = GNUNET_FS_pseudonym_discovery_callback_register (main_ctx->cfg,
-                                                      &add_namespace_to_ts,
-                                                      
main_ctx->search_ns_treestore);
-
-  found = FALSE;
-  value = NULL;
-  if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL 
(main_ctx->search_ns_treestore), 
-                                    &iter))
-  {
-    while (TRUE)
-    {
-      gtk_tree_model_get (GTK_TREE_MODEL (main_ctx->search_ns_treestore), 
&iter,
-                          GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_NAME,
-                          &value,
-                          GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_KEY,
-                          &key,
-                          -1);
-      if (NULL == selected_ns_id)
-        found = TRUE;
-      if ( (key != NULL) && 
-          (0 == memcmp (key, selected_ns_id, sizeof (struct 
GNUNET_CRYPTO_EccPublicKey))) )
-        found = TRUE;
-      if (found || 
-         (! gtk_tree_model_iter_next (GTK_TREE_MODEL 
(main_ctx->search_ns_treestore), 
-                                      &iter)))
-        break;
-      g_free (value);
-    }
-  }
-  if ( (!found) &&
-       gtk_tree_model_get_iter_first (GTK_TREE_MODEL 
(main_ctx->search_ns_treestore),
-                                     &iter))
-  {
-    gtk_tree_model_get (GTK_TREE_MODEL (main_ctx->search_ns_treestore), &iter,
-                        GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_NAME,
-                        &value,
-                        GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_KEY,
-                        &key,
-                        -1);
-    found = TRUE;
-  }
-  if (found)
-    gtk_tree_selection_select_iter (gtk_tree_view_get_selection
-                                   (main_ctx->ns_selector_treeview), &iter);
-  if (value != NULL)
-  {
-    gtk_label_set_text (main_ctx->search_ns_label, value);
-    g_free (value);
-  }
-  GNUNET_free_non_null (selected_ns_id);
-}
-
-
-/* end of gnunet-fs-gtk_main-window-namespace-dropdown.c */




reply via email to

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