gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r4898 - in gnunet-gtk: . contrib/flags src/plugins/fs


From: gnunet
Subject: [GNUnet-SVN] r4898 - in gnunet-gtk: . contrib/flags src/plugins/fs
Date: Sat, 2 Jun 2007 02:23:58 -0600 (MDT)

Author: grothoff
Date: 2007-06-02 02:23:57 -0600 (Sat, 02 Jun 2007)
New Revision: 4898

Added:
   gnunet-gtk/contrib/flags/convert.sh
   gnunet-gtk/src/plugins/fs/namespace_create.c
Modified:
   gnunet-gtk/TODO
   gnunet-gtk/gnunet-gtk.glade
   gnunet-gtk/src/plugins/fs/Makefile.am
   gnunet-gtk/src/plugins/fs/namespace.c
   gnunet-gtk/src/plugins/fs/namespace.h
Log:
working on making namespace creation dialog pretty

Modified: gnunet-gtk/TODO
===================================================================
--- gnunet-gtk/TODO     2007-06-02 07:25:12 UTC (rev 4897)
+++ gnunet-gtk/TODO     2007-06-02 08:23:57 UTC (rev 4898)
@@ -12,28 +12,25 @@
 
 0.7.2 (goal: re-enable all 0.7.0 features):
 - create custom gtk logger (via memory logger?) [see also #1027]
-
-0.7.2a:
-- re-enable advanced/namespace menus 
+  => currently, "infoMessage" opens a window that cannot be closed
+     and that does not have a frame!!! [RC]
+- re-enable advanced/namespace menus  [RC]
   + namespace creation
-    => currently crashes (in ECRS!)
+    => currently fails (in ECRS!)
   + namespace update
     => FIX implementation!
   + namespace addition
-    => untested
+    => currently fails (in ECRS!)
   + namespace search
     => untested
   + collection creation
-    => need to check!
+    => untested
   + collection abortion
-    => need to check!
-  + show content of current collection
-  + NS-related memory leaks (see #if 0 code in namespace.c)
-  + proper namespace/collection support:
-    * avoid repeatedly calling slow
-      gnunet-gtk iterator (see drupal)
-    * use new namespace APIs
-    * clean, short namespace search URIs
+    => untested
+  + enable "delete" menu item sensitivity when it makes sense!
+    => untested
+  + design and start use of short/nice namespace names/search URIs
+  + show content of current collection (where!?)
 
 
 0.7.3 (goal: polish):
@@ -46,13 +43,15 @@
   pattern that must be matched for the lines to be displayed
   (to further prune search results, for example)
 - gnunet-setup plugin
-- #1045 ability to pause a search
+- #1045 ability to pause a search => requires FSUI changes!
 - announce newly found namespaces to user -- #1040
+- #747 (sharing stats for gnunet-gtk) [RC]
 
 0.7.4 (goal: expand features):
 - chat
 - add option to list all indexed files and delete from them
-  (ECRS now supports listing of indexed files!)
+  (ECRS now supports listing of indexed files! 
+    => but this ECRS functionality may need to be tested!)
 - implement search bookmarking (e.g. user could add/edit/delete
   favourite namespace/key etc combinations)
 - allow tracking of files that have been (successfully/unsuccessfully)

Added: gnunet-gtk/contrib/flags/convert.sh
===================================================================
--- gnunet-gtk/contrib/flags/convert.sh                         (rev 0)
+++ gnunet-gtk/contrib/flags/convert.sh 2007-06-02 08:23:57 UTC (rev 4898)
@@ -0,0 +1,7 @@
+#!/bin/sh
+for n in *.svg
+do
+  echo $n
+  m=`echo $n | sed -e "s/\.svg//"`
+  convert $n -resize 30x20 -strip $m.png
+done


Property changes on: gnunet-gtk/contrib/flags/convert.sh
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:eol-style
   + native

Modified: gnunet-gtk/gnunet-gtk.glade
===================================================================
--- gnunet-gtk/gnunet-gtk.glade 2007-06-02 07:25:12 UTC (rev 4897)
+++ gnunet-gtk/gnunet-gtk.glade 2007-06-02 08:23:57 UTC (rev 4898)
@@ -6068,6 +6068,7 @@
              <property name="has_frame">True</property>
              <property name="invisible_char">*</property>
              <property name="activates_default">False</property>
+             <signal name="changed" 
handler="on_namespaceKeywordEntry_changed_" last_modification_time="Sat, 02 Jun 
2007 08:02:26 GMT"/>
              <accelerator key="Return" modifiers="0" signal="activate"/>
            </widget>
            <packing>
@@ -6078,8 +6079,9 @@
          </child>
 
          <child>
-           <widget class="GtkButton" id="button6">
+           <widget class="GtkButton" id="nsMetaDataDialogKeywordAddButton">
              <property name="visible">True</property>
+             <property name="sensitive">False</property>
              <property name="tooltip" translatable="yes">Add the given keyword 
to the list of keywords under which advertisements for the namespace will be 
published.</property>
              <property name="can_focus">True</property>
              <property name="label">gtk-add</property>
@@ -6094,6 +6096,26 @@
              <property name="fill">False</property>
            </packing>
          </child>
+
+         <child>
+           <widget class="GtkButton" id="nsMetaDataDialogKeywordRemoveButton">
+             <property name="border_width">2</property>
+             <property name="visible">True</property>
+             <property name="sensitive">False</property>
+             <property name="tooltip" translatable="yes">Add the given keyword 
to the list of keywords under which advertisements for the namespace will be 
published.</property>
+             <property name="can_focus">True</property>
+             <property name="label">gtk-remove</property>
+             <property name="use_stock">True</property>
+             <property name="relief">GTK_RELIEF_NORMAL</property>
+             <property name="focus_on_click">True</property>
+             <signal name="clicked" 
handler="on_namespacemetaDataDialogKeywordRemoveButton_clicked_" 
last_modification_time="Sat, 02 Jun 2007 07:57:57 GMT"/>
+           </widget>
+           <packing>
+             <property name="padding">0</property>
+             <property name="expand">False</property>
+             <property name="fill">False</property>
+           </packing>
+         </child>
        </widget>
        <packing>
          <property name="padding">0</property>
@@ -6249,6 +6271,7 @@
              <property name="has_frame">True</property>
              <property name="invisible_char">*</property>
              <property name="activates_default">False</property>
+             <signal name="changed" 
handler="on_namespaceMetaDataValueEntry_changed_" last_modification_time="Sat, 
02 Jun 2007 08:02:00 GMT"/>
              <accelerator key="Return" modifiers="0" signal="activate"/>
            </widget>
            <packing>
@@ -6259,8 +6282,9 @@
          </child>
 
          <child>
-           <widget class="GtkButton" id="button7">
+           <widget class="GtkButton" id="nsMetaDataDialogMetaDataAddButton">
              <property name="visible">True</property>
+             <property name="sensitive">False</property>
              <property name="tooltip" translatable="yes">Add the given 
metadata entry to the metadata for this namespace.</property>
              <property name="can_focus">True</property>
              <property name="label">gtk-add</property>
@@ -6275,6 +6299,25 @@
              <property name="fill">False</property>
            </packing>
          </child>
+
+         <child>
+           <widget class="GtkButton" id="nsMetaDataDialogMetaDataRemoveButton">
+             <property name="visible">True</property>
+             <property name="sensitive">False</property>
+             <property name="tooltip" translatable="yes">Add the given 
metadata entry to the metadata for this namespace.</property>
+             <property name="can_focus">True</property>
+             <property name="label">gtk-remove</property>
+             <property name="use_stock">True</property>
+             <property name="relief">GTK_RELIEF_NORMAL</property>
+             <property name="focus_on_click">True</property>
+             <signal name="clicked" 
handler="on_namespacemetaDataDialogMetaDataRemoveButton_clicked_" 
last_modification_time="Sat, 02 Jun 2007 07:59:21 GMT"/>
+           </widget>
+           <packing>
+             <property name="padding">0</property>
+             <property name="expand">False</property>
+             <property name="fill">False</property>
+           </packing>
+         </child>
        </widget>
        <packing>
          <property name="padding">5</property>

Modified: gnunet-gtk/src/plugins/fs/Makefile.am
===================================================================
--- gnunet-gtk/src/plugins/fs/Makefile.am       2007-06-02 07:25:12 UTC (rev 
4897)
+++ gnunet-gtk/src/plugins/fs/Makefile.am       2007-06-02 08:23:57 UTC (rev 
4898)
@@ -17,6 +17,7 @@
   helper.c helper.h \
   meta.c meta.h \
   namespace.c namespace.h \
+  namespace_create.c \
   namespace_search.c \
   search.c search.h \
   download.c download.h \

Modified: gnunet-gtk/src/plugins/fs/namespace.c
===================================================================
--- gnunet-gtk/src/plugins/fs/namespace.c       2007-06-02 07:25:12 UTC (rev 
4897)
+++ gnunet-gtk/src/plugins/fs/namespace.c       2007-06-02 08:23:57 UTC (rev 
4898)
@@ -20,7 +20,7 @@
 
 /**
  * @file src/plugins/fs/namespace.c
- * @brief operations creating/deleting and adding to/updating namespaces
+ * @brief operations for deleting and adding to/updating namespaces
  * @author Christian Grothoff
  */
 
@@ -51,13 +51,61 @@
   struct ECRS_MetaData * meta;
 } NamespaceList;
 
+/**
+ * Content selection in main list of available content.
+ */
 static GtkTreeSelection * content_selection;
 
 static NamespaceList * head;
 
 static GladeXML * metaXML;
 
-void makeNamespaceFrame(NamespaceList * entry) {
+/**
+ * The user has changed the selection either in the
+ * namespace content list or the global content list.
+ * Update search button status values (add/change).
+ */
+static void on_namespaceContentSelectionChanged(gpointer signal,
+                                               gpointer cls) {
+  NamespaceList * list = head;
+  int count;
+  int ncount;
+  GtkTreeSelection * ns;
+  GtkTreeIter iter;
+  char * freq;
+  int ok;
+
+  count = gtk_tree_selection_count_selected_rows(content_selection);
+  while (list != NULL) {
+    ns = gtk_tree_view_get_selection(GTK_TREE_VIEW(list->treeview));
+    ncount = gtk_tree_selection_count_selected_rows(ns);
+    gtk_widget_set_sensitive(list->addButton,
+                            count > 0);
+    /* now check if update is legal */
+    ok = 0;
+    if ( (count == 1) &&
+        (ncount == 1) &&
+        (TRUE == gtk_tree_selection_get_selected(ns,
+                                                 NULL,
+                                                 &iter)) ) {
+      
+      gtk_tree_model_get(list->model,
+                        &iter,
+                        IN_NAMESPACE_PUB_FREQ_STRING, &freq,
+                        -1);
+      if ( (freq != NULL) &&
+          (0 != strcmp(freq, _("never"))) )
+       ok = 1;
+      FREENONNULL(freq);
+    }     
+    gtk_widget_set_sensitive(list->updateButton,
+                            ok);
+    list = list->next;
+  }
+}
+
+
+static void makeNamespaceFrame(NamespaceList * entry) {
   GtkWidget * child;
   GtkWidget * resultList;
   GtkCellRenderer * renderer;
@@ -79,7 +127,7 @@
   entry->addButton = glade_xml_get_widget(namespaceXML,
                                          "addButton");
   entry->updateButton = glade_xml_get_widget(namespaceXML,
-                                            "updateButton");
+                                            "namespaceUpdateButton");
   entry->treeview = GTK_WIDGET(GTK_TREE_VIEW(resultList));
   model =
     gtk_list_store_new(IN_NAMESPACE_NUM,
@@ -98,7 +146,13 @@
   gtk_tree_view_set_model(GTK_TREE_VIEW(resultList),
                          GTK_TREE_MODEL(model));
   
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(resultList)),
-                             GTK_SELECTION_MULTIPLE);
+                             GTK_SELECTION_SINGLE);
+  g_signal_connect_data(content_selection,
+                       "changed",
+                       G_CALLBACK(&on_namespaceContentSelectionChanged),
+                       NULL,
+                       NULL,
+                       0);
 
 
 
