[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25211 - gnunet-gtk/src/setup
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25211 - gnunet-gtk/src/setup |
Date: |
Tue, 4 Dec 2012 09:54:30 +0100 |
Author: grothoff
Date: 2012-12-04 09:54:30 +0100 (Tue, 04 Dec 2012)
New Revision: 25211
Modified:
gnunet-gtk/src/setup/gnunet-setup-gns-edit.c
gnunet-gtk/src/setup/gnunet-setup-gns-edit.h
gnunet-gtk/src/setup/gnunet-setup-gns.c
Log:
-towards editing absolute expiration times
Modified: gnunet-gtk/src/setup/gnunet-setup-gns-edit.c
===================================================================
--- gnunet-gtk/src/setup/gnunet-setup-gns-edit.c 2012-12-04 08:42:07 UTC
(rev 25210)
+++ gnunet-gtk/src/setup/gnunet-setup-gns-edit.c 2012-12-04 08:54:30 UTC
(rev 25211)
@@ -190,6 +190,12 @@
static void
edit_dialog_setup_common_elements (struct EditDialogContext *edc)
{
+ GtkComboBox *cb;
+ GtkTreeModel *tm;
+ GtkListStore *ls;
+ GtkTreeIter iter;
+ gchar *opt;
+
if (GNUNET_YES !=
edc->old_record_in_namestore)
{
@@ -223,9 +229,6 @@
if (edc->n_is_relative)
{
struct GNUNET_TIME_Relative rt;
- GtkComboBox *cb;
- GtkListStore *ls;
- GtkTreeIter iter;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object
(edc->builder,
"edit_dialog_expiration_relative_radiobutton")),
@@ -324,7 +327,7 @@
GtkComboBox *cb;
GtkTreeModel *tm;
GtkTreeIter iter;
- gchararray *opt;
+ gchar *opt;
/* record name */
entry = GTK_ENTRY (gtk_builder_get_object (edc->builder,
@@ -373,9 +376,38 @@
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object
(edc->builder,
"edit_dialog_expiration_absolute_radiobutton"))))
{
- /* FIXME: implement! */
-
- GNUNET_break (0);
+ guint year;
+ guint month;
+ guint day;
+ guint hour;
+ guint minute;
+ guint second;
+ char fancydate[128];
+ struct GNUNET_TIME_Absolute atime;
+
+ gtk_calendar_get_date (GTK_CALENDAR (gtk_builder_get_object (edc->builder,
+
"edit_dialog_expiration_absolute_calendar")),
+ &year, &month, &day);
+ hour = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object
(edc->builder,
+
"edit_dialog_expiration_absolute_hours_spinbutton")));
+ minute = gtk_spin_button_get_value (GTK_SPIN_BUTTON
(gtk_builder_get_object (edc->builder,
+
"edit_dialog_expiration_absolute_minutes_spinbutton")));
+ second = gtk_spin_button_get_value (GTK_SPIN_BUTTON
(gtk_builder_get_object (edc->builder,
+
"edit_dialog_expiration_absolute_seconds_spinbutton")));
+ GNUNET_snprintf (fancydate,
+ sizeof (fancydate),
+ "%u-%u-%u %u:%u:%u",
+ (unsigned int) year,
+ (unsigned int) month + 1,
+ (unsigned int) day,
+ (unsigned int) hour,
+ (unsigned int) minute,
+ (unsigned int) second);
+ GNUNET_break (GNUNET_OK ==
+ GNUNET_STRINGS_fancy_time_to_absolute (fancydate,
+ &atime));
+ edc->n_exp_time = atime.abs_value;
+ edc->n_is_relative = FALSE;
}
/* extract target zone! */
@@ -395,8 +427,8 @@
GNUNET_break (0);
else
{
- GNUNET_free (edc->new_zone_option);
- edc->new_zone_option = GNUNET_strdup (opt);
+ g_free (edc->new_zone_option);
+ edc->new_zone_option = g_strdup (opt);
g_free (opt);
}
}
Modified: gnunet-gtk/src/setup/gnunet-setup-gns-edit.h
===================================================================
--- gnunet-gtk/src/setup/gnunet-setup-gns-edit.h 2012-12-04 08:42:07 UTC
(rev 25210)
+++ gnunet-gtk/src/setup/gnunet-setup-gns-edit.h 2012-12-04 08:54:30 UTC
(rev 25211)
@@ -112,7 +112,7 @@
/**
* Zone into which the record should be placed.
*/
- const char *new_zone_option;
+ gchar *new_zone_option;
/**
* Flag indicating if the old record was in the namestore.
Modified: gnunet-gtk/src/setup/gnunet-setup-gns.c
===================================================================
--- gnunet-gtk/src/setup/gnunet-setup-gns.c 2012-12-04 08:42:07 UTC (rev
25210)
+++ gnunet-gtk/src/setup/gnunet-setup-gns.c 2012-12-04 08:54:30 UTC (rev
25211)
@@ -1201,6 +1201,7 @@
g_free (edc->n_name);
g_free (edc->n_new_name);
g_free (edc->n_value);
+ g_free (edc->new_zone_option);
GNUNET_free (edc);
}
@@ -1240,7 +1241,7 @@
GNS_TREESTORE_COL_VAL_AS_STR, &edc->n_value,
-1);
edc->old_record_in_namestore = old_record_in_namestore;
- edc->new_zone_option = current_zone_option;
+ edc->new_zone_option = g_strdup (current_zone_option);
edc->n_new_name = g_strdup (edc->n_name);
edc->cont = &edit_dialog_continuation;
switch (n_type)
@@ -1589,149 +1590,14 @@
GNUNET_setup_gns_popup_edit_button_activate_cb (GtkWidget *widget,
gpointer user_data)
{
+ /* FIXME: not this easy! Row may still be a 'fresh' row!
+ Need to check model to determine if argument should
+ be YES or NO! */
edit_selected_row (GNUNET_YES);
}
/**
- * Function called upon completion of the calendar dialog.
- *
- * @param dialog the dialog
- * @param response_id reason for the dialog closing
- * @param user_data the 'GtkBuilder' we used to create the dialog
- */
-void
-GNUNET_setup_calendar_dialog_response_cb (GtkDialog *dialog,
- gint response_id,
- gpointer user_data)
-{
- GtkBuilder *builder = user_data;
- guint year;
- guint month;
- guint day;
- GtkTreeIter it;
- GtkTreeIter parent;
- GtkCellRendererText *renderer;
- GtkTreeSelection *sel;
- gboolean has_parent;
- char *path;
- int not_dummy;
- char fancydate[128];
- const char *gndate;
- struct GNUNET_TIME_Absolute atime;
-
- if (GTK_RESPONSE_OK != response_id)
- {
- gtk_widget_destroy (GTK_WIDGET (dialog));
- g_object_unref (G_OBJECT (builder));
- return;
- }
- gtk_calendar_get_date (GTK_CALENDAR (gtk_builder_get_object (builder,
-
"GNUNET_setup_calendar")),
- &year, &month, &day);
- GNUNET_snprintf (fancydate,
- sizeof (fancydate),
- "%u-%u-%u",
- (unsigned int) year,
- (unsigned int) month + 1,
- (unsigned int) day);
- GNUNET_break (GNUNET_OK ==
- GNUNET_STRINGS_fancy_time_to_absolute (fancydate,
- &atime));
- gndate = GNUNET_STRINGS_absolute_time_to_string (atime);
- sel = gtk_tree_view_get_selection (tv);
- if (gtk_tree_selection_get_selected (sel, NULL, &it))
- {
- gtk_tree_model_get (tm, &it,
- GNS_TREESTORE_COL_NOT_DUMMY_ROW, ¬_dummy,
- -1);
- if (GNUNET_NO != not_dummy)
- {
- /* Has parent? */
- has_parent = gtk_tree_model_iter_parent (tm, &parent, &it);
- if (FALSE != has_parent)
- {
- /* this is a single record */
- renderer = GTK_CELL_RENDERER_TEXT((GNUNET_SETUP_get_object
("GNUNET_setup_gns_name_cellrenderertext")));
- path = gtk_tree_model_get_string_from_iter (tm, &it);
- GNUNET_setup_gns_expiration_cellrenderertext_edited_cb (renderer,
- path,
- (gchar *)
gndate,
- NULL);
- }
- }
- }
- gtk_widget_destroy (GTK_WIDGET (dialog));
- g_object_unref (G_OBJECT (builder));
-}
-
-
-/**
- * User selected the 'calendar' option in the expiration context menu.
- * Popup the calendar dialog and allow the user to select a date.
- *
- * @param widget unused
- * @param user_data unused
- */
-void
-GNUNET_setup_gns_popup_cal_button_activate_cb (GtkWidget *widget,
- gpointer user_data)
-{
- GtkBuilder *builder;
- GtkWindow *dialog;
- GtkTreeSelection *sel;
- gboolean has_parent;
- int not_dummy;
- guint64 et;
- gboolean is_relative;
- GtkTreeIter it;
- GtkTreeIter parent;
- struct GNUNET_TIME_Absolute now;
- time_t tp;
- struct tm *ymd;
-
- sel = gtk_tree_view_get_selection (tv);
- if (! gtk_tree_selection_get_selected (sel, NULL, &it))
- return;
- gtk_tree_model_get (tm, &it,
- GNS_TREESTORE_COL_NOT_DUMMY_ROW, ¬_dummy,
- GNS_TREESTORE_COL_EXP_TIME_IS_REL, &is_relative,
- GNS_TREESTORE_COL_EXP_TIME, &et,
- -1);
- if (! not_dummy)
- return;
- has_parent = gtk_tree_model_iter_parent (tm, &parent, &it);
- if (! has_parent)
- return;
- now = GNUNET_TIME_absolute_get (); now = GNUNET_TIME_absolute_get ();
- if (is_relative)
- et = now.abs_value; /* use today as starting point */
- if (et < now.abs_value)
- et = now.abs_value; /* no not allow starting point in the past */
- tp = (time_t) (et / 1000LL); /* convert to seconds */
- builder =
- GNUNET_GTK_get_new_builder ("gnunet_setup_calendar_dialog.glade",
- NULL);
- if (NULL == builder)
- {
- GNUNET_break (0);
- return;
- }
- ymd = gmtime (&tp);
- gtk_calendar_select_month (GTK_CALENDAR (gtk_builder_get_object (builder,
-
"GNUNET_setup_calendar")),
- ymd->tm_mon,
- ymd->tm_year + 1900);
- gtk_calendar_mark_day (GTK_CALENDAR (gtk_builder_get_object (builder,
-
"GNUNET_setup_calendar")),
- ymd->tm_mday);
- dialog = GTK_WINDOW (gtk_builder_get_object
- (builder, "GNUNET_setup_calendar_dialog"));
- gtk_window_present (dialog);
-}
-
-
-/**
* A button was pressed in the GtkTreeView, check for right button and
* if applicable create the popup menu.
*
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25211 - gnunet-gtk/src/setup,
gnunet <=