diff options
Diffstat (limited to 'src/fs/gnunet-fs-gtk-anonymity_spin_buttons.c')
-rw-r--r-- | src/fs/gnunet-fs-gtk-anonymity_spin_buttons.c | 71 |
1 files changed, 27 insertions, 44 deletions
diff --git a/src/fs/gnunet-fs-gtk-anonymity_spin_buttons.c b/src/fs/gnunet-fs-gtk-anonymity_spin_buttons.c index 94829429..6c22aa7b 100644 --- a/src/fs/gnunet-fs-gtk-anonymity_spin_buttons.c +++ b/src/fs/gnunet-fs-gtk-anonymity_spin_buttons.c | |||
@@ -24,6 +24,7 @@ | |||
24 | * @brief operations to manage user's anonymity level selections | 24 | * @brief operations to manage user's anonymity level selections |
25 | */ | 25 | */ |
26 | #include "gnunet-fs-gtk-common.h" | 26 | #include "gnunet-fs-gtk-common.h" |
27 | #include "gnunet-fs-gtk-anonymity_spin_buttons.h" | ||
27 | #include <gdk/gdk.h> | 28 | #include <gdk/gdk.h> |
28 | 29 | ||
29 | /** | 30 | /** |
@@ -71,33 +72,34 @@ GNUNET_GTK_anonymity_spin_button_value_changed_cb (GtkWidget * w, gpointer data) | |||
71 | } | 72 | } |
72 | 73 | ||
73 | 74 | ||
74 | 75 | /** | |
76 | * Obtain the numeric anonymity level selected by a GtkComboBox. | ||
77 | * | ||
78 | * @param builder builder for looking up widgets | ||
79 | * @param combo_name name of the GtkComboBox with the anonymity selection | ||
80 | * @param p_level where to store the anonymity level | ||
81 | * @return TRUE on success, FALSE on failure | ||
82 | */ | ||
75 | gboolean | 83 | gboolean |
76 | GNUNET_GTK_get_selected_anonymity_level (GtkBuilder * builder, | 84 | GNUNET_GTK_get_selected_anonymity_level (GtkBuilder * builder, |
77 | gchar * combo_name, guint * p_level) | 85 | gchar * combo_name, guint * p_level) |
78 | { | 86 | { |
79 | GtkComboBox *combo; | 87 | GtkComboBox *combo; |
80 | GtkTreeIter iter; | ||
81 | GtkTreeModel *model; | ||
82 | guint level; | ||
83 | 88 | ||
84 | combo = GTK_COMBO_BOX (gtk_builder_get_object (builder, combo_name)); | 89 | combo = GTK_COMBO_BOX (gtk_builder_get_object (builder, combo_name)); |
85 | if (!combo) | 90 | if (!combo) |
86 | return FALSE; | 91 | return FALSE; |
87 | 92 | return GNUNET_GTK_get_selected_anonymity_combo_level (combo, p_level); | |
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 | } | 93 | } |
100 | 94 | ||
95 | |||
96 | /** | ||
97 | * Obtain the numeric anonymity level selected by a GtkComboBox. | ||
98 | * | ||
99 | * @param combo the GtkComboBox with the anonymity selection | ||
100 | * @param p_level where to store the anonymity level | ||
101 | * @return TRUE on success, FALSE on failure | ||
102 | */ | ||
101 | gboolean | 103 | gboolean |
102 | GNUNET_GTK_get_selected_anonymity_combo_level (GtkComboBox *combo, guint *p_level) | 104 | GNUNET_GTK_get_selected_anonymity_combo_level (GtkComboBox *combo, guint *p_level) |
103 | { | 105 | { |
@@ -105,64 +107,44 @@ GNUNET_GTK_get_selected_anonymity_combo_level (GtkComboBox *combo, guint *p_leve | |||
105 | GtkTreeModel *model; | 107 | GtkTreeModel *model; |
106 | guint level; | 108 | guint level; |
107 | 109 | ||
108 | if (!gtk_combo_box_get_active_iter (combo, &iter)) | 110 | if (! gtk_combo_box_get_active_iter (combo, &iter)) |
109 | return FALSE; | 111 | return FALSE; |
110 | |||
111 | model = gtk_combo_box_get_model (combo); | 112 | model = gtk_combo_box_get_model (combo); |
112 | if (!model) | 113 | if (!model) |
113 | return FALSE; | 114 | return FALSE; |
114 | |||
115 | gtk_tree_model_get (model, &iter, 1, &level, -1); | 115 | gtk_tree_model_get (model, &iter, 1, &level, -1); |
116 | if (p_level) | 116 | if (p_level) |
117 | *p_level = level; | 117 | *p_level = level; |
118 | return TRUE; | 118 | return TRUE; |
119 | } | 119 | } |
120 | 120 | ||
121 | |||
121 | gboolean | 122 | gboolean |
122 | GNUNET_GTK_select_anonymity_level (GtkBuilder * builder, gchar * combo_name, | 123 | GNUNET_GTK_select_anonymity_level (GtkBuilder * builder, gchar * combo_name, |
123 | guint sel_level) | 124 | guint sel_level) |
124 | { | 125 | { |
125 | GtkComboBox *combo; | 126 | GtkComboBox *combo; |
126 | GtkTreeIter iter; | ||
127 | GtkTreeModel *model; | ||
128 | guint level; | ||
129 | gboolean go_on; | ||
130 | 127 | ||
131 | combo = GTK_COMBO_BOX (gtk_builder_get_object (builder, combo_name)); | 128 | combo = GTK_COMBO_BOX (gtk_builder_get_object (builder, combo_name)); |
132 | if (!combo) | 129 | if (!combo) |
133 | return FALSE; | 130 | return FALSE; |
134 | 131 | return GNUNET_GTK_select_anonymity_combo_level (combo, sel_level); | |
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 | } | 132 | } |
151 | 133 | ||
134 | |||
152 | gboolean | 135 | gboolean |
153 | GNUNET_GTK_select_anonymity_combo_level (GtkComboBox *combo, guint sel_level) | 136 | GNUNET_GTK_select_anonymity_combo_level (GtkComboBox *combo, guint sel_level) |
154 | { | 137 | { |
155 | GtkTreeIter iter; | 138 | GtkTreeIter iter; |
156 | GtkTreeModel *model; | 139 | GtkTreeModel *model; |
157 | guint level; | 140 | guint level; |
158 | gboolean go_on; | ||
159 | 141 | ||
160 | model = gtk_combo_box_get_model (combo); | 142 | model = gtk_combo_box_get_model (combo); |
161 | if (!model) | 143 | if (!model) |
162 | return FALSE; | 144 | return FALSE; |
163 | 145 | if (! gtk_tree_model_get_iter_first (model, &iter)) | |
164 | for (go_on = gtk_tree_model_get_iter_first (model, &iter); go_on; | 146 | return FALSE; |
165 | go_on = gtk_tree_model_iter_next (model, &iter)) | 147 | do |
166 | { | 148 | { |
167 | gtk_tree_model_get (model, &iter, 1, &level, -1); | 149 | gtk_tree_model_get (model, &iter, 1, &level, -1); |
168 | if (level == sel_level) | 150 | if (level == sel_level) |
@@ -170,7 +152,8 @@ GNUNET_GTK_select_anonymity_combo_level (GtkComboBox *combo, guint sel_level) | |||
170 | gtk_combo_box_set_active_iter (combo, &iter); | 152 | gtk_combo_box_set_active_iter (combo, &iter); |
171 | return TRUE; | 153 | return TRUE; |
172 | } | 154 | } |
173 | } | 155 | } |
156 | while (gtk_tree_model_iter_next (model, &iter)); | ||
174 | return FALSE; | 157 | return FALSE; |
175 | } | 158 | } |
176 | 159 | ||