@@ -356,32 +410,17 @@
 }
 
 /**
- * The user has edited the search entry.
- * Update search button status.
- */
-static void on_namespaceContentSelectionChanged(gpointer signal,
-                                               gpointer cls) {
-  NamespaceList * list = head;
-
-  while (list != NULL) {
-    gtk_widget_set_sensitive(list->addButton,
-                            
gtk_tree_selection_count_selected_rows(content_selection) > 0);
-    list = list->next;
-  }
-}
-
-
-/**
  * Add a tab for the given namespace.
  */
-static int addTabForNamespace(void * unused,
-                             const char * namespaceName,
-                             const HashCode512 * namespaceId,
-                             const struct ECRS_MetaData * md,
-                             int rating) {
+int addTabForNamespace(void * unused,
+                      const char * namespaceName,
+                      const HashCode512 * namespaceId,
+                      const struct ECRS_MetaData * md,
+                      int rating) {
   NamespaceList * list;
   GtkWidget * label;
   GtkWidget * notebook;
+  GtkWidget * del_menu;
 
   DEBUG_BEGIN();
   label = gtk_label_new(namespaceName);
@@ -409,120 +448,16 @@
      &addNamespaceContentToModel,
      list->model);
   DEBUG_END();
+  /* enable "delete" menu entry */
+
+  del_menu = glade_xml_get_widget(getMainXML(),
+                                 "namespaceDelete");
+  gtk_widget_set_sensitive(del_menu,
+                          TRUE);
   return OK;
 }
 
