aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-fs-gtk-anonymity_spin_buttons.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/gnunet-fs-gtk-anonymity_spin_buttons.c')
-rw-r--r--src/fs/gnunet-fs-gtk-anonymity_spin_buttons.c115
1 files changed, 111 insertions, 4 deletions
diff --git a/src/fs/gnunet-fs-gtk-anonymity_spin_buttons.c b/src/fs/gnunet-fs-gtk-anonymity_spin_buttons.c
index bf53e859..94829429 100644
--- a/src/fs/gnunet-fs-gtk-anonymity_spin_buttons.c
+++ b/src/fs/gnunet-fs-gtk-anonymity_spin_buttons.c
@@ -21,15 +21,17 @@
21/** 21/**
22 * @file src/fs/gnunet-fs-gtk-anonymtiy_spin_buttons.c 22 * @file src/fs/gnunet-fs-gtk-anonymtiy_spin_buttons.c
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 * 24 * @brief operations to manage user's anonymity level selections
25 * This file contains callbacks to turn spin buttons red when the
26 * value reaches zero.
27 */ 25 */
28#include "gnunet-fs-gtk-common.h" 26#include "gnunet-fs-gtk-common.h"
29#include <gdk/gdk.h> 27#include <gdk/gdk.h>
30 28
31/** 29/**
32 * Spin button is changed, update its colour. 30 * Spin button is changed, update its color. NOTE: This function will eventually
31 * become obsolete as we migrate to the drop-down style of anonymity-level selection.
32 *
33 * @param w the spin button that changed
34 * @param builder's closure, unused
33 */ 35 */
34void 36void
35GNUNET_GTK_anonymity_spin_button_value_changed_cb (GtkWidget * w, gpointer data) 37GNUNET_GTK_anonymity_spin_button_value_changed_cb (GtkWidget * w, gpointer data)
@@ -69,4 +71,109 @@ GNUNET_GTK_anonymity_spin_button_value_changed_cb (GtkWidget * w, gpointer data)
69} 71}
70 72
71 73
74
75gboolean
76GNUNET_GTK_get_selected_anonymity_level (GtkBuilder * builder,
77 gchar * combo_name, guint * p_level)
78{
79 GtkComboBox *combo;
80 GtkTreeIter iter;
81 GtkTreeModel *model;
82 guint level;
83
84 combo = GTK_COMBO_BOX (gtk_builder_get_object (builder, combo_name));
85 if (!combo)
86 return FALSE;
87
88 if (!gtk_combo_box_get_active_iter (combo, &iter))
89 return FALSE;
90
91 model = gtk_combo_box_get_model (combo);
92 if (!model)
93 return FALSE;
94
95 gtk_tree_model_get (model, &iter, 1, &level, -1);
96 if (p_level)
97 *p_level = level;
98 return TRUE;
99}
100
101gboolean
102GNUNET_GTK_get_selected_anonymity_combo_level (GtkComboBox *combo, guint *p_level)
103{
104 GtkTreeIter iter;
105 GtkTreeModel *model;
106 guint level;
107
108 if (!gtk_combo_box_get_active_iter (combo, &iter))
109 return FALSE;
110
111 model = gtk_combo_box_get_model (combo);
112 if (!model)
113 return FALSE;
114
115 gtk_tree_model_get (model, &iter, 1, &level, -1);
116 if (p_level)
117 *p_level = level;
118 return TRUE;
119}
120
121gboolean
122GNUNET_GTK_select_anonymity_level (GtkBuilder * builder, gchar * combo_name,
123 guint sel_level)
124{
125 GtkComboBox *combo;
126 GtkTreeIter iter;
127 GtkTreeModel *model;
128 guint level;
129 gboolean go_on;
130
131 combo = GTK_COMBO_BOX (gtk_builder_get_object (builder, combo_name));
132 if (!combo)
133 return FALSE;
134
135 model = gtk_combo_box_get_model (combo);
136 if (!model)
137 return FALSE;
138
139 for (go_on = gtk_tree_model_get_iter_first (model, &iter); go_on;
140 go_on = gtk_tree_model_iter_next (model, &iter))
141 {
142 gtk_tree_model_get (model, &iter, 1, &level, -1);
143 if (level == sel_level)
144 {
145 gtk_combo_box_set_active_iter (combo, &iter);
146 return TRUE;
147 }
148 }
149 return FALSE;
150}
151
152gboolean
153GNUNET_GTK_select_anonymity_combo_level (GtkComboBox *combo, guint sel_level)
154{
155 GtkTreeIter iter;
156 GtkTreeModel *model;
157 guint level;
158 gboolean go_on;
159
160 model = gtk_combo_box_get_model (combo);
161 if (!model)
162 return FALSE;
163
164 for (go_on = gtk_tree_model_get_iter_first (model, &iter); go_on;
165 go_on = gtk_tree_model_iter_next (model, &iter))
166 {
167 gtk_tree_model_get (model, &iter, 1, &level, -1);
168 if (level == sel_level)
169 {
170 gtk_combo_box_set_active_iter (combo, &iter);
171 return TRUE;
172 }
173 }
174 return FALSE;
175}
176
177
178
72/* end of gnunet-fs-gtk-anonymtiy_spin_buttons.c */ 179/* end of gnunet-fs-gtk-anonymtiy_spin_buttons.c */