diff options
-rw-r--r-- | src/common/helper.c | 341 | ||||
-rw-r--r-- | src/core/main.c | 18 | ||||
-rw-r--r-- | src/include/Makefile.am | 6 | ||||
-rw-r--r-- | src/include/gnunetgtk_common.h | 88 | ||||
-rw-r--r-- | src/include/helper.h | 148 | ||||
-rw-r--r-- | src/include/platform.h | 11 | ||||
-rw-r--r-- | src/plugins/about/about.c | 4 | ||||
-rw-r--r-- | src/plugins/daemon/daemon.c | 13 | ||||
-rw-r--r-- | src/plugins/fs/download.c | 3 | ||||
-rw-r--r-- | src/plugins/fs/download.h | 7 | ||||
-rw-r--r-- | src/plugins/fs/fs.c | 13 | ||||
-rw-r--r-- | src/plugins/fs/fs.h | 8 | ||||
-rw-r--r-- | src/plugins/fs/search.c | 11 | ||||
-rw-r--r-- | src/plugins/fs/search.h | 5 | ||||
-rw-r--r-- | src/plugins/fs/upload.c | 12 | ||||
-rw-r--r-- | src/plugins/fs/upload.h | 6 |
16 files changed, 257 insertions, 437 deletions
diff --git a/src/common/helper.c b/src/common/helper.c index 396b8164..bf2ae4a8 100644 --- a/src/common/helper.c +++ b/src/common/helper.c | |||
@@ -17,65 +17,85 @@ | |||
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | /** | 19 | /** |
20 | * @file src/applications/afs/gtkui/helper.c | 20 | * @file src/common/helper.c |
21 | * @brief This file contains some GUI helper functions | 21 | * @brief This file contains some GUI helper functions |
22 | * @author Igor Wronsky | 22 | * @author Igor Wronsky |
23 | * @author Christian Grothoff | ||
23 | */ | 24 | */ |
24 | 25 | ||
25 | #include "platform.h" | 26 | #include "platform.h" |
26 | #include "helper.h" | 27 | #include "gnunetgtk_common.h" |
27 | 28 | ||
28 | #define HELPER_DEBUG NO | 29 | #define HELPER_DEBUG NO |
29 | 30 | ||
30 | static GladeXML * mainXML; | 31 | static GladeXML * mainXML; |
31 | 32 | ||
32 | static char *gladeFile = NULL; | 33 | static char * gladeFile; |
33 | 34 | ||
34 | static GtkWidget * infoWindow = NULL; | 35 | static GtkWidget * infoWindow; |
35 | 36 | ||
36 | static GtkWidget * infoText = NULL; | 37 | static GtkWidget * infoText; |
37 | 38 | ||
38 | /* the main thread */ | 39 | /** |
40 | * the main thread | ||
41 | */ | ||
39 | static PTHREAD_T mainThread; | 42 | static PTHREAD_T mainThread; |
40 | 43 | ||
44 | typedef struct { | ||
45 | Semaphore * sem; | ||
46 | void * args; | ||
47 | SimpleCallback func; | ||
48 | } SaveCall; | ||
49 | |||
41 | static SaveCall ** psc; | 50 | static SaveCall ** psc; |
51 | |||
42 | static unsigned int pscCount; | 52 | static unsigned int pscCount; |
53 | |||
43 | static Mutex sclock; | 54 | static Mutex sclock; |
44 | 55 | ||
45 | static int saveCallsUp; | 56 | static int saveCallsUp; |
46 | 57 | ||
47 | static GtkNotebook * notebook = NULL; | 58 | static gboolean saveCallWrapper(gpointer data) { |
59 | SaveCall * call = data; | ||
48 | 60 | ||
61 | call->func(call->args); | ||
62 | if (call->sem != NULL) | ||
63 | SEMAPHORE_UP(call->sem); | ||
64 | return FALSE; | ||
65 | } | ||
49 | 66 | ||
50 | /** | 67 | /** |
51 | * Call a callback function from the mainloop/main thread ("SaveCall"). | 68 | * Call a callback function from the mainloop/main thread ("SaveCall"). |
52 | * Since GTK doesn't work with multi-threaded applications under Windows, | 69 | * Since GTK doesn't work with multi-threaded applications under Windows, |
53 | * all GTK operations have to be done in the main thread | 70 | * all GTK operations have to be done in the main thread |
54 | */ | 71 | */ |
55 | void gtkSaveCall(GtkFunction func, void *args) { | 72 | void gtkSaveCall(SimpleCallback func, |
73 | void * args) { | ||
56 | SaveCall call; | 74 | SaveCall call; |
57 | int i; | 75 | int i; |
58 | 76 | ||
59 | call.args = args; | ||
60 | call.func = func; | ||
61 | MUTEX_LOCK(&sclock); | 77 | MUTEX_LOCK(&sclock); |
62 | if ( (saveCallsUp == NO) || | 78 | if ( (saveCallsUp == NO) || |
63 | (! PTHREAD_SELF_TEST(&mainThread)) ) { | 79 | (! PTHREAD_SELF_TEST(&mainThread)) ) { |
64 | call.sem = SEMAPHORE_NEW(0); | 80 | call.args = args; |
81 | call.func = func; | ||
82 | call.sem = SEMAPHORE_NEW(0); | ||
65 | GROW(psc, | 83 | GROW(psc, |
66 | pscCount, | 84 | pscCount, |
67 | pscCount+1); | 85 | pscCount+1); |
68 | psc[pscCount-1] = &call; | 86 | psc[pscCount-1] = &call; |
69 | MUTEX_UNLOCK(&sclock); | 87 | MUTEX_UNLOCK(&sclock); |
70 | gtk_idle_add(func, &call); | 88 | gtk_idle_add(&saveCallWrapper, |
89 | &call); | ||
71 | SEMAPHORE_DOWN(call.sem); | 90 | SEMAPHORE_DOWN(call.sem); |
72 | /* remove from psc list */ | 91 | /* remove from psc list */ |
73 | MUTEX_LOCK(&sclock); | 92 | MUTEX_LOCK(&sclock); |
74 | for (i=0;i<pscCount;i++) | 93 | for (i=0;i<pscCount;i++) { |
75 | if (psc[i] == &call) { | 94 | if (psc[i] == &call) { |
76 | psc[i] = psc[pscCount-1]; | 95 | psc[i] = psc[pscCount-1]; |
77 | break; | 96 | break; |
78 | } | 97 | } |
98 | } | ||
79 | GNUNET_ASSERT(i != pscCount); | 99 | GNUNET_ASSERT(i != pscCount); |
80 | GROW(psc, | 100 | GROW(psc, |
81 | pscCount, | 101 | pscCount, |
@@ -84,20 +104,10 @@ void gtkSaveCall(GtkFunction func, void *args) { | |||
84 | SEMAPHORE_FREE(call.sem); | 104 | SEMAPHORE_FREE(call.sem); |
85 | } else { | 105 | } else { |
86 | MUTEX_UNLOCK(&sclock); | 106 | MUTEX_UNLOCK(&sclock); |
87 | call.sem = NULL; | 107 | func(args); |
88 | func(&call); | ||
89 | } | 108 | } |
90 | } | 109 | } |
91 | 110 | ||
92 | /** | ||
93 | * Initialize "SaveCalls" | ||
94 | */ | ||
95 | void gtkInitSaveCalls() { | ||
96 | MUTEX_CREATE_RECURSIVE(&sclock); | ||
97 | PTHREAD_GET_SELF(&mainThread); | ||
98 | saveCallsUp = YES; | ||
99 | } | ||
100 | |||
101 | int gtkRunSomeSaveCalls() { | 111 | int gtkRunSomeSaveCalls() { |
102 | int i; | 112 | int i; |
103 | 113 | ||
@@ -124,80 +134,32 @@ int gtkRunSomeSaveCalls() { | |||
124 | return YES; | 134 | return YES; |
125 | } | 135 | } |
126 | 136 | ||
127 | void gtkDoneSaveCalls() { | ||
128 | int i; | ||
129 | |||
130 | saveCallsUp = NO; | ||
131 | PTHREAD_REL_SELF(&mainThread); | ||
132 | MUTEX_LOCK(&sclock); | ||
133 | for (i=0;i<pscCount;i++) | ||
134 | psc[i]->func(psc[i]); | ||
135 | i = pscCount; | ||
136 | MUTEX_UNLOCK(&sclock); | ||
137 | /* wait until all PSC-jobs have left | ||
138 | the gtkSaveCall method before destroying | ||
139 | the mutex! */ | ||
140 | while (i != 0) { | ||
141 | gnunet_util_sleep(50 * cronMILLIS); | ||
142 | MUTEX_LOCK(&sclock); | ||
143 | i = pscCount; | ||
144 | MUTEX_UNLOCK(&sclock); | ||
145 | } | ||
146 | MUTEX_DESTROY(&sclock); | ||
147 | } | ||
148 | |||
149 | |||
150 | /** | ||
151 | * Called from a "SaveCall"-function to indicate that it is done | ||
152 | */ | ||
153 | void gtkSaveCallDone(Semaphore *sem) { | ||
154 | if (sem) | ||
155 | SEMAPHORE_UP(sem); | ||
156 | } | ||
157 | |||
158 | /** | ||
159 | * Destroy a widget. Called from threads other than the main thread | ||
160 | */ | ||
161 | gint doDestroyWidget(SaveCall *call) { | ||
162 | gtk_widget_destroy((GtkWidget *) call->args); | ||
163 | |||
164 | gtkSaveCallDone(call->sem); | ||
165 | |||
166 | return FALSE; | ||
167 | } | ||
168 | |||
169 | /** | 137 | /** |
170 | * Callback for handling "delete_event": close the window | 138 | * Callback for handling "delete_event": close the window |
171 | */ | 139 | */ |
172 | gint deleteEvent(GtkWidget * widget, | 140 | static gint |
173 | GdkEvent * event, | 141 | deleteEvent(GtkWidget * widget, |
174 | gpointer data) { | 142 | GdkEvent * event, |
175 | #if DEBUG_HELPER | 143 | gpointer data) { |
176 | LOG(LOG_DEBUG, | ||
177 | "In '%s'.\n", | ||
178 | __FUNCTION__); | ||
179 | #endif | ||
180 | return FALSE; | 144 | return FALSE; |
181 | } | 145 | } |
182 | 146 | ||
183 | /** | 147 | /** |
184 | * A callback to destroy any widget given as second argument | 148 | * A callback to destroy any widget given as second argument |
185 | */ | 149 | */ |
186 | void destroyWidget(GtkWidget * dummy, | 150 | static void |
187 | GtkWidget * widget) { | 151 | destroyWidget(GtkWidget * dummy, |
188 | #if DEBUG_HELPER | 152 | GtkWidget * widget) { |
189 | LOG(LOG_DEBUG, | ||
190 | "In '%s' of %p.\n", | ||
191 | __FUNCTION__, | ||
192 | widget); | ||
193 | #endif | ||
194 | gtk_widget_destroy(widget); | 153 | gtk_widget_destroy(widget); |
195 | } | 154 | } |
196 | 155 | ||
197 | /** | 156 | /** |
198 | * Callback function for guiMessage() | 157 | * Callback function for guiMessage() |
158 | * | ||
159 | * FIXME: use GLADE (or direct GTK functionality) here! | ||
199 | */ | 160 | */ |
200 | gint doGuiMessage(SaveCall *call) { | 161 | static void doGuiMessage(void * args) { |
162 | const gchar * msg = args; | ||
201 | GtkWidget * window; | 163 | GtkWidget * window; |
202 | GtkWidget * label; | 164 | GtkWidget * label; |
203 | GtkWidget * box; | 165 | GtkWidget * box; |
@@ -216,8 +178,7 @@ gint doGuiMessage(SaveCall *call) { | |||
216 | gtk_container_add(GTK_CONTAINER(window), | 178 | gtk_container_add(GTK_CONTAINER(window), |
217 | box); | 179 | box); |
218 | 180 | ||
219 | label = gtk_label_new((gchar *) call->args); | 181 | label = gtk_label_new(msg); |
220 | free((gchar *) call->args); /* allocated in g_strdup_vprintf */ | ||
221 | gtk_box_pack_start(GTK_BOX(box), | 182 | gtk_box_pack_start(GTK_BOX(box), |
222 | label, | 183 | label, |
223 | FALSE, | 184 | FALSE, |
@@ -226,49 +187,60 @@ gint doGuiMessage(SaveCall *call) { | |||
226 | 187 | ||
227 | button = gtk_button_new_with_label(_("Ok")); | 188 | button = gtk_button_new_with_label(_("Ok")); |
228 | gtk_signal_connect(GTK_OBJECT (button), | 189 | gtk_signal_connect(GTK_OBJECT (button), |
229 | "clicked", | 190 | "clicked", |
230 | GTK_SIGNAL_FUNC(destroyWidget), | 191 | GTK_SIGNAL_FUNC(destroyWidget), |
231 | window); | 192 | window); |
232 | gtk_box_pack_start(GTK_BOX(box),button,FALSE,FALSE,0); | 193 | gtk_box_pack_start(GTK_BOX(box), |
233 | 194 | button, | |
195 | FALSE, | ||
196 | FALSE, | ||
197 | 0); | ||
234 | gtk_window_set_position(GTK_WINDOW(window), | 198 | gtk_window_set_position(GTK_WINDOW(window), |
235 | GTK_WIN_POS_MOUSE); | 199 | GTK_WIN_POS_MOUSE); |
236 | gtk_widget_show_all(window); | 200 | gtk_widget_show_all(window); |
237 | gtk_widget_grab_focus(button); | 201 | gtk_widget_grab_focus(button); |
238 | |||
239 | gtkSaveCallDone(call->sem); | ||
240 | |||
241 | return FALSE; | ||
242 | } | 202 | } |
243 | 203 | ||
244 | /** | 204 | /** |
245 | * Displays an informative message to the user in a fresh window | 205 | * Displays an informative message to the user in a fresh window |
246 | */ | 206 | */ |
247 | void guiMessage(const char * format, ...) { | 207 | void guiMessage(const char * format, |
208 | ...) { | ||
248 | va_list args; | 209 | va_list args; |
249 | gchar *note; | 210 | gchar *note; |
250 | 211 | ||
251 | va_start(args, format); | 212 | va_start(args, format); |
252 | note = g_strdup_vprintf(format, args); | 213 | note = g_strdup_vprintf(format, args); |
253 | va_end(args); | 214 | va_end(args); |
254 | 215 | gtkSaveCall(&doGuiMessage, note); | |
255 | gtkSaveCall((GtkFunction) doGuiMessage, note); | 216 | free(note); |
256 | } | 217 | } |
257 | 218 | ||
258 | static void hideWindow(GtkWidget * widget, | 219 | static void hideWindow(GtkWidget * widget, |
259 | gpointer data) { | 220 | gpointer data) { |
260 | if(widget) | 221 | if (widget != NULL) |
261 | gtk_widget_hide(widget); | 222 | gtk_widget_hide(widget); |
262 | } | 223 | } |
263 | 224 | ||
264 | /** | 225 | /** |
226 | * Closure for doInfoMessage. | ||
227 | */ | ||
228 | typedef struct { | ||
229 | int doPopup; | ||
230 | char * note; | ||
231 | } InfoMessage; | ||
232 | |||
233 | /** | ||
265 | * Callback for infoMessage() | 234 | * Callback for infoMessage() |
235 | * | ||
236 | * FIXME: use GLADE (or direct GTK functionality) here! | ||
266 | */ | 237 | */ |
267 | gint doInfoMessage(SaveCall *call) { | 238 | static void doInfoMessage(void * args) { |
239 | const InfoMessage * info = args; | ||
268 | GtkTextIter iter; | 240 | GtkTextIter iter; |
269 | GtkTextBuffer * buffer; | 241 | GtkTextBuffer * buffer; |
270 | 242 | ||
271 | if(!infoWindow) { | 243 | if (! infoWindow) { |
272 | GtkWidget * box1; | 244 | GtkWidget * box1; |
273 | GtkWidget * button; | 245 | GtkWidget * button; |
274 | GtkWidget * scrolled_window; | 246 | GtkWidget * scrolled_window; |
@@ -306,7 +278,7 @@ gint doInfoMessage(SaveCall *call) { | |||
306 | infoText = gtk_text_view_new(); | 278 | infoText = gtk_text_view_new(); |
307 | 279 | ||
308 | gtk_text_view_set_editable(GTK_TEXT_VIEW (infoText), | 280 | gtk_text_view_set_editable(GTK_TEXT_VIEW (infoText), |
309 | FALSE); | 281 | FALSE); |
310 | gtk_container_add(GTK_CONTAINER(scrolled_window), | 282 | gtk_container_add(GTK_CONTAINER(scrolled_window), |
311 | infoText); | 283 | infoText); |
312 | gtk_widget_show(infoText); | 284 | gtk_widget_show(infoText); |
@@ -333,29 +305,26 @@ gint doInfoMessage(SaveCall *call) { | |||
333 | GTK_OBJECT(infoWindow)); | 305 | GTK_OBJECT(infoWindow)); |
334 | gtk_widget_show(button); | 306 | gtk_widget_show(button); |
335 | } | 307 | } |
336 | if(((InfoMessage *) call->args)->doPopup==YES) | 308 | if (info->doPopup==YES) |
337 | gtk_widget_show(infoWindow); | 309 | gtk_widget_show(infoWindow); |
338 | 310 | ||
339 | /* append the text */ | 311 | /* append the text */ |
340 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW (infoText)); | 312 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(infoText)); |
341 | gtk_text_buffer_get_iter_at_offset(buffer, &iter, -1); | 313 | gtk_text_buffer_get_iter_at_offset(buffer, &iter, -1); |
342 | gtk_text_buffer_insert(buffer, | 314 | gtk_text_buffer_insert(buffer, |
343 | &iter, | 315 | &iter, |
344 | ((InfoMessage *) call->args)->note, | 316 | info->note, |
345 | -1); | 317 | -1); |
346 | |||
347 | gtkSaveCallDone(call->sem); | ||
348 | |||
349 | return FALSE; | ||
350 | } | 318 | } |
351 | 319 | ||
352 | /** | 320 | /** |
353 | * Appends a message to the info window | 321 | * Appends a message to the info window |
354 | * | 322 | * |
355 | * @param doPopup do we open the window, YES or NO | 323 | * @param doPopup do we open the window, YES or NO |
356 | * | ||
357 | */ | 324 | */ |
358 | void infoMessage(int doPopup, const char * format, ...) { | 325 | void infoMessage(int doPopup, |
326 | const char * format, | ||
327 | ...) { | ||
359 | va_list args; | 328 | va_list args; |
360 | InfoMessage info; | 329 | InfoMessage info; |
361 | 330 | ||
@@ -363,11 +332,12 @@ void infoMessage(int doPopup, const char * format, ...) { | |||
363 | info.note = g_strdup_vprintf(format, args); | 332 | info.note = g_strdup_vprintf(format, args); |
364 | va_end(args); | 333 | va_end(args); |
365 | info.doPopup = doPopup; | 334 | info.doPopup = doPopup; |
366 | gtkSaveCall((GtkFunction) doInfoMessage, &info); | 335 | gtkSaveCall(&doInfoMessage, |
336 | &info); | ||
367 | g_free(info.note); | 337 | g_free(info.note); |
368 | } | 338 | } |
369 | 339 | ||
370 | static gint saveAddLogEntry(SaveCall * call) { | 340 | static void saveAddLogEntry(void * args) { |
371 | static GtkWidget * s = NULL; | 341 | static GtkWidget * s = NULL; |
372 | static int once = 1; | 342 | static int once = 1; |
373 | static guint id; | 343 | static guint id; |
@@ -383,9 +353,7 @@ static gint saveAddLogEntry(SaveCall * call) { | |||
383 | id); | 353 | id); |
384 | gtk_statusbar_push(GTK_STATUSBAR(s), | 354 | gtk_statusbar_push(GTK_STATUSBAR(s), |
385 | id, | 355 | id, |
386 | (const char*) call->args); | 356 | (const char*) args); |
387 | gtkSaveCallDone(call->sem); | ||
388 | return FALSE; | ||
389 | } | 357 | } |
390 | 358 | ||
391 | /** | 359 | /** |
@@ -394,121 +362,31 @@ static gint saveAddLogEntry(SaveCall * call) { | |||
394 | * @param txt the log entry | 362 | * @param txt the log entry |
395 | * | 363 | * |
396 | */ | 364 | */ |
397 | void addLogEntry(const char *txt) { | 365 | void addLogEntry(const char * txt) { |
398 | infoMessage(NO, txt); | 366 | infoMessage(NO, txt); |
399 | gtkSaveCall((GtkFunction)saveAddLogEntry, | 367 | gtkSaveCall(&saveAddLogEntry, |
400 | (void*) txt); | 368 | (void*) txt); |
401 | } | 369 | } |
402 | 370 | ||
403 | gint doAddToNotebook(SaveCall *call) { | ||
404 | GtkWidget * label = gtk_label_new(((AddNotebook *) call->args)->labelName); | ||
405 | gtk_notebook_append_page(notebook, | ||
406 | ((AddNotebook *) call->args)->frame, | ||
407 | label); | ||
408 | gtk_widget_show(((AddNotebook *) call->args)->frame); | ||
409 | |||
410 | gtkSaveCallDone(call->sem); | ||
411 | |||
412 | return FALSE; | ||
413 | } | ||
414 | |||
415 | void addToNotebook(const char * labelName, | ||
416 | GtkWidget * frame) { | ||
417 | AddNotebook note; | ||
418 | |||
419 | note.labelName = labelName; | ||
420 | note.frame = frame; | ||
421 | /* add a new notebook for the search results */ | ||
422 | gtkSaveCall((GtkFunction) doAddToNotebook, ¬e); | ||
423 | } | ||
424 | |||
425 | /** | 371 | /** |
426 | * A function for numeric comparisons of strings | 372 | * Simple accessor method. |
427 | */ | 373 | */ |
428 | gint numericComp(GtkCList *clist, | 374 | const char * getGladeFileName() { |
429 | gconstpointer ptr1, | 375 | return gladeFile; |
430 | gconstpointer ptr2) { | ||
431 | double value1; | ||
432 | double value2; | ||
433 | GtkCListRow * row1 = (GtkCListRow *) ptr1; | ||
434 | GtkCListRow * row2 = (GtkCListRow *) ptr2; | ||
435 | |||
436 | value1 = atof(GTK_CELL_TEXT(row1->cell[clist->sort_column])->text); | ||
437 | value2 = atof(GTK_CELL_TEXT(row2->cell[clist->sort_column])->text); | ||
438 | |||
439 | if(value1>value2) | ||
440 | return(-1); | ||
441 | else if(value1==value2) | ||
442 | return(0); | ||
443 | else | ||
444 | return(1); | ||
445 | } | 376 | } |
446 | 377 | ||
447 | /** | 378 | /** |
448 | * A function for case-insensitive text comparisons | 379 | * Simple accessor method. |
449 | */ | 380 | */ |
450 | gint alphaComp(GtkCList *clist, | 381 | GladeXML * getMainXML() { |
451 | gconstpointer ptr1, | 382 | return mainXML; |
452 | gconstpointer ptr2) { | ||
453 | char * text1; | ||
454 | char * text2; | ||
455 | GtkCListRow * row1 = (GtkCListRow *) ptr1; | ||
456 | GtkCListRow * row2 = (GtkCListRow *) ptr2; | ||
457 | |||
458 | text1 = GTK_CELL_TEXT(row1->cell[clist->sort_column])->text; | ||
459 | text2 = GTK_CELL_TEXT(row2->cell[clist->sort_column])->text; | ||
460 | |||
461 | return (strcasecmp(text1,text2)); | ||
462 | } | 383 | } |
463 | 384 | ||
464 | /** | 385 | void initGNUnetGTKCommon() { |
465 | * A function for percentage comparisons | 386 | MUTEX_CREATE_RECURSIVE(&sclock); |
466 | */ | 387 | PTHREAD_GET_SELF(&mainThread); |
467 | gint percentComp(GtkCList *clist, | 388 | saveCallsUp = YES; |
468 | gconstpointer ptr1, | ||
469 | gconstpointer ptr2) { | ||
470 | char * tmp1; | ||
471 | char * tmp2; | ||
472 | double value1; | ||
473 | double value2; | ||
474 | GtkCListRow * row1 = (GtkCListRow *) ptr1; | ||
475 | GtkCListRow * row2 = (GtkCListRow *) ptr2; | ||
476 | |||
477 | tmp1 = GTK_CELL_TEXT(row1->cell[clist->sort_column])->text; | ||
478 | tmp2 = GTK_CELL_TEXT(row2->cell[clist->sort_column])->text; | ||
479 | |||
480 | /* Hack for DONE strings :) */ | ||
481 | if(strstr(tmp1,"%") == 0) { | ||
482 | if(strstr(tmp2,"%") == 0) | ||
483 | return 0; /* Both "DONE" */ | ||
484 | else | ||
485 | return -1; /* A done, B not */ | ||
486 | } | ||
487 | if(strstr(tmp2,"%")==0) | ||
488 | return 1; /* B done, A not */ | ||
489 | |||
490 | /* Both have %, must remove */ | ||
491 | tmp1 = STRDUP(GTK_CELL_TEXT(row1->cell[clist->sort_column])->text); | ||
492 | tmp2 = STRDUP(GTK_CELL_TEXT(row2->cell[clist->sort_column])->text); | ||
493 | |||
494 | tmp1[strlen(tmp1)-1]=0; | ||
495 | tmp2[strlen(tmp2)-1]=0; | ||
496 | |||
497 | value1 = atof(tmp1); | ||
498 | value2 = atof(tmp2); | ||
499 | |||
500 | FREE(tmp1); | ||
501 | FREE(tmp2); | ||
502 | |||
503 | if(value1>value2) | ||
504 | return(-1); | ||
505 | else if(value1==value2) | ||
506 | return(0); | ||
507 | else | ||
508 | return(1); | ||
509 | } | ||
510 | 389 | ||
511 | void initGlade() { | ||
512 | /* load the interface */ | 390 | /* load the interface */ |
513 | #ifdef MINGW | 391 | #ifdef MINGW |
514 | gladeFile = MALLOC(_MAX_PATH + 1); | 392 | gladeFile = MALLOC(_MAX_PATH + 1); |
@@ -522,21 +400,32 @@ void initGlade() { | |||
522 | NULL); | 400 | NULL); |
523 | } | 401 | } |
524 | 402 | ||
525 | void doneGlade() { | 403 | void doneGNUnetGTKCommon() { |
404 | int i; | ||
405 | |||
526 | UNREF(mainXML); | 406 | UNREF(mainXML); |
527 | mainXML = NULL; | 407 | mainXML = NULL; |
528 | FREE(gladeFile); | 408 | FREE(gladeFile); |
529 | gladeFile = NULL; | 409 | gladeFile = NULL; |
530 | } | ||
531 | 410 | ||
532 | const char * getGladeFileName() { | 411 | saveCallsUp = NO; |
533 | return gladeFile; | 412 | PTHREAD_REL_SELF(&mainThread); |
534 | } | 413 | MUTEX_LOCK(&sclock); |
414 | for (i=0;i<pscCount;i++) | ||
415 | psc[i]->func(psc[i]); | ||
416 | i = pscCount; | ||
417 | MUTEX_UNLOCK(&sclock); | ||
418 | /* wait until all PSC-jobs have left | ||
419 | the gtkSaveCall method before destroying | ||
420 | the mutex! */ | ||
421 | while (i != 0) { | ||
422 | gnunet_util_sleep(50 * cronMILLIS); | ||
423 | MUTEX_LOCK(&sclock); | ||
424 | i = pscCount; | ||
425 | MUTEX_UNLOCK(&sclock); | ||
426 | } | ||
427 | MUTEX_DESTROY(&sclock); | ||
535 | 428 | ||
536 | GladeXML * getMainXML() { | ||
537 | return mainXML; | ||
538 | } | 429 | } |
539 | 430 | ||
540 | |||
541 | |||
542 | /* end of helper.c */ | 431 | /* end of helper.c */ |
diff --git a/src/core/main.c b/src/core/main.c index 6bf5225e..3f3c8cea 100644 --- a/src/core/main.c +++ b/src/core/main.c | |||
@@ -19,16 +19,13 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file src/main.c | 22 | * @file src/core/main.c |
23 | * @brief Main function of gnunet-gtk | 23 | * @brief Main function of gnunet-gtk |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "config.h" | 27 | #include "platform.h" |
28 | #include "gettext.h" | 28 | #include "gnunetgtk_common.h" |
29 | |||
30 | #include <GNUnet/gnunet_util.h> | ||
31 | #include "helper.h" | ||
32 | 29 | ||
33 | /** | 30 | /** |
34 | * Prints the usage information for this command if the user errs. | 31 | * Prints the usage information for this command if the user errs. |
@@ -200,9 +197,7 @@ int main(int argc, | |||
200 | &parseOptions)) | 197 | &parseOptions)) |
201 | return 0; | 198 | return 0; |
202 | startCron(); | 199 | startCron(); |
203 | gtkInitSaveCalls(); | 200 | initGNUnetGTKCommon(); |
204 | |||
205 | initGlade(); | ||
206 | root | 201 | root |
207 | = glade_xml_get_widget(getMainXML(), | 202 | = glade_xml_get_widget(getMainXML(), |
208 | "mainWindow"); | 203 | "mainWindow"); |
@@ -237,9 +232,8 @@ int main(int argc, | |||
237 | unloadPlugin(plugin); | 232 | unloadPlugin(plugin); |
238 | plugin = next; | 233 | plugin = next; |
239 | } | 234 | } |
240 | 235 | ||
241 | gtkDoneSaveCalls(); | 236 | doneGNUnetGTKCommon(); |
242 | doneGlade(); | ||
243 | doneUtil(); | 237 | doneUtil(); |
244 | 238 | ||
245 | return 0; | 239 | return 0; |
diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 098592df..7de20133 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am | |||
@@ -1,5 +1,9 @@ | |||
1 | gnunetincludedir = $(includedir)/GNUnet | ||
2 | |||
3 | gnunetinclude_HEADERS = \ | ||
4 | gnunetgtk_common.h | ||
5 | |||
1 | EXTRA_DIST = \ | 6 | EXTRA_DIST = \ |
2 | helper.h \ | ||
3 | gettext.h \ | 7 | gettext.h \ |
4 | plibc.h \ | 8 | plibc.h \ |
5 | platform.h | 9 | platform.h |
diff --git a/src/include/gnunetgtk_common.h b/src/include/gnunetgtk_common.h new file mode 100644 index 00000000..7dd342fa --- /dev/null +++ b/src/include/gnunetgtk_common.h | |||
@@ -0,0 +1,88 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | (C) 2005 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 2, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file src/include/gnunetgtk_common.h | ||
23 | * @author Igor Wronsky | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | |||
27 | #ifndef GTKUI_HELPER_H | ||
28 | #define GTKUI_HELPER_H | ||
29 | |||
30 | void initGNUnetGTKCommon(void); | ||
31 | |||
32 | void doneGNUnetGTKCommon(void); | ||
33 | |||
34 | /** | ||
35 | * Get the name of the main glade file for gnunet-gtk. | ||
36 | */ | ||
37 | const char * getGladeFileName(void); | ||
38 | |||
39 | /** | ||
40 | * Get the GladeXML for the main window of gnunet-gtk. | ||
41 | */ | ||
42 | GladeXML * getMainXML(void); | ||
43 | |||
44 | /** | ||
45 | * Displays an informative message to the user | ||
46 | * in a new popup window. | ||
47 | */ | ||
48 | void guiMessage(const char * format, | ||
49 | ...); | ||
50 | |||
51 | /** | ||
52 | * Appends a message to the info window | ||
53 | * @param doPopup if YES, the info window will | ||
54 | * be opened | ||
55 | */ | ||
56 | void infoMessage(int doPopup, | ||
57 | const char * format, ...); | ||
58 | |||
59 | /** | ||
60 | * Appends a log entry to the info window | ||
61 | * and update the statusbar to show this | ||
62 | * message (until the next call). | ||
63 | * | ||
64 | * @param txt the log entry | ||
65 | */ | ||
66 | void addLogEntry(const char * txt); | ||
67 | |||
68 | /** | ||
69 | * Simple callback function. | ||
70 | */ | ||
71 | typedef void (*SimpleCallback)(void *); | ||
72 | |||
73 | /** | ||
74 | * Call a callback function from the mainloop/main thread ("SaveCall"). | ||
75 | * Since GTK doesn't work with multi-threaded applications under Windows, | ||
76 | * all GTK operations have to be done in the main thread | ||
77 | */ | ||
78 | void gtkSaveCall(SimpleCallback func, | ||
79 | void * arg); | ||
80 | |||
81 | /** | ||
82 | * Use this method when blocking the | ||
83 | * GTK event thread and save calls should | ||
84 | * still continue. | ||
85 | */ | ||
86 | int gtkRunSomeSaveCalls(); | ||
87 | |||
88 | #endif | ||
diff --git a/src/include/helper.h b/src/include/helper.h deleted file mode 100644 index be9a044e..00000000 --- a/src/include/helper.h +++ /dev/null | |||
@@ -1,148 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | |||
4 | GNUnet is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published | ||
6 | by the Free Software Foundation; either version 2, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | GNUnet is distributed in the hope that it will be useful, but | ||
10 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with GNUnet; see the file COPYING. If not, write to the | ||
16 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
17 | Boston, MA 02111-1307, USA. | ||
18 | */ | ||
19 | |||
20 | /** | ||
21 | * @file src/helper.h | ||
22 | * @author Igor Wronsky | ||
23 | */ | ||
24 | |||
25 | #ifndef GTKUI_HELPER_H | ||
26 | #define GTKUI_HELPER_H | ||
27 | |||
28 | #include "platform.h" | ||
29 | #include <GNUnet/gnunet_util.h> | ||
30 | |||
31 | /* for GTK 2 */ | ||
32 | #define GTK_ENABLE_BROKEN | ||
33 | |||
34 | #include <gtk/gtk.h> | ||
35 | #include <gtk/gtktext.h> | ||
36 | #include <glade/glade.h> | ||
37 | |||
38 | const char * getGladeFileName(void); | ||
39 | |||
40 | GladeXML * getMainXML(void); | ||
41 | |||
42 | void initGlade(void); | ||
43 | |||
44 | void doneGlade(void); | ||
45 | |||
46 | typedef struct { | ||
47 | Semaphore *sem; | ||
48 | void *args; | ||
49 | GtkFunction func; | ||
50 | } SaveCall; | ||
51 | |||
52 | typedef struct { | ||
53 | int doPopup; | ||
54 | gchar *note; | ||
55 | } InfoMessage; | ||
56 | |||
57 | typedef struct { | ||
58 | const char *labelName; | ||
59 | GtkWidget *frame; | ||
60 | } AddNotebook; | ||
61 | |||
62 | |||
63 | /* callback: window close: close the window */ | ||
64 | gint deleteEvent(GtkWidget * widget, | ||
65 | GdkEvent * event, | ||
66 | gpointer data); | ||
67 | |||
68 | /** | ||
69 | * A callback to destroy any widget given as second argument | ||
70 | * | ||
71 | */ | ||
72 | void destroyWidget(GtkWidget * dummy, GtkWidget * widget); | ||
73 | |||
74 | /** | ||
75 | * Displays an informative message to the user | ||
76 | */ | ||
77 | void guiMessage(const char * format, ...); | ||
78 | |||
79 | /** | ||
80 | * Appends a message to the info window | ||
81 | */ | ||
82 | void infoMessage(int doPopup, const char * format, ...); | ||
83 | |||
84 | /** | ||
85 | * Appends a log entry to the info window | ||
86 | * | ||
87 | * @param txt the log entry | ||
88 | * | ||
89 | */ | ||
90 | void addLogEntry(const char *txt); | ||
91 | |||
92 | /** | ||
93 | * A function for numeric comparisons of strings | ||
94 | */ | ||
95 | gint numericComp(GtkCList *clist, | ||
96 | gconstpointer ptr1, | ||
97 | gconstpointer ptr2); | ||
98 | |||
99 | /** | ||
100 | * A function for case-insensitive text comparisons | ||
101 | */ | ||
102 | gint alphaComp(GtkCList *clist, | ||
103 | gconstpointer ptr1, | ||
104 | gconstpointer ptr2); | ||
105 | |||
106 | /** | ||
107 | * A function for comparisons of percentages | ||
108 | */ | ||
109 | gint percentComp(GtkCList *clist, | ||
110 | gconstpointer ptr1, | ||
111 | gconstpointer ptr2); | ||
112 | |||
113 | /** | ||
114 | * A general right-button popup menu callback | ||
115 | */ | ||
116 | gboolean popupCallback(GtkWidget *widget, | ||
117 | GdkEvent *event, | ||
118 | GtkWidget *menu ); | ||
119 | |||
120 | /** | ||
121 | * Call a callback function from the mainloop/main thread ("SaveCall"). | ||
122 | * Since GTK doesn't work with multi-threaded applications under Windows, | ||
123 | * all GTK operations have to be done in the main thread | ||
124 | */ | ||
125 | void gtkSaveCall(GtkFunction func, void *args); | ||
126 | |||
127 | /** | ||
128 | * Initialize "SaveCalls" | ||
129 | */ | ||
130 | void gtkInitSaveCalls(); | ||
131 | |||
132 | void gtkDoneSaveCalls(); | ||
133 | |||
134 | int gtkRunSomeSaveCalls(); | ||
135 | |||
136 | /** | ||
137 | * Called from a "SaveCall"-function to indicate that it is done | ||
138 | */ | ||
139 | void gtkSaveCallDone(Semaphore *sem); | ||
140 | |||
141 | /** | ||
142 | * Destroy a widget. Called from threads other than the main thread | ||
143 | */ | ||
144 | gint doDestroyWidget(SaveCall *call); | ||
145 | |||
146 | extern GtkWidget * infoWindow; | ||
147 | |||
148 | #endif | ||
diff --git a/src/include/platform.h b/src/include/platform.h index b90c0939..0d2d6ac0 100644 --- a/src/include/platform.h +++ b/src/include/platform.h | |||
@@ -174,4 +174,15 @@ long long atoll(const char *nptr); | |||
174 | #include "langinfo.h" | 174 | #include "langinfo.h" |
175 | #endif | 175 | #endif |
176 | 176 | ||
177 | #include <GNUnet/gnunet_util.h> | ||
178 | |||
179 | /* for GTK 2 */ | ||
180 | #define GTK_ENABLE_BROKEN | ||
181 | |||
182 | #include <gtk/gtk.h> | ||
183 | #include <gtk/gtktext.h> | ||
184 | #include <glade/glade.h> | ||
185 | |||
186 | |||
187 | |||
177 | #endif | 188 | #endif |
diff --git a/src/plugins/about/about.c b/src/plugins/about/about.c index dbea4c75..0dcf032e 100644 --- a/src/plugins/about/about.c +++ b/src/plugins/about/about.c | |||
@@ -25,8 +25,8 @@ | |||
25 | * This file contains the about dialog. | 25 | * This file contains the about dialog. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include "config.h" | 28 | #include "platform.h" |
29 | #include "helper.h" | 29 | #include "gnunetgtk_common.h" |
30 | 30 | ||
31 | /** | 31 | /** |
32 | * This displays an about window | 32 | * This displays an about window |
diff --git a/src/plugins/daemon/daemon.c b/src/plugins/daemon/daemon.c index 396989eb..df265a79 100644 --- a/src/plugins/daemon/daemon.c +++ b/src/plugins/daemon/daemon.c | |||
@@ -25,10 +25,11 @@ | |||
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "helper.h" | 28 | #include "gnunetgtk_common.h" |
29 | #include <GNUnet/gnunet_util.h> | ||
30 | 29 | ||
31 | static gint doUpdateMenus(SaveCall * call) { | 30 | |
31 | static void doUpdateMenus(void * arg) { | ||
32 | int ret = *(int*) arg; | ||
32 | static GtkWidget * killEntry = NULL; | 33 | static GtkWidget * killEntry = NULL; |
33 | static GtkWidget * launchEntry = NULL; | 34 | static GtkWidget * launchEntry = NULL; |
34 | static GtkWidget * statsEntryYes = NULL; | 35 | static GtkWidget * statsEntryYes = NULL; |
@@ -36,9 +37,7 @@ static gint doUpdateMenus(SaveCall * call) { | |||
36 | static int once = 1; | 37 | static int once = 1; |
37 | static int isLocal; | 38 | static int isLocal; |
38 | char * host; | 39 | char * host; |
39 | int ret; | ||
40 | 40 | ||
41 | ret = * (int*) call->args; | ||
42 | if (once) { | 41 | if (once) { |
43 | once = 0; | 42 | once = 0; |
44 | killEntry | 43 | killEntry |
@@ -73,8 +72,6 @@ static gint doUpdateMenus(SaveCall * call) { | |||
73 | gtk_widget_set_sensitive(killEntry, TRUE); | 72 | gtk_widget_set_sensitive(killEntry, TRUE); |
74 | gtk_widget_set_sensitive(launchEntry, FALSE); | 73 | gtk_widget_set_sensitive(launchEntry, FALSE); |
75 | } | 74 | } |
76 | gtkSaveCallDone(call->sem); | ||
77 | return FALSE; | ||
78 | } | 75 | } |
79 | 76 | ||
80 | static void cronCheckDaemon(void * dummy) { | 77 | static void cronCheckDaemon(void * dummy) { |
@@ -84,7 +81,7 @@ static void cronCheckDaemon(void * dummy) { | |||
84 | ret = checkGNUnetDaemonRunning(); | 81 | ret = checkGNUnetDaemonRunning(); |
85 | if (ret != last) { | 82 | if (ret != last) { |
86 | last = ret; | 83 | last = ret; |
87 | gtkSaveCall((GtkFunction) doUpdateMenus, &ret); | 84 | gtkSaveCall(&doUpdateMenus, &ret); |
88 | } | 85 | } |
89 | } | 86 | } |
90 | 87 | ||
diff --git a/src/plugins/fs/download.c b/src/plugins/fs/download.c index 644005b4..9947a2ef 100644 --- a/src/plugins/fs/download.c +++ b/src/plugins/fs/download.c | |||
@@ -25,9 +25,10 @@ | |||
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunetgtk_common.h" | ||
28 | #include "download.h" | 29 | #include "download.h" |
29 | #include "search.h" | 30 | #include "search.h" |
30 | #include "helper.h" | 31 | #include "fs.h" |
31 | #include <extractor.h> | 32 | #include <extractor.h> |
32 | 33 | ||
33 | typedef struct DL { | 34 | typedef struct DL { |
diff --git a/src/plugins/fs/download.h b/src/plugins/fs/download.h index 3a0a9463..a897d458 100644 --- a/src/plugins/fs/download.h +++ b/src/plugins/fs/download.h | |||
@@ -19,7 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file src/download.h | 22 | * @file src/plugins/fs/download.h |
23 | * @brief code for downloading with gnunet-gtk | 23 | * @brief code for downloading with gnunet-gtk |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
@@ -27,9 +27,7 @@ | |||
27 | #ifndef GTK_DOWNLOAD_H | 27 | #ifndef GTK_DOWNLOAD_H |
28 | #define GTK_DOWNLOAD_H | 28 | #define GTK_DOWNLOAD_H |
29 | 29 | ||
30 | #include "helper.h" | 30 | #include <GNUnet/gnunet_ecrs_lib.h> |
31 | #include "fs.h" | ||
32 | |||
33 | 31 | ||
34 | /** | 32 | /** |
35 | */ | 33 | */ |
@@ -47,5 +45,4 @@ void fs_download_start(void); | |||
47 | 45 | ||
48 | void fs_download_stop(void); | 46 | void fs_download_stop(void); |
49 | 47 | ||
50 | |||
51 | #endif | 48 | #endif |
diff --git a/src/plugins/fs/fs.c b/src/plugins/fs/fs.c index 8ee954a6..6b30d9d5 100644 --- a/src/plugins/fs/fs.c +++ b/src/plugins/fs/fs.c | |||
@@ -24,8 +24,9 @@ | |||
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "platform.h" | ||
28 | #include "gnunetgtk_common.h" | ||
27 | #include "fs.h" | 29 | #include "fs.h" |
28 | #include "helper.h" | ||
29 | #include "download.h" | 30 | #include "download.h" |
30 | #include "search.h" | 31 | #include "search.h" |
31 | #include "upload.h" | 32 | #include "upload.h" |
@@ -33,10 +34,9 @@ | |||
33 | 34 | ||
34 | struct FSUI_Context * ctx; | 35 | struct FSUI_Context * ctx; |
35 | 36 | ||
36 | static gint saveEventProcessor(SaveCall * call) { | 37 | static void saveEventProcessor(void * arg) { |
37 | const FSUI_Event * event; | 38 | const FSUI_Event * event = arg; |
38 | 39 | ||
39 | event = (const FSUI_Event *) call->args; | ||
40 | switch (event->type) { | 40 | switch (event->type) { |
41 | case FSUI_search_result: | 41 | case FSUI_search_result: |
42 | displaySearchResult(&event->data.SearchResult.fi, | 42 | displaySearchResult(&event->data.SearchResult.fi, |
@@ -106,9 +106,6 @@ static gint saveEventProcessor(SaveCall * call) { | |||
106 | event->type); | 106 | event->type); |
107 | break; | 107 | break; |
108 | } | 108 | } |
109 | |||
110 | gtkSaveCallDone(call->sem); | ||
111 | return FALSE; | ||
112 | } | 109 | } |
113 | 110 | ||
114 | /** | 111 | /** |
@@ -116,7 +113,7 @@ static gint saveEventProcessor(SaveCall * call) { | |||
116 | */ | 113 | */ |
117 | static void eventProcessor(void * cls, | 114 | static void eventProcessor(void * cls, |
118 | const FSUI_Event * event) { | 115 | const FSUI_Event * event) { |
119 | gtkSaveCall((GtkFunction) &saveEventProcessor, | 116 | gtkSaveCall(&saveEventProcessor, |
120 | (void*) event); | 117 | (void*) event); |
121 | } | 118 | } |
122 | 119 | ||
diff --git a/src/plugins/fs/fs.h b/src/plugins/fs/fs.h index f08904fc..085fb7ff 100644 --- a/src/plugins/fs/fs.h +++ b/src/plugins/fs/fs.h | |||
@@ -19,7 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file src/fs.h | 22 | * @file src/plugins/fs/fs.h |
23 | * @brief file-sharing globals of gnunet-gtk | 23 | * @brief file-sharing globals of gnunet-gtk |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
@@ -27,7 +27,6 @@ | |||
27 | #ifndef GTK_FS_H | 27 | #ifndef GTK_FS_H |
28 | #define GTK_FS_H | 28 | #define GTK_FS_H |
29 | 29 | ||
30 | #include <GNUnet/gnunet_util.h> | ||
31 | #include <GNUnet/gnunet_ecrs_lib.h> | 30 | #include <GNUnet/gnunet_ecrs_lib.h> |
32 | #include <GNUnet/gnunet_fsui_lib.h> | 31 | #include <GNUnet/gnunet_fsui_lib.h> |
33 | 32 | ||
@@ -80,11 +79,6 @@ enum { | |||
80 | KTYPE_NUM, | 79 | KTYPE_NUM, |
81 | }; | 80 | }; |
82 | 81 | ||
83 | |||
84 | extern struct FSUI_Context * ctx; | 82 | extern struct FSUI_Context * ctx; |
85 | 83 | ||
86 | void gtk_fs_init(void); | ||
87 | |||
88 | void gtk_fs_done(void); | ||
89 | |||
90 | #endif | 84 | #endif |
diff --git a/src/plugins/fs/search.c b/src/plugins/fs/search.c index 6fc8d830..ea98f4e4 100644 --- a/src/plugins/fs/search.c +++ b/src/plugins/fs/search.c | |||
@@ -25,8 +25,9 @@ | |||
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunetgtk_common.h" | ||
28 | #include "search.h" | 29 | #include "search.h" |
29 | #include "helper.h" | 30 | #include "fs.h" |
30 | #include <extractor.h> | 31 | #include <extractor.h> |
31 | 32 | ||
32 | /** | 33 | /** |
@@ -617,7 +618,7 @@ static int addNamespace(GtkListStore * model, | |||
617 | * cron job that periodically updates the model for the | 618 | * cron job that periodically updates the model for the |
618 | * namespace selection in the search vbox. | 619 | * namespace selection in the search vbox. |
619 | */ | 620 | */ |
620 | static gint updateNCBModelSafe(SaveCall * call) { | 621 | static void updateNCBModelSafe(void * unused) { |
621 | GtkWidget * searchNamespaceCB; | 622 | GtkWidget * searchNamespaceCB; |
622 | GtkListStore * model; | 623 | GtkListStore * model; |
623 | GtkTreeIter iter; | 624 | GtkTreeIter iter; |
@@ -644,12 +645,10 @@ static gint updateNCBModelSafe(SaveCall * call) { | |||
644 | if (-1 == gtk_combo_box_get_active(GTK_COMBO_BOX(searchNamespaceCB))) | 645 | if (-1 == gtk_combo_box_get_active(GTK_COMBO_BOX(searchNamespaceCB))) |
645 | gtk_combo_box_set_active(GTK_COMBO_BOX(searchNamespaceCB), | 646 | gtk_combo_box_set_active(GTK_COMBO_BOX(searchNamespaceCB), |
646 | 0); | 647 | 0); |
647 | gtkSaveCallDone(call->sem); | ||
648 | return FALSE; | ||
649 | } | 648 | } |
650 | 649 | ||
651 | static void updateNCBModel(void * call) { | 650 | static void updateNCBModel(void * dummy) { |
652 | gtkSaveCall((GtkFunction) updateNCBModelSafe, NULL); | 651 | gtkSaveCall(&updateNCBModelSafe, NULL); |
653 | } | 652 | } |
654 | 653 | ||
655 | /** | 654 | /** |
diff --git a/src/plugins/fs/search.h b/src/plugins/fs/search.h index c2c84d9c..b134ce3e 100644 --- a/src/plugins/fs/search.h +++ b/src/plugins/fs/search.h | |||
@@ -19,7 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file src/search.h | 22 | * @file src/plugins/fs/search.h |
23 | * @brief code for searching with gnunet-gtk | 23 | * @brief code for searching with gnunet-gtk |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
@@ -27,8 +27,7 @@ | |||
27 | #ifndef GTK_SEARCH_H | 27 | #ifndef GTK_SEARCH_H |
28 | #define GTK_SEARCH_H | 28 | #define GTK_SEARCH_H |
29 | 29 | ||
30 | #include "helper.h" | 30 | #include <GNUnet/gnunet_ecrs_lib.h> |
31 | #include "fs.h" | ||
32 | 31 | ||
33 | /** | 32 | /** |
34 | * Add an entry to the search tree. | 33 | * Add an entry to the search tree. |
diff --git a/src/plugins/fs/upload.c b/src/plugins/fs/upload.c index 63c5e03d..112935a1 100644 --- a/src/plugins/fs/upload.c +++ b/src/plugins/fs/upload.c | |||
@@ -19,21 +19,23 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file src/upload.c | 22 | * @file src/plugins/fs/upload.c |
23 | * @brief code for uploading with gnunet-gtk | 23 | * @brief code for uploading with gnunet-gtk |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunetgtk_common.h" | ||
28 | #include "search.h" | 29 | #include "search.h" |
29 | #include "upload.h" | 30 | #include "upload.h" |
31 | #include "fs.h" | ||
30 | #include <extractor.h> | 32 | #include <extractor.h> |
31 | 33 | ||
32 | #ifdef MINGW | 34 | #ifdef MINGW |
33 | #include <shlobj.h> | 35 | #include <shlobj.h> |
34 | #ifndef BIF_NONEWFOLDERBUTTON | 36 | #ifndef BIF_NONEWFOLDERBUTTON |
35 | #define BIF_NONEWFOLDERBUTTON 0x200 | 37 | #define BIF_NONEWFOLDERBUTTON 0x200 |
36 | #endif | 38 | #endif |
37 | #endif | 39 | #endif |
38 | 40 | ||
39 | 41 | ||
diff --git a/src/plugins/fs/upload.h b/src/plugins/fs/upload.h index fd1083d1..1f34b118 100644 --- a/src/plugins/fs/upload.h +++ b/src/plugins/fs/upload.h | |||
@@ -19,7 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file src/upload.h | 22 | * @file src/plugins/fs/upload.h |
23 | * @brief code for uploading with gnunet-gtk | 23 | * @brief code for uploading with gnunet-gtk |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
@@ -27,9 +27,6 @@ | |||
27 | #ifndef GTK_UPLOAD_H | 27 | #ifndef GTK_UPLOAD_H |
28 | #define GTK_UPLOAD_H | 28 | #define GTK_UPLOAD_H |
29 | 29 | ||
30 | #include "helper.h" | ||
31 | #include "fs.h" | ||
32 | |||
33 | /** | 30 | /** |
34 | */ | 31 | */ |
35 | void displayUploadUpdate(const char * mainName, | 32 | void displayUploadUpdate(const char * mainName, |
@@ -57,7 +54,6 @@ void displayUploadResult(const ECRS_FileInfo * info, | |||
57 | const struct ECRS_URI * uri, | 54 | const struct ECRS_URI * uri, |
58 | GtkTreeRowReference * row); | 55 | GtkTreeRowReference * row); |
59 | 56 | ||
60 | |||
61 | void fs_upload_start(void); | 57 | void fs_upload_start(void); |
62 | 58 | ||
63 | void fs_upload_stop(void); | 59 | void fs_upload_stop(void); |