-void on_namespacemetaDataDialogKeywordAddButton_clicked_fs(gpointer dummy,
-                                                          GtkWidget * 
uploadButton) {
-  handleKeywordListUpdate(metaXML,
-                         "namespaceKeywordEntry",
-                         "namespaceMetaDataDialogKeywordList");
-}
 
-void on_namespacemetaDataDialogMetaDataAddButton_clicked_fs(gpointer dummy,
-                                                           GtkWidget * 
uploadButton) {
-  handleMetaDataListUpdate(metaXML,
-                          "namespaceMetaDataDialogMetaTypeComboBox",
-                          "namespaceMetaDataValueEntry",
-                          "namespaceMetaDataDialogMetaDataList");
-}
-
-void create_namespace_clicked_fs(GtkWidget * dummy1,
-                                GtkWidget * dummy2) {
-  const char * namespaceName;
-  GtkWidget * nameLine;
-  GtkWidget * dialog;
-  GtkWidget * spin;
-  struct ECRS_MetaData * meta;
-  struct ECRS_URI * keywordURI;
-  struct ECRS_URI * root;
-  HashCode512 namespaceId;
-  HashCode512 rootEntry;
-
-  DEBUG_BEGIN();
-  metaXML
-    = glade_xml_new(getGladeFileName(),
-                   "namespaceMetaDataDialog",
-                   PACKAGE_NAME);
-  connectGladeWithPlugins(metaXML);
-  dialog = glade_xml_get_widget(metaXML,
-                               "namespaceMetaDataDialog");
-  createMetaDataListTreeView(metaXML,                  
-                            "namespaceMetaDataDialogMetaDataList",
-                            NULL,
-                            NULL);
-  createKeywordListTreeView(metaXML,
-                           "namespaceMetaDataDialogKeywordList",
-                           NULL);
-  createMetaTypeComboBox(metaXML,                      
-                        "namespaceMetaDataDialogMetaTypeComboBox");
-  gtk_dialog_set_default_response(GTK_DIALOG(dialog),
-                                 GTK_RESPONSE_OK);
-  if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
-    meta
-      = getMetaDataFromList(metaXML,
-                           "namespaceMetaDataDialogMetaDataList",
-                           NULL);
-    keywordURI
-      = getKeywordURIFromList(metaXML,
-                             "namespaceMetaDataDialogKeywordList");
-    spin = glade_xml_get_widget(metaXML,
-                               "namespaceAnonymityspinbutton");
-    nameLine = glade_xml_get_widget(metaXML,
-                                   "namespaceRootEntry");
-    namespaceName = gtk_entry_get_text(GTK_ENTRY(nameLine));
-    if (namespaceName == NULL)
-      namespaceName = "root"; /* do NOT translate "root"! */
-    hash(namespaceName,
-        strlen(namespaceName),
-        &rootEntry);
-    nameLine = glade_xml_get_widget(metaXML,
-                                   "namespaceNameEntry");
-    namespaceName = gtk_entry_get_text(GTK_ENTRY(nameLine));
-    root = NS_createNamespace(ectx,
-                             cfg,
-                             gtk_spin_button_get_value_as_int
-                             (GTK_SPIN_BUTTON(spin)),
-                             1000, /* FIXME: priority */
-                             999999, /* FIXME: expiration */
-                             namespaceName,
-                               meta,
-                               keywordURI,
-                               &rootEntry);
-    if (root != NULL) {
-      ECRS_getNamespaceId(root,
-                         &namespaceId);
-      addTabForNamespace(NULL,
-                        namespaceName,
-                        &namespaceId,
-                        meta,
-                        0);
-      ECRS_freeUri(root);
-    } else {
-      GtkWidget * dialog;
-
-      dialog = gtk_message_dialog_new
-       (NULL,
-        GTK_DIALOG_MODAL,
-        GTK_MESSAGE_ERROR,
-        GTK_BUTTONS_CLOSE,
-        _("Failed to create namespace `%s'."
-          "Consult logs, most likely error is"
-          " that a namespace with that name "
-          "already exists."),
-        namespaceName);
-      gtk_dialog_run(GTK_DIALOG(dialog));
-      gtk_widget_destroy(dialog);
-    }
-    ECRS_freeMetaData(meta);
-    ECRS_freeUri(keywordURI);
-  }
-  gtk_widget_destroy(dialog);
-  UNREF(metaXML);
-  metaXML = NULL;
-  DEBUG_END();
-}
-
 void namespaceDelete_clicked_fs(GtkWidget * dummy1,
                                GtkWidget * dummy2) {
   GtkWidget * notebook;
@@ -587,6 +522,7 @@
   NS_deleteNamespace(ectx,
                     cfg,
                     list->name);
+
   DEBUG_END();
 }
 
