aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2007-06-02 08:23:57 +0000
committerChristian Grothoff <christian@grothoff.org>2007-06-02 08:23:57 +0000
commitdfe7268d67ddb0018cf8823997e8e4a79d064e27 (patch)
treec5531384ec993de0f84380d3e93338ab6ea3fdde
parentdf417bcdb3b22bae7e1fd60714b00594d6f0dfb7 (diff)
downloadgnunet-gtk-dfe7268d67ddb0018cf8823997e8e4a79d064e27.tar.gz
gnunet-gtk-dfe7268d67ddb0018cf8823997e8e4a79d064e27.zip
working on making namespace creation dialog pretty
-rw-r--r--TODO31
-rwxr-xr-xcontrib/flags/convert.sh7
-rw-r--r--gnunet-gtk.glade47
-rw-r--r--src/plugins/fs/Makefile.am1
-rw-r--r--src/plugins/fs/namespace.c228
-rw-r--r--src/plugins/fs/namespace.h10
-rw-r--r--src/plugins/fs/namespace_create.c260
7 files changed, 424 insertions, 160 deletions
diff --git a/TODO b/TODO
index 28dbbbe2..8c9158c2 100644
--- a/TODO
+++ b/TODO
@@ -12,28 +12,25 @@ Notes:
12 12
130.7.2 (goal: re-enable all 0.7.0 features): 130.7.2 (goal: re-enable all 0.7.0 features):
14- create custom gtk logger (via memory logger?) [see also #1027] 14- create custom gtk logger (via memory logger?) [see also #1027]
15 15 => currently, "infoMessage" opens a window that cannot be closed
160.7.2a: 16 and that does not have a frame!!! [RC]
17- re-enable advanced/namespace menus 17- re-enable advanced/namespace menus [RC]
18 + namespace creation 18 + namespace creation
19 => currently crashes (in ECRS!) 19 => currently fails (in ECRS!)
20 + namespace update 20 + namespace update
21 => FIX implementation! 21 => FIX implementation!
22 + namespace addition 22 + namespace addition
23 => untested 23 => currently fails (in ECRS!)
24 + namespace search 24 + namespace search
25 => untested 25 => untested
26 + collection creation 26 + collection creation
27 => need to check! 27 => untested
28 + collection abortion 28 + collection abortion
29 => need to check! 29 => untested
30 + show content of current collection 30 + enable "delete" menu item sensitivity when it makes sense!
31 + NS-related memory leaks (see #if 0 code in namespace.c) 31 => untested
32 + proper namespace/collection support: 32 + design and start use of short/nice namespace names/search URIs
33 * avoid repeatedly calling slow 33 + show content of current collection (where!?)
34 gnunet-gtk iterator (see drupal)
35 * use new namespace APIs
36 * clean, short namespace search URIs
37 34
38 35
390.7.3 (goal: polish): 360.7.3 (goal: polish):
@@ -46,13 +43,15 @@ Notes:
46 pattern that must be matched for the lines to be displayed 43 pattern that must be matched for the lines to be displayed
47 (to further prune search results, for example) 44 (to further prune search results, for example)
48- gnunet-setup plugin 45- gnunet-setup plugin
49- #1045 ability to pause a search 46- #1045 ability to pause a search => requires FSUI changes!
50- announce newly found namespaces to user -- #1040 47- announce newly found namespaces to user -- #1040
48- #747 (sharing stats for gnunet-gtk) [RC]
51 49
520.7.4 (goal: expand features): 500.7.4 (goal: expand features):
53- chat 51- chat
54- add option to list all indexed files and delete from them 52- add option to list all indexed files and delete from them
55 (ECRS now supports listing of indexed files!) 53 (ECRS now supports listing of indexed files!
54 => but this ECRS functionality may need to be tested!)
56- implement search bookmarking (e.g. user could add/edit/delete 55- implement search bookmarking (e.g. user could add/edit/delete
57 favourite namespace/key etc combinations) 56 favourite namespace/key etc combinations)
58- allow tracking of files that have been (successfully/unsuccessfully) 57- allow tracking of files that have been (successfully/unsuccessfully)
diff --git a/contrib/flags/convert.sh b/contrib/flags/convert.sh
new file mode 100755
index 00000000..027033f0
--- /dev/null
+++ b/contrib/flags/convert.sh
@@ -0,0 +1,7 @@
1#!/bin/sh
2for n in *.svg
3do
4 echo $n
5 m=`echo $n | sed -e "s/\.svg//"`
6 convert $n -resize 30x20 -strip $m.png
7done
diff --git a/gnunet-gtk.glade b/gnunet-gtk.glade
index b79c452b..96b0de5c 100644
--- a/gnunet-gtk.glade
+++ b/gnunet-gtk.glade
@@ -6068,6 +6068,7 @@ Daniel Nylander &lt;po@danielnylander.se&gt;
6068 <property name="has_frame">True</property> 6068 <property name="has_frame">True</property>
6069 <property name="invisible_char">*</property> 6069 <property name="invisible_char">*</property>
6070 <property name="activates_default">False</property> 6070 <property name="activates_default">False</property>
6071 <signal name="changed" handler="on_namespaceKeywordEntry_changed_" last_modification_time="Sat, 02 Jun 2007 08:02:26 GMT"/>
6071 <accelerator key="Return" modifiers="0" signal="activate"/> 6072 <accelerator key="Return" modifiers="0" signal="activate"/>
6072 </widget> 6073 </widget>
6073 <packing> 6074 <packing>
@@ -6078,8 +6079,9 @@ Daniel Nylander &lt;po@danielnylander.se&gt;
6078 </child> 6079 </child>
6079 6080
6080 <child> 6081 <child>
6081 <widget class="GtkButton" id="button6"> 6082 <widget class="GtkButton" id="nsMetaDataDialogKeywordAddButton">
6082 <property name="visible">True</property> 6083 <property name="visible">True</property>
6084 <property name="sensitive">False</property>
6083 <property name="tooltip" translatable="yes">Add the given keyword to the list of keywords under which advertisements for the namespace will be published.</property> 6085 <property name="tooltip" translatable="yes">Add the given keyword to the list of keywords under which advertisements for the namespace will be published.</property>
6084 <property name="can_focus">True</property> 6086 <property name="can_focus">True</property>
6085 <property name="label">gtk-add</property> 6087 <property name="label">gtk-add</property>
@@ -6094,6 +6096,26 @@ Daniel Nylander &lt;po@danielnylander.se&gt;
6094 <property name="fill">False</property> 6096 <property name="fill">False</property>
6095 </packing> 6097 </packing>
6096 </child> 6098 </child>
6099
6100 <child>
6101 <widget class="GtkButton" id="nsMetaDataDialogKeywordRemoveButton">
6102 <property name="border_width">2</property>
6103 <property name="visible">True</property>
6104 <property name="sensitive">False</property>
6105 <property name="tooltip" translatable="yes">Add the given keyword to the list of keywords under which advertisements for the namespace will be published.</property>
6106 <property name="can_focus">True</property>
6107 <property name="label">gtk-remove</property>
6108 <property name="use_stock">True</property>
6109 <property name="relief">GTK_RELIEF_NORMAL</property>
6110 <property name="focus_on_click">True</property>
6111 <signal name="clicked" handler="on_namespacemetaDataDialogKeywordRemoveButton_clicked_" last_modification_time="Sat, 02 Jun 2007 07:57:57 GMT"/>
6112 </widget>
6113 <packing>
6114 <property name="padding">0</property>
6115 <property name="expand">False</property>
6116 <property name="fill">False</property>
6117 </packing>
6118 </child>
6097 </widget> 6119 </widget>
6098 <packing> 6120 <packing>
6099 <property name="padding">0</property> 6121 <property name="padding">0</property>
@@ -6249,6 +6271,7 @@ Daniel Nylander &lt;po@danielnylander.se&gt;
6249 <property name="has_frame">True</property> 6271 <property name="has_frame">True</property>
6250 <property name="invisible_char">*</property> 6272 <property name="invisible_char">*</property>
6251 <property name="activates_default">False</property> 6273 <property name="activates_default">False</property>
6274 <signal name="changed" handler="on_namespaceMetaDataValueEntry_changed_" last_modification_time="Sat, 02 Jun 2007 08:02:00 GMT"/>
6252 <accelerator key="Return" modifiers="0" signal="activate"/> 6275 <accelerator key="Return" modifiers="0" signal="activate"/>
6253 </widget> 6276 </widget>
6254 <packing> 6277 <packing>
@@ -6259,8 +6282,9 @@ Daniel Nylander &lt;po@danielnylander.se&gt;
6259 </child> 6282 </child>
6260 6283
6261 <child> 6284 <child>
6262 <widget class="GtkButton" id="button7"> 6285 <widget class="GtkButton" id="nsMetaDataDialogMetaDataAddButton">
6263 <property name="visible">True</property> 6286 <property name="visible">True</property>
6287 <property name="sensitive">False</property>
6264 <property name="tooltip" translatable="yes">Add the given metadata entry to the metadata for this namespace.</property> 6288 <property name="tooltip" translatable="yes">Add the given metadata entry to the metadata for this namespace.</property>
6265 <property name="can_focus">True</property> 6289 <property name="can_focus">True</property>
6266 <property name="label">gtk-add</property> 6290 <property name="label">gtk-add</property>
@@ -6275,6 +6299,25 @@ Daniel Nylander &lt;po@danielnylander.se&gt;
6275 <property name="fill">False</property> 6299 <property name="fill">False</property>
6276 </packing> 6300 </packing>
6277 </child> 6301 </child>
6302
6303 <child>
6304 <widget class="GtkButton" id="nsMetaDataDialogMetaDataRemoveButton">
6305 <property name="visible">True</property>
6306 <property name="sensitive">False</property>
6307 <property name="tooltip" translatable="yes">Add the given metadata entry to the metadata for this namespace.</property>
6308 <property name="can_focus">True</property>
6309 <property name="label">gtk-remove</property>
6310 <property name="use_stock">True</property>
6311 <property name="relief">GTK_RELIEF_NORMAL</property>
6312 <property name="focus_on_click">True</property>
6313 <signal name="clicked" handler="on_namespacemetaDataDialogMetaDataRemoveButton_clicked_" last_modification_time="Sat, 02 Jun 2007 07:59:21 GMT"/>
6314 </widget>
6315 <packing>
6316 <property name="padding">0</property>
6317 <property name="expand">False</property>
6318 <property name="fill">False</property>
6319 </packing>
6320 </child>
6278 </widget> 6321 </widget>
6279 <packing> 6322 <packing>
6280 <property name="padding">5</property> 6323 <property name="padding">5</property>
diff --git a/src/plugins/fs/Makefile.am b/src/plugins/fs/Makefile.am
index 7e3b4dfe..b29d3115 100644
--- a/src/plugins/fs/Makefile.am
+++ b/src/plugins/fs/Makefile.am
@@ -17,6 +17,7 @@ libgnunetgtkmodule_fs_la_SOURCES = \
17 helper.c helper.h \ 17 helper.c helper.h \
18 meta.c meta.h \ 18 meta.c meta.h \
19 namespace.c namespace.h \ 19 namespace.c namespace.h \
20 namespace_create.c \
20 namespace_search.c \ 21 namespace_search.c \
21 search.c search.h \ 22 search.c search.h \
22 download.c download.h \ 23 download.c download.h \
diff --git a/src/plugins/fs/namespace.c b/src/plugins/fs/namespace.c
index d0cfa1cb..3144f1b4 100644
--- a/src/plugins/fs/namespace.c
+++ b/src/plugins/fs/namespace.c
@@ -20,7 +20,7 @@
20 20
21/** 21/**
22 * @file src/plugins/fs/namespace.c 22 * @file src/plugins/fs/namespace.c
23 * @brief operations creating/deleting and adding to/updating namespaces 23 * @brief operations for deleting and adding to/updating namespaces
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26 26
@@ -51,13 +51,61 @@ typedef struct NL {
51 struct ECRS_MetaData * meta; 51 struct ECRS_MetaData * meta;
52} NamespaceList; 52} NamespaceList;
53 53
54/**
55 * Content selection in main list of available content.
56 */
54static GtkTreeSelection * content_selection; 57static GtkTreeSelection * content_selection;
55 58
56static NamespaceList * head; 59static NamespaceList * head;
57 60
58static GladeXML * metaXML; 61static GladeXML * metaXML;
59 62
60void makeNamespaceFrame(NamespaceList * entry) { 63/**
64 * The user has changed the selection either in the
65 * namespace content list or the global content list.
66 * Update search button status values (add/change).
67 */
68static void on_namespaceContentSelectionChanged(gpointer signal,
69 gpointer cls) {
70 NamespaceList * list = head;
71 int count;
72 int ncount;
73 GtkTreeSelection * ns;
74 GtkTreeIter iter;
75 char * freq;
76 int ok;
77
78 count = gtk_tree_selection_count_selected_rows(content_selection);
79 while (list != NULL) {
80 ns = gtk_tree_view_get_selection(GTK_TREE_VIEW(list->treeview));
81 ncount = gtk_tree_selection_count_selected_rows(ns);
82 gtk_widget_set_sensitive(list->addButton,
83 count > 0);
84 /* now check if update is legal */
85 ok = 0;
86 if ( (count == 1) &&
87 (ncount == 1) &&
88 (TRUE == gtk_tree_selection_get_selected(ns,
89 NULL,
90 &iter)) ) {
91
92 gtk_tree_model_get(list->model,
93 &iter,
94 IN_NAMESPACE_PUB_FREQ_STRING, &freq,
95 -1);
96 if ( (freq != NULL) &&
97 (0 != strcmp(freq, _("never"))) )
98 ok = 1;
99 FREENONNULL(freq);
100 }
101 gtk_widget_set_sensitive(list->updateButton,
102 ok);
103 list = list->next;
104 }
105}
106
107
108static void makeNamespaceFrame(NamespaceList * entry) {
61 GtkWidget * child; 109 GtkWidget * child;
62 GtkWidget * resultList; 110 GtkWidget * resultList;
63 GtkCellRenderer * renderer; 111 GtkCellRenderer * renderer;
@@ -79,7 +127,7 @@ void makeNamespaceFrame(NamespaceList * entry) {
79 entry->addButton = glade_xml_get_widget(namespaceXML, 127 entry->addButton = glade_xml_get_widget(namespaceXML,
80 "addButton"); 128 "addButton");
81 entry->updateButton = glade_xml_get_widget(namespaceXML, 129 entry->updateButton = glade_xml_get_widget(namespaceXML,
82 "updateButton"); 130 "namespaceUpdateButton");
83 entry->treeview = GTK_WIDGET(GTK_TREE_VIEW(resultList)); 131 entry->treeview = GTK_WIDGET(GTK_TREE_VIEW(resultList));
84 model = 132 model =
85 gtk_list_store_new(IN_NAMESPACE_NUM, 133 gtk_list_store_new(IN_NAMESPACE_NUM,
@@ -98,7 +146,13 @@ void makeNamespaceFrame(NamespaceList * entry) {
98 gtk_tree_view_set_model(GTK_TREE_VIEW(resultList), 146 gtk_tree_view_set_model(GTK_TREE_VIEW(resultList),
99 GTK_TREE_MODEL(model)); 147 GTK_TREE_MODEL(model));
100 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(resultList)), 148 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(resultList)),
101 GTK_SELECTION_MULTIPLE); 149 GTK_SELECTION_SINGLE);
150 g_signal_connect_data(content_selection,
151 "changed",
152 G_CALLBACK(&on_namespaceContentSelectionChanged),
153 NULL,
154 NULL,
155 0);
102 156
103 157
104 158
@@ -356,32 +410,17 @@ static int addNamespaceContentToModel(void * cls,
356} 410}
357 411
358/** 412/**
359 * The user has edited the search entry.
360 * Update search button status.
361 */
362static void on_namespaceContentSelectionChanged(gpointer signal,
363 gpointer cls) {
364 NamespaceList * list = head;
365
366 while (list != NULL) {
367 gtk_widget_set_sensitive(list->addButton,
368 gtk_tree_selection_count_selected_rows(content_selection) > 0);
369 list = list->next;
370 }
371}
372
373
374/**
375 * Add a tab for the given namespace. 413 * Add a tab for the given namespace.
376 */ 414 */
377static int addTabForNamespace(void * unused, 415int addTabForNamespace(void * unused,
378 const char * namespaceName, 416 const char * namespaceName,
379 const HashCode512 * namespaceId, 417 const HashCode512 * namespaceId,
380 const struct ECRS_MetaData * md, 418 const struct ECRS_MetaData * md,
381 int rating) { 419 int rating) {
382 NamespaceList * list; 420 NamespaceList * list;
383 GtkWidget * label; 421 GtkWidget * label;
384 GtkWidget * notebook; 422 GtkWidget * notebook;
423 GtkWidget * del_menu;
385 424
386 DEBUG_BEGIN(); 425 DEBUG_BEGIN();
387 label = gtk_label_new(namespaceName); 426 label = gtk_label_new(namespaceName);
@@ -409,119 +448,15 @@ static int addTabForNamespace(void * unused,
409 &addNamespaceContentToModel, 448 &addNamespaceContentToModel,
410 list->model); 449 list->model);
411 DEBUG_END(); 450 DEBUG_END();
412 return OK; 451 /* enable "delete" menu entry */
413}
414 452
415void on_namespacemetaDataDialogKeywordAddButton_clicked_fs(gpointer dummy, 453 del_menu = glade_xml_get_widget(getMainXML(),
416 GtkWidget * uploadButton) { 454 "namespaceDelete");
417 handleKeywordListUpdate(metaXML, 455 gtk_widget_set_sensitive(del_menu,
418 "namespaceKeywordEntry", 456 TRUE);
419 "namespaceMetaDataDialogKeywordList"); 457 return OK;
420}
421
422void on_namespacemetaDataDialogMetaDataAddButton_clicked_fs(gpointer dummy,
423 GtkWidget * uploadButton) {
424 handleMetaDataListUpdate(metaXML,
425 "namespaceMetaDataDialogMetaTypeComboBox",
426 "namespaceMetaDataValueEntry",
427 "namespaceMetaDataDialogMetaDataList");
428} 458}
429 459
430void create_namespace_clicked_fs(GtkWidget * dummy1,
431 GtkWidget * dummy2) {
432 const char * namespaceName;
433 GtkWidget * nameLine;
434 GtkWidget * dialog;
435 GtkWidget * spin;
436 struct ECRS_MetaData * meta;
437 struct ECRS_URI * keywordURI;
438 struct ECRS_URI * root;
439 HashCode512 namespaceId;
440 HashCode512 rootEntry;
441
442 DEBUG_BEGIN();
443 metaXML
444 = glade_xml_new(getGladeFileName(),
445 "namespaceMetaDataDialog",
446 PACKAGE_NAME);
447 connectGladeWithPlugins(metaXML);
448 dialog = glade_xml_get_widget(metaXML,
449 "namespaceMetaDataDialog");
450 createMetaDataListTreeView(metaXML,
451 "namespaceMetaDataDialogMetaDataList",
452 NULL,
453 NULL);
454 createKeywordListTreeView(metaXML,
455 "namespaceMetaDataDialogKeywordList",
456 NULL);
457 createMetaTypeComboBox(metaXML,
458 "namespaceMetaDataDialogMetaTypeComboBox");
459 gtk_dialog_set_default_response(GTK_DIALOG(dialog),
460 GTK_RESPONSE_OK);
461 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
462 meta
463 = getMetaDataFromList(metaXML,
464 "namespaceMetaDataDialogMetaDataList",
465 NULL);
466 keywordURI
467 = getKeywordURIFromList(metaXML,
468 "namespaceMetaDataDialogKeywordList");
469 spin = glade_xml_get_widget(metaXML,
470 "namespaceAnonymityspinbutton");
471 nameLine = glade_xml_get_widget(metaXML,
472 "namespaceRootEntry");
473 namespaceName = gtk_entry_get_text(GTK_ENTRY(nameLine));
474 if (namespaceName == NULL)
475 namespaceName = "root"; /* do NOT translate "root"! */
476 hash(namespaceName,
477 strlen(namespaceName),
478 &rootEntry);
479 nameLine = glade_xml_get_widget(metaXML,
480 "namespaceNameEntry");
481 namespaceName = gtk_entry_get_text(GTK_ENTRY(nameLine));
482 root = NS_createNamespace(ectx,
483 cfg,
484 gtk_spin_button_get_value_as_int
485 (GTK_SPIN_BUTTON(spin)),
486 1000, /* FIXME: priority */
487 999999, /* FIXME: expiration */
488 namespaceName,
489 meta,
490 keywordURI,
491 &rootEntry);
492 if (root != NULL) {
493 ECRS_getNamespaceId(root,
494 &namespaceId);
495 addTabForNamespace(NULL,
496 namespaceName,
497 &namespaceId,
498 meta,
499 0);
500 ECRS_freeUri(root);
501 } else {
502 GtkWidget * dialog;
503
504 dialog = gtk_message_dialog_new
505 (NULL,
506 GTK_DIALOG_MODAL,
507 GTK_MESSAGE_ERROR,
508 GTK_BUTTONS_CLOSE,
509 _("Failed to create namespace `%s'."
510 "Consult logs, most likely error is"
511 " that a namespace with that name "
512 "already exists."),
513 namespaceName);
514 gtk_dialog_run(GTK_DIALOG(dialog));
515 gtk_widget_destroy(dialog);
516 }
517 ECRS_freeMetaData(meta);
518 ECRS_freeUri(keywordURI);
519 }
520 gtk_widget_destroy(dialog);
521 UNREF(metaXML);
522 metaXML = NULL;
523 DEBUG_END();
524}
525 460
526void namespaceDelete_clicked_fs(GtkWidget * dummy1, 461void namespaceDelete_clicked_fs(GtkWidget * dummy1,
527 GtkWidget * dummy2) { 462 GtkWidget * dummy2) {
@@ -587,6 +522,7 @@ void namespaceDelete_clicked_fs(GtkWidget * dummy1,
587 NS_deleteNamespace(ectx, 522 NS_deleteNamespace(ectx,
588 cfg, 523 cfg,
589 list->name); 524 list->name);
525
590 DEBUG_END(); 526 DEBUG_END();
591} 527}
592 528
@@ -603,10 +539,10 @@ typedef struct {
603 * Publish the selected file in the 539 * Publish the selected file in the
604 * selected namespace. 540 * selected namespace.
605 */ 541 */
606static void initiateUpload(GtkTreeModel * model, 542static void addToNamespaceCB(GtkTreeModel * model,
607 GtkTreePath * path, 543 GtkTreePath * path,
608 GtkTreeIter * iter, 544 GtkTreeIter * iter,
609 gpointer data) { 545 gpointer data) {
610 IUC * cls = data; 546 IUC * cls = data;
611 struct ECRS_URI * resultURI; 547 struct ECRS_URI * resultURI;
612 struct ECRS_URI * dst; 548 struct ECRS_URI * dst;
@@ -761,7 +697,7 @@ void on_namespaceInsertButton_clicked_fs(GtkWidget * dummy1,
761 } 697 }
762 ggc_tree_selection_selected_foreach 698 ggc_tree_selection_selected_foreach
763 (content_selection, 699 (content_selection,
764 &initiateUpload, 700 &addToNamespaceCB,
765 &cls); 701 &cls);
766 } 702 }
767 gtk_widget_destroy(dialog); 703 gtk_widget_destroy(dialog);
@@ -929,7 +865,7 @@ void on_namespaceUpdateButton_clicked_fs(GtkWidget * dummy1,
929 865
930 ggc_tree_selection_selected_foreach 866 ggc_tree_selection_selected_foreach
931 (selection, 867 (selection,
932 &initiateUpload, 868 &addToNamespaceCB,
933 &cls); 869 &cls);
934 } 870 }
935 gtk_widget_destroy(dialog); 871 gtk_widget_destroy(dialog);
@@ -1058,7 +994,10 @@ void on_localNamespaceContentFrameTreeView_destroy_fs(GtkWidget * tree,
1058 NamespaceList * prev; 994 NamespaceList * prev;
1059 NamespaceList * pos; 995 NamespaceList * pos;
1060 NamespaceList * next; 996 NamespaceList * next;
997 GtkWidget * del_menu;
1061 998
999 fprintf(stderr,
1000 "DESTROYING!\n");
1062 pos = head; 1001 pos = head;
1063 while (pos != NULL) { 1002 while (pos != NULL) {
1064 next = pos->next; 1003 next = pos->next;
@@ -1098,12 +1037,17 @@ void on_localNamespaceContentFrameTreeView_destroy_fs(GtkWidget * tree,
1098 &iter)); 1037 &iter));
1099 } 1038 }
1100 FREE(pos); 1039 FREE(pos);
1040 fprintf(stderr,
1041 "DESTROYED %p!\n", head);
1042 del_menu = glade_xml_get_widget(getMainXML(),
1043 "namespaceDelete");
1044 gtk_widget_set_sensitive(del_menu,
1045 head != NULL);
1101} 1046}
1102 1047
1103void fs_namespace_stop() { 1048void fs_namespace_stop() {
1104 URITRACK_unregisterTrackCallback(&updateViewSave, 1049 URITRACK_unregisterTrackCallback(&updateViewSave,
1105 NULL); 1050 NULL);
1106 /* FIXME: free resources! */
1107} 1051}
1108 1052
1109/* end of namespace.c */ 1053/* end of namespace.c */
diff --git a/src/plugins/fs/namespace.h b/src/plugins/fs/namespace.h
index c2260f29..f0a251f5 100644
--- a/src/plugins/fs/namespace.h
+++ b/src/plugins/fs/namespace.h
@@ -27,6 +27,16 @@
27#ifndef GTK_NAMESPACE_H 27#ifndef GTK_NAMESPACE_H
28#define GTK_NAMESPACE_H 28#define GTK_NAMESPACE_H
29 29
30/**
31 * Add a tab for the given namespace.
32 */
33int addTabForNamespace(void * unused,
34 const char * namespaceName,
35 const HashCode512 * namespaceId,
36 const struct ECRS_MetaData * md,
37 int rating);
38
39
30void fs_namespace_start(void); 40void fs_namespace_start(void);
31 41
32void fs_namespace_stop(void); 42void fs_namespace_stop(void);
diff --git a/src/plugins/fs/namespace_create.c b/src/plugins/fs/namespace_create.c
new file mode 100644
index 00000000..6b6e3f86
--- /dev/null
+++ b/src/plugins/fs/namespace_create.c
@@ -0,0 +1,260 @@
1/*
2 This file is part of GNUnet.
3 (C) 2005, 2006, 2007 Christian Grothoff (and other contributing authors)
4
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
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file src/plugins/fs/namespace.c
23 * @brief operations creating namespaces
24 * @author Christian Grothoff
25 */
26
27#include "platform.h"
28#include "gnunetgtk_common.h"
29#include "fs.h"
30#include "helper.h"
31#include "meta.h"
32#include "namespace.h"
33#include "content_tracking.h"
34#include <GNUnet/gnunet_util_crypto.h>
35#include <GNUnet/gnunet_uritrack_lib.h>
36#include <GNUnet/gnunet_namespace_lib.h>
37#include <extractor.h>
38
39
40static GladeXML * metaXML;
41
42
43void on_namespacemetaDataDialogKeywordRemoveButton_clicked_fs(gpointer dummy,
44 GtkWidget * uploadButton) {
45 handleListRemove(metaXML,
46 "namespaceMetaDataDialogKeywordList");
47}
48
49void on_namespacemetaDataDialogMetaDataRemoveButton_clicked_fs(gpointer dummy,
50 GtkWidget * uploadButton) {
51 handleListRemove(metaXML,
52 "namespaceMetaDataDialogMetaDataList");
53}
54
55void on_namespacemetaDataDialogKeywordAddButton_clicked_fs(gpointer dummy,
56 GtkWidget * uploadButton) {
57 handleKeywordListUpdate(metaXML,
58 "namespaceKeywordEntry",
59 "namespaceMetaDataDialogKeywordList");
60}
61
62void on_namespacemetaDataDialogMetaDataAddButton_clicked_fs(gpointer dummy,
63 GtkWidget * uploadButton) {
64 handleMetaDataListUpdate(metaXML,
65 "namespaceMetaDataDialogMetaTypeComboBox",
66 "namespaceMetaDataValueEntry",
67 "namespaceMetaDataDialogMetaDataList");
68}
69
70/**
71 * The selection of the keyword list changed.
72 * Update button status.
73 */
74static void on_keyword_list_selection_changed(gpointer signal,
75 gpointer cls) {
76 GtkTreeSelection * selection;
77 GtkWidget * button;
78
79 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(glade_xml_get_widget(metaXML,
80 "namespaceMetaDataDialogKeywordList")));
81 button
82 = glade_xml_get_widget(metaXML,
83 "nsMetaDataDialogKeywordRemoveButton");
84 gtk_widget_set_sensitive(button,
85 gtk_tree_selection_count_selected_rows(selection) > 0);
86}
87
88/**
89 * The selection of the metadata list changed.
90 * Update button status.
91 */
92static void on_metadata_list_selection_changed(gpointer signal,
93 gpointer cls) {
94 GtkTreeSelection * selection;
95 GtkWidget * button;
96
97 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(glade_xml_get_widget(metaXML,
98 "namespaceMetaDataDialogMetaDataList")));
99 button
100 = glade_xml_get_widget(metaXML,
101 "nsMetaDataDialogMetaDataRemoveButton");
102 gtk_widget_set_sensitive(button,
103 gtk_tree_selection_count_selected_rows(selection) > 0);
104}
105
106/**
107 * The user has edited the metadata entry.
108 * Update add button status.
109 */
110void on_namespaceMetaDataValueEntry_changed_fs(gpointer dummy2,
111 GtkWidget * searchEntry) {
112 const char * input;
113 GtkWidget * button;
114
115 input = gtk_entry_get_text(GTK_ENTRY(glade_xml_get_widget(metaXML,
116 "namespaceMetaDataValueEntry")));
117 if (input == NULL)
118 return;
119 button
120 = glade_xml_get_widget(metaXML,
121 "nsMetaDataDialogMetaDataAddButton");
122 gtk_widget_set_sensitive(button,
123 strlen(input) > 0);
124}
125
126/**
127 * The user has edited the keyword entry.
128 * Update add button status.
129 */
130void on_namespaceKeywordEntry_changed_fs(gpointer dummy2,
131 GtkWidget * searchEntry) {
132 const char * input;
133 GtkWidget * button;
134
135 input = gtk_entry_get_text(GTK_ENTRY(glade_xml_get_widget(metaXML,
136 "namespaceKeywordEntry")));
137 if (input == NULL)
138 return;
139 button
140 = glade_xml_get_widget(metaXML,
141 "nsMetaDataDialogKeywordAddButton");
142 gtk_widget_set_sensitive(button,
143 strlen(input) > 0);
144}
145
146
147void create_namespace_clicked_fs(GtkWidget * dummy1,
148 GtkWidget * dummy2) {
149 const char * namespaceName;
150 GtkWidget * nameLine;
151 GtkWidget * dialog;
152 GtkWidget * spin;
153 struct ECRS_MetaData * meta;
154 struct ECRS_URI * keywordURI;
155 struct ECRS_URI * root;
156 HashCode512 namespaceId;
157 HashCode512 rootEntry;
158
159 DEBUG_BEGIN();
160 metaXML
161 = glade_xml_new(getGladeFileName(),
162 "namespaceMetaDataDialog",
163 PACKAGE_NAME);
164 connectGladeWithPlugins(metaXML);
165 dialog = glade_xml_get_widget(metaXML,
166 "namespaceMetaDataDialog");
167 createMetaDataListTreeView(metaXML,
168 "namespaceMetaDataDialogMetaDataList",
169 NULL,
170 NULL);
171 g_signal_connect_data(gtk_tree_view_get_selection(GTK_TREE_VIEW(glade_xml_get_widget(metaXML,
172 "namespaceMetaDataDialogMetaDataList"))),
173 "changed",
174 G_CALLBACK(&on_metadata_list_selection_changed),
175 NULL,
176 NULL,
177 0);
178 createKeywordListTreeView(metaXML,
179 "namespaceMetaDataDialogKeywordList",
180 NULL);
181 g_signal_connect_data(gtk_tree_view_get_selection(GTK_TREE_VIEW(glade_xml_get_widget(metaXML,
182 "namespaceMetaDataDialogKeywordList"))),
183 "changed",
184 G_CALLBACK(&on_keyword_list_selection_changed),
185 NULL,
186 NULL,
187 0);
188
189 createMetaTypeComboBox(metaXML,
190 "namespaceMetaDataDialogMetaTypeComboBox");
191 gtk_dialog_set_default_response(GTK_DIALOG(dialog),
192 GTK_RESPONSE_OK);
193 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
194 meta
195 = getMetaDataFromList(metaXML,
196 "namespaceMetaDataDialogMetaDataList",
197 NULL);
198 keywordURI
199 = getKeywordURIFromList(metaXML,
200 "namespaceMetaDataDialogKeywordList");
201 spin = glade_xml_get_widget(metaXML,
202 "namespaceAnonymityspinbutton");
203 nameLine = glade_xml_get_widget(metaXML,
204 "namespaceRootEntry");
205 namespaceName = gtk_entry_get_text(GTK_ENTRY(nameLine));
206 if (namespaceName == NULL)
207 namespaceName = "root"; /* do NOT translate "root"! */
208 hash(namespaceName,
209 strlen(namespaceName),
210 &rootEntry);
211 nameLine = glade_xml_get_widget(metaXML,
212 "namespaceNameEntry");
213 namespaceName = gtk_entry_get_text(GTK_ENTRY(nameLine));
214 root = NS_createNamespace(ectx,
215 cfg,
216 gtk_spin_button_get_value_as_int
217 (GTK_SPIN_BUTTON(spin)),
218 1000, /* FIXME: priority */
219 999999, /* FIXME: expiration */
220 namespaceName,
221 meta,
222 keywordURI,
223 &rootEntry);
224 if (root != NULL) {
225 ECRS_getNamespaceId(root,
226 &namespaceId);
227 addTabForNamespace(NULL,
228 namespaceName,
229 &namespaceId,
230 meta,
231 0);
232 ECRS_freeUri(root);
233 } else {
234 GtkWidget * dialog;
235
236 /* IMPROVE-ME: we could check if the
237 namespace exists as the user
238 enters its name and disable the
239 "Ok" button unless the name is unique */
240 dialog = gtk_message_dialog_new
241 (NULL,
242 GTK_DIALOG_MODAL,
243 GTK_MESSAGE_ERROR,
244 GTK_BUTTONS_CLOSE,
245 _("Failed to create namespace `%s'."
246 "Consult logs, most likely error is"
247 " that a namespace with that name "
248 "already exists."),
249 namespaceName);
250 gtk_dialog_run(GTK_DIALOG(dialog));
251 gtk_widget_destroy(dialog);
252 }
253 ECRS_freeMetaData(meta);
254 ECRS_freeUri(keywordURI);
255 }
256 gtk_widget_destroy(dialog);
257 UNREF(metaXML);
258 metaXML = NULL;
259 DEBUG_END();
260}