aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fs/gnunet-fs-gtk.c66
-rw-r--r--src/fs/gnunet-fs-gtk_event-handler.c12
2 files changed, 62 insertions, 16 deletions
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 */ ,