@@ -603,10 +539,10 @@
  * Publish the selected file in the
  * selected namespace.
  */
-static void initiateUpload(GtkTreeModel * model,
-                          GtkTreePath * path,
-                          GtkTreeIter * iter,
-                          gpointer data) {
+static void addToNamespaceCB(GtkTreeModel * model,
+                            GtkTreePath * path,
+                            GtkTreeIter * iter,
+                            gpointer data) {
   IUC * cls = data;
   struct ECRS_URI * resultURI;
   struct ECRS_URI * dst;
@@ -761,7 +697,7 @@
     }
     ggc_tree_selection_selected_foreach
       (content_selection,
-       &initiateUpload,
+       &addToNamespaceCB,
        &cls);
   }
   gtk_widget_destroy(dialog);
@@ -929,7 +865,7 @@
 
     ggc_tree_selection_selected_foreach
       (selection,
-       &initiateUpload,
+       &addToNamespaceCB,
        &cls);
   }
   gtk_widget_destroy(dialog);
@@ -1058,7 +994,10 @@
   NamespaceList * prev;
   NamespaceList * pos;
   NamespaceList * next;
+  GtkWidget * del_menu;
 
+  fprintf(stderr,
+         "DESTROYING!\n");
   pos = head;
   while (pos != NULL) {
     next = pos->next;
@@ -1098,12 +1037,17 @@
                                      &iter));
   }
   FREE(pos);
