[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25207 - in gnunet-gtk: contrib src/setup
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25207 - in gnunet-gtk: contrib src/setup |
Date: |
Mon, 3 Dec 2012 20:54:53 +0100 |
Author: grothoff
Date: 2012-12-03 20:54:53 +0100 (Mon, 03 Dec 2012)
New Revision: 25207
Modified:
gnunet-gtk/contrib/gnunet_setup_gns_edit_a.glade
gnunet-gtk/src/setup/gnunet-setup-gns-edit.c
Log:
-simplify expiration editing for now
Modified: gnunet-gtk/contrib/gnunet_setup_gns_edit_a.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_setup_gns_edit_a.glade 2012-12-03 19:02:19 UTC
(rev 25206)
+++ gnunet-gtk/contrib/gnunet_setup_gns_edit_a.glade 2012-12-03 19:54:53 UTC
(rev 25207)
@@ -528,12 +528,15 @@
<object class="GtkComboBox"
id="edit_dialog_expiration_relative_combobox">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="tooltip_text"
translatable="yes">Relative expiration time of the record. The syntax is a
number followed by a space and a time unit, possibly followed by additional
numbers and time units. For example, you can specify "1 d" or "6 h 30 m 15 s".
Use the drop-down menu to select from a set of common defaults.</property>
+ <property name="tooltip_text"
translatable="yes">Relative expiration time of the record. The syntax is a
number followed by a space and a time unit, possibly followed by additional
numbers and time units. For example, you can specify "1 d" or "6 h 30 m 15 s".
Use the drop-down menu to select from a set of common defaults. (Editing is not
possible right now as Gtk2 and Gtk3 use incompatible ways for doing this.)
</property>
<property
name="model">edit_dialog_expiration_relative_liststore</property>
- <property name="has_entry">True</property>
<property name="entry_text_column">0</property>
- <signal name="changed"
handler="GNS_edit_dialog_expiration_relative_combobox_changed_cb" swapped="no"/>
- <signal name="editing-done"
handler="GNS_edit_dialog_expiration_relative_combobox_editing_done_cb"
swapped="no"/>
+ <child>
+ <object class="GtkCellRendererText"
id="edit_dialog_expiration_relative_combobox_cellrenderertext"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
</object>
<packing>
<property name="expand">True</property>
Modified: gnunet-gtk/src/setup/gnunet-setup-gns-edit.c
===================================================================
--- gnunet-gtk/src/setup/gnunet-setup-gns-edit.c 2012-12-03 19:02:19 UTC
(rev 25206)
+++ gnunet-gtk/src/setup/gnunet-setup-gns-edit.c 2012-12-03 19:54:53 UTC
(rev 25207)
@@ -99,42 +99,6 @@
/**
- * The user has changed the relative expiration time.
- *
- * @param widget the combo box
- * @param user_data the 'struct EditDialogContext' of the dialog
- */
-void
-GNS_edit_dialog_expiration_relative_combobox_changed_cb (GtkComboBox *widget,
- gpointer user_data)
-{
- struct EditDialogContext *edc = user_data;
-
- /* not sure if we need to do anything here */
- // FIXME
- GNUNET_break (0);
-}
-
-
-/**
- * The user finished adding an expiration value from hand. Add
- * it to the model and select it -- if it is a valid value.
- *
- * @param cell_editable the changed cell
- * @param user_data the 'struct EditDialogContext' of the dialog
- */
-void
-GNS_edit_dialog_expiration_relative_combobox_editing_done_cb (GtkCellEditable
*cell_editable,
- gpointer
user_data)
-{
- struct EditDialogContext *edc = user_data;
-
- // FIXME
- GNUNET_break (0);
-}
-
-
-/**
* The 'relative' expiration time radiobutton was toggled (on or off).
*
* @param button the button
@@ -225,7 +189,6 @@
edc->n_is_shadow);
if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value == edc->n_exp_time)
{
- fprintf (stderr, "forever\n");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object
(edc->builder,
"edit_dialog_expiration_never_radiobutton")),
TRUE);
@@ -241,8 +204,10 @@
if (edc->n_is_relative)
{
struct GNUNET_TIME_Relative rt;
+ GtkComboBox *cb;
+ GtkListStore *ls;
+ GtkTreeIter iter;
- fprintf (stderr, "relative\n");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object
(edc->builder,
"edit_dialog_expiration_relative_radiobutton")),
TRUE);
@@ -251,13 +216,15 @@
gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
"edit_dialog_expiration_absolute_hbox")));
rt.rel_value = edc->n_exp_time;
-#if 0
- /* FIXME: gtk_combo_box_set_text does not exist, we need to
- update the model and then select the respective element... */
- gtk_combo_box_set_text (GTK_ENTRY (gtk_builder_get_object (edc->builder,
-
"edit_dialog_expiration_relative_combobox")),
- GNUNET_STRINGS_relative_time_to_string (rt,
GNUNET_NO));
-#endif
+
+ cb = GTK_COMBO_BOX (gtk_builder_get_object (edc->builder,
+
"edit_dialog_expiration_relative_combobox"));
+ ls = GTK_LIST_STORE (gtk_combo_box_get_model (cb));
+ gtk_list_store_insert_with_values (ls, &iter,
+ -1 /* position: append */,
+ 0,
GNUNET_STRINGS_relative_time_to_string (rt, GNUNET_NO),
+ -1);
+ gtk_combo_box_set_active_iter (cb, &iter);
}
else
{
@@ -266,7 +233,6 @@
struct tm *ymd;
GtkCalendar *cal;
- fprintf (stderr, "absolute\n");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object
(edc->builder,
"edit_dialog_expiration_absolute_radiobutton")),
TRUE);
@@ -298,6 +264,76 @@
/**
+ * Perform the reverse of the 'edit_dialog_setup_common_elements' function,
+ * that is, extract the values from the (common) widgets and store the
+ * values in 'edc'.
+ *
+ * @param edc edit dialog to extract data from
+ */
+static void
+edit_dialog_putes_common_elements (struct EditDialogContext *edc)
+{
+ GtkEntry *entry;
+ const char *rt_s;
+ struct GNUNET_TIME_Relative rt;
+ GtkComboBox *cb;
+ GtkTreeModel *tm;
+ GtkTreeIter iter;
+
+ /* record name */
+ entry = GTK_ENTRY (gtk_builder_get_object (edc->builder,
+ "edit_dialog_name_entry"));
+ g_free (edc->n_new_name);
+ edc->n_new_name = g_strdup (gtk_entry_get_text (entry));
+
+ /* is public flag */
+ edc->n_public = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
(gtk_builder_get_object (edc->builder,
+
"edit_dialog_options_public_checkbutton")));
+ /* is shadow flag */
+ edc->n_is_shadow = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
(gtk_builder_get_object (edc->builder,
+
"edit_dialog_options_shadow_checkbutton")));
+
+ /* 'forever' expiration time */
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object
(edc->builder,
+
"edit_dialog_expiration_never_radiobutton"))))
+ {
+ edc->n_exp_time = GNUNET_TIME_UNIT_FOREVER_REL.rel_value;
+ edc->n_is_relative = TRUE; /* doesn't matter, but make sure it is
well-defined anyway */
+ }
+
+ /* 'relative' expiration time */
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object
(edc->builder,
+
"edit_dialog_expiration_relative_radiobutton"))))
+ {
+ cb = GTK_COMBO_BOX (gtk_builder_get_object (edc->builder,
+
"edit_dialog_expiration_relative_combobox"));
+ tm = gtk_combo_box_get_model (cb);
+ if (TRUE != gtk_combo_box_get_active_iter (cb, &iter))
+ {
+ GNUNET_break (0);
+ return;
+ }
+ gtk_tree_model_get (tm, &iter,
+ 0, &rt_s,
+ -1);
+ GNUNET_break (GNUNET_YES ==
+ GNUNET_STRINGS_fancy_time_to_relative (rt_s,
+ &rt));
+ edc->n_exp_time = rt.rel_value;
+ edc->n_is_relative = TRUE;
+ }
+
+ /* 'absolute' expiration time */
+ 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);
+ }
+}
+
+
+/**
* Run the edit dialog. Performs all of the common initialization
* steps to run an edit dialog for records.
*
@@ -307,8 +343,6 @@
run_edit_dialog (struct EditDialogContext *edc)
{
edit_dialog_setup_common_elements (edc);
- edc->dialog = GTK_DIALOG (gtk_builder_get_object (edc->builder,
- "edit_a_dialog"));
gtk_dialog_set_default_response (edc->dialog,
GTK_RESPONSE_OK);
gtk_window_present (GTK_WINDOW (edc->dialog));
@@ -356,9 +390,18 @@
gpointer user_data)
{
struct EditDialogContext *edc = user_data;
-
- fprintf (stderr, "response CB %d!\n", response_id);
- /* FIXME: resync dialog elements back into 'edc'! */
+ GtkEntry *entry;
+ const gchar *value;
+
+ if (GTK_RESPONSE_OK == response_id)
+ {
+ edit_dialog_putes_common_elements (edc);
+ entry = GTK_ENTRY (gtk_builder_get_object (edc->builder,
+ "edit_dialog_a_entry"));
+ value = gtk_entry_get_text (entry);
+ g_free (edc->n_value);
+ edc->n_value = g_strdup (value);
+ }
gtk_widget_destroy (GTK_WIDGET (edc->dialog));
g_object_unref (edc->builder);
edc->builder = NULL;
@@ -410,6 +453,8 @@
edc->n_value);
}
edc->validator = &edit_dialog_a_validity_check;
+ edc->dialog = GTK_DIALOG (gtk_builder_get_object (edc->builder,
+ "edit_a_dialog"));
run_edit_dialog (edc);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25207 - in gnunet-gtk: contrib src/setup,
gnunet <=