diff options
Diffstat (limited to 'src/namestore/gnunet-namestore-gtk_edit.c')
-rw-r--r-- | src/namestore/gnunet-namestore-gtk_edit.c | 92 |
1 files changed, 45 insertions, 47 deletions
diff --git a/src/namestore/gnunet-namestore-gtk_edit.c b/src/namestore/gnunet-namestore-gtk_edit.c index de8a1bd6..fc6dbca9 100644 --- a/src/namestore/gnunet-namestore-gtk_edit.c +++ b/src/namestore/gnunet-namestore-gtk_edit.c | |||
@@ -27,24 +27,6 @@ | |||
27 | 27 | ||
28 | 28 | ||
29 | /** | 29 | /** |
30 | * Columns in the 'zone_liststore'. | ||
31 | */ | ||
32 | enum ZoneListColumn | ||
33 | { | ||
34 | /** | ||
35 | * A gchararray with the name of the zone for users. | ||
36 | */ | ||
37 | ZONELIST_COL_NAME = 0, | ||
38 | |||
39 | /** | ||
40 | * A gchararray with the name of the configuration file option with | ||
41 | * the zone key. | ||
42 | */ | ||
43 | ZONELIST_COL_OPTION = 1 | ||
44 | }; | ||
45 | |||
46 | |||
47 | /** | ||
48 | * Disable 'save' button, dialog state is not acceptable. | 30 | * Disable 'save' button, dialog state is not acceptable. |
49 | * | 31 | * |
50 | * @param edc dialog to modify | 32 | * @param edc dialog to modify |
@@ -164,6 +146,44 @@ GNS_edit_dialog_expiration_absolute_radiobutton_toggled_cb (GtkToggleButton *but | |||
164 | 146 | ||
165 | 147 | ||
166 | /** | 148 | /** |
149 | * Setup the zone combobox. | ||
150 | * | ||
151 | * @param edc dialog to setup the combo box for | ||
152 | */ | ||
153 | static void | ||
154 | setup_zone (struct EditDialogContext *edc) | ||
155 | { | ||
156 | GtkTreeIter iter; | ||
157 | GtkComboBox *cb; | ||
158 | gchar *name; | ||
159 | |||
160 | cb = GTK_COMBO_BOX (gtk_builder_get_object (edc->builder, | ||
161 | "edit_dialog_zone_combobox")); | ||
162 | |||
163 | gtk_combo_box_set_model (cb, | ||
164 | GTK_TREE_MODEL (edc->zone_liststore)); | ||
165 | GNUNET_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (edc->zone_liststore), | ||
166 | &iter)); | ||
167 | do { | ||
168 | gtk_tree_model_get (GTK_TREE_MODEL (edc->zone_liststore), | ||
169 | &iter, | ||
170 | ZONE_LS_NAME, &name, | ||
171 | -1); | ||
172 | if (0 == strcmp (name, | ||
173 | edc->new_zone_option)) | ||
174 | { | ||
175 | g_free (name); | ||
176 | break; | ||
177 | } | ||
178 | g_free (name); | ||
179 | } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (edc->zone_liststore), | ||
180 | &iter)); | ||
181 | gtk_combo_box_set_active_iter (cb, | ||
182 | &iter); | ||
183 | } | ||
184 | |||
185 | |||
186 | /** | ||
167 | * Initialize widgets of the edit dialog that are the same regardless of | 187 | * Initialize widgets of the edit dialog that are the same regardless of |
168 | * the type of the record. | 188 | * the type of the record. |
169 | * | 189 | * |
@@ -173,10 +193,8 @@ static void | |||
173 | edit_dialog_setup_common_elements (struct EditDialogContext *edc) | 193 | edit_dialog_setup_common_elements (struct EditDialogContext *edc) |
174 | { | 194 | { |
175 | GtkComboBox *cb; | 195 | GtkComboBox *cb; |
176 | GtkTreeModel *tm; | ||
177 | GtkListStore *ls; | 196 | GtkListStore *ls; |
178 | GtkTreeIter iter; | 197 | GtkTreeIter iter; |
179 | gchar *opt; | ||
180 | struct GNUNET_TIME_Absolute at; | 198 | struct GNUNET_TIME_Absolute at; |
181 | struct GNUNET_TIME_Relative rt; | 199 | struct GNUNET_TIME_Relative rt; |
182 | time_t tp; | 200 | time_t tp; |
@@ -270,32 +288,7 @@ edit_dialog_setup_common_elements (struct EditDialogContext *edc) | |||
270 | gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder, | 288 | gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder, |
271 | "edit_dialog_expiration_absolute_seconds_spinbutton")), | 289 | "edit_dialog_expiration_absolute_seconds_spinbutton")), |
272 | (double) ymd->tm_sec); | 290 | (double) ymd->tm_sec); |
273 | 291 | setup_zone (edc); | |
274 | /* set source zone! */ | ||
275 | cb = GTK_COMBO_BOX (gtk_builder_get_object (edc->builder, | ||
276 | "edit_dialog_zone_combobox")); | ||
277 | tm = gtk_combo_box_get_model (cb); | ||
278 | opt = NULL; | ||
279 | if (gtk_tree_model_get_iter_first (tm, &iter)) | ||
280 | { | ||
281 | do | ||
282 | { | ||
283 | gtk_tree_model_get (tm, &iter, | ||
284 | ZONELIST_COL_OPTION, &opt, | ||
285 | -1); | ||
286 | if ( (NULL != opt) && | ||
287 | (0 == strcasecmp (opt, | ||
288 | edc->new_zone_option)) ) | ||
289 | break; | ||
290 | g_free (opt); | ||
291 | opt = NULL; | ||
292 | } while (gtk_tree_model_iter_next (tm, &iter)); | ||
293 | } | ||
294 | if (NULL != opt) | ||
295 | { | ||
296 | gtk_combo_box_set_active_iter (cb, &iter); | ||
297 | g_free (opt); | ||
298 | } | ||
299 | } | 292 | } |
300 | 293 | ||
301 | 294 | ||
@@ -315,6 +308,7 @@ edit_dialog_putes_common_elements (struct EditDialogContext *edc) | |||
315 | GtkTreeModel *tm; | 308 | GtkTreeModel *tm; |
316 | GtkTreeIter iter; | 309 | GtkTreeIter iter; |
317 | gchar *opt; | 310 | gchar *opt; |
311 | struct GNUNET_IDENTITY_Ego *ego; | ||
318 | 312 | ||
319 | /* is public flag */ | 313 | /* is public flag */ |
320 | edc->n_public = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder, | 314 | edc->n_public = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder, |
@@ -402,15 +396,19 @@ edit_dialog_putes_common_elements (struct EditDialogContext *edc) | |||
402 | else | 396 | else |
403 | { | 397 | { |
404 | gtk_tree_model_get (tm, &iter, | 398 | gtk_tree_model_get (tm, &iter, |
405 | ZONELIST_COL_OPTION, &opt, | 399 | ZONE_LS_NAME, &opt, |
400 | ZONE_LS_EGO, &ego, | ||
406 | -1); | 401 | -1); |
407 | if (NULL == opt) | 402 | if (NULL == opt) |
403 | { | ||
408 | GNUNET_break (0); | 404 | GNUNET_break (0); |
405 | } | ||
409 | else | 406 | else |
410 | { | 407 | { |
411 | g_free (edc->new_zone_option); | 408 | g_free (edc->new_zone_option); |
412 | edc->new_zone_option = g_strdup (opt); | 409 | edc->new_zone_option = g_strdup (opt); |
413 | g_free (opt); | 410 | g_free (opt); |
411 | edc->ego = ego; | ||
414 | } | 412 | } |
415 | } | 413 | } |
416 | } | 414 | } |