+  fprintf(stderr,
+         "DESTROYED %p!\n", head);
+  del_menu = glade_xml_get_widget(getMainXML(),
+                                 "namespaceDelete");
+  gtk_widget_set_sensitive(del_menu,
+                          head != NULL);
 }
 
 void fs_namespace_stop() {
   URITRACK_unregisterTrackCallback(&updateViewSave,
                                   NULL);
-  /* FIXME: free resources! */
 }
 
 /* end of namespace.c */

Modified: gnunet-gtk/src/plugins/fs/namespace.h
===================================================================
--- gnunet-gtk/src/plugins/fs/namespace.h       2007-06-02 07:25:12 UTC (rev 
4897)
+++ gnunet-gtk/src/plugins/fs/namespace.h       2007-06-02 08:23:57 UTC (rev 
4898)
@@ -27,6 +27,16 @@
 #ifndef GTK_NAMESPACE_H
 #define GTK_NAMESPACE_H
 
+/**
+ * Add a tab for the given namespace.
+ */
+int addTabForNamespace(void * unused,
+                      const char * namespaceName,
+                      const HashCode512 * namespaceId,
+                      const struct ECRS_MetaData * md,
+                      int rating);
+
+
 void fs_namespace_start(void);
 
 void fs_namespace_stop(void);

