aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-12-24 21:46:49 +0000
committerChristian Grothoff <christian@grothoff.org>2011-12-24 21:46:49 +0000
commit143f3b1e52c156efdeb52a49eb662a3c2bd9cb75 (patch)
tree6c08d4f63284593cbfae2d8bb72fd8c83ac00442
parenta5c0a556120d1ffa1aba820443c49b8c299cae44 (diff)
downloadgnunet-gtk-143f3b1e52c156efdeb52a49eb662a3c2bd9cb75.tar.gz
gnunet-gtk-143f3b1e52c156efdeb52a49eb662a3c2bd9cb75.zip
-LRN: make publication type selector do something - #2028
-rw-r--r--contrib/gnunet_fs_gtk_main_window.glade7
-rw-r--r--src/fs/gnunet-fs-gtk-edit_publish_dialog.c85
2 files changed, 75 insertions, 17 deletions
diff --git a/contrib/gnunet_fs_gtk_main_window.glade b/contrib/gnunet_fs_gtk_main_window.glade
index 6536f10c..dc5bc596 100644
--- a/contrib/gnunet_fs_gtk_main_window.glade
+++ b/contrib/gnunet_fs_gtk_main_window.glade
@@ -61,11 +61,12 @@
61 </packing> 61 </packing>
62 </child> 62 </child>
63 <child> 63 <child>
64 <object class="GtkComboBox" id="_GNUNET_GTK_edit_publication_type_combo"> 64 <object class="GtkComboBox" id="GNUNET_GTK_edit_publication_type_combo">
65 <property name="visible">True</property> 65 <property name="visible">True</property>
66 <property name="can_focus">False</property> 66 <property name="can_focus">False</property>
67 <property name="model">GNUNET_GTK_publication_types_liststore</property> 67 <property name="model">GNUNET_GTK_publication_types_liststore</property>
68 <property name="active">0</property> 68 <property name="active">0</property>
69 <signal name="changed" handler="GNUNET_GTK_edit_publication_type_combo_changed_cb" swapped="no"/>
69 <child> 70 <child>
70 <object class="GtkCellRendererText" id="cellrenderertext2"/> 71 <object class="GtkCellRendererText" id="cellrenderertext2"/>
71 <attributes> 72 <attributes>
@@ -2165,12 +2166,12 @@
2165 <columns> 2166 <columns>
2166 <!-- column-name Type --> 2167 <!-- column-name Type -->
2167 <column type="gint"/> 2168 <column type="gint"/>
2168 <!-- column-name Type1 --> 2169 <!-- column-name Type_name -->
2169 <column type="gchararray"/> 2170 <column type="gchararray"/>
2170 </columns> 2171 </columns>
2171 <data> 2172 <data>
2172 <row> 2173 <row>
2173 <col id="0">-1</col> 2174 <col id="0">0</col>
2174 <col id="1" translatable="yes">Generic</col> 2175 <col id="1" translatable="yes">Generic</col>
2175 </row> 2176 </row>
2176 <row> 2177 <row>
diff --git a/src/fs/gnunet-fs-gtk-edit_publish_dialog.c b/src/fs/gnunet-fs-gtk-edit_publish_dialog.c
index 955cf655..f4ea52a4 100644
--- a/src/fs/gnunet-fs-gtk-edit_publish_dialog.c
+++ b/src/fs/gnunet-fs-gtk-edit_publish_dialog.c
@@ -30,6 +30,60 @@
30 30
31#define PUBSTATE "edit-publication-state" 31#define PUBSTATE "edit-publication-state"
32 32
33#include "metatypes.c"
34
35void change_metatypes (GtkBuilder *builder, gint code)
36{
37 GtkListStore *metatypes_list;
38 gint pub_type = 0, i;
39 gint pubtype_count = 0;
40 gint max_type;
41 GtkTreeIter iter;
42 metatypes_list = GTK_LIST_STORE (gtk_builder_get_object (builder,
43 "GNUNET_GTK_publication_metadata_types_liststore"));
44
45 for (pub_type = 0; types[pub_type] != NULL; pub_type++)
46 pubtype_count += 1;
47
48 if (code < pubtype_count)
49 pub_type = code;
50 else
51 pub_type = 0;
52
53 gtk_list_store_clear (metatypes_list);
54 max_type = EXTRACTOR_metatype_get_max ();
55 for (i = 0; types[pub_type][i] != EXTRACTOR_METATYPE_RESERVED; i++)
56 {
57 if (types[pub_type][i] < max_type && types[pub_type][i] > 0)
58 gtk_list_store_insert_with_values (metatypes_list, &iter, G_MAXINT,
59 0, types[pub_type][i],
60 1, EXTRACTOR_METAFORMAT_UTF8,
61 2, EXTRACTOR_metatype_to_string (types[pub_type][i]),
62 3, EXTRACTOR_metatype_to_description (types[pub_type][i]), -1);
63 }
64}
65
66void
67GNUNET_GTK_edit_publication_type_combo_changed_cb (GtkComboBox *widget,
68 gpointer user_data)
69{
70 GtkTreeIter iter;
71 GtkBuilder *builder;
72 GtkListStore *pubtypes_list;
73 gint code;
74
75 if (!gtk_combo_box_get_active_iter (widget, &iter))
76 return;
77 builder = GTK_BUILDER (user_data);
78
79 pubtypes_list = GTK_LIST_STORE (gtk_builder_get_object (builder,
80 "GNUNET_GTK_publication_types_liststore"));
81
82 gtk_tree_model_get (GTK_TREE_MODEL (pubtypes_list), &iter, 0, &code, -1);
83
84 change_metatypes (builder, code);
85}
86
33struct EditPublicationState 87struct EditPublicationState
34{ 88{
35 int do_index; 89 int do_index;
@@ -105,16 +159,10 @@ GNUNET_GTK_edit_publication_window_realize_cb (GtkWidget *widget,
105 gpointer user_data) 159 gpointer user_data)
106{ 160{
107 GtkBuilder *builder; 161 GtkBuilder *builder;
108 GtkListStore *metatypes_list;
109 GtkTreeIter iter;
110 GtkTreeView *tv; 162 GtkTreeView *tv;
111 GtkTreeSelection *sel; 163 GtkTreeSelection *sel;
112 guint type;
113 guint max_type;
114 164
115 builder = GTK_BUILDER (user_data); 165 builder = GTK_BUILDER (user_data);
116 metatypes_list = GTK_LIST_STORE (gtk_builder_get_object (builder,
117 "GNUNET_GTK_publication_metadata_types_liststore"));
118 166
119 tv = GTK_TREE_VIEW (gtk_builder_get_object (builder, 167 tv = GTK_TREE_VIEW (gtk_builder_get_object (builder,
120 "GNUNET_GTK_edit_publication_metadata_tree_view")); 168 "GNUNET_GTK_edit_publication_metadata_tree_view"));
@@ -127,14 +175,6 @@ GNUNET_GTK_edit_publication_window_realize_cb (GtkWidget *widget,
127 sel = gtk_tree_view_get_selection (tv); 175 sel = gtk_tree_view_get_selection (tv);
128 g_signal_connect (G_OBJECT (sel), "changed", 176 g_signal_connect (G_OBJECT (sel), "changed",
129 G_CALLBACK (keywords_selection_changed_cb), builder); 177 G_CALLBACK (keywords_selection_changed_cb), builder);
130
131 max_type = EXTRACTOR_metatype_get_max ();
132 for (type = 1; type < max_type - 1; type++)
133 gtk_list_store_insert_with_values (metatypes_list, &iter, G_MAXINT,
134 0, type,
135 1, EXTRACTOR_METAFORMAT_UTF8,
136 2, EXTRACTOR_metatype_to_string (type),
137 3, EXTRACTOR_metatype_to_description (type), -1);
138} 178}
139 179
140 180
@@ -1036,6 +1076,10 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkBuilder *builder,
1036 GtkEntry *entry; 1076 GtkEntry *entry;
1037 GtkWidget *ok; 1077 GtkWidget *ok;
1038 struct EditPublicationState *state; 1078 struct EditPublicationState *state;
1079 GtkListStore *pubtypes_list;
1080 GtkComboBox *pubtypes_combo;
1081 GtkTreeIter iter;
1082 gint code;
1039 1083
1040 GNUNET_FS_GTK_setup_expiration_year_adjustment (builder); 1084 GNUNET_FS_GTK_setup_expiration_year_adjustment (builder);
1041 if (GNUNET_FS_file_information_is_directory (fip)) 1085 if (GNUNET_FS_file_information_is_directory (fip))
@@ -1067,6 +1111,19 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkBuilder *builder,
1067 "GNUNET_GTK_edit_publication_window")); 1111 "GNUNET_GTK_edit_publication_window"));
1068 gtk_window_set_title (GTK_WINDOW (dialog), short_fn); 1112 gtk_window_set_title (GTK_WINDOW (dialog), short_fn);
1069 1113
1114 pubtypes_list = GTK_LIST_STORE (gtk_builder_get_object (builder,
1115 "GNUNET_GTK_publication_types_liststore"));
1116 pubtypes_combo = GTK_COMBO_BOX (gtk_builder_get_object (builder,
1117 "GNUNET_GTK_edit_publication_type_combo"));
1118
1119 if (gtk_combo_box_get_active_iter (pubtypes_combo, &iter))
1120 {
1121 gtk_tree_model_get (GTK_TREE_MODEL (pubtypes_list), &iter, 0, &code, -1);
1122 change_metatypes (builder, 0);
1123 }
1124 else
1125 gtk_combo_box_set_active (pubtypes_combo, 0);
1126
1070 state = GNUNET_malloc (sizeof (struct EditPublicationState)); 1127 state = GNUNET_malloc (sizeof (struct EditPublicationState));
1071 state->do_index = do_index; 1128 state->do_index = do_index;
1072 if (NULL != short_fn) 1129 if (NULL != short_fn)