diff options
author | Christian Grothoff <christian@grothoff.org> | 2005-08-25 07:45:37 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2005-08-25 07:45:37 +0000 |
commit | b325866879e0a3b3eaf28c6d97f11e02a2e76341 (patch) | |
tree | 69016748e5a4213a967e9c267f5a9b807f2e467e | |
parent | 8c9f46dfb4974385821f20e252bf88b0aaff9147 (diff) | |
download | gnunet-gtk-b325866879e0a3b3eaf28c6d97f11e02a2e76341.tar.gz gnunet-gtk-b325866879e0a3b3eaf28c6d97f11e02a2e76341.zip |
namespace update hacking and minor bugfixes
-rw-r--r-- | gnunet-gtk.glade | 17 | ||||
-rw-r--r-- | src/plugins/fs/meta.c | 7 | ||||
-rw-r--r-- | src/plugins/fs/meta.h | 1 | ||||
-rw-r--r-- | src/plugins/fs/namespace.c | 115 |
4 files changed, 86 insertions, 54 deletions
diff --git a/gnunet-gtk.glade b/gnunet-gtk.glade index 34d7a12c..75fa1fd6 100644 --- a/gnunet-gtk.glade +++ b/gnunet-gtk.glade | |||
@@ -6313,6 +6313,7 @@ Phan Vinh Thinh <teppi82@gmail.com> | |||
6313 | <property name="yalign">0.5</property> | 6313 | <property name="yalign">0.5</property> |
6314 | <property name="xpad">5</property> | 6314 | <property name="xpad">5</property> |
6315 | <property name="ypad">0</property> | 6315 | <property name="ypad">0</property> |
6316 | <property name="mnemonic_widget">namespaceUpdateAnonymitySpinButton</property> | ||
6316 | <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> | 6317 | <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> |
6317 | <property name="width_chars">-1</property> | 6318 | <property name="width_chars">-1</property> |
6318 | <property name="single_line_mode">False</property> | 6319 | <property name="single_line_mode">False</property> |
@@ -6371,6 +6372,7 @@ Phan Vinh Thinh <teppi82@gmail.com> | |||
6371 | <property name="yalign">0.5</property> | 6372 | <property name="yalign">0.5</property> |
6372 | <property name="xpad">6</property> | 6373 | <property name="xpad">6</property> |
6373 | <property name="ypad">0</property> | 6374 | <property name="ypad">0</property> |
6375 | <property name="mnemonic_widget">nextIdentifierEntry</property> | ||
6374 | <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> | 6376 | <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> |
6375 | <property name="width_chars">-1</property> | 6377 | <property name="width_chars">-1</property> |
6376 | <property name="single_line_mode">False</property> | 6378 | <property name="single_line_mode">False</property> |
@@ -6384,15 +6386,20 @@ Phan Vinh Thinh <teppi82@gmail.com> | |||
6384 | </child> | 6386 | </child> |
6385 | 6387 | ||
6386 | <child> | 6388 | <child> |
6387 | <widget class="GtkComboBoxEntry" id="nextIdentifierComboBoxEntry"> | 6389 | <widget class="GtkEntry" id="nextIdentifierEntry"> |
6388 | <property name="visible">True</property> | 6390 | <property name="visible">True</property> |
6389 | <property name="add_tearoffs">False</property> | 6391 | <property name="can_focus">True</property> |
6392 | <property name="editable">True</property> | ||
6393 | <property name="visibility">True</property> | ||
6394 | <property name="max_length">0</property> | ||
6395 | <property name="text" translatable="yes"></property> | ||
6390 | <property name="has_frame">True</property> | 6396 | <property name="has_frame">True</property> |
6391 | <property name="focus_on_click">True</property> | 6397 | <property name="invisible_char">*</property> |
6398 | <property name="activates_default">False</property> | ||
6392 | </widget> | 6399 | </widget> |
6393 | <packing> | 6400 | <packing> |
6394 | <property name="padding">0</property> | 6401 | <property name="padding">0</property> |
6395 | <property name="expand">False</property> | 6402 | <property name="expand">True</property> |
6396 | <property name="fill">True</property> | 6403 | <property name="fill">True</property> |
6397 | </packing> | 6404 | </packing> |
6398 | </child> | 6405 | </child> |
@@ -6525,6 +6532,7 @@ Phan Vinh Thinh <teppi82@gmail.com> | |||
6525 | <property name="yalign">0.5</property> | 6532 | <property name="yalign">0.5</property> |
6526 | <property name="xpad">5</property> | 6533 | <property name="xpad">5</property> |
6527 | <property name="ypad">0</property> | 6534 | <property name="ypad">0</property> |
6535 | <property name="mnemonic_widget">namespaceUpdateMetaValueEntry</property> | ||
6528 | <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> | 6536 | <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> |
6529 | <property name="width_chars">-1</property> | 6537 | <property name="width_chars">-1</property> |
6530 | <property name="single_line_mode">False</property> | 6538 | <property name="single_line_mode">False</property> |
@@ -6666,6 +6674,7 @@ Phan Vinh Thinh <teppi82@gmail.com> | |||
6666 | <property name="yalign">0.5</property> | 6674 | <property name="yalign">0.5</property> |
6667 | <property name="xpad">5</property> | 6675 | <property name="xpad">5</property> |
6668 | <property name="ypad">0</property> | 6676 | <property name="ypad">0</property> |
6677 | <property name="mnemonic_widget">scrolledwindow31</property> | ||
6669 | <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> | 6678 | <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> |
6670 | <property name="width_chars">-1</property> | 6679 | <property name="width_chars">-1</property> |
6671 | <property name="single_line_mode">False</property> | 6680 | <property name="single_line_mode">False</property> |
diff --git a/src/plugins/fs/meta.c b/src/plugins/fs/meta.c index 62a11d15..e51a426b 100644 --- a/src/plugins/fs/meta.c +++ b/src/plugins/fs/meta.c | |||
@@ -385,6 +385,13 @@ struct ECRS_URI * getKeywordURIFromList(GladeXML * xml, | |||
385 | return keywordURI; | 385 | return keywordURI; |
386 | } | 386 | } |
387 | 387 | ||
388 | char * updateIntervalToString(TIME_T interval) { | ||
389 | if (interval == ECRS_SBLOCK_UPDATE_SPORADIC) | ||
390 | return strdup(_("--sporadic update--")); | ||
391 | if (interval == ECRS_SBLOCK_UPDATE_NONE) | ||
392 | return strdup(_("--no update--")); | ||
393 | return timeIntervalToFancyString(interval * cronSECONDS); | ||
394 | } | ||
388 | 395 | ||
389 | int tryParseTimeInterval(GladeXML * xml, | 396 | int tryParseTimeInterval(GladeXML * xml, |
390 | const char * intervalComboBoxEntry, | 397 | const char * intervalComboBoxEntry, |
diff --git a/src/plugins/fs/meta.h b/src/plugins/fs/meta.h index c41f23f1..5e52709e 100644 --- a/src/plugins/fs/meta.h +++ b/src/plugins/fs/meta.h | |||
@@ -58,6 +58,7 @@ struct ECRS_MetaData * getMetaDataFromList(GladeXML * xml, | |||
58 | struct ECRS_URI * getKeywordURIFromList(GladeXML * xml, | 58 | struct ECRS_URI * getKeywordURIFromList(GladeXML * xml, |
59 | const char * name); | 59 | const char * name); |
60 | 60 | ||
61 | char * updateIntervalToString(TIME_T interval); | ||
61 | 62 | ||
62 | int tryParseTimeInterval(GladeXML * xml, | 63 | int tryParseTimeInterval(GladeXML * xml, |
63 | const char * intervalComboBoxEntry, | 64 | const char * intervalComboBoxEntry, |
diff --git a/src/plugins/fs/namespace.c b/src/plugins/fs/namespace.c index 21d304e6..ac0d42d0 100644 --- a/src/plugins/fs/namespace.c +++ b/src/plugins/fs/namespace.c | |||
@@ -119,32 +119,30 @@ static GtkWidget * makeNamespaceFrame(GtkWidget ** treeview, | |||
119 | renderer = gtk_cell_renderer_text_new(); | 119 | renderer = gtk_cell_renderer_text_new(); |
120 | gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList), | 120 | gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList), |
121 | -1, | 121 | -1, |
122 | _("Last ID"), | 122 | _("Publication Frequency"), |
123 | renderer, | 123 | renderer, |
124 | "text", IN_NAMESPACE_LAST_STRING, | 124 | "text", IN_NAMESPACE_PUB_FREQ_STRING, |
125 | NULL); | 125 | NULL); |
126 | renderer = gtk_cell_renderer_text_new(); | 126 | renderer = gtk_cell_renderer_text_new(); |
127 | gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList), | 127 | gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList), |
128 | -1, | 128 | -1, |
129 | _("Next ID"), | 129 | _("Next Publication Date"), |
130 | renderer, | 130 | renderer, |
131 | "text", IN_NAMESPACE_NEXT_STRING, | 131 | "text", IN_NAMESPACE_PUB_DATE_STRING, |
132 | NULL); | 132 | NULL); |
133 | |||
134 | |||
135 | renderer = gtk_cell_renderer_text_new(); | 133 | renderer = gtk_cell_renderer_text_new(); |
136 | gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList), | 134 | gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList), |
137 | -1, | 135 | -1, |
138 | _("Publication Frequency"), | 136 | _("Last ID"), |
139 | renderer, | 137 | renderer, |
140 | "text", IN_NAMESPACE_PUB_FREQ_STRING, | 138 | "text", IN_NAMESPACE_LAST_STRING, |
141 | NULL); | 139 | NULL); |
142 | renderer = gtk_cell_renderer_text_new(); | 140 | renderer = gtk_cell_renderer_text_new(); |
143 | gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList), | 141 | gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(resultList), |
144 | -1, | 142 | -1, |
145 | _("Next Publication Date"), | 143 | _("Next ID"), |
146 | renderer, | 144 | renderer, |
147 | "text", IN_NAMESPACE_PUB_DATE_STRING, | 145 | "text", IN_NAMESPACE_NEXT_STRING, |
148 | NULL); | 146 | NULL); |
149 | child = gtk_bin_get_child(GTK_BIN(window)); | 147 | child = gtk_bin_get_child(GTK_BIN(window)); |
150 | gtk_widget_ref(GTK_WIDGET(child)); | 148 | gtk_widget_ref(GTK_WIDGET(child)); |
@@ -294,7 +292,6 @@ static int addNamespaceContentToModel(void * cls, | |||
294 | char * freq; | 292 | char * freq; |
295 | char * date; | 293 | char * date; |
296 | unsigned long long size; | 294 | unsigned long long size; |
297 | TIME_T t; | ||
298 | 295 | ||
299 | filename = ECRS_getFirstFromMetaData(fi->meta, | 296 | filename = ECRS_getFirstFromMetaData(fi->meta, |
300 | EXTRACTOR_FILENAME, | 297 | EXTRACTOR_FILENAME, |
@@ -331,9 +328,14 @@ static int addNamespaceContentToModel(void * cls, | |||
331 | uriString = ECRS_uriToString(fi->uri); | 328 | uriString = ECRS_uriToString(fi->uri); |
332 | hash2enc(lastId, &last); | 329 | hash2enc(lastId, &last); |
333 | hash2enc(nextId, &next); | 330 | hash2enc(nextId, &next); |
334 | t = nextPublicationTime; | 331 | if (publicationFrequency == ECRS_SBLOCK_UPDATE_SPORADIC) |
335 | date = GN_CTIME(&t); | 332 | date = STRDUP(_("unspecified")); |
336 | freq = timeIntervalToFancyString(publicationFrequency * cronSECONDS); | 333 | else if (publicationFrequency == ECRS_SBLOCK_UPDATE_NONE) |
334 | date = STRDUP(_("never")); | ||
335 | else | ||
336 | date = GN_CTIME(&nextPublicationTime); | ||
337 | |||
338 | freq = updateIntervalToString(publicationFrequency); | ||
337 | gtk_list_store_append(model, | 339 | gtk_list_store_append(model, |
338 | &iter); | 340 | &iter); |
339 | gtk_list_store_set(model, | 341 | gtk_list_store_set(model, |
@@ -793,17 +795,6 @@ void on_namespaceInsertButton_clicked(GtkWidget * dummy1, | |||
793 | metaXML = NULL; | 795 | metaXML = NULL; |
794 | } | 796 | } |
795 | 797 | ||
796 | typedef struct { | ||
797 | unsigned int anonymityLevel; | ||
798 | char * namespaceName; | ||
799 | TIME_T updateInterval; | ||
800 | HashCode512 lastId; | ||
801 | HashCode512 thisId; | ||
802 | HashCode512 * nextId; | ||
803 | struct ECRS_MetaData * meta; | ||
804 | } UUC; | ||
805 | |||
806 | |||
807 | void on_namespaceUpdateButton_clicked(GtkWidget * dummy1, | 798 | void on_namespaceUpdateButton_clicked(GtkWidget * dummy1, |
808 | GtkWidget * dummy2) { | 799 | GtkWidget * dummy2) { |
809 | const char * identifierName; | 800 | const char * identifierName; |
@@ -814,15 +805,18 @@ void on_namespaceUpdateButton_clicked(GtkWidget * dummy1, | |||
814 | GtkWidget * dialog; | 805 | GtkWidget * dialog; |
815 | GtkWidget * spin; | 806 | GtkWidget * spin; |
816 | GtkWidget * update; | 807 | GtkWidget * update; |
808 | GtkTreeIter iter; | ||
817 | struct ECRS_MetaData * meta; | 809 | struct ECRS_MetaData * meta; |
818 | HashCode512 nextId; | 810 | HashCode512 nextId; |
811 | HashCode512 prevId; | ||
819 | GtkWidget * contentList; | 812 | GtkWidget * contentList; |
820 | GtkTreeSelection * selection; | 813 | GtkTreeSelection * selection; |
821 | GtkTreeSelection * selectionNamespace; | 814 | GtkTreeSelection * selectionNamespace; |
822 | UUC cls; | 815 | IUC cls; |
823 | gint num; | 816 | gint num; |
824 | char * oldName; | 817 | const char * last; |
825 | struct ECRS_URI * uri; | 818 | const char * next; |
819 | const char * freq; | ||
826 | 820 | ||
827 | contentList | 821 | contentList |
828 | = glade_xml_get_widget(getMainXML(), | 822 | = glade_xml_get_widget(getMainXML(), |
@@ -876,32 +870,56 @@ void on_namespaceUpdateButton_clicked(GtkWidget * dummy1, | |||
876 | gtk_widget_destroy(dialog); | 870 | gtk_widget_destroy(dialog); |
877 | return; | 871 | return; |
878 | } | 872 | } |
879 | 873 | if (FALSE == gtk_tree_selection_get_selected(selectionNamespace, | |
874 | NULL, | ||
875 | &iter)) { | ||
876 | BREAK(); | ||
877 | return; | ||
878 | } | ||
879 | gtk_tree_model_get(list->model, | ||
880 | &iter, | ||
881 | IN_NAMESPACE_LAST_STRING, &last, | ||
882 | IN_NAMESPACE_NEXT_STRING, &next, | ||
883 | IN_NAMESPACE_PUB_FREQ_STRING, &freq, | ||
884 | IN_NAMESPACE_META, &meta, | ||
885 | -1); | ||
880 | metaXML | 886 | metaXML |
881 | = glade_xml_new(getGladeFileName(), | 887 | = glade_xml_new(getGladeFileName(), |
882 | "namespaceUpdateDialog", | 888 | "namespaceUpdateDialog", |
883 | PACKAGE_NAME); | 889 | PACKAGE_NAME); |
884 | connectGladeWithPlugins(metaXML); | 890 | connectGladeWithPlugins(metaXML); |
885 | 891 | ||
886 | |||
887 | uri = NULL; // FIXME | ||
888 | oldName = STRDUP("FIXME"); // ECRS_uriToString(uri); | ||
889 | nameLine = glade_xml_get_widget(metaXML, | 892 | nameLine = glade_xml_get_widget(metaXML, |
890 | "identifierLabel"); | 893 | "identifierLabel"); |
891 | gtk_label_set_text(GTK_LABEL(nameLine), | 894 | gtk_label_set_text(GTK_LABEL(nameLine), |
892 | oldName); | 895 | next); |
893 | FREE(oldName); | 896 | if (OK != enc2hash(next, |
894 | /* FIXME: set next identifier label! */ | 897 | &cls.thisId)) { |
898 | BREAK(); | ||
899 | UNREF(metaXML); | ||
900 | metaXML = NULL; | ||
901 | return; | ||
902 | } | ||
903 | if (OK == enc2hash(last, | ||
904 | &prevId)) { | ||
905 | cls.lastId = &prevId; | ||
906 | } else { | ||
907 | BREAK(); /* should not happen, try to continue */ | ||
908 | cls.lastId = NULL; | ||
909 | } | ||
910 | nameLine = glade_xml_get_widget(metaXML, | ||
911 | "nextIdentifierEntry"); | ||
912 | gtk_entry_set_text(GTK_ENTRY(nameLine), | ||
913 | ""); /* FIXME: compute next for sporadic updates (extend libecrs?) */ | ||
895 | 914 | ||
896 | update = glade_xml_get_widget(metaXML, | 915 | update = glade_xml_get_widget(metaXML, |
897 | "namespaceUpdateIntervalComboBoxEntry"); | 916 | "namespaceUpdateIntervalComboBoxEntry"); |
898 | /* FIXME: set update interval! */ | 917 | gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(update))), |
899 | 918 | freq); | |
900 | |||
901 | createMetaDataListTreeView(metaXML, | 919 | createMetaDataListTreeView(metaXML, |
902 | "namespaceUpdateMetaDataTreeView", | 920 | "namespaceUpdateMetaDataTreeView", |
903 | "namespaceUpdatePreviewImage", | 921 | "namespaceUpdatePreviewImage", |
904 | NULL); | 922 | meta); |
905 | createMetaTypeComboBox(metaXML, | 923 | createMetaTypeComboBox(metaXML, |
906 | "namespaceUpdateMetaTypeComboBox"); | 924 | "namespaceUpdateMetaTypeComboBox"); |
907 | dialog = glade_xml_get_widget(metaXML, | 925 | dialog = glade_xml_get_widget(metaXML, |
@@ -926,15 +944,15 @@ void on_namespaceUpdateButton_clicked(GtkWidget * dummy1, | |||
926 | return; | 944 | return; |
927 | } | 945 | } |
928 | 946 | ||
929 | meta = getMetaDataFromList(metaXML, | 947 | cls.meta = getMetaDataFromList(metaXML, |
930 | "namespaceUpdateMetaDataTreeView", | 948 | "namespaceUpdateMetaDataTreeView", |
931 | "namespaceUpdatePreviewImage"); | 949 | "namespaceUpdatePreviewImage"); |
932 | spin = glade_xml_get_widget(metaXML, | 950 | spin = glade_xml_get_widget(metaXML, |
933 | "namespaceUpdateAnonymitySpinButton"); | 951 | "namespaceUpdateAnonymitySpinButton"); |
934 | cls.anonymityLevel | 952 | cls.anonymityLevel |
935 | = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin)); | 953 | = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin)); |
936 | nameLine = glade_xml_get_widget(metaXML, | 954 | nameLine = glade_xml_get_widget(metaXML, |
937 | "nextIdentifierComboBoxEntry"); | 955 | "nextIdentifierEntry"); |
938 | identifierName = gtk_entry_get_text(GTK_ENTRY(nameLine)); | 956 | identifierName = gtk_entry_get_text(GTK_ENTRY(nameLine)); |
939 | if ( (identifierName == NULL) || | 957 | if ( (identifierName == NULL) || |
940 | (strlen(identifierName) == 0)) { | 958 | (strlen(identifierName) == 0)) { |
@@ -945,15 +963,12 @@ void on_namespaceUpdateButton_clicked(GtkWidget * dummy1, | |||
945 | &nextId); | 963 | &nextId); |
946 | cls.nextId = &nextId; | 964 | cls.nextId = &nextId; |
947 | } | 965 | } |
948 | cls.meta = meta; | 966 | |
949 | /* | 967 | gtk_tree_selection_selected_foreach |
950 | FIXME: | ||
951 | gtk_tree_selection_selected_foreach | ||
952 | (selection, | 968 | (selection, |
953 | &initiateUpload, | 969 | &initiateUpload, |
954 | &cls); | 970 | &cls); |
955 | */ | 971 | ECRS_freeMetaData(cls.meta); |
956 | ECRS_freeMetaData(meta); | ||
957 | } | 972 | } |
958 | gtk_widget_destroy(dialog); | 973 | gtk_widget_destroy(dialog); |
959 | UNREF(metaXML); | 974 | UNREF(metaXML); |