aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-03-05 00:36:22 +0000
committerChristian Grothoff <christian@grothoff.org>2012-03-05 00:36:22 +0000
commit460b3ca16d05a8529579fa2b30a1fc4e91da6509 (patch)
tree87518a3af60b514ffb2172e58ffc8bd266e34630
parentd0e22a6ee4d161fa73ef02ca2d91763acfd0d5c1 (diff)
downloadgnunet-gtk-460b3ca16d05a8529579fa2b30a1fc4e91da6509.tar.gz
gnunet-gtk-460b3ca16d05a8529579fa2b30a1fc4e91da6509.zip
-fixing various bugs, including signal handler signatures, also finally enabling probes #2150
-rw-r--r--contrib/gnunet_fs_gtk_main_window.glade12
-rw-r--r--contrib/gnunet_fs_gtk_search_tab.glade2
-rw-r--r--src/fs/gnunet-fs-gtk.c66
-rw-r--r--src/fs/gnunet-fs-gtk_event-handler.c12
4 files changed, 69 insertions, 23 deletions
diff --git a/contrib/gnunet_fs_gtk_main_window.glade b/contrib/gnunet_fs_gtk_main_window.glade
index 4bd06cc9..3186c010 100644
--- a/contrib/gnunet_fs_gtk_main_window.glade
+++ b/contrib/gnunet_fs_gtk_main_window.glade
@@ -161,7 +161,9 @@
161 <property name="default_width">700</property> 161 <property name="default_width">700</property>
162 <property name="default_height">500</property> 162 <property name="default_height">500</property>
163 <property name="icon_name">gnunet-gtk</property> 163 <property name="icon_name">gnunet-gtk</property>
164 <signal name="delete_event" handler="GNUNET_GTK_quit_cb" after="yes"/> 164 <signal name="size_request" handler="GNUNET_FS_GTK_main_window_size_request"/>
165 <signal name="drag_end" handler="GNUNET_FS_GTK_main_window_drag_end"/>
166 <signal name="delete_event" handler="GNUNET_FS_GTK_delete_event_cb" after="yes"/>
165 <child> 167 <child>
166 <object class="GtkVBox" id="GNUNET_GTK_main_window_vbox"> 168 <object class="GtkVBox" id="GNUNET_GTK_main_window_vbox">
167 <property name="visible">True</property> 169 <property name="visible">True</property>
@@ -271,7 +273,7 @@
271 <property name="use_underline">True</property> 273 <property name="use_underline">True</property>
272 <property name="use_stock">True</property> 274 <property name="use_stock">True</property>
273 <accelerator key="q" signal="activate" modifiers="GDK_CONTROL_MASK"/> 275 <accelerator key="q" signal="activate" modifiers="GDK_CONTROL_MASK"/>
274 <signal name="activate" handler="GNUNET_GTK_quit_cb"/> 276 <signal name="activate" handler="GNUNET_FS_GTK_menu_quit_activate_cb"/>
275 </object> 277 </object>
276 </child> 278 </child>
277 </object> 279 </object>
@@ -813,8 +815,6 @@
813 </child> 815 </child>
814 </object> 816 </object>
815 <packing> 817 <packing>
816 <property name="expand">True</property>
817 <property name="fill">True</property>
818 <property name="position">0</property> 818 <property name="position">0</property>
819 </packing> 819 </packing>
820 </child> 820 </child>
@@ -851,9 +851,9 @@
851 <object class="GtkSizeGroup" id="enties_and_comboboxes_sizegroup"> 851 <object class="GtkSizeGroup" id="enties_and_comboboxes_sizegroup">
852 <property name="mode">vertical</property> 852 <property name="mode">vertical</property>
853 <widgets> 853 <widgets>
854 <widget name="main_window_search_mime_combobox"/>
855 <widget name="main_window_search_anonymity_combobox"/>
856 <widget name="main_window_search_entry"/> 854 <widget name="main_window_search_entry"/>
855 <widget name="main_window_search_anonymity_combobox"/>
856 <widget name="main_window_search_mime_combobox"/>
857 </widgets> 857 </widgets>
858 </object> 858 </object>
859 <object class="GtkAdjustment" id="expiration_year_adjustment"> 859 <object class="GtkAdjustment" id="expiration_year_adjustment">
diff --git a/contrib/gnunet_fs_gtk_search_tab.glade b/contrib/gnunet_fs_gtk_search_tab.glade
index aa08da4c..036d9ec4 100644
--- a/contrib/gnunet_fs_gtk_search_tab.glade
+++ b/contrib/gnunet_fs_gtk_search_tab.glade
@@ -88,7 +88,7 @@
88 <object class="GtkTreeViewColumn" id="search_result_availability_column"> 88 <object class="GtkTreeViewColumn" id="search_result_availability_column">
89 <property name="title">Availability</property> 89 <property name="title">Availability</property>
90 <property name="clickable">True</property> 90 <property name="clickable">True</property>
91 <property name="visible">False</property> 91 <property name="visible">True</property>
92 <property name="reorderable">True</property> 92 <property name="reorderable">True</property>
93 <property name="sort_indicator">True</property> 93 <property name="sort_indicator">True</property>
94 <property name="sort_column_id">5</property> 94 <property name="sort_column_id">5</property>
diff --git a/src/fs/gnunet-fs-gtk.c b/src/fs/gnunet-fs-gtk.c
index 415f142c..b44b970c 100644
--- a/src/fs/gnunet-fs-gtk.c
+++ b/src/fs/gnunet-fs-gtk.c
@@ -110,7 +110,7 @@ GNUNET_FS_GTK_get_anonymity_level_list_store ()
110 * 110 *
111 * @param main_window main window widget 111 * @param main_window main window widget
112 */ 112 */
113static void 113void
114main_window_save_position (GtkWidget *main_window) 114main_window_save_position (GtkWidget *main_window)
115{ 115{
116 GdkWindow *main_window_gdk; 116 GdkWindow *main_window_gdk;
@@ -157,6 +157,40 @@ main_window_save_position (GtkWidget *main_window)
157 157
158 158
159/** 159/**
160 * Obtains main window position and size before it's destroyed
161 * and saves these into user's config file.
162 *
163 * @param main_window main window widget
164 */
165void
166GNUNET_FS_GTK_main_window_drag_end (GtkWidget *main_window,
167 GdkDragContext *drag_context,
168 gpointer user_data)
169{
170 struct GNUNET_GTK_MainWindowContext *main_context = user_data;
171
172 main_window_save_position (main_context->main_window);
173}
174
175
176/**
177 * Obtains main window position and size before it's destroyed
178 * and saves these into user's config file.
179 *
180 * @param main_window main window widget
181 */
182void
183GNUNET_FS_GTK_main_window_size_request (GtkWidget *main_window,
184 GtkRequisition *requisition,
185 gpointer user_data)
186{
187 struct GNUNET_GTK_MainWindowContext *main_context = user_data;
188
189 main_window_save_position (main_context->main_window);
190}
191
192
193/**
160 * Task run on shutdown. 194 * Task run on shutdown.
161 * FIXME-STYLE: does this need to be a separate task!? 195 * FIXME-STYLE: does this need to be a separate task!?
162 * 196 *
@@ -182,11 +216,30 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
182 * @param user_data global builder instance, unused 216 * @param user_data global builder instance, unused
183 */ 217 */
184void 218void
185GNUNET_GTK_quit_cb (GObject * object, gpointer user_data) 219GNUNET_FS_GTK_menu_quit_activate_cb (GtkMenuItem *object,
220 gpointer user_data)
186{ 221{
187 struct GNUNET_GTK_MainWindowContext *main_context = user_data; 222 struct GNUNET_GTK_MainWindowContext *main_context = user_data;
188 223
189 main_window_save_position (main_context->main_window); 224 GNUNET_GTK_tray_icon_destroy ();
225 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
226 &shutdown_task, NULL);
227 GNUNET_free (main_context);
228}
229
230
231/**
232 * Callback invoked if the application is supposed to exit.
233 *
234 * @param object origin of the quit event, unused
235 * @param user_data global builder instance, unused
236 */
237void
238GNUNET_FS_GTK_delete_event_cb (GtkWidget *object,
239 GdkEvent *event,
240 gpointer user_data)
241{
242 struct GNUNET_GTK_MainWindowContext *main_context = user_data;
190 243
191 GNUNET_GTK_tray_icon_destroy (); 244 GNUNET_GTK_tray_icon_destroy ();
192 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, 245 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
@@ -208,20 +261,16 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
208 unsigned long long dl_parallel, req_parallel, window_x, window_y, 261 unsigned long long dl_parallel, req_parallel, window_x, window_y,
209 window_width, window_height; 262 window_width, window_height;
210 int maximized; 263 int maximized;
211
212 struct GNUNET_GTK_MainWindowContext *main_context; 264 struct GNUNET_GTK_MainWindowContext *main_context;
213 265
214 main_context = GNUNET_malloc (sizeof (struct GNUNET_GTK_MainWindowContext)); 266 main_context = GNUNET_malloc (sizeof (struct GNUNET_GTK_MainWindowContext));
215
216 ml = cls; 267 ml = cls;
217
218 /* setup main context */ 268 /* setup main context */
219 if (GNUNET_OK != GNUNET_GTK_main_loop_build_window (cls, main_context)) 269 if (GNUNET_OK != GNUNET_GTK_main_loop_build_window (cls, main_context))
220 { 270 {
221 GNUNET_free (main_context); 271 GNUNET_free (main_context);
222 return; 272 return;
223 } 273 }
224
225 main_context->builder = GNUNET_GTK_main_loop_get_builder (cls); 274 main_context->builder = GNUNET_GTK_main_loop_get_builder (cls);
226 main_context->cfg = GNUNET_GTK_main_loop_get_configuration (cls); 275 main_context->cfg = GNUNET_GTK_main_loop_get_configuration (cls);
227 main_context->search_ns_treestore = GTK_TREE_STORE (GNUNET_FS_GTK_get_main_window_object ("main_window_search_namespace_treestore")); 276 main_context->search_ns_treestore = GTK_TREE_STORE (GNUNET_FS_GTK_get_main_window_object ("main_window_search_namespace_treestore"));
@@ -297,8 +346,7 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
297 /* initialize file-sharing */ 346 /* initialize file-sharing */
298 fs = GNUNET_FS_start (main_context->cfg, "gnunet-fs-gtk", 347 fs = GNUNET_FS_start (main_context->cfg, "gnunet-fs-gtk",
299 &GNUNET_GTK_fs_event_handler, NULL, 348 &GNUNET_GTK_fs_event_handler, NULL,
300 GNUNET_FS_FLAGS_NONE | GNUNET_FS_FLAGS_PERSISTENCE 349 GNUNET_FS_FLAGS_PERSISTENCE | GNUNET_FS_FLAGS_DO_PROBES,
301 /* | GNUNET_FS_FLAGS_DO_PROBES */ ,
302 GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM, 350 GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM,
303 (unsigned int) dl_parallel, 351 (unsigned int) dl_parallel,
304 GNUNET_FS_OPTIONS_REQUEST_PARALLELISM, 352 GNUNET_FS_OPTIONS_REQUEST_PARALLELISM,
diff --git a/src/fs/gnunet-fs-gtk_event-handler.c b/src/fs/gnunet-fs-gtk_event-handler.c
index 4017e10f..49483158 100644
--- a/src/fs/gnunet-fs-gtk_event-handler.c
+++ b/src/fs/gnunet-fs-gtk_event-handler.c
@@ -1440,9 +1440,9 @@ get_mimetype_from_metadata (const struct GNUNET_CONTAINER_MetaData *meta)
1440static void 1440static void
1441update_search_result (struct SearchResult *sr, 1441update_search_result (struct SearchResult *sr,
1442 const struct GNUNET_CONTAINER_MetaData *meta, 1442 const struct GNUNET_CONTAINER_MetaData *meta,
1443 int32_t availability_rank, 1443 uint32_t applicability_rank,
1444 uint32_t availability_certainty, 1444 int32_t availability_rank,
1445 uint32_t applicability_rank) 1445 uint32_t availability_certainty)
1446{ 1446{
1447 GtkTreeIter iter; 1447 GtkTreeIter iter;
1448 struct GNUNET_CONTAINER_MetaData *ometa; 1448 struct GNUNET_CONTAINER_MetaData *ometa;
@@ -1479,11 +1479,9 @@ update_search_result (struct SearchResult *sr,
1479 if (NULL != ometa) 1479 if (NULL != ometa)
1480 GNUNET_CONTAINER_meta_data_destroy (ometa); 1480 GNUNET_CONTAINER_meta_data_destroy (ometa);
1481 if (availability_certainty > 0) 1481 if (availability_certainty > 0)
1482 percent_avail = 1482 percent_avail = 50 + (2 * availability_rank - availability_certainty) * 50 / availability_certainty;
1483 (availability_certainty +
1484 availability_rank) * 50 / availability_certainty;
1485 else 1483 else
1486 percent_avail = 0; 1484 percent_avail = 50;
1487 gtk_tree_store_set (ts, &iter, 1485 gtk_tree_store_set (ts, &iter,
1488 0, GNUNET_CONTAINER_meta_data_duplicate (meta), 1486 0, GNUNET_CONTAINER_meta_data_duplicate (meta),
1489 3, pixbuf /* preview */ , 1487 3, pixbuf /* preview */ ,