Added: gnunet-gtk/src/plugins/fs/namespace_create.c
===================================================================
--- gnunet-gtk/src/plugins/fs/namespace_create.c                                
(rev 0)
+++ gnunet-gtk/src/plugins/fs/namespace_create.c        2007-06-02 08:23:57 UTC 
(rev 4898)
@@ -0,0 +1,260 @@
+/*
+     This file is part of GNUnet.
+     (C) 2005, 2006, 2007 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/plugins/fs/namespace.c
+ * @brief operations creating namespaces
+ * @author Christian Grothoff
+ */
+
+#include "platform.h"
+#include "gnunetgtk_common.h"
+#include "fs.h"
+#include "helper.h"
+#include "meta.h"
+#include "namespace.h"
+#include "content_tracking.h"
+#include <GNUnet/gnunet_util_crypto.h>
+#include <GNUnet/gnunet_uritrack_lib.h>
+#include <GNUnet/gnunet_namespace_lib.h>
+#include <extractor.h>
+
+
+static GladeXML * metaXML;
+
+
+void on_namespacemetaDataDialogKeywordRemoveButton_clicked_fs(gpointer dummy,
+                                                             GtkWidget * 
uploadButton) {
+  handleListRemove(metaXML,
+                  "namespaceMetaDataDialogKeywordList");
+}
+
+void on_namespacemetaDataDialogMetaDataRemoveButton_clicked_fs(gpointer dummy,
+                                                              GtkWidget * 
uploadButton) {
+  handleListRemove(metaXML,
+                  "namespaceMetaDataDialogMetaDataList");
+}
+
+void on_namespacemetaDataDialogKeywordAddButton_clicked_fs(gpointer dummy,
+                                                          GtkWidget * 
uploadButton) {
+  handleKeywordListUpdate(metaXML,
+                         "namespaceKeywordEntry",
+                         "namespaceMetaDataDialogKeywordList");
+}
+
+void on_namespacemetaDataDialogMetaDataAddButton_clicked_fs(gpointer dummy,
+                                                           GtkWidget * 
uploadButton) {
+  handleMetaDataListUpdate(metaXML,
+                          "namespaceMetaDataDialogMetaTypeComboBox",
+                          "namespaceMetaDataValueEntry",
+                          "namespaceMetaDataDialogMetaDataList");
+}
+
+/**
+ * The selection of the keyword list changed.
+ * Update button status.
+ */
+static void on_keyword_list_selection_changed(gpointer signal,
+                                             gpointer cls) {
+  GtkTreeSelection * selection;
+  GtkWidget * button;
+
+  selection = 
gtk_tree_view_get_selection(GTK_TREE_VIEW(glade_xml_get_widget(metaXML,
+                                                                            
"namespaceMetaDataDialogKeywordList")));
+  button
+    = glade_xml_get_widget(metaXML,
+                          "nsMetaDataDialogKeywordRemoveButton");
+  gtk_widget_set_sensitive(button,
+                          gtk_tree_selection_count_selected_rows(selection) > 
0);
+}
+
+/**
+ * The selection of the metadata list changed.
+ * Update button status.
+ */
+static void on_metadata_list_selection_changed(gpointer signal,
+                                              gpointer cls) {
+  GtkTreeSelection * selection;
+  GtkWidget * button;
+
+  selection = 
gtk_tree_view_get_selection(GTK_TREE_VIEW(glade_xml_get_widget(metaXML,
+                                                                            
"namespaceMetaDataDialogMetaDataList")));
+  button
+    = glade_xml_get_widget(metaXML,
+                          "nsMetaDataDialogMetaDataRemoveButton");
+  gtk_widget_set_sensitive(button,
+                          gtk_tree_selection_count_selected_rows(selection) > 
0);
+}
+
+/**
+ * The user has edited the metadata entry.
+ * Update add button status.
+ */
+void on_namespaceMetaDataValueEntry_changed_fs(gpointer dummy2,
+                                              GtkWidget * searchEntry) {
+  const char * input;
+  GtkWidget * button;
+
+  input = gtk_entry_get_text(GTK_ENTRY(glade_xml_get_widget(metaXML,
+                                                           
"namespaceMetaDataValueEntry")));
+  if (input == NULL)
+    return;
+  button
+    = glade_xml_get_widget(metaXML,
+                          "nsMetaDataDialogMetaDataAddButton");
+  gtk_widget_set_sensitive(button,
+                          strlen(input) > 0);
+}
+
+/**
+ * The user has edited the keyword entry.
+ * Update add button status.
+ */
+void on_namespaceKeywordEntry_changed_fs(gpointer dummy2,
+                                              GtkWidget * searchEntry) {
+  const char * input;
+  GtkWidget * button;
+
+  input = gtk_entry_get_text(GTK_ENTRY(glade_xml_get_widget(metaXML,
+                                                           
"namespaceKeywordEntry")));
+  if (input == NULL)
+    return;
+  button
+    = glade_xml_get_widget(metaXML,
+                          "nsMetaDataDialogKeywordAddButton");
+  gtk_widget_set_sensitive(button,
+                          strlen(input) > 0);
+}
+
+
+void create_namespace_clicked_fs(GtkWidget * dummy1,
+                                GtkWidget * dummy2) {
+  const char * namespaceName;
+  GtkWidget * nameLine;
+  GtkWidget * dialog;
+  GtkWidget * spin;
+  struct ECRS_MetaData * meta;
+  struct ECRS_URI * keywordURI;
+  struct ECRS_URI * root;
+  HashCode512 namespaceId;
+  HashCode512 rootEntry;
+
+  DEBUG_BEGIN();
+  metaXML
+    = glade_xml_new(getGladeFileName(),
+                   "namespaceMetaDataDialog",
+                   PACKAGE_NAME);
+  connectGladeWithPlugins(metaXML);
+  dialog = glade_xml_get_widget(metaXML,
+                               "namespaceMetaDataDialog");
+  createMetaDataListTreeView(metaXML,                  
+                            "namespaceMetaDataDialogMetaDataList",
+                            NULL,
+                            NULL);
+  
g_signal_connect_data(gtk_tree_view_get_selection(GTK_TREE_VIEW(glade_xml_get_widget(metaXML,
+                                                                               
       "namespaceMetaDataDialogMetaDataList"))),
+                       "changed",
+                       G_CALLBACK(&on_metadata_list_selection_changed),
+                       NULL,
+                       NULL,
+                       0);
+  createKeywordListTreeView(metaXML,
+                           "namespaceMetaDataDialogKeywordList",
+                           NULL);
+  
g_signal_connect_data(gtk_tree_view_get_selection(GTK_TREE_VIEW(glade_xml_get_widget(metaXML,
+                                                                               
       "namespaceMetaDataDialogKeywordList"))),
+                       "changed",
+                       G_CALLBACK(&on_keyword_list_selection_changed),
+                       NULL,
+                       NULL,
+                       0);
+
+  createMetaTypeComboBox(metaXML,                      
+                        "namespaceMetaDataDialogMetaTypeComboBox");
+  gtk_dialog_set_default_response(GTK_DIALOG(dialog),
+                                 GTK_RESPONSE_OK);
+  if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
+    meta
+      = getMetaDataFromList(metaXML,
+                           "namespaceMetaDataDialogMetaDataList",
+                           NULL);
+    keywordURI
+      = getKeywordURIFromList(metaXML,
+                             "namespaceMetaDataDialogKeywordList");
+    spin = glade_xml_get_widget(metaXML,
+                               "namespaceAnonymityspinbutton");
+    nameLine = glade_xml_get_widget(metaXML,
+                                   "namespaceRootEntry");
+    namespaceName = gtk_entry_get_text(GTK_ENTRY(nameLine));
+    if (namespaceName == NULL)
+      namespaceName = "root"; /* do NOT translate "root"! */
+    hash(namespaceName,
+        strlen(namespaceName),
+        &rootEntry);
+    nameLine = glade_xml_get_widget(metaXML,
+                                   "namespaceNameEntry");
+    namespaceName = gtk_entry_get_text(GTK_ENTRY(nameLine));
+    root = NS_createNamespace(ectx,
+                             cfg,
+                             gtk_spin_button_get_value_as_int
+                             (GTK_SPIN_BUTTON(spin)),
+                             1000, /* FIXME: priority */
+                             999999, /* FIXME: expiration */
+                             namespaceName,
+                               meta,
+                               keywordURI,
+                               &rootEntry);
+    if (root != NULL) {
+      ECRS_getNamespaceId(root,
+                         &namespaceId);
+      addTabForNamespace(NULL,
+                        namespaceName,
+                        &namespaceId,
+                        meta,
+                        0);
+      ECRS_freeUri(root);
+    } else {
+      GtkWidget * dialog;
+
+      /* IMPROVE-ME: we could check if the
+        namespace exists as the user
+        enters its name and disable the
+        "Ok" button unless the name is unique */
+      dialog = gtk_message_dialog_new
+       (NULL,
+        GTK_DIALOG_MODAL,
+        GTK_MESSAGE_ERROR,
+        GTK_BUTTONS_CLOSE,
+        _("Failed to create namespace `%s'."
+          "Consult logs, most likely error is"
+          " that a namespace with that name "
+          "already exists."),
+        namespaceName);
+      gtk_dialog_run(GTK_DIALOG(dialog));
+      gtk_widget_destroy(dialog);
+    }
+    ECRS_freeMetaData(meta);
+    ECRS_freeUri(keywordURI);
+  }
+  gtk_widget_destroy(dialog);
+  UNREF(metaXML);
+  metaXML = NULL;
+  DEBUG_END();
+}


Property changes on: gnunet-gtk/src/plugins/fs/namespace_create.c
___________________________________________________________________
Name: svn:eol-style
   + native





reply via email to

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