diff options
Diffstat (limited to 'src/setup')
-rw-r--r-- | src/setup/gnunet-setup-gns-edit.c | 50 | ||||
-rw-r--r-- | src/setup/gnunet-setup-gns-edit.h | 2 | ||||
-rw-r--r-- | src/setup/gnunet-setup-gns.c | 144 |
3 files changed, 47 insertions, 149 deletions
diff --git a/src/setup/gnunet-setup-gns-edit.c b/src/setup/gnunet-setup-gns-edit.c index fc3c273e..c5d5bb3e 100644 --- a/src/setup/gnunet-setup-gns-edit.c +++ b/src/setup/gnunet-setup-gns-edit.c | |||
@@ -190,6 +190,12 @@ GNS_edit_dialog_expiration_absolute_radiobutton_toggled_cb (GtkToggleButton *but | |||
190 | static void | 190 | static void |
191 | edit_dialog_setup_common_elements (struct EditDialogContext *edc) | 191 | edit_dialog_setup_common_elements (struct EditDialogContext *edc) |
192 | { | 192 | { |
193 | GtkComboBox *cb; | ||
194 | GtkTreeModel *tm; | ||
195 | GtkListStore *ls; | ||
196 | GtkTreeIter iter; | ||
197 | gchar *opt; | ||
198 | |||
193 | if (GNUNET_YES != | 199 | if (GNUNET_YES != |
194 | edc->old_record_in_namestore) | 200 | edc->old_record_in_namestore) |
195 | { | 201 | { |
@@ -223,9 +229,6 @@ edit_dialog_setup_common_elements (struct EditDialogContext *edc) | |||
223 | if (edc->n_is_relative) | 229 | if (edc->n_is_relative) |
224 | { | 230 | { |
225 | struct GNUNET_TIME_Relative rt; | 231 | struct GNUNET_TIME_Relative rt; |
226 | GtkComboBox *cb; | ||
227 | GtkListStore *ls; | ||
228 | GtkTreeIter iter; | ||
229 | 232 | ||
230 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder, | 233 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder, |
231 | "edit_dialog_expiration_relative_radiobutton")), | 234 | "edit_dialog_expiration_relative_radiobutton")), |
@@ -324,7 +327,7 @@ edit_dialog_putes_common_elements (struct EditDialogContext *edc) | |||
324 | GtkComboBox *cb; | 327 | GtkComboBox *cb; |
325 | GtkTreeModel *tm; | 328 | GtkTreeModel *tm; |
326 | GtkTreeIter iter; | 329 | GtkTreeIter iter; |
327 | gchararray *opt; | 330 | gchar *opt; |
328 | 331 | ||
329 | /* record name */ | 332 | /* record name */ |
330 | entry = GTK_ENTRY (gtk_builder_get_object (edc->builder, | 333 | entry = GTK_ENTRY (gtk_builder_get_object (edc->builder, |
@@ -373,9 +376,38 @@ edit_dialog_putes_common_elements (struct EditDialogContext *edc) | |||
373 | if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder, | 376 | if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder, |
374 | "edit_dialog_expiration_absolute_radiobutton")))) | 377 | "edit_dialog_expiration_absolute_radiobutton")))) |
375 | { | 378 | { |
376 | /* FIXME: implement! */ | 379 | guint year; |
377 | 380 | guint month; | |
378 | GNUNET_break (0); | 381 | guint day; |
382 | guint hour; | ||
383 | guint minute; | ||
384 | guint second; | ||
385 | char fancydate[128]; | ||
386 | struct GNUNET_TIME_Absolute atime; | ||
387 | |||
388 | gtk_calendar_get_date (GTK_CALENDAR (gtk_builder_get_object (edc->builder, | ||
389 | "edit_dialog_expiration_absolute_calendar")), | ||
390 | &year, &month, &day); | ||
391 | hour = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder, | ||
392 | "edit_dialog_expiration_absolute_hours_spinbutton"))); | ||
393 | minute = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder, | ||
394 | "edit_dialog_expiration_absolute_minutes_spinbutton"))); | ||
395 | second = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder, | ||
396 | "edit_dialog_expiration_absolute_seconds_spinbutton"))); | ||
397 | GNUNET_snprintf (fancydate, | ||
398 | sizeof (fancydate), | ||
399 | "%u-%u-%u %u:%u:%u", | ||
400 | (unsigned int) year, | ||
401 | (unsigned int) month + 1, | ||
402 | (unsigned int) day, | ||
403 | (unsigned int) hour, | ||
404 | (unsigned int) minute, | ||
405 | (unsigned int) second); | ||
406 | GNUNET_break (GNUNET_OK == | ||
407 | GNUNET_STRINGS_fancy_time_to_absolute (fancydate, | ||
408 | &atime)); | ||
409 | edc->n_exp_time = atime.abs_value; | ||
410 | edc->n_is_relative = FALSE; | ||
379 | } | 411 | } |
380 | 412 | ||
381 | /* extract target zone! */ | 413 | /* extract target zone! */ |
@@ -395,8 +427,8 @@ edit_dialog_putes_common_elements (struct EditDialogContext *edc) | |||
395 | GNUNET_break (0); | 427 | GNUNET_break (0); |
396 | else | 428 | else |
397 | { | 429 | { |
398 | GNUNET_free (edc->new_zone_option); | 430 | g_free (edc->new_zone_option); |
399 | edc->new_zone_option = GNUNET_strdup (opt); | 431 | edc->new_zone_option = g_strdup (opt); |
400 | g_free (opt); | 432 | g_free (opt); |
401 | } | 433 | } |
402 | } | 434 | } |
diff --git a/src/setup/gnunet-setup-gns-edit.h b/src/setup/gnunet-setup-gns-edit.h index 2386553c..9a305560 100644 --- a/src/setup/gnunet-setup-gns-edit.h +++ b/src/setup/gnunet-setup-gns-edit.h | |||
@@ -112,7 +112,7 @@ struct EditDialogContext | |||
112 | /** | 112 | /** |
113 | * Zone into which the record should be placed. | 113 | * Zone into which the record should be placed. |
114 | */ | 114 | */ |
115 | const char *new_zone_option; | 115 | gchar *new_zone_option; |
116 | 116 | ||
117 | /** | 117 | /** |
118 | * Flag indicating if the old record was in the namestore. | 118 | * Flag indicating if the old record was in the namestore. |
diff --git a/src/setup/gnunet-setup-gns.c b/src/setup/gnunet-setup-gns.c index 99152a90..8f14edf4 100644 --- a/src/setup/gnunet-setup-gns.c +++ b/src/setup/gnunet-setup-gns.c | |||
@@ -1201,6 +1201,7 @@ edit_dialog_continuation (struct EditDialogContext *edc, | |||
1201 | g_free (edc->n_name); | 1201 | g_free (edc->n_name); |
1202 | g_free (edc->n_new_name); | 1202 | g_free (edc->n_new_name); |
1203 | g_free (edc->n_value); | 1203 | g_free (edc->n_value); |
1204 | g_free (edc->new_zone_option); | ||
1204 | GNUNET_free (edc); | 1205 | GNUNET_free (edc); |
1205 | } | 1206 | } |
1206 | 1207 | ||
@@ -1240,7 +1241,7 @@ edit_selected_row (int old_record_in_namestore) | |||
1240 | GNS_TREESTORE_COL_VAL_AS_STR, &edc->n_value, | 1241 | GNS_TREESTORE_COL_VAL_AS_STR, &edc->n_value, |
1241 | -1); | 1242 | -1); |
1242 | edc->old_record_in_namestore = old_record_in_namestore; | 1243 | edc->old_record_in_namestore = old_record_in_namestore; |
1243 | edc->new_zone_option = current_zone_option; | 1244 | edc->new_zone_option = g_strdup (current_zone_option); |
1244 | edc->n_new_name = g_strdup (edc->n_name); | 1245 | edc->n_new_name = g_strdup (edc->n_name); |
1245 | edc->cont = &edit_dialog_continuation; | 1246 | edc->cont = &edit_dialog_continuation; |
1246 | switch (n_type) | 1247 | switch (n_type) |
@@ -1589,149 +1590,14 @@ void | |||
1589 | GNUNET_setup_gns_popup_edit_button_activate_cb (GtkWidget *widget, | 1590 | GNUNET_setup_gns_popup_edit_button_activate_cb (GtkWidget *widget, |
1590 | gpointer user_data) | 1591 | gpointer user_data) |
1591 | { | 1592 | { |
1593 | /* FIXME: not this easy! Row may still be a 'fresh' row! | ||
1594 | Need to check model to determine if argument should | ||
1595 | be YES or NO! */ | ||
1592 | edit_selected_row (GNUNET_YES); | 1596 | edit_selected_row (GNUNET_YES); |
1593 | } | 1597 | } |
1594 | 1598 | ||
1595 | 1599 | ||
1596 | /** | 1600 | /** |
1597 | * Function called upon completion of the calendar dialog. | ||
1598 | * | ||
1599 | * @param dialog the dialog | ||
1600 | * @param response_id reason for the dialog closing | ||
1601 | * @param user_data the 'GtkBuilder' we used to create the dialog | ||
1602 | */ | ||
1603 | void | ||
1604 | GNUNET_setup_calendar_dialog_response_cb (GtkDialog *dialog, | ||
1605 | gint response_id, | ||
1606 | gpointer user_data) | ||
1607 | { | ||
1608 | GtkBuilder *builder = user_data; | ||
1609 | guint year; | ||
1610 | guint month; | ||
1611 | guint day; | ||
1612 | GtkTreeIter it; | ||
1613 | GtkTreeIter parent; | ||
1614 | GtkCellRendererText *renderer; | ||
1615 | GtkTreeSelection *sel; | ||
1616 | gboolean has_parent; | ||
1617 | char *path; | ||
1618 | int not_dummy; | ||
1619 | char fancydate[128]; | ||
1620 | const char *gndate; | ||
1621 | struct GNUNET_TIME_Absolute atime; | ||
1622 | |||
1623 | if (GTK_RESPONSE_OK != response_id) | ||
1624 | { | ||
1625 | gtk_widget_destroy (GTK_WIDGET (dialog)); | ||
1626 | g_object_unref (G_OBJECT (builder)); | ||
1627 | return; | ||
1628 | } | ||
1629 | gtk_calendar_get_date (GTK_CALENDAR (gtk_builder_get_object (builder, | ||
1630 | "GNUNET_setup_calendar")), | ||
1631 | &year, &month, &day); | ||
1632 | GNUNET_snprintf (fancydate, | ||
1633 | sizeof (fancydate), | ||
1634 | "%u-%u-%u", | ||
1635 | (unsigned int) year, | ||
1636 | (unsigned int) month + 1, | ||
1637 | (unsigned int) day); | ||
1638 | GNUNET_break (GNUNET_OK == | ||
1639 | GNUNET_STRINGS_fancy_time_to_absolute (fancydate, | ||
1640 | &atime)); | ||
1641 | gndate = GNUNET_STRINGS_absolute_time_to_string (atime); | ||
1642 | sel = gtk_tree_view_get_selection (tv); | ||
1643 | if (gtk_tree_selection_get_selected (sel, NULL, &it)) | ||
1644 | { | ||
1645 | gtk_tree_model_get (tm, &it, | ||
1646 | GNS_TREESTORE_COL_NOT_DUMMY_ROW, ¬_dummy, | ||
1647 | -1); | ||
1648 | if (GNUNET_NO != not_dummy) | ||
1649 | { | ||
1650 | /* Has parent? */ | ||
1651 | has_parent = gtk_tree_model_iter_parent (tm, &parent, &it); | ||
1652 | if (FALSE != has_parent) | ||
1653 | { | ||
1654 | /* this is a single record */ | ||
1655 | renderer = GTK_CELL_RENDERER_TEXT((GNUNET_SETUP_get_object ("GNUNET_setup_gns_name_cellrenderertext"))); | ||
1656 | path = gtk_tree_model_get_string_from_iter (tm, &it); | ||
1657 | GNUNET_setup_gns_expiration_cellrenderertext_edited_cb (renderer, | ||
1658 | path, | ||
1659 | (gchar *) gndate, | ||
1660 | NULL); | ||
1661 | } | ||
1662 | } | ||
1663 | } | ||
1664 | gtk_widget_destroy (GTK_WIDGET (dialog)); | ||
1665 | g_object_unref (G_OBJECT (builder)); | ||
1666 | } | ||
1667 | |||
1668 | |||
1669 | /** | ||
1670 | * User selected the 'calendar' option in the expiration context menu. | ||
1671 | * Popup the calendar dialog and allow the user to select a date. | ||
1672 | * | ||
1673 | * @param widget unused | ||
1674 | * @param user_data unused | ||
1675 | */ | ||
1676 | void | ||
1677 | GNUNET_setup_gns_popup_cal_button_activate_cb (GtkWidget *widget, | ||
1678 | gpointer user_data) | ||
1679 | { | ||
1680 | GtkBuilder *builder; | ||
1681 | GtkWindow *dialog; | ||
1682 | GtkTreeSelection *sel; | ||
1683 | gboolean has_parent; | ||
1684 | int not_dummy; | ||
1685 | guint64 et; | ||
1686 | gboolean is_relative; | ||
1687 | GtkTreeIter it; | ||
1688 | GtkTreeIter parent; | ||
1689 | struct GNUNET_TIME_Absolute now; | ||
1690 | time_t tp; | ||
1691 | struct tm *ymd; | ||
1692 | |||
1693 | sel = gtk_tree_view_get_selection (tv); | ||
1694 | if (! gtk_tree_selection_get_selected (sel, NULL, &it)) | ||
1695 | return; | ||
1696 | gtk_tree_model_get (tm, &it, | ||
1697 | GNS_TREESTORE_COL_NOT_DUMMY_ROW, ¬_dummy, | ||
1698 | GNS_TREESTORE_COL_EXP_TIME_IS_REL, &is_relative, | ||
1699 | GNS_TREESTORE_COL_EXP_TIME, &et, | ||
1700 | -1); | ||
1701 | if (! not_dummy) | ||
1702 | return; | ||
1703 | has_parent = gtk_tree_model_iter_parent (tm, &parent, &it); | ||
1704 | if (! has_parent) | ||
1705 | return; | ||
1706 | now = GNUNET_TIME_absolute_get (); now = GNUNET_TIME_absolute_get (); | ||
1707 | if (is_relative) | ||
1708 | et = now.abs_value; /* use today as starting point */ | ||
1709 | if (et < now.abs_value) | ||
1710 | et = now.abs_value; /* no not allow starting point in the past */ | ||
1711 | tp = (time_t) (et / 1000LL); /* convert to seconds */ | ||
1712 | builder = | ||
1713 | GNUNET_GTK_get_new_builder ("gnunet_setup_calendar_dialog.glade", | ||
1714 | NULL); | ||
1715 | if (NULL == builder) | ||
1716 | { | ||
1717 | GNUNET_break (0); | ||
1718 | return; | ||
1719 | } | ||
1720 | ymd = gmtime (&tp); | ||
1721 | gtk_calendar_select_month (GTK_CALENDAR (gtk_builder_get_object (builder, | ||
1722 | "GNUNET_setup_calendar")), | ||
1723 | ymd->tm_mon, | ||
1724 | ymd->tm_year + 1900); | ||
1725 | gtk_calendar_mark_day (GTK_CALENDAR (gtk_builder_get_object (builder, | ||
1726 | "GNUNET_setup_calendar")), | ||
1727 | ymd->tm_mday); | ||
1728 | dialog = GTK_WINDOW (gtk_builder_get_object | ||
1729 | (builder, "GNUNET_setup_calendar_dialog")); | ||
1730 | gtk_window_present (dialog); | ||
1731 | } | ||
1732 | |||
1733 | |||
1734 | /** | ||
1735 | * A button was pressed in the GtkTreeView, check for right button and | 1601 | * A button was pressed in the GtkTreeView, check for right button and |
1736 | * if applicable create the popup menu. | 1602 | * if applicable create the popup menu. |
1737 | * | 1603 | * |