diff options
author | ng0 <ng0@n0.is> | 2019-05-15 15:51:29 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-05-15 15:51:29 +0000 |
commit | 51cf7682ce12732f75365e2766f481132b3baaee (patch) | |
tree | a3f0a8e08c6e93a17216dc66236ad3e157878cd9 /src/fs | |
parent | f85786c61f2f03c6e3d2d7f00a6b1446bab3c41e (diff) | |
download | gnunet-gtk-51cf7682ce12732f75365e2766f481132b3baaee.tar.gz gnunet-gtk-51cf7682ce12732f75365e2766f481132b3baaee.zip |
clang-format all C code. Add symlink of clang-format to bootstrap.
Diffstat (limited to 'src/fs')
24 files changed, 3693 insertions, 3052 deletions
diff --git a/src/fs/gnunet-fs-gtk.c b/src/fs/gnunet-fs-gtk.c index 24bfdbe5..76e4154a 100644 --- a/src/fs/gnunet-fs-gtk.c +++ b/src/fs/gnunet-fs-gtk.c | |||
@@ -147,7 +147,8 @@ GNUNET_FS_GTK_get_main_window_object (const char *name) | |||
147 | GtkTreeModel * | 147 | GtkTreeModel * |
148 | GNUNET_FS_GTK_get_anonymity_level_list_store () | 148 | GNUNET_FS_GTK_get_anonymity_level_list_store () |
149 | { | 149 | { |
150 | return GTK_TREE_MODEL (GNUNET_FS_GTK_get_main_window_object ("anonymity_level_liststore")); | 150 | return GTK_TREE_MODEL ( |
151 | GNUNET_FS_GTK_get_main_window_object ("anonymity_level_liststore")); | ||
151 | } | 152 | } |
152 | 153 | ||
153 | 154 | ||
@@ -170,35 +171,48 @@ main_window_save_position (GtkWidget *main_window) | |||
170 | struct GNUNET_CONFIGURATION_Handle *cfg; | 171 | struct GNUNET_CONFIGURATION_Handle *cfg; |
171 | struct GNUNET_CONFIGURATION_Handle *cfgDefault; | 172 | struct GNUNET_CONFIGURATION_Handle *cfgDefault; |
172 | 173 | ||
173 | cfg = (struct GNUNET_CONFIGURATION_Handle *) GNUNET_GTK_main_loop_get_configuration (ml); | 174 | cfg = (struct GNUNET_CONFIGURATION_Handle *) |
175 | GNUNET_GTK_main_loop_get_configuration (ml); | ||
174 | main_window_gdk = gtk_widget_get_window (main_window); | 176 | main_window_gdk = gtk_widget_get_window (main_window); |
175 | maximized = GNUNET_YES; | 177 | maximized = GNUNET_YES; |
176 | if (NULL != main_window_gdk) | 178 | if (NULL != main_window_gdk) |
177 | { | 179 | { |
178 | window_state = gdk_window_get_state (main_window_gdk); | 180 | window_state = gdk_window_get_state (main_window_gdk); |
179 | if (!(window_state & GDK_WINDOW_STATE_MAXIMIZED)) | 181 | if (! (window_state & GDK_WINDOW_STATE_MAXIMIZED)) |
180 | maximized = GNUNET_NO; | 182 | maximized = GNUNET_NO; |
181 | } | 183 | } |
182 | 184 | ||
183 | gtk_window_get_position (GTK_WINDOW (main_window), &window_x, &window_y); | 185 | gtk_window_get_position (GTK_WINDOW (main_window), &window_x, &window_y); |
184 | gtk_window_get_size (GTK_WINDOW (main_window), &window_width, &window_height); | 186 | gtk_window_get_size (GTK_WINDOW (main_window), &window_width, &window_height); |
185 | 187 | ||
186 | GNUNET_CONFIGURATION_set_value_number (cfg, "gnunet-fs-gtk", | 188 | GNUNET_CONFIGURATION_set_value_number (cfg, |
187 | "MAIN_WINDOW_X", window_x); | 189 | "gnunet-fs-gtk", |
188 | GNUNET_CONFIGURATION_set_value_number (cfg, "gnunet-fs-gtk", | 190 | "MAIN_WINDOW_X", |
189 | "MAIN_WINDOW_Y", window_y); | 191 | window_x); |
190 | GNUNET_CONFIGURATION_set_value_number (cfg, "gnunet-fs-gtk", | 192 | GNUNET_CONFIGURATION_set_value_number (cfg, |
191 | "MAIN_WINDOW_WIDTH", window_width); | 193 | "gnunet-fs-gtk", |
192 | GNUNET_CONFIGURATION_set_value_number (cfg, "gnunet-fs-gtk", | 194 | "MAIN_WINDOW_Y", |
193 | "MAIN_WINDOW_HEIGHT", window_height); | 195 | window_y); |
194 | GNUNET_CONFIGURATION_set_value_string (cfg, "gnunet-fs-gtk", | 196 | GNUNET_CONFIGURATION_set_value_number (cfg, |
195 | "MAIN_WINDOW_MAXIMIZED", | 197 | "gnunet-fs-gtk", |
196 | (maximized == GNUNET_YES) ? "YES" : "NO"); | 198 | "MAIN_WINDOW_WIDTH", |
199 | window_width); | ||
200 | GNUNET_CONFIGURATION_set_value_number (cfg, | ||
201 | "gnunet-fs-gtk", | ||
202 | "MAIN_WINDOW_HEIGHT", | ||
203 | window_height); | ||
204 | GNUNET_CONFIGURATION_set_value_string (cfg, | ||
205 | "gnunet-fs-gtk", | ||
206 | "MAIN_WINDOW_MAXIMIZED", | ||
207 | (maximized == GNUNET_YES) ? "YES" | ||
208 | : "NO"); | ||
197 | 209 | ||
198 | cfgDefault = GNUNET_CONFIGURATION_create (); | 210 | cfgDefault = GNUNET_CONFIGURATION_create (); |
199 | (void) GNUNET_CONFIGURATION_load (cfgDefault, NULL); /* load defaults only */ | 211 | (void) GNUNET_CONFIGURATION_load (cfgDefault, NULL); /* load defaults only */ |
200 | GNUNET_CONFIGURATION_write_diffs (cfgDefault, cfg, | 212 | GNUNET_CONFIGURATION_write_diffs (cfgDefault, |
201 | GNUNET_GTK_main_loop_get_configuration_file (ml)); | 213 | cfg, |
214 | GNUNET_GTK_main_loop_get_configuration_file ( | ||
215 | ml)); | ||
202 | GNUNET_CONFIGURATION_destroy (cfgDefault); | 216 | GNUNET_CONFIGURATION_destroy (cfgDefault); |
203 | } | 217 | } |
204 | 218 | ||
@@ -213,8 +227,8 @@ main_window_save_position (GtkWidget *main_window) | |||
213 | */ | 227 | */ |
214 | gboolean | 228 | gboolean |
215 | GNUNET_GTK_main_window_configure_event_cb (GtkWidget *main_window, | 229 | GNUNET_GTK_main_window_configure_event_cb (GtkWidget *main_window, |
216 | GdkEventConfigure *event, | 230 | GdkEventConfigure *event, |
217 | gpointer user_data) | 231 | gpointer user_data) |
218 | { | 232 | { |
219 | struct GNUNET_GTK_MainWindowContext *main_context = user_data; | 233 | struct GNUNET_GTK_MainWindowContext *main_context = user_data; |
220 | 234 | ||
@@ -239,9 +253,7 @@ shutdown_task (void *cls) | |||
239 | { | 253 | { |
240 | GNUNET_FS_probe_stop (sr->probe); | 254 | GNUNET_FS_probe_stop (sr->probe); |
241 | sr->probe = NULL; | 255 | sr->probe = NULL; |
242 | GNUNET_CONTAINER_DLL_remove (pl_head, | 256 | GNUNET_CONTAINER_DLL_remove (pl_head, pl_tail, sr); |
243 | pl_tail, | ||
244 | sr); | ||
245 | } | 257 | } |
246 | if (NULL != fs) | 258 | if (NULL != fs) |
247 | { | 259 | { |
@@ -303,8 +315,7 @@ shutdown_task (void *cls) | |||
303 | * @param user_data global builder instance, unused | 315 | * @param user_data global builder instance, unused |
304 | */ | 316 | */ |
305 | void | 317 | void |
306 | GNUNET_FS_GTK_menu_quit_activate_cb (GtkMenuItem *object, | 318 | GNUNET_FS_GTK_menu_quit_activate_cb (GtkMenuItem *object, gpointer user_data) |
307 | gpointer user_data) | ||
308 | { | 319 | { |
309 | GNUNET_SCHEDULER_shutdown (); | 320 | GNUNET_SCHEDULER_shutdown (); |
310 | } | 321 | } |
@@ -319,8 +330,8 @@ GNUNET_FS_GTK_menu_quit_activate_cb (GtkMenuItem *object, | |||
319 | */ | 330 | */ |
320 | void | 331 | void |
321 | GNUNET_FS_GTK_delete_event_cb (GtkWidget *object, | 332 | GNUNET_FS_GTK_delete_event_cb (GtkWidget *object, |
322 | GdkEvent *event, | 333 | GdkEvent *event, |
323 | gpointer user_data) | 334 | gpointer user_data) |
324 | { | 335 | { |
325 | /* GNUNET_FS_GTK_delete_event_cb will eventually be called if we shut down | 336 | /* GNUNET_FS_GTK_delete_event_cb will eventually be called if we shut down |
326 | * the scheduler, because shutting it down will make GTK delete the main | 337 | * the scheduler, because shutting it down will make GTK delete the main |
@@ -342,9 +353,7 @@ GNUNET_FS_GTK_delete_event_cb (GtkWidget *object, | |||
342 | * @param data NULL | 353 | * @param data NULL |
343 | */ | 354 | */ |
344 | static void | 355 | static void |
345 | process_paste (GtkClipboard *cb, | 356 | process_paste (GtkClipboard *cb, const gchar *text, gpointer data) |
346 | const gchar *text, | ||
347 | gpointer data) | ||
348 | { | 357 | { |
349 | struct GNUNET_FS_Uri *kskuri; | 358 | struct GNUNET_FS_Uri *kskuri; |
350 | char *emsg; | 359 | char *emsg; |
@@ -375,15 +384,14 @@ process_paste (GtkClipboard *cb, | |||
375 | * TRUE if there is now a pop-up menu | 384 | * TRUE if there is now a pop-up menu |
376 | */ | 385 | */ |
377 | gboolean | 386 | gboolean |
378 | GNUNET_FS_GTK_main_window_button_press_event (GtkWidget * widget, | 387 | GNUNET_FS_GTK_main_window_button_press_event (GtkWidget *widget, |
379 | GdkEvent * event, | 388 | GdkEvent *event, |
380 | gpointer user_data) | 389 | gpointer user_data) |
381 | { | 390 | { |
382 | GdkEventButton *event_button = (GdkEventButton *) event; | 391 | GdkEventButton *event_button = (GdkEventButton *) event; |
383 | GtkClipboard *cb; | 392 | GtkClipboard *cb; |
384 | 393 | ||
385 | if ( (GDK_BUTTON_PRESS != event->type) || | 394 | if ((GDK_BUTTON_PRESS != event->type) || (2 != event_button->button)) |
386 | (2 != event_button->button) ) | ||
387 | return FALSE; | 395 | return FALSE; |
388 | cb = gtk_clipboard_get (gdk_atom_intern ("PRIMARY", FALSE)); | 396 | cb = gtk_clipboard_get (gdk_atom_intern ("PRIMARY", FALSE)); |
389 | gtk_clipboard_request_text (cb, &process_paste, NULL); | 397 | gtk_clipboard_request_text (cb, &process_paste, NULL); |
@@ -405,10 +413,10 @@ GNUNET_FS_GTK_main_window_button_press_event (GtkWidget * widget, | |||
405 | */ | 413 | */ |
406 | static UniqueResponse | 414 | static UniqueResponse |
407 | unique_app_message_cb (UniqueApp *app, | 415 | unique_app_message_cb (UniqueApp *app, |
408 | gint command, | 416 | gint command, |
409 | UniqueMessageData *message_data, | 417 | UniqueMessageData *message_data, |
410 | guint time_, | 418 | guint time_, |
411 | gpointer user_data) | 419 | gpointer user_data) |
412 | { | 420 | { |
413 | struct GNUNET_GTK_MainWindowContext *main_context = user_data; | 421 | struct GNUNET_GTK_MainWindowContext *main_context = user_data; |
414 | 422 | ||
@@ -418,46 +426,44 @@ unique_app_message_cb (UniqueApp *app, | |||
418 | time_); | 426 | time_); |
419 | 427 | ||
420 | switch (command) | 428 | switch (command) |
429 | { | ||
430 | case UNIQUE_NEW: | ||
431 | /* this is unexpected... */ | ||
432 | GNUNET_break (0); | ||
433 | break; | ||
434 | case UNIQUE_OPEN: { | ||
435 | gchar **uris; | ||
436 | gint n_uris; | ||
437 | gint i; | ||
438 | |||
439 | uris = unique_message_data_get_uris (message_data); | ||
440 | n_uris = g_strv_length (uris); | ||
441 | for (i = 0; i < n_uris; i++) | ||
421 | { | 442 | { |
422 | case UNIQUE_NEW: | 443 | if (GNUNET_OK != |
423 | /* this is unexpected... */ | 444 | GNUNET_FS_GTK_handle_uri_string (uris[i], 1 /* anonymity level */)) |
424 | GNUNET_break (0); | 445 | return UNIQUE_RESPONSE_PASSTHROUGH; |
425 | break; | ||
426 | case UNIQUE_OPEN: | ||
427 | { | ||
428 | gchar **uris; | ||
429 | gint n_uris; | ||
430 | gint i; | ||
431 | |||
432 | uris = unique_message_data_get_uris (message_data); | ||
433 | n_uris = g_strv_length (uris); | ||
434 | for (i = 0; i < n_uris; i++) | ||
435 | { | ||
436 | if (GNUNET_OK != | ||
437 | GNUNET_FS_GTK_handle_uri_string (uris[i], | ||
438 | 1 /* anonymity level */)) | ||
439 | return UNIQUE_RESPONSE_PASSTHROUGH; | ||
440 | } | ||
441 | g_strfreev (uris); | ||
442 | } | ||
443 | break; | ||
444 | case UNIQUE_ACTIVATE: | ||
445 | break; | ||
446 | default: | ||
447 | break; | ||
448 | } | 446 | } |
447 | g_strfreev (uris); | ||
448 | } | ||
449 | break; | ||
450 | case UNIQUE_ACTIVATE: | ||
451 | break; | ||
452 | default: | ||
453 | break; | ||
454 | } | ||
449 | return UNIQUE_RESPONSE_OK; | 455 | return UNIQUE_RESPONSE_OK; |
450 | } | 456 | } |
451 | #endif | 457 | #endif |
452 | 458 | ||
453 | 459 | ||
454 | static char * | 460 | static char * |
455 | format_service_list (unsigned int count, const char *const*list) | 461 | format_service_list (unsigned int count, const char *const *list) |
456 | { | 462 | { |
457 | size_t len = 0; | 463 | size_t len = 0; |
458 | int i; | 464 | int i; |
459 | const char *header = _("GNUnet node appears to be on."); | 465 | const char *header = _ ("GNUnet node appears to be on."); |
460 | const char *listheader = _("Currently running services:\n"); | 466 | const char *listheader = _ ("Currently running services:\n"); |
461 | char *result; | 467 | char *result; |
462 | char *p; | 468 | char *p; |
463 | int r; | 469 | int r; |
@@ -506,9 +512,9 @@ format_service_list (unsigned int count, const char *const*list) | |||
506 | 512 | ||
507 | static void | 513 | static void |
508 | service_list_callback (void *cls, | 514 | service_list_callback (void *cls, |
509 | enum GNUNET_ARM_RequestStatus rs, | 515 | enum GNUNET_ARM_RequestStatus rs, |
510 | unsigned int count, | 516 | unsigned int count, |
511 | const char *const*list) | 517 | const char *const *list) |
512 | { | 518 | { |
513 | char *service_list; | 519 | char *service_list; |
514 | 520 | ||
@@ -521,8 +527,7 @@ service_list_callback (void *cls, | |||
521 | 527 | ||
522 | 528 | ||
523 | static void | 529 | static void |
524 | arm_connection_state_change (void *cls, | 530 | arm_connection_state_change (void *cls, int connected) |
525 | int connected) | ||
526 | { | 531 | { |
527 | char *service_list; | 532 | char *service_list; |
528 | 533 | ||
@@ -531,27 +536,27 @@ arm_connection_state_change (void *cls, | |||
531 | service_list = format_service_list (0, NULL); | 536 | service_list = format_service_list (0, NULL); |
532 | GNUNET_FS_GTK_update_connection_indicator (cls, TRUE, service_list); | 537 | GNUNET_FS_GTK_update_connection_indicator (cls, TRUE, service_list); |
533 | GNUNET_free_non_null (service_list); | 538 | GNUNET_free_non_null (service_list); |
534 | GNUNET_ARM_request_service_list (arm, | 539 | GNUNET_ARM_request_service_list (arm, &service_list_callback, cls); |
535 | &service_list_callback, cls); | ||
536 | } | 540 | } |
537 | else | 541 | else |
538 | GNUNET_FS_GTK_update_connection_indicator (cls, FALSE, | 542 | GNUNET_FS_GTK_update_connection_indicator ( |
539 | _("Can't connect to the Automatic Restart Manager service.")); | 543 | cls, |
544 | FALSE, | ||
545 | _ ("Can't connect to the Automatic Restart Manager service.")); | ||
540 | } | 546 | } |
541 | 547 | ||
542 | 548 | ||
543 | static void | 549 | static void |
544 | service_status_change (void *cls, | 550 | service_status_change (void *cls, |
545 | const char *service, | 551 | const char *service, |
546 | enum GNUNET_ARM_ServiceStatus status) | 552 | enum GNUNET_ARM_ServiceStatus status) |
547 | { | 553 | { |
548 | /* Very crude, we can probably do better. | 554 | /* Very crude, we can probably do better. |
549 | * Maybe keep a list of running services, and modify it in response | 555 | * Maybe keep a list of running services, and modify it in response |
550 | * to service status changes, then update the indicator, | 556 | * to service status changes, then update the indicator, |
551 | * without requesting a list from ARM every goddamned time? | 557 | * without requesting a list from ARM every goddamned time? |
552 | */ | 558 | */ |
553 | GNUNET_ARM_request_service_list (arm, | 559 | GNUNET_ARM_request_service_list (arm, &service_list_callback, cls); |
554 | &service_list_callback, cls); | ||
555 | } | 560 | } |
556 | 561 | ||
557 | 562 | ||
@@ -560,16 +565,19 @@ monitor_zone_error (void *cls) | |||
560 | { | 565 | { |
561 | GtkListStore *ls; | 566 | GtkListStore *ls; |
562 | 567 | ||
563 | ls = GTK_LIST_STORE (GNUNET_FS_GTK_get_main_window_object ("namespace_label_liststore")); | 568 | ls = GTK_LIST_STORE ( |
569 | GNUNET_FS_GTK_get_main_window_object ("namespace_label_liststore")); | ||
564 | gtk_list_store_clear (ls); | 570 | gtk_list_store_clear (ls); |
565 | gtk_widget_hide (GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ("main_window_search_namespace_combobox"))); | 571 | gtk_widget_hide (GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ( |
572 | "main_window_search_namespace_combobox"))); | ||
566 | } | 573 | } |
567 | 574 | ||
568 | 575 | ||
569 | static void | 576 | static void |
570 | monitor_zone_sync (void *cls) | 577 | monitor_zone_sync (void *cls) |
571 | { | 578 | { |
572 | gtk_widget_show (GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ("main_window_search_namespace_combobox"))); | 579 | gtk_widget_show (GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ( |
580 | "main_window_search_namespace_combobox"))); | ||
573 | } | 581 | } |
574 | 582 | ||
575 | 583 | ||
@@ -587,10 +595,10 @@ monitor_zone_sync (void *cls) | |||
587 | */ | 595 | */ |
588 | static void | 596 | static void |
589 | monitor_zone_records (void *cls, | 597 | monitor_zone_records (void *cls, |
590 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 598 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
591 | const char *label, | 599 | const char *label, |
592 | unsigned int rd_count, | 600 | unsigned int rd_count, |
593 | const struct GNUNET_GNSRECORD_Data *rd) | 601 | const struct GNUNET_GNSRECORD_Data *rd) |
594 | { | 602 | { |
595 | GtkListStore *ls; | 603 | GtkListStore *ls; |
596 | GtkTreeModel *tm; | 604 | GtkTreeModel *tm; |
@@ -598,39 +606,30 @@ monitor_zone_records (void *cls, | |||
598 | gchar *id; | 606 | gchar *id; |
599 | gchar *label_gnu; | 607 | gchar *label_gnu; |
600 | 608 | ||
601 | GNUNET_NAMESTORE_zone_monitor_next (main_context.zm, | 609 | GNUNET_NAMESTORE_zone_monitor_next (main_context.zm, 1); |
602 | 1); | 610 | ls = GTK_LIST_STORE ( |
603 | ls = GTK_LIST_STORE (GNUNET_FS_GTK_get_main_window_object ("namespace_label_liststore")); | 611 | GNUNET_FS_GTK_get_main_window_object ("namespace_label_liststore")); |
604 | label_gnu = g_strdup_printf ("%s.%s", | 612 | label_gnu = g_strdup_printf ("%s.%s", label, "gnu"); |
605 | label, | ||
606 | "gnu"); | ||
607 | if (0 == rd_count) | 613 | if (0 == rd_count) |
608 | { | 614 | { |
609 | tm = GTK_TREE_MODEL (ls); | 615 | tm = GTK_TREE_MODEL (ls); |
610 | if (gtk_tree_model_get_iter_first (tm, &iter)) | 616 | if (gtk_tree_model_get_iter_first (tm, &iter)) |
611 | do | 617 | do |
612 | { | 618 | { |
613 | gtk_tree_model_get (tm, &iter, | 619 | gtk_tree_model_get (tm, &iter, 0, &id, -1); |
614 | 0, &id, | 620 | if (0 == strcmp (id, label_gnu)) |
615 | -1); | 621 | { |
616 | if (0 == strcmp (id, label_gnu)) | 622 | GNUNET_assert (gtk_list_store_remove (ls, &iter)); |
617 | { | 623 | g_free (id); |
618 | GNUNET_assert (gtk_list_store_remove (ls, &iter)); | 624 | g_free (label_gnu); |
619 | g_free (id); | 625 | return; |
620 | g_free (label_gnu); | 626 | } |
621 | return; | 627 | g_free (id); |
622 | } | 628 | } while (gtk_tree_model_iter_next (tm, &iter)); |
623 | g_free (id); | ||
624 | } | ||
625 | while (gtk_tree_model_iter_next (tm, &iter)); | ||
626 | GNUNET_break (0); | 629 | GNUNET_break (0); |
627 | return; | 630 | return; |
628 | } | 631 | } |
629 | gtk_list_store_insert_with_values (ls, | 632 | gtk_list_store_insert_with_values (ls, &iter, -1, 0, label_gnu, -1); |
630 | &iter, | ||
631 | -1, | ||
632 | 0, label_gnu, | ||
633 | -1); | ||
634 | g_free (label_gnu); | 633 | g_free (label_gnu); |
635 | } | 634 | } |
636 | 635 | ||
@@ -649,31 +648,35 @@ monitor_zone_records (void *cls, | |||
649 | */ | 648 | */ |
650 | static void | 649 | static void |
651 | handle_sks_zone_identity (void *cls, | 650 | handle_sks_zone_identity (void *cls, |
652 | struct GNUNET_IDENTITY_Ego *ego, | 651 | struct GNUNET_IDENTITY_Ego *ego, |
653 | void **ctx, | 652 | void **ctx, |
654 | const char *name) | 653 | const char *name) |
655 | { | 654 | { |
656 | main_context.id_op = NULL; | 655 | main_context.id_op = NULL; |
657 | 656 | ||
658 | if (NULL == ego) | 657 | if (NULL == ego) |
659 | { | 658 | { |
660 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 659 | GNUNET_log ( |
661 | _("No default ego specified for `fs-sks` service, will not enable namespace search.\n")); | 660 | GNUNET_ERROR_TYPE_WARNING, |
661 | _ ( | ||
662 | "No default ego specified for `fs-sks` service, will not enable namespace search.\n")); | ||
662 | return; | 663 | return; |
663 | } | 664 | } |
664 | main_context.sks_zone = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPrivateKey); | 665 | main_context.sks_zone = GNUNET_new (struct GNUNET_CRYPTO_EcdsaPrivateKey); |
665 | *main_context.sks_zone = *GNUNET_IDENTITY_ego_get_private_key (ego); | 666 | *main_context.sks_zone = *GNUNET_IDENTITY_ego_get_private_key (ego); |
666 | gtk_widget_show (GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ("main_window_search_namespace_label"))); | 667 | gtk_widget_show (GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ( |
667 | gtk_widget_show (GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ("main_window_search_namespace_combobox"))); | 668 | "main_window_search_namespace_label"))); |
669 | gtk_widget_show (GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ( | ||
670 | "main_window_search_namespace_combobox"))); | ||
668 | main_context.zm = GNUNET_NAMESTORE_zone_monitor_start (main_context.cfg, | 671 | main_context.zm = GNUNET_NAMESTORE_zone_monitor_start (main_context.cfg, |
669 | main_context.sks_zone, | 672 | main_context.sks_zone, |
670 | GNUNET_YES, | 673 | GNUNET_YES, |
671 | &monitor_zone_error, | 674 | &monitor_zone_error, |
672 | NULL, | 675 | NULL, |
673 | &monitor_zone_records, | 676 | &monitor_zone_records, |
674 | NULL, | 677 | NULL, |
675 | &monitor_zone_sync, | 678 | &monitor_zone_sync, |
676 | NULL); | 679 | NULL); |
677 | } | 680 | } |
678 | 681 | ||
679 | 682 | ||
@@ -700,36 +703,68 @@ run (void *cls) | |||
700 | return; | 703 | return; |
701 | main_context.builder = GNUNET_GTK_main_loop_get_builder (ml); | 704 | main_context.builder = GNUNET_GTK_main_loop_get_builder (ml); |
702 | main_context.cfg = GNUNET_GTK_main_loop_get_configuration (ml); | 705 | main_context.cfg = GNUNET_GTK_main_loop_get_configuration (ml); |
703 | main_context.search_ns_treestore = GTK_TREE_STORE (GNUNET_FS_GTK_get_main_window_object ("main_window_search_namespace_treestore")); | 706 | main_context.search_ns_treestore = |
704 | main_context.main_window = GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window")); | 707 | GTK_TREE_STORE (GNUNET_FS_GTK_get_main_window_object ( |
705 | main_context.main_window = GNUNET_GTK_plug_me ("GNUNET_FS_GTK_PLUG", | 708 | "main_window_search_namespace_treestore")); |
706 | main_context.main_window); | 709 | main_context.main_window = GTK_WIDGET ( |
707 | main_context.ns_selector_treeview = GTK_TREE_VIEW (GNUNET_FS_GTK_get_main_window_object ("namespace_selector_treeview")); | 710 | GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window")); |
708 | main_context.ns_selector_window = GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ("namespace_selector_window")); | 711 | main_context.main_window = |
709 | main_context.ns_dropdown_button = GTK_TOGGLE_BUTTON (GNUNET_FS_GTK_get_main_window_object ("main_window_search_namespace_dropdown_button")); | 712 | GNUNET_GTK_plug_me ("GNUNET_FS_GTK_PLUG", main_context.main_window); |
710 | main_context.search_ns_label = GTK_LABEL (GNUNET_FS_GTK_get_main_window_object ("main_window_search_selected_namespace_label")); | 713 | main_context.ns_selector_treeview = GTK_TREE_VIEW ( |
711 | 714 | GNUNET_FS_GTK_get_main_window_object ("namespace_selector_treeview")); | |
712 | main_context.search_entry = GTK_ENTRY (GNUNET_FS_GTK_get_main_window_object ("main_window_search_entry")); | 715 | main_context.ns_selector_window = GTK_WIDGET ( |
713 | 716 | GNUNET_FS_GTK_get_main_window_object ("namespace_selector_window")); | |
714 | downloads_treestore = GTK_TREE_STORE (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_file_sharing_downloads_tree_store")); | 717 | main_context.ns_dropdown_button = |
715 | main_context.anonymity_combo = GTK_COMBO_BOX (GNUNET_FS_GTK_get_main_window_object ("main_window_search_anonymity_combobox")); | 718 | GTK_TOGGLE_BUTTON (GNUNET_FS_GTK_get_main_window_object ( |
716 | main_context.anonymity_level_liststore = GTK_LIST_STORE (GNUNET_FS_GTK_get_main_window_object ("anonymity_level_liststore")); | 719 | "main_window_search_namespace_dropdown_button")); |
717 | 720 | main_context.search_ns_label = | |
718 | main_context.preview_image = GTK_IMAGE (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window_preview_image")); | 721 | GTK_LABEL (GNUNET_FS_GTK_get_main_window_object ( |
719 | main_context.md_liststore = GTK_LIST_STORE (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_meta_data_list_store")); | 722 | "main_window_search_selected_namespace_label")); |
720 | main_context.md_treeview = GTK_TREE_VIEW (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window_metadata_treeview")); | 723 | |
724 | main_context.search_entry = GTK_ENTRY ( | ||
725 | GNUNET_FS_GTK_get_main_window_object ("main_window_search_entry")); | ||
726 | |||
727 | downloads_treestore = GTK_TREE_STORE (GNUNET_FS_GTK_get_main_window_object ( | ||
728 | "GNUNET_GTK_file_sharing_downloads_tree_store")); | ||
729 | main_context.anonymity_combo = | ||
730 | GTK_COMBO_BOX (GNUNET_FS_GTK_get_main_window_object ( | ||
731 | "main_window_search_anonymity_combobox")); | ||
732 | main_context.anonymity_level_liststore = GTK_LIST_STORE ( | ||
733 | GNUNET_FS_GTK_get_main_window_object ("anonymity_level_liststore")); | ||
734 | |||
735 | main_context.preview_image = GTK_IMAGE (GNUNET_FS_GTK_get_main_window_object ( | ||
736 | "GNUNET_GTK_main_window_preview_image")); | ||
737 | main_context.md_liststore = GTK_LIST_STORE ( | ||
738 | GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_meta_data_list_store")); | ||
739 | main_context.md_treeview = | ||
740 | GTK_TREE_VIEW (GNUNET_FS_GTK_get_main_window_object ( | ||
741 | "GNUNET_GTK_main_window_metadata_treeview")); | ||
721 | main_context.ns_discovery_handle = NULL; | 742 | main_context.ns_discovery_handle = NULL; |
722 | 743 | ||
723 | main_context.download_location_chooser = GTK_FILE_CHOOSER (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_search_frame_download_location_chooser")); | 744 | main_context.download_location_chooser = |
724 | main_context.download_name_entry = GTK_ENTRY (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_search_frame_download_filename_entry")); | 745 | GTK_FILE_CHOOSER (GNUNET_FS_GTK_get_main_window_object ( |
725 | main_context.download_anonymity_combo = GTK_COMBO_BOX (GNUNET_FS_GTK_get_main_window_object ("main_window_download_anonymity_combobox")); | 746 | "GNUNET_GTK_search_frame_download_location_chooser")); |
726 | main_context.download_recursive_checkbutton = GTK_CHECK_BUTTON (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_search_frame_download_recursive_checkbox")); | 747 | main_context.download_name_entry = |
727 | main_context.download_download_button = GTK_BUTTON (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_search_frame_download_download_button")); | 748 | GTK_ENTRY (GNUNET_FS_GTK_get_main_window_object ( |
728 | main_context.download_panel = GTK_BOX (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_search_frame_download_vbox")); | 749 | "GNUNET_GTK_search_frame_download_filename_entry")); |
729 | 750 | main_context.download_anonymity_combo = | |
730 | main_context.notebook = GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window_notebook")); | 751 | GTK_COMBO_BOX (GNUNET_FS_GTK_get_main_window_object ( |
731 | 752 | "main_window_download_anonymity_combobox")); | |
732 | main_context.connection_indicator = GTK_IMAGE (GNUNET_FS_GTK_get_main_window_object ("GNUNET_FS_GTK_main_window_connection_indicator")); | 753 | main_context.download_recursive_checkbutton = |
754 | GTK_CHECK_BUTTON (GNUNET_FS_GTK_get_main_window_object ( | ||
755 | "GNUNET_GTK_search_frame_download_recursive_checkbox")); | ||
756 | main_context.download_download_button = | ||
757 | GTK_BUTTON (GNUNET_FS_GTK_get_main_window_object ( | ||
758 | "GNUNET_GTK_search_frame_download_download_button")); | ||
759 | main_context.download_panel = GTK_BOX (GNUNET_FS_GTK_get_main_window_object ( | ||
760 | "GNUNET_GTK_search_frame_download_vbox")); | ||
761 | |||
762 | main_context.notebook = GTK_NOTEBOOK ( | ||
763 | GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window_notebook")); | ||
764 | |||
765 | main_context.connection_indicator = | ||
766 | GTK_IMAGE (GNUNET_FS_GTK_get_main_window_object ( | ||
767 | "GNUNET_FS_GTK_main_window_connection_indicator")); | ||
733 | 768 | ||
734 | GNUNET_GTK_set_icon_search_path (); | 769 | GNUNET_GTK_set_icon_search_path (); |
735 | GNUNET_GTK_setup_nls (); | 770 | GNUNET_GTK_setup_nls (); |
@@ -743,22 +778,32 @@ run (void *cls) | |||
743 | 778 | ||
744 | /* setup main window */ | 779 | /* setup main window */ |
745 | maximized = GNUNET_CONFIGURATION_get_value_yesno (main_context.cfg, | 780 | maximized = GNUNET_CONFIGURATION_get_value_yesno (main_context.cfg, |
746 | "gnunet-fs-gtk", | 781 | "gnunet-fs-gtk", |
747 | "MAIN_WINDOW_MAXIMIZED"); | 782 | "MAIN_WINDOW_MAXIMIZED"); |
748 | if (GNUNET_SYSERR == maximized) | 783 | if (GNUNET_SYSERR == maximized) |
749 | maximized = GNUNET_YES; | 784 | maximized = GNUNET_YES; |
750 | if ( (GNUNET_NO == maximized) && | 785 | if ((GNUNET_NO == maximized) && |
751 | (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context.cfg, "gnunet-fs-gtk", | 786 | (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context.cfg, |
752 | "MAIN_WINDOW_X", &window_x)) && | 787 | "gnunet-fs-gtk", |
753 | (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context.cfg, "gnunet-fs-gtk", | 788 | "MAIN_WINDOW_X", |
754 | "MAIN_WINDOW_Y", &window_y)) && | 789 | &window_x)) && |
755 | (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context.cfg, "gnunet-fs-gtk", | 790 | (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context.cfg, |
756 | "MAIN_WINDOW_WIDTH", &window_width)) && | 791 | "gnunet-fs-gtk", |
757 | (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context.cfg, "gnunet-fs-gtk", | 792 | "MAIN_WINDOW_Y", |
758 | "MAIN_WINDOW_HEIGHT", &window_height)) ) | 793 | &window_y)) && |
794 | (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context.cfg, | ||
795 | "gnunet-fs-gtk", | ||
796 | "MAIN_WINDOW_WIDTH", | ||
797 | &window_width)) && | ||
798 | (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (main_context.cfg, | ||
799 | "gnunet-fs-gtk", | ||
800 | "MAIN_WINDOW_HEIGHT", | ||
801 | &window_height))) | ||
759 | { | 802 | { |
760 | gtk_window_move (GTK_WINDOW (main_context.main_window), window_x, window_y); | 803 | gtk_window_move (GTK_WINDOW (main_context.main_window), window_x, window_y); |
761 | gtk_window_resize (GTK_WINDOW (main_context.main_window), window_width, window_height); | 804 | gtk_window_resize (GTK_WINDOW (main_context.main_window), |
805 | window_width, | ||
806 | window_height); | ||
762 | } | 807 | } |
763 | else | 808 | else |
764 | { | 809 | { |
@@ -769,7 +814,8 @@ run (void *cls) | |||
769 | /* Allow multiple selection in metadata view; */ | 814 | /* Allow multiple selection in metadata view; */ |
770 | /* FIXME-GTK3: this can be done within (modern versions of) glade | 815 | /* FIXME-GTK3: this can be done within (modern versions of) glade |
771 | (However, this needs GTK >= 3.2, we currently target 3.0) */ | 816 | (However, this needs GTK >= 3.2, we currently target 3.0) */ |
772 | gtk_tree_selection_set_mode (gtk_tree_view_get_selection (main_context.md_treeview), | 817 | gtk_tree_selection_set_mode (gtk_tree_view_get_selection ( |
818 | main_context.md_treeview), | ||
773 | GTK_SELECTION_MULTIPLE); | 819 | GTK_SELECTION_MULTIPLE); |
774 | 820 | ||
775 | /* FIXME: should these '1's be here? Maybe better to put them into | 821 | /* FIXME: should these '1's be here? Maybe better to put them into |
@@ -789,9 +835,11 @@ run (void *cls) | |||
789 | req_parallel = DEFAULT_MAX_PARALLEL_REQUESTS; | 835 | req_parallel = DEFAULT_MAX_PARALLEL_REQUESTS; |
790 | 836 | ||
791 | /* initialize file-sharing */ | 837 | /* initialize file-sharing */ |
792 | fs = GNUNET_FS_start (main_context.cfg, "gnunet-fs-gtk", | 838 | fs = GNUNET_FS_start (main_context.cfg, |
793 | &GNUNET_GTK_fs_event_handler, NULL, | 839 | "gnunet-fs-gtk", |
794 | GNUNET_FS_FLAGS_PERSISTENCE | GNUNET_FS_FLAGS_DO_PROBES, | 840 | &GNUNET_GTK_fs_event_handler, |
841 | NULL, | ||
842 | GNUNET_FS_FLAGS_PERSISTENCE | GNUNET_FS_FLAGS_DO_PROBES, | ||
795 | GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM, | 843 | GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM, |
796 | (unsigned int) dl_parallel, | 844 | (unsigned int) dl_parallel, |
797 | GNUNET_FS_OPTIONS_REQUEST_PARALLELISM, | 845 | GNUNET_FS_OPTIONS_REQUEST_PARALLELISM, |
@@ -809,15 +857,18 @@ run (void *cls) | |||
809 | &service_status_change, | 857 | &service_status_change, |
810 | &main_context); | 858 | &main_context); |
811 | main_context.gns = GNUNET_GNS_connect (main_context.cfg); | 859 | main_context.gns = GNUNET_GNS_connect (main_context.cfg); |
812 | main_context.identity = GNUNET_IDENTITY_connect (main_context.cfg, NULL, NULL); | 860 | main_context.identity = |
861 | GNUNET_IDENTITY_connect (main_context.cfg, NULL, NULL); | ||
813 | main_context.id_op = GNUNET_IDENTITY_get (main_context.identity, | 862 | main_context.id_op = GNUNET_IDENTITY_get (main_context.identity, |
814 | "fs-sks", | 863 | "fs-sks", |
815 | &handle_sks_zone_identity, | 864 | &handle_sks_zone_identity, |
816 | NULL); | 865 | NULL); |
817 | #if HAVE_LIBUNIQUE | 866 | #if HAVE_LIBUNIQUE |
818 | unique_app_watch_window (unique_app, GTK_WINDOW (main_context.main_window)); | 867 | unique_app_watch_window (unique_app, GTK_WINDOW (main_context.main_window)); |
819 | g_signal_connect (unique_app, "message-received", | 868 | g_signal_connect (unique_app, |
820 | G_CALLBACK (unique_app_message_cb), &main_context); | 869 | "message-received", |
870 | G_CALLBACK (unique_app_message_cb), | ||
871 | &main_context); | ||
821 | #endif | 872 | #endif |
822 | /* make GUI visible */ | 873 | /* make GUI visible */ |
823 | gtk_widget_show (main_context.main_window); | 874 | gtk_widget_show (main_context.main_window); |
@@ -831,14 +882,11 @@ run (void *cls) | |||
831 | GNUNET_GTK_main_loop_get_args (ml, &argc, &argv); | 882 | GNUNET_GTK_main_loop_get_args (ml, &argc, &argv); |
832 | 883 | ||
833 | for (i = 0; i < argc; i++) | 884 | for (i = 0; i < argc; i++) |
834 | { | 885 | { |
835 | if (GNUNET_OK != | 886 | if (GNUNET_OK != |
836 | GNUNET_FS_GTK_handle_uri_string (argv[i], | 887 | GNUNET_FS_GTK_handle_uri_string (argv[i], 1 /* anonymity level */)) |
837 | 1 /* anonymity level */)) | 888 | fprintf (stderr, "Invalid URI `%s'\n", argv[i]); |
838 | fprintf (stderr, | 889 | } |
839 | "Invalid URI `%s'\n", | ||
840 | argv[i]); | ||
841 | } | ||
842 | } | 890 | } |
843 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); | 891 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
844 | } | 892 | } |
@@ -848,8 +896,7 @@ int | |||
848 | main (int argc, char **argv) | 896 | main (int argc, char **argv) |
849 | { | 897 | { |
850 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | 898 | static struct GNUNET_GETOPT_CommandLineOption options[] = { |
851 | GNUNET_GETOPT_OPTION_END | 899 | GNUNET_GETOPT_OPTION_END}; |
852 | }; | ||
853 | #if HAVE_LIBUNIQUE | 900 | #if HAVE_LIBUNIQUE |
854 | int arge; | 901 | int arge; |
855 | 902 | ||
@@ -859,20 +906,16 @@ main (int argc, char **argv) | |||
859 | { | 906 | { |
860 | UniqueResponse response; | 907 | UniqueResponse response; |
861 | 908 | ||
862 | arge = GNUNET_GETOPT_run ("gnunet-fs-gtk", | 909 | arge = GNUNET_GETOPT_run ("gnunet-fs-gtk", options, argc, argv); |
863 | options, | ||
864 | argc, argv); | ||
865 | response = unique_app_send_message (unique_app, UNIQUE_ACTIVATE, NULL); | 910 | response = unique_app_send_message (unique_app, UNIQUE_ACTIVATE, NULL); |
866 | while (arge < argc) | 911 | while (arge < argc) |
867 | { | 912 | { |
868 | UniqueMessageData *msg; | 913 | UniqueMessageData *msg; |
869 | 914 | ||
870 | msg = unique_message_data_new (); | 915 | msg = unique_message_data_new (); |
871 | unique_message_data_set_text (msg, argv[arge], strlen (argv[arge])+1); | 916 | unique_message_data_set_text (msg, argv[arge], strlen (argv[arge]) + 1); |
872 | if (UNIQUE_RESPONSE_OK == response) | 917 | if (UNIQUE_RESPONSE_OK == response) |
873 | response = unique_app_send_message (unique_app, | 918 | response = unique_app_send_message (unique_app, UNIQUE_OPEN, msg); |
874 | UNIQUE_OPEN, | ||
875 | msg); | ||
876 | unique_message_data_free (msg); | 919 | unique_message_data_free (msg); |
877 | arge++; | 920 | arge++; |
878 | } | 921 | } |
@@ -884,11 +927,12 @@ main (int argc, char **argv) | |||
884 | #endif | 927 | #endif |
885 | if (GNUNET_OK != | 928 | if (GNUNET_OK != |
886 | GNUNET_GTK_main_loop_start ("gnunet-fs-gtk", | 929 | GNUNET_GTK_main_loop_start ("gnunet-fs-gtk", |
887 | "GTK GUI for GNUnet", | 930 | "GTK GUI for GNUnet", |
888 | argc, argv, | 931 | argc, |
889 | options, | 932 | argv, |
933 | options, | ||
890 | "gnunet_fs_gtk_main_window.glade", | 934 | "gnunet_fs_gtk_main_window.glade", |
891 | &run)) | 935 | &run)) |
892 | { | 936 | { |
893 | #if HAVE_LIBUNIQUE | 937 | #if HAVE_LIBUNIQUE |
894 | g_object_unref (unique_app); | 938 | g_object_unref (unique_app); |
diff --git a/src/fs/gnunet-fs-gtk.h b/src/fs/gnunet-fs-gtk.h index c8464aa8..e968efc7 100644 --- a/src/fs/gnunet-fs-gtk.h +++ b/src/fs/gnunet-fs-gtk.h | |||
@@ -65,13 +65,12 @@ struct SearchLookup | |||
65 | /** | 65 | /** |
66 | * Task to trigger timeout. | 66 | * Task to trigger timeout. |
67 | */ | 67 | */ |
68 | struct GNUNET_SCHEDULER_Task * timeout_task; | 68 | struct GNUNET_SCHEDULER_Task *timeout_task; |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * Desired anonymity level. | 71 | * Desired anonymity level. |
72 | */ | 72 | */ |
73 | guint anonymity_level; | 73 | guint anonymity_level; |
74 | |||
75 | }; | 74 | }; |
76 | 75 | ||
77 | 76 | ||
@@ -140,7 +139,6 @@ struct PseuLookupContext | |||
140 | * Nickname we're saving under. | 139 | * Nickname we're saving under. |
141 | */ | 140 | */ |
142 | char *nick; | 141 | char *nick; |
143 | |||
144 | }; | 142 | }; |
145 | 143 | ||
146 | 144 | ||
@@ -256,7 +254,6 @@ struct GNUNET_GTK_MainWindowContext | |||
256 | * Our zone for SKS operations. Can be NULL. | 254 | * Our zone for SKS operations. Can be NULL. |
257 | */ | 255 | */ |
258 | struct GNUNET_CRYPTO_EcdsaPrivateKey *sks_zone; | 256 | struct GNUNET_CRYPTO_EcdsaPrivateKey *sks_zone; |
259 | |||
260 | }; | 257 | }; |
261 | 258 | ||
262 | 259 | ||
@@ -264,86 +261,86 @@ struct GNUNET_GTK_MainWindowContext | |||
264 | * Columns in the search namespace model. | 261 | * Columns in the search namespace model. |
265 | */ | 262 | */ |
266 | enum GNUNET_GTK_FS_MAIN_WINDOW_SearchNamespaceModelColumns | 263 | enum GNUNET_GTK_FS_MAIN_WINDOW_SearchNamespaceModelColumns |
267 | { | 264 | { |
268 | /** | 265 | /** |
269 | * A gchararray. | 266 | * A gchararray. |
270 | */ | 267 | */ |
271 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_NAME = 0, | 268 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_NAME = 0, |
272 | 269 | ||
273 | /** | 270 | /** |
274 | * A gpointer. | 271 | * A gpointer. |
275 | */ | 272 | */ |
276 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_KEY = 1, | 273 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_KEY = 1, |
277 | 274 | ||
278 | /** | 275 | /** |
279 | * A gchararray. | 276 | * A gchararray. |
280 | */ | 277 | */ |
281 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_ROOT = 2, | 278 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_ROOT = 2, |
282 | 279 | ||
283 | /** | 280 | /** |
284 | * A gchararray. | 281 | * A gchararray. |
285 | */ | 282 | */ |
286 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_TOOLTIP = 3, | 283 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_NAMESPACE_MC_TOOLTIP = 3, |
287 | }; | 284 | }; |
288 | 285 | ||
289 | 286 | ||
290 | /** | 287 | /** |
291 | * Columns in the meta data model. | 288 | * Columns in the meta data model. |
292 | */ | 289 | */ |
293 | enum GNUNET_GTK_FS_MAIN_WINDOW_MetaDataModelColumns | 290 | enum GNUNET_GTK_FS_MAIN_WINDOW_MetaDataModelColumns |
294 | { | 291 | { |
295 | /** | 292 | /** |
296 | * A guint. | 293 | * A guint. |
297 | */ | 294 | */ |
298 | GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_TYPE = 0, | 295 | GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_TYPE = 0, |
299 | 296 | ||
300 | /** | 297 | /** |
301 | * A guint. | 298 | * A guint. |
302 | */ | 299 | */ |
303 | GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_FORMAT = 1, | 300 | GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_FORMAT = 1, |
304 | 301 | ||
305 | /** | 302 | /** |
306 | * A gchararray. | 303 | * A gchararray. |
307 | */ | 304 | */ |
308 | GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_TYPE_STRING = 2, | 305 | GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_TYPE_STRING = 2, |
309 | 306 | ||
310 | /** | 307 | /** |
311 | * A gchararray. | 308 | * A gchararray. |
312 | */ | 309 | */ |
313 | GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_VALUE = 3, | 310 | GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_VALUE = 3, |
314 | }; | 311 | }; |
315 | 312 | ||
316 | 313 | ||
317 | /** | 314 | /** |
318 | * Columns in the search mime model. | 315 | * Columns in the search mime model. |
319 | */ | 316 | */ |
320 | enum GNUNET_GTK_FS_MAIN_WINDOW_SearchMimeModelColumns | 317 | enum GNUNET_GTK_FS_MAIN_WINDOW_SearchMimeModelColumns |
321 | { | 318 | { |
322 | /** | 319 | /** |
323 | * A gchararray. | 320 | * A gchararray. |
324 | */ | 321 | */ |
325 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_MIME_MC_MIME = 0, | 322 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_MIME_MC_MIME = 0, |
326 | 323 | ||
327 | /** | 324 | /** |
328 | * A gchararray. | 325 | * A gchararray. |
329 | */ | 326 | */ |
330 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_MIME_MC_TYPE = 1, | 327 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_MIME_MC_TYPE = 1, |
331 | 328 | ||
332 | /** | 329 | /** |
333 | * A gchararray. | 330 | * A gchararray. |
334 | */ | 331 | */ |
335 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_MIME_MC_EXTENSION = 2, | 332 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_MIME_MC_EXTENSION = 2, |
336 | 333 | ||
337 | /** | 334 | /** |
338 | * A gchararray. | 335 | * A gchararray. |
339 | */ | 336 | */ |
340 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_MIME_MC_LOSSYNESS = 3, | 337 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_MIME_MC_LOSSYNESS = 3, |
341 | 338 | ||
342 | /** | 339 | /** |
343 | * A gchararray. | 340 | * A gchararray. |
344 | */ | 341 | */ |
345 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_MIME_MC_FREEDOM = 4, | 342 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_MIME_MC_FREEDOM = 4, |
346 | }; | 343 | }; |
347 | 344 | ||
348 | /** | 345 | /** |
349 | * Get main context. | 346 | * Get main context. |
@@ -404,8 +401,9 @@ GNUNET_FS_GTK_get_main_window_object (const char *name); | |||
404 | * @return TRUE on success, FALSE on error | 401 | * @return TRUE on success, FALSE on error |
405 | */ | 402 | */ |
406 | gboolean | 403 | gboolean |
407 | GNUNET_GTK_get_selected_anonymity_level (GtkBuilder * builder, | 404 | GNUNET_GTK_get_selected_anonymity_level (GtkBuilder *builder, |
408 | gchar * combo_name, guint * p_level); | 405 | gchar *combo_name, |
406 | guint *p_level); | ||
409 | 407 | ||
410 | 408 | ||
411 | /** | 409 | /** |
@@ -416,7 +414,8 @@ GNUNET_GTK_get_selected_anonymity_level (GtkBuilder * builder, | |||
416 | * @return TRUE on success, FALSE on error | 414 | * @return TRUE on success, FALSE on error |
417 | */ | 415 | */ |
418 | gboolean | 416 | gboolean |
419 | GNUNET_GTK_get_selected_anonymity_combo_level (GtkComboBox *combo, guint *p_level); | 417 | GNUNET_GTK_get_selected_anonymity_combo_level (GtkComboBox *combo, |
418 | guint *p_level); | ||
420 | 419 | ||
421 | 420 | ||
422 | /** | 421 | /** |
@@ -429,7 +428,8 @@ GNUNET_GTK_get_selected_anonymity_combo_level (GtkComboBox *combo, guint *p_leve | |||
429 | * @return TRUE on success, FALSE on error (no item with such level) | 428 | * @return TRUE on success, FALSE on error (no item with such level) |
430 | */ | 429 | */ |
431 | gboolean | 430 | gboolean |
432 | GNUNET_GTK_select_anonymity_level (GtkBuilder * builder, gchar * combo_name, | 431 | GNUNET_GTK_select_anonymity_level (GtkBuilder *builder, |
432 | gchar *combo_name, | ||
433 | guint sel_level); | 433 | guint sel_level); |
434 | 434 | ||
435 | 435 | ||
diff --git a/src/fs/gnunet-fs-gtk_about.c b/src/fs/gnunet-fs-gtk_about.c index 51f6e6fe..917b713d 100644 --- a/src/fs/gnunet-fs-gtk_about.c +++ b/src/fs/gnunet-fs-gtk_about.c | |||
@@ -35,7 +35,7 @@ | |||
35 | * @param data global builder, unused | 35 | * @param data global builder, unused |
36 | */ | 36 | */ |
37 | void | 37 | void |
38 | GNUNET_GTK_main_menu_help_about_activate_cb (GtkWidget * dummy, gpointer data) | 38 | GNUNET_GTK_main_menu_help_about_activate_cb (GtkWidget *dummy, gpointer data) |
39 | { | 39 | { |
40 | GNUNET_GTK_display_about ("gnunet_fs_gtk_about_window.glade"); | 40 | GNUNET_GTK_display_about ("gnunet_fs_gtk_about_window.glade"); |
41 | } | 41 | } |
diff --git a/src/fs/gnunet-fs-gtk_anonymity-widgets.c b/src/fs/gnunet-fs-gtk_anonymity-widgets.c index 4d53bf52..7b870323 100644 --- a/src/fs/gnunet-fs-gtk_anonymity-widgets.c +++ b/src/fs/gnunet-fs-gtk_anonymity-widgets.c | |||
@@ -37,7 +37,7 @@ | |||
37 | * @param data the builder's closure, unused | 37 | * @param data the builder's closure, unused |
38 | */ | 38 | */ |
39 | void | 39 | void |
40 | GNUNET_GTK_anonymity_spin_button_value_changed_cb (GtkWidget * w, gpointer data) | 40 | GNUNET_GTK_anonymity_spin_button_value_changed_cb (GtkWidget *w, gpointer data) |
41 | { | 41 | { |
42 | #ifdef GdkRBGA | 42 | #ifdef GdkRBGA |
43 | GtkSpinButton *spin; | 43 | GtkSpinButton *spin; |
@@ -83,13 +83,14 @@ GNUNET_GTK_anonymity_spin_button_value_changed_cb (GtkWidget * w, gpointer data) | |||
83 | * @return TRUE on success, FALSE on failure | 83 | * @return TRUE on success, FALSE on failure |
84 | */ | 84 | */ |
85 | gboolean | 85 | gboolean |
86 | GNUNET_GTK_select_anonymity_level (GtkBuilder * builder, gchar * combo_name, | 86 | GNUNET_GTK_select_anonymity_level (GtkBuilder *builder, |
87 | gchar *combo_name, | ||
87 | guint sel_level) | 88 | guint sel_level) |
88 | { | 89 | { |
89 | GtkComboBox *combo; | 90 | GtkComboBox *combo; |
90 | 91 | ||
91 | combo = GTK_COMBO_BOX (gtk_builder_get_object (builder, combo_name)); | 92 | combo = GTK_COMBO_BOX (gtk_builder_get_object (builder, combo_name)); |
92 | if (!combo) | 93 | if (! combo) |
93 | return FALSE; | 94 | return FALSE; |
94 | return GNUNET_GTK_select_anonymity_combo_level (combo, sel_level); | 95 | return GNUNET_GTK_select_anonymity_combo_level (combo, sel_level); |
95 | } | 96 | } |
@@ -110,13 +111,14 @@ GNUNET_GTK_select_anonymity_combo_level (GtkComboBox *combo, guint sel_level) | |||
110 | guint level; | 111 | guint level; |
111 | 112 | ||
112 | model = gtk_combo_box_get_model (combo); | 113 | model = gtk_combo_box_get_model (combo); |
113 | if (!model) | 114 | if (! model) |
114 | return FALSE; | 115 | return FALSE; |
115 | if (! gtk_tree_model_get_iter_first (model, &iter)) | 116 | if (! gtk_tree_model_get_iter_first (model, &iter)) |
116 | return FALSE; | 117 | return FALSE; |
117 | do | 118 | do |
118 | { | 119 | { |
119 | gtk_tree_model_get (model, &iter, | 120 | gtk_tree_model_get (model, |
121 | &iter, | ||
120 | GNUNET_GTK_ANONYMITY_LEVEL_MC_LEVEL, | 122 | GNUNET_GTK_ANONYMITY_LEVEL_MC_LEVEL, |
121 | &level, | 123 | &level, |
122 | -1); | 124 | -1); |
@@ -125,11 +127,9 @@ GNUNET_GTK_select_anonymity_combo_level (GtkComboBox *combo, guint sel_level) | |||
125 | gtk_combo_box_set_active_iter (combo, &iter); | 127 | gtk_combo_box_set_active_iter (combo, &iter); |
126 | return TRUE; | 128 | return TRUE; |
127 | } | 129 | } |
128 | } | 130 | } while (gtk_tree_model_iter_next (model, &iter)); |
129 | while (gtk_tree_model_iter_next (model, &iter)); | ||
130 | return FALSE; | 131 | return FALSE; |
131 | } | 132 | } |
132 | 133 | ||
133 | 134 | ||
134 | |||
135 | /* end of gnunet-fs-gtk-anonymtiy_spin_buttons.c */ | 135 | /* end of gnunet-fs-gtk-anonymtiy_spin_buttons.c */ |
diff --git a/src/fs/gnunet-fs-gtk_anonymity-widgets.h b/src/fs/gnunet-fs-gtk_anonymity-widgets.h index 46fc3077..53122446 100644 --- a/src/fs/gnunet-fs-gtk_anonymity-widgets.h +++ b/src/fs/gnunet-fs-gtk_anonymity-widgets.h | |||
@@ -38,7 +38,8 @@ | |||
38 | * @return TRUE on success, FALSE on failure | 38 | * @return TRUE on success, FALSE on failure |
39 | */ | 39 | */ |
40 | gboolean | 40 | gboolean |
41 | GNUNET_GTK_select_anonymity_level (GtkBuilder * builder, gchar * combo_name, | 41 | GNUNET_GTK_select_anonymity_level (GtkBuilder *builder, |
42 | gchar *combo_name, | ||
42 | guint sel_level); | 43 | guint sel_level); |
43 | 44 | ||
44 | 45 | ||
diff --git a/src/fs/gnunet-fs-gtk_common.c b/src/fs/gnunet-fs-gtk_common.c index 6ae17e1e..743456e9 100644 --- a/src/fs/gnunet-fs-gtk_common.c +++ b/src/fs/gnunet-fs-gtk_common.c | |||
@@ -44,7 +44,8 @@ | |||
44 | */ | 44 | */ |
45 | char * | 45 | char * |
46 | GNUNET_FS_GTK_dubious_meta_to_utf8 (enum EXTRACTOR_MetaFormat format, | 46 | GNUNET_FS_GTK_dubious_meta_to_utf8 (enum EXTRACTOR_MetaFormat format, |
47 | const char *data, size_t data_len) | 47 | const char *data, |
48 | size_t data_len) | ||
48 | { | 49 | { |
49 | switch (format) | 50 | switch (format) |
50 | { | 51 | { |
@@ -52,10 +53,12 @@ GNUNET_FS_GTK_dubious_meta_to_utf8 (enum EXTRACTOR_MetaFormat format, | |||
52 | /* data must not contain NULLs (hence the -1) */ | 53 | /* data must not contain NULLs (hence the -1) */ |
53 | if (g_utf8_validate (data, data_len - 1, NULL)) | 54 | if (g_utf8_validate (data, data_len - 1, NULL)) |
54 | return GNUNET_strdup (data); | 55 | return GNUNET_strdup (data); |
55 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 56 | GNUNET_log ( |
56 | _("Failed to validate supposedly utf-8 string `%s' of length %u, assuming it to be a C string\n"), | 57 | GNUNET_ERROR_TYPE_INFO, |
57 | data, | 58 | _ ( |
58 | (unsigned int) data_len); | 59 | "Failed to validate supposedly utf-8 string `%s' of length %u, assuming it to be a C string\n"), |
60 | data, | ||
61 | (unsigned int) data_len); | ||
59 | format = EXTRACTOR_METAFORMAT_C_STRING; | 62 | format = EXTRACTOR_METAFORMAT_C_STRING; |
60 | /* fall-through */ | 63 | /* fall-through */ |
61 | case EXTRACTOR_METAFORMAT_C_STRING: | 64 | case EXTRACTOR_METAFORMAT_C_STRING: |
@@ -95,11 +98,13 @@ GNUNET_FS_GTK_dubious_meta_to_utf8 (enum EXTRACTOR_MetaFormat format, | |||
95 | * @return 0 to continue (always) | 98 | * @return 0 to continue (always) |
96 | */ | 99 | */ |
97 | int | 100 | int |
98 | GNUNET_FS_GTK_add_meta_data_to_list_store (void *cls, const char *plugin_name, | 101 | GNUNET_FS_GTK_add_meta_data_to_list_store (void *cls, |
102 | const char *plugin_name, | ||
99 | enum EXTRACTOR_MetaType type, | 103 | enum EXTRACTOR_MetaType type, |
100 | enum EXTRACTOR_MetaFormat format, | 104 | enum EXTRACTOR_MetaFormat format, |
101 | const char *data_mime_type, | 105 | const char *data_mime_type, |
102 | const char *data, size_t data_len) | 106 | const char *data, |
107 | size_t data_len) | ||
103 | { | 108 | { |
104 | GtkListStore *ls = GTK_LIST_STORE (cls); | 109 | GtkListStore *ls = GTK_LIST_STORE (cls); |
105 | char *data_to_insert; | 110 | char *data_to_insert; |
@@ -107,18 +112,21 @@ GNUNET_FS_GTK_add_meta_data_to_list_store (void *cls, const char *plugin_name, | |||
107 | data_to_insert = GNUNET_FS_GTK_dubious_meta_to_utf8 (format, data, data_len); | 112 | data_to_insert = GNUNET_FS_GTK_dubious_meta_to_utf8 (format, data, data_len); |
108 | if (NULL == data_to_insert) | 113 | if (NULL == data_to_insert) |
109 | return 0; | 114 | return 0; |
110 | gtk_list_store_insert_with_values (ls, NULL, G_MAXINT, | 115 | gtk_list_store_insert_with_values ( |
111 | GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_TYPE, | 116 | ls, |
112 | type, | 117 | NULL, |
113 | GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_FORMAT, | 118 | G_MAXINT, |
114 | format, | 119 | GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_TYPE, |
120 | type, | ||
121 | GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_FORMAT, | ||
122 | format, | ||
115 | #if HAVE_EXTRACTOR | 123 | #if HAVE_EXTRACTOR |
116 | GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_TYPE_STRING, | 124 | GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_TYPE_STRING, |
117 | EXTRACTOR_metatype_to_string (type), | 125 | EXTRACTOR_metatype_to_string (type), |
118 | #endif | 126 | #endif |
119 | GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_VALUE, | 127 | GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_VALUE, |
120 | data_to_insert, | 128 | data_to_insert, |
121 | -1); | 129 | -1); |
122 | GNUNET_free (data_to_insert); | 130 | GNUNET_free (data_to_insert); |
123 | return 0; | 131 | return 0; |
124 | } | 132 | } |
@@ -131,8 +139,8 @@ GNUNET_FS_GTK_add_meta_data_to_list_store (void *cls, const char *plugin_name, | |||
131 | * @return NULL on error, otherwise the embedded thumbnail | 139 | * @return NULL on error, otherwise the embedded thumbnail |
132 | */ | 140 | */ |
133 | GdkPixbuf * | 141 | GdkPixbuf * |
134 | GNUNET_FS_GTK_get_thumbnail_from_meta_data (const struct | 142 | GNUNET_FS_GTK_get_thumbnail_from_meta_data ( |
135 | GNUNET_CONTAINER_MetaData *meta) | 143 | const struct GNUNET_CONTAINER_MetaData *meta) |
136 | { | 144 | { |
137 | GdkPixbuf *pixbuf; | 145 | GdkPixbuf *pixbuf; |
138 | GdkPixbufLoader *loader; | 146 | GdkPixbufLoader *loader; |
@@ -175,7 +183,8 @@ GNUNET_FS_GTK_mmap_and_scan (const char *filename, | |||
175 | void *ddata; | 183 | void *ddata; |
176 | int ret; | 184 | int ret; |
177 | 185 | ||
178 | if (GNUNET_OK != GNUNET_DISK_file_size (filename, &fsize, GNUNET_YES, GNUNET_YES)) | 186 | if (GNUNET_OK != |
187 | GNUNET_DISK_file_size (filename, &fsize, GNUNET_YES, GNUNET_YES)) | ||
179 | { | 188 | { |
180 | GNUNET_break (0); | 189 | GNUNET_break (0); |
181 | return GNUNET_SYSERR; | 190 | return GNUNET_SYSERR; |
@@ -185,24 +194,31 @@ GNUNET_FS_GTK_mmap_and_scan (const char *filename, | |||
185 | /* empty file, cannot be a directory */ | 194 | /* empty file, cannot be a directory */ |
186 | return GNUNET_SYSERR; | 195 | return GNUNET_SYSERR; |
187 | } | 196 | } |
188 | if (NULL == (fh = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ, | 197 | if (NULL == (fh = GNUNET_DISK_file_open (filename, |
189 | GNUNET_DISK_PERM_NONE))) | 198 | GNUNET_DISK_OPEN_READ, |
199 | GNUNET_DISK_PERM_NONE))) | ||
190 | { | 200 | { |
191 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", filename); | 201 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", filename); |
192 | return GNUNET_SYSERR; | 202 | return GNUNET_SYSERR; |
193 | } | 203 | } |
194 | if (NULL == (ddata = GNUNET_DISK_file_map (fh, &mh, GNUNET_DISK_MAP_TYPE_READ, (size_t) fsize))) | 204 | if (NULL == (ddata = GNUNET_DISK_file_map (fh, |
205 | &mh, | ||
206 | GNUNET_DISK_MAP_TYPE_READ, | ||
207 | (size_t) fsize))) | ||
195 | { | 208 | { |
196 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "mmap", filename); | 209 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "mmap", filename); |
197 | GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fh)); | 210 | GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fh)); |
198 | return GNUNET_SYSERR; | 211 | return GNUNET_SYSERR; |
199 | } | 212 | } |
200 | if (GNUNET_SYSERR == | 213 | if (GNUNET_SYSERR == GNUNET_FS_directory_list_contents ((size_t) fsize, |
201 | GNUNET_FS_directory_list_contents ((size_t) fsize, ddata, 0, dep, | 214 | ddata, |
202 | dep_cls)) | 215 | 0, |
216 | dep, | ||
217 | dep_cls)) | ||
203 | { | 218 | { |
204 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 219 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
205 | _("Selected file `%s' is not a GNUnet directory!\n"), filename); | 220 | _ ("Selected file `%s' is not a GNUnet directory!\n"), |
221 | filename); | ||
206 | ret = GNUNET_SYSERR; | 222 | ret = GNUNET_SYSERR; |
207 | } | 223 | } |
208 | else | 224 | else |
@@ -225,38 +241,39 @@ GNUNET_FS_GTK_mmap_and_scan (const char *filename, | |||
225 | * @return description of the result in utf-8, never NULL | 241 | * @return description of the result in utf-8, never NULL |
226 | */ | 242 | */ |
227 | char * | 243 | char * |
228 | GNUNET_FS_GTK_get_description_from_metadata (const struct GNUNET_CONTAINER_MetaData *meta, | 244 | GNUNET_FS_GTK_get_description_from_metadata ( |
229 | int *is_a_dup) | 245 | const struct GNUNET_CONTAINER_MetaData *meta, |
246 | int *is_a_dup) | ||
230 | { | 247 | { |
231 | char *desc; | 248 | char *desc; |
232 | char *utf8_desc; | 249 | char *utf8_desc; |
233 | 250 | ||
234 | desc = | 251 | desc = GNUNET_CONTAINER_meta_data_get_first_by_types ( |
235 | GNUNET_CONTAINER_meta_data_get_first_by_types (meta, | 252 | meta, |
236 | EXTRACTOR_METATYPE_PACKAGE_NAME, | 253 | EXTRACTOR_METATYPE_PACKAGE_NAME, |
237 | EXTRACTOR_METATYPE_TITLE, | 254 | EXTRACTOR_METATYPE_TITLE, |
238 | EXTRACTOR_METATYPE_BOOK_TITLE, | 255 | EXTRACTOR_METATYPE_BOOK_TITLE, |
239 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, | 256 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, |
240 | EXTRACTOR_METATYPE_FILENAME, | 257 | EXTRACTOR_METATYPE_FILENAME, |
241 | EXTRACTOR_METATYPE_DESCRIPTION, | 258 | EXTRACTOR_METATYPE_DESCRIPTION, |
242 | EXTRACTOR_METATYPE_ALBUM, | 259 | EXTRACTOR_METATYPE_ALBUM, |
243 | EXTRACTOR_METATYPE_COMMENT, | 260 | EXTRACTOR_METATYPE_COMMENT, |
244 | EXTRACTOR_METATYPE_SUBJECT, | 261 | EXTRACTOR_METATYPE_SUBJECT, |
245 | EXTRACTOR_METATYPE_KEYWORDS, | 262 | EXTRACTOR_METATYPE_KEYWORDS, |
246 | -1); | 263 | -1); |
247 | if (desc == NULL) | 264 | if (desc == NULL) |
248 | { | 265 | { |
249 | *is_a_dup = GNUNET_YES; | 266 | *is_a_dup = GNUNET_YES; |
250 | return GNUNET_strdup (_("no description supplied")); | 267 | return GNUNET_strdup (_ ("no description supplied")); |
251 | } | 268 | } |
252 | utf8_desc = | 269 | utf8_desc = GNUNET_FS_GTK_dubious_meta_to_utf8 (EXTRACTOR_METAFORMAT_UTF8, |
253 | GNUNET_FS_GTK_dubious_meta_to_utf8 (EXTRACTOR_METAFORMAT_UTF8, desc, | 270 | desc, |
254 | strlen (desc) + 1); | 271 | strlen (desc) + 1); |
255 | GNUNET_free (desc); | 272 | GNUNET_free (desc); |
256 | if (utf8_desc == NULL) | 273 | if (utf8_desc == NULL) |
257 | { | 274 | { |
258 | *is_a_dup = GNUNET_YES; | 275 | *is_a_dup = GNUNET_YES; |
259 | return GNUNET_strdup (_("no description supplied")); | 276 | return GNUNET_strdup (_ ("no description supplied")); |
260 | } | 277 | } |
261 | *is_a_dup = GNUNET_NO; | 278 | *is_a_dup = GNUNET_NO; |
262 | return utf8_desc; | 279 | return utf8_desc; |
@@ -272,7 +289,7 @@ GNUNET_FS_GTK_get_description_from_metadata (const struct GNUNET_CONTAINER_MetaD | |||
272 | */ | 289 | */ |
273 | void | 290 | void |
274 | GNUNET_FS_GTK_handle_uri (const struct GNUNET_FS_Uri *uri, | 291 | GNUNET_FS_GTK_handle_uri (const struct GNUNET_FS_Uri *uri, |
275 | guint anonymity_level) | 292 | guint anonymity_level) |
276 | { | 293 | { |
277 | GtkEntry *query_entry; | 294 | GtkEntry *query_entry; |
278 | GtkComboBox *ns_cb; | 295 | GtkComboBox *ns_cb; |
@@ -290,14 +307,15 @@ GNUNET_FS_GTK_handle_uri (const struct GNUNET_FS_Uri *uri, | |||
290 | GNUNET_FS_GTK_open_download_as_dialog (de); | 307 | GNUNET_FS_GTK_open_download_as_dialog (de); |
291 | return; | 308 | return; |
292 | } | 309 | } |
293 | query_entry = GTK_ENTRY (GNUNET_FS_GTK_get_main_window_object ("main_window_search_entry")); | 310 | query_entry = GTK_ENTRY ( |
294 | ns_cb = GTK_COMBO_BOX (GNUNET_FS_GTK_get_main_window_object ("main_window_search_namespace_combobox")); | 311 | GNUNET_FS_GTK_get_main_window_object ("main_window_search_entry")); |
312 | ns_cb = GTK_COMBO_BOX (GNUNET_FS_GTK_get_main_window_object ( | ||
313 | "main_window_search_namespace_combobox")); | ||
295 | ns_entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (ns_cb))); | 314 | ns_entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (ns_cb))); |
296 | if (GNUNET_FS_uri_test_sks (uri)) | 315 | if (GNUNET_FS_uri_test_sks (uri)) |
297 | { | 316 | { |
298 | /* select the namespace */ | 317 | /* select the namespace */ |
299 | if (GNUNET_OK != | 318 | if (GNUNET_OK != GNUNET_FS_uri_sks_get_namespace (uri, &want)) |
300 | GNUNET_FS_uri_sks_get_namespace (uri, &want)) | ||
301 | { | 319 | { |
302 | GNUNET_break (0); | 320 | GNUNET_break (0); |
303 | return; | 321 | return; |
@@ -306,16 +324,14 @@ GNUNET_FS_GTK_handle_uri (const struct GNUNET_FS_Uri *uri, | |||
306 | const char *ns_zkey; | 324 | const char *ns_zkey; |
307 | 325 | ||
308 | ns_zkey = GNUNET_GNSRECORD_pkey_to_zkey (&want); | 326 | ns_zkey = GNUNET_GNSRECORD_pkey_to_zkey (&want); |
309 | gtk_entry_set_text (ns_entry, | 327 | gtk_entry_set_text (ns_entry, ns_zkey); |
310 | ns_zkey); | ||
311 | } | 328 | } |
312 | /* set search entry to the namespace identifier */ | 329 | /* set search entry to the namespace identifier */ |
313 | { | 330 | { |
314 | char *query_string; | 331 | char *query_string; |
315 | 332 | ||
316 | query_string = GNUNET_FS_uri_sks_get_content_id (uri); | 333 | query_string = GNUNET_FS_uri_sks_get_content_id (uri); |
317 | gtk_entry_set_text (query_entry, | 334 | gtk_entry_set_text (query_entry, query_string); |
318 | query_string); | ||
319 | GNUNET_free (query_string); | 335 | GNUNET_free (query_string); |
320 | } | 336 | } |
321 | return; | 337 | return; |
@@ -329,8 +345,7 @@ GNUNET_FS_GTK_handle_uri (const struct GNUNET_FS_Uri *uri, | |||
329 | char *query_string; | 345 | char *query_string; |
330 | 346 | ||
331 | query_string = GNUNET_FS_uri_ksk_to_string_fancy (uri); | 347 | query_string = GNUNET_FS_uri_ksk_to_string_fancy (uri); |
332 | gtk_entry_set_text (query_entry, | 348 | gtk_entry_set_text (query_entry, query_string); |
333 | query_string); | ||
334 | GNUNET_free (query_string); | 349 | GNUNET_free (query_string); |
335 | } | 350 | } |
336 | return; | 351 | return; |
@@ -347,8 +362,7 @@ GNUNET_FS_GTK_handle_uri (const struct GNUNET_FS_Uri *uri, | |||
347 | * @return #GNUNET_OK if iter was filled, #GNUNET_SYSERR otherwise | 362 | * @return #GNUNET_OK if iter was filled, #GNUNET_SYSERR otherwise |
348 | */ | 363 | */ |
349 | int | 364 | int |
350 | GNUNET_GTK_get_iter_from_reference (GtkTreeRowReference *rr, | 365 | GNUNET_GTK_get_iter_from_reference (GtkTreeRowReference *rr, GtkTreeIter *iter) |
351 | GtkTreeIter *iter) | ||
352 | { | 366 | { |
353 | int result = GNUNET_SYSERR; | 367 | int result = GNUNET_SYSERR; |
354 | if (rr != NULL) | 368 | if (rr != NULL) |
@@ -361,8 +375,7 @@ GNUNET_GTK_get_iter_from_reference (GtkTreeRowReference *rr, | |||
361 | model = gtk_tree_row_reference_get_model (rr); | 375 | model = gtk_tree_row_reference_get_model (rr); |
362 | if (path != NULL && model != NULL) | 376 | if (path != NULL && model != NULL) |
363 | { | 377 | { |
364 | if (gtk_tree_model_get_iter (model, | 378 | if (gtk_tree_model_get_iter (model, iter, path)) |
365 | iter, path)) | ||
366 | result = GNUNET_OK; | 379 | result = GNUNET_OK; |
367 | gtk_tree_path_free (path); | 380 | gtk_tree_path_free (path); |
368 | } | 381 | } |
@@ -415,9 +428,9 @@ GNUNET_GTK_get_reference_from_iter (GtkTreeModel *model, GtkTreeIter *iter) | |||
415 | */ | 428 | */ |
416 | gboolean | 429 | gboolean |
417 | GNUNET_GTK_tree_model_get_next_flat_iter (GtkTreeModel *model, | 430 | GNUNET_GTK_tree_model_get_next_flat_iter (GtkTreeModel *model, |
418 | GtkTreeIter *iter, | 431 | GtkTreeIter *iter, |
419 | gboolean allow_children, | 432 | gboolean allow_children, |
420 | GtkTreeIter *next_iter) | 433 | GtkTreeIter *next_iter) |
421 | { | 434 | { |
422 | GtkTreeIter current_iter = *iter; | 435 | GtkTreeIter current_iter = *iter; |
423 | while (TRUE) | 436 | while (TRUE) |
@@ -439,7 +452,7 @@ GNUNET_GTK_tree_model_get_next_flat_iter (GtkTreeModel *model, | |||
439 | } | 452 | } |
440 | } | 453 | } |
441 | allow_children = FALSE; | 454 | allow_children = FALSE; |
442 | if (!gtk_tree_model_iter_parent (model, &tmp_iter, ¤t_iter)) | 455 | if (! gtk_tree_model_iter_parent (model, &tmp_iter, ¤t_iter)) |
443 | return FALSE; | 456 | return FALSE; |
444 | current_iter = tmp_iter; | 457 | current_iter = tmp_iter; |
445 | } | 458 | } |
diff --git a/src/fs/gnunet-fs-gtk_common.h b/src/fs/gnunet-fs-gtk_common.h index 64d04341..0665e8dc 100644 --- a/src/fs/gnunet-fs-gtk_common.h +++ b/src/fs/gnunet-fs-gtk_common.h | |||
@@ -40,8 +40,8 @@ | |||
40 | * @return NULL on error, otherwise the embedded thumbnail | 40 | * @return NULL on error, otherwise the embedded thumbnail |
41 | */ | 41 | */ |
42 | GdkPixbuf * | 42 | GdkPixbuf * |
43 | GNUNET_FS_GTK_get_thumbnail_from_meta_data (const struct | 43 | GNUNET_FS_GTK_get_thumbnail_from_meta_data ( |
44 | GNUNET_CONTAINER_MetaData *meta); | 44 | const struct GNUNET_CONTAINER_MetaData *meta); |
45 | 45 | ||
46 | 46 | ||
47 | /** | 47 | /** |
@@ -76,11 +76,13 @@ GNUNET_FS_GTK_mmap_and_scan (const char *filename, | |||
76 | * @return 0 to continue (always) | 76 | * @return 0 to continue (always) |
77 | */ | 77 | */ |
78 | int | 78 | int |
79 | GNUNET_FS_GTK_add_meta_data_to_list_store (void *cls, const char *plugin_name, | 79 | GNUNET_FS_GTK_add_meta_data_to_list_store (void *cls, |
80 | const char *plugin_name, | ||
80 | enum EXTRACTOR_MetaType type, | 81 | enum EXTRACTOR_MetaType type, |
81 | enum EXTRACTOR_MetaFormat format, | 82 | enum EXTRACTOR_MetaFormat format, |
82 | const char *data_mime_type, | 83 | const char *data_mime_type, |
83 | const char *data, size_t data_len); | 84 | const char *data, |
85 | size_t data_len); | ||
84 | 86 | ||
85 | 87 | ||
86 | /** | 88 | /** |
@@ -98,8 +100,8 @@ GNUNET_FS_GTK_add_meta_data_to_list_store (void *cls, const char *plugin_name, | |||
98 | */ | 100 | */ |
99 | char * | 101 | char * |
100 | GNUNET_FS_GTK_dubious_meta_to_utf8 (enum EXTRACTOR_MetaFormat format, | 102 | GNUNET_FS_GTK_dubious_meta_to_utf8 (enum EXTRACTOR_MetaFormat format, |
101 | const char *data, size_t data_len); | 103 | const char *data, |
102 | 104 | size_t data_len); | |
103 | 105 | ||
104 | 106 | ||
105 | /** | 107 | /** |
@@ -112,8 +114,9 @@ GNUNET_FS_GTK_dubious_meta_to_utf8 (enum EXTRACTOR_MetaFormat format, | |||
112 | * @return description of the result in utf-8, never NULL | 114 | * @return description of the result in utf-8, never NULL |
113 | */ | 115 | */ |
114 | char * | 116 | char * |
115 | GNUNET_FS_GTK_get_description_from_metadata (const struct GNUNET_CONTAINER_MetaData *meta, | 117 | GNUNET_FS_GTK_get_description_from_metadata ( |
116 | int *is_a_dup); | 118 | const struct GNUNET_CONTAINER_MetaData *meta, |
119 | int *is_a_dup); | ||
117 | 120 | ||
118 | 121 | ||
119 | /** | 122 | /** |
@@ -125,7 +128,7 @@ GNUNET_FS_GTK_get_description_from_metadata (const struct GNUNET_CONTAINER_MetaD | |||
125 | */ | 128 | */ |
126 | void | 129 | void |
127 | GNUNET_FS_GTK_handle_uri (const struct GNUNET_FS_Uri *uri, | 130 | GNUNET_FS_GTK_handle_uri (const struct GNUNET_FS_Uri *uri, |
128 | guint anonymity_level); | 131 | guint anonymity_level); |
129 | 132 | ||
130 | 133 | ||
131 | /** | 134 | /** |
@@ -136,8 +139,7 @@ GNUNET_FS_GTK_handle_uri (const struct GNUNET_FS_Uri *uri, | |||
136 | * @return #GNUNET_OK if iter was filled, #GNUNET_SYSERR otherwise | 139 | * @return #GNUNET_OK if iter was filled, #GNUNET_SYSERR otherwise |
137 | */ | 140 | */ |
138 | int | 141 | int |
139 | GNUNET_GTK_get_iter_from_reference (GtkTreeRowReference *rr, | 142 | GNUNET_GTK_get_iter_from_reference (GtkTreeRowReference *rr, GtkTreeIter *iter); |
140 | GtkTreeIter *iter); | ||
141 | 143 | ||
142 | 144 | ||
143 | /** | 145 | /** |
@@ -148,8 +150,7 @@ GNUNET_GTK_get_iter_from_reference (GtkTreeRowReference *rr, | |||
148 | * @return newly created reference or NULL in case of error | 150 | * @return newly created reference or NULL in case of error |
149 | */ | 151 | */ |
150 | GtkTreeRowReference * | 152 | GtkTreeRowReference * |
151 | GNUNET_GTK_get_reference_from_iter (GtkTreeModel *model, | 153 | GNUNET_GTK_get_reference_from_iter (GtkTreeModel *model, GtkTreeIter *iter); |
152 | GtkTreeIter *iter); | ||
153 | 154 | ||
154 | 155 | ||
155 | /** | 156 | /** |
@@ -171,9 +172,9 @@ GNUNET_GTK_get_reference_from_iter (GtkTreeModel *model, | |||
171 | */ | 172 | */ |
172 | gboolean | 173 | gboolean |
173 | GNUNET_GTK_tree_model_get_next_flat_iter (GtkTreeModel *model, | 174 | GNUNET_GTK_tree_model_get_next_flat_iter (GtkTreeModel *model, |
174 | GtkTreeIter *iter, | 175 | GtkTreeIter *iter, |
175 | gboolean allow_children, | 176 | gboolean allow_children, |
176 | GtkTreeIter *next_iter); | 177 | GtkTreeIter *next_iter); |
177 | 178 | ||
178 | 179 | ||
179 | #endif | 180 | #endif |
diff --git a/src/fs/gnunet-fs-gtk_download-save-as.c b/src/fs/gnunet-fs-gtk_download-save-as.c index 5d17d4dd..b9da6609 100644 --- a/src/fs/gnunet-fs-gtk_download-save-as.c +++ b/src/fs/gnunet-fs-gtk_download-save-as.c | |||
@@ -79,7 +79,9 @@ clean_up_download_as_context (struct DownloadAsDialogContext *dlc) | |||
79 | if (NULL != dlc->dirname) | 79 | if (NULL != dlc->dirname) |
80 | { | 80 | { |
81 | if (0 != RMDIR (dlc->dirname)) | 81 | if (0 != RMDIR (dlc->dirname)) |
82 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "rmdir", dlc->dirname); | 82 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, |
83 | "rmdir", | ||
84 | dlc->dirname); | ||
83 | GNUNET_free (dlc->dirname); | 85 | GNUNET_free (dlc->dirname); |
84 | } | 86 | } |
85 | GNUNET_free (dlc); | 87 | GNUNET_free (dlc); |
@@ -109,13 +111,14 @@ GNUNET_FS_GTK_free_download_entry (struct DownloadEntry *de) | |||
109 | if (NULL != de->rr) | 111 | if (NULL != de->rr) |
110 | { | 112 | { |
111 | path = gtk_tree_row_reference_get_path (de->rr); | 113 | path = gtk_tree_row_reference_get_path (de->rr); |
112 | GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (downloads_treestore), | 114 | GNUNET_assert ( |
113 | &iter, path)); | 115 | gtk_tree_model_get_iter (GTK_TREE_MODEL (downloads_treestore), |
116 | &iter, | ||
117 | path)); | ||
114 | gtk_tree_path_free (path); | 118 | gtk_tree_path_free (path); |
115 | gtk_tree_row_reference_free (de->rr); | 119 | gtk_tree_row_reference_free (de->rr); |
116 | de->rr = NULL; | 120 | de->rr = NULL; |
117 | gtk_tree_store_remove (downloads_treestore, | 121 | gtk_tree_store_remove (downloads_treestore, &iter); |
118 | &iter); | ||
119 | } | 122 | } |
120 | GNUNET_free (de); | 123 | GNUNET_free (de); |
121 | } | 124 | } |
@@ -130,7 +133,8 @@ GNUNET_FS_GTK_free_download_entry (struct DownloadEntry *de) | |||
130 | * @return always FALSE (destroy the window) | 133 | * @return always FALSE (destroy the window) |
131 | */ | 134 | */ |
132 | gboolean | 135 | gboolean |
133 | GNUNET_GTK_save_as_dialog_delete_event_cb (GtkWidget * widget, GdkEvent * event, | 136 | GNUNET_GTK_save_as_dialog_delete_event_cb (GtkWidget *widget, |
137 | GdkEvent *event, | ||
134 | gpointer user_data) | 138 | gpointer user_data) |
135 | { | 139 | { |
136 | struct DownloadAsDialogContext *dlc = user_data; | 140 | struct DownloadAsDialogContext *dlc = user_data; |
@@ -150,8 +154,8 @@ GNUNET_GTK_save_as_dialog_delete_event_cb (GtkWidget * widget, GdkEvent * event, | |||
150 | * @param user_data the 'structDownloadAsDialogContext' of the dialog | 154 | * @param user_data the 'structDownloadAsDialogContext' of the dialog |
151 | */ | 155 | */ |
152 | void | 156 | void |
153 | GNUNET_GTK_save_as_dialog_response_cb (GtkDialog * dialog, | 157 | GNUNET_GTK_save_as_dialog_response_cb (GtkDialog *dialog, |
154 | gint response_id, | 158 | gint response_id, |
155 | gpointer user_data) | 159 | gpointer user_data) |
156 | { | 160 | { |
157 | struct DownloadAsDialogContext *dlc = user_data; | 161 | struct DownloadAsDialogContext *dlc = user_data; |
@@ -168,20 +172,19 @@ GNUNET_GTK_save_as_dialog_response_cb (GtkDialog * dialog, | |||
168 | } | 172 | } |
169 | GNUNET_free_non_null (de->filename); | 173 | GNUNET_free_non_null (de->filename); |
170 | de->filename = | 174 | de->filename = |
171 | GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER (dlc->dialog)); | 175 | GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER (dlc->dialog)); |
172 | cb = GTK_TOGGLE_BUTTON (gtk_builder_get_object | 176 | cb = GTK_TOGGLE_BUTTON ( |
173 | (dlc->builder, "GNUNET_GTK_save_as_recursive_check_button")); | 177 | gtk_builder_get_object (dlc->builder, |
178 | "GNUNET_GTK_save_as_recursive_check_button")); | ||
174 | if (dlc->download_directly) | 179 | if (dlc->download_directly) |
175 | { | 180 | { |
176 | de->is_recursive = | 181 | de->is_recursive = |
177 | (TRUE == | 182 | (TRUE == gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cb))) |
178 | gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cb))) ? GNUNET_YES : | 183 | ? GNUNET_YES |
179 | GNUNET_NO; | 184 | : GNUNET_NO; |
180 | de->anonymity = | 185 | de->anonymity = (uint32_t) gtk_spin_button_get_value (GTK_SPIN_BUTTON ( |
181 | (uint32_t) gtk_spin_button_get_value (GTK_SPIN_BUTTON | 186 | gtk_builder_get_object (dlc->builder, |
182 | (gtk_builder_get_object | 187 | "GNUNET_GTK_save_as_dialog_anonymity_spin_button"))); |
183 | (dlc->builder, | ||
184 | "GNUNET_GTK_save_as_dialog_anonymity_spin_button"))); | ||
185 | } | 188 | } |
186 | gtk_widget_destroy (GTK_WIDGET (dialog)); | 189 | gtk_widget_destroy (GTK_WIDGET (dialog)); |
187 | if (dlc->download_directly) | 190 | if (dlc->download_directly) |
@@ -220,8 +223,7 @@ open_saveas_dialog (struct DownloadEntry *de, int download_directly) | |||
220 | dlc->de = de; | 223 | dlc->de = de; |
221 | dlc->download_directly = download_directly; | 224 | dlc->download_directly = download_directly; |
222 | dlc->builder = | 225 | dlc->builder = |
223 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_download_as_dialog.glade", | 226 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_download_as_dialog.glade", dlc); |
224 | dlc); | ||
225 | if (NULL == dlc->builder) | 227 | if (NULL == dlc->builder) |
226 | { | 228 | { |
227 | GNUNET_break (0); | 229 | GNUNET_break (0); |
@@ -229,20 +231,22 @@ open_saveas_dialog (struct DownloadEntry *de, int download_directly) | |||
229 | GNUNET_free (dlc); | 231 | GNUNET_free (dlc); |
230 | return; | 232 | return; |
231 | } | 233 | } |
232 | dlc->dialog = GTK_WIDGET (gtk_builder_get_object | 234 | dlc->dialog = GTK_WIDGET ( |
233 | (dlc->builder, "GNUNET_GTK_save_as_dialog")); | 235 | gtk_builder_get_object (dlc->builder, "GNUNET_GTK_save_as_dialog")); |
234 | 236 | ||
235 | /* Enable recursive button for directories and | 237 | /* Enable recursive button for directories and |
236 | set recursive 'default' value based on what the 'dc' tells us */ | 238 | set recursive 'default' value based on what the 'dc' tells us */ |
237 | cb = GTK_WIDGET (gtk_builder_get_object | 239 | cb = GTK_WIDGET ( |
238 | (dlc->builder, "GNUNET_GTK_save_as_recursive_check_button")); | 240 | gtk_builder_get_object (dlc->builder, |
239 | hb = GTK_WIDGET (gtk_builder_get_object (dlc->builder, "GNUNET_GTK_save_as_dialog_options_hbox")); | 241 | "GNUNET_GTK_save_as_recursive_check_button")); |
242 | hb = GTK_WIDGET ( | ||
243 | gtk_builder_get_object (dlc->builder, | ||
244 | "GNUNET_GTK_save_as_dialog_options_hbox")); | ||
240 | if (download_directly) | 245 | if (download_directly) |
241 | { | 246 | { |
242 | if (GNUNET_YES == de->is_directory) | 247 | if (GNUNET_YES == de->is_directory) |
243 | gtk_widget_set_sensitive (cb, TRUE); | 248 | gtk_widget_set_sensitive (cb, TRUE); |
244 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb), | 249 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb), de->is_recursive); |
245 | de->is_recursive); | ||
246 | gtk_widget_show (hb); | 250 | gtk_widget_show (hb); |
247 | } | 251 | } |
248 | else | 252 | else |
@@ -267,20 +271,21 @@ open_saveas_dialog (struct DownloadEntry *de, int download_directly) | |||
267 | { | 271 | { |
268 | if (GNUNET_OK != GNUNET_DISK_directory_create (dirname)) | 272 | if (GNUNET_OK != GNUNET_DISK_directory_create (dirname)) |
269 | { | 273 | { |
270 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "mkdir", dirname); | 274 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "mkdir", dirname); |
271 | } | 275 | } |
272 | else | 276 | else |
273 | { | 277 | { |
274 | dlc->dirname = dirname; | 278 | dlc->dirname = dirname; |
275 | } | 279 | } |
276 | } | 280 | } |
277 | gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dlc->dialog), dirname); | 281 | gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dlc->dialog), |
278 | gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dlc->dialog), basename); | 282 | dirname); |
283 | gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dlc->dialog), | ||
284 | basename); | ||
279 | if (NULL == dlc->dirname) | 285 | if (NULL == dlc->dirname) |
280 | GNUNET_free (dirname); | 286 | GNUNET_free (dirname); |
281 | } | 287 | } |
282 | gtk_dialog_set_default_response (GTK_DIALOG (dlc->dialog), | 288 | gtk_dialog_set_default_response (GTK_DIALOG (dlc->dialog), GTK_RESPONSE_OK); |
283 | GTK_RESPONSE_OK); | ||
284 | gtk_window_present (GTK_WINDOW (dlc->dialog)); | 289 | gtk_window_present (GTK_WINDOW (dlc->dialog)); |
285 | } | 290 | } |
286 | 291 | ||
@@ -340,26 +345,30 @@ GNUNET_FS_GTK_download_context_start_download (struct DownloadEntry *de) | |||
340 | { | 345 | { |
341 | GNUNET_break (NULL != | 346 | GNUNET_break (NULL != |
342 | GNUNET_FS_download_start_from_search (fs, | 347 | GNUNET_FS_download_start_from_search (fs, |
343 | de->sr->result, | 348 | de->sr->result, |
344 | de->filename, | 349 | de->filename, |
345 | NULL /* tempname */ , | 350 | NULL /* tempname */, |
346 | 0 /* offset */ , | 351 | 0 /* offset */, |
347 | len, | 352 | len, |
348 | de->anonymity, opt, | 353 | de->anonymity, |
354 | opt, | ||
349 | de)); | 355 | de)); |
350 | } | 356 | } |
351 | else | 357 | else |
352 | { | 358 | { |
353 | GNUNET_break (NULL != | 359 | GNUNET_break ( |
354 | GNUNET_FS_download_start (fs, | 360 | NULL != |
355 | de->uri, | 361 | GNUNET_FS_download_start (fs, |
356 | NULL /* meta data */, | 362 | de->uri, |
357 | de->filename, NULL /* tempname */ , | 363 | NULL /* meta data */, |
358 | 0 /* offset */ , | 364 | de->filename, |
359 | len, | 365 | NULL /* tempname */, |
360 | de->anonymity, opt, | 366 | 0 /* offset */, |
361 | de, | 367 | len, |
362 | (NULL != de->pde) ? de->pde->dc : NULL)); | 368 | de->anonymity, |
369 | opt, | ||
370 | de, | ||
371 | (NULL != de->pde) ? de->pde->dc : NULL)); | ||
363 | } | 372 | } |
364 | } | 373 | } |
365 | 374 | ||
diff --git a/src/fs/gnunet-fs-gtk_download-save-as.h b/src/fs/gnunet-fs-gtk_download-save-as.h index 57d1523b..58abd636 100644 --- a/src/fs/gnunet-fs-gtk_download-save-as.h +++ b/src/fs/gnunet-fs-gtk_download-save-as.h | |||
@@ -75,5 +75,4 @@ void | |||
75 | GNUNET_FS_GTK_free_download_entry (struct DownloadEntry *de); | 75 | GNUNET_FS_GTK_free_download_entry (struct DownloadEntry *de); |
76 | 76 | ||
77 | 77 | ||
78 | |||
79 | #endif | 78 | #endif |
diff --git a/src/fs/gnunet-fs-gtk_event-handler.c b/src/fs/gnunet-fs-gtk_event-handler.c index ff481140..14b8fee8 100644 --- a/src/fs/gnunet-fs-gtk_event-handler.c +++ b/src/fs/gnunet-fs-gtk_event-handler.c | |||
@@ -35,150 +35,150 @@ | |||
35 | * Columns in the file sharing result model. | 35 | * Columns in the file sharing result model. |
36 | */ | 36 | */ |
37 | enum SEARCH_TAB_ModelColumns | 37 | enum SEARCH_TAB_ModelColumns |
38 | { | 38 | { |
39 | /** | 39 | /** |
40 | * A gpointer. | 40 | * A gpointer. |
41 | */ | 41 | */ |
42 | SEARCH_TAB_MC_METADATA = 0, | 42 | SEARCH_TAB_MC_METADATA = 0, |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * A gpointer. | 45 | * A gpointer. |
46 | */ | 46 | */ |
47 | SEARCH_TAB_MC_URI = 1, | 47 | SEARCH_TAB_MC_URI = 1, |
48 | 48 | ||
49 | /** | 49 | /** |
50 | * A guint64. | 50 | * A guint64. |
51 | */ | 51 | */ |
52 | SEARCH_TAB_MC_FILESIZE = 2, | 52 | SEARCH_TAB_MC_FILESIZE = 2, |
53 | 53 | ||
54 | /** | 54 | /** |
55 | * A GdkPixbuf. | 55 | * A GdkPixbuf. |
56 | */ | 56 | */ |
57 | SEARCH_TAB_MC_PREVIEW = 3, | 57 | SEARCH_TAB_MC_PREVIEW = 3, |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * A guint. | 60 | * A guint. |
61 | */ | 61 | */ |
62 | SEARCH_TAB_MC_PERCENT_PROGRESS = 4, | 62 | SEARCH_TAB_MC_PERCENT_PROGRESS = 4, |
63 | 63 | ||
64 | /** | 64 | /** |
65 | * A guint. | 65 | * A guint. |
66 | */ | 66 | */ |
67 | SEARCH_TAB_MC_PERCENT_AVAILABILITY = 5, | 67 | SEARCH_TAB_MC_PERCENT_AVAILABILITY = 5, |
68 | 68 | ||
69 | /** | 69 | /** |
70 | * A gchararray. | 70 | * A gchararray. |
71 | */ | 71 | */ |
72 | SEARCH_TAB_MC_FILENAME = 6, | 72 | SEARCH_TAB_MC_FILENAME = 6, |
73 | 73 | ||
74 | /** | 74 | /** |
75 | * A gchararray. | 75 | * A gchararray. |
76 | */ | 76 | */ |
77 | SEARCH_TAB_MC_URI_AS_STRING = 7, | 77 | SEARCH_TAB_MC_URI_AS_STRING = 7, |
78 | 78 | ||
79 | /** | 79 | /** |
80 | * A gchararray. | 80 | * A gchararray. |
81 | */ | 81 | */ |
82 | SEARCH_TAB_MC_STATUS_COLOUR = 8, | 82 | SEARCH_TAB_MC_STATUS_COLOUR = 8, |
83 | 83 | ||
84 | /** | 84 | /** |
85 | * A gpointer. | 85 | * A gpointer. |
86 | */ | 86 | */ |
87 | SEARCH_TAB_MC_SEARCH_RESULT = 9, | 87 | SEARCH_TAB_MC_SEARCH_RESULT = 9, |
88 | 88 | ||
89 | /** | 89 | /** |
90 | * A gchararray. | 90 | * A gchararray. |
91 | */ | 91 | */ |
92 | SEARCH_TAB_MC_MIMETYPE = 10, | 92 | SEARCH_TAB_MC_MIMETYPE = 10, |
93 | 93 | ||
94 | /** | 94 | /** |
95 | * A guint. | 95 | * A guint. |
96 | */ | 96 | */ |
97 | SEARCH_TAB_MC_APPLICABILITY_RANK = 11, | 97 | SEARCH_TAB_MC_APPLICABILITY_RANK = 11, |
98 | 98 | ||
99 | /** | 99 | /** |
100 | * A guint. | 100 | * A guint. |
101 | */ | 101 | */ |
102 | SEARCH_TAB_MC_AVAILABILITY_CERTAINTY = 12, | 102 | SEARCH_TAB_MC_AVAILABILITY_CERTAINTY = 12, |
103 | 103 | ||
104 | /** | 104 | /** |
105 | * A gint. | 105 | * A gint. |
106 | */ | 106 | */ |
107 | SEARCH_TAB_MC_AVAILABILITY_RANK = 13, | 107 | SEARCH_TAB_MC_AVAILABILITY_RANK = 13, |
108 | 108 | ||
109 | /** | 109 | /** |
110 | * A guint64. | 110 | * A guint64. |
111 | */ | 111 | */ |
112 | SEARCH_TAB_MC_COMPLETED = 14, | 112 | SEARCH_TAB_MC_COMPLETED = 14, |
113 | 113 | ||
114 | /** | 114 | /** |
115 | * A gchararray. | 115 | * A gchararray. |
116 | */ | 116 | */ |
117 | SEARCH_TAB_MC_DOWNLOADED_FILENAME = 15, | 117 | SEARCH_TAB_MC_DOWNLOADED_FILENAME = 15, |
118 | 118 | ||
119 | /** | 119 | /** |
120 | * A gint. | 120 | * A gint. |
121 | */ | 121 | */ |
122 | SEARCH_TAB_MC_DOWNLOADED_ANONYMITY = 16, | 122 | SEARCH_TAB_MC_DOWNLOADED_ANONYMITY = 16, |
123 | 123 | ||
124 | /** | 124 | /** |
125 | * A GdkPixbuf. | 125 | * A GdkPixbuf. |
126 | */ | 126 | */ |
127 | SEARCH_TAB_MC_STATUS_ICON = 17, | 127 | SEARCH_TAB_MC_STATUS_ICON = 17, |
128 | 128 | ||
129 | /** | 129 | /** |
130 | * A guint. | 130 | * A guint. |
131 | */ | 131 | */ |
132 | SEARCH_TAB_MC_UNKNOWN_AVAILABILITY = 18, | 132 | SEARCH_TAB_MC_UNKNOWN_AVAILABILITY = 18, |
133 | 133 | ||
134 | /** | 134 | /** |
135 | * A gboolean. | 135 | * A gboolean. |
136 | */ | 136 | */ |
137 | SEARCH_TAB_MC_SHOW_NS_ASSOCIATION = 19 | 137 | SEARCH_TAB_MC_SHOW_NS_ASSOCIATION = 19 |
138 | 138 | ||
139 | }; | 139 | }; |
140 | 140 | ||
141 | 141 | ||
142 | /** | 142 | /** |
143 | * Columns in the publish frame model. | 143 | * Columns in the publish frame model. |
144 | */ | 144 | */ |
145 | enum PUBLISH_TAB_ModelColumns | 145 | enum PUBLISH_TAB_ModelColumns |
146 | { | 146 | { |
147 | /** | 147 | /** |
148 | * A gchararray. | 148 | * A gchararray. |
149 | */ | 149 | */ |
150 | PUBLISH_TAB_MC_FILENAME = 0, | 150 | PUBLISH_TAB_MC_FILENAME = 0, |
151 | 151 | ||
152 | /** | 152 | /** |
153 | * A gchararray. | 153 | * A gchararray. |
154 | */ | 154 | */ |
155 | PUBLISH_TAB_MC_FILESIZE = 1, | 155 | PUBLISH_TAB_MC_FILESIZE = 1, |
156 | 156 | ||
157 | /** | 157 | /** |
158 | * A gchararray. | 158 | * A gchararray. |
159 | */ | 159 | */ |
160 | PUBLISH_TAB_MC_BGCOLOUR = 2, | 160 | PUBLISH_TAB_MC_BGCOLOUR = 2, |
161 | 161 | ||
162 | /** | 162 | /** |
163 | * A guint. | 163 | * A guint. |
164 | */ | 164 | */ |
165 | PUBLISH_TAB_MC_PROGRESS = 3, | 165 | PUBLISH_TAB_MC_PROGRESS = 3, |
166 | 166 | ||
167 | /** | 167 | /** |
168 | * A gpointer. | 168 | * A gpointer. |
169 | */ | 169 | */ |
170 | PUBLISH_TAB_MC_ENT = 4, | 170 | PUBLISH_TAB_MC_ENT = 4, |
171 | 171 | ||
172 | /** | 172 | /** |
173 | * A gchararray. | 173 | * A gchararray. |
174 | */ | 174 | */ |
175 | PUBLISH_TAB_MC_RESULT_STRING = 5, | 175 | PUBLISH_TAB_MC_RESULT_STRING = 5, |
176 | 176 | ||
177 | /** | 177 | /** |
178 | * A GdkPixbuf. | 178 | * A GdkPixbuf. |
179 | */ | 179 | */ |
180 | PUBLISH_TAB_MC_STATUS_ICON = 6 | 180 | PUBLISH_TAB_MC_STATUS_ICON = 6 |
181 | }; | 181 | }; |
182 | 182 | ||
183 | 183 | ||
184 | /** | 184 | /** |
@@ -355,9 +355,7 @@ load_animation (const char *basename) | |||
355 | char *fn; | 355 | char *fn; |
356 | 356 | ||
357 | dd = GNUNET_GTK_get_data_dir (); | 357 | dd = GNUNET_GTK_get_data_dir (); |
358 | GNUNET_asprintf (&fn, | 358 | GNUNET_asprintf (&fn, "%s%s.gif", dd, basename); |
359 | "%s%s.gif", | ||
360 | dd, basename); | ||
361 | ac = GNUNET_GTK_animation_context_create (fn); | 359 | ac = GNUNET_GTK_animation_context_create (fn); |
362 | GNUNET_free (fn); | 360 | GNUNET_free (fn); |
363 | return ac; | 361 | return ac; |
@@ -404,12 +402,15 @@ get_default_download_directory (char *buffer, size_t size) | |||
404 | 402 | ||
405 | cfg = GNUNET_FS_GTK_get_configuration (); | 403 | cfg = GNUNET_FS_GTK_get_configuration (); |
406 | 404 | ||
407 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gnunet-fs-gtk", | 405 | if (GNUNET_OK != |
408 | "DEFAULT_DOWNLOAD_DIRECTORY", | 406 | GNUNET_CONFIGURATION_get_value_filename (cfg, |
409 | &dirname)) | 407 | "gnunet-fs-gtk", |
408 | "DEFAULT_DOWNLOAD_DIRECTORY", | ||
409 | &dirname)) | ||
410 | return NULL; | 410 | return NULL; |
411 | 411 | ||
412 | if (GNUNET_YES != GNUNET_DISK_directory_test ((const char *) dirname, GNUNET_YES)) | 412 | if (GNUNET_YES != |
413 | GNUNET_DISK_directory_test ((const char *) dirname, GNUNET_YES)) | ||
413 | { | 414 | { |
414 | GNUNET_free (dirname); | 415 | GNUNET_free (dirname); |
415 | return NULL; | 416 | return NULL; |
@@ -443,20 +444,23 @@ get_default_download_directory (char *buffer, size_t size) | |||
443 | */ | 444 | */ |
444 | static void | 445 | static void |
445 | build_relative_name (GtkTreeModel *tm, | 446 | build_relative_name (GtkTreeModel *tm, |
446 | GtkTreeIter *iter, | 447 | GtkTreeIter *iter, |
447 | int *finished_chain, | 448 | int *finished_chain, |
448 | gchar **root_directory, | 449 | gchar **root_directory, |
449 | gchar **relative_directory, | 450 | gchar **relative_directory, |
450 | int *anonymity) | 451 | int *anonymity) |
451 | { | 452 | { |
452 | char *filename; | 453 | char *filename; |
453 | int downloaded_anonymity; | 454 | int downloaded_anonymity; |
454 | GtkTreeIter parent; | 455 | GtkTreeIter parent; |
455 | 456 | ||
456 | gtk_tree_model_get (tm, iter, | 457 | gtk_tree_model_get (tm, |
457 | SEARCH_TAB_MC_DOWNLOADED_FILENAME, &filename, | 458 | iter, |
458 | SEARCH_TAB_MC_DOWNLOADED_ANONYMITY, &downloaded_anonymity, | 459 | SEARCH_TAB_MC_DOWNLOADED_FILENAME, |
459 | -1); | 460 | &filename, |
461 | SEARCH_TAB_MC_DOWNLOADED_ANONYMITY, | ||
462 | &downloaded_anonymity, | ||
463 | -1); | ||
460 | 464 | ||
461 | if (! gtk_tree_model_iter_parent (tm, &parent, iter)) | 465 | if (! gtk_tree_model_iter_parent (tm, &parent, iter)) |
462 | { | 466 | { |
@@ -479,7 +483,7 @@ build_relative_name (GtkTreeModel *tm, | |||
479 | /* If no download directory is known, try working directory */ | 483 | /* If no download directory is known, try working directory */ |
480 | if (NULL == tmp) | 484 | if (NULL == tmp) |
481 | tmp = g_strdup (getcwd (buf, sizeof (buf))); | 485 | tmp = g_strdup (getcwd (buf, sizeof (buf))); |
482 | *root_directory = g_strdup (tmp); | 486 | *root_directory = g_strdup (tmp); |
483 | } | 487 | } |
484 | else | 488 | else |
485 | { | 489 | { |
@@ -498,7 +502,12 @@ build_relative_name (GtkTreeModel *tm, | |||
498 | } | 502 | } |
499 | else | 503 | else |
500 | { | 504 | { |
501 | build_relative_name (tm, &parent, NULL, root_directory, relative_directory, anonymity); | 505 | build_relative_name (tm, |
506 | &parent, | ||
507 | NULL, | ||
508 | root_directory, | ||
509 | relative_directory, | ||
510 | anonymity); | ||
502 | /* We now know the root directory parent stems from, | 511 | /* We now know the root directory parent stems from, |
503 | * and parent's name (without .gnd) relative to the root directory. | 512 | * and parent's name (without .gnd) relative to the root directory. |
504 | * Now we need to check that root + reldir = directory | 513 | * Now we need to check that root + reldir = directory |
@@ -507,7 +516,8 @@ build_relative_name (GtkTreeModel *tm, | |||
507 | if (NULL != filename) | 516 | if (NULL != filename) |
508 | { | 517 | { |
509 | gchar *our_dirname = g_path_get_dirname (filename); | 518 | gchar *our_dirname = g_path_get_dirname (filename); |
510 | gchar *our_expected_dirname = g_build_filename (*root_directory, *relative_directory, NULL); | 519 | gchar *our_expected_dirname = |
520 | g_build_filename (*root_directory, *relative_directory, NULL); | ||
511 | gchar *bname = g_path_get_basename (filename); | 521 | gchar *bname = g_path_get_basename (filename); |
512 | int chain_ok; | 522 | int chain_ok; |
513 | char *dot_gnd; | 523 | char *dot_gnd; |
@@ -527,7 +537,7 @@ build_relative_name (GtkTreeModel *tm, | |||
527 | dot_gnd = strrchr (bname, '.'); | 537 | dot_gnd = strrchr (bname, '.'); |
528 | if (NULL != dot_gnd && strcmp (dot_gnd, ".gnd") == 0) | 538 | if (NULL != dot_gnd && strcmp (dot_gnd, ".gnd") == 0) |
529 | *dot_gnd = '\0'; | 539 | *dot_gnd = '\0'; |
530 | if (!chain_ok) | 540 | if (! chain_ok) |
531 | { | 541 | { |
532 | /* User decided to download one of the directories into | 542 | /* User decided to download one of the directories into |
533 | * a different place - respect that decision, pick that | 543 | * a different place - respect that decision, pick that |
@@ -541,7 +551,8 @@ build_relative_name (GtkTreeModel *tm, | |||
541 | else | 551 | else |
542 | { | 552 | { |
543 | /* Continue the chain from the same root directory */ | 553 | /* Continue the chain from the same root directory */ |
544 | gchar *new_relative_directory = g_build_filename (*relative_directory, bname, NULL); | 554 | gchar *new_relative_directory = |
555 | g_build_filename (*relative_directory, bname, NULL); | ||
545 | g_free (*relative_directory); | 556 | g_free (*relative_directory); |
546 | *relative_directory = new_relative_directory; | 557 | *relative_directory = new_relative_directory; |
547 | } | 558 | } |
@@ -573,9 +584,9 @@ build_relative_name (GtkTreeModel *tm, | |||
573 | */ | 584 | */ |
574 | static char * | 585 | static char * |
575 | get_suggested_filename_anonymity2 (GtkTreeModel *tm, | 586 | get_suggested_filename_anonymity2 (GtkTreeModel *tm, |
576 | GtkTreeIter *iter, | 587 | GtkTreeIter *iter, |
577 | char **download_directory, | 588 | char **download_directory, |
578 | int *anonymity) | 589 | int *anonymity) |
579 | { | 590 | { |
580 | char *result; | 591 | char *result; |
581 | char *downloaddir; | 592 | char *downloaddir; |
@@ -590,11 +601,14 @@ get_suggested_filename_anonymity2 (GtkTreeModel *tm, | |||
590 | downloaddir = NULL; | 601 | downloaddir = NULL; |
591 | relname = NULL; | 602 | relname = NULL; |
592 | finished_chain = GNUNET_NO; | 603 | finished_chain = GNUNET_NO; |
593 | build_relative_name (tm, iter, &finished_chain, &downloaddir, &relname, &downloaded_anonymity); | 604 | build_relative_name (tm, |
605 | iter, | ||
606 | &finished_chain, | ||
607 | &downloaddir, | ||
608 | &relname, | ||
609 | &downloaded_anonymity); | ||
594 | 610 | ||
595 | gtk_tree_model_get (tm, iter, | 611 | gtk_tree_model_get (tm, iter, SEARCH_TAB_MC_METADATA, &meta, -1); |
596 | SEARCH_TAB_MC_METADATA, &meta, | ||
597 | -1); | ||
598 | 612 | ||
599 | filename = GNUNET_FS_meta_data_suggest_filename (meta); | 613 | filename = GNUNET_FS_meta_data_suggest_filename (meta); |
600 | /* Don't trust metadata */ | 614 | /* Don't trust metadata */ |
@@ -604,7 +618,8 @@ get_suggested_filename_anonymity2 (GtkTreeModel *tm, | |||
604 | if (NULL != tmp) | 618 | if (NULL != tmp) |
605 | { | 619 | { |
606 | tmplen = strlen (tmp); | 620 | tmplen = strlen (tmp); |
607 | if ((1 == tmplen && '.' == tmp[0]) || (2 <= tmplen && '.' == tmp[0] && '.' == tmp[1])) | 621 | if ((1 == tmplen && '.' == tmp[0]) || |
622 | (2 <= tmplen && '.' == tmp[0] && '.' == tmp[1])) | ||
608 | tmp = NULL; | 623 | tmp = NULL; |
609 | else if ((1 == tmplen && ('/' == tmp[0] || '\\' == tmp[0])) || 0 == tmplen) | 624 | else if ((1 == tmplen && ('/' == tmp[0] || '\\' == tmp[0])) || 0 == tmplen) |
610 | tmp = NULL; | 625 | tmp = NULL; |
@@ -614,14 +629,19 @@ get_suggested_filename_anonymity2 (GtkTreeModel *tm, | |||
614 | /* now, if we have a directory, replace trailing '/' with ".gnd" */ | 629 | /* now, if we have a directory, replace trailing '/' with ".gnd" */ |
615 | if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (meta)) | 630 | if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (meta)) |
616 | { | 631 | { |
617 | if ((tmp[tmplen-1] == '/') || (tmp[tmplen-1] == '\\')) | 632 | if ((tmp[tmplen - 1] == '/') || (tmp[tmplen - 1] == '\\')) |
618 | tmp[tmplen-1] = '\0'; | 633 | tmp[tmplen - 1] = '\0'; |
619 | if (relname) | 634 | if (relname) |
620 | { | 635 | { |
621 | if (finished_chain) | 636 | if (finished_chain) |
622 | GNUNET_asprintf (&result, "%s%s", relname, GNUNET_FS_DIRECTORY_EXT); | 637 | GNUNET_asprintf (&result, "%s%s", relname, GNUNET_FS_DIRECTORY_EXT); |
623 | else | 638 | else |
624 | GNUNET_asprintf (&result, "%s%s%s%s", relname, DIR_SEPARATOR_STR, tmp, GNUNET_FS_DIRECTORY_EXT); | 639 | GNUNET_asprintf (&result, |
640 | "%s%s%s%s", | ||
641 | relname, | ||
642 | DIR_SEPARATOR_STR, | ||
643 | tmp, | ||
644 | GNUNET_FS_DIRECTORY_EXT); | ||
625 | } | 645 | } |
626 | else | 646 | else |
627 | GNUNET_asprintf (&result, "%s%s", tmp, GNUNET_FS_DIRECTORY_EXT); | 647 | GNUNET_asprintf (&result, "%s%s", tmp, GNUNET_FS_DIRECTORY_EXT); |
@@ -669,7 +689,6 @@ struct SearchListPopupContext | |||
669 | * Search result at the respective row. | 689 | * Search result at the respective row. |
670 | */ | 690 | */ |
671 | struct SearchResult *sr; | 691 | struct SearchResult *sr; |
672 | |||
673 | }; | 692 | }; |
674 | 693 | ||
675 | 694 | ||
@@ -680,8 +699,7 @@ struct SearchListPopupContext | |||
680 | * @param user_data the 'struct SearchListPopupContext' of the menu | 699 | * @param user_data the 'struct SearchListPopupContext' of the menu |
681 | */ | 700 | */ |
682 | static void | 701 | static void |
683 | search_list_popup_selection_done (GtkMenuShell *menushell, | 702 | search_list_popup_selection_done (GtkMenuShell *menushell, gpointer user_data) |
684 | gpointer user_data) | ||
685 | { | 703 | { |
686 | struct SearchListPopupContext *spc = user_data; | 704 | struct SearchListPopupContext *spc = user_data; |
687 | 705 | ||
@@ -700,7 +718,7 @@ search_list_popup_selection_done (GtkMenuShell *menushell, | |||
700 | */ | 718 | */ |
701 | void | 719 | void |
702 | GNUNET_FS_GTK_search_treeview_cursor_changed (GtkTreeView *tv, | 720 | GNUNET_FS_GTK_search_treeview_cursor_changed (GtkTreeView *tv, |
703 | gpointer user_data); | 721 | gpointer user_data); |
704 | 722 | ||
705 | 723 | ||
706 | /** | 724 | /** |
@@ -724,30 +742,31 @@ setup_download_list_entry (struct DownloadEntry *de, | |||
724 | if (NULL == pde) | 742 | if (NULL == pde) |
725 | { | 743 | { |
726 | /* top level */ | 744 | /* top level */ |
727 | gtk_tree_store_insert (downloads_treestore, | 745 | gtk_tree_store_insert (downloads_treestore, &download_iter, NULL, G_MAXINT); |
728 | &download_iter, | ||
729 | NULL, | ||
730 | G_MAXINT); | ||
731 | } | 746 | } |
732 | else | 747 | else |
733 | { | 748 | { |
734 | /* below parent */ | 749 | /* below parent */ |
735 | path = gtk_tree_row_reference_get_path (pde->rr); | 750 | path = gtk_tree_row_reference_get_path (pde->rr); |
736 | GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (downloads_treestore), | 751 | GNUNET_assert ( |
737 | &download_piter, path)); | 752 | gtk_tree_model_get_iter (GTK_TREE_MODEL (downloads_treestore), |
753 | &download_piter, | ||
754 | path)); | ||
738 | gtk_tree_path_free (path); | 755 | gtk_tree_path_free (path); |
739 | gtk_tree_store_insert (downloads_treestore, | 756 | gtk_tree_store_insert (downloads_treestore, |
740 | &download_iter, | 757 | &download_iter, |
741 | &download_piter, | 758 | &download_piter, |
742 | G_MAXINT); | 759 | G_MAXINT); |
743 | } | 760 | } |
744 | gtk_tree_store_set (downloads_treestore, &download_iter, | 761 | gtk_tree_store_set (downloads_treestore, |
745 | SEARCH_TAB_MC_SEARCH_RESULT, sr, | 762 | &download_iter, |
763 | SEARCH_TAB_MC_SEARCH_RESULT, | ||
764 | sr, | ||
746 | -1); | 765 | -1); |
747 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (downloads_treestore), | 766 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (downloads_treestore), |
748 | &download_iter); | 767 | &download_iter); |
749 | de->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (downloads_treestore), | 768 | de->rr = |
750 | path); | 769 | gtk_tree_row_reference_new (GTK_TREE_MODEL (downloads_treestore), path); |
751 | gtk_tree_path_free (path); | 770 | gtk_tree_path_free (path); |
752 | } | 771 | } |
753 | 772 | ||
@@ -759,14 +778,13 @@ setup_download_list_entry (struct DownloadEntry *de, | |||
759 | * @param[out] iter set to the respective position in the #downloads_treestore | 778 | * @param[out] iter set to the respective position in the #downloads_treestore |
760 | */ | 779 | */ |
761 | static void | 780 | static void |
762 | get_download_list_entry (struct DownloadEntry *de, | 781 | get_download_list_entry (struct DownloadEntry *de, GtkTreeIter *iter) |
763 | GtkTreeIter *iter) | ||
764 | { | 782 | { |
765 | GtkTreePath *path; | 783 | GtkTreePath *path; |
766 | 784 | ||
767 | path = gtk_tree_row_reference_get_path (de->rr); | 785 | path = gtk_tree_row_reference_get_path (de->rr); |
768 | GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (downloads_treestore), | 786 | GNUNET_assert ( |
769 | iter, path)); | 787 | gtk_tree_model_get_iter (GTK_TREE_MODEL (downloads_treestore), iter, path)); |
770 | gtk_tree_path_free (path); | 788 | gtk_tree_path_free (path); |
771 | } | 789 | } |
772 | 790 | ||
@@ -797,33 +815,32 @@ start_download2 (int save_as, int download_directly) | |||
797 | gboolean recursive; | 815 | gboolean recursive; |
798 | GtkTreeIter next_item; | 816 | GtkTreeIter next_item; |
799 | 817 | ||
800 | tv = GTK_TREE_VIEW (gtk_builder_get_object (st->builder, "_search_result_frame")); | 818 | tv = GTK_TREE_VIEW ( |
819 | gtk_builder_get_object (st->builder, "_search_result_frame")); | ||
801 | sel = gtk_tree_view_get_selection (tv); | 820 | sel = gtk_tree_view_get_selection (tv); |
802 | if (!gtk_tree_selection_get_selected (sel, &model, &iter)) | 821 | if (! gtk_tree_selection_get_selected (sel, &model, &iter)) |
803 | return; | 822 | return; |
804 | gtk_tree_model_get (model, &iter, | 823 | gtk_tree_model_get (model, &iter, SEARCH_TAB_MC_SEARCH_RESULT, &sr, -1); |
805 | SEARCH_TAB_MC_SEARCH_RESULT, &sr, | ||
806 | -1); | ||
807 | if (NULL == sr) | 824 | if (NULL == sr) |
808 | { | 825 | { |
809 | GNUNET_break (0); | 826 | GNUNET_break (0); |
810 | return; | 827 | return; |
811 | } | 828 | } |
812 | GNUNET_assert (NULL != sr->uri); | 829 | GNUNET_assert (NULL != sr->uri); |
813 | if (GNUNET_FS_uri_test_ksk (sr->uri) || | 830 | if (GNUNET_FS_uri_test_ksk (sr->uri) || GNUNET_FS_uri_test_sks (sr->uri)) |
814 | GNUNET_FS_uri_test_sks (sr->uri)) | ||
815 | { | 831 | { |
816 | GNUNET_FS_GTK_handle_uri (sr->uri, 1); | 832 | GNUNET_FS_GTK_handle_uri (sr->uri, 1); |
817 | return; | 833 | return; |
818 | } | 834 | } |
819 | 835 | ||
820 | if (!((NULL == sr->download) && (NULL != sr->uri) && | 836 | if (! ((NULL == sr->download) && (NULL != sr->uri) && |
821 | ((GNUNET_FS_uri_test_chk (sr->uri) || | 837 | ((GNUNET_FS_uri_test_chk (sr->uri) || |
822 | GNUNET_FS_uri_test_loc (sr->uri))))) | 838 | GNUNET_FS_uri_test_loc (sr->uri))))) |
823 | return; | 839 | return; |
824 | 840 | ||
825 | path = gtk_tree_model_get_path (model, &iter); | 841 | path = gtk_tree_model_get_path (model, &iter); |
826 | recursive = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (mctx->download_recursive_checkbutton)); | 842 | recursive = gtk_toggle_button_get_active ( |
843 | GTK_TOGGLE_BUTTON (mctx->download_recursive_checkbutton)); | ||
827 | filename = gtk_entry_get_text (mctx->download_name_entry); | 844 | filename = gtk_entry_get_text (mctx->download_name_entry); |
828 | downloaddir = gtk_file_chooser_get_filename (mctx->download_location_chooser); | 845 | downloaddir = gtk_file_chooser_get_filename (mctx->download_location_chooser); |
829 | 846 | ||
@@ -832,9 +849,11 @@ start_download2 (int save_as, int download_directly) | |||
832 | if (gtk_tree_model_iter_parent (model, &parent_iter, &iter)) | 849 | if (gtk_tree_model_iter_parent (model, &parent_iter, &iter)) |
833 | { | 850 | { |
834 | struct SearchResult *psr = NULL; | 851 | struct SearchResult *psr = NULL; |
835 | gtk_tree_model_get (model, &parent_iter, | 852 | gtk_tree_model_get (model, |
836 | SEARCH_TAB_MC_SEARCH_RESULT, &psr, | 853 | &parent_iter, |
837 | -1); | 854 | SEARCH_TAB_MC_SEARCH_RESULT, |
855 | &psr, | ||
856 | -1); | ||
838 | if (psr) | 857 | if (psr) |
839 | de->pde = psr->download; | 858 | de->pde = psr->download; |
840 | } | 859 | } |
@@ -849,7 +868,10 @@ start_download2 (int save_as, int download_directly) | |||
849 | filename); | 868 | filename); |
850 | de->sr = sr; | 869 | de->sr = sr; |
851 | sr->download = de; | 870 | sr->download = de; |
852 | if (GNUNET_GTK_get_selected_anonymity_combo_level (mctx->download_anonymity_combo, &anonymity)) | 871 | if ( |
872 | GNUNET_GTK_get_selected_anonymity_combo_level (mctx | ||
873 | ->download_anonymity_combo, | ||
874 | &anonymity)) | ||
853 | de->anonymity = anonymity; | 875 | de->anonymity = anonymity; |
854 | else | 876 | else |
855 | de->anonymity = 1; | 877 | de->anonymity = 1; |
@@ -866,9 +888,10 @@ start_download2 (int save_as, int download_directly) | |||
866 | gtk_tree_path_free (path); | 888 | gtk_tree_path_free (path); |
867 | g_free (downloaddir); | 889 | g_free (downloaddir); |
868 | 890 | ||
869 | if (!save_as) | 891 | if (! save_as) |
870 | { | 892 | { |
871 | if (GNUNET_GTK_tree_model_get_next_flat_iter (model, &iter, | 893 | if (GNUNET_GTK_tree_model_get_next_flat_iter (model, |
894 | &iter, | ||
872 | ! recursive, | 895 | ! recursive, |
873 | &next_item)) | 896 | &next_item)) |
874 | gtk_tree_selection_select_iter (sel, &next_item); | 897 | gtk_tree_selection_select_iter (sel, &next_item); |
@@ -886,8 +909,8 @@ start_download2 (int save_as, int download_directly) | |||
886 | */ | 909 | */ |
887 | static void | 910 | static void |
888 | start_download_ctx_menu_helper (struct SearchListPopupContext *spc, | 911 | start_download_ctx_menu_helper (struct SearchListPopupContext *spc, |
889 | int is_recursive, | 912 | int is_recursive, |
890 | int save_as) | 913 | int save_as) |
891 | { | 914 | { |
892 | start_download2 (save_as, GNUNET_YES); | 915 | start_download2 (save_as, GNUNET_YES); |
893 | } | 916 | } |
@@ -904,10 +927,10 @@ start_download_ctx_menu_helper (struct SearchListPopupContext *spc, | |||
904 | * @param user_data the 'struct SearchTab' that was activated | 927 | * @param user_data the 'struct SearchTab' that was activated |
905 | */ | 928 | */ |
906 | void | 929 | void |
907 | GNUNET_FS_GTK_search_treeview_row_activated (GtkTreeView * tree_view, | 930 | GNUNET_FS_GTK_search_treeview_row_activated (GtkTreeView *tree_view, |
908 | GtkTreePath * path, | 931 | GtkTreePath *path, |
909 | GtkTreeViewColumn * column, | 932 | GtkTreeViewColumn *column, |
910 | gpointer user_data) | 933 | gpointer user_data) |
911 | { | 934 | { |
912 | start_download2 (GNUNET_NO, GNUNET_NO); | 935 | start_download2 (GNUNET_NO, GNUNET_NO); |
913 | } | 936 | } |
@@ -921,7 +944,7 @@ GNUNET_FS_GTK_search_treeview_row_activated (GtkTreeView * tree_view, | |||
921 | */ | 944 | */ |
922 | void | 945 | void |
923 | GNUNET_GTK_search_frame_download_download_button_clicked_cb (GtkButton *button, | 946 | GNUNET_GTK_search_frame_download_download_button_clicked_cb (GtkButton *button, |
924 | gpointer user_data) | 947 | gpointer user_data) |
925 | { | 948 | { |
926 | start_download2 (GNUNET_NO, GNUNET_NO); | 949 | start_download2 (GNUNET_NO, GNUNET_NO); |
927 | } | 950 | } |
@@ -935,8 +958,9 @@ GNUNET_GTK_search_frame_download_download_button_clicked_cb (GtkButton *button, | |||
935 | * @param user_data the main window context | 958 | * @param user_data the main window context |
936 | */ | 959 | */ |
937 | void | 960 | void |
938 | GNUNET_GTK_search_frame_download_filename_change_button_clicked_cb (GtkButton *button, | 961 | GNUNET_GTK_search_frame_download_filename_change_button_clicked_cb ( |
939 | gpointer user_data) | 962 | GtkButton *button, |
963 | gpointer user_data) | ||
940 | { | 964 | { |
941 | start_download2 (GNUNET_YES, GNUNET_NO); | 965 | start_download2 (GNUNET_YES, GNUNET_NO); |
942 | } | 966 | } |
@@ -977,8 +1001,7 @@ handle_uri_from_ctx_menu (GtkMenuItem *item, gpointer user_data) | |||
977 | uris = GNUNET_FS_uri_to_string (uri); | 1001 | uris = GNUNET_FS_uri_to_string (uri); |
978 | if (NULL == uris) | 1002 | if (NULL == uris) |
979 | return; | 1003 | return; |
980 | GNUNET_break (GNUNET_OK == | 1004 | GNUNET_break (GNUNET_OK == GNUNET_FS_GTK_handle_uri_string (uris, 1)); |
981 | GNUNET_FS_GTK_handle_uri_string (uris, 1)); | ||
982 | GNUNET_free (uris); | 1005 | GNUNET_free (uris); |
983 | /* GObject will clean up the URI */ | 1006 | /* GObject will clean up the URI */ |
984 | } | 1007 | } |
@@ -1045,12 +1068,14 @@ abort_download_ctx_menu (GtkMenuItem *item, gpointer user_data) | |||
1045 | GNUNET_FS_download_stop (de->dc, GNUNET_YES); | 1068 | GNUNET_FS_download_stop (de->dc, GNUNET_YES); |
1046 | if (NULL != spc->tab) | 1069 | if (NULL != spc->tab) |
1047 | { | 1070 | { |
1048 | tv = GTK_TREE_VIEW (gtk_builder_get_object (spc->tab->builder, "_search_result_frame")); | 1071 | tv = GTK_TREE_VIEW ( |
1072 | gtk_builder_get_object (spc->tab->builder, "_search_result_frame")); | ||
1049 | GNUNET_FS_GTK_search_treeview_cursor_changed (tv, spc->tab); | 1073 | GNUNET_FS_GTK_search_treeview_cursor_changed (tv, spc->tab); |
1050 | } | 1074 | } |
1051 | else | 1075 | else |
1052 | { | 1076 | { |
1053 | tv = GTK_TREE_VIEW (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_download_frame")); | 1077 | tv = GTK_TREE_VIEW ( |
1078 | GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_download_frame")); | ||
1054 | GNUNET_FS_GTK_download_frame_treeview_cursor_changed_cb (tv, NULL); | 1079 | GNUNET_FS_GTK_download_frame_treeview_cursor_changed_cb (tv, NULL); |
1055 | } | 1080 | } |
1056 | } | 1081 | } |
@@ -1076,11 +1101,11 @@ copy_search_uri_to_clipboard_ctx_menu (GtkMenuItem *item, gpointer user_data) | |||
1076 | 1101 | ||
1077 | path = gtk_tree_row_reference_get_path (spc->rr); | 1102 | path = gtk_tree_row_reference_get_path (spc->rr); |
1078 | if (NULL != spc->tab) | 1103 | if (NULL != spc->tab) |
1079 | tv = GTK_TREE_VIEW (gtk_builder_get_object | 1104 | tv = GTK_TREE_VIEW ( |
1080 | (spc->tab->builder, | 1105 | gtk_builder_get_object (spc->tab->builder, "_search_result_frame")); |
1081 | "_search_result_frame")); | ||
1082 | else | 1106 | else |
1083 | tv = GTK_TREE_VIEW (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_download_frame")); | 1107 | tv = GTK_TREE_VIEW ( |
1108 | GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_download_frame")); | ||
1084 | tm = gtk_tree_view_get_model (tv); | 1109 | tm = gtk_tree_view_get_model (tv); |
1085 | if (! gtk_tree_model_get_iter (tm, &iter, path)) | 1110 | if (! gtk_tree_model_get_iter (tm, &iter, path)) |
1086 | { | 1111 | { |
@@ -1088,9 +1113,7 @@ copy_search_uri_to_clipboard_ctx_menu (GtkMenuItem *item, gpointer user_data) | |||
1088 | gtk_tree_path_free (path); | 1113 | gtk_tree_path_free (path); |
1089 | return; | 1114 | return; |
1090 | } | 1115 | } |
1091 | gtk_tree_model_get (tm, &iter, | 1116 | gtk_tree_model_get (tm, &iter, SEARCH_TAB_MC_URI, &uri, -1); |
1092 | SEARCH_TAB_MC_URI, &uri, | ||
1093 | -1); | ||
1094 | gtk_tree_path_free (path); | 1117 | gtk_tree_path_free (path); |
1095 | if (uri == NULL) | 1118 | if (uri == NULL) |
1096 | { | 1119 | { |
@@ -1110,8 +1133,7 @@ copy_search_uri_to_clipboard_ctx_menu (GtkMenuItem *item, gpointer user_data) | |||
1110 | * | 1133 | * |
1111 | * @return 0 to continue iteration, 1 to abort | 1134 | * @return 0 to continue iteration, 1 to abort |
1112 | */ | 1135 | */ |
1113 | typedef int (*EmbeddedUriCallback) (void *cls, | 1136 | typedef int (*EmbeddedUriCallback) (void *cls, const struct GNUNET_FS_Uri *uri); |
1114 | const struct GNUNET_FS_Uri *uri); | ||
1115 | 1137 | ||
1116 | 1138 | ||
1117 | /** | 1139 | /** |
@@ -1147,11 +1169,12 @@ struct UriScannerCallbackContext | |||
1147 | */ | 1169 | */ |
1148 | static int | 1170 | static int |
1149 | check_for_embedded_uri (void *cls, | 1171 | check_for_embedded_uri (void *cls, |
1150 | const char *plugin_name, | 1172 | const char *plugin_name, |
1151 | enum EXTRACTOR_MetaType type, | 1173 | enum EXTRACTOR_MetaType type, |
1152 | enum EXTRACTOR_MetaFormat format, | 1174 | enum EXTRACTOR_MetaFormat format, |
1153 | const char *data_mime_type, | 1175 | const char *data_mime_type, |
1154 | const char *data, size_t data_size) | 1176 | const char *data, |
1177 | size_t data_size) | ||
1155 | { | 1178 | { |
1156 | struct UriScannerCallbackContext *ctx = cls; | 1179 | struct UriScannerCallbackContext *ctx = cls; |
1157 | int result; | 1180 | int result; |
@@ -1159,21 +1182,19 @@ check_for_embedded_uri (void *cls, | |||
1159 | struct GNUNET_FS_Uri *uri; | 1182 | struct GNUNET_FS_Uri *uri; |
1160 | 1183 | ||
1161 | if ((EXTRACTOR_METATYPE_URI != type) || | 1184 | if ((EXTRACTOR_METATYPE_URI != type) || |
1162 | (EXTRACTOR_METAFORMAT_UTF8 != format) || | 1185 | (EXTRACTOR_METAFORMAT_UTF8 != format) || (NULL == data_mime_type) || |
1163 | (NULL == data_mime_type) || | 1186 | (0 != strcmp ("text/plain", data_mime_type)) || (0 == data_size) || |
1164 | (0 != strcmp ("text/plain", data_mime_type)) || | 1187 | ('\0' != data[data_size - 1])) |
1165 | (0 == data_size) || | ||
1166 | ('\0' != data[data_size - 1]) ) | ||
1167 | return 0; | 1188 | return 0; |
1168 | emsg = NULL; | 1189 | emsg = NULL; |
1169 | uri = GNUNET_FS_uri_parse (data, &emsg); | 1190 | uri = GNUNET_FS_uri_parse (data, &emsg); |
1170 | if (NULL == uri) | 1191 | if (NULL == uri) |
1171 | { | 1192 | { |
1172 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1193 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1173 | _("Failed to parse URI `%.*s': %s\n"), | 1194 | _ ("Failed to parse URI `%.*s': %s\n"), |
1174 | (int) data_size, | 1195 | (int) data_size, |
1175 | data, | 1196 | data, |
1176 | emsg); | 1197 | emsg); |
1177 | GNUNET_free_non_null (emsg); | 1198 | GNUNET_free_non_null (emsg); |
1178 | return 0; | 1199 | return 0; |
1179 | } | 1200 | } |
@@ -1192,14 +1213,14 @@ check_for_embedded_uri (void *cls, | |||
1192 | */ | 1213 | */ |
1193 | static void | 1214 | static void |
1194 | find_embedded_uris (const struct GNUNET_CONTAINER_MetaData *meta, | 1215 | find_embedded_uris (const struct GNUNET_CONTAINER_MetaData *meta, |
1195 | EmbeddedUriCallback cb, void *cls) | 1216 | EmbeddedUriCallback cb, |
1217 | void *cls) | ||
1196 | { | 1218 | { |
1197 | struct UriScannerCallbackContext ctx; | 1219 | struct UriScannerCallbackContext ctx; |
1198 | 1220 | ||
1199 | ctx.cb = cb; | 1221 | ctx.cb = cb; |
1200 | ctx.cls = cls; | 1222 | ctx.cls = cls; |
1201 | GNUNET_CONTAINER_meta_data_iterate (meta, | 1223 | GNUNET_CONTAINER_meta_data_iterate (meta, &check_for_embedded_uri, &ctx); |
1202 | &check_for_embedded_uri, &ctx); | ||
1203 | } | 1224 | } |
1204 | 1225 | ||
1205 | 1226 | ||
@@ -1217,7 +1238,6 @@ struct UriPopulationContext | |||
1217 | * Counter used to limit the number of entries we add. | 1238 | * Counter used to limit the number of entries we add. |
1218 | */ | 1239 | */ |
1219 | int counter; | 1240 | int counter; |
1220 | |||
1221 | }; | 1241 | }; |
1222 | 1242 | ||
1223 | 1243 | ||
@@ -1231,8 +1251,7 @@ struct UriPopulationContext | |||
1231 | * 1 if we have reached the limit | 1251 | * 1 if we have reached the limit |
1232 | */ | 1252 | */ |
1233 | static int | 1253 | static int |
1234 | populate_popup_with_uri_items (void *cls, | 1254 | populate_popup_with_uri_items (void *cls, const struct GNUNET_FS_Uri *uri) |
1235 | const struct GNUNET_FS_Uri *uri) | ||
1236 | { | 1255 | { |
1237 | struct UriPopulationContext *ctx = cls; | 1256 | struct UriPopulationContext *ctx = cls; |
1238 | GtkWidget *child; | 1257 | GtkWidget *child; |
@@ -1245,23 +1264,18 @@ populate_popup_with_uri_items (void *cls, | |||
1245 | 1264 | ||
1246 | ctx->counter++; | 1265 | ctx->counter++; |
1247 | uris = GNUNET_FS_uri_to_string (uri); | 1266 | uris = GNUNET_FS_uri_to_string (uri); |
1248 | GNUNET_asprintf (&labels, | 1267 | GNUNET_asprintf (&labels, _ ("URI #%d: %s"), ctx->counter, uris); |
1249 | _("URI #%d: %s"), | ||
1250 | ctx->counter, | ||
1251 | uris); | ||
1252 | GNUNET_free (uris); | 1268 | GNUNET_free (uris); |
1253 | label = gtk_accel_label_new (labels); | 1269 | label = gtk_accel_label_new (labels); |
1254 | GNUNET_free (labels); | 1270 | GNUNET_free (labels); |
1255 | box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, | 1271 | box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); |
1256 | 2); | ||
1257 | child = gtk_menu_item_new (); | 1272 | child = gtk_menu_item_new (); |
1258 | ns_association_icon = gtk_image_new_from_icon_name ("gnunet-fs-gtk-ns-association", | 1273 | ns_association_icon = |
1259 | GTK_ICON_SIZE_MENU); | 1274 | gtk_image_new_from_icon_name ("gnunet-fs-gtk-ns-association", |
1260 | gtk_container_add (GTK_CONTAINER (box), | 1275 | GTK_ICON_SIZE_MENU); |
1261 | ns_association_icon); | 1276 | gtk_container_add (GTK_CONTAINER (box), ns_association_icon); |
1262 | #if GTK_CHECK_VERSION(3,16,0) | 1277 | #if GTK_CHECK_VERSION(3, 16, 0) |
1263 | gtk_label_set_xalign (GTK_LABEL (label), | 1278 | gtk_label_set_xalign (GTK_LABEL (label), 0.0); |
1264 | 0.0); | ||
1265 | #endif | 1279 | #endif |
1266 | accel_group = gtk_accel_group_new (); | 1280 | accel_group = gtk_accel_group_new (); |
1267 | gtk_widget_add_accelerator (child, | 1281 | gtk_widget_add_accelerator (child, |
@@ -1270,23 +1284,18 @@ populate_popup_with_uri_items (void *cls, | |||
1270 | GDK_KEY_m, | 1284 | GDK_KEY_m, |
1271 | GDK_CONTROL_MASK, | 1285 | GDK_CONTROL_MASK, |
1272 | GTK_ACCEL_VISIBLE); | 1286 | GTK_ACCEL_VISIBLE); |
1273 | gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), | 1287 | gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), child); |
1274 | child); | 1288 | gtk_box_pack_end (GTK_BOX (box), label, TRUE, TRUE, 0); |
1275 | gtk_box_pack_end (GTK_BOX (box), | 1289 | gtk_container_add (GTK_CONTAINER (child), box); |
1276 | label, | ||
1277 | TRUE, | ||
1278 | TRUE, | ||
1279 | 0); | ||
1280 | gtk_container_add (GTK_CONTAINER (child), | ||
1281 | box); | ||
1282 | 1290 | ||
1283 | g_object_set_data_full (G_OBJECT (child), | 1291 | g_object_set_data_full (G_OBJECT (child), |
1284 | "fs-uri", | 1292 | "fs-uri", |
1285 | GNUNET_FS_uri_dup (uri), | 1293 | GNUNET_FS_uri_dup (uri), |
1286 | (GDestroyNotify) &GNUNET_FS_uri_destroy); | 1294 | (GDestroyNotify) &GNUNET_FS_uri_destroy); |
1287 | g_signal_connect (child, "activate", | 1295 | g_signal_connect (child, |
1288 | G_CALLBACK (handle_uri_from_ctx_menu), | 1296 | "activate", |
1289 | NULL); | 1297 | G_CALLBACK (handle_uri_from_ctx_menu), |
1298 | NULL); | ||
1290 | gtk_widget_show (child); | 1299 | gtk_widget_show (child); |
1291 | gtk_menu_shell_append (GTK_MENU_SHELL (ctx->menu), child); | 1300 | gtk_menu_shell_append (GTK_MENU_SHELL (ctx->menu), child); |
1292 | 1301 | ||
@@ -1323,9 +1332,7 @@ search_list_get_popup (GtkTreeModel *tm, | |||
1323 | path = gtk_tree_model_get_path (tm, iter); | 1332 | path = gtk_tree_model_get_path (tm, iter); |
1324 | spc->rr = gtk_tree_row_reference_new (tm, path); | 1333 | spc->rr = gtk_tree_row_reference_new (tm, path); |
1325 | gtk_tree_path_free (path); | 1334 | gtk_tree_path_free (path); |
1326 | gtk_tree_model_get (tm, iter, | 1335 | gtk_tree_model_get (tm, iter, SEARCH_TAB_MC_SEARCH_RESULT, &sr, -1); |
1327 | SEARCH_TAB_MC_SEARCH_RESULT, &sr, | ||
1328 | -1); | ||
1329 | if (NULL == sr) | 1336 | if (NULL == sr) |
1330 | { | 1337 | { |
1331 | GNUNET_break (0); | 1338 | GNUNET_break (0); |
@@ -1336,39 +1343,43 @@ search_list_get_popup (GtkTreeModel *tm, | |||
1336 | 1343 | ||
1337 | spc->sr = sr; | 1344 | spc->sr = sr; |
1338 | menu = GTK_MENU (gtk_menu_new ()); | 1345 | menu = GTK_MENU (gtk_menu_new ()); |
1339 | if ( (NULL == sr->download) && | 1346 | if ((NULL == sr->download) && (NULL != sr->uri) && |
1340 | (NULL != sr->uri) && | 1347 | ((GNUNET_FS_uri_test_chk (sr->uri) || GNUNET_FS_uri_test_loc (sr->uri)))) |
1341 | ( (GNUNET_FS_uri_test_chk (sr->uri) || | ||
1342 | GNUNET_FS_uri_test_loc (sr->uri))) ) | ||
1343 | { | 1348 | { |
1344 | /* only display download menus if there is a URI */ | 1349 | /* only display download menus if there is a URI */ |
1345 | child = gtk_menu_item_new_with_label (_("_Download")); | 1350 | child = gtk_menu_item_new_with_label (_ ("_Download")); |
1346 | g_signal_connect (child, "activate", | 1351 | g_signal_connect (child, |
1347 | G_CALLBACK (start_download_ctx_menu), spc); | 1352 | "activate", |
1348 | gtk_label_set_use_underline (GTK_LABEL | 1353 | G_CALLBACK (start_download_ctx_menu), |
1349 | (gtk_bin_get_child (GTK_BIN (child))), | 1354 | spc); |
1350 | TRUE); | 1355 | gtk_label_set_use_underline (GTK_LABEL ( |
1356 | gtk_bin_get_child (GTK_BIN (child))), | ||
1357 | TRUE); | ||
1351 | gtk_widget_show (child); | 1358 | gtk_widget_show (child); |
1352 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); | 1359 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); |
1353 | 1360 | ||
1354 | if (is_directory == GNUNET_YES) | 1361 | if (is_directory == GNUNET_YES) |
1355 | { | 1362 | { |
1356 | child = gtk_menu_item_new_with_label (_("Download _recursively")); | 1363 | child = gtk_menu_item_new_with_label (_ ("Download _recursively")); |
1357 | g_signal_connect (child, "activate", | 1364 | g_signal_connect (child, |
1358 | G_CALLBACK (start_download_recursively_ctx_menu), spc); | 1365 | "activate", |
1359 | gtk_label_set_use_underline (GTK_LABEL | 1366 | G_CALLBACK (start_download_recursively_ctx_menu), |
1360 | (gtk_bin_get_child (GTK_BIN (child))), | 1367 | spc); |
1361 | TRUE); | 1368 | gtk_label_set_use_underline (GTK_LABEL ( |
1369 | gtk_bin_get_child (GTK_BIN (child))), | ||
1370 | TRUE); | ||
1362 | gtk_widget_show (child); | 1371 | gtk_widget_show (child); |
1363 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); | 1372 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); |
1364 | } | 1373 | } |
1365 | 1374 | ||
1366 | child = gtk_menu_item_new_with_label (_("Download _as...")); | 1375 | child = gtk_menu_item_new_with_label (_ ("Download _as...")); |
1367 | g_signal_connect (child, "activate", | 1376 | g_signal_connect (child, |
1368 | G_CALLBACK (download_as_ctx_menu), spc); | 1377 | "activate", |
1369 | gtk_label_set_use_underline (GTK_LABEL | 1378 | G_CALLBACK (download_as_ctx_menu), |
1370 | (gtk_bin_get_child (GTK_BIN (child))), | 1379 | spc); |
1371 | TRUE); | 1380 | gtk_label_set_use_underline (GTK_LABEL ( |
1381 | gtk_bin_get_child (GTK_BIN (child))), | ||
1382 | TRUE); | ||
1372 | gtk_widget_show (child); | 1383 | gtk_widget_show (child); |
1373 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); | 1384 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); |
1374 | } | 1385 | } |
@@ -1381,9 +1392,7 @@ search_list_get_popup (GtkTreeModel *tm, | |||
1381 | /* check for embedded URIs */ | 1392 | /* check for embedded URIs */ |
1382 | uri_pop_ctx.counter = 0; | 1393 | uri_pop_ctx.counter = 0; |
1383 | uri_pop_ctx.menu = menu; | 1394 | uri_pop_ctx.menu = menu; |
1384 | find_embedded_uris (sr->meta, | 1395 | find_embedded_uris (sr->meta, &populate_popup_with_uri_items, &uri_pop_ctx); |
1385 | &populate_popup_with_uri_items, | ||
1386 | &uri_pop_ctx); | ||
1387 | if (0 < uri_pop_ctx.counter) | 1396 | if (0 < uri_pop_ctx.counter) |
1388 | { | 1397 | { |
1389 | /* Insert another separator */ | 1398 | /* Insert another separator */ |
@@ -1392,30 +1401,36 @@ search_list_get_popup (GtkTreeModel *tm, | |||
1392 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); | 1401 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); |
1393 | } | 1402 | } |
1394 | 1403 | ||
1395 | if ( (NULL != sr->download) && | 1404 | if ((NULL != sr->download) && (GNUNET_YES != sr->download->is_done)) |
1396 | (GNUNET_YES != sr->download->is_done) ) | ||
1397 | { | 1405 | { |
1398 | child = gtk_menu_item_new_with_label (_("_Abort download")); | 1406 | child = gtk_menu_item_new_with_label (_ ("_Abort download")); |
1399 | g_signal_connect (child, "activate", | 1407 | g_signal_connect (child, |
1400 | G_CALLBACK (abort_download_ctx_menu), spc); | 1408 | "activate", |
1401 | gtk_label_set_use_underline (GTK_LABEL | 1409 | G_CALLBACK (abort_download_ctx_menu), |
1402 | (gtk_bin_get_child (GTK_BIN (child))), | 1410 | spc); |
1411 | gtk_label_set_use_underline (GTK_LABEL ( | ||
1412 | gtk_bin_get_child (GTK_BIN (child))), | ||
1403 | TRUE); | 1413 | TRUE); |
1404 | gtk_widget_show (child); | 1414 | gtk_widget_show (child); |
1405 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); | 1415 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); |
1406 | } | 1416 | } |
1407 | if (NULL != sr->uri) | 1417 | if (NULL != sr->uri) |
1408 | { | 1418 | { |
1409 | child = gtk_menu_item_new_with_label (_("_Copy URI to Clipboard")); | 1419 | child = gtk_menu_item_new_with_label (_ ("_Copy URI to Clipboard")); |
1410 | g_signal_connect (child, "activate", | 1420 | g_signal_connect (child, |
1411 | G_CALLBACK (copy_search_uri_to_clipboard_ctx_menu), spc); | 1421 | "activate", |
1412 | gtk_label_set_use_underline (GTK_LABEL | 1422 | G_CALLBACK (copy_search_uri_to_clipboard_ctx_menu), |
1413 | (gtk_bin_get_child (GTK_BIN (child))), TRUE); | 1423 | spc); |
1424 | gtk_label_set_use_underline (GTK_LABEL ( | ||
1425 | gtk_bin_get_child (GTK_BIN (child))), | ||
1426 | TRUE); | ||
1414 | gtk_widget_show (child); | 1427 | gtk_widget_show (child); |
1415 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); | 1428 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); |
1416 | } | 1429 | } |
1417 | g_signal_connect (menu, "selection-done", | 1430 | g_signal_connect (menu, |
1418 | G_CALLBACK (search_list_popup_selection_done), spc); | 1431 | "selection-done", |
1432 | G_CALLBACK (search_list_popup_selection_done), | ||
1433 | spc); | ||
1419 | return menu; | 1434 | return menu; |
1420 | } | 1435 | } |
1421 | 1436 | ||
@@ -1429,8 +1444,7 @@ search_list_get_popup (GtkTreeModel *tm, | |||
1429 | * TRUE if there is now a pop-up menu | 1444 | * TRUE if there is now a pop-up menu |
1430 | */ | 1445 | */ |
1431 | gboolean | 1446 | gboolean |
1432 | GNUNET_FS_GTK_search_treeview_popup_menu (GtkWidget *widget, | 1447 | GNUNET_FS_GTK_search_treeview_popup_menu (GtkWidget *widget, gpointer user_data) |
1433 | gpointer user_data) | ||
1434 | { | 1448 | { |
1435 | GtkTreeView *tv = GTK_TREE_VIEW (widget); | 1449 | GtkTreeView *tv = GTK_TREE_VIEW (widget); |
1436 | struct SearchTab *tab = user_data; | 1450 | struct SearchTab *tab = user_data; |
@@ -1465,9 +1479,9 @@ GNUNET_FS_GTK_search_treeview_popup_menu (GtkWidget *widget, | |||
1465 | * TRUE to stop the propagation | 1479 | * TRUE to stop the propagation |
1466 | */ | 1480 | */ |
1467 | gboolean | 1481 | gboolean |
1468 | GNUNET_FS_GTK_search_treeview_button_press_event (GtkWidget * widget, | 1482 | GNUNET_FS_GTK_search_treeview_button_press_event (GtkWidget *widget, |
1469 | GdkEvent * event, | 1483 | GdkEvent *event, |
1470 | gpointer user_data) | 1484 | gpointer user_data) |
1471 | { | 1485 | { |
1472 | GtkTreeView *tv = GTK_TREE_VIEW (widget); | 1486 | GtkTreeView *tv = GTK_TREE_VIEW (widget); |
1473 | GdkEventButton *event_button = (GdkEventButton *) event; | 1487 | GdkEventButton *event_button = (GdkEventButton *) event; |
@@ -1477,24 +1491,24 @@ GNUNET_FS_GTK_search_treeview_button_press_event (GtkWidget * widget, | |||
1477 | GtkTreeIter iter; | 1491 | GtkTreeIter iter; |
1478 | GtkMenu *menu; | 1492 | GtkMenu *menu; |
1479 | 1493 | ||
1480 | if ( (GDK_BUTTON_PRESS != event->type) || | 1494 | if ((GDK_BUTTON_PRESS != event->type) || (3 != event_button->button)) |
1481 | (3 != event_button->button) ) | ||
1482 | return FALSE; /* not a right-click */ | 1495 | return FALSE; /* not a right-click */ |
1483 | if (! gtk_tree_view_get_path_at_pos (tv, | 1496 | if (! gtk_tree_view_get_path_at_pos (tv, |
1484 | event_button->x, event_button->y, | 1497 | event_button->x, |
1485 | &path, NULL, NULL, NULL)) | 1498 | event_button->y, |
1499 | &path, | ||
1500 | NULL, | ||
1501 | NULL, | ||
1502 | NULL)) | ||
1486 | return FALSE; /* click outside of area with values, ignore */ | 1503 | return FALSE; /* click outside of area with values, ignore */ |
1487 | tm = gtk_tree_view_get_model (tv); | 1504 | tm = gtk_tree_view_get_model (tv); |
1488 | if (! gtk_tree_model_get_iter (tm, &iter, path)) | 1505 | if (! gtk_tree_model_get_iter (tm, &iter, path)) |
1489 | return FALSE; /* not sure how we got a path but no iter... */ | 1506 | return FALSE; /* not sure how we got a path but no iter... */ |
1490 | gtk_tree_path_free (path); | 1507 | gtk_tree_path_free (path); |
1491 | menu = search_list_get_popup (tm, | 1508 | menu = search_list_get_popup (tm, tab, &iter); |
1492 | tab, | ||
1493 | &iter); | ||
1494 | if (NULL == menu) | 1509 | if (NULL == menu) |
1495 | return FALSE; | 1510 | return FALSE; |
1496 | gtk_menu_popup_at_pointer (menu, | 1511 | gtk_menu_popup_at_pointer (menu, event); |
1497 | event); | ||
1498 | return FALSE; | 1512 | return FALSE; |
1499 | } | 1513 | } |
1500 | 1514 | ||
@@ -1510,8 +1524,8 @@ GNUNET_FS_GTK_search_treeview_button_press_event (GtkWidget * widget, | |||
1510 | * TRUE to stop the propagation | 1524 | * TRUE to stop the propagation |
1511 | */ | 1525 | */ |
1512 | gboolean | 1526 | gboolean |
1513 | GNUNET_GTK_download_frame_button_press_event_cb (GtkWidget * widget, | 1527 | GNUNET_GTK_download_frame_button_press_event_cb (GtkWidget *widget, |
1514 | GdkEvent * event, | 1528 | GdkEvent *event, |
1515 | gpointer user_data) | 1529 | gpointer user_data) |
1516 | { | 1530 | { |
1517 | GtkTreeView *tv = GTK_TREE_VIEW (widget); | 1531 | GtkTreeView *tv = GTK_TREE_VIEW (widget); |
@@ -1521,24 +1535,24 @@ GNUNET_GTK_download_frame_button_press_event_cb (GtkWidget * widget, | |||
1521 | GtkTreeIter iter; | 1535 | GtkTreeIter iter; |
1522 | GtkMenu *menu; | 1536 | GtkMenu *menu; |
1523 | 1537 | ||
1524 | if ( (GDK_BUTTON_PRESS != event->type) || | 1538 | if ((GDK_BUTTON_PRESS != event->type) || (3 != event_button->button)) |
1525 | (3 != event_button->button) ) | ||
1526 | return FALSE; /* not a right-click */ | 1539 | return FALSE; /* not a right-click */ |
1527 | if (! gtk_tree_view_get_path_at_pos (tv, | 1540 | if (! gtk_tree_view_get_path_at_pos (tv, |
1528 | event_button->x, event_button->y, | 1541 | event_button->x, |
1529 | &path, NULL, NULL, NULL)) | 1542 | event_button->y, |
1543 | &path, | ||
1544 | NULL, | ||
1545 | NULL, | ||
1546 | NULL)) | ||
1530 | return FALSE; /* click outside of area with values, ignore */ | 1547 | return FALSE; /* click outside of area with values, ignore */ |
1531 | tm = gtk_tree_view_get_model (tv); | 1548 | tm = gtk_tree_view_get_model (tv); |
1532 | if (! gtk_tree_model_get_iter (tm, &iter, path)) | 1549 | if (! gtk_tree_model_get_iter (tm, &iter, path)) |
1533 | return FALSE; /* not sure how we got a path but no iter... */ | 1550 | return FALSE; /* not sure how we got a path but no iter... */ |
1534 | gtk_tree_path_free (path); | 1551 | gtk_tree_path_free (path); |
1535 | menu = search_list_get_popup (tm, | 1552 | menu = search_list_get_popup (tm, NULL, &iter); |
1536 | NULL, | ||
1537 | &iter); | ||
1538 | if (NULL == menu) | 1553 | if (NULL == menu) |
1539 | return FALSE; | 1554 | return FALSE; |
1540 | gtk_menu_popup_at_pointer (menu, | 1555 | gtk_menu_popup_at_pointer (menu, event); |
1541 | event); | ||
1542 | return FALSE; | 1556 | return FALSE; |
1543 | } | 1557 | } |
1544 | 1558 | ||
@@ -1557,11 +1571,17 @@ update_search_label (struct SearchTab *tab) | |||
1557 | while (tab->parent != NULL) | 1571 | while (tab->parent != NULL) |
1558 | tab = tab->parent->tab; | 1572 | tab = tab->parent->tab; |
1559 | if (tab->num_results > 0) | 1573 | if (tab->num_results > 0) |
1560 | GNUNET_asprintf (&label_text, "%.*s%s (%u)", 20, tab->query_txt, | 1574 | GNUNET_asprintf (&label_text, |
1575 | "%.*s%s (%u)", | ||
1576 | 20, | ||
1577 | tab->query_txt, | ||
1561 | strlen (tab->query_txt) > 20 ? "..." : "", | 1578 | strlen (tab->query_txt) > 20 ? "..." : "", |
1562 | tab->num_results); | 1579 | tab->num_results); |
1563 | else | 1580 | else |
1564 | GNUNET_asprintf (&label_text, "%.*s%s", 20, tab->query_txt, | 1581 | GNUNET_asprintf (&label_text, |
1582 | "%.*s%s", | ||
1583 | 20, | ||
1584 | tab->query_txt, | ||
1565 | strlen (tab->query_txt) > 20 ? "..." : ""); | 1585 | strlen (tab->query_txt) > 20 ? "..." : ""); |
1566 | gtk_label_set_text (tab->label, label_text); | 1586 | gtk_label_set_text (tab->label, label_text); |
1567 | gtk_widget_set_tooltip_text (GTK_WIDGET (tab->label), tab->query_txt); | 1587 | gtk_widget_set_tooltip_text (GTK_WIDGET (tab->label), tab->query_txt); |
@@ -1600,40 +1620,34 @@ close_search_tab (struct SearchTab *tab) | |||
1600 | for (i = gtk_notebook_get_n_pages (mctx->notebook) - 1; i >= 0; i--) | 1620 | for (i = gtk_notebook_get_n_pages (mctx->notebook) - 1; i >= 0; i--) |
1601 | if (tab->frame == gtk_notebook_get_nth_page (mctx->notebook, i)) | 1621 | if (tab->frame == gtk_notebook_get_nth_page (mctx->notebook, i)) |
1602 | index = i; | 1622 | index = i; |
1603 | if (gtk_tree_model_iter_children (GTK_TREE_MODEL (tab->ts), | 1623 | if (gtk_tree_model_iter_children (GTK_TREE_MODEL (tab->ts), &iter, NULL)) |
1604 | &iter, | 1624 | { |
1605 | NULL)) | 1625 | do |
1606 | { | 1626 | { |
1607 | do | 1627 | struct SearchResult *sr; |
1608 | { | 1628 | |
1609 | struct SearchResult *sr; | 1629 | gtk_tree_model_get (GTK_TREE_MODEL (tab->ts), |
1610 | 1630 | &iter, | |
1611 | gtk_tree_model_get (GTK_TREE_MODEL (tab->ts), | 1631 | SEARCH_TAB_MC_SEARCH_RESULT, |
1612 | &iter, | 1632 | &sr, |
1613 | SEARCH_TAB_MC_SEARCH_RESULT, &sr, | 1633 | -1); |
1614 | -1); | 1634 | if (NULL != sr) |
1615 | if (NULL != sr) | 1635 | sr->tab = NULL; |
1616 | sr->tab = NULL; | 1636 | } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (tab->ts), &iter)); |
1617 | } | 1637 | } |
1618 | while (gtk_tree_model_iter_next (GTK_TREE_MODEL (tab->ts), | 1638 | gtk_notebook_remove_page (mctx->notebook, index); |
1619 | &iter)); | ||
1620 | } | ||
1621 | gtk_notebook_remove_page (mctx->notebook, | ||
1622 | index); | ||
1623 | g_object_unref (tab->builder); | 1639 | g_object_unref (tab->builder); |
1624 | GNUNET_free (tab->query_txt); | 1640 | GNUNET_free (tab->query_txt); |
1625 | GNUNET_CONTAINER_DLL_remove (search_tab_head, | 1641 | GNUNET_CONTAINER_DLL_remove (search_tab_head, search_tab_tail, tab); |
1626 | search_tab_tail, | ||
1627 | tab); | ||
1628 | if (tab == uri_tab) | 1642 | if (tab == uri_tab) |
1629 | uri_tab = NULL; | 1643 | uri_tab = NULL; |
1630 | if (NULL != tab->atv) | 1644 | if (NULL != tab->atv) |
1631 | GNUNET_GTK_animation_tree_view_unregister (tab->atv); | 1645 | GNUNET_GTK_animation_tree_view_unregister (tab->atv); |
1632 | GNUNET_free (tab); | 1646 | GNUNET_free (tab); |
1633 | if ( (NULL == search_tab_head) && | 1647 | if ((NULL == search_tab_head) && (NULL == uri_tab)) |
1634 | (NULL == uri_tab) ) | ||
1635 | { | 1648 | { |
1636 | struct GNUNET_GTK_MainWindowContext *mctx = GNUNET_FS_GTK_get_main_context (); | 1649 | struct GNUNET_GTK_MainWindowContext *mctx = |
1650 | GNUNET_FS_GTK_get_main_context (); | ||
1637 | GNUNET_GTK_animation_context_destroy (animation_downloading); | 1651 | GNUNET_GTK_animation_context_destroy (animation_downloading); |
1638 | animation_downloading = NULL; | 1652 | animation_downloading = NULL; |
1639 | GNUNET_GTK_animation_context_destroy (animation_downloaded); | 1653 | GNUNET_GTK_animation_context_destroy (animation_downloaded); |
@@ -1674,10 +1688,11 @@ GNUNET_FS_GTK_close_uri_tab_ () | |||
1674 | static void | 1688 | static void |
1675 | download_lost_parent (struct DownloadEntry *de) | 1689 | download_lost_parent (struct DownloadEntry *de) |
1676 | { | 1690 | { |
1677 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1691 | GNUNET_log ( |
1678 | "Download %p lost search parent; removing from search result %p list.\n", | 1692 | GNUNET_ERROR_TYPE_DEBUG, |
1679 | de, | 1693 | "Download %p lost search parent; removing from search result %p list.\n", |
1680 | de->sr); | 1694 | de, |
1695 | de->sr); | ||
1681 | if (NULL != de->sr->rr) | 1696 | if (NULL != de->sr->rr) |
1682 | { | 1697 | { |
1683 | gtk_tree_row_reference_free (de->sr->rr); | 1698 | gtk_tree_row_reference_free (de->sr->rr); |
@@ -1696,37 +1711,34 @@ download_lost_parent (struct DownloadEntry *de) | |||
1696 | * @param iter parent of the subtree to check | 1711 | * @param iter parent of the subtree to check |
1697 | */ | 1712 | */ |
1698 | static void | 1713 | static void |
1699 | remove_results_in_subtree (GtkTreeModel *tm, | 1714 | remove_results_in_subtree (GtkTreeModel *tm, GtkTreeIter *iter) |
1700 | GtkTreeIter *iter) | ||
1701 | { | 1715 | { |
1702 | GtkTreeIter child; | 1716 | GtkTreeIter child; |
1703 | struct SearchResult *sr; | 1717 | struct SearchResult *sr; |
1704 | 1718 | ||
1705 | if (gtk_tree_model_iter_children (tm, | 1719 | if (gtk_tree_model_iter_children (tm, &child, iter)) |
1706 | &child, | ||
1707 | iter)) | ||
1708 | { | 1720 | { |
1709 | do | 1721 | do |
1710 | { | 1722 | { |
1711 | gtk_tree_model_get (tm, &child, | 1723 | gtk_tree_model_get (tm, &child, SEARCH_TAB_MC_SEARCH_RESULT, &sr, -1); |
1712 | SEARCH_TAB_MC_SEARCH_RESULT, &sr, | ||
1713 | -1); | ||
1714 | remove_results_in_subtree (tm, &child); | 1724 | remove_results_in_subtree (tm, &child); |
1715 | gtk_tree_row_reference_free (sr->rr); | 1725 | gtk_tree_row_reference_free (sr->rr); |
1716 | sr->rr = NULL; | 1726 | sr->rr = NULL; |
1717 | if (NULL != sr->probe) | 1727 | if (NULL != sr->probe) |
1718 | { | 1728 | { |
1719 | GNUNET_FS_probe_stop (sr->probe); | 1729 | GNUNET_FS_probe_stop (sr->probe); |
1720 | sr->probe = NULL; | 1730 | sr->probe = NULL; |
1721 | GNUNET_CONTAINER_DLL_remove (pl_head, | 1731 | GNUNET_CONTAINER_DLL_remove (pl_head, pl_tail, sr); |
1722 | pl_tail, | ||
1723 | sr); | ||
1724 | } | 1732 | } |
1725 | /* get ready for removal of the tree */ | 1733 | /* get ready for removal of the tree */ |
1726 | gtk_tree_store_set (GTK_TREE_STORE (tm), &child, | 1734 | gtk_tree_store_set (GTK_TREE_STORE (tm), |
1727 | SEARCH_TAB_MC_METADATA, NULL, | 1735 | &child, |
1728 | SEARCH_TAB_MC_URI, NULL, | 1736 | SEARCH_TAB_MC_METADATA, |
1729 | SEARCH_TAB_MC_SEARCH_RESULT, NULL, | 1737 | NULL, |
1738 | SEARCH_TAB_MC_URI, | ||
1739 | NULL, | ||
1740 | SEARCH_TAB_MC_SEARCH_RESULT, | ||
1741 | NULL, | ||
1730 | -1); | 1742 | -1); |
1731 | if (NULL != sr->download) | 1743 | if (NULL != sr->download) |
1732 | { | 1744 | { |
@@ -1745,8 +1757,7 @@ remove_results_in_subtree (GtkTreeModel *tm, | |||
1745 | sr->meta = NULL; | 1757 | sr->meta = NULL; |
1746 | } | 1758 | } |
1747 | GNUNET_free (sr); | 1759 | GNUNET_free (sr); |
1748 | } | 1760 | } while (gtk_tree_model_iter_next (tm, &child)); |
1749 | while (gtk_tree_model_iter_next (tm, &child)); | ||
1750 | } | 1761 | } |
1751 | } | 1762 | } |
1752 | 1763 | ||
@@ -1766,17 +1777,15 @@ free_search_result (struct SearchResult *sr) | |||
1766 | GtkTreeModel *tm; | 1777 | GtkTreeModel *tm; |
1767 | GtkTreeIter iter; | 1778 | GtkTreeIter iter; |
1768 | 1779 | ||
1769 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1780 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Freeing a search result SR=%p\n", sr); |
1770 | "Freeing a search result SR=%p\n", | ||
1771 | sr); | ||
1772 | if (NULL == sr) | 1781 | if (NULL == sr) |
1773 | { | 1782 | { |
1774 | GNUNET_break (0); | 1783 | GNUNET_break (0); |
1775 | return; | 1784 | return; |
1776 | } | 1785 | } |
1777 | if ( (NULL != sr->rr) && | 1786 | if ((NULL != sr->rr) && |
1778 | (NULL != (tm = gtk_tree_row_reference_get_model (sr->rr))) && | 1787 | (NULL != (tm = gtk_tree_row_reference_get_model (sr->rr))) && |
1779 | (NULL != (tp = gtk_tree_row_reference_get_path (sr->rr))) ) | 1788 | (NULL != (tp = gtk_tree_row_reference_get_path (sr->rr)))) |
1780 | { | 1789 | { |
1781 | if (! gtk_tree_model_get_iter (tm, &iter, tp)) | 1790 | if (! gtk_tree_model_get_iter (tm, &iter, tp)) |
1782 | { | 1791 | { |
@@ -1787,24 +1796,24 @@ free_search_result (struct SearchResult *sr) | |||
1787 | /* get ready for later removal of the tree */ | 1796 | /* get ready for later removal of the tree */ |
1788 | gtk_tree_store_set (GTK_TREE_STORE (tm), | 1797 | gtk_tree_store_set (GTK_TREE_STORE (tm), |
1789 | &iter, | 1798 | &iter, |
1790 | SEARCH_TAB_MC_METADATA, NULL, | 1799 | SEARCH_TAB_MC_METADATA, |
1791 | SEARCH_TAB_MC_URI, NULL, | 1800 | NULL, |
1792 | SEARCH_TAB_MC_SEARCH_RESULT, NULL, | 1801 | SEARCH_TAB_MC_URI, |
1802 | NULL, | ||
1803 | SEARCH_TAB_MC_SEARCH_RESULT, | ||
1804 | NULL, | ||
1793 | -1); | 1805 | -1); |
1794 | gtk_tree_path_free (tp); | 1806 | gtk_tree_path_free (tp); |
1795 | gtk_tree_row_reference_free (sr->rr); | 1807 | gtk_tree_row_reference_free (sr->rr); |
1796 | sr->rr = NULL; | 1808 | sr->rr = NULL; |
1797 | remove_results_in_subtree (tm, &iter); | 1809 | remove_results_in_subtree (tm, &iter); |
1798 | GNUNET_FS_GTK_remove_treestore_subtree (GTK_TREE_STORE (tm), | 1810 | GNUNET_FS_GTK_remove_treestore_subtree (GTK_TREE_STORE (tm), &iter); |
1799 | &iter); | ||
1800 | } | 1811 | } |
1801 | if (NULL != sr->probe) | 1812 | if (NULL != sr->probe) |
1802 | { | 1813 | { |
1803 | GNUNET_FS_probe_stop (sr->probe); | 1814 | GNUNET_FS_probe_stop (sr->probe); |
1804 | sr->probe = NULL; | 1815 | sr->probe = NULL; |
1805 | GNUNET_CONTAINER_DLL_remove (pl_head, | 1816 | GNUNET_CONTAINER_DLL_remove (pl_head, pl_tail, sr); |
1806 | pl_tail, | ||
1807 | sr); | ||
1808 | } | 1817 | } |
1809 | if (NULL != sr->download) | 1818 | if (NULL != sr->download) |
1810 | { | 1819 | { |
@@ -1835,7 +1844,7 @@ free_search_result (struct SearchResult *sr) | |||
1835 | */ | 1844 | */ |
1836 | void | 1845 | void |
1837 | GNUNET_FS_GTK_search_treeview_cursor_changed (GtkTreeView *tv, | 1846 | GNUNET_FS_GTK_search_treeview_cursor_changed (GtkTreeView *tv, |
1838 | gpointer user_data) | 1847 | gpointer user_data) |
1839 | { | 1848 | { |
1840 | GtkTreeSelection *sel; | 1849 | GtkTreeSelection *sel; |
1841 | GtkTreeModel *model; | 1850 | GtkTreeModel *model; |
@@ -1858,20 +1867,22 @@ GNUNET_FS_GTK_search_treeview_cursor_changed (GtkTreeView *tv, | |||
1858 | return; | 1867 | return; |
1859 | } | 1868 | } |
1860 | pixbuf = NULL; | 1869 | pixbuf = NULL; |
1861 | gtk_tree_model_get (model, &iter, | 1870 | gtk_tree_model_get (model, |
1862 | SEARCH_TAB_MC_PREVIEW, &pixbuf, | 1871 | &iter, |
1863 | SEARCH_TAB_MC_SEARCH_RESULT, &sr, | 1872 | SEARCH_TAB_MC_PREVIEW, |
1873 | &pixbuf, | ||
1874 | SEARCH_TAB_MC_SEARCH_RESULT, | ||
1875 | &sr, | ||
1864 | -1); | 1876 | -1); |
1865 | if (NULL == sr) | 1877 | if (NULL == sr) |
1866 | return; | 1878 | return; |
1867 | selpath = gtk_tree_model_get_path (model, &iter); | 1879 | selpath = gtk_tree_model_get_path (model, &iter); |
1868 | if ( (NULL == current_selected_search_result) || | 1880 | if ((NULL == current_selected_search_result) || |
1869 | (0 != gtk_tree_path_compare (selpath, current_selected_search_result)) ) | 1881 | (0 != gtk_tree_path_compare (selpath, current_selected_search_result))) |
1870 | { | 1882 | { |
1871 | if ( (NULL == sr->download) && | 1883 | if ((NULL == sr->download) && (NULL != sr->uri) && |
1872 | (NULL != sr->uri) && | 1884 | ((GNUNET_FS_uri_test_chk (sr->uri) || |
1873 | ( (GNUNET_FS_uri_test_chk (sr->uri) || | 1885 | GNUNET_FS_uri_test_loc (sr->uri)))) |
1874 | GNUNET_FS_uri_test_loc (sr->uri)) ) ) | ||
1875 | { | 1886 | { |
1876 | char *download_directory; | 1887 | char *download_directory; |
1877 | char *filename; | 1888 | char *filename; |
@@ -1881,21 +1892,29 @@ GNUNET_FS_GTK_search_treeview_cursor_changed (GtkTreeView *tv, | |||
1881 | /* Calculate suggested filename */ | 1892 | /* Calculate suggested filename */ |
1882 | anonymity = -1; | 1893 | anonymity = -1; |
1883 | download_directory = NULL; | 1894 | download_directory = NULL; |
1884 | filename = get_suggested_filename_anonymity2 (model, &iter, | 1895 | filename = get_suggested_filename_anonymity2 (model, |
1896 | &iter, | ||
1885 | &download_directory, | 1897 | &download_directory, |
1886 | &anonymity); | 1898 | &anonymity); |
1887 | 1899 | ||
1888 | is_directory = GNUNET_FS_meta_data_test_for_directory (sr->meta); | 1900 | is_directory = GNUNET_FS_meta_data_test_for_directory (sr->meta); |
1889 | gtk_widget_set_sensitive (GTK_WIDGET (mctx->download_recursive_checkbutton), is_directory); | 1901 | gtk_widget_set_sensitive (GTK_WIDGET ( |
1902 | mctx->download_recursive_checkbutton), | ||
1903 | is_directory); | ||
1890 | 1904 | ||
1891 | /* TODO: make this configurable */ | 1905 | /* TODO: make this configurable */ |
1892 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mctx->download_recursive_checkbutton), is_directory == GNUNET_YES); | 1906 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON ( |
1907 | mctx->download_recursive_checkbutton), | ||
1908 | is_directory == GNUNET_YES); | ||
1893 | 1909 | ||
1894 | /* TODO: make this configurable */ | 1910 | /* TODO: make this configurable */ |
1895 | GNUNET_GTK_select_anonymity_combo_level (mctx->download_anonymity_combo, anonymity >= 0 ? anonymity : 1); | 1911 | GNUNET_GTK_select_anonymity_combo_level (mctx->download_anonymity_combo, |
1912 | anonymity >= 0 ? anonymity : 1); | ||
1896 | 1913 | ||
1897 | gtk_entry_set_text (mctx->download_name_entry, filename != NULL ? filename : NULL); | 1914 | gtk_entry_set_text (mctx->download_name_entry, |
1898 | gtk_file_chooser_set_current_folder (mctx->download_location_chooser, download_directory); | 1915 | filename != NULL ? filename : NULL); |
1916 | gtk_file_chooser_set_current_folder (mctx->download_location_chooser, | ||
1917 | download_directory); | ||
1899 | 1918 | ||
1900 | gtk_widget_show_all (GTK_WIDGET (mctx->download_panel)); | 1919 | gtk_widget_show_all (GTK_WIDGET (mctx->download_panel)); |
1901 | GNUNET_free_non_null (filename); | 1920 | GNUNET_free_non_null (filename); |
@@ -1934,8 +1953,7 @@ GNUNET_FS_GTK_search_treeview_cursor_changed (GtkTreeView *tv, | |||
1934 | * @param data main window context | 1953 | * @param data main window context |
1935 | */ | 1954 | */ |
1936 | void | 1955 | void |
1937 | GNUNET_GTK_main_window_notebook_switch_page_cb (GtkWidget * dummy, | 1956 | GNUNET_GTK_main_window_notebook_switch_page_cb (GtkWidget *dummy, gpointer data) |
1938 | gpointer data) | ||
1939 | { | 1957 | { |
1940 | gint page; | 1958 | gint page; |
1941 | GtkWidget *w; | 1959 | GtkWidget *w; |
@@ -1951,8 +1969,8 @@ GNUNET_GTK_main_window_notebook_switch_page_cb (GtkWidget * dummy, | |||
1951 | if (tab->frame != w) | 1969 | if (tab->frame != w) |
1952 | continue; | 1970 | continue; |
1953 | current_search_tab = tab; | 1971 | current_search_tab = tab; |
1954 | tv = GTK_TREE_VIEW (gtk_builder_get_object | 1972 | tv = GTK_TREE_VIEW ( |
1955 | (tab->builder, "_search_result_frame")); | 1973 | gtk_builder_get_object (tab->builder, "_search_result_frame")); |
1956 | GNUNET_FS_GTK_search_treeview_cursor_changed (tv, tab); | 1974 | GNUNET_FS_GTK_search_treeview_cursor_changed (tv, tab); |
1957 | return; | 1975 | return; |
1958 | } | 1976 | } |
@@ -2001,7 +2019,8 @@ GNUNET_FS_GTK_search_result_close_button_clicked (GtkButton *button, | |||
2001 | * @param user_data the 'struct SearchTab' of the tab to pause | 2019 | * @param user_data the 'struct SearchTab' of the tab to pause |
2002 | */ | 2020 | */ |
2003 | void | 2021 | void |
2004 | GNUNET_FS_GTK_search_result_pause_button_clicked (GtkButton *button, gpointer user_data) | 2022 | GNUNET_FS_GTK_search_result_pause_button_clicked (GtkButton *button, |
2023 | gpointer user_data) | ||
2005 | { | 2024 | { |
2006 | struct SearchTab *tab = user_data; | 2025 | struct SearchTab *tab = user_data; |
2007 | 2026 | ||
@@ -2023,7 +2042,8 @@ GNUNET_FS_GTK_search_result_pause_button_clicked (GtkButton *button, gpointer us | |||
2023 | * @param user_data the 'struct SearchTab' of the tab to resume | 2042 | * @param user_data the 'struct SearchTab' of the tab to resume |
2024 | */ | 2043 | */ |
2025 | void | 2044 | void |
2026 | GNUNET_FS_GTK_search_result_play_button_clicked (GtkButton * button, gpointer user_data) | 2045 | GNUNET_FS_GTK_search_result_play_button_clicked (GtkButton *button, |
2046 | gpointer user_data) | ||
2027 | { | 2047 | { |
2028 | struct SearchTab *tab = user_data; | 2048 | struct SearchTab *tab = user_data; |
2029 | 2049 | ||
@@ -2046,38 +2066,30 @@ GNUNET_FS_GTK_search_result_play_button_clicked (GtkButton * button, gpointer us | |||
2046 | * @return #GNUNET_YES if there are no active downloads left in the subtree | 2066 | * @return #GNUNET_YES if there are no active downloads left in the subtree |
2047 | */ | 2067 | */ |
2048 | static int | 2068 | static int |
2049 | stop_downloads_in_subtree (GtkTreeModel *tm, | 2069 | stop_downloads_in_subtree (GtkTreeModel *tm, GtkTreeIter *iter) |
2050 | GtkTreeIter *iter) | ||
2051 | { | 2070 | { |
2052 | GtkTreeIter child; | 2071 | GtkTreeIter child; |
2053 | struct SearchResult *sr; | 2072 | struct SearchResult *sr; |
2054 | int ret; | 2073 | int ret; |
2055 | 2074 | ||
2056 | ret = GNUNET_YES; | 2075 | ret = GNUNET_YES; |
2057 | if (gtk_tree_model_iter_children (tm, | 2076 | if (gtk_tree_model_iter_children (tm, &child, iter)) |
2058 | &child, | ||
2059 | iter)) | ||
2060 | { | 2077 | { |
2061 | do | 2078 | do |
2062 | { | 2079 | { |
2063 | gtk_tree_model_get (tm, &child, | 2080 | gtk_tree_model_get (tm, &child, SEARCH_TAB_MC_SEARCH_RESULT, &sr, -1); |
2064 | SEARCH_TAB_MC_SEARCH_RESULT, &sr, | ||
2065 | -1); | ||
2066 | if (NULL == sr) | 2081 | if (NULL == sr) |
2067 | continue; | 2082 | continue; |
2068 | if ( (NULL != sr->download) && | 2083 | if ((NULL != sr->download) && (GNUNET_YES == sr->download->is_done)) |
2069 | (GNUNET_YES == sr->download->is_done) ) | ||
2070 | { | 2084 | { |
2071 | /* got a finished download, stop it */ | 2085 | /* got a finished download, stop it */ |
2072 | GNUNET_FS_download_stop (sr->download->dc, GNUNET_YES); | 2086 | GNUNET_FS_download_stop (sr->download->dc, GNUNET_YES); |
2073 | } | 2087 | } |
2074 | if ( (NULL != sr->download) || | 2088 | if ((NULL != sr->download) || (NULL != sr->result)) |
2075 | (NULL != sr->result) ) | 2089 | ret = GNUNET_NO; |
2076 | ret = GNUNET_NO; | ||
2077 | if (GNUNET_YES != stop_downloads_in_subtree (tm, &child)) | 2090 | if (GNUNET_YES != stop_downloads_in_subtree (tm, &child)) |
2078 | ret = GNUNET_NO; | 2091 | ret = GNUNET_NO; |
2079 | } | 2092 | } while (gtk_tree_model_iter_next (tm, &child)); |
2080 | while (gtk_tree_model_iter_next (tm, &child)); | ||
2081 | } | 2093 | } |
2082 | return ret; | 2094 | return ret; |
2083 | } | 2095 | } |
@@ -2093,7 +2105,7 @@ stop_downloads_in_subtree (GtkTreeModel *tm, | |||
2093 | * @param user_data | 2105 | * @param user_data |
2094 | */ | 2106 | */ |
2095 | void | 2107 | void |
2096 | GNUNET_FS_GTK_downloads_clear_button_clicked (GtkButton * button, | 2108 | GNUNET_FS_GTK_downloads_clear_button_clicked (GtkButton *button, |
2097 | gpointer user_data) | 2109 | gpointer user_data) |
2098 | { | 2110 | { |
2099 | struct SearchResult *sr; | 2111 | struct SearchResult *sr; |
@@ -2105,28 +2117,21 @@ GNUNET_FS_GTK_downloads_clear_button_clicked (GtkButton * button, | |||
2105 | return; | 2117 | return; |
2106 | do | 2118 | do |
2107 | { | 2119 | { |
2108 | gtk_tree_model_get (tm, &iter, | 2120 | gtk_tree_model_get (tm, &iter, SEARCH_TAB_MC_SEARCH_RESULT, &sr, -1); |
2109 | SEARCH_TAB_MC_SEARCH_RESULT, &sr, | ||
2110 | -1); | ||
2111 | if (NULL == sr) | 2121 | if (NULL == sr) |
2112 | { | 2122 | { |
2113 | GNUNET_break (0); | 2123 | GNUNET_break (0); |
2114 | continue; | 2124 | continue; |
2115 | } | 2125 | } |
2116 | if ( (NULL != sr->download) && | 2126 | if ((NULL != sr->download) && (GNUNET_YES == sr->download->is_done)) |
2117 | (GNUNET_YES == sr->download->is_done) ) | ||
2118 | { | 2127 | { |
2119 | /* got a finished download, stop it */ | 2128 | /* got a finished download, stop it */ |
2120 | GNUNET_FS_download_stop (sr->download->dc, | 2129 | GNUNET_FS_download_stop (sr->download->dc, GNUNET_YES); |
2121 | GNUNET_YES); | 2130 | if (! gtk_tree_model_get_iter_first (tm, &iter)) |
2122 | if (! gtk_tree_model_get_iter_first (tm, | 2131 | return; |
2123 | &iter)) | ||
2124 | return; | ||
2125 | } | 2132 | } |
2126 | if ( (NULL == sr->download) && | 2133 | if ((NULL == sr->download) && (NULL == sr->result) && |
2127 | (NULL == sr->result) && | 2134 | (GNUNET_YES == stop_downloads_in_subtree (tm, &iter))) |
2128 | (GNUNET_YES == stop_downloads_in_subtree (tm, | ||
2129 | &iter)) ) | ||
2130 | { | 2135 | { |
2131 | /* no active download and no associated FS-API search result; | 2136 | /* no active download and no associated FS-API search result; |
2132 | so this must be some left-over entry from an opened | 2137 | so this must be some left-over entry from an opened |
@@ -2134,10 +2139,9 @@ GNUNET_FS_GTK_downloads_clear_button_clicked (GtkButton * button, | |||
2134 | free_search_result (sr); | 2139 | free_search_result (sr); |
2135 | /* the above call clobbered our 'iter', restart from the beginning... */ | 2140 | /* the above call clobbered our 'iter', restart from the beginning... */ |
2136 | if (! gtk_tree_model_get_iter_first (tm, &iter)) | 2141 | if (! gtk_tree_model_get_iter_first (tm, &iter)) |
2137 | return; | 2142 | return; |
2138 | } | 2143 | } |
2139 | } | 2144 | } while (gtk_tree_model_iter_next (tm, &iter)); |
2140 | while (gtk_tree_model_iter_next (tm, &iter)); | ||
2141 | } | 2145 | } |
2142 | 2146 | ||
2143 | 2147 | ||
@@ -2149,10 +2153,9 @@ GNUNET_FS_GTK_downloads_clear_button_clicked (GtkButton * button, | |||
2149 | * @param emsg the error message | 2153 | * @param emsg the error message |
2150 | */ | 2154 | */ |
2151 | static void | 2155 | static void |
2152 | handle_search_error (struct SearchTab *tab, | 2156 | handle_search_error (struct SearchTab *tab, const char *emsg) |
2153 | const char *emsg) | ||
2154 | { | 2157 | { |
2155 | gtk_label_set_text (tab->label, _("Error!")); | 2158 | gtk_label_set_text (tab->label, _ ("Error!")); |
2156 | gtk_widget_set_tooltip_text (GTK_WIDGET (tab->label), emsg); | 2159 | gtk_widget_set_tooltip_text (GTK_WIDGET (tab->label), emsg); |
2157 | } | 2160 | } |
2158 | 2161 | ||
@@ -2168,11 +2171,11 @@ static char * | |||
2168 | get_mimetype_from_metadata (const struct GNUNET_CONTAINER_MetaData *meta) | 2171 | get_mimetype_from_metadata (const struct GNUNET_CONTAINER_MetaData *meta) |
2169 | { | 2172 | { |
2170 | return GNUNET_CONTAINER_meta_data_get_first_by_types (meta, | 2173 | return GNUNET_CONTAINER_meta_data_get_first_by_types (meta, |
2171 | EXTRACTOR_METATYPE_MIMETYPE, | 2174 | EXTRACTOR_METATYPE_MIMETYPE, |
2172 | #if HAVE_EXTRACTOR_H | 2175 | #if HAVE_EXTRACTOR_H |
2173 | EXTRACTOR_METATYPE_FORMAT, | 2176 | EXTRACTOR_METATYPE_FORMAT, |
2174 | #endif | 2177 | #endif |
2175 | -1); | 2178 | -1); |
2176 | } | 2179 | } |
2177 | 2180 | ||
2178 | 2181 | ||
@@ -2191,9 +2194,9 @@ static void | |||
2191 | update_search_result (struct SearchResult *sr, | 2194 | update_search_result (struct SearchResult *sr, |
2192 | const struct GNUNET_CONTAINER_MetaData *meta, | 2195 | const struct GNUNET_CONTAINER_MetaData *meta, |
2193 | uint32_t applicability_rank, | 2196 | uint32_t applicability_rank, |
2194 | int32_t availability_rank, | 2197 | int32_t availability_rank, |
2195 | uint32_t availability_certainty, | 2198 | uint32_t availability_certainty, |
2196 | struct GNUNET_TIME_Relative probe_time) | 2199 | struct GNUNET_TIME_Relative probe_time) |
2197 | { | 2200 | { |
2198 | GtkTreeIter iter; | 2201 | GtkTreeIter iter; |
2199 | GtkTreeView *tv; | 2202 | GtkTreeView *tv; |
@@ -2231,33 +2234,61 @@ update_search_result (struct SearchResult *sr, | |||
2231 | } | 2234 | } |
2232 | sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); | 2235 | sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); |
2233 | if (availability_certainty > 0) | 2236 | if (availability_certainty > 0) |
2234 | percent_avail = 50 + (gint) (availability_rank * 50.0 / availability_certainty); | 2237 | percent_avail = |
2238 | 50 + (gint) (availability_rank * 50.0 / availability_certainty); | ||
2235 | else | 2239 | else |
2236 | percent_avail = 50; | 2240 | percent_avail = 50; |
2237 | gtk_tree_store_set (ts, &iter, | 2241 | gtk_tree_store_set (ts, |
2238 | SEARCH_TAB_MC_METADATA, sr->meta, | 2242 | &iter, |
2239 | SEARCH_TAB_MC_PREVIEW, pixbuf, | 2243 | SEARCH_TAB_MC_METADATA, |
2240 | SEARCH_TAB_MC_PERCENT_AVAILABILITY, (guint) percent_avail, | 2244 | sr->meta, |
2241 | SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, (0 == availability_certainty) ? (gint) (probe_time.rel_value_us / GNUNET_FS_PROBE_UPDATE_FREQUENCY.rel_value_us) : -1, | 2245 | SEARCH_TAB_MC_PREVIEW, |
2242 | SEARCH_TAB_MC_FILENAME, desc, | 2246 | pixbuf, |
2243 | SEARCH_TAB_MC_MIMETYPE, mime, | 2247 | SEARCH_TAB_MC_PERCENT_AVAILABILITY, |
2244 | SEARCH_TAB_MC_APPLICABILITY_RANK, (guint) applicability_rank, | 2248 | (guint) percent_avail, |
2245 | SEARCH_TAB_MC_AVAILABILITY_CERTAINTY, (guint) availability_certainty, | 2249 | SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, |
2246 | SEARCH_TAB_MC_AVAILABILITY_RANK, (gint) availability_rank, | 2250 | (0 == availability_certainty) |
2251 | ? (gint) (probe_time.rel_value_us / | ||
2252 | GNUNET_FS_PROBE_UPDATE_FREQUENCY.rel_value_us) | ||
2253 | : -1, | ||
2254 | SEARCH_TAB_MC_FILENAME, | ||
2255 | desc, | ||
2256 | SEARCH_TAB_MC_MIMETYPE, | ||
2257 | mime, | ||
2258 | SEARCH_TAB_MC_APPLICABILITY_RANK, | ||
2259 | (guint) applicability_rank, | ||
2260 | SEARCH_TAB_MC_AVAILABILITY_CERTAINTY, | ||
2261 | (guint) availability_certainty, | ||
2262 | SEARCH_TAB_MC_AVAILABILITY_RANK, | ||
2263 | (gint) availability_rank, | ||
2247 | -1); | 2264 | -1); |
2248 | if (NULL != sr->download) | 2265 | if (NULL != sr->download) |
2249 | { | 2266 | { |
2250 | get_download_list_entry (sr->download, &iter); | 2267 | get_download_list_entry (sr->download, &iter); |
2251 | gtk_tree_store_set (downloads_treestore, &iter, | 2268 | gtk_tree_store_set (downloads_treestore, |
2252 | SEARCH_TAB_MC_METADATA, sr->meta, | 2269 | &iter, |
2253 | SEARCH_TAB_MC_PREVIEW, pixbuf, | 2270 | SEARCH_TAB_MC_METADATA, |
2254 | SEARCH_TAB_MC_PERCENT_AVAILABILITY, (guint) percent_avail, | 2271 | sr->meta, |
2255 | SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, (0 == availability_certainty) ? (gint) (probe_time.rel_value_us / GNUNET_FS_PROBE_UPDATE_FREQUENCY.rel_value_us) : -1, | 2272 | SEARCH_TAB_MC_PREVIEW, |
2256 | SEARCH_TAB_MC_FILENAME, desc, | 2273 | pixbuf, |
2257 | SEARCH_TAB_MC_MIMETYPE, mime, | 2274 | SEARCH_TAB_MC_PERCENT_AVAILABILITY, |
2258 | SEARCH_TAB_MC_APPLICABILITY_RANK, (guint) applicability_rank, | 2275 | (guint) percent_avail, |
2259 | SEARCH_TAB_MC_AVAILABILITY_CERTAINTY, (guint) availability_certainty, | 2276 | SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, |
2260 | SEARCH_TAB_MC_AVAILABILITY_RANK, (gint) availability_rank, | 2277 | (0 == availability_certainty) |
2278 | ? (gint) ( | ||
2279 | probe_time.rel_value_us / | ||
2280 | GNUNET_FS_PROBE_UPDATE_FREQUENCY.rel_value_us) | ||
2281 | : -1, | ||
2282 | SEARCH_TAB_MC_FILENAME, | ||
2283 | desc, | ||
2284 | SEARCH_TAB_MC_MIMETYPE, | ||
2285 | mime, | ||
2286 | SEARCH_TAB_MC_APPLICABILITY_RANK, | ||
2287 | (guint) applicability_rank, | ||
2288 | SEARCH_TAB_MC_AVAILABILITY_CERTAINTY, | ||
2289 | (guint) availability_certainty, | ||
2290 | SEARCH_TAB_MC_AVAILABILITY_RANK, | ||
2291 | (gint) availability_rank, | ||
2261 | -1); | 2292 | -1); |
2262 | } | 2293 | } |
2263 | 2294 | ||
@@ -2272,7 +2303,8 @@ update_search_result (struct SearchResult *sr, | |||
2272 | GtkTreeSelection *sel; | 2303 | GtkTreeSelection *sel; |
2273 | GtkTreeModel *model; | 2304 | GtkTreeModel *model; |
2274 | GtkTreeIter iter; | 2305 | GtkTreeIter iter; |
2275 | tv = GTK_TREE_VIEW (gtk_builder_get_object (sr->tab->builder, "_search_result_frame")); | 2306 | tv = GTK_TREE_VIEW ( |
2307 | gtk_builder_get_object (sr->tab->builder, "_search_result_frame")); | ||
2276 | sel = gtk_tree_view_get_selection (tv); | 2308 | sel = gtk_tree_view_get_selection (tv); |
2277 | if (gtk_tree_selection_get_selected (sel, &model, &iter)) | 2309 | if (gtk_tree_selection_get_selected (sel, &model, &iter)) |
2278 | { | 2310 | { |
@@ -2294,8 +2326,7 @@ update_search_result (struct SearchResult *sr, | |||
2294 | * @return 1 (abort iteration) | 2326 | * @return 1 (abort iteration) |
2295 | */ | 2327 | */ |
2296 | static int | 2328 | static int |
2297 | see_if_there_are_any_uris (void *cls, | 2329 | see_if_there_are_any_uris (void *cls, const struct GNUNET_FS_Uri *sks_uri) |
2298 | const struct GNUNET_FS_Uri *sks_uri) | ||
2299 | { | 2330 | { |
2300 | gboolean *gb = cls; | 2331 | gboolean *gb = cls; |
2301 | 2332 | ||
@@ -2325,7 +2356,7 @@ see_if_there_are_any_uris (void *cls, | |||
2325 | */ | 2356 | */ |
2326 | struct SearchResult * | 2357 | struct SearchResult * |
2327 | GNUNET_GTK_add_search_result (struct SearchTab *tab, | 2358 | GNUNET_GTK_add_search_result (struct SearchTab *tab, |
2328 | uint32_t anonymity, | 2359 | uint32_t anonymity, |
2329 | GtkTreeRowReference *parent_rr, | 2360 | GtkTreeRowReference *parent_rr, |
2330 | const struct GNUNET_FS_Uri *uri, | 2361 | const struct GNUNET_FS_Uri *uri, |
2331 | const struct GNUNET_CONTAINER_MetaData *meta, | 2362 | const struct GNUNET_CONTAINER_MetaData *meta, |
@@ -2356,12 +2387,11 @@ GNUNET_GTK_add_search_result (struct SearchTab *tab, | |||
2356 | fsize = 0; | 2387 | fsize = 0; |
2357 | status_colour = "gray"; | 2388 | status_colour = "gray"; |
2358 | mime = GNUNET_strdup (GNUNET_FS_DIRECTORY_MIME); | 2389 | mime = GNUNET_strdup (GNUNET_FS_DIRECTORY_MIME); |
2359 | uris = GNUNET_strdup (_("no URI")); | 2390 | uris = GNUNET_strdup (_ ("no URI")); |
2360 | } | 2391 | } |
2361 | else | 2392 | else |
2362 | { | 2393 | { |
2363 | if ( (GNUNET_FS_uri_test_loc (uri)) || | 2394 | if ((GNUNET_FS_uri_test_loc (uri)) || (GNUNET_FS_uri_test_chk (uri))) |
2364 | (GNUNET_FS_uri_test_chk (uri)) ) | ||
2365 | { | 2395 | { |
2366 | fsize = GNUNET_FS_uri_chk_get_file_size (uri); | 2396 | fsize = GNUNET_FS_uri_chk_get_file_size (uri); |
2367 | mime = get_mimetype_from_metadata (meta); | 2397 | mime = get_mimetype_from_metadata (meta); |
@@ -2377,27 +2407,21 @@ GNUNET_GTK_add_search_result (struct SearchTab *tab, | |||
2377 | } | 2407 | } |
2378 | desc = GNUNET_FS_GTK_get_description_from_metadata (meta, &desc_is_a_dup); | 2408 | desc = GNUNET_FS_GTK_get_description_from_metadata (meta, &desc_is_a_dup); |
2379 | pixbuf = GNUNET_FS_GTK_get_thumbnail_from_meta_data (meta); | 2409 | pixbuf = GNUNET_FS_GTK_get_thumbnail_from_meta_data (meta); |
2380 | find_embedded_uris (meta, | 2410 | find_embedded_uris (meta, &see_if_there_are_any_uris, &show_uri_association); |
2381 | &see_if_there_are_any_uris, | ||
2382 | &show_uri_association); | ||
2383 | 2411 | ||
2384 | sr = GNUNET_new (struct SearchResult); | 2412 | sr = GNUNET_new (struct SearchResult); |
2385 | sr->result = result; | 2413 | sr->result = result; |
2386 | if (NULL == result) | 2414 | if (NULL == result) |
2387 | { | 2415 | { |
2388 | sr->probe = GNUNET_FS_probe (GNUNET_FS_GTK_get_fs_handle (), | 2416 | sr->probe = GNUNET_FS_probe (GNUNET_FS_GTK_get_fs_handle (), |
2389 | uri, | 2417 | uri, |
2390 | meta, | 2418 | meta, |
2391 | sr, | 2419 | sr, |
2392 | anonymity); | 2420 | anonymity); |
2393 | GNUNET_CONTAINER_DLL_insert (pl_head, | 2421 | GNUNET_CONTAINER_DLL_insert (pl_head, pl_tail, sr); |
2394 | pl_tail, | ||
2395 | sr); | ||
2396 | } | 2422 | } |
2397 | sr->tab = tab; | 2423 | sr->tab = tab; |
2398 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2424 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Allocated a search result SR=%p\n", sr); |
2399 | "Allocated a search result SR=%p\n", | ||
2400 | sr); | ||
2401 | if (NULL != parent_rr) | 2425 | if (NULL != parent_rr) |
2402 | { | 2426 | { |
2403 | /* get piter from parent */ | 2427 | /* get piter from parent */ |
@@ -2427,26 +2451,48 @@ GNUNET_GTK_add_search_result (struct SearchTab *tab, | |||
2427 | } | 2451 | } |
2428 | sr->uri = (uri == NULL) ? NULL : GNUNET_FS_uri_dup (uri); | 2452 | sr->uri = (uri == NULL) ? NULL : GNUNET_FS_uri_dup (uri); |
2429 | sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); | 2453 | sr->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); |
2430 | gtk_tree_store_insert_with_values (ts, &iter, pitr, G_MAXINT, | 2454 | gtk_tree_store_insert_with_values (ts, |
2431 | SEARCH_TAB_MC_METADATA, sr->meta, | 2455 | &iter, |
2432 | SEARCH_TAB_MC_URI, sr->uri, | 2456 | pitr, |
2433 | SEARCH_TAB_MC_FILESIZE, fsize, | 2457 | G_MAXINT, |
2434 | SEARCH_TAB_MC_PREVIEW, pixbuf, | 2458 | SEARCH_TAB_MC_METADATA, |
2435 | SEARCH_TAB_MC_PERCENT_PROGRESS, 0, | 2459 | sr->meta, |
2436 | SEARCH_TAB_MC_PERCENT_AVAILABILITY, (0 == fsize) ? 100 : 50, | 2460 | SEARCH_TAB_MC_URI, |
2437 | SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, (0 == fsize) ? -1 : 0, | 2461 | sr->uri, |
2438 | SEARCH_TAB_MC_FILENAME, desc, | 2462 | SEARCH_TAB_MC_FILESIZE, |
2439 | SEARCH_TAB_MC_URI_AS_STRING, uris, | 2463 | fsize, |
2440 | SEARCH_TAB_MC_STATUS_COLOUR, status_colour, | 2464 | SEARCH_TAB_MC_PREVIEW, |
2441 | SEARCH_TAB_MC_SEARCH_RESULT, sr, | 2465 | pixbuf, |
2442 | SEARCH_TAB_MC_MIMETYPE, mime, | 2466 | SEARCH_TAB_MC_PERCENT_PROGRESS, |
2443 | SEARCH_TAB_MC_APPLICABILITY_RANK, applicability_rank, | 2467 | 0, |
2444 | SEARCH_TAB_MC_AVAILABILITY_CERTAINTY, 0, | 2468 | SEARCH_TAB_MC_PERCENT_AVAILABILITY, |
2445 | SEARCH_TAB_MC_AVAILABILITY_RANK, 0, | 2469 | (0 == fsize) ? 100 : 50, |
2446 | SEARCH_TAB_MC_COMPLETED, (guint64) 0, | 2470 | SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, |
2447 | SEARCH_TAB_MC_DOWNLOADED_FILENAME, NULL, | 2471 | (0 == fsize) ? -1 : 0, |
2448 | SEARCH_TAB_MC_DOWNLOADED_ANONYMITY, (guint) -1, | 2472 | SEARCH_TAB_MC_FILENAME, |
2449 | SEARCH_TAB_MC_SHOW_NS_ASSOCIATION, show_uri_association, | 2473 | desc, |
2474 | SEARCH_TAB_MC_URI_AS_STRING, | ||
2475 | uris, | ||
2476 | SEARCH_TAB_MC_STATUS_COLOUR, | ||
2477 | status_colour, | ||
2478 | SEARCH_TAB_MC_SEARCH_RESULT, | ||
2479 | sr, | ||
2480 | SEARCH_TAB_MC_MIMETYPE, | ||
2481 | mime, | ||
2482 | SEARCH_TAB_MC_APPLICABILITY_RANK, | ||
2483 | applicability_rank, | ||
2484 | SEARCH_TAB_MC_AVAILABILITY_CERTAINTY, | ||
2485 | 0, | ||
2486 | SEARCH_TAB_MC_AVAILABILITY_RANK, | ||
2487 | 0, | ||
2488 | SEARCH_TAB_MC_COMPLETED, | ||
2489 | (guint64) 0, | ||
2490 | SEARCH_TAB_MC_DOWNLOADED_FILENAME, | ||
2491 | NULL, | ||
2492 | SEARCH_TAB_MC_DOWNLOADED_ANONYMITY, | ||
2493 | (guint) -1, | ||
2494 | SEARCH_TAB_MC_SHOW_NS_ASSOCIATION, | ||
2495 | show_uri_association, | ||
2450 | -1); | 2496 | -1); |
2451 | if (NULL != pixbuf) | 2497 | if (NULL != pixbuf) |
2452 | g_object_unref (pixbuf); | 2498 | g_object_unref (pixbuf); |
@@ -2483,7 +2529,9 @@ GNUNET_GTK_add_search_result (struct SearchTab *tab, | |||
2483 | * @param filename new filename | 2529 | * @param filename new filename |
2484 | */ | 2530 | */ |
2485 | void | 2531 | void |
2486 | GNUNET_FS_GTK_set_item_downloaded_name (GtkTreeStore *ts, GtkTreeRowReference *rr, gchar *filename) | 2532 | GNUNET_FS_GTK_set_item_downloaded_name (GtkTreeStore *ts, |
2533 | GtkTreeRowReference *rr, | ||
2534 | gchar *filename) | ||
2487 | { | 2535 | { |
2488 | struct GNUNET_GTK_MainWindowContext *mctx = GNUNET_FS_GTK_get_main_context (); | 2536 | struct GNUNET_GTK_MainWindowContext *mctx = GNUNET_FS_GTK_get_main_context (); |
2489 | GtkTreeIter iter; | 2537 | GtkTreeIter iter; |
@@ -2541,11 +2589,13 @@ GNUNET_FS_GTK_set_item_downloaded_name (GtkTreeStore *ts, GtkTreeRowReference *r | |||
2541 | while (relname[0] == '/' || relname[0] == '\\') | 2589 | while (relname[0] == '/' || relname[0] == '\\') |
2542 | relname++; | 2590 | relname++; |
2543 | gtk_entry_set_text (mctx->download_name_entry, relname); | 2591 | gtk_entry_set_text (mctx->download_name_entry, relname); |
2544 | gtk_file_chooser_set_current_folder (mctx->download_location_chooser, dirname); | 2592 | gtk_file_chooser_set_current_folder (mctx->download_location_chooser, |
2593 | dirname); | ||
2545 | break; | 2594 | break; |
2546 | } | 2595 | } |
2547 | current = dirname; | 2596 | current = dirname; |
2548 | } while (dirname[0] != '.'); /* FIXME: Check that this condition is correct */ | 2597 | } while (dirname[0] != |
2598 | '.'); /* FIXME: Check that this condition is correct */ | ||
2549 | g_free (dirname); | 2599 | g_free (dirname); |
2550 | } | 2600 | } |
2551 | gtk_tree_path_free (path); | 2601 | gtk_tree_path_free (path); |
@@ -2572,8 +2622,8 @@ GNUNET_FS_GTK_set_item_downloaded_name (GtkTreeStore *ts, GtkTreeRowReference *r | |||
2572 | */ | 2622 | */ |
2573 | static struct SearchResult * | 2623 | static struct SearchResult * |
2574 | process_search_result (struct SearchTab *tab, | 2624 | process_search_result (struct SearchTab *tab, |
2575 | uint32_t anonymity, | 2625 | uint32_t anonymity, |
2576 | struct SearchResult *parent, | 2626 | struct SearchResult *parent, |
2577 | const struct GNUNET_FS_Uri *uri, | 2627 | const struct GNUNET_FS_Uri *uri, |
2578 | const struct GNUNET_CONTAINER_MetaData *meta, | 2628 | const struct GNUNET_CONTAINER_MetaData *meta, |
2579 | struct GNUNET_FS_SearchResult *result, | 2629 | struct GNUNET_FS_SearchResult *result, |
@@ -2582,10 +2632,12 @@ process_search_result (struct SearchTab *tab, | |||
2582 | struct SearchResult *sr; | 2632 | struct SearchResult *sr; |
2583 | 2633 | ||
2584 | sr = GNUNET_GTK_add_search_result (tab, | 2634 | sr = GNUNET_GTK_add_search_result (tab, |
2585 | anonymity, | 2635 | anonymity, |
2586 | (parent != NULL) ? parent->rr : NULL, | 2636 | (parent != NULL) ? parent->rr : NULL, |
2587 | uri, | 2637 | uri, |
2588 | meta, result, applicability_rank); | 2638 | meta, |
2639 | result, | ||
2640 | applicability_rank); | ||
2589 | update_search_label (tab); | 2641 | update_search_label (tab); |
2590 | GNUNET_break (NULL != sr); | 2642 | GNUNET_break (NULL != sr); |
2591 | return sr; | 2643 | return sr; |
@@ -2601,7 +2653,7 @@ process_search_result (struct SearchTab *tab, | |||
2601 | */ | 2653 | */ |
2602 | static struct SearchTab * | 2654 | static struct SearchTab * |
2603 | setup_search_tab (struct GNUNET_FS_SearchContext *sc, | 2655 | setup_search_tab (struct GNUNET_FS_SearchContext *sc, |
2604 | const struct GNUNET_FS_Uri *query) | 2656 | const struct GNUNET_FS_Uri *query) |
2605 | { | 2657 | { |
2606 | struct SearchTab *tab; | 2658 | struct SearchTab *tab; |
2607 | GtkWindow *sf; | 2659 | GtkWindow *sf; |
@@ -2634,53 +2686,51 @@ setup_search_tab (struct GNUNET_FS_SearchContext *sc, | |||
2634 | else | 2686 | else |
2635 | tab->query_txt = GNUNET_FS_uri_to_string (query); | 2687 | tab->query_txt = GNUNET_FS_uri_to_string (query); |
2636 | } | 2688 | } |
2637 | tab->builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_search_tab.glade", | 2689 | tab->builder = |
2638 | tab); | 2690 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_search_tab.glade", tab); |
2639 | tab->ts = | 2691 | tab->ts = GTK_TREE_STORE ( |
2640 | GTK_TREE_STORE (gtk_builder_get_object | 2692 | gtk_builder_get_object (tab->builder, |
2641 | (tab->builder, | 2693 | "GNUNET_GTK_file_sharing_result_tree_store")); |
2642 | "GNUNET_GTK_file_sharing_result_tree_store")); | 2694 | tv = GTK_TREE_VIEW ( |
2643 | tv = GTK_TREE_VIEW (gtk_builder_get_object | 2695 | gtk_builder_get_object (tab->builder, "_search_result_frame")); |
2644 | (tab->builder, "_search_result_frame")); | 2696 | anim_col = GTK_TREE_VIEW_COLUMN ( |
2645 | anim_col = GTK_TREE_VIEW_COLUMN (gtk_builder_get_object | 2697 | gtk_builder_get_object (tab->builder, |
2646 | (tab->builder, "search_result_status_pixbuf_column")); | 2698 | "search_result_status_pixbuf_column")); |
2647 | tab->atv = GNUNET_GTK_animation_tree_view_register (tv, | 2699 | tab->atv = GNUNET_GTK_animation_tree_view_register (tv, anim_col); |
2648 | anim_col); | ||
2649 | /* load frame */ | 2700 | /* load frame */ |
2650 | sf = GTK_WINDOW (gtk_builder_get_object | 2701 | sf = GTK_WINDOW ( |
2651 | (tab->builder, "_search_result_frame_window")); | 2702 | gtk_builder_get_object (tab->builder, "_search_result_frame_window")); |
2652 | tab->frame = gtk_bin_get_child (GTK_BIN (sf)); | 2703 | tab->frame = gtk_bin_get_child (GTK_BIN (sf)); |
2653 | g_object_ref (tab->frame); | 2704 | g_object_ref (tab->frame); |
2654 | gtk_container_remove (GTK_CONTAINER (sf), tab->frame); | 2705 | gtk_container_remove (GTK_CONTAINER (sf), tab->frame); |
2655 | gtk_widget_destroy (GTK_WIDGET (sf)); | 2706 | gtk_widget_destroy (GTK_WIDGET (sf)); |
2656 | 2707 | ||
2657 | /* load tab_label */ | 2708 | /* load tab_label */ |
2658 | sf = GTK_WINDOW (gtk_builder_get_object | 2709 | sf = GTK_WINDOW ( |
2659 | (tab->builder, "_search_result_label_window")); | 2710 | gtk_builder_get_object (tab->builder, "_search_result_label_window")); |
2660 | tab->tab_label = gtk_bin_get_child (GTK_BIN (sf)); | 2711 | tab->tab_label = gtk_bin_get_child (GTK_BIN (sf)); |
2661 | g_object_ref (tab->tab_label); | 2712 | g_object_ref (tab->tab_label); |
2662 | gtk_container_remove (GTK_CONTAINER (sf), tab->tab_label); | 2713 | gtk_container_remove (GTK_CONTAINER (sf), tab->tab_label); |
2663 | gtk_widget_destroy (GTK_WIDGET (sf)); | 2714 | gtk_widget_destroy (GTK_WIDGET (sf)); |
2664 | 2715 | ||
2665 | /* get refs to widgets */ | 2716 | /* get refs to widgets */ |
2666 | tab->label = | 2717 | tab->label = GTK_LABEL ( |
2667 | GTK_LABEL (gtk_builder_get_object | 2718 | gtk_builder_get_object (tab->builder, "_search_result_label_window_label")); |
2668 | (tab->builder, "_search_result_label_window_label")); | 2719 | tab->close_button = GTK_WIDGET ( |
2669 | tab->close_button = | 2720 | gtk_builder_get_object (tab->builder, "_search_result_label_close_button")); |
2670 | GTK_WIDGET (gtk_builder_get_object | 2721 | tab->play_button = GTK_WIDGET ( |
2671 | (tab->builder, "_search_result_label_close_button")); | 2722 | gtk_builder_get_object (tab->builder, "_search_result_label_play_button")); |
2672 | tab->play_button = | 2723 | tab->pause_button = GTK_WIDGET ( |
2673 | GTK_WIDGET (gtk_builder_get_object | 2724 | gtk_builder_get_object (tab->builder, "_search_result_label_pause_button")); |
2674 | (tab->builder, "_search_result_label_play_button")); | ||
2675 | tab->pause_button = | ||
2676 | GTK_WIDGET (gtk_builder_get_object | ||
2677 | (tab->builder, "_search_result_label_pause_button")); | ||
2678 | /* patch text */ | 2725 | /* patch text */ |
2679 | update_search_label (tab); | 2726 | update_search_label (tab); |
2680 | 2727 | ||
2681 | /* make visible */ | 2728 | /* make visible */ |
2682 | pages = gtk_notebook_get_n_pages (mctx->notebook); | 2729 | pages = gtk_notebook_get_n_pages (mctx->notebook); |
2683 | gtk_notebook_insert_page (mctx->notebook, tab->frame, tab->tab_label, pages - 1); | 2730 | gtk_notebook_insert_page (mctx->notebook, |
2731 | tab->frame, | ||
2732 | tab->tab_label, | ||
2733 | pages - 1); | ||
2684 | gtk_notebook_set_current_page (mctx->notebook, pages - 1); | 2734 | gtk_notebook_set_current_page (mctx->notebook, pages - 1); |
2685 | gtk_widget_show (GTK_WIDGET (mctx->notebook)); | 2735 | gtk_widget_show (GTK_WIDGET (mctx->notebook)); |
2686 | return tab; | 2736 | return tab; |
@@ -2743,7 +2793,7 @@ setup_inner_search (struct GNUNET_FS_SearchContext *sc, | |||
2743 | */ | 2793 | */ |
2744 | struct SearchResult * | 2794 | struct SearchResult * |
2745 | GNUNET_GTK_add_to_uri_tab (uint32_t anonymity, | 2795 | GNUNET_GTK_add_to_uri_tab (uint32_t anonymity, |
2746 | const struct GNUNET_CONTAINER_MetaData *meta, | 2796 | const struct GNUNET_CONTAINER_MetaData *meta, |
2747 | const struct GNUNET_FS_Uri *uri) | 2797 | const struct GNUNET_FS_Uri *uri) |
2748 | { | 2798 | { |
2749 | struct GNUNET_GTK_MainWindowContext *mctx = GNUNET_FS_GTK_get_main_context (); | 2799 | struct GNUNET_GTK_MainWindowContext *mctx = GNUNET_FS_GTK_get_main_context (); |
@@ -2763,16 +2813,18 @@ GNUNET_GTK_add_to_uri_tab (uint32_t anonymity, | |||
2763 | break; | 2813 | break; |
2764 | } | 2814 | } |
2765 | return GNUNET_GTK_add_search_result (uri_tab, | 2815 | return GNUNET_GTK_add_search_result (uri_tab, |
2766 | anonymity, | 2816 | anonymity, |
2767 | NULL, uri, meta, NULL, 0); | 2817 | NULL, |
2818 | uri, | ||
2819 | meta, | ||
2820 | NULL, | ||
2821 | 0); | ||
2768 | } | 2822 | } |
2769 | 2823 | ||
2770 | 2824 | ||
2771 | |||
2772 | /* ***************** Download event handling ****************** */ | 2825 | /* ***************** Download event handling ****************** */ |
2773 | 2826 | ||
2774 | 2827 | ||
2775 | |||
2776 | /** | 2828 | /** |
2777 | * Change the (background) color of the given download entry. | 2829 | * Change the (background) color of the given download entry. |
2778 | * | 2830 | * |
@@ -2780,8 +2832,7 @@ GNUNET_GTK_add_to_uri_tab (uint32_t anonymity, | |||
2780 | * @param color name of the color to use | 2832 | * @param color name of the color to use |
2781 | */ | 2833 | */ |
2782 | static void | 2834 | static void |
2783 | change_download_color (struct DownloadEntry *de, | 2835 | change_download_color (struct DownloadEntry *de, const char *color) |
2784 | const char *color) | ||
2785 | { | 2836 | { |
2786 | GtkTreeIter iter; | 2837 | GtkTreeIter iter; |
2787 | GtkTreePath *path; | 2838 | GtkTreePath *path; |
@@ -2789,34 +2840,28 @@ change_download_color (struct DownloadEntry *de, | |||
2789 | struct SearchTab *tab; | 2840 | struct SearchTab *tab; |
2790 | 2841 | ||
2791 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2842 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2792 | "Changing download DE=%p color to %s\n", | 2843 | "Changing download DE=%p color to %s\n", |
2793 | de, | 2844 | de, |
2794 | color); | 2845 | color); |
2795 | deep = de; | 2846 | deep = de; |
2796 | while (NULL != deep->pde) | 2847 | while (NULL != deep->pde) |
2797 | deep = deep->pde; | 2848 | deep = deep->pde; |
2798 | tab = NULL; | 2849 | tab = NULL; |
2799 | if ( (NULL != deep->sr) && | 2850 | if ((NULL != deep->sr) && (NULL != (tab = deep->sr->tab))) |
2800 | (NULL != (tab = deep->sr->tab)) ) | ||
2801 | { | 2851 | { |
2802 | path = gtk_tree_row_reference_get_path (de->sr->rr); | 2852 | path = gtk_tree_row_reference_get_path (de->sr->rr); |
2803 | GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (tab->ts), | 2853 | GNUNET_assert ( |
2804 | &iter, | 2854 | gtk_tree_model_get_iter (GTK_TREE_MODEL (tab->ts), &iter, path)); |
2805 | path)); | ||
2806 | gtk_tree_path_free (path); | 2855 | gtk_tree_path_free (path); |
2807 | gtk_tree_store_set (tab->ts, | 2856 | gtk_tree_store_set (tab->ts, &iter, SEARCH_TAB_MC_STATUS_COLOUR, color, -1); |
2808 | &iter, | ||
2809 | SEARCH_TAB_MC_STATUS_COLOUR, color, | ||
2810 | -1); | ||
2811 | } | 2857 | } |
2812 | /* do the same update to the downloads tree store */ | 2858 | /* do the same update to the downloads tree store */ |
2813 | get_download_list_entry (de, | 2859 | get_download_list_entry (de, &iter); |
2814 | &iter); | ||
2815 | gtk_tree_store_set (downloads_treestore, | 2860 | gtk_tree_store_set (downloads_treestore, |
2816 | &iter, | 2861 | &iter, |
2817 | SEARCH_TAB_MC_STATUS_COLOUR, color, | 2862 | SEARCH_TAB_MC_STATUS_COLOUR, |
2863 | color, | ||
2818 | -1); | 2864 | -1); |
2819 | |||
2820 | } | 2865 | } |
2821 | 2866 | ||
2822 | 2867 | ||
@@ -2827,8 +2872,7 @@ change_download_color (struct DownloadEntry *de, | |||
2827 | * @param icon status icon to display | 2872 | * @param icon status icon to display |
2828 | */ | 2873 | */ |
2829 | static void | 2874 | static void |
2830 | change_download_status_icon (struct DownloadEntry *de, | 2875 | change_download_status_icon (struct DownloadEntry *de, GdkPixbuf *icon) |
2831 | GdkPixbuf *icon) | ||
2832 | { | 2876 | { |
2833 | GtkTreeIter iter; | 2877 | GtkTreeIter iter; |
2834 | GtkTreePath *path; | 2878 | GtkTreePath *path; |
@@ -2839,24 +2883,20 @@ change_download_status_icon (struct DownloadEntry *de, | |||
2839 | while (NULL != deep->pde) | 2883 | while (NULL != deep->pde) |
2840 | deep = deep->pde; | 2884 | deep = deep->pde; |
2841 | tab = NULL; | 2885 | tab = NULL; |
2842 | if ( (NULL != deep->sr) && | 2886 | if ((NULL != deep->sr) && (NULL != (tab = deep->sr->tab))) |
2843 | (NULL != (tab = deep->sr->tab)) ) | ||
2844 | { | 2887 | { |
2845 | path = gtk_tree_row_reference_get_path (de->sr->rr); | 2888 | path = gtk_tree_row_reference_get_path (de->sr->rr); |
2846 | GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (tab->ts), | 2889 | GNUNET_assert ( |
2847 | &iter, | 2890 | gtk_tree_model_get_iter (GTK_TREE_MODEL (tab->ts), &iter, path)); |
2848 | path)); | ||
2849 | gtk_tree_path_free (path); | 2891 | gtk_tree_path_free (path); |
2850 | gtk_tree_store_set (tab->ts, | 2892 | gtk_tree_store_set (tab->ts, &iter, SEARCH_TAB_MC_STATUS_ICON, icon, -1); |
2851 | &iter, | ||
2852 | SEARCH_TAB_MC_STATUS_ICON, icon, | ||
2853 | -1); | ||
2854 | } | 2893 | } |
2855 | /* do the same update to the downloads tree store */ | 2894 | /* do the same update to the downloads tree store */ |
2856 | get_download_list_entry (de, &iter); | 2895 | get_download_list_entry (de, &iter); |
2857 | gtk_tree_store_set (downloads_treestore, | 2896 | gtk_tree_store_set (downloads_treestore, |
2858 | &iter, | 2897 | &iter, |
2859 | SEARCH_TAB_MC_STATUS_ICON, icon, | 2898 | SEARCH_TAB_MC_STATUS_ICON, |
2899 | icon, | ||
2860 | -1); | 2900 | -1); |
2861 | } | 2901 | } |
2862 | 2902 | ||
@@ -2906,7 +2946,6 @@ struct AddDirectoryEntryContext | |||
2906 | * and we're calling during a 'PROGRESS' event. | 2946 | * and we're calling during a 'PROGRESS' event. |
2907 | */ | 2947 | */ |
2908 | int check_duplicates; | 2948 | int check_duplicates; |
2909 | |||
2910 | }; | 2949 | }; |
2911 | 2950 | ||
2912 | 2951 | ||
@@ -2934,7 +2973,8 @@ struct AddDirectoryEntryContext | |||
2934 | * @param data data available for the file (@a length bytes) | 2973 | * @param data data available for the file (@a length bytes) |
2935 | */ | 2974 | */ |
2936 | static void | 2975 | static void |
2937 | add_directory_entry (void *cls, const char *filename, | 2976 | add_directory_entry (void *cls, |
2977 | const char *filename, | ||
2938 | const struct GNUNET_FS_Uri *uri, | 2978 | const struct GNUNET_FS_Uri *uri, |
2939 | const struct GNUNET_CONTAINER_MetaData *meta, | 2979 | const struct GNUNET_CONTAINER_MetaData *meta, |
2940 | size_t length, | 2980 | size_t length, |
@@ -2948,8 +2988,8 @@ add_directory_entry (void *cls, const char *filename, | |||
2948 | struct GNUNET_FS_Uri *xuri; | 2988 | struct GNUNET_FS_Uri *xuri; |
2949 | 2989 | ||
2950 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2990 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2951 | "Adding directory entry `%s'\n", | 2991 | "Adding directory entry `%s'\n", |
2952 | filename); | 2992 | filename); |
2953 | if (NULL == uri) | 2993 | if (NULL == uri) |
2954 | { | 2994 | { |
2955 | /* directory meta data itself */ | 2995 | /* directory meta data itself */ |
@@ -2972,21 +3012,18 @@ add_directory_entry (void *cls, const char *filename, | |||
2972 | { | 3012 | { |
2973 | do | 3013 | do |
2974 | { | 3014 | { |
2975 | gtk_tree_model_get (tm, &iter, | 3015 | gtk_tree_model_get (tm, &iter, SEARCH_TAB_MC_URI, &xuri, -1); |
2976 | SEARCH_TAB_MC_URI, &xuri, | ||
2977 | -1); | ||
2978 | if (GNUNET_YES == GNUNET_FS_uri_test_equal (xuri, uri)) | 3016 | if (GNUNET_YES == GNUNET_FS_uri_test_equal (xuri, uri)) |
2979 | return; /* already present */ | 3017 | return; /* already present */ |
2980 | } | 3018 | } while (gtk_tree_model_iter_next (tm, &iter)); |
2981 | while (gtk_tree_model_iter_next (tm, | ||
2982 | &iter)); | ||
2983 | } | 3019 | } |
2984 | } | 3020 | } |
2985 | GNUNET_GTK_add_search_result (ade->tab, | 3021 | GNUNET_GTK_add_search_result (ade->tab, |
2986 | ade->anonymity, | 3022 | ade->anonymity, |
2987 | ade->prr, | 3023 | ade->prr, |
2988 | uri, | 3024 | uri, |
2989 | meta, NULL, | 3025 | meta, |
3026 | NULL, | ||
2990 | 0); | 3027 | 0); |
2991 | } | 3028 | } |
2992 | 3029 | ||
@@ -3007,8 +3044,8 @@ add_directory_entry (void *cls, const char *filename, | |||
3007 | */ | 3044 | */ |
3008 | static void | 3045 | static void |
3009 | mark_download_progress (struct DownloadEntry *de, | 3046 | mark_download_progress (struct DownloadEntry *de, |
3010 | const char *filename, | 3047 | const char *filename, |
3011 | uint64_t size, | 3048 | uint64_t size, |
3012 | uint64_t completed, | 3049 | uint64_t completed, |
3013 | const void *block_data, | 3050 | const void *block_data, |
3014 | uint64_t offset, | 3051 | uint64_t offset, |
@@ -3022,8 +3059,8 @@ mark_download_progress (struct DownloadEntry *de, | |||
3022 | struct SearchTab *tab; | 3059 | struct SearchTab *tab; |
3023 | 3060 | ||
3024 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3061 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3025 | "Marking download progress for DE=%p, %llu/%llu, %llu@%llu depth=%u\n", | 3062 | "Marking download progress for DE=%p, %llu/%llu, %llu@%llu depth=%u\n", |
3026 | de, | 3063 | de, |
3027 | (unsigned long long) completed, | 3064 | (unsigned long long) completed, |
3028 | (unsigned long long) size, | 3065 | (unsigned long long) size, |
3029 | (unsigned long long) block_size, | 3066 | (unsigned long long) block_size, |
@@ -3033,13 +3070,11 @@ mark_download_progress (struct DownloadEntry *de, | |||
3033 | while (NULL != deep->pde) | 3070 | while (NULL != deep->pde) |
3034 | deep = deep->pde; | 3071 | deep = deep->pde; |
3035 | tab = NULL; | 3072 | tab = NULL; |
3036 | if ( (NULL != deep->sr) && | 3073 | if ((NULL != deep->sr) && (NULL != (tab = deep->sr->tab))) |
3037 | (NULL != (tab = deep->sr->tab)) ) | ||
3038 | { | 3074 | { |
3039 | path = gtk_tree_row_reference_get_path (de->sr->rr); | 3075 | path = gtk_tree_row_reference_get_path (de->sr->rr); |
3040 | GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (tab->ts), | 3076 | GNUNET_assert ( |
3041 | &iter, | 3077 | gtk_tree_model_get_iter (GTK_TREE_MODEL (tab->ts), &iter, path)); |
3042 | path)); | ||
3043 | gtk_tree_path_free (path); | 3078 | gtk_tree_path_free (path); |
3044 | /* FIXME-DESIGN: should we replace the 'availability' with | 3079 | /* FIXME-DESIGN: should we replace the 'availability' with |
3045 | 'progress' once the download has started and re-use the | 3080 | 'progress' once the download has started and re-use the |
@@ -3047,25 +3082,28 @@ mark_download_progress (struct DownloadEntry *de, | |||
3047 | a custom CellRenderer... */ | 3082 | a custom CellRenderer... */ |
3048 | gtk_tree_store_set (tab->ts, | 3083 | gtk_tree_store_set (tab->ts, |
3049 | &iter, | 3084 | &iter, |
3050 | SEARCH_TAB_MC_PERCENT_PROGRESS, (guint) ((size > 0) ? (100 * completed / size) : 100), | 3085 | SEARCH_TAB_MC_PERCENT_PROGRESS, |
3051 | SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, (completed ? -1 : 0), | 3086 | (guint) ((size > 0) ? (100 * completed / size) : 100), |
3052 | SEARCH_TAB_MC_COMPLETED, completed, | 3087 | SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, |
3088 | (completed ? -1 : 0), | ||
3089 | SEARCH_TAB_MC_COMPLETED, | ||
3090 | completed, | ||
3053 | -1); | 3091 | -1); |
3054 | } | 3092 | } |
3055 | get_download_list_entry (de, | 3093 | get_download_list_entry (de, &diter); |
3056 | &diter); | ||
3057 | gtk_tree_store_set (downloads_treestore, | 3094 | gtk_tree_store_set (downloads_treestore, |
3058 | &diter, | 3095 | &diter, |
3059 | SEARCH_TAB_MC_PERCENT_PROGRESS, (guint) ((size > 0) ? (100 * completed / size) : 100), | 3096 | SEARCH_TAB_MC_PERCENT_PROGRESS, |
3060 | SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, (completed ? -1 : 0), | 3097 | (guint) ((size > 0) ? (100 * completed / size) : 100), |
3061 | SEARCH_TAB_MC_COMPLETED, completed, | 3098 | SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, |
3099 | (completed ? -1 : 0), | ||
3100 | SEARCH_TAB_MC_COMPLETED, | ||
3101 | completed, | ||
3062 | -1); | 3102 | -1); |
3063 | if (completed < size) | 3103 | if (completed < size) |
3064 | { | 3104 | { |
3065 | /* partial completion, consider looking at the block */ | 3105 | /* partial completion, consider looking at the block */ |
3066 | if ( (depth == 0) && | 3106 | if ((depth == 0) && (block_size > 0) && (GNUNET_YES == de->is_directory)) |
3067 | (block_size > 0) && | ||
3068 | (GNUNET_YES == de->is_directory) ) | ||
3069 | { | 3107 | { |
3070 | /* got a data block of a directory, list its contents */ | 3108 | /* got a data block of a directory, list its contents */ |
3071 | struct AddDirectoryEntryContext ade; | 3109 | struct AddDirectoryEntryContext ade; |
@@ -3075,31 +3113,28 @@ mark_download_progress (struct DownloadEntry *de, | |||
3075 | ade.check_duplicates = GNUNET_NO; | 3113 | ade.check_duplicates = GNUNET_NO; |
3076 | ade.anonymity = de->anonymity; | 3114 | ade.anonymity = de->anonymity; |
3077 | if (GNUNET_SYSERR == | 3115 | if (GNUNET_SYSERR == |
3078 | GNUNET_FS_directory_list_contents ((size_t) block_size, | 3116 | GNUNET_FS_directory_list_contents ((size_t) block_size, |
3079 | block_data, | 3117 | block_data, |
3080 | offset, | 3118 | offset, |
3081 | &add_directory_entry, | 3119 | &add_directory_entry, |
3082 | &ade)) | 3120 | &ade)) |
3083 | { | 3121 | { |
3084 | /* Mime type was wrong, this is not a directory, update model! */ | 3122 | /* Mime type was wrong, this is not a directory, update model! */ |
3085 | de->is_directory = GNUNET_SYSERR; | 3123 | de->is_directory = GNUNET_SYSERR; |
3086 | if (NULL != tab) | 3124 | if (NULL != tab) |
3087 | gtk_tree_store_set (tab->ts, | 3125 | gtk_tree_store_set (tab->ts, &iter, SEARCH_TAB_MC_MIMETYPE, "", -1); |
3088 | &iter, | ||
3089 | SEARCH_TAB_MC_MIMETYPE, "", | ||
3090 | -1); | ||
3091 | gtk_tree_store_set (downloads_treestore, | 3126 | gtk_tree_store_set (downloads_treestore, |
3092 | &diter, | 3127 | &diter, |
3093 | SEARCH_TAB_MC_MIMETYPE, "", | 3128 | SEARCH_TAB_MC_MIMETYPE, |
3094 | -1); | 3129 | "", |
3130 | -1); | ||
3095 | } | 3131 | } |
3096 | } | 3132 | } |
3097 | } | 3133 | } |
3098 | else | 3134 | else |
3099 | { | 3135 | { |
3100 | /* full completion, look at the entire file */ | 3136 | /* full completion, look at the entire file */ |
3101 | if ( (GNUNET_YES == de->is_directory) && | 3137 | if ((GNUNET_YES == de->is_directory) && (filename != NULL)) |
3102 | (filename != NULL) ) | ||
3103 | { | 3138 | { |
3104 | struct AddDirectoryEntryContext ade; | 3139 | struct AddDirectoryEntryContext ade; |
3105 | 3140 | ||
@@ -3109,10 +3144,8 @@ mark_download_progress (struct DownloadEntry *de, | |||
3109 | ade.prr = de->sr->rr; | 3144 | ade.prr = de->sr->rr; |
3110 | ade.check_duplicates = GNUNET_YES; | 3145 | ade.check_duplicates = GNUNET_YES; |
3111 | if (GNUNET_OK != | 3146 | if (GNUNET_OK != |
3112 | GNUNET_FS_GTK_mmap_and_scan (filename, | 3147 | GNUNET_FS_GTK_mmap_and_scan (filename, &add_directory_entry, &ade)) |
3113 | &add_directory_entry, | 3148 | de->is_directory = GNUNET_NO; |
3114 | &ade)) | ||
3115 | de->is_directory = GNUNET_NO; | ||
3116 | } | 3149 | } |
3117 | } | 3150 | } |
3118 | } | 3151 | } |
@@ -3126,8 +3159,7 @@ mark_download_progress (struct DownloadEntry *de, | |||
3126 | * @param emsg error message to display | 3159 | * @param emsg error message to display |
3127 | */ | 3160 | */ |
3128 | static void | 3161 | static void |
3129 | mark_download_error (struct DownloadEntry *de, | 3162 | mark_download_error (struct DownloadEntry *de, const char *emsg) |
3130 | const char *emsg) | ||
3131 | { | 3163 | { |
3132 | GtkTreeIter iter; | 3164 | GtkTreeIter iter; |
3133 | GtkTreePath *path; | 3165 | GtkTreePath *path; |
@@ -3142,26 +3174,32 @@ mark_download_error (struct DownloadEntry *de, | |||
3142 | while (NULL != deep->pde) | 3174 | while (NULL != deep->pde) |
3143 | deep = deep->pde; | 3175 | deep = deep->pde; |
3144 | tab = NULL; | 3176 | tab = NULL; |
3145 | if ( (NULL != deep->sr) && | 3177 | if ((NULL != deep->sr) && (NULL != (tab = deep->sr->tab))) |
3146 | (NULL != (tab = deep->sr->tab)) ) | ||
3147 | { | 3178 | { |
3148 | path = gtk_tree_row_reference_get_path (de->sr->rr); | 3179 | path = gtk_tree_row_reference_get_path (de->sr->rr); |
3149 | GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (tab->ts), | 3180 | GNUNET_assert ( |
3150 | &iter, | 3181 | gtk_tree_model_get_iter (GTK_TREE_MODEL (tab->ts), &iter, path)); |
3151 | path)); | ||
3152 | gtk_tree_path_free (path); | 3182 | gtk_tree_path_free (path); |
3153 | gtk_tree_store_set (tab->ts, | 3183 | gtk_tree_store_set (tab->ts, |
3154 | &iter, | 3184 | &iter, |
3155 | SEARCH_TAB_MC_PERCENT_PROGRESS, (guint) 0, | 3185 | SEARCH_TAB_MC_PERCENT_PROGRESS, |
3156 | SEARCH_TAB_MC_URI_AS_STRING, emsg, | 3186 | (guint) 0, |
3157 | SEARCH_TAB_MC_STATUS_ICON, GNUNET_GTK_animation_context_get_pixbuf (animation_error), | 3187 | SEARCH_TAB_MC_URI_AS_STRING, |
3188 | emsg, | ||
3189 | SEARCH_TAB_MC_STATUS_ICON, | ||
3190 | GNUNET_GTK_animation_context_get_pixbuf ( | ||
3191 | animation_error), | ||
3158 | -1); | 3192 | -1); |
3159 | } | 3193 | } |
3160 | get_download_list_entry (de, &iter); | 3194 | get_download_list_entry (de, &iter); |
3161 | gtk_tree_store_set (downloads_treestore, &iter, | 3195 | gtk_tree_store_set (downloads_treestore, |
3162 | SEARCH_TAB_MC_PERCENT_PROGRESS, (guint) 0, | 3196 | &iter, |
3163 | SEARCH_TAB_MC_URI_AS_STRING, emsg, | 3197 | SEARCH_TAB_MC_PERCENT_PROGRESS, |
3164 | SEARCH_TAB_MC_STATUS_ICON, GNUNET_GTK_animation_context_get_pixbuf (animation_error), | 3198 | (guint) 0, |
3199 | SEARCH_TAB_MC_URI_AS_STRING, | ||
3200 | emsg, | ||
3201 | SEARCH_TAB_MC_STATUS_ICON, | ||
3202 | GNUNET_GTK_animation_context_get_pixbuf (animation_error), | ||
3165 | -1); | 3203 | -1); |
3166 | } | 3204 | } |
3167 | 3205 | ||
@@ -3174,8 +3212,7 @@ mark_download_error (struct DownloadEntry *de, | |||
3174 | * @param size overall size of the file | 3212 | * @param size overall size of the file |
3175 | */ | 3213 | */ |
3176 | static void | 3214 | static void |
3177 | mark_download_completed (struct DownloadEntry *de, | 3215 | mark_download_completed (struct DownloadEntry *de, uint64_t size) |
3178 | uint64_t size) | ||
3179 | { | 3216 | { |
3180 | GtkTreeIter iter; | 3217 | GtkTreeIter iter; |
3181 | GtkTreePath *path; | 3218 | GtkTreePath *path; |
@@ -3189,30 +3226,37 @@ mark_download_completed (struct DownloadEntry *de, | |||
3189 | while (NULL != deep->pde) | 3226 | while (NULL != deep->pde) |
3190 | deep = deep->pde; | 3227 | deep = deep->pde; |
3191 | tab = NULL; | 3228 | tab = NULL; |
3192 | if ( (NULL != deep->sr) && | 3229 | if ((NULL != deep->sr) && (NULL != (tab = deep->sr->tab))) |
3193 | (NULL != (tab = deep->sr->tab)) ) | ||
3194 | { | 3230 | { |
3195 | path = gtk_tree_row_reference_get_path (de->sr->rr); | 3231 | path = gtk_tree_row_reference_get_path (de->sr->rr); |
3196 | GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (tab->ts), | 3232 | GNUNET_assert ( |
3197 | &iter, | 3233 | gtk_tree_model_get_iter (GTK_TREE_MODEL (tab->ts), &iter, path)); |
3198 | path)); | ||
3199 | gtk_tree_path_free (path); | 3234 | gtk_tree_path_free (path); |
3200 | gtk_tree_store_set (tab->ts, | 3235 | gtk_tree_store_set (tab->ts, |
3201 | &iter, | 3236 | &iter, |
3202 | SEARCH_TAB_MC_PERCENT_PROGRESS, (guint) 100, | 3237 | SEARCH_TAB_MC_PERCENT_PROGRESS, |
3203 | SEARCH_TAB_MC_PERCENT_AVAILABILITY, (guint) 100, | 3238 | (guint) 100, |
3204 | SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, -1, | 3239 | SEARCH_TAB_MC_PERCENT_AVAILABILITY, |
3205 | SEARCH_TAB_MC_STATUS_ICON, GNUNET_GTK_animation_context_get_pixbuf (animation_downloaded), | 3240 | (guint) 100, |
3241 | SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, | ||
3242 | -1, | ||
3243 | SEARCH_TAB_MC_STATUS_ICON, | ||
3244 | GNUNET_GTK_animation_context_get_pixbuf ( | ||
3245 | animation_downloaded), | ||
3206 | -1); | 3246 | -1); |
3207 | } | 3247 | } |
3208 | get_download_list_entry (de, | 3248 | get_download_list_entry (de, &iter); |
3209 | &iter); | ||
3210 | gtk_tree_store_set (downloads_treestore, | 3249 | gtk_tree_store_set (downloads_treestore, |
3211 | &iter, | 3250 | &iter, |
3212 | SEARCH_TAB_MC_PERCENT_PROGRESS, (guint) 100, | 3251 | SEARCH_TAB_MC_PERCENT_PROGRESS, |
3213 | SEARCH_TAB_MC_PERCENT_AVAILABILITY, (guint) 100, | 3252 | (guint) 100, |
3214 | SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, -1, | 3253 | SEARCH_TAB_MC_PERCENT_AVAILABILITY, |
3215 | SEARCH_TAB_MC_STATUS_ICON, GNUNET_GTK_animation_context_get_pixbuf (animation_downloaded), | 3254 | (guint) 100, |
3255 | SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, | ||
3256 | -1, | ||
3257 | SEARCH_TAB_MC_STATUS_ICON, | ||
3258 | GNUNET_GTK_animation_context_get_pixbuf ( | ||
3259 | animation_downloaded), | ||
3216 | -1); | 3260 | -1); |
3217 | } | 3261 | } |
3218 | 3262 | ||
@@ -3236,8 +3280,8 @@ static struct DownloadEntry * | |||
3236 | setup_download (struct DownloadEntry *de, | 3280 | setup_download (struct DownloadEntry *de, |
3237 | struct DownloadEntry *pde, | 3281 | struct DownloadEntry *pde, |
3238 | struct SearchResult *sr, | 3282 | struct SearchResult *sr, |
3239 | uint32_t anonymity, | 3283 | uint32_t anonymity, |
3240 | struct GNUNET_FS_DownloadContext *dc, | 3284 | struct GNUNET_FS_DownloadContext *dc, |
3241 | const struct GNUNET_FS_Uri *uri, | 3285 | const struct GNUNET_FS_Uri *uri, |
3242 | const char *filename, | 3286 | const char *filename, |
3243 | const struct GNUNET_CONTAINER_MetaData *meta, | 3287 | const struct GNUNET_CONTAINER_MetaData *meta, |
@@ -3249,15 +3293,16 @@ setup_download (struct DownloadEntry *de, | |||
3249 | GtkTreeModel *tm; | 3293 | GtkTreeModel *tm; |
3250 | struct DownloadEntry *deep; | 3294 | struct DownloadEntry *deep; |
3251 | 3295 | ||
3252 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3296 | GNUNET_log ( |
3253 | "Setting up download, initially DE=%p, PDE=%p for %p & %p into %llu/%llu `%s'\n", | 3297 | GNUNET_ERROR_TYPE_DEBUG, |
3254 | de, | 3298 | "Setting up download, initially DE=%p, PDE=%p for %p & %p into %llu/%llu `%s'\n", |
3255 | pde, | 3299 | de, |
3256 | sr, | 3300 | pde, |
3257 | dc, | 3301 | sr, |
3258 | (unsigned long long) completed, | 3302 | dc, |
3259 | (unsigned long long) size, | 3303 | (unsigned long long) completed, |
3260 | filename); | 3304 | (unsigned long long) size, |
3305 | filename); | ||
3261 | GNUNET_assert (NULL != uri); | 3306 | GNUNET_assert (NULL != uri); |
3262 | if (NULL == de) | 3307 | if (NULL == de) |
3263 | { | 3308 | { |
@@ -3288,9 +3333,7 @@ setup_download (struct DownloadEntry *de, | |||
3288 | deep = de; | 3333 | deep = de; |
3289 | while (NULL != deep->pde) | 3334 | while (NULL != deep->pde) |
3290 | deep = deep->pde; | 3335 | deep = deep->pde; |
3291 | if ( (NULL == de->sr) && | 3336 | if ((NULL == de->sr) && (NULL != pde) && (NULL != deep->sr->tab)) |
3292 | (NULL != pde) && | ||
3293 | (NULL != deep->sr->tab) ) | ||
3294 | { | 3337 | { |
3295 | /* child download, find appropriate search result from parent! */ | 3338 | /* child download, find appropriate search result from parent! */ |
3296 | GtkTreePath *path; | 3339 | GtkTreePath *path; |
@@ -3301,8 +3344,8 @@ setup_download (struct DownloadEntry *de, | |||
3301 | 3344 | ||
3302 | tm = GTK_TREE_MODEL (deep->sr->tab->ts); | 3345 | tm = GTK_TREE_MODEL (deep->sr->tab->ts); |
3303 | path = gtk_tree_row_reference_get_path (pde->sr->rr); | 3346 | path = gtk_tree_row_reference_get_path (pde->sr->rr); |
3304 | if ( (! gtk_tree_model_get_iter (tm, &iter, path)) || | 3347 | if ((! gtk_tree_model_get_iter (tm, &iter, path)) || |
3305 | (! gtk_tree_model_iter_children (tm, &child, &iter)) ) | 3348 | (! gtk_tree_model_iter_children (tm, &child, &iter))) |
3306 | { | 3349 | { |
3307 | GNUNET_break (0); | 3350 | GNUNET_break (0); |
3308 | } | 3351 | } |
@@ -3310,24 +3353,25 @@ setup_download (struct DownloadEntry *de, | |||
3310 | { | 3353 | { |
3311 | do | 3354 | do |
3312 | { | 3355 | { |
3313 | gtk_tree_model_get (tm, &child, | 3356 | gtk_tree_model_get (tm, |
3314 | SEARCH_TAB_MC_URI, &uri, | 3357 | &child, |
3315 | SEARCH_TAB_MC_SEARCH_RESULT, &de->sr, | 3358 | SEARCH_TAB_MC_URI, |
3359 | &uri, | ||
3360 | SEARCH_TAB_MC_SEARCH_RESULT, | ||
3361 | &de->sr, | ||
3316 | -1); | 3362 | -1); |
3317 | if (GNUNET_YES == GNUNET_FS_uri_test_equal (de->uri, | 3363 | if (GNUNET_YES == GNUNET_FS_uri_test_equal (de->uri, uri)) |
3318 | uri)) | 3364 | break; |
3319 | break; | 3365 | de->sr = NULL; |
3320 | de->sr = NULL; | 3366 | } while (gtk_tree_model_iter_next (tm, &child)); |
3321 | } | ||
3322 | while (gtk_tree_model_iter_next (tm, &child)); | ||
3323 | if (NULL == de->sr) | 3367 | if (NULL == de->sr) |
3324 | { | 3368 | { |
3325 | /* child not found, what's going on!? */ | 3369 | /* child not found, what's going on!? */ |
3326 | GNUNET_break (0); | 3370 | GNUNET_break (0); |
3327 | } | 3371 | } |
3328 | else | 3372 | else |
3329 | { | 3373 | { |
3330 | de->sr->download = de; | 3374 | de->sr->download = de; |
3331 | } | 3375 | } |
3332 | } | 3376 | } |
3333 | gtk_tree_path_free (path); | 3377 | gtk_tree_path_free (path); |
@@ -3337,22 +3381,15 @@ setup_download (struct DownloadEntry *de, | |||
3337 | /* Stand-alone download with no 'row'/search result affiliated | 3381 | /* Stand-alone download with no 'row'/search result affiliated |
3338 | with the download so far; create a fresh entry for this | 3382 | with the download so far; create a fresh entry for this |
3339 | download */ | 3383 | download */ |
3340 | de->sr = GNUNET_GTK_add_search_result (NULL, | 3384 | de->sr = |
3341 | anonymity, | 3385 | GNUNET_GTK_add_search_result (NULL, anonymity, NULL, uri, meta, NULL, 0); |
3342 | NULL, | ||
3343 | uri, | ||
3344 | meta, | ||
3345 | NULL, 0); | ||
3346 | GNUNET_FS_probe_stop (de->sr->probe); | 3386 | GNUNET_FS_probe_stop (de->sr->probe); |
3347 | de->sr->probe = NULL; | 3387 | de->sr->probe = NULL; |
3348 | GNUNET_CONTAINER_DLL_remove (pl_head, | 3388 | GNUNET_CONTAINER_DLL_remove (pl_head, pl_tail, de->sr); |
3349 | pl_tail, | ||
3350 | de->sr); | ||
3351 | de->sr->download = de; | 3389 | de->sr->download = de; |
3352 | path = gtk_tree_row_reference_get_path (de->sr->rr); | 3390 | path = gtk_tree_row_reference_get_path (de->sr->rr); |
3353 | tm = gtk_tree_row_reference_get_model (de->sr->rr); | 3391 | tm = gtk_tree_row_reference_get_model (de->sr->rr); |
3354 | if (! gtk_tree_model_get_iter (tm, | 3392 | if (! gtk_tree_model_get_iter (tm, &iter, path)) |
3355 | &iter, path)) | ||
3356 | { | 3393 | { |
3357 | GNUNET_break (0); | 3394 | GNUNET_break (0); |
3358 | gtk_tree_path_free (path); | 3395 | gtk_tree_path_free (path); |
@@ -3363,7 +3400,7 @@ setup_download (struct DownloadEntry *de, | |||
3363 | { | 3400 | { |
3364 | struct GNUNET_CONTAINER_MetaData *meta; | 3401 | struct GNUNET_CONTAINER_MetaData *meta; |
3365 | 3402 | ||
3366 | /* get metadata from existing tab, might have a mime type */ | 3403 | /* get metadata from existing tab, might have a mime type */ |
3367 | path = gtk_tree_row_reference_get_path (de->sr->rr); | 3404 | path = gtk_tree_row_reference_get_path (de->sr->rr); |
3368 | tm = gtk_tree_row_reference_get_model (de->sr->rr); | 3405 | tm = gtk_tree_row_reference_get_model (de->sr->rr); |
3369 | if (! gtk_tree_model_get_iter (tm, &iter, path)) | 3406 | if (! gtk_tree_model_get_iter (tm, &iter, path)) |
@@ -3372,47 +3409,65 @@ setup_download (struct DownloadEntry *de, | |||
3372 | gtk_tree_path_free (path); | 3409 | gtk_tree_path_free (path); |
3373 | return de; | 3410 | return de; |
3374 | } | 3411 | } |
3375 | gtk_tree_model_get (tm, &iter, | 3412 | gtk_tree_model_get (tm, &iter, SEARCH_TAB_MC_METADATA, &meta, -1); |
3376 | SEARCH_TAB_MC_METADATA, &meta, | ||
3377 | -1); | ||
3378 | de->is_directory = GNUNET_FS_meta_data_test_for_directory (meta); | 3413 | de->is_directory = GNUNET_FS_meta_data_test_for_directory (meta); |
3379 | } | 3414 | } |
3380 | if (NULL == de->rr) | 3415 | if (NULL == de->rr) |
3381 | setup_download_list_entry (de, pde, de->sr); | 3416 | setup_download_list_entry (de, pde, de->sr); |
3382 | gtk_tree_path_free (path); | 3417 | gtk_tree_path_free (path); |
3383 | gtk_tree_store_set (GTK_TREE_STORE (tm), &iter, | 3418 | gtk_tree_store_set (GTK_TREE_STORE (tm), |
3384 | SEARCH_TAB_MC_PERCENT_PROGRESS, (guint) ((size > 0) ? (100 * completed / size) : 100), | 3419 | &iter, |
3385 | SEARCH_TAB_MC_FILENAME, filename, | 3420 | SEARCH_TAB_MC_PERCENT_PROGRESS, |
3386 | SEARCH_TAB_MC_STATUS_COLOUR, "blue", | 3421 | (guint) ((size > 0) ? (100 * completed / size) : 100), |
3387 | SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, -1, | 3422 | SEARCH_TAB_MC_FILENAME, |
3388 | SEARCH_TAB_MC_SEARCH_RESULT, de->sr, | 3423 | filename, |
3389 | SEARCH_TAB_MC_COMPLETED, (guint64) completed, | 3424 | SEARCH_TAB_MC_STATUS_COLOUR, |
3390 | SEARCH_TAB_MC_DOWNLOADED_FILENAME, de->filename, | 3425 | "blue", |
3391 | SEARCH_TAB_MC_DOWNLOADED_ANONYMITY, de->anonymity, | 3426 | SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, |
3392 | SEARCH_TAB_MC_STATUS_ICON, GNUNET_GTK_animation_context_get_pixbuf (animation_download_stalled), | 3427 | -1, |
3428 | SEARCH_TAB_MC_SEARCH_RESULT, | ||
3429 | de->sr, | ||
3430 | SEARCH_TAB_MC_COMPLETED, | ||
3431 | (guint64) completed, | ||
3432 | SEARCH_TAB_MC_DOWNLOADED_FILENAME, | ||
3433 | de->filename, | ||
3434 | SEARCH_TAB_MC_DOWNLOADED_ANONYMITY, | ||
3435 | de->anonymity, | ||
3436 | SEARCH_TAB_MC_STATUS_ICON, | ||
3437 | GNUNET_GTK_animation_context_get_pixbuf ( | ||
3438 | animation_download_stalled), | ||
3393 | -1); | 3439 | -1); |
3394 | /* also update downloads tab */ | 3440 | /* also update downloads tab */ |
3395 | get_download_list_entry (de, &iter); | 3441 | get_download_list_entry (de, &iter); |
3396 | gtk_tree_store_set (downloads_treestore, &iter, | 3442 | gtk_tree_store_set (downloads_treestore, |
3397 | SEARCH_TAB_MC_PERCENT_PROGRESS, (guint) ((size > 0) ? (100 * completed / size) : 100), | 3443 | &iter, |
3398 | SEARCH_TAB_MC_FILENAME, filename, | 3444 | SEARCH_TAB_MC_PERCENT_PROGRESS, |
3399 | SEARCH_TAB_MC_STATUS_COLOUR, "blue", | 3445 | (guint) ((size > 0) ? (100 * completed / size) : 100), |
3400 | SEARCH_TAB_MC_SEARCH_RESULT, de->sr, | 3446 | SEARCH_TAB_MC_FILENAME, |
3401 | SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, -1, | 3447 | filename, |
3402 | SEARCH_TAB_MC_COMPLETED, (guint64) completed, | 3448 | SEARCH_TAB_MC_STATUS_COLOUR, |
3403 | SEARCH_TAB_MC_DOWNLOADED_FILENAME, de->filename, | 3449 | "blue", |
3404 | SEARCH_TAB_MC_DOWNLOADED_ANONYMITY, de->anonymity, | 3450 | SEARCH_TAB_MC_SEARCH_RESULT, |
3405 | SEARCH_TAB_MC_STATUS_ICON, GNUNET_GTK_animation_context_get_pixbuf (animation_download_stalled), | 3451 | de->sr, |
3452 | SEARCH_TAB_MC_UNKNOWN_AVAILABILITY, | ||
3453 | -1, | ||
3454 | SEARCH_TAB_MC_COMPLETED, | ||
3455 | (guint64) completed, | ||
3456 | SEARCH_TAB_MC_DOWNLOADED_FILENAME, | ||
3457 | de->filename, | ||
3458 | SEARCH_TAB_MC_DOWNLOADED_ANONYMITY, | ||
3459 | de->anonymity, | ||
3460 | SEARCH_TAB_MC_STATUS_ICON, | ||
3461 | GNUNET_GTK_animation_context_get_pixbuf ( | ||
3462 | animation_download_stalled), | ||
3406 | -1); | 3463 | -1); |
3407 | return de; | 3464 | return de; |
3408 | } | 3465 | } |
3409 | 3466 | ||
3410 | 3467 | ||
3411 | |||
3412 | /* ***************** Publish event handling ****************** */ | 3468 | /* ***************** Publish event handling ****************** */ |
3413 | 3469 | ||
3414 | 3470 | ||
3415 | |||
3416 | /** | 3471 | /** |
3417 | * Change the (background) color of the given publish entry. | 3472 | * Change the (background) color of the given publish entry. |
3418 | * | 3473 | * |
@@ -3420,15 +3475,15 @@ setup_download (struct DownloadEntry *de, | |||
3420 | * @param color name of the color to use | 3475 | * @param color name of the color to use |
3421 | */ | 3476 | */ |
3422 | static void | 3477 | static void |
3423 | change_publish_color (struct PublishEntry *pe, | 3478 | change_publish_color (struct PublishEntry *pe, const char *color) |
3424 | const char *color) | ||
3425 | { | 3479 | { |
3426 | GtkTreeIter iter; | 3480 | GtkTreeIter iter; |
3427 | GtkTreePath *path; | 3481 | GtkTreePath *path; |
3428 | 3482 | ||
3429 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3483 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3430 | "Changing publish PE=%p color to %s\n", | 3484 | "Changing publish PE=%p color to %s\n", |
3431 | pe, color); | 3485 | pe, |
3486 | color); | ||
3432 | path = gtk_tree_row_reference_get_path (pe->rr); | 3487 | path = gtk_tree_row_reference_get_path (pe->rr); |
3433 | if (! gtk_tree_model_get_iter (GTK_TREE_MODEL (pe->tab->ts), &iter, path)) | 3488 | if (! gtk_tree_model_get_iter (GTK_TREE_MODEL (pe->tab->ts), &iter, path)) |
3434 | { | 3489 | { |
@@ -3437,9 +3492,7 @@ change_publish_color (struct PublishEntry *pe, | |||
3437 | return; | 3492 | return; |
3438 | } | 3493 | } |
3439 | gtk_tree_path_free (path); | 3494 | gtk_tree_path_free (path); |
3440 | gtk_tree_store_set (pe->tab->ts, &iter, | 3495 | gtk_tree_store_set (pe->tab->ts, &iter, PUBLISH_TAB_MC_BGCOLOUR, color, -1); |
3441 | PUBLISH_TAB_MC_BGCOLOUR, color, | ||
3442 | -1); | ||
3443 | } | 3496 | } |
3444 | 3497 | ||
3445 | 3498 | ||
@@ -3452,7 +3505,8 @@ change_publish_color (struct PublishEntry *pe, | |||
3452 | * @param completed number of bytes we have completed | 3505 | * @param completed number of bytes we have completed |
3453 | */ | 3506 | */ |
3454 | static void | 3507 | static void |
3455 | mark_publish_progress (struct PublishEntry *pe, uint64_t size, | 3508 | mark_publish_progress (struct PublishEntry *pe, |
3509 | uint64_t size, | ||
3456 | uint64_t completed) | 3510 | uint64_t completed) |
3457 | { | 3511 | { |
3458 | GtkTreeIter iter; | 3512 | GtkTreeIter iter; |
@@ -3466,8 +3520,10 @@ mark_publish_progress (struct PublishEntry *pe, uint64_t size, | |||
3466 | return; | 3520 | return; |
3467 | } | 3521 | } |
3468 | gtk_tree_path_free (path); | 3522 | gtk_tree_path_free (path); |
3469 | gtk_tree_store_set (pe->tab->ts, &iter, | 3523 | gtk_tree_store_set (pe->tab->ts, |
3470 | PUBLISH_TAB_MC_PROGRESS, (guint) ((size > 0) ? (100 * completed / size) : 100), | 3524 | &iter, |
3525 | PUBLISH_TAB_MC_PROGRESS, | ||
3526 | (guint) ((size > 0) ? (100 * completed / size) : 100), | ||
3471 | -1); | 3527 | -1); |
3472 | } | 3528 | } |
3473 | 3529 | ||
@@ -3497,10 +3553,15 @@ handle_publish_completed (struct PublishEntry *pe, | |||
3497 | gtk_tree_path_free (path); | 3553 | gtk_tree_path_free (path); |
3498 | pe->uri = GNUNET_FS_uri_dup (uri); | 3554 | pe->uri = GNUNET_FS_uri_dup (uri); |
3499 | uris = GNUNET_FS_uri_to_string (uri); | 3555 | uris = GNUNET_FS_uri_to_string (uri); |
3500 | gtk_tree_store_set (pe->tab->ts, &iter, | 3556 | gtk_tree_store_set (pe->tab->ts, |
3501 | PUBLISH_TAB_MC_RESULT_STRING, uris, | 3557 | &iter, |
3502 | PUBLISH_TAB_MC_PROGRESS, 100, | 3558 | PUBLISH_TAB_MC_RESULT_STRING, |
3503 | PUBLISH_TAB_MC_STATUS_ICON, GNUNET_GTK_animation_context_get_pixbuf (animation_published), | 3559 | uris, |
3560 | PUBLISH_TAB_MC_PROGRESS, | ||
3561 | 100, | ||
3562 | PUBLISH_TAB_MC_STATUS_ICON, | ||
3563 | GNUNET_GTK_animation_context_get_pixbuf ( | ||
3564 | animation_published), | ||
3504 | -1); | 3565 | -1); |
3505 | GNUNET_free (uris); | 3566 | GNUNET_free (uris); |
3506 | change_publish_color (pe, "green"); | 3567 | change_publish_color (pe, "green"); |
@@ -3515,8 +3576,7 @@ handle_publish_completed (struct PublishEntry *pe, | |||
3515 | * @param emsg the error message | 3576 | * @param emsg the error message |
3516 | */ | 3577 | */ |
3517 | static void | 3578 | static void |
3518 | handle_publish_error (struct PublishEntry *pe, | 3579 | handle_publish_error (struct PublishEntry *pe, const char *emsg) |
3519 | const char *emsg) | ||
3520 | { | 3580 | { |
3521 | GtkTreeIter iter; | 3581 | GtkTreeIter iter; |
3522 | GtkTreePath *path; | 3582 | GtkTreePath *path; |
@@ -3531,10 +3591,14 @@ handle_publish_error (struct PublishEntry *pe, | |||
3531 | gtk_tree_path_free (path); | 3591 | gtk_tree_path_free (path); |
3532 | if (NULL == animation_error) | 3592 | if (NULL == animation_error) |
3533 | animation_error = load_animation ("error"); | 3593 | animation_error = load_animation ("error"); |
3534 | gtk_tree_store_set (pe->tab->ts, &iter, | 3594 | gtk_tree_store_set (pe->tab->ts, |
3535 | PUBLISH_TAB_MC_RESULT_STRING, emsg, | 3595 | &iter, |
3536 | PUBLISH_TAB_MC_PROGRESS, 100, | 3596 | PUBLISH_TAB_MC_RESULT_STRING, |
3537 | PUBLISH_TAB_MC_STATUS_ICON, GNUNET_GTK_animation_context_get_pixbuf (animation_error), | 3597 | emsg, |
3598 | PUBLISH_TAB_MC_PROGRESS, | ||
3599 | 100, | ||
3600 | PUBLISH_TAB_MC_STATUS_ICON, | ||
3601 | GNUNET_GTK_animation_context_get_pixbuf (animation_error), | ||
3538 | -1); | 3602 | -1); |
3539 | change_publish_color (pe, "red"); | 3603 | change_publish_color (pe, "red"); |
3540 | } | 3604 | } |
@@ -3594,8 +3658,7 @@ handle_publish_stop (struct PublishEntry *pe) | |||
3594 | GNUNET_break (0); | 3658 | GNUNET_break (0); |
3595 | return; | 3659 | return; |
3596 | } | 3660 | } |
3597 | (void) gtk_tree_store_remove (pe->tab->ts, | 3661 | (void) gtk_tree_store_remove (pe->tab->ts, &iter); |
3598 | &iter); | ||
3599 | gtk_tree_path_free (path); | 3662 | gtk_tree_path_free (path); |
3600 | gtk_tree_row_reference_free (pe->rr); | 3663 | gtk_tree_row_reference_free (pe->rr); |
3601 | if (NULL != pe->uri) | 3664 | if (NULL != pe->uri) |
@@ -3603,7 +3666,9 @@ handle_publish_stop (struct PublishEntry *pe) | |||
3603 | GNUNET_FS_uri_destroy (pe->uri); | 3666 | GNUNET_FS_uri_destroy (pe->uri); |
3604 | pe->uri = NULL; | 3667 | pe->uri = NULL; |
3605 | } | 3668 | } |
3606 | if (! gtk_tree_model_iter_children (GTK_TREE_MODEL (pe->tab->ts), &iter, NULL)) | 3669 | if (! gtk_tree_model_iter_children (GTK_TREE_MODEL (pe->tab->ts), |
3670 | &iter, | ||
3671 | NULL)) | ||
3607 | delete_publish_tab (); | 3672 | delete_publish_tab (); |
3608 | GNUNET_free (pe); | 3673 | GNUNET_free (pe); |
3609 | } | 3674 | } |
@@ -3617,8 +3682,8 @@ handle_publish_stop (struct PublishEntry *pe) | |||
3617 | * @param user_data the 'struct PublishTab' that is being closed | 3682 | * @param user_data the 'struct PublishTab' that is being closed |
3618 | */ | 3683 | */ |
3619 | void | 3684 | void |
3620 | GNUNET_FS_GTK_publish_label_close_button_clicked (GtkButton * button, | 3685 | GNUNET_FS_GTK_publish_label_close_button_clicked (GtkButton *button, |
3621 | gpointer user_data) | 3686 | gpointer user_data) |
3622 | { | 3687 | { |
3623 | struct PublishTab *tab = user_data; | 3688 | struct PublishTab *tab = user_data; |
3624 | struct PublishEntry *pe; | 3689 | struct PublishEntry *pe; |
@@ -3630,9 +3695,7 @@ GNUNET_FS_GTK_publish_label_close_button_clicked (GtkButton * button, | |||
3630 | tm = GTK_TREE_MODEL (publish_tab->ts); | 3695 | tm = GTK_TREE_MODEL (publish_tab->ts); |
3631 | while (gtk_tree_model_iter_children (tm, &iter, NULL)) | 3696 | while (gtk_tree_model_iter_children (tm, &iter, NULL)) |
3632 | { | 3697 | { |
3633 | gtk_tree_model_get (tm, &iter, | 3698 | gtk_tree_model_get (tm, &iter, PUBLISH_TAB_MC_ENT, &pe, -1); |
3634 | PUBLISH_TAB_MC_ENT, &pe, | ||
3635 | -1); | ||
3636 | GNUNET_FS_publish_stop (pe->pc); | 3699 | GNUNET_FS_publish_stop (pe->pc); |
3637 | } | 3700 | } |
3638 | clear_metadata_display (); | 3701 | clear_metadata_display (); |
@@ -3651,8 +3714,10 @@ GNUNET_FS_GTK_publish_label_close_button_clicked (GtkButton * button, | |||
3651 | * @return the publishing entry that will represent this operation | 3714 | * @return the publishing entry that will represent this operation |
3652 | */ | 3715 | */ |
3653 | static struct PublishEntry * | 3716 | static struct PublishEntry * |
3654 | setup_publish (struct GNUNET_FS_PublishContext *pc, const char *fn, | 3717 | setup_publish (struct GNUNET_FS_PublishContext *pc, |
3655 | uint64_t fsize, struct PublishEntry *parent) | 3718 | const char *fn, |
3719 | uint64_t fsize, | ||
3720 | struct PublishEntry *parent) | ||
3656 | { | 3721 | { |
3657 | struct PublishEntry *ent; | 3722 | struct PublishEntry *ent; |
3658 | GtkTreeIter *pitrptr; | 3723 | GtkTreeIter *pitrptr; |
@@ -3672,37 +3737,36 @@ setup_publish (struct GNUNET_FS_PublishContext *pc, const char *fn, | |||
3672 | publish_tab = GNUNET_new (struct PublishTab); | 3737 | publish_tab = GNUNET_new (struct PublishTab); |
3673 | publish_tab->builder = | 3738 | publish_tab->builder = |
3674 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_publish_tab.glade", | 3739 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_publish_tab.glade", |
3675 | publish_tab); | 3740 | publish_tab); |
3676 | df = GTK_WINDOW (gtk_builder_get_object | 3741 | df = GTK_WINDOW ( |
3677 | (publish_tab->builder, "_publish_frame_window")); | 3742 | gtk_builder_get_object (publish_tab->builder, "_publish_frame_window")); |
3678 | publish_tab->frame = gtk_bin_get_child (GTK_BIN (df)); | 3743 | publish_tab->frame = gtk_bin_get_child (GTK_BIN (df)); |
3679 | g_object_ref (publish_tab->frame); | 3744 | g_object_ref (publish_tab->frame); |
3680 | gtk_container_remove (GTK_CONTAINER (df), publish_tab->frame); | 3745 | gtk_container_remove (GTK_CONTAINER (df), publish_tab->frame); |
3681 | gtk_widget_destroy (GTK_WIDGET (df)); | 3746 | gtk_widget_destroy (GTK_WIDGET (df)); |
3682 | 3747 | ||
3683 | /* load tab_label */ | 3748 | /* load tab_label */ |
3684 | df = GTK_WINDOW (gtk_builder_get_object | 3749 | df = GTK_WINDOW ( |
3685 | (publish_tab->builder, "_publish_label_window")); | 3750 | gtk_builder_get_object (publish_tab->builder, "_publish_label_window")); |
3686 | tab_label = gtk_bin_get_child (GTK_BIN (df)); | 3751 | tab_label = gtk_bin_get_child (GTK_BIN (df)); |
3687 | g_object_ref (tab_label); | 3752 | g_object_ref (tab_label); |
3688 | gtk_container_remove (GTK_CONTAINER (df), tab_label); | 3753 | gtk_container_remove (GTK_CONTAINER (df), tab_label); |
3689 | gtk_widget_destroy (GTK_WIDGET (df)); | 3754 | gtk_widget_destroy (GTK_WIDGET (df)); |
3690 | 3755 | ||
3691 | tv = GTK_TREE_VIEW (gtk_builder_get_object | 3756 | tv = GTK_TREE_VIEW ( |
3692 | (publish_tab->builder, "_publish_tree_view")); | 3757 | gtk_builder_get_object (publish_tab->builder, "_publish_tree_view")); |
3693 | anim_col = GTK_TREE_VIEW_COLUMN (gtk_builder_get_object | 3758 | anim_col = GTK_TREE_VIEW_COLUMN ( |
3694 | (publish_tab->builder, "_publish_animated_icon")); | 3759 | gtk_builder_get_object (publish_tab->builder, "_publish_animated_icon")); |
3695 | if ( (NULL != tv) && (NULL != anim_col) ) | 3760 | if ((NULL != tv) && (NULL != anim_col)) |
3696 | publish_tab->atv = GNUNET_GTK_animation_tree_view_register (tv, | 3761 | publish_tab->atv = GNUNET_GTK_animation_tree_view_register (tv, anim_col); |
3697 | anim_col); | ||
3698 | 3762 | ||
3699 | /* make visible */ | 3763 | /* make visible */ |
3700 | gtk_notebook_insert_page (mctx->notebook, publish_tab->frame, tab_label, 0); | 3764 | gtk_notebook_insert_page (mctx->notebook, publish_tab->frame, tab_label, 0); |
3701 | gtk_widget_show (GTK_WIDGET (mctx->notebook)); | 3765 | gtk_widget_show (GTK_WIDGET (mctx->notebook)); |
3702 | gtk_notebook_set_current_page (mctx->notebook, 0); | 3766 | gtk_notebook_set_current_page (mctx->notebook, 0); |
3703 | publish_tab->ts = | 3767 | publish_tab->ts = |
3704 | GTK_TREE_STORE (gtk_builder_get_object | 3768 | GTK_TREE_STORE (gtk_builder_get_object (publish_tab->builder, |
3705 | (publish_tab->builder, "_publish_frame_tree_store")); | 3769 | "_publish_frame_tree_store")); |
3706 | } | 3770 | } |
3707 | 3771 | ||
3708 | /* decide where to insert in the tab */ | 3772 | /* decide where to insert in the tab */ |
@@ -3714,9 +3778,9 @@ setup_publish (struct GNUNET_FS_PublishContext *pc, const char *fn, | |||
3714 | { | 3778 | { |
3715 | /* create new iter from parent */ | 3779 | /* create new iter from parent */ |
3716 | path = gtk_tree_row_reference_get_path (parent->rr); | 3780 | path = gtk_tree_row_reference_get_path (parent->rr); |
3717 | if (TRUE != | 3781 | if (TRUE != gtk_tree_model_get_iter (GTK_TREE_MODEL (publish_tab->ts), |
3718 | gtk_tree_model_get_iter (GTK_TREE_MODEL (publish_tab->ts), &piter, | 3782 | &piter, |
3719 | path)) | 3783 | path)) |
3720 | { | 3784 | { |
3721 | GNUNET_break (0); | 3785 | GNUNET_break (0); |
3722 | return NULL; | 3786 | return NULL; |
@@ -3734,13 +3798,23 @@ setup_publish (struct GNUNET_FS_PublishContext *pc, const char *fn, | |||
3734 | ent->tab = publish_tab; | 3798 | ent->tab = publish_tab; |
3735 | ent->pc = pc; | 3799 | ent->pc = pc; |
3736 | size_fancy = GNUNET_STRINGS_byte_size_fancy (fsize); | 3800 | size_fancy = GNUNET_STRINGS_byte_size_fancy (fsize); |
3737 | gtk_tree_store_insert_with_values (publish_tab->ts, &iter, pitrptr, G_MAXINT, | 3801 | gtk_tree_store_insert_with_values (publish_tab->ts, |
3738 | PUBLISH_TAB_MC_FILENAME, fn, | 3802 | &iter, |
3739 | PUBLISH_TAB_MC_FILESIZE, size_fancy, | 3803 | pitrptr, |
3740 | PUBLISH_TAB_MC_BGCOLOUR, "white", | 3804 | G_MAXINT, |
3741 | PUBLISH_TAB_MC_PROGRESS, (guint) 0, | 3805 | PUBLISH_TAB_MC_FILENAME, |
3742 | PUBLISH_TAB_MC_ENT, ent, | 3806 | fn, |
3743 | PUBLISH_TAB_MC_STATUS_ICON, GNUNET_GTK_animation_context_get_pixbuf (animation_publishing), | 3807 | PUBLISH_TAB_MC_FILESIZE, |
3808 | size_fancy, | ||
3809 | PUBLISH_TAB_MC_BGCOLOUR, | ||
3810 | "white", | ||
3811 | PUBLISH_TAB_MC_PROGRESS, | ||
3812 | (guint) 0, | ||
3813 | PUBLISH_TAB_MC_ENT, | ||
3814 | ent, | ||
3815 | PUBLISH_TAB_MC_STATUS_ICON, | ||
3816 | GNUNET_GTK_animation_context_get_pixbuf ( | ||
3817 | animation_publishing), | ||
3744 | -1); | 3818 | -1); |
3745 | GNUNET_free (size_fancy); | 3819 | GNUNET_free (size_fancy); |
3746 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (publish_tab->ts), &iter); | 3820 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (publish_tab->ts), &iter); |
@@ -3750,7 +3824,6 @@ setup_publish (struct GNUNET_FS_PublishContext *pc, const char *fn, | |||
3750 | } | 3824 | } |
3751 | 3825 | ||
3752 | 3826 | ||
3753 | |||
3754 | /** | 3827 | /** |
3755 | * Context for the publish list popup menu. | 3828 | * Context for the publish list popup menu. |
3756 | */ | 3829 | */ |
@@ -3770,7 +3843,6 @@ struct PublishListPopupContext | |||
3770 | * Publishing entry at the respective row. | 3843 | * Publishing entry at the respective row. |
3771 | */ | 3844 | */ |
3772 | struct PublishEntry *pe; | 3845 | struct PublishEntry *pe; |
3773 | |||
3774 | }; | 3846 | }; |
3775 | 3847 | ||
3776 | 3848 | ||
@@ -3781,8 +3853,7 @@ struct PublishListPopupContext | |||
3781 | * @param user_data the 'struct PublishListPopupContext' of the menu | 3853 | * @param user_data the 'struct PublishListPopupContext' of the menu |
3782 | */ | 3854 | */ |
3783 | static void | 3855 | static void |
3784 | publish_list_popup_selection_done (GtkMenuShell *menushell, | 3856 | publish_list_popup_selection_done (GtkMenuShell *menushell, gpointer user_data) |
3785 | gpointer user_data) | ||
3786 | { | 3857 | { |
3787 | struct PublishListPopupContext *ppc = user_data; | 3858 | struct PublishListPopupContext *ppc = user_data; |
3788 | 3859 | ||
@@ -3859,12 +3930,8 @@ publish_list_get_popup (GtkTreeModel *tm, | |||
3859 | struct PublishEntry *pe; | 3930 | struct PublishEntry *pe; |
3860 | struct PublishListPopupContext *ppc; | 3931 | struct PublishListPopupContext *ppc; |
3861 | 3932 | ||
3862 | gtk_tree_model_get (tm, iter, | 3933 | gtk_tree_model_get (tm, iter, PUBLISH_TAB_MC_ENT, &pe, -1); |
3863 | PUBLISH_TAB_MC_ENT, &pe, | 3934 | if ((NULL == pe->uri) && ((NULL == pe->pc) || (GNUNET_NO == pe->is_top))) |
3864 | -1); | ||
3865 | if ( (NULL == pe->uri) && | ||
3866 | ( (NULL == pe->pc) || | ||
3867 | (GNUNET_NO == pe->is_top) ) ) | ||
3868 | { | 3935 | { |
3869 | /* no actions available, refuse to pop up */ | 3936 | /* no actions available, refuse to pop up */ |
3870 | return NULL; | 3937 | return NULL; |
@@ -3879,27 +3946,34 @@ publish_list_get_popup (GtkTreeModel *tm, | |||
3879 | menu = GTK_MENU (gtk_menu_new ()); | 3946 | menu = GTK_MENU (gtk_menu_new ()); |
3880 | if (NULL != pe->uri) | 3947 | if (NULL != pe->uri) |
3881 | { | 3948 | { |
3882 | child = gtk_menu_item_new_with_label (_("_Copy URI to Clipboard")); | 3949 | child = gtk_menu_item_new_with_label (_ ("_Copy URI to Clipboard")); |
3883 | g_signal_connect (child, "activate", | 3950 | g_signal_connect (child, |
3884 | G_CALLBACK (copy_publish_uri_to_clipboard_ctx_menu), ppc); | 3951 | "activate", |
3885 | gtk_label_set_use_underline (GTK_LABEL | 3952 | G_CALLBACK (copy_publish_uri_to_clipboard_ctx_menu), |
3886 | (gtk_bin_get_child (GTK_BIN (child))), TRUE); | 3953 | ppc); |
3954 | gtk_label_set_use_underline (GTK_LABEL ( | ||
3955 | gtk_bin_get_child (GTK_BIN (child))), | ||
3956 | TRUE); | ||
3887 | gtk_widget_show (child); | 3957 | gtk_widget_show (child); |
3888 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); | 3958 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); |
3889 | } | 3959 | } |
3890 | else if (NULL != pe->pc) | 3960 | else if (NULL != pe->pc) |
3891 | { | 3961 | { |
3892 | child = gtk_menu_item_new_with_label (_("_Abort publishing")); | 3962 | child = gtk_menu_item_new_with_label (_ ("_Abort publishing")); |
3893 | g_signal_connect (child, "activate", | 3963 | g_signal_connect (child, |
3894 | G_CALLBACK (abort_publish_ctx_menu), ppc); | 3964 | "activate", |
3895 | gtk_label_set_use_underline (GTK_LABEL | 3965 | G_CALLBACK (abort_publish_ctx_menu), |
3896 | (gtk_bin_get_child (GTK_BIN (child))), | 3966 | ppc); |
3967 | gtk_label_set_use_underline (GTK_LABEL ( | ||
3968 | gtk_bin_get_child (GTK_BIN (child))), | ||
3897 | TRUE); | 3969 | TRUE); |
3898 | gtk_widget_show (child); | 3970 | gtk_widget_show (child); |
3899 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); | 3971 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); |
3900 | } | 3972 | } |
3901 | g_signal_connect (menu, "selection-done", | 3973 | g_signal_connect (menu, |
3902 | G_CALLBACK (publish_list_popup_selection_done), ppc); | 3974 | "selection-done", |
3975 | G_CALLBACK (publish_list_popup_selection_done), | ||
3976 | ppc); | ||
3903 | return menu; | 3977 | return menu; |
3904 | } | 3978 | } |
3905 | 3979 | ||
@@ -3914,7 +3988,7 @@ publish_list_get_popup (GtkTreeModel *tm, | |||
3914 | */ | 3988 | */ |
3915 | gboolean | 3989 | gboolean |
3916 | GNUNET_FS_GTK_publish_treeview_popup_menu (GtkWidget *widget, | 3990 | GNUNET_FS_GTK_publish_treeview_popup_menu (GtkWidget *widget, |
3917 | gpointer user_data) | 3991 | gpointer user_data) |
3918 | { | 3992 | { |
3919 | GtkTreeView *tv = GTK_TREE_VIEW (widget); | 3993 | GtkTreeView *tv = GTK_TREE_VIEW (widget); |
3920 | struct PublishTab *tab = user_data; | 3994 | struct PublishTab *tab = user_data; |
@@ -3949,9 +4023,9 @@ GNUNET_FS_GTK_publish_treeview_popup_menu (GtkWidget *widget, | |||
3949 | * TRUE to stop the event propagation. | 4023 | * TRUE to stop the event propagation. |
3950 | */ | 4024 | */ |
3951 | gboolean | 4025 | gboolean |
3952 | GNUNET_FS_GTK_publish_treeview_button_press_event (GtkWidget * widget, | 4026 | GNUNET_FS_GTK_publish_treeview_button_press_event (GtkWidget *widget, |
3953 | GdkEvent * event, | 4027 | GdkEvent *event, |
3954 | gpointer user_data) | 4028 | gpointer user_data) |
3955 | { | 4029 | { |
3956 | GtkTreeView *tv = GTK_TREE_VIEW (widget); | 4030 | GtkTreeView *tv = GTK_TREE_VIEW (widget); |
3957 | GdkEventButton *event_button = (GdkEventButton *) event; | 4031 | GdkEventButton *event_button = (GdkEventButton *) event; |
@@ -3961,33 +4035,31 @@ GNUNET_FS_GTK_publish_treeview_button_press_event (GtkWidget * widget, | |||
3961 | GtkTreeIter iter; | 4035 | GtkTreeIter iter; |
3962 | GtkMenu *menu; | 4036 | GtkMenu *menu; |
3963 | 4037 | ||
3964 | if ( (GDK_BUTTON_PRESS != event->type) || | 4038 | if ((GDK_BUTTON_PRESS != event->type) || (3 != event_button->button)) |
3965 | (3 != event_button->button) ) | ||
3966 | return FALSE; /* not a right-click */ | 4039 | return FALSE; /* not a right-click */ |
3967 | if (! gtk_tree_view_get_path_at_pos (tv, | 4040 | if (! gtk_tree_view_get_path_at_pos (tv, |
3968 | event_button->x, event_button->y, | 4041 | event_button->x, |
3969 | &path, NULL, NULL, NULL)) | 4042 | event_button->y, |
4043 | &path, | ||
4044 | NULL, | ||
4045 | NULL, | ||
4046 | NULL)) | ||
3970 | return FALSE; /* click outside of area with values, ignore */ | 4047 | return FALSE; /* click outside of area with values, ignore */ |
3971 | tm = gtk_tree_view_get_model (tv); | 4048 | tm = gtk_tree_view_get_model (tv); |
3972 | if (! gtk_tree_model_get_iter (tm, &iter, path)) | 4049 | if (! gtk_tree_model_get_iter (tm, &iter, path)) |
3973 | return FALSE; /* not sure how we got a path but no iter... */ | 4050 | return FALSE; /* not sure how we got a path but no iter... */ |
3974 | gtk_tree_path_free (path); | 4051 | gtk_tree_path_free (path); |
3975 | menu = publish_list_get_popup (tm, | 4052 | menu = publish_list_get_popup (tm, tab, &iter); |
3976 | tab, | ||
3977 | &iter); | ||
3978 | if (NULL == menu) | 4053 | if (NULL == menu) |
3979 | return FALSE; | 4054 | return FALSE; |
3980 | gtk_menu_popup_at_pointer (menu, | 4055 | gtk_menu_popup_at_pointer (menu, event); |
3981 | event); | ||
3982 | return FALSE; /* propagate further, to focus on the item (for example) */ | 4056 | return FALSE; /* propagate further, to focus on the item (for example) */ |
3983 | } | 4057 | } |
3984 | 4058 | ||
3985 | 4059 | ||
3986 | |||
3987 | /* ***************** Master event handler ****************** */ | 4060 | /* ***************** Master event handler ****************** */ |
3988 | 4061 | ||
3989 | 4062 | ||
3990 | |||
3991 | /** | 4063 | /** |
3992 | * Notification of FS to a client about the progress of an | 4064 | * Notification of FS to a client about the progress of an |
3993 | * operation. Callbacks of this type will be used for uploads, | 4065 | * operation. Callbacks of this type will be used for uploads, |
@@ -4009,30 +4081,30 @@ GNUNET_GTK_fs_event_handler (void *cls, | |||
4009 | { | 4081 | { |
4010 | void *ret; | 4082 | void *ret; |
4011 | 4083 | ||
4012 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4084 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got FS event %d\n", info->status); |
4013 | "Got FS event %d\n", | ||
4014 | info->status); | ||
4015 | GNUNET_FS_GTK_set_fs_handle (info->fsh); | 4085 | GNUNET_FS_GTK_set_fs_handle (info->fsh); |
4016 | switch (info->status) | 4086 | switch (info->status) |
4017 | { | 4087 | { |
4018 | case GNUNET_FS_STATUS_PUBLISH_START: | 4088 | case GNUNET_FS_STATUS_PUBLISH_START: |
4019 | return setup_publish (info->value.publish.pc, info->value.publish.filename, | 4089 | return setup_publish (info->value.publish.pc, |
4020 | info->value.publish.size, info->value.publish.pctx); | 4090 | info->value.publish.filename, |
4091 | info->value.publish.size, | ||
4092 | info->value.publish.pctx); | ||
4021 | case GNUNET_FS_STATUS_PUBLISH_RESUME: | 4093 | case GNUNET_FS_STATUS_PUBLISH_RESUME: |
4022 | ret = | 4094 | ret = setup_publish (info->value.publish.pc, |
4023 | setup_publish (info->value.publish.pc, info->value.publish.filename, | 4095 | info->value.publish.filename, |
4024 | info->value.publish.size, info->value.publish.pctx); | 4096 | info->value.publish.size, |
4097 | info->value.publish.pctx); | ||
4025 | if (NULL == ret) | 4098 | if (NULL == ret) |
4026 | return ret; | 4099 | return ret; |
4027 | if (NULL != info->value.publish.specifics.resume.message) | 4100 | if (NULL != info->value.publish.specifics.resume.message) |
4028 | { | 4101 | { |
4029 | handle_publish_error (ret, | 4102 | handle_publish_error (ret, info->value.publish.specifics.resume.message); |
4030 | info->value.publish.specifics.resume.message); | ||
4031 | } | 4103 | } |
4032 | else if (NULL != info->value.publish.specifics.resume.chk_uri) | 4104 | else if (NULL != info->value.publish.specifics.resume.chk_uri) |
4033 | { | 4105 | { |
4034 | handle_publish_completed (ret, | 4106 | handle_publish_completed (ret, |
4035 | info->value.publish.specifics.resume.chk_uri); | 4107 | info->value.publish.specifics.resume.chk_uri); |
4036 | } | 4108 | } |
4037 | return ret; | 4109 | return ret; |
4038 | case GNUNET_FS_STATUS_PUBLISH_SUSPEND: | 4110 | case GNUNET_FS_STATUS_PUBLISH_SUSPEND: |
@@ -4040,72 +4112,72 @@ GNUNET_GTK_fs_event_handler (void *cls, | |||
4040 | return NULL; | 4112 | return NULL; |
4041 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS: | 4113 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS: |
4042 | mark_publish_progress (info->value.publish.cctx, | 4114 | mark_publish_progress (info->value.publish.cctx, |
4043 | info->value.publish.size, | 4115 | info->value.publish.size, |
4044 | info->value.publish.completed); | 4116 | info->value.publish.completed); |
4045 | return info->value.publish.cctx; | 4117 | return info->value.publish.cctx; |
4046 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY: | 4118 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY: |
4047 | mark_publish_progress (info->value.publish.cctx, | 4119 | mark_publish_progress (info->value.publish.cctx, |
4048 | info->value.publish.specifics.progress_directory.total, | 4120 | info->value.publish.specifics.progress_directory |
4049 | info->value.publish.specifics.progress_directory.completed); | 4121 | .total, |
4122 | info->value.publish.specifics.progress_directory | ||
4123 | .completed); | ||
4050 | return info->value.publish.cctx; | 4124 | return info->value.publish.cctx; |
4051 | case GNUNET_FS_STATUS_PUBLISH_ERROR: | 4125 | case GNUNET_FS_STATUS_PUBLISH_ERROR: |
4052 | handle_publish_error (info->value.publish.cctx, | 4126 | handle_publish_error (info->value.publish.cctx, |
4053 | info->value.publish.specifics.error.message); | 4127 | info->value.publish.specifics.error.message); |
4054 | return info->value.publish.cctx; | 4128 | return info->value.publish.cctx; |
4055 | case GNUNET_FS_STATUS_PUBLISH_COMPLETED: | 4129 | case GNUNET_FS_STATUS_PUBLISH_COMPLETED: |
4056 | handle_publish_completed (info->value.publish.cctx, | 4130 | handle_publish_completed (info->value.publish.cctx, |
4057 | info->value.publish.specifics.completed.chk_uri); | 4131 | info->value.publish.specifics.completed.chk_uri); |
4058 | return info->value.publish.cctx; | 4132 | return info->value.publish.cctx; |
4059 | case GNUNET_FS_STATUS_PUBLISH_STOPPED: | 4133 | case GNUNET_FS_STATUS_PUBLISH_STOPPED: |
4060 | handle_publish_stop (info->value.publish.cctx); | 4134 | handle_publish_stop (info->value.publish.cctx); |
4061 | return NULL; | 4135 | return NULL; |
4062 | case GNUNET_FS_STATUS_DOWNLOAD_START: | 4136 | case GNUNET_FS_STATUS_DOWNLOAD_START: |
4063 | return setup_download (info->value.download.cctx, info->value.download.pctx, | 4137 | return setup_download (info->value.download.cctx, |
4138 | info->value.download.pctx, | ||
4064 | info->value.download.sctx, | 4139 | info->value.download.sctx, |
4065 | info->value.download.anonymity, | 4140 | info->value.download.anonymity, |
4066 | info->value.download.dc, | 4141 | info->value.download.dc, |
4067 | info->value.download.uri, | 4142 | info->value.download.uri, |
4068 | info->value.download.filename, | 4143 | info->value.download.filename, |
4069 | info->value.download.specifics.start.meta, | 4144 | info->value.download.specifics.start.meta, |
4070 | info->value.download.size, | 4145 | info->value.download.size, |
4071 | info->value.download.completed); | 4146 | info->value.download.completed); |
4072 | case GNUNET_FS_STATUS_DOWNLOAD_RESUME: | 4147 | case GNUNET_FS_STATUS_DOWNLOAD_RESUME: |
4073 | ret = | 4148 | ret = setup_download (info->value.download.cctx, |
4074 | setup_download (info->value.download.cctx, info->value.download.pctx, | 4149 | info->value.download.pctx, |
4075 | info->value.download.sctx, | 4150 | info->value.download.sctx, |
4076 | info->value.download.anonymity, | 4151 | info->value.download.anonymity, |
4077 | info->value.download.dc, | 4152 | info->value.download.dc, |
4078 | info->value.download.uri, info->value.download.filename, | 4153 | info->value.download.uri, |
4079 | info->value.download.specifics.resume.meta, | 4154 | info->value.download.filename, |
4080 | info->value.download.size, | 4155 | info->value.download.specifics.resume.meta, |
4081 | info->value.download.completed); | 4156 | info->value.download.size, |
4157 | info->value.download.completed); | ||
4082 | if (NULL != info->value.download.specifics.resume.message) | 4158 | if (NULL != info->value.download.specifics.resume.message) |
4083 | mark_download_error (ret, | 4159 | mark_download_error (ret, info->value.download.specifics.resume.message); |
4084 | info->value.download.specifics.resume.message); | ||
4085 | return ret; | 4160 | return ret; |
4086 | case GNUNET_FS_STATUS_DOWNLOAD_SUSPEND: | 4161 | case GNUNET_FS_STATUS_DOWNLOAD_SUSPEND: |
4087 | stop_download (info->value.download.cctx); | 4162 | stop_download (info->value.download.cctx); |
4088 | return NULL; | 4163 | return NULL; |
4089 | case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: | 4164 | case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: |
4090 | mark_download_progress (info->value.download.cctx, | 4165 | mark_download_progress (info->value.download.cctx, |
4091 | info->value.download.filename, | 4166 | info->value.download.filename, |
4092 | info->value.download.size, | 4167 | info->value.download.size, |
4093 | info->value.download.completed, | 4168 | info->value.download.completed, |
4094 | info->value.download.specifics.progress.data, | 4169 | info->value.download.specifics.progress.data, |
4095 | info->value.download.specifics.progress. | 4170 | info->value.download.specifics.progress.offset, |
4096 | offset, | 4171 | info->value.download.specifics.progress.data_len, |
4097 | info->value.download.specifics.progress. | 4172 | info->value.download.specifics.progress.depth); |
4098 | data_len, | ||
4099 | info->value.download.specifics.progress. | ||
4100 | depth); | ||
4101 | return info->value.download.cctx; | 4173 | return info->value.download.cctx; |
4102 | case GNUNET_FS_STATUS_DOWNLOAD_ERROR: | 4174 | case GNUNET_FS_STATUS_DOWNLOAD_ERROR: |
4103 | mark_download_error (info->value.download.cctx, | 4175 | mark_download_error (info->value.download.cctx, |
4104 | info->value.download.specifics.error.message); | 4176 | info->value.download.specifics.error.message); |
4105 | return info->value.download.cctx; | 4177 | return info->value.download.cctx; |
4106 | case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: | 4178 | case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: |
4107 | mark_download_completed (info->value.download.cctx, | 4179 | mark_download_completed (info->value.download.cctx, |
4108 | info->value.download.size); | 4180 | info->value.download.size); |
4109 | return info->value.download.cctx; | 4181 | return info->value.download.cctx; |
4110 | case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: | 4182 | case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: |
4111 | stop_download (info->value.download.cctx); | 4183 | stop_download (info->value.download.cctx); |
@@ -4113,12 +4185,14 @@ GNUNET_GTK_fs_event_handler (void *cls, | |||
4113 | case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE: | 4185 | case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE: |
4114 | change_download_color (info->value.download.cctx, "yellow"); | 4186 | change_download_color (info->value.download.cctx, "yellow"); |
4115 | change_download_status_icon (info->value.download.cctx, | 4187 | change_download_status_icon (info->value.download.cctx, |
4116 | GNUNET_GTK_animation_context_get_pixbuf (animation_downloading)); | 4188 | GNUNET_GTK_animation_context_get_pixbuf ( |
4189 | animation_downloading)); | ||
4117 | return info->value.download.cctx; | 4190 | return info->value.download.cctx; |
4118 | case GNUNET_FS_STATUS_DOWNLOAD_INACTIVE: | 4191 | case GNUNET_FS_STATUS_DOWNLOAD_INACTIVE: |
4119 | change_download_color (info->value.download.cctx, "blue"); | 4192 | change_download_color (info->value.download.cctx, "blue"); |
4120 | change_download_status_icon (info->value.download.cctx, | 4193 | change_download_status_icon (info->value.download.cctx, |
4121 | GNUNET_GTK_animation_context_get_pixbuf (animation_download_stalled)); | 4194 | GNUNET_GTK_animation_context_get_pixbuf ( |
4195 | animation_download_stalled)); | ||
4122 | return info->value.download.cctx; | 4196 | return info->value.download.cctx; |
4123 | case GNUNET_FS_STATUS_DOWNLOAD_LOST_PARENT: | 4197 | case GNUNET_FS_STATUS_DOWNLOAD_LOST_PARENT: |
4124 | download_lost_parent (info->value.download.cctx); | 4198 | download_lost_parent (info->value.download.cctx); |
@@ -4131,30 +4205,27 @@ GNUNET_GTK_fs_event_handler (void *cls, | |||
4131 | case GNUNET_FS_STATUS_SEARCH_RESUME: | 4205 | case GNUNET_FS_STATUS_SEARCH_RESUME: |
4132 | ret = setup_search_tab (info->value.search.sc, info->value.search.query); | 4206 | ret = setup_search_tab (info->value.search.sc, info->value.search.query); |
4133 | if (info->value.search.specifics.resume.message) | 4207 | if (info->value.search.specifics.resume.message) |
4134 | handle_search_error (ret, | 4208 | handle_search_error (ret, info->value.search.specifics.resume.message); |
4135 | info->value.search.specifics.resume.message); | ||
4136 | return ret; | 4209 | return ret; |
4137 | case GNUNET_FS_STATUS_SEARCH_RESUME_RESULT: | 4210 | case GNUNET_FS_STATUS_SEARCH_RESUME_RESULT: |
4138 | ret = | 4211 | ret = |
4139 | process_search_result (info->value.search.cctx, | 4212 | process_search_result (info->value.search.cctx, |
4140 | info->value.search.anonymity, | 4213 | info->value.search.anonymity, |
4141 | info->value.search.pctx, | 4214 | info->value.search.pctx, |
4142 | info->value.search.specifics.resume_result.uri, | 4215 | info->value.search.specifics.resume_result.uri, |
4143 | info->value.search.specifics.resume_result.meta, | 4216 | info->value.search.specifics.resume_result.meta, |
4144 | info->value.search.specifics.resume_result. | 4217 | info->value.search.specifics.resume_result.result, |
4145 | result, | 4218 | info->value.search.specifics.resume_result |
4146 | info->value.search.specifics.resume_result. | 4219 | .applicability_rank); |
4147 | applicability_rank); | ||
4148 | update_search_result (ret, | 4220 | update_search_result (ret, |
4149 | info->value.search.specifics.resume_result. | 4221 | info->value.search.specifics.resume_result.meta, |
4150 | meta, | 4222 | info->value.search.specifics.resume_result |
4151 | info->value.search.specifics.resume_result. | 4223 | .applicability_rank, |
4152 | applicability_rank, | 4224 | info->value.search.specifics.resume_result |
4153 | info->value.search.specifics.resume_result. | 4225 | .availability_rank, |
4154 | availability_rank, | 4226 | info->value.search.specifics.resume_result |
4155 | info->value.search.specifics.resume_result. | 4227 | .availability_certainty, |
4156 | availability_certainty, | 4228 | GNUNET_TIME_UNIT_ZERO); |
4157 | GNUNET_TIME_UNIT_ZERO); | ||
4158 | GNUNET_break (NULL != ret); | 4229 | GNUNET_break (NULL != ret); |
4159 | return ret; | 4230 | return ret; |
4160 | case GNUNET_FS_STATUS_SEARCH_SUSPEND: | 4231 | case GNUNET_FS_STATUS_SEARCH_SUSPEND: |
@@ -4162,31 +4233,30 @@ GNUNET_GTK_fs_event_handler (void *cls, | |||
4162 | return NULL; | 4233 | return NULL; |
4163 | case GNUNET_FS_STATUS_SEARCH_RESULT: | 4234 | case GNUNET_FS_STATUS_SEARCH_RESULT: |
4164 | return process_search_result (info->value.search.cctx, | 4235 | return process_search_result (info->value.search.cctx, |
4165 | info->value.search.anonymity, | 4236 | info->value.search.anonymity, |
4166 | info->value.search.pctx, | 4237 | info->value.search.pctx, |
4167 | info->value.search.specifics.result.uri, | 4238 | info->value.search.specifics.result.uri, |
4168 | info->value.search.specifics.result.meta, | 4239 | info->value.search.specifics.result.meta, |
4169 | info->value.search.specifics.result.result, | 4240 | info->value.search.specifics.result.result, |
4170 | info->value.search.specifics.result. | 4241 | info->value.search.specifics.result |
4171 | applicability_rank); | 4242 | .applicability_rank); |
4172 | case GNUNET_FS_STATUS_SEARCH_RESULT_NAMESPACE: | 4243 | case GNUNET_FS_STATUS_SEARCH_RESULT_NAMESPACE: |
4173 | GNUNET_break (0); | 4244 | GNUNET_break (0); |
4174 | break; | 4245 | break; |
4175 | case GNUNET_FS_STATUS_SEARCH_UPDATE: | 4246 | case GNUNET_FS_STATUS_SEARCH_UPDATE: |
4176 | update_search_result (info->value.search.specifics.update.cctx, | 4247 | update_search_result (info->value.search.specifics.update.cctx, |
4177 | info->value.search.specifics.update.meta, | 4248 | info->value.search.specifics.update.meta, |
4178 | info->value.search.specifics.update. | 4249 | info->value.search.specifics.update |
4179 | applicability_rank, | 4250 | .applicability_rank, |
4180 | info->value.search.specifics.update. | 4251 | info->value.search.specifics.update.availability_rank, |
4181 | availability_rank, | 4252 | info->value.search.specifics.update |
4182 | info->value.search.specifics.update. | 4253 | .availability_certainty, |
4183 | availability_certainty, | 4254 | info->value.search.specifics.update |
4184 | info->value.search.specifics.update. | 4255 | .current_probe_time); |
4185 | current_probe_time); | ||
4186 | return info->value.search.specifics.update.cctx; | 4256 | return info->value.search.specifics.update.cctx; |
4187 | case GNUNET_FS_STATUS_SEARCH_ERROR: | 4257 | case GNUNET_FS_STATUS_SEARCH_ERROR: |
4188 | handle_search_error (info->value.search.cctx, | 4258 | handle_search_error (info->value.search.cctx, |
4189 | info->value.search.specifics.error.message); | 4259 | info->value.search.specifics.error.message); |
4190 | return info->value.search.cctx; | 4260 | return info->value.search.cctx; |
4191 | case GNUNET_FS_STATUS_SEARCH_PAUSED: | 4261 | case GNUNET_FS_STATUS_SEARCH_PAUSED: |
4192 | return info->value.search.cctx; | 4262 | return info->value.search.cctx; |
@@ -4205,10 +4275,11 @@ GNUNET_GTK_fs_event_handler (void *cls, | |||
4205 | return info->value.unindex.cctx; | 4275 | return info->value.unindex.cctx; |
4206 | case GNUNET_FS_STATUS_UNINDEX_RESUME: | 4276 | case GNUNET_FS_STATUS_UNINDEX_RESUME: |
4207 | return GNUNET_FS_GTK_unindex_handle_resume_ (info->value.unindex.uc, | 4277 | return GNUNET_FS_GTK_unindex_handle_resume_ (info->value.unindex.uc, |
4208 | info->value.unindex.filename, | 4278 | info->value.unindex.filename, |
4209 | info->value.unindex.size, | 4279 | info->value.unindex.size, |
4210 | info->value.unindex.completed, | 4280 | info->value.unindex.completed, |
4211 | info->value.unindex.specifics.resume.message); | 4281 | info->value.unindex.specifics |
4282 | .resume.message); | ||
4212 | case GNUNET_FS_STATUS_UNINDEX_SUSPEND: | 4283 | case GNUNET_FS_STATUS_UNINDEX_SUSPEND: |
4213 | GNUNET_FS_GTK_unindex_handle_stop_ (info->value.unindex.cctx); | 4284 | GNUNET_FS_GTK_unindex_handle_stop_ (info->value.unindex.cctx); |
4214 | return NULL; | 4285 | return NULL; |
@@ -4224,7 +4295,8 @@ GNUNET_GTK_fs_event_handler (void *cls, | |||
4224 | case GNUNET_FS_STATUS_UNINDEX_ERROR: | 4295 | case GNUNET_FS_STATUS_UNINDEX_ERROR: |
4225 | if (NULL != info->value.unindex.cctx) | 4296 | if (NULL != info->value.unindex.cctx) |
4226 | GNUNET_FS_GTK_unindex_handle_error_ (info->value.unindex.cctx, | 4297 | GNUNET_FS_GTK_unindex_handle_error_ (info->value.unindex.cctx, |
4227 | info->value.unindex.specifics.error.message); | 4298 | info->value.unindex.specifics.error |
4299 | .message); | ||
4228 | else | 4300 | else |
4229 | GNUNET_FS_unindex_stop (info->value.unindex.uc); | 4301 | GNUNET_FS_unindex_stop (info->value.unindex.uc); |
4230 | return info->value.unindex.cctx; | 4302 | return info->value.unindex.cctx; |
diff --git a/src/fs/gnunet-fs-gtk_event-handler.h b/src/fs/gnunet-fs-gtk_event-handler.h index 749ae174..66f34b2c 100644 --- a/src/fs/gnunet-fs-gtk_event-handler.h +++ b/src/fs/gnunet-fs-gtk_event-handler.h | |||
@@ -116,7 +116,6 @@ struct SearchTab | |||
116 | * Number of results we got for this search. | 116 | * Number of results we got for this search. |
117 | */ | 117 | */ |
118 | unsigned int num_results; | 118 | unsigned int num_results; |
119 | |||
120 | }; | 119 | }; |
121 | 120 | ||
122 | 121 | ||
@@ -263,7 +262,6 @@ extern struct SearchResult *pl_tail; | |||
263 | extern GtkTreeStore *downloads_treestore; | 262 | extern GtkTreeStore *downloads_treestore; |
264 | 263 | ||
265 | 264 | ||
266 | |||
267 | /** | 265 | /** |
268 | * Setup a new top-level entry in the URI/orphan tab. If necessary, create | 266 | * Setup a new top-level entry in the URI/orphan tab. If necessary, create |
269 | * the URI tab first. | 267 | * the URI tab first. |
@@ -275,7 +273,7 @@ extern GtkTreeStore *downloads_treestore; | |||
275 | */ | 273 | */ |
276 | struct SearchResult * | 274 | struct SearchResult * |
277 | GNUNET_GTK_add_to_uri_tab (uint32_t anonymity, | 275 | GNUNET_GTK_add_to_uri_tab (uint32_t anonymity, |
278 | const struct GNUNET_CONTAINER_MetaData *meta, | 276 | const struct GNUNET_CONTAINER_MetaData *meta, |
279 | const struct GNUNET_FS_Uri *uri); | 277 | const struct GNUNET_FS_Uri *uri); |
280 | 278 | ||
281 | 279 | ||
@@ -298,7 +296,7 @@ GNUNET_GTK_add_to_uri_tab (uint32_t anonymity, | |||
298 | */ | 296 | */ |
299 | struct SearchResult * | 297 | struct SearchResult * |
300 | GNUNET_GTK_add_search_result (struct SearchTab *tab, | 298 | GNUNET_GTK_add_search_result (struct SearchTab *tab, |
301 | uint32_t anonymity, | 299 | uint32_t anonymity, |
302 | GtkTreeRowReference *parent_rr, | 300 | GtkTreeRowReference *parent_rr, |
303 | const struct GNUNET_FS_Uri *uri, | 301 | const struct GNUNET_FS_Uri *uri, |
304 | const struct GNUNET_CONTAINER_MetaData *meta, | 302 | const struct GNUNET_CONTAINER_MetaData *meta, |
@@ -307,7 +305,9 @@ GNUNET_GTK_add_search_result (struct SearchTab *tab, | |||
307 | 305 | ||
308 | 306 | ||
309 | void | 307 | void |
310 | GNUNET_FS_GTK_set_item_downloaded_name (GtkTreeStore *ts, GtkTreeRowReference *rr, gchar *filename); | 308 | GNUNET_FS_GTK_set_item_downloaded_name (GtkTreeStore *ts, |
309 | GtkTreeRowReference *rr, | ||
310 | gchar *filename); | ||
311 | 311 | ||
312 | /** | 312 | /** |
313 | * Notification of FS to a client about the progress of an | 313 | * Notification of FS to a client about the progress of an |
@@ -345,8 +345,9 @@ GNUNET_FS_GTK_close_uri_tab_ (); | |||
345 | */ | 345 | */ |
346 | void | 346 | void |
347 | GNUNET_FS_GTK_update_connection_indicator ( | 347 | GNUNET_FS_GTK_update_connection_indicator ( |
348 | struct GNUNET_GTK_MainWindowContext *main_ctx, | 348 | struct GNUNET_GTK_MainWindowContext *main_ctx, |
349 | gboolean connected, const gchar *tooltip); | 349 | gboolean connected, |
350 | const gchar *tooltip); | ||
350 | 351 | ||
351 | 352 | ||
352 | #endif | 353 | #endif |
diff --git a/src/fs/gnunet-fs-gtk_main-window-connection.c b/src/fs/gnunet-fs-gtk_main-window-connection.c index 41cdfb1b..6afe56cc 100644 --- a/src/fs/gnunet-fs-gtk_main-window-connection.c +++ b/src/fs/gnunet-fs-gtk_main-window-connection.c | |||
@@ -34,15 +34,17 @@ | |||
34 | * @param tooltip new tooltip text | 34 | * @param tooltip new tooltip text |
35 | */ | 35 | */ |
36 | void | 36 | void |
37 | GNUNET_FS_GTK_update_connection_indicator (struct GNUNET_GTK_MainWindowContext *main_ctx, | 37 | GNUNET_FS_GTK_update_connection_indicator ( |
38 | gboolean connected, | 38 | struct GNUNET_GTK_MainWindowContext *main_ctx, |
39 | const gchar *tooltip) | 39 | gboolean connected, |
40 | const gchar *tooltip) | ||
40 | { | 41 | { |
41 | gtk_image_set_from_icon_name (main_ctx->connection_indicator, | 42 | gtk_image_set_from_icon_name (main_ctx->connection_indicator, |
42 | connected ? "network-transmit-receive" : "network-offline", | 43 | connected ? "network-transmit-receive" |
44 | : "network-offline", | ||
43 | GTK_ICON_SIZE_BUTTON); | 45 | GTK_ICON_SIZE_BUTTON); |
44 | gtk_widget_set_tooltip_text (GTK_WIDGET (main_ctx->connection_indicator), | 46 | gtk_widget_set_tooltip_text (GTK_WIDGET (main_ctx->connection_indicator), |
45 | tooltip); | 47 | tooltip); |
46 | } | 48 | } |
47 | 49 | ||
48 | /** | 50 | /** |
@@ -64,7 +66,9 @@ run_armview (struct GNUNET_GTK_MainWindowContext *main_ctx) | |||
64 | */ | 66 | */ |
65 | gboolean | 67 | gboolean |
66 | GNUNET_FS_GTK_main_window_connection_indicator_button_press_event_cb ( | 68 | GNUNET_FS_GTK_main_window_connection_indicator_button_press_event_cb ( |
67 | GtkWidget *widget, GdkEvent *event, gpointer user_data) | 69 | GtkWidget *widget, |
70 | GdkEvent *event, | ||
71 | gpointer user_data) | ||
68 | { | 72 | { |
69 | run_armview (user_data); | 73 | run_armview (user_data); |
70 | return FALSE; | 74 | return FALSE; |
diff --git a/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c b/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c index 88a72335..f5e27148 100644 --- a/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c +++ b/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <string.h> | 29 | #include <string.h> |
30 | 30 | ||
31 | 31 | ||
32 | |||
33 | /** | 32 | /** |
34 | * Helper function of GNUNET_GTK_FS_metadata_copy_selection_activated | 33 | * Helper function of GNUNET_GTK_FS_metadata_copy_selection_activated |
35 | * which copies the (selected) entries from the tree view to the | 34 | * which copies the (selected) entries from the tree view to the |
@@ -41,14 +40,17 @@ | |||
41 | * @param user_data 'GList**' where we should store the types and values found | 40 | * @param user_data 'GList**' where we should store the types and values found |
42 | */ | 41 | */ |
43 | static void | 42 | static void |
44 | copy_metadata_to_clipboard (GtkTreeModel * model, GtkTreePath * path, | 43 | copy_metadata_to_clipboard (GtkTreeModel *model, |
45 | GtkTreeIter * iter, gpointer user_data) | 44 | GtkTreePath *path, |
45 | GtkTreeIter *iter, | ||
46 | gpointer user_data) | ||
46 | { | 47 | { |
47 | GList **l = user_data; | 48 | GList **l = user_data; |
48 | gchar *type; | 49 | gchar *type; |
49 | gchar *value; | 50 | gchar *value; |
50 | 51 | ||
51 | gtk_tree_model_get (model, iter, | 52 | gtk_tree_model_get (model, |
53 | iter, | ||
52 | GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_TYPE_STRING, | 54 | GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_TYPE_STRING, |
53 | &type, | 55 | &type, |
54 | GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_VALUE, | 56 | GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_VALUE, |
@@ -66,8 +68,8 @@ copy_metadata_to_clipboard (GtkTreeModel * model, GtkTreePath * path, | |||
66 | * @param user_data the GtkBuilder of the main window | 68 | * @param user_data the GtkBuilder of the main window |
67 | */ | 69 | */ |
68 | void | 70 | void |
69 | GNUNET_GTK_FS_metadata_copy_selection_activated (GtkMenuItem * menuitem, | 71 | GNUNET_GTK_FS_metadata_copy_selection_activated (GtkMenuItem *menuitem, |
70 | gpointer user_data) | 72 | gpointer user_data) |
71 | { | 73 | { |
72 | struct GNUNET_GTK_MainWindowContext *main_ctx = user_data; | 74 | struct GNUNET_GTK_MainWindowContext *main_ctx = user_data; |
73 | GtkTreeView *tree; | 75 | GtkTreeView *tree; |
@@ -83,7 +85,8 @@ GNUNET_GTK_FS_metadata_copy_selection_activated (GtkMenuItem * menuitem, | |||
83 | tree = main_ctx->md_treeview; | 85 | tree = main_ctx->md_treeview; |
84 | pairs = NULL; | 86 | pairs = NULL; |
85 | gtk_tree_selection_selected_foreach (gtk_tree_view_get_selection (tree), | 87 | gtk_tree_selection_selected_foreach (gtk_tree_view_get_selection (tree), |
86 | ©_metadata_to_clipboard, &pairs); | 88 | ©_metadata_to_clipboard, |
89 | &pairs); | ||
87 | if (NULL == pairs) | 90 | if (NULL == pairs) |
88 | return; /* nothing selected */ | 91 | return; /* nothing selected */ |
89 | total_len = 0; | 92 | total_len = 0; |
@@ -93,12 +96,12 @@ GNUNET_GTK_FS_metadata_copy_selection_activated (GtkMenuItem * menuitem, | |||
93 | type = pos; | 96 | type = pos; |
94 | value = pos->next; | 97 | value = pos->next; |
95 | GNUNET_assert (NULL != value); | 98 | GNUNET_assert (NULL != value); |
96 | total_len += | 99 | total_len += strlen ((gchar *) type->data) + |
97 | strlen ((gchar *) type->data) + strlen ((gchar *) value->data) + | 100 | strlen ((gchar *) value->data) + 2 /* ": " */ + |
98 | 2 /* ": " */ + ((NULL != value->next) ? 1 : 0) /* "\n" */ ; | 101 | ((NULL != value->next) ? 1 : 0) /* "\n" */; |
99 | } | 102 | } |
100 | GNUNET_assert (total_len > 0); | 103 | GNUNET_assert (total_len > 0); |
101 | total_len++; /* "\0" */ | 104 | total_len++; /* "\0" */ |
102 | s = g_new0 (gchar, total_len); | 105 | s = g_new0 (gchar, total_len); |
103 | if (NULL == s) | 106 | if (NULL == s) |
104 | { | 107 | { |
@@ -135,24 +138,23 @@ GNUNET_GTK_FS_metadata_copy_selection_activated (GtkMenuItem * menuitem, | |||
135 | * @param user_data the gtk builder of the main window | 138 | * @param user_data the gtk builder of the main window |
136 | */ | 139 | */ |
137 | gboolean | 140 | gboolean |
138 | GNUNET_GTK_main_window_metadata_treeview_button_press_event_cb (GtkWidget * widget, | 141 | GNUNET_GTK_main_window_metadata_treeview_button_press_event_cb ( |
139 | GdkEvent * event, | 142 | GtkWidget *widget, |
140 | gpointer user_data) | 143 | GdkEvent *event, |
144 | gpointer user_data) | ||
141 | { | 145 | { |
142 | struct GNUNET_GTK_MainWindowContext *main_ctx = user_data; | 146 | struct GNUNET_GTK_MainWindowContext *main_ctx = user_data; |
143 | GdkEventButton *event_button = (GdkEventButton *) event; | 147 | GdkEventButton *event_button = (GdkEventButton *) event; |
144 | GtkMenu *menu; | 148 | GtkMenu *menu; |
145 | 149 | ||
146 | /* Ignore double-clicks and triple-clicks */ | 150 | /* Ignore double-clicks and triple-clicks */ |
147 | if ( (event_button->button != 3) || | 151 | if ((event_button->button != 3) || (event_button->type != GDK_BUTTON_PRESS)) |
148 | (event_button->type != GDK_BUTTON_PRESS) ) | ||
149 | return FALSE; | 152 | return FALSE; |
150 | menu = GTK_MENU (gtk_builder_get_object (main_ctx->builder, | 153 | menu = GTK_MENU ( |
151 | "metadata_popup_menu")); | 154 | gtk_builder_get_object (main_ctx->builder, "metadata_popup_menu")); |
152 | if (NULL == menu) | 155 | if (NULL == menu) |
153 | return FALSE; | 156 | return FALSE; |
154 | gtk_menu_popup_at_pointer (menu, | 157 | gtk_menu_popup_at_pointer (menu, event); |
155 | event); | ||
156 | return FALSE; | 158 | return FALSE; |
157 | } | 159 | } |
158 | 160 | ||
@@ -166,13 +168,14 @@ GNUNET_GTK_main_window_metadata_treeview_button_press_event_cb (GtkWidget * widg | |||
166 | * @return TRUE we did it | 168 | * @return TRUE we did it |
167 | */ | 169 | */ |
168 | gboolean | 170 | gboolean |
169 | GNUNET_GTK_main_window_metadata_treeview_popup_menu_cb (GtkWidget * widget, | 171 | GNUNET_GTK_main_window_metadata_treeview_popup_menu_cb (GtkWidget *widget, |
170 | gpointer user_data) | 172 | gpointer user_data) |
171 | { | 173 | { |
172 | struct GNUNET_GTK_MainWindowContext *main_ctx = user_data; | 174 | struct GNUNET_GTK_MainWindowContext *main_ctx = user_data; |
173 | GtkMenu *menu; | 175 | GtkMenu *menu; |
174 | 176 | ||
175 | menu = GTK_MENU (gtk_builder_get_object (main_ctx->builder, "metadata_popup_menu")); | 177 | menu = GTK_MENU ( |
178 | gtk_builder_get_object (main_ctx->builder, "metadata_popup_menu")); | ||
176 | if (NULL == menu) | 179 | if (NULL == menu) |
177 | return FALSE; | 180 | return FALSE; |
178 | gtk_menu_popup_at_widget (menu, | 181 | gtk_menu_popup_at_widget (menu, |
diff --git a/src/fs/gnunet-fs-gtk_main-window-search.c b/src/fs/gnunet-fs-gtk_main-window-search.c index e2970743..b79150fd 100644 --- a/src/fs/gnunet-fs-gtk_main-window-search.c +++ b/src/fs/gnunet-fs-gtk_main-window-search.c | |||
@@ -32,7 +32,8 @@ | |||
32 | /** | 32 | /** |
33 | * How long until we decide a SKS namespace GNS lookup has failed? | 33 | * How long until we decide a SKS namespace GNS lookup has failed? |
34 | */ | 34 | */ |
35 | #define LOOKUP_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2) | 35 | #define LOOKUP_TIMEOUT \ |
36 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2) | ||
36 | 37 | ||
37 | 38 | ||
38 | /** | 39 | /** |
@@ -41,11 +42,9 @@ | |||
41 | static void | 42 | static void |
42 | beep () | 43 | beep () |
43 | { | 44 | { |
44 | gdk_display_beep | 45 | gdk_display_beep (gdk_screen_get_display ( |
45 | (gdk_screen_get_display | 46 | gdk_window_get_screen (gtk_widget_get_parent_window (GTK_WIDGET ( |
46 | (gdk_window_get_screen | 47 | GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window")))))); |
47 | (gtk_widget_get_parent_window | ||
48 | (GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window")))))); | ||
49 | } | 48 | } |
50 | 49 | ||
51 | 50 | ||
@@ -56,12 +55,13 @@ beep () | |||
56 | * @param anonymity_level degree of anonymity to apply for the search | 55 | * @param anonymity_level degree of anonymity to apply for the search |
57 | */ | 56 | */ |
58 | static void | 57 | static void |
59 | search_for_uri (struct GNUNET_FS_Uri *uri, | 58 | search_for_uri (struct GNUNET_FS_Uri *uri, guint anonymity_level) |
60 | guint anonymity_level) | ||
61 | { | 59 | { |
62 | GNUNET_FS_search_start (GNUNET_FS_GTK_get_fs_handle (), | 60 | GNUNET_FS_search_start (GNUNET_FS_GTK_get_fs_handle (), |
63 | uri, anonymity_level, | 61 | uri, |
64 | GNUNET_FS_SEARCH_OPTION_NONE, NULL); | 62 | anonymity_level, |
63 | GNUNET_FS_SEARCH_OPTION_NONE, | ||
64 | NULL); | ||
65 | GNUNET_FS_uri_destroy (uri); | 65 | GNUNET_FS_uri_destroy (uri); |
66 | } | 66 | } |
67 | 67 | ||
@@ -74,11 +74,10 @@ search_for_uri (struct GNUNET_FS_Uri *uri, | |||
74 | void | 74 | void |
75 | abort_search_lookup (struct SearchLookup *sl) | 75 | abort_search_lookup (struct SearchLookup *sl) |
76 | { | 76 | { |
77 | struct GNUNET_GTK_MainWindowContext *main_ctx = GNUNET_FS_GTK_get_main_context (); | 77 | struct GNUNET_GTK_MainWindowContext *main_ctx = |
78 | GNUNET_FS_GTK_get_main_context (); | ||
78 | 79 | ||
79 | GNUNET_CONTAINER_DLL_remove (main_ctx->sl_head, | 80 | GNUNET_CONTAINER_DLL_remove (main_ctx->sl_head, main_ctx->sl_tail, sl); |
80 | main_ctx->sl_tail, | ||
81 | sl); | ||
82 | if (NULL != sl->timeout_task) | 81 | if (NULL != sl->timeout_task) |
83 | { | 82 | { |
84 | GNUNET_SCHEDULER_cancel (sl->timeout_task); | 83 | GNUNET_SCHEDULER_cancel (sl->timeout_task); |
@@ -107,7 +106,7 @@ timeout_search_lookup (void *cls) | |||
107 | 106 | ||
108 | sl->timeout_task = NULL; | 107 | sl->timeout_task = NULL; |
109 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 108 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
110 | _("Failed to resolve namespace in time\n")); | 109 | _ ("Failed to resolve namespace in time\n")); |
111 | abort_search_lookup (sl); | 110 | abort_search_lookup (sl); |
112 | } | 111 | } |
113 | 112 | ||
@@ -122,15 +121,15 @@ timeout_search_lookup (void *cls) | |||
122 | */ | 121 | */ |
123 | static void | 122 | static void |
124 | handle_gns_result (void *cls, | 123 | handle_gns_result (void *cls, |
125 | uint32_t rd_count, | 124 | uint32_t rd_count, |
126 | const struct GNUNET_GNSRECORD_Data *rd) | 125 | const struct GNUNET_GNSRECORD_Data *rd) |
127 | { | 126 | { |
128 | struct SearchLookup *sl = cls; | 127 | struct SearchLookup *sl = cls; |
129 | unsigned int i; | 128 | unsigned int i; |
130 | struct GNUNET_FS_Uri *uri; | 129 | struct GNUNET_FS_Uri *uri; |
131 | 130 | ||
132 | sl->gns = NULL; | 131 | sl->gns = NULL; |
133 | for (i=0;i<rd_count;i++) | 132 | for (i = 0; i < rd_count; i++) |
134 | { | 133 | { |
135 | if (GNUNET_GNSRECORD_TYPE_PKEY != rd[i].record_type) | 134 | if (GNUNET_GNSRECORD_TYPE_PKEY != rd[i].record_type) |
136 | continue; | 135 | continue; |
@@ -145,7 +144,7 @@ handle_gns_result (void *cls, | |||
145 | return; | 144 | return; |
146 | } | 145 | } |
147 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 146 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
148 | _("Failed to resolve namespace in time\n")); | 147 | _ ("Failed to resolve namespace in time\n")); |
149 | abort_search_lookup (sl); | 148 | abort_search_lookup (sl); |
150 | } | 149 | } |
151 | 150 | ||
@@ -168,8 +167,10 @@ start_search (struct GNUNET_GTK_MainWindowContext *main_ctx) | |||
168 | char *emsg; | 167 | char *emsg; |
169 | 168 | ||
170 | /* get anonymity level */ | 169 | /* get anonymity level */ |
171 | if (!GNUNET_GTK_get_selected_anonymity_level | 170 | if (! GNUNET_GTK_get_selected_anonymity_level ( |
172 | (main_ctx->builder, "main_window_search_anonymity_combobox", &anonymity_level)) | 171 | main_ctx->builder, |
172 | "main_window_search_anonymity_combobox", | ||
173 | &anonymity_level)) | ||
173 | { | 174 | { |
174 | GNUNET_break (0); | 175 | GNUNET_break (0); |
175 | return; | 176 | return; |
@@ -181,18 +182,18 @@ start_search (struct GNUNET_GTK_MainWindowContext *main_ctx) | |||
181 | GtkTreeModel *mime_model; | 182 | GtkTreeModel *mime_model; |
182 | GtkTreeIter iter; | 183 | GtkTreeIter iter; |
183 | 184 | ||
184 | mime_combo = GTK_COMBO_BOX (GNUNET_FS_GTK_get_main_window_object | 185 | mime_combo = GTK_COMBO_BOX (GNUNET_FS_GTK_get_main_window_object ( |
185 | ("main_window_search_mime_combobox")); | 186 | "main_window_search_mime_combobox")); |
186 | mime_model = gtk_combo_box_get_model (mime_combo); | 187 | mime_model = gtk_combo_box_get_model (mime_combo); |
187 | mime_keyword = NULL; | 188 | mime_keyword = NULL; |
188 | if ( (NULL != mime_model) && | 189 | if ((NULL != mime_model) && |
189 | gtk_combo_box_get_active_iter (mime_combo, &iter)) | 190 | gtk_combo_box_get_active_iter (mime_combo, &iter)) |
190 | gtk_tree_model_get (mime_model, &iter, | 191 | gtk_tree_model_get (mime_model, |
192 | &iter, | ||
191 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_MIME_MC_MIME, | 193 | GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_MIME_MC_MIME, |
192 | &mime_keyword, | 194 | &mime_keyword, |
193 | -1); | 195 | -1); |
194 | if ( (NULL != mime_keyword) && | 196 | if ((NULL != mime_keyword) && (0 == strcmp (mime_keyword, " "))) |
195 | (0 == strcmp (mime_keyword, " ")) ) | ||
196 | { | 197 | { |
197 | g_free (mime_keyword); | 198 | g_free (mime_keyword); |
198 | mime_keyword = NULL; | 199 | mime_keyword = NULL; |
@@ -201,13 +202,12 @@ start_search (struct GNUNET_GTK_MainWindowContext *main_ctx) | |||
201 | { | 202 | { |
202 | GtkComboBox *namespace_box; | 203 | GtkComboBox *namespace_box; |
203 | 204 | ||
204 | namespace_box = GTK_COMBO_BOX (GNUNET_FS_GTK_get_main_window_object ("main_window_search_namespace_combobox")); | 205 | namespace_box = GTK_COMBO_BOX (GNUNET_FS_GTK_get_main_window_object ( |
205 | nsid = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (namespace_box)))); | 206 | "main_window_search_namespace_combobox")); |
206 | if ( (NULL != nsid) && | 207 | nsid = gtk_entry_get_text ( |
207 | ( (0 == strcasecmp (nsid, | 208 | GTK_ENTRY (gtk_bin_get_child (GTK_BIN (namespace_box)))); |
208 | "<none>")) || | 209 | if ((NULL != nsid) && ((0 == strcasecmp (nsid, "<none>")) || |
209 | (0 == strcasecmp (nsid, | 210 | (0 == strcasecmp (nsid, _ ("<none>"))))) |
210 | _("<none>"))) ) ) | ||
211 | nsid = NULL; | 211 | nsid = NULL; |
212 | } | 212 | } |
213 | 213 | ||
@@ -218,9 +218,7 @@ start_search (struct GNUNET_GTK_MainWindowContext *main_ctx) | |||
218 | entry_keywords = gtk_entry_get_text (main_ctx->search_entry); | 218 | entry_keywords = gtk_entry_get_text (main_ctx->search_entry); |
219 | if (NULL != mime_keyword) | 219 | if (NULL != mime_keyword) |
220 | { | 220 | { |
221 | keywords = g_strdup_printf ("%s +%s", | 221 | keywords = g_strdup_printf ("%s +%s", entry_keywords, mime_keyword); |
222 | entry_keywords, | ||
223 | mime_keyword); | ||
224 | g_free (mime_keyword); | 222 | g_free (mime_keyword); |
225 | } | 223 | } |
226 | else | 224 | else |
@@ -230,26 +228,22 @@ start_search (struct GNUNET_GTK_MainWindowContext *main_ctx) | |||
230 | } | 228 | } |
231 | 229 | ||
232 | /* build KSK/SKS URI */ | 230 | /* build KSK/SKS URI */ |
233 | if ( (NULL != nsid) && | 231 | if ((NULL != nsid) && (0 < strlen (nsid))) |
234 | (0 < strlen (nsid)) ) | ||
235 | { | 232 | { |
236 | sl = GNUNET_new (struct SearchLookup); | 233 | sl = GNUNET_new (struct SearchLookup); |
237 | sl->keywords = keywords; | 234 | sl->keywords = keywords; |
238 | sl->anonymity_level = anonymity_level; | 235 | sl->anonymity_level = anonymity_level; |
239 | sl->timeout_task = GNUNET_SCHEDULER_add_delayed (LOOKUP_TIMEOUT, | 236 | sl->timeout_task = |
240 | &timeout_search_lookup, sl); | 237 | GNUNET_SCHEDULER_add_delayed (LOOKUP_TIMEOUT, &timeout_search_lookup, sl); |
241 | GNUNET_CRYPTO_ecdsa_key_get_public (main_ctx->sks_zone, | 238 | GNUNET_CRYPTO_ecdsa_key_get_public (main_ctx->sks_zone, &pub_sks_zone); |
242 | &pub_sks_zone); | ||
243 | sl->gns = GNUNET_GNS_lookup (main_ctx->gns, | 239 | sl->gns = GNUNET_GNS_lookup (main_ctx->gns, |
244 | nsid, | 240 | nsid, |
245 | &pub_sks_zone, | 241 | &pub_sks_zone, |
246 | GNUNET_GNSRECORD_TYPE_PKEY, | 242 | GNUNET_GNSRECORD_TYPE_PKEY, |
247 | GNUNET_NO, | 243 | GNUNET_NO, |
248 | &handle_gns_result, | 244 | &handle_gns_result, |
249 | sl); | 245 | sl); |
250 | GNUNET_CONTAINER_DLL_insert (main_ctx->sl_head, | 246 | GNUNET_CONTAINER_DLL_insert (main_ctx->sl_head, main_ctx->sl_tail, sl); |
251 | main_ctx->sl_tail, | ||
252 | sl); | ||
253 | return; | 247 | return; |
254 | } | 248 | } |
255 | 249 | ||
@@ -258,8 +252,9 @@ start_search (struct GNUNET_GTK_MainWindowContext *main_ctx) | |||
258 | if (NULL == uri) | 252 | if (NULL == uri) |
259 | { | 253 | { |
260 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 254 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
261 | _("Invalid keyword string `%s': %s"), | 255 | _ ("Invalid keyword string `%s': %s"), |
262 | keywords, emsg); | 256 | keywords, |
257 | emsg); | ||
263 | g_free (keywords); | 258 | g_free (keywords); |
264 | GNUNET_free_non_null (emsg); | 259 | GNUNET_free_non_null (emsg); |
265 | return; | 260 | return; |
@@ -276,8 +271,7 @@ start_search (struct GNUNET_GTK_MainWindowContext *main_ctx) | |||
276 | * @param user_data the main window context builder | 271 | * @param user_data the main window context builder |
277 | */ | 272 | */ |
278 | void | 273 | void |
279 | main_window_search_button_clicked_cb (GtkButton * button, | 274 | main_window_search_button_clicked_cb (GtkButton *button, gpointer user_data) |
280 | gpointer user_data) | ||
281 | { | 275 | { |
282 | struct GNUNET_GTK_MainWindowContext *main_ctx = user_data; | 276 | struct GNUNET_GTK_MainWindowContext *main_ctx = user_data; |
283 | 277 | ||
@@ -295,8 +289,8 @@ main_window_search_button_clicked_cb (GtkButton * button, | |||
295 | * @return FALSE if this was not ENTER, TRUE if it was | 289 | * @return FALSE if this was not ENTER, TRUE if it was |
296 | */ | 290 | */ |
297 | gboolean | 291 | gboolean |
298 | main_window_search_entry_key_press_event_cb (GtkWidget * widget, | 292 | main_window_search_entry_key_press_event_cb (GtkWidget *widget, |
299 | GdkEventKey * event, | 293 | GdkEventKey *event, |
300 | gpointer user_data) | 294 | gpointer user_data) |
301 | { | 295 | { |
302 | struct GNUNET_GTK_MainWindowContext *main_ctx = user_data; | 296 | struct GNUNET_GTK_MainWindowContext *main_ctx = user_data; |
@@ -363,11 +357,8 @@ abort_pseu_lookup (struct PseuLookupContext *lctx) | |||
363 | { | 357 | { |
364 | struct GNUNET_GTK_MainWindowContext *main_ctx = lctx->main_ctx; | 358 | struct GNUNET_GTK_MainWindowContext *main_ctx = lctx->main_ctx; |
365 | 359 | ||
366 | GNUNET_CONTAINER_DLL_remove (main_ctx->lctx_head, | 360 | GNUNET_CONTAINER_DLL_remove (main_ctx->lctx_head, main_ctx->lctx_tail, lctx); |
367 | main_ctx->lctx_tail, | 361 | (void) GNUNET_SCHEDULER_add_now (&end_pseu_lookup, lctx); |
368 | lctx); | ||
369 | (void) GNUNET_SCHEDULER_add_now (&end_pseu_lookup, | ||
370 | lctx); | ||
371 | } | 362 | } |
372 | 363 | ||
373 | 364 | ||
@@ -382,9 +373,7 @@ abort_pseu_lookup (struct PseuLookupContext *lctx) | |||
382 | * @param emsg NULL on success, otherwise an error message | 373 | * @param emsg NULL on success, otherwise an error message |
383 | */ | 374 | */ |
384 | static void | 375 | static void |
385 | store_continuation (void *cls, | 376 | store_continuation (void *cls, int32_t success, const char *emsg) |
386 | int32_t success, | ||
387 | const char *emsg) | ||
388 | { | 377 | { |
389 | struct PseuLookupContext *lctx = cls; | 378 | struct PseuLookupContext *lctx = cls; |
390 | 379 | ||
@@ -392,8 +381,8 @@ store_continuation (void *cls, | |||
392 | if (NULL != emsg) | 381 | if (NULL != emsg) |
393 | { | 382 | { |
394 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 383 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
395 | _("Failed to save record: %s\n"), | 384 | _ ("Failed to save record: %s\n"), |
396 | emsg); | 385 | emsg); |
397 | beep (); | 386 | beep (); |
398 | } | 387 | } |
399 | abort_pseu_lookup (lctx); | 388 | abort_pseu_lookup (lctx); |
@@ -407,8 +396,7 @@ store_continuation (void *cls, | |||
407 | * @param nick nickname to store the namespace under | 396 | * @param nick nickname to store the namespace under |
408 | */ | 397 | */ |
409 | static void | 398 | static void |
410 | save_pseudonym_with_nick (struct PseuLookupContext *lctx, | 399 | save_pseudonym_with_nick (struct PseuLookupContext *lctx, const char *nick) |
411 | const char *nick) | ||
412 | { | 400 | { |
413 | struct GNUNET_GNSRECORD_Data rd; | 401 | struct GNUNET_GNSRECORD_Data rd; |
414 | struct GNUNET_GTK_MainWindowContext *main_ctx; | 402 | struct GNUNET_GTK_MainWindowContext *main_ctx; |
@@ -416,14 +404,12 @@ save_pseudonym_with_nick (struct PseuLookupContext *lctx, | |||
416 | GNUNET_break (NULL == lctx->nick); | 404 | GNUNET_break (NULL == lctx->nick); |
417 | lctx->nick = GNUNET_strdup (nick); | 405 | lctx->nick = GNUNET_strdup (nick); |
418 | /* again, show progress indicator, this should be fast though... */ | 406 | /* again, show progress indicator, this should be fast though... */ |
419 | lctx->progress_dialog_builder | 407 | lctx->progress_dialog_builder = |
420 | = GNUNET_GTK_get_new_builder | 408 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_pseu_progress_dialog.glade", |
421 | ("gnunet_fs_gtk_pseu_progress_dialog.glade", | 409 | lctx); |
422 | lctx); | 410 | lctx->progress_dialog = |
423 | lctx->progress_dialog | 411 | GTK_WIDGET (gtk_builder_get_object (lctx->progress_dialog_builder, |
424 | = GTK_WIDGET (gtk_builder_get_object | 412 | "GNUNET_FS_GTK_pseu_progress_dialog")); |
425 | (lctx->progress_dialog_builder, | ||
426 | "GNUNET_FS_GTK_pseu_progress_dialog")); | ||
427 | /* show the window */ | 413 | /* show the window */ |
428 | gtk_window_present (GTK_WINDOW (lctx->progress_dialog)); | 414 | gtk_window_present (GTK_WINDOW (lctx->progress_dialog)); |
429 | memset (&rd, 0, sizeof (rd)); | 415 | memset (&rd, 0, sizeof (rd)); |
@@ -436,10 +422,12 @@ save_pseudonym_with_nick (struct PseuLookupContext *lctx, | |||
436 | lctx->namestore = GNUNET_NAMESTORE_connect (main_ctx->cfg); | 422 | lctx->namestore = GNUNET_NAMESTORE_connect (main_ctx->cfg); |
437 | GNUNET_assert (NULL != lctx->namestore); | 423 | GNUNET_assert (NULL != lctx->namestore); |
438 | lctx->qe = GNUNET_NAMESTORE_records_store (lctx->namestore, | 424 | lctx->qe = GNUNET_NAMESTORE_records_store (lctx->namestore, |
439 | main_ctx->sks_zone, | 425 | main_ctx->sks_zone, |
440 | nick, | 426 | nick, |
441 | 1, &rd, | 427 | 1, |
442 | &store_continuation, lctx); | 428 | &rd, |
429 | &store_continuation, | ||
430 | lctx); | ||
443 | } | 431 | } |
444 | 432 | ||
445 | 433 | ||
@@ -452,19 +440,18 @@ save_pseudonym_with_nick (struct PseuLookupContext *lctx, | |||
452 | * @param user_data the `struct PseuLookupContext` | 440 | * @param user_data the `struct PseuLookupContext` |
453 | */ | 441 | */ |
454 | void | 442 | void |
455 | GNUNET_GTK_enter_nick_window_execute_button_clicked_cb (GtkButton * button, | 443 | GNUNET_GTK_enter_nick_window_execute_button_clicked_cb (GtkButton *button, |
456 | gpointer user_data) | 444 | gpointer user_data) |
457 | { | 445 | { |
458 | struct PseuLookupContext *lctx = user_data; | 446 | struct PseuLookupContext *lctx = user_data; |
459 | GtkEntry *entry; | 447 | GtkEntry *entry; |
460 | const char *nick; | 448 | const char *nick; |
461 | 449 | ||
462 | entry = GTK_ENTRY (gtk_builder_get_object | 450 | entry = GTK_ENTRY ( |
463 | (lctx->nick_dialog_builder, | 451 | gtk_builder_get_object (lctx->nick_dialog_builder, |
464 | "GNUNET_GTK_enter_nick_window_nick_entry")); | 452 | "GNUNET_GTK_enter_nick_window_nick_entry")); |
465 | nick = gtk_entry_get_text (entry); | 453 | nick = gtk_entry_get_text (entry); |
466 | if ( (NULL == nick) || | 454 | if ((NULL == nick) || (0 == strlen (nick))) |
467 | (0 == strlen (nick) )) | ||
468 | { | 455 | { |
469 | GNUNET_break (0); | 456 | GNUNET_break (0); |
470 | abort_pseu_lookup (lctx); | 457 | abort_pseu_lookup (lctx); |
@@ -486,17 +473,21 @@ GNUNET_GTK_enter_nick_window_execute_button_clicked_cb (GtkButton * button, | |||
486 | */ | 473 | */ |
487 | void | 474 | void |
488 | GNUNET_GTK_enter_nick_window_nick_entry_changed_cb (GtkWidget *widget, | 475 | GNUNET_GTK_enter_nick_window_nick_entry_changed_cb (GtkWidget *widget, |
489 | gpointer user_data) | 476 | gpointer user_data) |
490 | { | 477 | { |
491 | struct PseuLookupContext *lctx = user_data; | 478 | struct PseuLookupContext *lctx = user_data; |
492 | const gchar *new_text; | 479 | const gchar *new_text; |
493 | GtkButton * button; | 480 | GtkButton *button; |
494 | 481 | ||
495 | new_text = gtk_entry_get_text (GTK_ENTRY (widget)); | 482 | new_text = gtk_entry_get_text (GTK_ENTRY (widget)); |
496 | button = GTK_BUTTON (gtk_builder_get_object (lctx->nick_dialog_builder, | 483 | button = GTK_BUTTON ( |
497 | "GNUNET_GTK_enter_nick_window_execute_button")); | 484 | gtk_builder_get_object (lctx->nick_dialog_builder, |
485 | "GNUNET_GTK_enter_nick_window_execute_button")); | ||
498 | gtk_widget_set_sensitive (GTK_WIDGET (button), | 486 | gtk_widget_set_sensitive (GTK_WIDGET (button), |
499 | (GNUNET_OK == GNUNET_DNSPARSER_check_label (new_text)) ? TRUE : FALSE); | 487 | (GNUNET_OK == |
488 | GNUNET_DNSPARSER_check_label (new_text)) | ||
489 | ? TRUE | ||
490 | : FALSE); | ||
500 | } | 491 | } |
501 | 492 | ||
502 | 493 | ||
@@ -508,8 +499,8 @@ GNUNET_GTK_enter_nick_window_nick_entry_changed_cb (GtkWidget *widget, | |||
508 | * @param user_data the `struct PseuLookupContext` | 499 | * @param user_data the `struct PseuLookupContext` |
509 | */ | 500 | */ |
510 | void | 501 | void |
511 | GNUNET_GTK_enter_nick_window_cancel_button_clicked_cb (GtkButton * button, | 502 | GNUNET_GTK_enter_nick_window_cancel_button_clicked_cb (GtkButton *button, |
512 | gpointer user_data) | 503 | gpointer user_data) |
513 | { | 504 | { |
514 | struct PseuLookupContext *lctx = user_data; | 505 | struct PseuLookupContext *lctx = user_data; |
515 | 506 | ||
@@ -527,10 +518,11 @@ static void | |||
527 | ask_for_nickname (struct PseuLookupContext *lctx) | 518 | ask_for_nickname (struct PseuLookupContext *lctx) |
528 | { | 519 | { |
529 | /* setup the dialog and get the widgets we need most */ | 520 | /* setup the dialog and get the widgets we need most */ |
530 | lctx->nick_dialog_builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_enter_nick_dialog.glade", | 521 | lctx->nick_dialog_builder = |
531 | lctx); | 522 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_enter_nick_dialog.glade", lctx); |
532 | lctx->nick_dialog = GTK_WIDGET (gtk_builder_get_object (lctx->nick_dialog_builder, | 523 | lctx->nick_dialog = |
533 | "GNUNET_GTK_enter_nick_window")); | 524 | GTK_WIDGET (gtk_builder_get_object (lctx->nick_dialog_builder, |
525 | "GNUNET_GTK_enter_nick_window")); | ||
534 | /* show the window */ | 526 | /* show the window */ |
535 | gtk_window_present (GTK_WINDOW (lctx->nick_dialog)); | 527 | gtk_window_present (GTK_WINDOW (lctx->nick_dialog)); |
536 | } | 528 | } |
@@ -548,8 +540,8 @@ ask_for_nickname (struct PseuLookupContext *lctx) | |||
548 | */ | 540 | */ |
549 | static void | 541 | static void |
550 | lookup_finished (void *cls, | 542 | lookup_finished (void *cls, |
551 | uint32_t rd_count, | 543 | uint32_t rd_count, |
552 | const struct GNUNET_GNSRECORD_Data *rd) | 544 | const struct GNUNET_GNSRECORD_Data *rd) |
553 | { | 545 | { |
554 | struct PseuLookupContext *lctx = cls; | 546 | struct PseuLookupContext *lctx = cls; |
555 | unsigned int i; | 547 | unsigned int i; |
@@ -563,18 +555,17 @@ lookup_finished (void *cls, | |||
563 | lctx->progress_dialog_builder = NULL; | 555 | lctx->progress_dialog_builder = NULL; |
564 | lctx->progress_dialog = NULL; | 556 | lctx->progress_dialog = NULL; |
565 | } | 557 | } |
566 | for (i=0;i<rd_count;i++) | 558 | for (i = 0; i < rd_count; i++) |
567 | { | 559 | { |
568 | if (GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) | 560 | if (GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) |
569 | { | 561 | { |
570 | nick = rd[i].data; | 562 | nick = rd[i].data; |
571 | if ('\0' != nick[rd[i].data_size - 1]) | 563 | if ('\0' != nick[rd[i].data_size - 1]) |
572 | { | 564 | { |
573 | GNUNET_break (0); | 565 | GNUNET_break (0); |
574 | continue; | 566 | continue; |
575 | } | 567 | } |
576 | save_pseudonym_with_nick (lctx, | 568 | save_pseudonym_with_nick (lctx, nick); |
577 | nick); | ||
578 | return; | 569 | return; |
579 | } | 570 | } |
580 | } | 571 | } |
@@ -592,7 +583,7 @@ lookup_finished (void *cls, | |||
592 | */ | 583 | */ |
593 | void | 584 | void |
594 | GNUNET_FS_GTK_pseu_progress_dialog_cancel_button_clicked_cb (GtkButton *button, | 585 | GNUNET_FS_GTK_pseu_progress_dialog_cancel_button_clicked_cb (GtkButton *button, |
595 | gpointer user_data) | 586 | gpointer user_data) |
596 | { | 587 | { |
597 | struct PseuLookupContext *lctx = user_data; | 588 | struct PseuLookupContext *lctx = user_data; |
598 | 589 | ||
@@ -620,8 +611,8 @@ GNUNET_FS_GTK_pseu_progress_dialog_cancel_button_clicked_cb (GtkButton *button, | |||
620 | */ | 611 | */ |
621 | gboolean | 612 | gboolean |
622 | GNUNET_GTK_enter_nick_window_delete_event_cb (GtkWidget *widget, | 613 | GNUNET_GTK_enter_nick_window_delete_event_cb (GtkWidget *widget, |
623 | GdkEvent * event, | 614 | GdkEvent *event, |
624 | void *cls) | 615 | void *cls) |
625 | { | 616 | { |
626 | /* Don't allow GTK to kill the window, user must click execute or cancel */ | 617 | /* Don't allow GTK to kill the window, user must click execute or cancel */ |
627 | beep (); | 618 | beep (); |
@@ -639,8 +630,8 @@ GNUNET_GTK_enter_nick_window_delete_event_cb (GtkWidget *widget, | |||
639 | */ | 630 | */ |
640 | gboolean | 631 | gboolean |
641 | GNUNET_FS_GTK_pseu_progress_dialog_delete_event_cb (GtkWidget *widget, | 632 | GNUNET_FS_GTK_pseu_progress_dialog_delete_event_cb (GtkWidget *widget, |
642 | GdkEvent * event, | 633 | GdkEvent *event, |
643 | void *cls) | 634 | void *cls) |
644 | { | 635 | { |
645 | /* Don't allow GTK to kill the window, until the search is finished */ | 636 | /* Don't allow GTK to kill the window, until the search is finished */ |
646 | beep (); | 637 | beep (); |
@@ -656,8 +647,7 @@ GNUNET_FS_GTK_pseu_progress_dialog_delete_event_cb (GtkWidget *widget, | |||
656 | * @param user_data the main window context builder | 647 | * @param user_data the main window context builder |
657 | */ | 648 | */ |
658 | void | 649 | void |
659 | GNUNET_FS_GTK_save_button_clicked_cb (GtkButton * button, | 650 | GNUNET_FS_GTK_save_button_clicked_cb (GtkButton *button, gpointer user_data) |
660 | gpointer user_data) | ||
661 | { | 651 | { |
662 | struct GNUNET_GTK_MainWindowContext *main_ctx = user_data; | 652 | struct GNUNET_GTK_MainWindowContext *main_ctx = user_data; |
663 | GtkComboBox *widget; | 653 | GtkComboBox *widget; |
@@ -673,14 +663,16 @@ GNUNET_FS_GTK_save_button_clicked_cb (GtkButton * button, | |||
673 | return; | 663 | return; |
674 | } | 664 | } |
675 | /* get anonymity level */ | 665 | /* get anonymity level */ |
676 | if (!GNUNET_GTK_get_selected_anonymity_level | 666 | if (! GNUNET_GTK_get_selected_anonymity_level ( |
677 | (main_ctx->builder, "main_window_search_anonymity_combobox", &anonymity_level)) | 667 | main_ctx->builder, |
668 | "main_window_search_anonymity_combobox", | ||
669 | &anonymity_level)) | ||
678 | { | 670 | { |
679 | GNUNET_break (0); | 671 | GNUNET_break (0); |
680 | return; | 672 | return; |
681 | } | 673 | } |
682 | widget = GTK_COMBO_BOX (GNUNET_FS_GTK_get_main_window_object | 674 | widget = GTK_COMBO_BOX (GNUNET_FS_GTK_get_main_window_object ( |
683 | ("main_window_search_namespace_combobox")); | 675 | "main_window_search_namespace_combobox")); |
684 | text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (widget)))); | 676 | text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (widget)))); |
685 | ret = GNUNET_GNSRECORD_zkey_to_pkey (text, &pkey); | 677 | ret = GNUNET_GNSRECORD_zkey_to_pkey (text, &pkey); |
686 | if (GNUNET_OK != ret) | 678 | if (GNUNET_OK != ret) |
@@ -691,26 +683,26 @@ GNUNET_FS_GTK_save_button_clicked_cb (GtkButton * button, | |||
691 | lctx = GNUNET_new (struct PseuLookupContext); | 683 | lctx = GNUNET_new (struct PseuLookupContext); |
692 | lctx->pkey = pkey; | 684 | lctx->pkey = pkey; |
693 | lctx->main_ctx = main_ctx; | 685 | lctx->main_ctx = main_ctx; |
694 | GNUNET_CONTAINER_DLL_insert (main_ctx->lctx_head, | 686 | GNUNET_CONTAINER_DLL_insert (main_ctx->lctx_head, main_ctx->lctx_tail, lctx); |
695 | main_ctx->lctx_tail, | ||
696 | lctx); | ||
697 | 687 | ||
698 | if (0 == anonymity_level) | 688 | if (0 == anonymity_level) |
699 | { | 689 | { |
700 | /* setup the dialog and get the widgets we need most */ | 690 | /* setup the dialog and get the widgets we need most */ |
701 | lctx->progress_dialog_builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_pseu_progress_dialog.glade", | 691 | lctx->progress_dialog_builder = |
702 | lctx); | 692 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_pseu_progress_dialog.glade", |
703 | lctx->progress_dialog = GTK_WIDGET (gtk_builder_get_object (lctx->progress_dialog_builder, | 693 | lctx); |
704 | "GNUNET_FS_GTK_pseu_progress_dialog")); | 694 | lctx->progress_dialog = GTK_WIDGET ( |
695 | gtk_builder_get_object (lctx->progress_dialog_builder, | ||
696 | "GNUNET_FS_GTK_pseu_progress_dialog")); | ||
705 | /* show the window */ | 697 | /* show the window */ |
706 | gtk_window_present (GTK_WINDOW (lctx->progress_dialog)); | 698 | gtk_window_present (GTK_WINDOW (lctx->progress_dialog)); |
707 | lctx->lr = GNUNET_GNS_lookup (main_ctx->gns, | 699 | lctx->lr = GNUNET_GNS_lookup (main_ctx->gns, |
708 | GNUNET_GNS_EMPTY_LABEL_AT, | 700 | GNUNET_GNS_EMPTY_LABEL_AT, |
709 | &pkey, | 701 | &pkey, |
710 | GNUNET_GNSRECORD_TYPE_NICK, | 702 | GNUNET_GNSRECORD_TYPE_NICK, |
711 | GNUNET_NO, | 703 | GNUNET_NO, |
712 | &lookup_finished, | 704 | &lookup_finished, |
713 | lctx); | 705 | lctx); |
714 | } | 706 | } |
715 | else | 707 | else |
716 | { | 708 | { |
@@ -719,8 +711,7 @@ GNUNET_FS_GTK_save_button_clicked_cb (GtkButton * button, | |||
719 | ask_for_nickname (lctx); | 711 | ask_for_nickname (lctx); |
720 | } | 712 | } |
721 | /* do not allow save again just yet */ | 713 | /* do not allow save again just yet */ |
722 | gtk_widget_set_sensitive (GTK_WIDGET (button), | 714 | gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE); |
723 | FALSE); | ||
724 | } | 715 | } |
725 | 716 | ||
726 | 717 | ||
@@ -733,7 +724,7 @@ GNUNET_FS_GTK_save_button_clicked_cb (GtkButton * button, | |||
733 | */ | 724 | */ |
734 | void | 725 | void |
735 | main_window_search_namespace_combobox_changed_cb (GtkComboBox *widget, | 726 | main_window_search_namespace_combobox_changed_cb (GtkComboBox *widget, |
736 | gpointer user_data) | 727 | gpointer user_data) |
737 | { | 728 | { |
738 | GtkButton *button; | 729 | GtkButton *button; |
739 | const gchar *text; | 730 | const gchar *text; |
@@ -742,12 +733,12 @@ main_window_search_namespace_combobox_changed_cb (GtkComboBox *widget, | |||
742 | 733 | ||
743 | text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (widget)))); | 734 | text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (widget)))); |
744 | ret = GNUNET_GNSRECORD_zkey_to_pkey (text, &pkey); | 735 | ret = GNUNET_GNSRECORD_zkey_to_pkey (text, &pkey); |
745 | button = GTK_BUTTON (GNUNET_FS_GTK_get_main_window_object | 736 | button = GTK_BUTTON ( |
746 | ("GNUNET_FS_GTK_save_button")); | 737 | GNUNET_FS_GTK_get_main_window_object ("GNUNET_FS_GTK_save_button")); |
747 | gtk_widget_set_visible (GTK_WIDGET (button), | 738 | gtk_widget_set_visible (GTK_WIDGET (button), |
748 | (GNUNET_OK == ret) ? TRUE : FALSE); | 739 | (GNUNET_OK == ret) ? TRUE : FALSE); |
749 | gtk_widget_set_sensitive (GTK_WIDGET (button), | 740 | gtk_widget_set_sensitive (GTK_WIDGET (button), |
750 | (GNUNET_OK == ret) ? TRUE : FALSE); | 741 | (GNUNET_OK == ret) ? TRUE : FALSE); |
751 | } | 742 | } |
752 | 743 | ||
753 | 744 | ||
diff --git a/src/fs/gnunet-fs-gtk_main-window-view-toggles.c b/src/fs/gnunet-fs-gtk_main-window-view-toggles.c index c2073480..3db0a1e3 100644 --- a/src/fs/gnunet-fs-gtk_main-window-view-toggles.c +++ b/src/fs/gnunet-fs-gtk_main-window-view-toggles.c | |||
@@ -35,8 +35,7 @@ | |||
35 | * @param toggle_menu name of menu entry | 35 | * @param toggle_menu name of menu entry |
36 | */ | 36 | */ |
37 | static void | 37 | static void |
38 | toggle_view (const char *toggled_widget, | 38 | toggle_view (const char *toggled_widget, const char *toggle_menu) |
39 | const char *toggle_menu) | ||
40 | { | 39 | { |
41 | GtkCheckMenuItem *mi; | 40 | GtkCheckMenuItem *mi; |
42 | GtkWidget *widget; | 41 | GtkWidget *widget; |
@@ -61,11 +60,14 @@ check_extras () | |||
61 | GtkCheckMenuItem *m2; | 60 | GtkCheckMenuItem *m2; |
62 | GtkWidget *wbox; | 61 | GtkWidget *wbox; |
63 | 62 | ||
64 | m1 = GTK_CHECK_MENU_ITEM (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_menu_view_metadata")); | 63 | m1 = GTK_CHECK_MENU_ITEM (GNUNET_FS_GTK_get_main_window_object ( |
65 | m2 = GTK_CHECK_MENU_ITEM (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_menu_view_preview")); | 64 | "GNUNET_GTK_main_menu_view_metadata")); |
66 | wbox = GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window_extras_vbox")); | 65 | m2 = GTK_CHECK_MENU_ITEM ( |
67 | if ( (gtk_check_menu_item_get_active (m1)) || | 66 | GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_menu_view_preview")); |
68 | (gtk_check_menu_item_get_active (m2)) ) | 67 | wbox = GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ( |
68 | "GNUNET_GTK_main_window_extras_vbox")); | ||
69 | if ((gtk_check_menu_item_get_active (m1)) || | ||
70 | (gtk_check_menu_item_get_active (m2))) | ||
69 | gtk_widget_show (wbox); | 71 | gtk_widget_show (wbox); |
70 | else | 72 | else |
71 | gtk_widget_hide (wbox); | 73 | gtk_widget_hide (wbox); |
@@ -79,8 +81,7 @@ check_extras () | |||
79 | * @param data main window builder (unused) | 81 | * @param data main window builder (unused) |
80 | */ | 82 | */ |
81 | void | 83 | void |
82 | GNUNET_GTK_main_menu_view_preview_toggled_cb (GtkWidget * dummy, | 84 | GNUNET_GTK_main_menu_view_preview_toggled_cb (GtkWidget *dummy, gpointer data) |
83 | gpointer data) | ||
84 | { | 85 | { |
85 | toggle_view ("GNUNET_GTK_main_window_preview_image", | 86 | toggle_view ("GNUNET_GTK_main_window_preview_image", |
86 | "GNUNET_GTK_main_menu_view_preview"); | 87 | "GNUNET_GTK_main_menu_view_preview"); |
@@ -95,13 +96,11 @@ GNUNET_GTK_main_menu_view_preview_toggled_cb (GtkWidget * dummy, | |||
95 | * @param data main window builder (unused) | 96 | * @param data main window builder (unused) |
96 | */ | 97 | */ |
97 | void | 98 | void |
98 | GNUNET_GTK_main_menu_view_metadata_toggled_cb (GtkWidget * dummy, | 99 | GNUNET_GTK_main_menu_view_metadata_toggled_cb (GtkWidget *dummy, gpointer data) |
99 | gpointer data) | ||
100 | { | 100 | { |
101 | toggle_view ("GNUNET_GTK_main_window_metadata_treeview", | 101 | toggle_view ("GNUNET_GTK_main_window_metadata_treeview", |
102 | "GNUNET_GTK_main_menu_view_metadata"); | 102 | "GNUNET_GTK_main_menu_view_metadata"); |
103 | check_extras (); | 103 | check_extras (); |
104 | |||
105 | } | 104 | } |
106 | 105 | ||
107 | 106 | ||
@@ -112,8 +111,7 @@ GNUNET_GTK_main_menu_view_metadata_toggled_cb (GtkWidget * dummy, | |||
112 | * @param data main window builder (unused) | 111 | * @param data main window builder (unused) |
113 | */ | 112 | */ |
114 | void | 113 | void |
115 | GNUNET_GTK_main_menu_view_search_toggled_cb (GtkWidget * dummy, | 114 | GNUNET_GTK_main_menu_view_search_toggled_cb (GtkWidget *dummy, gpointer data) |
116 | gpointer data) | ||
117 | { | 115 | { |
118 | toggle_view ("main_window_search_hbox", | 116 | toggle_view ("main_window_search_hbox", |
119 | "GNUNET_GTK_main_menu_search_preview"); | 117 | "GNUNET_GTK_main_menu_search_preview"); |
diff --git a/src/fs/gnunet-fs-gtk_open-directory.c b/src/fs/gnunet-fs-gtk_open-directory.c index 3c8d1f37..a83477ec 100644 --- a/src/fs/gnunet-fs-gtk_open-directory.c +++ b/src/fs/gnunet-fs-gtk_open-directory.c | |||
@@ -45,7 +45,6 @@ struct AddChildContext | |||
45 | * Anonymity level to use for probes in the directory. | 45 | * Anonymity level to use for probes in the directory. |
46 | */ | 46 | */ |
47 | uint32_t anonymity; | 47 | uint32_t anonymity; |
48 | |||
49 | }; | 48 | }; |
50 | 49 | ||
51 | 50 | ||
@@ -66,8 +65,11 @@ struct AddChildContext | |||
66 | * @param data data available for the file (@a length bytes) | 65 | * @param data data available for the file (@a length bytes) |
67 | */ | 66 | */ |
68 | static void | 67 | static void |
69 | add_child (void *cls, const char *filename, const struct GNUNET_FS_Uri *uri, | 68 | add_child (void *cls, |
70 | const struct GNUNET_CONTAINER_MetaData *meta, size_t length, | 69 | const char *filename, |
70 | const struct GNUNET_FS_Uri *uri, | ||
71 | const struct GNUNET_CONTAINER_MetaData *meta, | ||
72 | size_t length, | ||
71 | const void *data) | 73 | const void *data) |
72 | { | 74 | { |
73 | struct AddChildContext *acc = cls; | 75 | struct AddChildContext *acc = cls; |
@@ -78,13 +80,14 @@ add_child (void *cls, const char *filename, const struct GNUNET_FS_Uri *uri, | |||
78 | struct GNUNET_CONTAINER_MetaData *dmeta; | 80 | struct GNUNET_CONTAINER_MetaData *dmeta; |
79 | 81 | ||
80 | dmeta = GNUNET_CONTAINER_meta_data_duplicate (meta); | 82 | dmeta = GNUNET_CONTAINER_meta_data_duplicate (meta); |
81 | GNUNET_CONTAINER_meta_data_insert (dmeta, "<user>", | 83 | GNUNET_CONTAINER_meta_data_insert (dmeta, |
84 | "<user>", | ||
82 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, | 85 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, |
83 | EXTRACTOR_METAFORMAT_UTF8, "text/plain", | 86 | EXTRACTOR_METAFORMAT_UTF8, |
87 | "text/plain", | ||
84 | acc->filename, | 88 | acc->filename, |
85 | strlen (acc->filename) + 1); | 89 | strlen (acc->filename) + 1); |
86 | acc->sr = GNUNET_GTK_add_to_uri_tab (acc->anonymity, | 90 | acc->sr = GNUNET_GTK_add_to_uri_tab (acc->anonymity, dmeta, NULL); |
87 | dmeta, NULL); | ||
88 | GNUNET_CONTAINER_meta_data_destroy (dmeta); | 91 | GNUNET_CONTAINER_meta_data_destroy (dmeta); |
89 | return; | 92 | return; |
90 | } | 93 | } |
@@ -93,12 +96,13 @@ add_child (void *cls, const char *filename, const struct GNUNET_FS_Uri *uri, | |||
93 | GNUNET_break (0); | 96 | GNUNET_break (0); |
94 | return; | 97 | return; |
95 | } | 98 | } |
96 | GNUNET_assert (NULL != | 99 | GNUNET_assert (NULL != GNUNET_GTK_add_search_result (acc->sr->tab, |
97 | GNUNET_GTK_add_search_result (acc->sr->tab, | 100 | acc->anonymity, |
98 | acc->anonymity, | 101 | acc->sr->rr, |
99 | acc->sr->rr, | 102 | uri, |
100 | uri, | 103 | meta, |
101 | meta, NULL, 0)); | 104 | NULL, |
105 | 0)); | ||
102 | } | 106 | } |
103 | 107 | ||
104 | 108 | ||
@@ -124,12 +128,14 @@ GNUNET_GTK_open_directory_dialog_response_cb (GtkDialog *dialog, | |||
124 | g_object_unref (G_OBJECT (builder)); | 128 | g_object_unref (G_OBJECT (builder)); |
125 | return; | 129 | return; |
126 | } | 130 | } |
127 | filename = GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER (dialog)); | 131 | filename = |
132 | GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER (dialog)); | ||
128 | gtk_widget_destroy (GTK_WIDGET (dialog)); | 133 | gtk_widget_destroy (GTK_WIDGET (dialog)); |
129 | g_object_unref (G_OBJECT (builder)); | 134 | g_object_unref (G_OBJECT (builder)); |
130 | acc.filename = filename; | 135 | acc.filename = filename; |
131 | acc.sr = NULL; | 136 | acc.sr = NULL; |
132 | acc.anonymity = 1; // FIXME, might want to add this to dialog to allow user to set it. | 137 | acc.anonymity = |
138 | 1; // FIXME, might want to add this to dialog to allow user to set it. | ||
133 | GNUNET_FS_GTK_mmap_and_scan (filename, &add_child, &acc); | 139 | GNUNET_FS_GTK_mmap_and_scan (filename, &add_child, &acc); |
134 | GNUNET_free (filename); | 140 | GNUNET_free (filename); |
135 | } | 141 | } |
@@ -143,7 +149,7 @@ GNUNET_GTK_open_directory_dialog_response_cb (GtkDialog *dialog, | |||
143 | * @param data the main dialog builder, unused | 149 | * @param data the main dialog builder, unused |
144 | */ | 150 | */ |
145 | void | 151 | void |
146 | GNUNET_GTK_main_menu_file_open_gnunet_directory_activate_cb (GtkWidget * dummy, | 152 | GNUNET_GTK_main_menu_file_open_gnunet_directory_activate_cb (GtkWidget *dummy, |
147 | gpointer data) | 153 | gpointer data) |
148 | { | 154 | { |
149 | GtkWidget *ad; | 155 | GtkWidget *ad; |
@@ -152,16 +158,17 @@ GNUNET_GTK_main_menu_file_open_gnunet_directory_activate_cb (GtkWidget * dummy, | |||
152 | GtkFileFilter *ff; | 158 | GtkFileFilter *ff; |
153 | 159 | ||
154 | builder = | 160 | builder = |
155 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_open_directory_dialog.glade", NULL); | 161 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_open_directory_dialog.glade", |
162 | NULL); | ||
156 | if (NULL == builder) | 163 | if (NULL == builder) |
157 | { | 164 | { |
158 | GNUNET_break (0); | 165 | GNUNET_break (0); |
159 | return; | 166 | return; |
160 | } | 167 | } |
161 | ad = GTK_WIDGET (gtk_builder_get_object | 168 | ad = GTK_WIDGET ( |
162 | (builder, "GNUNET_GTK_open_directory_dialog")); | 169 | gtk_builder_get_object (builder, "GNUNET_GTK_open_directory_dialog")); |
163 | ff = GTK_FILE_FILTER (gtk_builder_get_object | 170 | ff = GTK_FILE_FILTER ( |
164 | (builder, "gnunet_directory_filter")); | 171 | gtk_builder_get_object (builder, "gnunet_directory_filter")); |
165 | /* FIXME-FEATURE: some day, write a custom file filter for gnunet-directories... */ | 172 | /* FIXME-FEATURE: some day, write a custom file filter for gnunet-directories... */ |
166 | gtk_file_filter_add_pattern (ff, "*" GNUNET_FS_DIRECTORY_EXT); | 173 | gtk_file_filter_add_pattern (ff, "*" GNUNET_FS_DIRECTORY_EXT); |
167 | 174 | ||
diff --git a/src/fs/gnunet-fs-gtk_open-uri.c b/src/fs/gnunet-fs-gtk_open-uri.c index 87ca0ee1..63b0105c 100644 --- a/src/fs/gnunet-fs-gtk_open-uri.c +++ b/src/fs/gnunet-fs-gtk_open-uri.c | |||
@@ -42,8 +42,7 @@ | |||
42 | * parse the URI | 42 | * parse the URI |
43 | */ | 43 | */ |
44 | int | 44 | int |
45 | GNUNET_FS_GTK_handle_uri_string (const char *uris, | 45 | GNUNET_FS_GTK_handle_uri_string (const char *uris, guint anonymity_level) |
46 | guint anonymity_level) | ||
47 | { | 46 | { |
48 | struct GNUNET_FS_Uri *uri; | 47 | struct GNUNET_FS_Uri *uri; |
49 | char *perr; | 48 | char *perr; |
@@ -66,7 +65,7 @@ GNUNET_FS_GTK_handle_uri_string (const char *uris, | |||
66 | * @param user_data the `GtkBuilder` of the URI dialog | 65 | * @param user_data the `GtkBuilder` of the URI dialog |
67 | */ | 66 | */ |
68 | void | 67 | void |
69 | GNUNET_GTK_open_url_dialog_execute_button_clicked_cb (GtkButton * button, | 68 | GNUNET_GTK_open_url_dialog_execute_button_clicked_cb (GtkButton *button, |
70 | gpointer user_data) | 69 | gpointer user_data) |
71 | { | 70 | { |
72 | GtkBuilder *builder = GTK_BUILDER (user_data); | 71 | GtkBuilder *builder = GTK_BUILDER (user_data); |
@@ -78,17 +77,18 @@ GNUNET_GTK_open_url_dialog_execute_button_clicked_cb (GtkButton * button, | |||
78 | char *uris; | 77 | char *uris; |
79 | 78 | ||
80 | dialog = | 79 | dialog = |
81 | GTK_WIDGET (gtk_builder_get_object | 80 | GTK_WIDGET (gtk_builder_get_object (builder, "GNUNET_GTK_open_url_window")); |
82 | (builder, "GNUNET_GTK_open_url_window")); | 81 | tb = GTK_TEXT_BUFFER ( |
83 | tb = GTK_TEXT_BUFFER (gtk_builder_get_object | 82 | gtk_builder_get_object (builder, |
84 | (builder, | 83 | "GNUNET_GTK_open_url_dialog_url_textview_buffer")); |
85 | "GNUNET_GTK_open_url_dialog_url_textview_buffer")); | ||
86 | gtk_text_buffer_get_iter_at_offset (tb, &ti_start, 0); | 84 | gtk_text_buffer_get_iter_at_offset (tb, &ti_start, 0); |
87 | gtk_text_buffer_get_iter_at_offset (tb, &ti_end, -1); | 85 | gtk_text_buffer_get_iter_at_offset (tb, &ti_end, -1); |
88 | 86 | ||
89 | uris = gtk_text_buffer_get_text (tb, &ti_start, &ti_end, FALSE); | 87 | uris = gtk_text_buffer_get_text (tb, &ti_start, &ti_end, FALSE); |
90 | if (!GNUNET_GTK_get_selected_anonymity_level | 88 | if (! GNUNET_GTK_get_selected_anonymity_level ( |
91 | (builder, "GNUNET_GTK_open_url_dialog_anonymity_combobox", &anonymity_level)) | 89 | builder, |
90 | "GNUNET_GTK_open_url_dialog_anonymity_combobox", | ||
91 | &anonymity_level)) | ||
92 | { | 92 | { |
93 | GNUNET_break (0); | 93 | GNUNET_break (0); |
94 | gtk_widget_destroy (dialog); | 94 | gtk_widget_destroy (dialog); |
@@ -96,7 +96,7 @@ GNUNET_GTK_open_url_dialog_execute_button_clicked_cb (GtkButton * button, | |||
96 | return; | 96 | return; |
97 | } | 97 | } |
98 | GNUNET_break (GNUNET_OK == | 98 | GNUNET_break (GNUNET_OK == |
99 | GNUNET_FS_GTK_handle_uri_string (uris, anonymity_level)); | 99 | GNUNET_FS_GTK_handle_uri_string (uris, anonymity_level)); |
100 | g_free (uris); | 100 | g_free (uris); |
101 | gtk_widget_destroy (dialog); | 101 | gtk_widget_destroy (dialog); |
102 | g_object_unref (G_OBJECT (builder)); | 102 | g_object_unref (G_OBJECT (builder)); |
@@ -110,15 +110,14 @@ GNUNET_GTK_open_url_dialog_execute_button_clicked_cb (GtkButton * button, | |||
110 | * @param user_data the 'GtkBuilder' of the URI dialog | 110 | * @param user_data the 'GtkBuilder' of the URI dialog |
111 | */ | 111 | */ |
112 | void | 112 | void |
113 | GNUNET_GTK_open_url_dialog_cancel_button_clicked_cb (GtkButton * button, | 113 | GNUNET_GTK_open_url_dialog_cancel_button_clicked_cb (GtkButton *button, |
114 | gpointer user_data) | 114 | gpointer user_data) |
115 | { | 115 | { |
116 | GtkBuilder *builder = GTK_BUILDER (user_data); | 116 | GtkBuilder *builder = GTK_BUILDER (user_data); |
117 | GtkWidget *dialog; | 117 | GtkWidget *dialog; |
118 | 118 | ||
119 | dialog = GTK_WIDGET (gtk_builder_get_object | 119 | dialog = |
120 | (builder, | 120 | GTK_WIDGET (gtk_builder_get_object (builder, "GNUNET_GTK_open_url_window")); |
121 | "GNUNET_GTK_open_url_window")); | ||
122 | gtk_widget_destroy (GTK_WIDGET (dialog)); | 121 | gtk_widget_destroy (GTK_WIDGET (dialog)); |
123 | g_object_unref (G_OBJECT (builder)); | 122 | g_object_unref (G_OBJECT (builder)); |
124 | } | 123 | } |
@@ -133,8 +132,8 @@ GNUNET_GTK_open_url_dialog_cancel_button_clicked_cb (GtkButton * button, | |||
133 | * @return FALSE (allow destruction) | 132 | * @return FALSE (allow destruction) |
134 | */ | 133 | */ |
135 | gboolean | 134 | gboolean |
136 | GNUNET_GTK_open_url_window_delete_event_cb (GtkWidget * widget, | 135 | GNUNET_GTK_open_url_window_delete_event_cb (GtkWidget *widget, |
137 | GdkEvent * event, | 136 | GdkEvent *event, |
138 | gpointer user_data) | 137 | gpointer user_data) |
139 | { | 138 | { |
140 | GtkBuilder *builder = GTK_BUILDER (user_data); | 139 | GtkBuilder *builder = GTK_BUILDER (user_data); |
@@ -153,8 +152,8 @@ GNUNET_GTK_open_url_window_delete_event_cb (GtkWidget * widget, | |||
153 | * @param user_data the 'GtkBuilder' of the URI dialog | 152 | * @param user_data the 'GtkBuilder' of the URI dialog |
154 | */ | 153 | */ |
155 | gboolean | 154 | gboolean |
156 | GNUNET_GTK_open_url_dialog_url_textview_key_press_event_cb (GtkWidget * widget, | 155 | GNUNET_GTK_open_url_dialog_url_textview_key_press_event_cb (GtkWidget *widget, |
157 | GdkEventKey * event, | 156 | GdkEventKey *event, |
158 | gpointer user_data) | 157 | gpointer user_data) |
159 | { | 158 | { |
160 | GtkBuilder *builder = GTK_BUILDER (user_data); | 159 | GtkBuilder *builder = GTK_BUILDER (user_data); |
@@ -162,11 +161,12 @@ GNUNET_GTK_open_url_dialog_url_textview_key_press_event_cb (GtkWidget * widget, | |||
162 | 161 | ||
163 | if (event->keyval != GDK_KEY_Return) | 162 | if (event->keyval != GDK_KEY_Return) |
164 | return FALSE; | 163 | return FALSE; |
165 | execute = GTK_WIDGET (gtk_builder_get_object (builder, | 164 | execute = GTK_WIDGET ( |
166 | "GNUNET_GTK_open_url_dialog_execute_button")); | 165 | gtk_builder_get_object (builder, |
166 | "GNUNET_GTK_open_url_dialog_execute_button")); | ||
167 | if (gtk_widget_get_sensitive (execute)) | 167 | if (gtk_widget_get_sensitive (execute)) |
168 | GNUNET_GTK_open_url_dialog_execute_button_clicked_cb (GTK_BUTTON (execute), | 168 | GNUNET_GTK_open_url_dialog_execute_button_clicked_cb (GTK_BUTTON (execute), |
169 | user_data); | 169 | user_data); |
170 | return TRUE; | 170 | return TRUE; |
171 | } | 171 | } |
172 | 172 | ||
@@ -179,9 +179,9 @@ GNUNET_GTK_open_url_dialog_url_textview_key_press_event_cb (GtkWidget * widget, | |||
179 | * @param user_data the 'GtkBuilder' of the URI dialog | 179 | * @param user_data the 'GtkBuilder' of the URI dialog |
180 | */ | 180 | */ |
181 | void | 181 | void |
182 | GNUNET_GTK_open_url_dialog_url_textview_buffer_changed_cb (GtkTextBuffer * | 182 | GNUNET_GTK_open_url_dialog_url_textview_buffer_changed_cb ( |
183 | textbuffer, | 183 | GtkTextBuffer *textbuffer, |
184 | gpointer user_data) | 184 | gpointer user_data) |
185 | { | 185 | { |
186 | GtkBuilder *builder = GTK_BUILDER (user_data); | 186 | GtkBuilder *builder = GTK_BUILDER (user_data); |
187 | struct GNUNET_FS_Uri *uri; | 187 | struct GNUNET_FS_Uri *uri; |
@@ -192,9 +192,9 @@ GNUNET_GTK_open_url_dialog_url_textview_buffer_changed_cb (GtkTextBuffer * | |||
192 | char *uris; | 192 | char *uris; |
193 | 193 | ||
194 | perr = NULL; | 194 | perr = NULL; |
195 | tb = GTK_TEXT_BUFFER (gtk_builder_get_object | 195 | tb = GTK_TEXT_BUFFER ( |
196 | (builder, | 196 | gtk_builder_get_object (builder, |
197 | "GNUNET_GTK_open_url_dialog_url_textview_buffer")); | 197 | "GNUNET_GTK_open_url_dialog_url_textview_buffer")); |
198 | gtk_text_buffer_get_iter_at_offset (tb, &ti_start, 0); | 198 | gtk_text_buffer_get_iter_at_offset (tb, &ti_start, 0); |
199 | gtk_text_buffer_get_iter_at_offset (tb, &ti_end, -1); | 199 | gtk_text_buffer_get_iter_at_offset (tb, &ti_end, -1); |
200 | uris = gtk_text_buffer_get_text (tb, &ti_start, &ti_end, FALSE); | 200 | uris = gtk_text_buffer_get_text (tb, &ti_start, &ti_end, FALSE); |
@@ -203,9 +203,8 @@ GNUNET_GTK_open_url_dialog_url_textview_buffer_changed_cb (GtkTextBuffer * | |||
203 | else | 203 | else |
204 | uri = NULL; | 204 | uri = NULL; |
205 | g_free (uris); | 205 | g_free (uris); |
206 | gtk_widget_set_sensitive (GTK_WIDGET | 206 | gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object ( |
207 | (gtk_builder_get_object | 207 | builder, |
208 | (builder, | ||
209 | "GNUNET_GTK_open_url_dialog_execute_button")), | 208 | "GNUNET_GTK_open_url_dialog_execute_button")), |
210 | (uri == NULL) ? FALSE : TRUE); | 209 | (uri == NULL) ? FALSE : TRUE); |
211 | if (uri != NULL) | 210 | if (uri != NULL) |
@@ -221,7 +220,7 @@ GNUNET_GTK_open_url_dialog_url_textview_buffer_changed_cb (GtkTextBuffer * | |||
221 | * @param user_data unused | 220 | * @param user_data unused |
222 | */ | 221 | */ |
223 | void | 222 | void |
224 | GNUNET_GTK_main_menu_file_download_uri_activate_cb (GtkWidget * dummy, | 223 | GNUNET_GTK_main_menu_file_download_uri_activate_cb (GtkWidget *dummy, |
225 | gpointer user_data) | 224 | gpointer user_data) |
226 | { | 225 | { |
227 | GtkBuilder *builder; | 226 | GtkBuilder *builder; |
@@ -239,22 +238,22 @@ GNUNET_GTK_main_menu_file_download_uri_activate_cb (GtkWidget * dummy, | |||
239 | GNUNET_break (0); | 238 | GNUNET_break (0); |
240 | return; | 239 | return; |
241 | } | 240 | } |
242 | dialog = GTK_WIDGET (gtk_builder_get_object | 241 | dialog = |
243 | (builder, | 242 | GTK_WIDGET (gtk_builder_get_object (builder, "GNUNET_GTK_open_url_window")); |
244 | "GNUNET_GTK_open_url_window")); | 243 | tb = GTK_TEXT_BUFFER ( |
245 | tb = GTK_TEXT_BUFFER (gtk_builder_get_object | 244 | gtk_builder_get_object (builder, |
246 | (builder, | 245 | "GNUNET_GTK_open_url_dialog_url_textview_buffer")); |
247 | "GNUNET_GTK_open_url_dialog_url_textview_buffer")); | ||
248 | gtk_text_buffer_get_iter_at_offset (tb, &ti_start, 0); | 246 | gtk_text_buffer_get_iter_at_offset (tb, &ti_start, 0); |
249 | gtk_text_buffer_get_iter_at_offset (tb, &ti_end, -1); | 247 | gtk_text_buffer_get_iter_at_offset (tb, &ti_end, -1); |
250 | gtk_text_buffer_delete (tb, &ti_start, &ti_end); | 248 | gtk_text_buffer_delete (tb, &ti_start, &ti_end); |
251 | 249 | ||
252 | /* FIXME-FEATURE: query the clipboard, maybe there's valid URI in there? | 250 | /* FIXME-FEATURE: query the clipboard, maybe there's valid URI in there? |
253 | * If so, get it. */ | 251 | * If so, get it. */ |
254 | combo = GTK_COMBO_BOX (gtk_builder_get_object | 252 | combo = GTK_COMBO_BOX ( |
255 | (builder, | 253 | gtk_builder_get_object (builder, |
256 | "GNUNET_GTK_open_url_dialog_anonymity_combobox")); | 254 | "GNUNET_GTK_open_url_dialog_anonymity_combobox")); |
257 | gtk_combo_box_set_model (combo, GNUNET_FS_GTK_get_anonymity_level_list_store ()); | 255 | gtk_combo_box_set_model (combo, |
256 | GNUNET_FS_GTK_get_anonymity_level_list_store ()); | ||
258 | toplevel = gtk_widget_get_toplevel (dummy); | 257 | toplevel = gtk_widget_get_toplevel (dummy); |
259 | if (GTK_IS_WINDOW (toplevel)) | 258 | if (GTK_IS_WINDOW (toplevel)) |
260 | gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (toplevel)); | 259 | gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (toplevel)); |
diff --git a/src/fs/gnunet-fs-gtk_open-uri.h b/src/fs/gnunet-fs-gtk_open-uri.h index edb6cf53..3bb27389 100644 --- a/src/fs/gnunet-fs-gtk_open-uri.h +++ b/src/fs/gnunet-fs-gtk_open-uri.h | |||
@@ -36,7 +36,6 @@ | |||
36 | * #GNUNET_SYSERR if we failed to parse the URI | 36 | * #GNUNET_SYSERR if we failed to parse the URI |
37 | */ | 37 | */ |
38 | int | 38 | int |
39 | GNUNET_FS_GTK_handle_uri_string (const char *uris, | 39 | GNUNET_FS_GTK_handle_uri_string (const char *uris, guint anonymity_level); |
40 | guint anonymity_level); | ||
41 | 40 | ||
42 | #endif | 41 | #endif |
diff --git a/src/fs/gnunet-fs-gtk_publish-dialog.c b/src/fs/gnunet-fs-gtk_publish-dialog.c index c696afa5..bcd10d30 100644 --- a/src/fs/gnunet-fs-gtk_publish-dialog.c +++ b/src/fs/gnunet-fs-gtk_publish-dialog.c | |||
@@ -40,7 +40,8 @@ | |||
40 | /** | 40 | /** |
41 | * Columns in the publish model. | 41 | * Columns in the publish model. |
42 | */ | 42 | */ |
43 | enum PUBLISH_ModelColumns { | 43 | enum PUBLISH_ModelColumns |
44 | { | ||
44 | /** | 45 | /** |
45 | * A gchararray. | 46 | * A gchararray. |
46 | */ | 47 | */ |
@@ -85,7 +86,8 @@ enum PUBLISH_ModelColumns { | |||
85 | /** | 86 | /** |
86 | * Columns in the identifiers model. | 87 | * Columns in the identifiers model. |
87 | */ | 88 | */ |
88 | enum IDENTIFIERS_ModelColumns { | 89 | enum IDENTIFIERS_ModelColumns |
90 | { | ||
89 | /** | 91 | /** |
90 | * A gchararray. | 92 | * A gchararray. |
91 | */ | 93 | */ |
@@ -115,7 +117,8 @@ enum IDENTIFIERS_ModelColumns { | |||
115 | /** | 117 | /** |
116 | * The columns in the "GNUNET_GTK_master_publish_dialog_ego_liststore" | 118 | * The columns in the "GNUNET_GTK_master_publish_dialog_ego_liststore" |
117 | */ | 119 | */ |
118 | enum EGO_ModelColumns { | 120 | enum EGO_ModelColumns |
121 | { | ||
119 | 122 | ||
120 | /** | 123 | /** |
121 | * A gchararray. | 124 | * A gchararray. |
@@ -137,7 +140,8 @@ struct AddDirClientContext; | |||
137 | /** | 140 | /** |
138 | * Main handle of the dialog for a publish operation. | 141 | * Main handle of the dialog for a publish operation. |
139 | */ | 142 | */ |
140 | struct MainPublishingDialogContext { | 143 | struct MainPublishingDialogContext |
144 | { | ||
141 | 145 | ||
142 | /** | 146 | /** |
143 | * Main builder for the publishing dialog. | 147 | * Main builder for the publishing dialog. |
@@ -318,7 +322,8 @@ struct MainPublishingDialogContext { | |||
318 | /** | 322 | /** |
319 | * Context we create when we are scanning a directory. | 323 | * Context we create when we are scanning a directory. |
320 | */ | 324 | */ |
321 | struct AddDirClientContext { | 325 | struct AddDirClientContext |
326 | { | ||
322 | /** | 327 | /** |
323 | * This is a doubly-linked list. | 328 | * This is a doubly-linked list. |
324 | */ | 329 | */ |
@@ -398,7 +403,8 @@ struct AddDirClientContext { | |||
398 | unsigned int total; | 403 | unsigned int total; |
399 | }; | 404 | }; |
400 | 405 | ||
401 | static void clear_keywords_from_tm(struct MainPublishingDialogContext *ctx); | 406 | static void |
407 | clear_keywords_from_tm (struct MainPublishingDialogContext *ctx); | ||
402 | 408 | ||
403 | /* ************************ editing operations inside the master dialog ***** */ | 409 | /* ************************ editing operations inside the master dialog ***** */ |
404 | 410 | ||
@@ -410,17 +416,18 @@ static void clear_keywords_from_tm(struct MainPublishingDialogContext *ctx); | |||
410 | * @param i2 second iterator | 416 | * @param i2 second iterator |
411 | * @return #GNUNET_YES if they are equal | 417 | * @return #GNUNET_YES if they are equal |
412 | */ | 418 | */ |
413 | static int gtk_tree_iter_equals(GtkTreeModel *tm, GtkTreeIter *i1, | 419 | static int |
414 | GtkTreeIter *i2) { | 420 | gtk_tree_iter_equals (GtkTreeModel *tm, GtkTreeIter *i1, GtkTreeIter *i2) |
421 | { | ||
415 | GtkTreePath *p1; | 422 | GtkTreePath *p1; |
416 | GtkTreePath *p2; | 423 | GtkTreePath *p2; |
417 | int ret; | 424 | int ret; |
418 | 425 | ||
419 | p1 = gtk_tree_model_get_path(tm, i1); | 426 | p1 = gtk_tree_model_get_path (tm, i1); |
420 | p2 = gtk_tree_model_get_path(tm, i2); | 427 | p2 = gtk_tree_model_get_path (tm, i2); |
421 | ret = gtk_tree_path_compare(p1, p2); | 428 | ret = gtk_tree_path_compare (p1, p2); |
422 | gtk_tree_path_free(p1); | 429 | gtk_tree_path_free (p1); |
423 | gtk_tree_path_free(p2); | 430 | gtk_tree_path_free (p2); |
424 | return (0 == ret) ? GNUNET_YES : GNUNET_NO; | 431 | return (0 == ret) ? GNUNET_YES : GNUNET_NO; |
425 | } | 432 | } |
426 | 433 | ||
@@ -430,7 +437,8 @@ static int gtk_tree_iter_equals(GtkTreeModel *tm, GtkTreeIter *i1, | |||
430 | * @param ctx master dialog to update selectivity for | 437 | * @param ctx master dialog to update selectivity for |
431 | */ | 438 | */ |
432 | static void | 439 | static void |
433 | update_selectivity_execute_cancel(struct MainPublishingDialogContext *ctx) { | 440 | update_selectivity_execute_cancel (struct MainPublishingDialogContext *ctx) |
441 | { | ||
434 | gboolean pub_in_global; | 442 | gboolean pub_in_global; |
435 | gboolean pub_in_own; | 443 | gboolean pub_in_own; |
436 | gboolean updateable; | 444 | gboolean updateable; |
@@ -438,32 +446,32 @@ update_selectivity_execute_cancel(struct MainPublishingDialogContext *ctx) { | |||
438 | GtkTreeIter iter; | 446 | GtkTreeIter iter; |
439 | 447 | ||
440 | pub_in_global = | 448 | pub_in_global = |
441 | gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ctx->global_checkbox)); | 449 | gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ctx->global_checkbox)); |
442 | pub_in_own = | 450 | pub_in_own = |
443 | gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ctx->own_checkbox)); | 451 | gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ctx->own_checkbox)); |
444 | updateable = | 452 | updateable = |
445 | gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ctx->updateable_checkbox)); | 453 | gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ctx->updateable_checkbox)); |
446 | gtk_widget_set_sensitive(ctx->update_id_hbox, updateable); | 454 | gtk_widget_set_sensitive (ctx->update_id_hbox, updateable); |
447 | gtk_widget_set_sensitive(ctx->own_vbox, pub_in_own); | 455 | gtk_widget_set_sensitive (ctx->own_vbox, pub_in_own); |
448 | 456 | ||
449 | ns_id = gtk_entry_get_text(GTK_ENTRY(ctx->identifier_entry)); | 457 | ns_id = gtk_entry_get_text (GTK_ENTRY (ctx->identifier_entry)); |
450 | 458 | ||
451 | /* Don't let the user close the dialog until all scanners are finished and | 459 | /* Don't let the user close the dialog until all scanners are finished and |
452 | their windows are closed */ | 460 | their windows are closed */ |
453 | if ((gtk_tree_model_get_iter_first(ctx->file_info_treemodel, &iter)) && | 461 | if ((gtk_tree_model_get_iter_first (ctx->file_info_treemodel, &iter)) && |
454 | (pub_in_global || pub_in_own) && | 462 | (pub_in_global || pub_in_own) && |
455 | ((!pub_in_own) || | 463 | ((! pub_in_own) || |
456 | ((NULL != ctx->ns) && (NULL != ns_id) && ('\0' != ns_id[0]))) && | 464 | ((NULL != ctx->ns) && (NULL != ns_id) && ('\0' != ns_id[0]))) && |
457 | (NULL == ctx->adddir_head)) | 465 | (NULL == ctx->adddir_head)) |
458 | gtk_widget_set_sensitive(ctx->execute_button, TRUE); | 466 | gtk_widget_set_sensitive (ctx->execute_button, TRUE); |
459 | else | 467 | else |
460 | gtk_widget_set_sensitive(ctx->execute_button, FALSE); | 468 | gtk_widget_set_sensitive (ctx->execute_button, FALSE); |
461 | 469 | ||
462 | /* if an 'edit' operation is open, don't even allow "cancel" */ | 470 | /* if an 'edit' operation is open, don't even allow "cancel" */ |
463 | if (ctx->adddir_head == NULL) | 471 | if (ctx->adddir_head == NULL) |
464 | gtk_widget_set_sensitive(ctx->cancel_button, TRUE); | 472 | gtk_widget_set_sensitive (ctx->cancel_button, TRUE); |
465 | else | 473 | else |
466 | gtk_widget_set_sensitive(ctx->cancel_button, FALSE); | 474 | gtk_widget_set_sensitive (ctx->cancel_button, FALSE); |
467 | } | 475 | } |
468 | 476 | ||
469 | /** | 477 | /** |
@@ -471,61 +479,71 @@ update_selectivity_execute_cancel(struct MainPublishingDialogContext *ctx) { | |||
471 | * | 479 | * |
472 | * @param ctx master dialog to update selectivity for | 480 | * @param ctx master dialog to update selectivity for |
473 | */ | 481 | */ |
474 | static void update_selectivity_edit(struct MainPublishingDialogContext *ctx) { | 482 | static void |
483 | update_selectivity_edit (struct MainPublishingDialogContext *ctx) | ||
484 | { | ||
475 | GtkTreeIter iter; | 485 | GtkTreeIter iter; |
476 | GtkTreeIter parent; | 486 | GtkTreeIter parent; |
477 | GtkTreeIter pred; | 487 | GtkTreeIter pred; |
478 | int is_dir; | 488 | int is_dir; |
479 | struct GNUNET_FS_FileInformation *fip; | 489 | struct GNUNET_FS_FileInformation *fip; |
480 | 490 | ||
481 | if (!gtk_tree_selection_get_selected(ctx->file_info_selection, NULL, &iter)) { | 491 | if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, &iter)) |
482 | gtk_widget_set_sensitive(ctx->up_button, FALSE); | 492 | { |
483 | gtk_widget_set_sensitive(ctx->down_button, FALSE); | 493 | gtk_widget_set_sensitive (ctx->up_button, FALSE); |
484 | gtk_widget_set_sensitive(ctx->left_button, FALSE); | 494 | gtk_widget_set_sensitive (ctx->down_button, FALSE); |
485 | gtk_widget_set_sensitive(ctx->right_button, FALSE); | 495 | gtk_widget_set_sensitive (ctx->left_button, FALSE); |
486 | gtk_widget_set_sensitive(ctx->delete_button, FALSE); | 496 | gtk_widget_set_sensitive (ctx->right_button, FALSE); |
487 | gtk_widget_set_sensitive(ctx->edit_button, FALSE); | 497 | gtk_widget_set_sensitive (ctx->delete_button, FALSE); |
498 | gtk_widget_set_sensitive (ctx->edit_button, FALSE); | ||
488 | return; | 499 | return; |
489 | } | 500 | } |
490 | gtk_widget_set_sensitive(ctx->delete_button, TRUE); | 501 | gtk_widget_set_sensitive (ctx->delete_button, TRUE); |
491 | gtk_widget_set_sensitive(ctx->edit_button, TRUE); | 502 | gtk_widget_set_sensitive (ctx->edit_button, TRUE); |
492 | 503 | ||
493 | /* figure out which move operations are currently legal */ | 504 | /* figure out which move operations are currently legal */ |
494 | GNUNET_assert( | 505 | GNUNET_assert ( |
495 | gtk_tree_selection_get_selected(ctx->file_info_selection, NULL, &iter)); | 506 | gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, &iter)); |
496 | if (gtk_tree_model_iter_next(ctx->file_info_treemodel, &iter)) | 507 | if (gtk_tree_model_iter_next (ctx->file_info_treemodel, &iter)) |
497 | gtk_widget_set_sensitive(ctx->down_button, TRUE); | 508 | gtk_widget_set_sensitive (ctx->down_button, TRUE); |
509 | else | ||
510 | gtk_widget_set_sensitive (ctx->down_button, FALSE); | ||
511 | GNUNET_assert ( | ||
512 | gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, &iter)); | ||
513 | if (gtk_tree_model_iter_parent (ctx->file_info_treemodel, &parent, &iter)) | ||
514 | { | ||
515 | gtk_widget_set_sensitive (ctx->left_button, TRUE); | ||
516 | GNUNET_assert ( | ||
517 | gtk_tree_model_iter_children (ctx->file_info_treemodel, &pred, &parent)); | ||
518 | } | ||
498 | else | 519 | else |
499 | gtk_widget_set_sensitive(ctx->down_button, FALSE); | 520 | { |
500 | GNUNET_assert( | 521 | gtk_widget_set_sensitive (ctx->left_button, FALSE); |
501 | gtk_tree_selection_get_selected(ctx->file_info_selection, NULL, &iter)); | 522 | GNUNET_assert ( |
502 | if (gtk_tree_model_iter_parent(ctx->file_info_treemodel, &parent, &iter)) { | 523 | gtk_tree_model_get_iter_first (ctx->file_info_treemodel, &pred)); |
503 | gtk_widget_set_sensitive(ctx->left_button, TRUE); | ||
504 | GNUNET_assert( | ||
505 | gtk_tree_model_iter_children(ctx->file_info_treemodel, &pred, &parent)); | ||
506 | } else { | ||
507 | gtk_widget_set_sensitive(ctx->left_button, FALSE); | ||
508 | GNUNET_assert( | ||
509 | gtk_tree_model_get_iter_first(ctx->file_info_treemodel, &pred)); | ||
510 | } | 524 | } |
511 | /* iterate over 'next' of pred to find out if our | 525 | /* iterate over 'next' of pred to find out if our |
512 | * predecessor is a directory! */ | 526 | * predecessor is a directory! */ |
513 | is_dir = GNUNET_SYSERR; | 527 | is_dir = GNUNET_SYSERR; |
514 | while (GNUNET_YES != | 528 | while (GNUNET_YES != |
515 | gtk_tree_iter_equals(ctx->file_info_treemodel, &pred, &iter)) { | 529 | gtk_tree_iter_equals (ctx->file_info_treemodel, &pred, &iter)) |
516 | gtk_tree_model_get(ctx->file_info_treemodel, &pred, | 530 | { |
517 | PUBLISH_MC_FILE_INFORMATION_STRUCT, &fip, -1); | 531 | gtk_tree_model_get (ctx->file_info_treemodel, |
518 | is_dir = GNUNET_FS_file_information_is_directory(fip); | 532 | &pred, |
519 | GNUNET_assert(gtk_tree_model_iter_next(ctx->file_info_treemodel, &pred)); | 533 | PUBLISH_MC_FILE_INFORMATION_STRUCT, |
534 | &fip, | ||
535 | -1); | ||
536 | is_dir = GNUNET_FS_file_information_is_directory (fip); | ||
537 | GNUNET_assert (gtk_tree_model_iter_next (ctx->file_info_treemodel, &pred)); | ||
520 | } | 538 | } |
521 | if (GNUNET_YES == is_dir) | 539 | if (GNUNET_YES == is_dir) |
522 | gtk_widget_set_sensitive(ctx->right_button, TRUE); | 540 | gtk_widget_set_sensitive (ctx->right_button, TRUE); |
523 | else | 541 | else |
524 | gtk_widget_set_sensitive(ctx->right_button, FALSE); | 542 | gtk_widget_set_sensitive (ctx->right_button, FALSE); |
525 | if (GNUNET_SYSERR != is_dir) | 543 | if (GNUNET_SYSERR != is_dir) |
526 | gtk_widget_set_sensitive(ctx->up_button, TRUE); | 544 | gtk_widget_set_sensitive (ctx->up_button, TRUE); |
527 | else | 545 | else |
528 | gtk_widget_set_sensitive(ctx->up_button, FALSE); | 546 | gtk_widget_set_sensitive (ctx->up_button, FALSE); |
529 | } | 547 | } |
530 | 548 | ||
531 | /** | 549 | /** |
@@ -535,11 +553,14 @@ static void update_selectivity_edit(struct MainPublishingDialogContext *ctx) { | |||
535 | * @param ts the changed selection | 553 | * @param ts the changed selection |
536 | * @param user_data master publishing dialog context of our window | 554 | * @param user_data master publishing dialog context of our window |
537 | */ | 555 | */ |
538 | void GNUNET_GTK_master_publish_dialog_file_informatino_treeview_selection_changed_cb( | 556 | void |
539 | GtkTreeSelection *ts, gpointer user_data) { | 557 | GNUNET_GTK_master_publish_dialog_file_informatino_treeview_selection_changed_cb ( |
558 | GtkTreeSelection *ts, | ||
559 | gpointer user_data) | ||
560 | { | ||
540 | struct MainPublishingDialogContext *ctx = user_data; | 561 | struct MainPublishingDialogContext *ctx = user_data; |
541 | 562 | ||
542 | update_selectivity_edit(ctx); | 563 | update_selectivity_edit (ctx); |
543 | } | 564 | } |
544 | 565 | ||
545 | /** | 566 | /** |
@@ -551,39 +572,63 @@ void GNUNET_GTK_master_publish_dialog_file_informatino_treeview_selection_change | |||
551 | * @param iter parent entry, or NULL for top-level addition | 572 | * @param iter parent entry, or NULL for top-level addition |
552 | * @param pos iterator to set to the location of the new element | 573 | * @param pos iterator to set to the location of the new element |
553 | */ | 574 | */ |
554 | static void create_dir_at_iter(struct MainPublishingDialogContext *ctx, | 575 | static void |
555 | const char *name, | 576 | create_dir_at_iter (struct MainPublishingDialogContext *ctx, |
556 | const struct GNUNET_FS_BlockOptions *bo, | 577 | const char *name, |
557 | GtkTreeIter *iter, GtkTreeIter *pos) { | 578 | const struct GNUNET_FS_BlockOptions *bo, |
579 | GtkTreeIter *iter, | ||
580 | GtkTreeIter *pos) | ||
581 | { | ||
558 | struct GNUNET_FS_FileInformation *fi; | 582 | struct GNUNET_FS_FileInformation *fi; |
559 | GtkTreeRowReference *row_reference; | 583 | GtkTreeRowReference *row_reference; |
560 | GtkTreePath *path; | 584 | GtkTreePath *path; |
561 | struct GNUNET_CONTAINER_MetaData *meta; | 585 | struct GNUNET_CONTAINER_MetaData *meta; |
562 | 586 | ||
563 | meta = GNUNET_CONTAINER_meta_data_create(); | 587 | meta = GNUNET_CONTAINER_meta_data_create (); |
564 | GNUNET_FS_meta_data_make_directory(meta); | 588 | GNUNET_FS_meta_data_make_directory (meta); |
565 | GNUNET_CONTAINER_meta_data_insert( | 589 | GNUNET_CONTAINER_meta_data_insert (meta, |
566 | meta, "<gnunet-gtk>", EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, | 590 | "<gnunet-gtk>", |
567 | EXTRACTOR_METAFORMAT_UTF8, "text/plain", name, strlen(name) + 1); | 591 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, |
568 | gtk_tree_store_insert_before(GTK_TREE_STORE(ctx->file_info_treemodel), pos, | 592 | EXTRACTOR_METAFORMAT_UTF8, |
569 | iter, NULL); | 593 | "text/plain", |
570 | path = gtk_tree_model_get_path(ctx->file_info_treemodel, pos); | 594 | name, |
571 | row_reference = gtk_tree_row_reference_new(ctx->file_info_treemodel, path); | 595 | strlen (name) + 1); |
572 | gtk_tree_path_free(path); | 596 | gtk_tree_store_insert_before (GTK_TREE_STORE (ctx->file_info_treemodel), |
573 | fi = GNUNET_FS_file_information_create_empty_directory( | 597 | pos, |
574 | GNUNET_FS_GTK_get_fs_handle(), row_reference, NULL, meta, bo, name); | 598 | iter, |
575 | GNUNET_CONTAINER_meta_data_destroy(meta); | 599 | NULL); |
576 | gtk_tree_store_set( | 600 | path = gtk_tree_model_get_path (ctx->file_info_treemodel, pos); |
577 | GTK_TREE_STORE(ctx->file_info_treemodel), pos, PUBLISH_MC_FILESIZE, | 601 | row_reference = gtk_tree_row_reference_new (ctx->file_info_treemodel, path); |
578 | MARKER_DIR_FILE_SIZE, PUBLISH_MC_DO_INDEX, (gboolean)GNUNET_NO, | 602 | gtk_tree_path_free (path); |
579 | PUBLISH_MC_FILENAME, name, PUBLISH_MC_ANONYMITY_LEVEL, | 603 | fi = GNUNET_FS_file_information_create_empty_directory ( |
580 | (guint)bo->anonymity_level, PUBLISH_MC_PRIORITY, | 604 | GNUNET_FS_GTK_get_fs_handle (), |
581 | (guint)bo->content_priority, PUBLISH_MC_FILE_INFORMATION_STRUCT, fi, | 605 | row_reference, |
582 | PUBLISH_MC_EXPIRATION_TIME_ABSOLUTE, | 606 | NULL, |
583 | (guint64)bo->expiration_time.abs_value_us, PUBLISH_MC_REPLICATION_LEVEL, | 607 | meta, |
584 | (guint)bo->replication_level, -1); | 608 | bo, |
585 | update_selectivity_edit(ctx); | 609 | name); |
586 | update_selectivity_execute_cancel(ctx); | 610 | GNUNET_CONTAINER_meta_data_destroy (meta); |
611 | gtk_tree_store_set (GTK_TREE_STORE (ctx->file_info_treemodel), | ||
612 | pos, | ||
613 | PUBLISH_MC_FILESIZE, | ||
614 | MARKER_DIR_FILE_SIZE, | ||
615 | PUBLISH_MC_DO_INDEX, | ||
616 | (gboolean) GNUNET_NO, | ||
617 | PUBLISH_MC_FILENAME, | ||
618 | name, | ||
619 | PUBLISH_MC_ANONYMITY_LEVEL, | ||
620 | (guint) bo->anonymity_level, | ||
621 | PUBLISH_MC_PRIORITY, | ||
622 | (guint) bo->content_priority, | ||
623 | PUBLISH_MC_FILE_INFORMATION_STRUCT, | ||
624 | fi, | ||
625 | PUBLISH_MC_EXPIRATION_TIME_ABSOLUTE, | ||
626 | (guint64) bo->expiration_time.abs_value_us, | ||
627 | PUBLISH_MC_REPLICATION_LEVEL, | ||
628 | (guint) bo->replication_level, | ||
629 | -1); | ||
630 | update_selectivity_edit (ctx); | ||
631 | update_selectivity_execute_cancel (ctx); | ||
587 | } | 632 | } |
588 | 633 | ||
589 | /** | 634 | /** |
@@ -601,9 +646,13 @@ static void create_dir_at_iter(struct MainPublishingDialogContext *ctx, | |||
601 | * we ensure that the tree view is expanded to cover | 646 | * we ensure that the tree view is expanded to cover |
602 | * the element; the element is also then selected | 647 | * the element; the element is also then selected |
603 | */ | 648 | */ |
604 | static void copy_entry(struct MainPublishingDialogContext *ctx, | 649 | static void |
605 | GtkTreeModel *tm, GtkTreeIter *old, GtkTreeIter *newpos, | 650 | copy_entry (struct MainPublishingDialogContext *ctx, |
606 | int dsel) { | 651 | GtkTreeModel *tm, |
652 | GtkTreeIter *old, | ||
653 | GtkTreeIter *newpos, | ||
654 | int dsel) | ||
655 | { | ||
607 | GtkTreePath *path; | 656 | GtkTreePath *path; |
608 | GtkTreeIter child; | 657 | GtkTreeIter child; |
609 | GtkTreeRowReference *rr; | 658 | GtkTreeRowReference *rr; |
@@ -619,60 +668,93 @@ static void copy_entry(struct MainPublishingDialogContext *ctx, | |||
619 | guint64 expiration_time_abs; | 668 | guint64 expiration_time_abs; |
620 | char *fsf; | 669 | char *fsf; |
621 | 670 | ||
622 | gtk_tree_model_get( | 671 | gtk_tree_model_get (tm, |
623 | tm, old, PUBLISH_MC_FILESIZE, &fsf, PUBLISH_MC_DO_INDEX, &do_index, | 672 | old, |
624 | PUBLISH_MC_FILENAME, &short_fn, PUBLISH_MC_ANONYMITY_LEVEL, | 673 | PUBLISH_MC_FILESIZE, |
625 | &anonymity_level, PUBLISH_MC_PRIORITY, &priority, | 674 | &fsf, |
626 | PUBLISH_MC_FILE_INFORMATION_STRUCT, &fip, | 675 | PUBLISH_MC_DO_INDEX, |
627 | PUBLISH_MC_EXPIRATION_TIME_ABSOLUTE, &expiration_time_abs, | 676 | &do_index, |
628 | PUBLISH_MC_REPLICATION_LEVEL, &replication_level, -1); | 677 | PUBLISH_MC_FILENAME, |
629 | gtk_tree_store_set(GTK_TREE_STORE(tm), newpos, PUBLISH_MC_FILESIZE, fsf, | 678 | &short_fn, |
630 | PUBLISH_MC_DO_INDEX, do_index, PUBLISH_MC_FILENAME, | 679 | PUBLISH_MC_ANONYMITY_LEVEL, |
631 | short_fn, PUBLISH_MC_ANONYMITY_LEVEL, anonymity_level, | 680 | &anonymity_level, |
632 | PUBLISH_MC_PRIORITY, priority, | 681 | PUBLISH_MC_PRIORITY, |
633 | PUBLISH_MC_FILE_INFORMATION_STRUCT, fip, | 682 | &priority, |
634 | PUBLISH_MC_EXPIRATION_TIME_ABSOLUTE, expiration_time_abs, | 683 | PUBLISH_MC_FILE_INFORMATION_STRUCT, |
635 | PUBLISH_MC_REPLICATION_LEVEL, replication_level, -1); | 684 | &fip, |
636 | g_free(short_fn); | 685 | PUBLISH_MC_EXPIRATION_TIME_ABSOLUTE, |
637 | g_free(fsf); | 686 | &expiration_time_abs, |
687 | PUBLISH_MC_REPLICATION_LEVEL, | ||
688 | &replication_level, | ||
689 | -1); | ||
690 | gtk_tree_store_set (GTK_TREE_STORE (tm), | ||
691 | newpos, | ||
692 | PUBLISH_MC_FILESIZE, | ||
693 | fsf, | ||
694 | PUBLISH_MC_DO_INDEX, | ||
695 | do_index, | ||
696 | PUBLISH_MC_FILENAME, | ||
697 | short_fn, | ||
698 | PUBLISH_MC_ANONYMITY_LEVEL, | ||
699 | anonymity_level, | ||
700 | PUBLISH_MC_PRIORITY, | ||
701 | priority, | ||
702 | PUBLISH_MC_FILE_INFORMATION_STRUCT, | ||
703 | fip, | ||
704 | PUBLISH_MC_EXPIRATION_TIME_ABSOLUTE, | ||
705 | expiration_time_abs, | ||
706 | PUBLISH_MC_REPLICATION_LEVEL, | ||
707 | replication_level, | ||
708 | -1); | ||
709 | g_free (short_fn); | ||
710 | g_free (fsf); | ||
638 | } | 711 | } |
639 | 712 | ||
640 | /* remember our destination location if needed */ | 713 | /* remember our destination location if needed */ |
641 | if (dsel == GNUNET_YES) { | 714 | if (dsel == GNUNET_YES) |
642 | path = gtk_tree_model_get_path(tm, newpos); | 715 | { |
643 | rr = gtk_tree_row_reference_new(tm, path); | 716 | path = gtk_tree_model_get_path (tm, newpos); |
644 | gtk_tree_path_free(path); | 717 | rr = gtk_tree_row_reference_new (tm, path); |
645 | } else { | 718 | gtk_tree_path_free (path); |
719 | } | ||
720 | else | ||
721 | { | ||
646 | rr = NULL; | 722 | rr = NULL; |
647 | } | 723 | } |
648 | 724 | ||
649 | /* recursively move children */ | 725 | /* recursively move children */ |
650 | if (gtk_tree_model_iter_children(tm, &child, old)) { | 726 | if (gtk_tree_model_iter_children (tm, &child, old)) |
651 | do { | 727 | { |
728 | do | ||
729 | { | ||
652 | GtkTreeRowReference *crr; | 730 | GtkTreeRowReference *crr; |
653 | GtkTreeIter cnewpos; | 731 | GtkTreeIter cnewpos; |
654 | 732 | ||
655 | path = gtk_tree_model_get_path(tm, &child); | 733 | path = gtk_tree_model_get_path (tm, &child); |
656 | crr = gtk_tree_row_reference_new(tm, path); | 734 | crr = gtk_tree_row_reference_new (tm, path); |
657 | gtk_tree_path_free(path); | 735 | gtk_tree_path_free (path); |
658 | gtk_tree_store_insert_before(GTK_TREE_STORE(tm), &cnewpos, newpos, NULL); | 736 | gtk_tree_store_insert_before (GTK_TREE_STORE (tm), |
659 | copy_entry(ctx, tm, &child, &cnewpos, GNUNET_NO); | 737 | &cnewpos, |
660 | path = gtk_tree_row_reference_get_path(crr); | 738 | newpos, |
661 | gtk_tree_row_reference_free(crr); | 739 | NULL); |
662 | GNUNET_assert(gtk_tree_model_get_iter(tm, &child, path)); | 740 | copy_entry (ctx, tm, &child, &cnewpos, GNUNET_NO); |
663 | gtk_tree_path_free(path); | 741 | path = gtk_tree_row_reference_get_path (crr); |
664 | } while (gtk_tree_model_iter_next(tm, &child)); | 742 | gtk_tree_row_reference_free (crr); |
743 | GNUNET_assert (gtk_tree_model_get_iter (tm, &child, path)); | ||
744 | gtk_tree_path_free (path); | ||
745 | } while (gtk_tree_model_iter_next (tm, &child)); | ||
665 | } | 746 | } |
666 | 747 | ||
667 | /* update selection, etc. if applicable */ | 748 | /* update selection, etc. if applicable */ |
668 | if (dsel == GNUNET_YES) { | 749 | if (dsel == GNUNET_YES) |
669 | path = gtk_tree_row_reference_get_path(rr); | 750 | { |
670 | gtk_tree_row_reference_free(rr); | 751 | path = gtk_tree_row_reference_get_path (rr); |
671 | gtk_tree_view_expand_to_path(ctx->file_info_treeview, path); | 752 | gtk_tree_row_reference_free (rr); |
672 | GNUNET_assert(gtk_tree_model_get_iter(tm, newpos, path)); | 753 | gtk_tree_view_expand_to_path (ctx->file_info_treeview, path); |
673 | gtk_tree_path_free(path); | 754 | GNUNET_assert (gtk_tree_model_get_iter (tm, newpos, path)); |
674 | gtk_tree_selection_select_iter(ctx->file_info_selection, newpos); | 755 | gtk_tree_path_free (path); |
675 | update_selectivity_edit(ctx); | 756 | gtk_tree_selection_select_iter (ctx->file_info_selection, newpos); |
757 | update_selectivity_edit (ctx); | ||
676 | } | 758 | } |
677 | } | 759 | } |
678 | 760 | ||
@@ -683,9 +765,12 @@ static void copy_entry(struct MainPublishingDialogContext *ctx, | |||
683 | * @param togglebutton button that was toggled | 765 | * @param togglebutton button that was toggled |
684 | * @param user_data context | 766 | * @param user_data context |
685 | */ | 767 | */ |
686 | void GNUNET_GTK_master_publish_dialog_global_checkbox_toggled_cb( | 768 | void |
687 | GtkToggleButton *togglebutton, gpointer user_data) { | 769 | GNUNET_GTK_master_publish_dialog_global_checkbox_toggled_cb ( |
688 | update_selectivity_execute_cancel(user_data); | 770 | GtkToggleButton *togglebutton, |
771 | gpointer user_data) | ||
772 | { | ||
773 | update_selectivity_execute_cancel (user_data); | ||
689 | } | 774 | } |
690 | 775 | ||
691 | /** | 776 | /** |
@@ -695,9 +780,12 @@ void GNUNET_GTK_master_publish_dialog_global_checkbox_toggled_cb( | |||
695 | * @param togglebutton button that was toggled | 780 | * @param togglebutton button that was toggled |
696 | * @param user_data context | 781 | * @param user_data context |
697 | */ | 782 | */ |
698 | void GNUNET_GTK_master_publish_dialog_own_checkbox_toggled_cb( | 783 | void |
699 | GtkToggleButton *togglebutton, gpointer user_data) { | 784 | GNUNET_GTK_master_publish_dialog_own_checkbox_toggled_cb ( |
700 | update_selectivity_execute_cancel(user_data); | 785 | GtkToggleButton *togglebutton, |
786 | gpointer user_data) | ||
787 | { | ||
788 | update_selectivity_execute_cancel (user_data); | ||
701 | } | 789 | } |
702 | 790 | ||
703 | /** | 791 | /** |
@@ -707,9 +795,12 @@ void GNUNET_GTK_master_publish_dialog_own_checkbox_toggled_cb( | |||
707 | * @param togglebutton button that was toggled | 795 | * @param togglebutton button that was toggled |
708 | * @param user_data context | 796 | * @param user_data context |
709 | */ | 797 | */ |
710 | void GNUNET_GTK_master_publish_dialog_updateable_checkbox_toggled_cb( | 798 | void |
711 | GtkToggleButton *togglebutton, gpointer user_data) { | 799 | GNUNET_GTK_master_publish_dialog_updateable_checkbox_toggled_cb ( |
712 | update_selectivity_execute_cancel(user_data); | 800 | GtkToggleButton *togglebutton, |
801 | gpointer user_data) | ||
802 | { | ||
803 | update_selectivity_execute_cancel (user_data); | ||
713 | } | 804 | } |
714 | 805 | ||
715 | /** | 806 | /** |
@@ -718,19 +809,22 @@ void GNUNET_GTK_master_publish_dialog_updateable_checkbox_toggled_cb( | |||
718 | * @param new_text new id for which to generate update id. | 809 | * @param new_text new id for which to generate update id. |
719 | * @return new update id (free with g_free()). | 810 | * @return new update id (free with g_free()). |
720 | */ | 811 | */ |
721 | static gchar *generate_update_id(const gchar *new_text) { | 812 | static gchar * |
813 | generate_update_id (const gchar *new_text) | ||
814 | { | ||
722 | gchar *dash; | 815 | gchar *dash; |
723 | gint64 num; | 816 | gint64 num; |
724 | gchar *new_update_id; | 817 | gchar *new_update_id; |
725 | gchar *copy_part; | 818 | gchar *copy_part; |
726 | 819 | ||
727 | copy_part = g_strdup(new_text); | 820 | copy_part = g_strdup (new_text); |
728 | dash = strrchr(copy_part, '-'); | 821 | dash = strrchr (copy_part, '-'); |
729 | if (!dash) | 822 | if (! dash) |
730 | num = 0; | 823 | num = 0; |
731 | else { | 824 | else |
825 | { | ||
732 | gchar *endptr; | 826 | gchar *endptr; |
733 | num = g_ascii_strtoll(&dash[1], &endptr, 10); | 827 | num = g_ascii_strtoll (&dash[1], &endptr, 10); |
734 | if (((0 <= num) && (endptr == &dash[1])) || (G_MAXINT64 == num) || | 828 | if (((0 <= num) && (endptr == &dash[1])) || (G_MAXINT64 == num) || |
735 | ('\0' != endptr[0])) | 829 | ('\0' != endptr[0])) |
736 | num = 0; | 830 | num = 0; |
@@ -738,10 +832,11 @@ static gchar *generate_update_id(const gchar *new_text) { | |||
738 | dash[0] = '\0'; | 832 | dash[0] = '\0'; |
739 | } | 833 | } |
740 | if ('\0' != new_text[0]) | 834 | if ('\0' != new_text[0]) |
741 | new_update_id = g_strdup_printf("%s-%" G_GINT64_FORMAT, copy_part, num + 1); | 835 | new_update_id = |
836 | g_strdup_printf ("%s-%" G_GINT64_FORMAT, copy_part, num + 1); | ||
742 | else | 837 | else |
743 | new_update_id = g_strdup(""); | 838 | new_update_id = g_strdup (""); |
744 | g_free(copy_part); | 839 | g_free (copy_part); |
745 | return new_update_id; | 840 | return new_update_id; |
746 | } | 841 | } |
747 | 842 | ||
@@ -757,16 +852,18 @@ static gchar *generate_update_id(const gchar *new_text) { | |||
757 | * @return TRUE if existing_update_id was generated from previous_id, | 852 | * @return TRUE if existing_update_id was generated from previous_id, |
758 | * FALSE otherwise | 853 | * FALSE otherwise |
759 | */ | 854 | */ |
760 | static gboolean update_id_is_autofilled(const gchar *existing_update_id, | 855 | static gboolean |
761 | const gchar *previous_id) { | 856 | update_id_is_autofilled (const gchar *existing_update_id, |
857 | const gchar *previous_id) | ||
858 | { | ||
762 | gboolean result; | 859 | gboolean result; |
763 | gchar *gen_update_id; | 860 | gchar *gen_update_id; |
764 | 861 | ||
765 | result = TRUE; | 862 | result = TRUE; |
766 | gen_update_id = generate_update_id(previous_id); | 863 | gen_update_id = generate_update_id (previous_id); |
767 | if (0 != strcmp(gen_update_id, existing_update_id)) | 864 | if (0 != strcmp (gen_update_id, existing_update_id)) |
768 | result = FALSE; | 865 | result = FALSE; |
769 | g_free(gen_update_id); | 866 | g_free (gen_update_id); |
770 | return result; | 867 | return result; |
771 | } | 868 | } |
772 | 869 | ||
@@ -777,24 +874,27 @@ static gboolean update_id_is_autofilled(const gchar *existing_update_id, | |||
777 | * @param ctx context | 874 | * @param ctx context |
778 | * @param new_text new identifier | 875 | * @param new_text new identifier |
779 | */ | 876 | */ |
780 | static void maybe_change_update_id(struct MainPublishingDialogContext *ctx, | 877 | static void |
781 | const gchar *new_text) { | 878 | maybe_change_update_id (struct MainPublishingDialogContext *ctx, |
879 | const gchar *new_text) | ||
880 | { | ||
782 | const gchar *existing_update_id; | 881 | const gchar *existing_update_id; |
783 | gchar *new_update_id; | 882 | gchar *new_update_id; |
784 | 883 | ||
785 | new_update_id = NULL; | 884 | new_update_id = NULL; |
786 | existing_update_id = gtk_entry_get_text(GTK_ENTRY(ctx->update_id_entry)); | 885 | existing_update_id = gtk_entry_get_text (GTK_ENTRY (ctx->update_id_entry)); |
787 | 886 | ||
788 | if (((NULL == ctx->previous_id) && ('\0' == existing_update_id[0])) || | 887 | if (((NULL == ctx->previous_id) && ('\0' == existing_update_id[0])) || |
789 | ((NULL != ctx->previous_id) && | 888 | ((NULL != ctx->previous_id) && |
790 | update_id_is_autofilled(existing_update_id, ctx->previous_id))) | 889 | update_id_is_autofilled (existing_update_id, ctx->previous_id))) |
791 | new_update_id = generate_update_id(new_text); | 890 | new_update_id = generate_update_id (new_text); |
792 | if (NULL != new_update_id) { | 891 | if (NULL != new_update_id) |
793 | gtk_entry_set_text(GTK_ENTRY(ctx->update_id_entry), new_update_id); | 892 | { |
794 | g_free(new_update_id); | 893 | gtk_entry_set_text (GTK_ENTRY (ctx->update_id_entry), new_update_id); |
795 | } | 894 | g_free (new_update_id); |
796 | g_free(ctx->previous_id); | 895 | } |
797 | ctx->previous_id = g_strdup(new_text); | 896 | g_free (ctx->previous_id); |
897 | ctx->previous_id = g_strdup (new_text); | ||
798 | } | 898 | } |
799 | 899 | ||
800 | /** | 900 | /** |
@@ -805,16 +905,19 @@ static void maybe_change_update_id(struct MainPublishingDialogContext *ctx, | |||
805 | * @param widget the entry that was changed | 905 | * @param widget the entry that was changed |
806 | * @param user_data our `struct MainPublishingDialogContext` | 906 | * @param user_data our `struct MainPublishingDialogContext` |
807 | */ | 907 | */ |
808 | void GNUNET_GTK_master_publish_dialog_identifier_entry_changed_cb( | 908 | void |
809 | GtkWidget *widget, gpointer user_data) { | 909 | GNUNET_GTK_master_publish_dialog_identifier_entry_changed_cb ( |
910 | GtkWidget *widget, | ||
911 | gpointer user_data) | ||
912 | { | ||
810 | struct MainPublishingDialogContext *ctx = user_data; | 913 | struct MainPublishingDialogContext *ctx = user_data; |
811 | const gchar *new_text; | 914 | const gchar *new_text; |
812 | 915 | ||
813 | new_text = gtk_entry_get_text(GTK_ENTRY(widget)); | 916 | new_text = gtk_entry_get_text (GTK_ENTRY (widget)); |
814 | if (NULL == new_text) | 917 | if (NULL == new_text) |
815 | return; | 918 | return; |
816 | maybe_change_update_id(ctx, new_text); | 919 | maybe_change_update_id (ctx, new_text); |
817 | update_selectivity_execute_cancel(ctx); | 920 | update_selectivity_execute_cancel (ctx); |
818 | } | 921 | } |
819 | 922 | ||
820 | /** | 923 | /** |
@@ -825,27 +928,37 @@ void GNUNET_GTK_master_publish_dialog_identifier_entry_changed_cb( | |||
825 | * @param ts the changed selection | 928 | * @param ts the changed selection |
826 | * @param user_data master publishing dialog context of our window | 929 | * @param user_data master publishing dialog context of our window |
827 | */ | 930 | */ |
828 | void GNUNET_GTK_master_publish_dialog_previous_identifiers_treeview_selection_changed_cb( | 931 | void |
829 | GtkTreeSelection *ts, gpointer user_data) { | 932 | GNUNET_GTK_master_publish_dialog_previous_identifiers_treeview_selection_changed_cb ( |
933 | GtkTreeSelection *ts, | ||
934 | gpointer user_data) | ||
935 | { | ||
830 | struct MainPublishingDialogContext *ctx = user_data; | 936 | struct MainPublishingDialogContext *ctx = user_data; |
831 | GtkTreeIter iter; | 937 | GtkTreeIter iter; |
832 | gchar *new_text; | 938 | gchar *new_text; |
833 | gchar *spath; | 939 | gchar *spath; |
834 | GtkTreePath *path; | 940 | GtkTreePath *path; |
835 | 941 | ||
836 | if (!gtk_tree_selection_get_selected(ts, NULL, &iter)) | 942 | if (! gtk_tree_selection_get_selected (ts, NULL, &iter)) |
837 | return; | 943 | return; |
838 | gtk_tree_model_get(ctx->identifiers_treemodel, &iter, IDENTIFIERS_MC_ID, | 944 | gtk_tree_model_get (ctx->identifiers_treemodel, |
839 | &new_text, IDENTIFIERS_MC_PATH_TO_ORIGINAL, &spath, -1); | 945 | &iter, |
946 | IDENTIFIERS_MC_ID, | ||
947 | &new_text, | ||
948 | IDENTIFIERS_MC_PATH_TO_ORIGINAL, | ||
949 | &spath, | ||
950 | -1); | ||
840 | path = NULL; | 951 | path = NULL; |
841 | if (spath) | 952 | if (spath) |
842 | path = gtk_tree_path_new_from_string(spath); | 953 | path = gtk_tree_path_new_from_string (spath); |
843 | if (path) { | 954 | if (path) |
844 | gtk_tree_selection_select_path(ts, path); | 955 | { |
845 | gtk_tree_path_free(path); | 956 | gtk_tree_selection_select_path (ts, path); |
846 | } else if (new_text) | 957 | gtk_tree_path_free (path); |
847 | gtk_entry_set_text(GTK_ENTRY(ctx->identifier_entry), new_text); | 958 | } |
848 | g_free(new_text); | 959 | else if (new_text) |
960 | gtk_entry_set_text (GTK_ENTRY (ctx->identifier_entry), new_text); | ||
961 | g_free (new_text); | ||
849 | } | 962 | } |
850 | 963 | ||
851 | /** | 964 | /** |
@@ -855,8 +968,10 @@ void GNUNET_GTK_master_publish_dialog_previous_identifiers_treeview_selection_ch | |||
855 | * @param dummy the button | 968 | * @param dummy the button |
856 | * @param user_data master publishing dialog context of our window | 969 | * @param user_data master publishing dialog context of our window |
857 | */ | 970 | */ |
858 | void GNUNET_GTK_master_publish_dialog_right_button_clicked_cb( | 971 | void |
859 | GtkWidget *dummy, gpointer user_data) { | 972 | GNUNET_GTK_master_publish_dialog_right_button_clicked_cb (GtkWidget *dummy, |
973 | gpointer user_data) | ||
974 | { | ||
860 | struct MainPublishingDialogContext *ctx = user_data; | 975 | struct MainPublishingDialogContext *ctx = user_data; |
861 | GtkTreeIter iter; | 976 | GtkTreeIter iter; |
862 | GtkTreeIter parent; | 977 | GtkTreeIter parent; |
@@ -864,33 +979,40 @@ void GNUNET_GTK_master_publish_dialog_right_button_clicked_cb( | |||
864 | GtkTreeIter prev; | 979 | GtkTreeIter prev; |
865 | GtkTreeIter pos; | 980 | GtkTreeIter pos; |
866 | 981 | ||
867 | if (!gtk_tree_selection_get_selected(ctx->file_info_selection, NULL, &iter)) { | 982 | if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, &iter)) |
868 | GNUNET_break(0); | 983 | { |
984 | GNUNET_break (0); | ||
869 | return; | 985 | return; |
870 | } | 986 | } |
871 | if (gtk_tree_model_iter_parent(ctx->file_info_treemodel, &parent, &iter)) | 987 | if (gtk_tree_model_iter_parent (ctx->file_info_treemodel, &parent, &iter)) |
872 | GNUNET_assert( | 988 | GNUNET_assert ( |
873 | gtk_tree_model_iter_children(ctx->file_info_treemodel, &pred, &parent)); | 989 | gtk_tree_model_iter_children (ctx->file_info_treemodel, &pred, &parent)); |
874 | else if (!gtk_tree_model_get_iter_first(ctx->file_info_treemodel, &pred)) { | 990 | else if (! gtk_tree_model_get_iter_first (ctx->file_info_treemodel, &pred)) |
875 | GNUNET_break(0); | 991 | { |
992 | GNUNET_break (0); | ||
876 | return; | 993 | return; |
877 | } | 994 | } |
878 | /* iterate over 'next' of pred to find out who our predecessor is! */ | 995 | /* iterate over 'next' of pred to find out who our predecessor is! */ |
879 | memset(&prev, 0, sizeof(GtkTreeIter)); | 996 | memset (&prev, 0, sizeof (GtkTreeIter)); |
880 | while (GNUNET_YES != | 997 | while (GNUNET_YES != |
881 | gtk_tree_iter_equals(ctx->file_info_treemodel, &pred, &iter)) { | 998 | gtk_tree_iter_equals (ctx->file_info_treemodel, &pred, &iter)) |
999 | { | ||
882 | prev = pred; | 1000 | prev = pred; |
883 | GNUNET_assert(gtk_tree_model_iter_next(ctx->file_info_treemodel, &pred)); | 1001 | GNUNET_assert (gtk_tree_model_iter_next (ctx->file_info_treemodel, &pred)); |
884 | } | 1002 | } |
885 | gtk_tree_store_insert_before(GTK_TREE_STORE(ctx->file_info_treemodel), &pos, | 1003 | gtk_tree_store_insert_before (GTK_TREE_STORE (ctx->file_info_treemodel), |
886 | &prev, NULL); | 1004 | &pos, |
887 | if (!gtk_tree_selection_get_selected(ctx->file_info_selection, NULL, &iter)) { | 1005 | &prev, |
888 | GNUNET_break(0); | 1006 | NULL); |
1007 | if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, &iter)) | ||
1008 | { | ||
1009 | GNUNET_break (0); | ||
889 | return; | 1010 | return; |
890 | } | 1011 | } |
891 | copy_entry(ctx, ctx->file_info_treemodel, &iter, &pos, GNUNET_YES); | 1012 | copy_entry (ctx, ctx->file_info_treemodel, &iter, &pos, GNUNET_YES); |
892 | GNUNET_FS_GTK_remove_treestore_subtree( | 1013 | GNUNET_FS_GTK_remove_treestore_subtree (GTK_TREE_STORE ( |
893 | GTK_TREE_STORE(ctx->file_info_treemodel), &iter); | 1014 | ctx->file_info_treemodel), |
1015 | &iter); | ||
894 | } | 1016 | } |
895 | 1017 | ||
896 | /** | 1018 | /** |
@@ -900,30 +1022,38 @@ void GNUNET_GTK_master_publish_dialog_right_button_clicked_cb( | |||
900 | * @param dummy the button | 1022 | * @param dummy the button |
901 | * @param user_data master publishing dialog context of our window | 1023 | * @param user_data master publishing dialog context of our window |
902 | */ | 1024 | */ |
903 | void GNUNET_GTK_master_publish_dialog_left_button_clicked_cb( | 1025 | void |
904 | GtkWidget *dummy, gpointer user_data) { | 1026 | GNUNET_GTK_master_publish_dialog_left_button_clicked_cb (GtkWidget *dummy, |
1027 | gpointer user_data) | ||
1028 | { | ||
905 | struct MainPublishingDialogContext *ctx = user_data; | 1029 | struct MainPublishingDialogContext *ctx = user_data; |
906 | GtkTreeIter iter; | 1030 | GtkTreeIter iter; |
907 | GtkTreeIter parent; | 1031 | GtkTreeIter parent; |
908 | GtkTreeIter pos; | 1032 | GtkTreeIter pos; |
909 | 1033 | ||
910 | if (!gtk_tree_selection_get_selected(ctx->file_info_selection, NULL, &iter)) { | 1034 | if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, &iter)) |
911 | GNUNET_break(0); | 1035 | { |
1036 | GNUNET_break (0); | ||
912 | return; | 1037 | return; |
913 | } | 1038 | } |
914 | if (!gtk_tree_model_iter_parent(ctx->file_info_treemodel, &parent, &iter)) { | 1039 | if (! gtk_tree_model_iter_parent (ctx->file_info_treemodel, &parent, &iter)) |
915 | GNUNET_break(0); | 1040 | { |
1041 | GNUNET_break (0); | ||
916 | return; | 1042 | return; |
917 | } | 1043 | } |
918 | gtk_tree_store_insert_after(GTK_TREE_STORE(ctx->file_info_treemodel), &pos, | 1044 | gtk_tree_store_insert_after (GTK_TREE_STORE (ctx->file_info_treemodel), |
919 | NULL, &parent); | 1045 | &pos, |
920 | if (!gtk_tree_selection_get_selected(ctx->file_info_selection, NULL, &iter)) { | 1046 | NULL, |
921 | GNUNET_break(0); | 1047 | &parent); |
1048 | if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, &iter)) | ||
1049 | { | ||
1050 | GNUNET_break (0); | ||
922 | return; | 1051 | return; |
923 | } | 1052 | } |
924 | copy_entry(ctx, ctx->file_info_treemodel, &iter, &pos, GNUNET_YES); | 1053 | copy_entry (ctx, ctx->file_info_treemodel, &iter, &pos, GNUNET_YES); |
925 | GNUNET_FS_GTK_remove_treestore_subtree( | 1054 | GNUNET_FS_GTK_remove_treestore_subtree (GTK_TREE_STORE ( |
926 | GTK_TREE_STORE(ctx->file_info_treemodel), &iter); | 1055 | ctx->file_info_treemodel), |
1056 | &iter); | ||
927 | } | 1057 | } |
928 | 1058 | ||
929 | /** | 1059 | /** |
@@ -933,8 +1063,10 @@ void GNUNET_GTK_master_publish_dialog_left_button_clicked_cb( | |||
933 | * @param dummy the button | 1063 | * @param dummy the button |
934 | * @param user_data master publishing dialog context of our window | 1064 | * @param user_data master publishing dialog context of our window |
935 | */ | 1065 | */ |
936 | void GNUNET_GTK_master_publish_dialog_up_button_clicked_cb(GtkWidget *dummy, | 1066 | void |
937 | gpointer user_data) { | 1067 | GNUNET_GTK_master_publish_dialog_up_button_clicked_cb (GtkWidget *dummy, |
1068 | gpointer user_data) | ||
1069 | { | ||
938 | struct MainPublishingDialogContext *ctx = user_data; | 1070 | struct MainPublishingDialogContext *ctx = user_data; |
939 | GtkTreeIter iter; | 1071 | GtkTreeIter iter; |
940 | GtkTreeIter parent; | 1072 | GtkTreeIter parent; |
@@ -943,35 +1075,45 @@ void GNUNET_GTK_master_publish_dialog_up_button_clicked_cb(GtkWidget *dummy, | |||
943 | GtkTreeIter *pprev; | 1075 | GtkTreeIter *pprev; |
944 | GtkTreeIter pos; | 1076 | GtkTreeIter pos; |
945 | 1077 | ||
946 | if (!gtk_tree_selection_get_selected(ctx->file_info_selection, NULL, &iter)) { | 1078 | if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, &iter)) |
947 | GNUNET_break(0); | 1079 | { |
1080 | GNUNET_break (0); | ||
948 | return; | 1081 | return; |
949 | } | 1082 | } |
950 | if (gtk_tree_model_iter_parent(ctx->file_info_treemodel, &parent, &iter)) { | 1083 | if (gtk_tree_model_iter_parent (ctx->file_info_treemodel, &parent, &iter)) |
951 | GNUNET_assert(TRUE == gtk_tree_model_iter_children(ctx->file_info_treemodel, | 1084 | { |
952 | &pred, &parent)); | 1085 | GNUNET_assert ( |
1086 | TRUE == | ||
1087 | gtk_tree_model_iter_children (ctx->file_info_treemodel, &pred, &parent)); | ||
953 | pprev = &parent; | 1088 | pprev = &parent; |
954 | } else if (!gtk_tree_model_get_iter_first(ctx->file_info_treemodel, &pred)) { | 1089 | } |
955 | GNUNET_break(0); | 1090 | else if (! gtk_tree_model_get_iter_first (ctx->file_info_treemodel, &pred)) |
1091 | { | ||
1092 | GNUNET_break (0); | ||
956 | return; | 1093 | return; |
957 | } | 1094 | } |
958 | pprev = NULL; | 1095 | pprev = NULL; |
959 | /* iterate over 'next' of pred to find out who our predecessor is! */ | 1096 | /* iterate over 'next' of pred to find out who our predecessor is! */ |
960 | while (GNUNET_YES != | 1097 | while (GNUNET_YES != |
961 | gtk_tree_iter_equals(ctx->file_info_treemodel, &pred, &iter)) { | 1098 | gtk_tree_iter_equals (ctx->file_info_treemodel, &pred, &iter)) |
1099 | { | ||
962 | prev = pred; | 1100 | prev = pred; |
963 | pprev = &prev; | 1101 | pprev = &prev; |
964 | GNUNET_assert(gtk_tree_model_iter_next(ctx->file_info_treemodel, &pred)); | 1102 | GNUNET_assert (gtk_tree_model_iter_next (ctx->file_info_treemodel, &pred)); |
965 | } | 1103 | } |
966 | gtk_tree_store_insert_before(GTK_TREE_STORE(ctx->file_info_treemodel), &pos, | 1104 | gtk_tree_store_insert_before (GTK_TREE_STORE (ctx->file_info_treemodel), |
967 | NULL, pprev); | 1105 | &pos, |
968 | if (!gtk_tree_selection_get_selected(ctx->file_info_selection, NULL, &iter)) { | 1106 | NULL, |
969 | GNUNET_break(0); | 1107 | pprev); |
1108 | if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, &iter)) | ||
1109 | { | ||
1110 | GNUNET_break (0); | ||
970 | return; | 1111 | return; |
971 | } | 1112 | } |
972 | copy_entry(ctx, ctx->file_info_treemodel, &iter, &pos, GNUNET_YES); | 1113 | copy_entry (ctx, ctx->file_info_treemodel, &iter, &pos, GNUNET_YES); |
973 | GNUNET_FS_GTK_remove_treestore_subtree( | 1114 | GNUNET_FS_GTK_remove_treestore_subtree (GTK_TREE_STORE ( |
974 | GTK_TREE_STORE(ctx->file_info_treemodel), &iter); | 1115 | ctx->file_info_treemodel), |
1116 | &iter); | ||
975 | } | 1117 | } |
976 | 1118 | ||
977 | /** | 1119 | /** |
@@ -981,31 +1123,39 @@ void GNUNET_GTK_master_publish_dialog_up_button_clicked_cb(GtkWidget *dummy, | |||
981 | * @param dummy the button | 1123 | * @param dummy the button |
982 | * @param user_data master publishing dialog context of our window | 1124 | * @param user_data master publishing dialog context of our window |
983 | */ | 1125 | */ |
984 | void GNUNET_GTK_master_publish_dialog_down_button_clicked_cb( | 1126 | void |
985 | GtkWidget *dummy, gpointer user_data) { | 1127 | GNUNET_GTK_master_publish_dialog_down_button_clicked_cb (GtkWidget *dummy, |
1128 | gpointer user_data) | ||
1129 | { | ||
986 | struct MainPublishingDialogContext *ctx = user_data; | 1130 | struct MainPublishingDialogContext *ctx = user_data; |
987 | GtkTreeIter iter; | 1131 | GtkTreeIter iter; |
988 | GtkTreeIter next; | 1132 | GtkTreeIter next; |
989 | GtkTreeIter pos; | 1133 | GtkTreeIter pos; |
990 | 1134 | ||
991 | if (!gtk_tree_selection_get_selected(ctx->file_info_selection, NULL, &iter)) { | 1135 | if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, &iter)) |
992 | GNUNET_break(0); | 1136 | { |
1137 | GNUNET_break (0); | ||
993 | return; | 1138 | return; |
994 | } | 1139 | } |
995 | if (!gtk_tree_selection_get_selected(ctx->file_info_selection, NULL, &next)) { | 1140 | if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, &next)) |
996 | GNUNET_break(0); | 1141 | { |
1142 | GNUNET_break (0); | ||
997 | return; | 1143 | return; |
998 | } | 1144 | } |
999 | GNUNET_assert(gtk_tree_model_iter_next(ctx->file_info_treemodel, &next)); | 1145 | GNUNET_assert (gtk_tree_model_iter_next (ctx->file_info_treemodel, &next)); |
1000 | gtk_tree_store_insert_after(GTK_TREE_STORE(ctx->file_info_treemodel), &pos, | 1146 | gtk_tree_store_insert_after (GTK_TREE_STORE (ctx->file_info_treemodel), |
1001 | NULL, &next); | 1147 | &pos, |
1002 | if (!gtk_tree_selection_get_selected(ctx->file_info_selection, NULL, &iter)) { | 1148 | NULL, |
1003 | GNUNET_break(0); | 1149 | &next); |
1150 | if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, &iter)) | ||
1151 | { | ||
1152 | GNUNET_break (0); | ||
1004 | return; | 1153 | return; |
1005 | } | 1154 | } |
1006 | copy_entry(ctx, ctx->file_info_treemodel, &iter, &pos, GNUNET_YES); | 1155 | copy_entry (ctx, ctx->file_info_treemodel, &iter, &pos, GNUNET_YES); |
1007 | GNUNET_FS_GTK_remove_treestore_subtree( | 1156 | GNUNET_FS_GTK_remove_treestore_subtree (GTK_TREE_STORE ( |
1008 | GTK_TREE_STORE(ctx->file_info_treemodel), &iter); | 1157 | ctx->file_info_treemodel), |
1158 | &iter); | ||
1009 | } | 1159 | } |
1010 | 1160 | ||
1011 | /** | 1161 | /** |
@@ -1015,8 +1165,10 @@ void GNUNET_GTK_master_publish_dialog_down_button_clicked_cb( | |||
1015 | * @param dummy the button | 1165 | * @param dummy the button |
1016 | * @param user_data master publishing dialog context of our window | 1166 | * @param user_data master publishing dialog context of our window |
1017 | */ | 1167 | */ |
1018 | void GNUNET_GTK_master_publish_dialog_new_button_clicked_cb( | 1168 | void |
1019 | GtkWidget *dummy, gpointer user_data) { | 1169 | GNUNET_GTK_master_publish_dialog_new_button_clicked_cb (GtkWidget *dummy, |
1170 | gpointer user_data) | ||
1171 | { | ||
1020 | struct MainPublishingDialogContext *ctx = user_data; | 1172 | struct MainPublishingDialogContext *ctx = user_data; |
1021 | GtkTreeIter iter; | 1173 | GtkTreeIter iter; |
1022 | GtkTreeIter pos; | 1174 | GtkTreeIter pos; |
@@ -1028,12 +1180,13 @@ void GNUNET_GTK_master_publish_dialog_new_button_clicked_cb( | |||
1028 | the configuration. */ | 1180 | the configuration. */ |
1029 | bo.anonymity_level = 1; | 1181 | bo.anonymity_level = 1; |
1030 | bo.content_priority = 1000; | 1182 | bo.content_priority = 1000; |
1031 | bo.expiration_time = GNUNET_TIME_relative_to_absolute(GNUNET_TIME_UNIT_YEARS); | 1183 | bo.expiration_time = |
1184 | GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS); | ||
1032 | bo.replication_level = 1; | 1185 | bo.replication_level = 1; |
1033 | if (!gtk_tree_selection_get_selected(ctx->file_info_selection, NULL, &iter)) | 1186 | if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, &iter)) |
1034 | create_dir_at_iter(ctx, "unnamed/", &bo, NULL, &pos); | 1187 | create_dir_at_iter (ctx, "unnamed/", &bo, NULL, &pos); |
1035 | else | 1188 | else |
1036 | create_dir_at_iter(ctx, "unnamed/", &bo, &iter, &pos); | 1189 | create_dir_at_iter (ctx, "unnamed/", &bo, &iter, &pos); |
1037 | } | 1190 | } |
1038 | 1191 | ||
1039 | /** | 1192 | /** |
@@ -1050,17 +1203,24 @@ void GNUNET_GTK_master_publish_dialog_new_button_clicked_cb( | |||
1050 | * @param client_info pointer to the GtkTreeRowReference, freed | 1203 | * @param client_info pointer to the GtkTreeRowReference, freed |
1051 | * @return GNUNET_OK to traverse entire subtree | 1204 | * @return GNUNET_OK to traverse entire subtree |
1052 | */ | 1205 | */ |
1053 | static int free_fi_row_reference( | 1206 | static int |
1054 | void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length, | 1207 | free_fi_row_reference (void *cls, |
1055 | struct GNUNET_CONTAINER_MetaData *meta, struct GNUNET_FS_Uri **uri, | 1208 | struct GNUNET_FS_FileInformation *fi, |
1056 | struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info) { | 1209 | uint64_t length, |
1210 | struct GNUNET_CONTAINER_MetaData *meta, | ||
1211 | struct GNUNET_FS_Uri **uri, | ||
1212 | struct GNUNET_FS_BlockOptions *bo, | ||
1213 | int *do_index, | ||
1214 | void **client_info) | ||
1215 | { | ||
1057 | GtkTreeRowReference *row = *client_info; | 1216 | GtkTreeRowReference *row = *client_info; |
1058 | 1217 | ||
1059 | if (NULL == row) { | 1218 | if (NULL == row) |
1060 | GNUNET_break(0); | 1219 | { |
1220 | GNUNET_break (0); | ||
1061 | return GNUNET_OK; | 1221 | return GNUNET_OK; |
1062 | } | 1222 | } |
1063 | gtk_tree_row_reference_free(row); | 1223 | gtk_tree_row_reference_free (row); |
1064 | *client_info = NULL; | 1224 | *client_info = NULL; |
1065 | return GNUNET_OK; | 1225 | return GNUNET_OK; |
1066 | } | 1226 | } |
@@ -1072,8 +1232,10 @@ static int free_fi_row_reference( | |||
1072 | * @param dummy the button | 1232 | * @param dummy the button |
1073 | * @param user_data master publishing dialog context of our window | 1233 | * @param user_data master publishing dialog context of our window |
1074 | */ | 1234 | */ |
1075 | void GNUNET_GTK_master_publish_dialog_delete_button_clicked_cb( | 1235 | void |
1076 | GtkWidget *dummy, gpointer user_data) { | 1236 | GNUNET_GTK_master_publish_dialog_delete_button_clicked_cb (GtkWidget *dummy, |
1237 | gpointer user_data) | ||
1238 | { | ||
1077 | struct MainPublishingDialogContext *ctx = user_data; | 1239 | struct MainPublishingDialogContext *ctx = user_data; |
1078 | GtkTreeIter iter; | 1240 | GtkTreeIter iter; |
1079 | struct GNUNET_FS_FileInformation *fip; | 1241 | struct GNUNET_FS_FileInformation *fip; |
@@ -1081,51 +1243,63 @@ void GNUNET_GTK_master_publish_dialog_delete_button_clicked_cb( | |||
1081 | GtkTreePath *path; | 1243 | GtkTreePath *path; |
1082 | 1244 | ||
1083 | /* initially, both 'iter' and 'next' point to the selected row */ | 1245 | /* initially, both 'iter' and 'next' point to the selected row */ |
1084 | if (!gtk_tree_selection_get_selected(ctx->file_info_selection, NULL, &iter)) { | 1246 | if (! gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, &iter)) |
1085 | GNUNET_break(0); | 1247 | { |
1248 | GNUNET_break (0); | ||
1086 | return; | 1249 | return; |
1087 | } | 1250 | } |
1088 | 1251 | ||
1089 | path = gtk_tree_model_get_path(ctx->file_info_treemodel, &iter); | 1252 | path = gtk_tree_model_get_path (ctx->file_info_treemodel, &iter); |
1090 | if (gtk_tree_model_iter_next(ctx->file_info_treemodel, &iter)) | 1253 | if (gtk_tree_model_iter_next (ctx->file_info_treemodel, &iter)) |
1091 | gtk_tree_path_next(path); | 1254 | gtk_tree_path_next (path); |
1092 | else { | 1255 | else |
1093 | if (!gtk_tree_path_prev(path)) { | 1256 | { |
1094 | if ((1 == gtk_tree_path_get_depth(path)) || (!gtk_tree_path_up(path))) { | 1257 | if (! gtk_tree_path_prev (path)) |
1095 | gtk_tree_path_free(path); | 1258 | { |
1259 | if ((1 == gtk_tree_path_get_depth (path)) || (! gtk_tree_path_up (path))) | ||
1260 | { | ||
1261 | gtk_tree_path_free (path); | ||
1096 | path = NULL; | 1262 | path = NULL; |
1097 | } | 1263 | } |
1098 | } | 1264 | } |
1099 | } | 1265 | } |
1100 | if (NULL == path) { | 1266 | if (NULL == path) |
1267 | { | ||
1101 | rr = NULL; | 1268 | rr = NULL; |
1102 | } else { | 1269 | } |
1103 | rr = gtk_tree_row_reference_new(ctx->file_info_treemodel, path); | 1270 | else |
1104 | gtk_tree_path_free(path); | 1271 | { |
1272 | rr = gtk_tree_row_reference_new (ctx->file_info_treemodel, path); | ||
1273 | gtk_tree_path_free (path); | ||
1105 | } | 1274 | } |
1106 | 1275 | ||
1107 | /* 'iter' might have again been clobbered, get it one more time... */ | 1276 | /* 'iter' might have again been clobbered, get it one more time... */ |
1108 | GNUNET_assert( | 1277 | GNUNET_assert ( |
1109 | gtk_tree_selection_get_selected(ctx->file_info_selection, NULL, &iter)); | 1278 | gtk_tree_selection_get_selected (ctx->file_info_selection, NULL, &iter)); |
1110 | 1279 | ||
1111 | /* now delete the subtree */ | 1280 | /* now delete the subtree */ |
1112 | gtk_tree_model_get(ctx->file_info_treemodel, &iter, | 1281 | gtk_tree_model_get (ctx->file_info_treemodel, |
1113 | PUBLISH_MC_FILE_INFORMATION_STRUCT, &fip, -1); | 1282 | &iter, |
1114 | GNUNET_FS_file_information_destroy(fip, &free_fi_row_reference, NULL); | 1283 | PUBLISH_MC_FILE_INFORMATION_STRUCT, |
1115 | GNUNET_FS_GTK_remove_treestore_subtree( | 1284 | &fip, |
1116 | GTK_TREE_STORE(ctx->file_info_treemodel), &iter); | 1285 | -1); |
1286 | GNUNET_FS_file_information_destroy (fip, &free_fi_row_reference, NULL); | ||
1287 | GNUNET_FS_GTK_remove_treestore_subtree (GTK_TREE_STORE ( | ||
1288 | ctx->file_info_treemodel), | ||
1289 | &iter); | ||
1117 | 1290 | ||
1118 | /* finally, select the item from 'rr' (if any) */ | 1291 | /* finally, select the item from 'rr' (if any) */ |
1119 | if (NULL != rr) { | 1292 | if (NULL != rr) |
1120 | path = gtk_tree_row_reference_get_path(rr); | 1293 | { |
1121 | gtk_tree_row_reference_free(rr); | 1294 | path = gtk_tree_row_reference_get_path (rr); |
1122 | gtk_tree_selection_select_path(ctx->file_info_selection, path); | 1295 | gtk_tree_row_reference_free (rr); |
1123 | gtk_tree_path_free(path); | 1296 | gtk_tree_selection_select_path (ctx->file_info_selection, path); |
1297 | gtk_tree_path_free (path); | ||
1124 | } | 1298 | } |
1125 | 1299 | ||
1126 | /* and now, depending on the selection, update the sensitivity of buttons */ | 1300 | /* and now, depending on the selection, update the sensitivity of buttons */ |
1127 | update_selectivity_execute_cancel(ctx); | 1301 | update_selectivity_execute_cancel (ctx); |
1128 | update_selectivity_edit(ctx); | 1302 | update_selectivity_edit (ctx); |
1129 | } | 1303 | } |
1130 | 1304 | ||
1131 | /* ******************** progress dialog / import of directories ************* */ | 1305 | /* ******************** progress dialog / import of directories ************* */ |
@@ -1136,19 +1310,23 @@ void GNUNET_GTK_master_publish_dialog_delete_button_clicked_cb( | |||
1136 | * | 1310 | * |
1137 | * @param adcc context for the progress dialog to close | 1311 | * @param adcc context for the progress dialog to close |
1138 | */ | 1312 | */ |
1139 | static void destroy_progress_dialog(struct AddDirClientContext *adcc) { | 1313 | static void |
1140 | GNUNET_assert(NULL == adcc->ds); | 1314 | destroy_progress_dialog (struct AddDirClientContext *adcc) |
1141 | if (NULL != adcc->kill_task) { | 1315 | { |
1142 | GNUNET_SCHEDULER_cancel(adcc->kill_task); | 1316 | GNUNET_assert (NULL == adcc->ds); |
1317 | if (NULL != adcc->kill_task) | ||
1318 | { | ||
1319 | GNUNET_SCHEDULER_cancel (adcc->kill_task); | ||
1143 | adcc->kill_task = NULL; | 1320 | adcc->kill_task = NULL; |
1144 | } | 1321 | } |
1145 | gtk_widget_destroy(adcc->progress_dialog); | 1322 | gtk_widget_destroy (adcc->progress_dialog); |
1146 | g_object_unref(G_OBJECT(adcc->progress_dialog_builder)); | 1323 | g_object_unref (G_OBJECT (adcc->progress_dialog_builder)); |
1147 | GNUNET_CONTAINER_DLL_remove(adcc->ctx->adddir_head, adcc->ctx->adddir_tail, | 1324 | GNUNET_CONTAINER_DLL_remove (adcc->ctx->adddir_head, |
1148 | adcc); | 1325 | adcc->ctx->adddir_tail, |
1149 | update_selectivity_execute_cancel(adcc->ctx); | 1326 | adcc); |
1150 | update_selectivity_edit(adcc->ctx); | 1327 | update_selectivity_execute_cancel (adcc->ctx); |
1151 | GNUNET_free(adcc); | 1328 | update_selectivity_edit (adcc->ctx); |
1329 | GNUNET_free (adcc); | ||
1152 | } | 1330 | } |
1153 | 1331 | ||
1154 | /** | 1332 | /** |
@@ -1158,16 +1336,19 @@ static void destroy_progress_dialog(struct AddDirClientContext *adcc) { | |||
1158 | * @param button the cancel button | 1336 | * @param button the cancel button |
1159 | * @param user_data progress dialog context of our window | 1337 | * @param user_data progress dialog context of our window |
1160 | */ | 1338 | */ |
1161 | void GNUNET_FS_GTK_progress_dialog_cancel_button_clicked_cb( | 1339 | void |
1162 | GtkButton *button, gpointer user_data) { | 1340 | GNUNET_FS_GTK_progress_dialog_cancel_button_clicked_cb (GtkButton *button, |
1341 | gpointer user_data) | ||
1342 | { | ||
1163 | struct AddDirClientContext *adcc = user_data; | 1343 | struct AddDirClientContext *adcc = user_data; |
1164 | 1344 | ||
1165 | if (NULL != adcc->ds) { | 1345 | if (NULL != adcc->ds) |
1346 | { | ||
1166 | /* signal the scanner to finish */ | 1347 | /* signal the scanner to finish */ |
1167 | GNUNET_FS_directory_scan_abort(adcc->ds); | 1348 | GNUNET_FS_directory_scan_abort (adcc->ds); |
1168 | adcc->ds = NULL; | 1349 | adcc->ds = NULL; |
1169 | } | 1350 | } |
1170 | destroy_progress_dialog(adcc); | 1351 | destroy_progress_dialog (adcc); |
1171 | } | 1352 | } |
1172 | 1353 | ||
1173 | /** | 1354 | /** |
@@ -1178,9 +1359,11 @@ void GNUNET_FS_GTK_progress_dialog_cancel_button_clicked_cb( | |||
1178 | * @param cls progress dialog context of our window | 1359 | * @param cls progress dialog context of our window |
1179 | * @return TRUE to refuse to close | 1360 | * @return TRUE to refuse to close |
1180 | */ | 1361 | */ |
1181 | gboolean GNUNET_FS_GTK_progress_dialog_delete_event_cb(GtkWidget *widget, | 1362 | gboolean |
1182 | GdkEvent *event, | 1363 | GNUNET_FS_GTK_progress_dialog_delete_event_cb (GtkWidget *widget, |
1183 | void *cls) { | 1364 | GdkEvent *event, |
1365 | void *cls) | ||
1366 | { | ||
1184 | /* Don't allow GTK to kill the window, until the scan is finished */ | 1367 | /* Don't allow GTK to kill the window, until the scan is finished */ |
1185 | return TRUE; | 1368 | return TRUE; |
1186 | } | 1369 | } |
@@ -1192,13 +1375,14 @@ gboolean GNUNET_FS_GTK_progress_dialog_delete_event_cb(GtkWidget *widget, | |||
1192 | * @param adcc progress dialog context of our window | 1375 | * @param adcc progress dialog context of our window |
1193 | * @param text text to add | 1376 | * @param text text to add |
1194 | */ | 1377 | */ |
1195 | static void insert_progress_dialog_text(struct AddDirClientContext *adcc, | 1378 | static void |
1196 | const char *text) { | 1379 | insert_progress_dialog_text (struct AddDirClientContext *adcc, const char *text) |
1197 | gtk_text_buffer_insert_at_cursor(adcc->progress_dialog_textbuffer, text, -1); | 1380 | { |
1198 | gtk_text_view_place_cursor_onscreen(adcc->progress_dialog_textview); | 1381 | gtk_text_buffer_insert_at_cursor (adcc->progress_dialog_textbuffer, text, -1); |
1199 | gtk_adjustment_set_value( | 1382 | gtk_text_view_place_cursor_onscreen (adcc->progress_dialog_textview); |
1200 | adcc->textview_vertical_adjustment, | 1383 | gtk_adjustment_set_value (adcc->textview_vertical_adjustment, |
1201 | gtk_adjustment_get_upper(adcc->textview_vertical_adjustment)); | 1384 | gtk_adjustment_get_upper ( |
1385 | adcc->textview_vertical_adjustment)); | ||
1202 | } | 1386 | } |
1203 | 1387 | ||
1204 | /** | 1388 | /** |
@@ -1211,9 +1395,14 @@ static void insert_progress_dialog_text(struct AddDirClientContext *adcc, | |||
1211 | * @param sibling predecessor of the item, can be NULL (for first) | 1395 | * @param sibling predecessor of the item, can be NULL (for first) |
1212 | * @param item_iter entry to set to the added item (OUT) | 1396 | * @param item_iter entry to set to the added item (OUT) |
1213 | */ | 1397 | */ |
1214 | static void add_item(struct AddDirClientContext *adcc, GtkTreeStore *ts, | 1398 | static void |
1215 | struct GNUNET_FS_ShareTreeItem *item, GtkTreeIter *parent, | 1399 | add_item (struct AddDirClientContext *adcc, |
1216 | GtkTreeIter *sibling, GtkTreeIter *item_iter) { | 1400 | GtkTreeStore *ts, |
1401 | struct GNUNET_FS_ShareTreeItem *item, | ||
1402 | GtkTreeIter *parent, | ||
1403 | GtkTreeIter *sibling, | ||
1404 | GtkTreeIter *item_iter) | ||
1405 | { | ||
1217 | char *file_size_fancy; | 1406 | char *file_size_fancy; |
1218 | struct GNUNET_FS_FileInformation *fi; | 1407 | struct GNUNET_FS_FileInformation *fi; |
1219 | GtkTreeRowReference *row_reference; | 1408 | GtkTreeRowReference *row_reference; |
@@ -1221,51 +1410,75 @@ static void add_item(struct AddDirClientContext *adcc, GtkTreeStore *ts, | |||
1221 | struct stat sbuf; | 1410 | struct stat sbuf; |
1222 | uint64_t fsize; | 1411 | uint64_t fsize; |
1223 | 1412 | ||
1224 | if (0 != STAT(item->filename, &sbuf)) { | 1413 | if (0 != STAT (item->filename, &sbuf)) |
1225 | GNUNET_log_strerror_file(GNUNET_ERROR_TYPE_ERROR, "stat", item->filename); | 1414 | { |
1415 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "stat", item->filename); | ||
1226 | return; | 1416 | return; |
1227 | } | 1417 | } |
1228 | 1418 | ||
1229 | if ((item->is_directory != GNUNET_YES) && | 1419 | if ((item->is_directory != GNUNET_YES) && |
1230 | (GNUNET_OK != | 1420 | (GNUNET_OK != |
1231 | GNUNET_DISK_file_size(item->filename, &fsize, GNUNET_YES, GNUNET_YES))) | 1421 | GNUNET_DISK_file_size (item->filename, &fsize, GNUNET_YES, GNUNET_YES))) |
1232 | return; | 1422 | return; |
1233 | gtk_tree_store_insert_after(ts, item_iter, parent, sibling); | 1423 | gtk_tree_store_insert_after (ts, item_iter, parent, sibling); |
1234 | path = gtk_tree_model_get_path(GTK_TREE_MODEL(ts), item_iter); | 1424 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (ts), item_iter); |
1235 | row_reference = gtk_tree_row_reference_new(GTK_TREE_MODEL(ts), path); | 1425 | row_reference = gtk_tree_row_reference_new (GTK_TREE_MODEL (ts), path); |
1236 | gtk_tree_path_free(path); | 1426 | gtk_tree_path_free (path); |
1237 | if (item->is_directory == GNUNET_YES) { | 1427 | if (item->is_directory == GNUNET_YES) |
1428 | { | ||
1238 | /* update meta data mime type (force to be GNUnet-directory) */ | 1429 | /* update meta data mime type (force to be GNUnet-directory) */ |
1239 | if (NULL != item->meta) | 1430 | if (NULL != item->meta) |
1240 | GNUNET_CONTAINER_meta_data_delete(item->meta, EXTRACTOR_METATYPE_MIMETYPE, | 1431 | GNUNET_CONTAINER_meta_data_delete (item->meta, |
1241 | NULL, 0); | 1432 | EXTRACTOR_METATYPE_MIMETYPE, |
1433 | NULL, | ||
1434 | 0); | ||
1242 | else | 1435 | else |
1243 | item->meta = GNUNET_CONTAINER_meta_data_create(); | 1436 | item->meta = GNUNET_CONTAINER_meta_data_create (); |
1244 | GNUNET_FS_meta_data_make_directory(item->meta); | 1437 | GNUNET_FS_meta_data_make_directory (item->meta); |
1245 | 1438 | ||
1246 | fi = GNUNET_FS_file_information_create_empty_directory( | 1439 | fi = GNUNET_FS_file_information_create_empty_directory ( |
1247 | GNUNET_FS_GTK_get_fs_handle(), row_reference, item->ksk_uri, item->meta, | 1440 | GNUNET_FS_GTK_get_fs_handle (), |
1248 | &adcc->directory_scan_bo, item->filename); | 1441 | row_reference, |
1249 | file_size_fancy = GNUNET_strdup(MARKER_DIR_FILE_SIZE); | 1442 | item->ksk_uri, |
1250 | } else { | 1443 | item->meta, |
1251 | fi = GNUNET_FS_file_information_create_from_file( | 1444 | &adcc->directory_scan_bo, |
1252 | GNUNET_FS_GTK_get_fs_handle(), row_reference, item->filename, | 1445 | item->filename); |
1253 | item->ksk_uri, item->meta, adcc->directory_scan_do_index, | 1446 | file_size_fancy = GNUNET_strdup (MARKER_DIR_FILE_SIZE); |
1254 | &adcc->directory_scan_bo); | 1447 | } |
1255 | file_size_fancy = GNUNET_STRINGS_byte_size_fancy(fsize); | 1448 | else |
1256 | } | 1449 | { |
1257 | gtk_tree_store_set( | 1450 | fi = |
1258 | ts, item_iter, PUBLISH_MC_FILESIZE, file_size_fancy, PUBLISH_MC_DO_INDEX, | 1451 | GNUNET_FS_file_information_create_from_file (GNUNET_FS_GTK_get_fs_handle (), |
1259 | (gboolean)adcc->directory_scan_do_index, PUBLISH_MC_FILENAME, | 1452 | row_reference, |
1260 | item->short_filename, PUBLISH_MC_ANONYMITY_LEVEL, | 1453 | item->filename, |
1261 | (guint)adcc->directory_scan_bo.anonymity_level, PUBLISH_MC_PRIORITY, | 1454 | item->ksk_uri, |
1262 | (guint)adcc->directory_scan_bo.content_priority, | 1455 | item->meta, |
1263 | PUBLISH_MC_FILE_INFORMATION_STRUCT, fi, | 1456 | adcc |
1264 | PUBLISH_MC_EXPIRATION_TIME_ABSOLUTE, | 1457 | ->directory_scan_do_index, |
1265 | (guint64)adcc->directory_scan_bo.expiration_time.abs_value_us, | 1458 | &adcc->directory_scan_bo); |
1266 | PUBLISH_MC_REPLICATION_LEVEL, | 1459 | file_size_fancy = GNUNET_STRINGS_byte_size_fancy (fsize); |
1267 | (guint)adcc->directory_scan_bo.replication_level, -1); | 1460 | } |
1268 | GNUNET_free(file_size_fancy); | 1461 | gtk_tree_store_set (ts, |
1462 | item_iter, | ||
1463 | PUBLISH_MC_FILESIZE, | ||
1464 | file_size_fancy, | ||
1465 | PUBLISH_MC_DO_INDEX, | ||
1466 | (gboolean) adcc->directory_scan_do_index, | ||
1467 | PUBLISH_MC_FILENAME, | ||
1468 | item->short_filename, | ||
1469 | PUBLISH_MC_ANONYMITY_LEVEL, | ||
1470 | (guint) adcc->directory_scan_bo.anonymity_level, | ||
1471 | PUBLISH_MC_PRIORITY, | ||
1472 | (guint) adcc->directory_scan_bo.content_priority, | ||
1473 | PUBLISH_MC_FILE_INFORMATION_STRUCT, | ||
1474 | fi, | ||
1475 | PUBLISH_MC_EXPIRATION_TIME_ABSOLUTE, | ||
1476 | (guint64) | ||
1477 | adcc->directory_scan_bo.expiration_time.abs_value_us, | ||
1478 | PUBLISH_MC_REPLICATION_LEVEL, | ||
1479 | (guint) adcc->directory_scan_bo.replication_level, | ||
1480 | -1); | ||
1481 | GNUNET_free (file_size_fancy); | ||
1269 | } | 1482 | } |
1270 | 1483 | ||
1271 | /** | 1484 | /** |
@@ -1276,21 +1489,23 @@ static void add_item(struct AddDirClientContext *adcc, GtkTreeStore *ts, | |||
1276 | * @param parent_iter parent of the current entry to add | 1489 | * @param parent_iter parent of the current entry to add |
1277 | */ | 1490 | */ |
1278 | static void | 1491 | static void |
1279 | add_share_items_to_treestore(struct AddDirClientContext *adcc, | 1492 | add_share_items_to_treestore (struct AddDirClientContext *adcc, |
1280 | struct GNUNET_FS_ShareTreeItem *toplevel, | 1493 | struct GNUNET_FS_ShareTreeItem *toplevel, |
1281 | GtkTreeIter *parent_iter) { | 1494 | GtkTreeIter *parent_iter) |
1495 | { | ||
1282 | struct MainPublishingDialogContext *ctx = adcc->ctx; | 1496 | struct MainPublishingDialogContext *ctx = adcc->ctx; |
1283 | GtkTreeStore *ts = GTK_TREE_STORE(ctx->file_info_treemodel); | 1497 | GtkTreeStore *ts = GTK_TREE_STORE (ctx->file_info_treemodel); |
1284 | GtkTreeIter *sibling_iter; | 1498 | GtkTreeIter *sibling_iter; |
1285 | GtkTreeIter last_added; | 1499 | GtkTreeIter last_added; |
1286 | struct GNUNET_FS_ShareTreeItem *item; | 1500 | struct GNUNET_FS_ShareTreeItem *item; |
1287 | 1501 | ||
1288 | sibling_iter = NULL; | 1502 | sibling_iter = NULL; |
1289 | for (item = toplevel; NULL != item; item = item->next) { | 1503 | for (item = toplevel; NULL != item; item = item->next) |
1290 | add_item(adcc, ts, item, parent_iter, sibling_iter, &last_added); | 1504 | { |
1505 | add_item (adcc, ts, item, parent_iter, sibling_iter, &last_added); | ||
1291 | sibling_iter = &last_added; | 1506 | sibling_iter = &last_added; |
1292 | if (item->is_directory == GNUNET_YES) | 1507 | if (item->is_directory == GNUNET_YES) |
1293 | add_share_items_to_treestore(adcc, item->children_head, sibling_iter); | 1508 | add_share_items_to_treestore (adcc, item->children_head, sibling_iter); |
1294 | } | 1509 | } |
1295 | } | 1510 | } |
1296 | 1511 | ||
@@ -1301,12 +1516,15 @@ add_share_items_to_treestore(struct AddDirClientContext *adcc, | |||
1301 | * | 1516 | * |
1302 | * @param cls progress dialog context of our window | 1517 | * @param cls progress dialog context of our window |
1303 | */ | 1518 | */ |
1304 | static void stop_scanner_task(void *cls) { | 1519 | static void |
1520 | stop_scanner_task (void *cls) | ||
1521 | { | ||
1305 | struct AddDirClientContext *adcc = cls; | 1522 | struct AddDirClientContext *adcc = cls; |
1306 | 1523 | ||
1307 | adcc->kill_task = NULL; | 1524 | adcc->kill_task = NULL; |
1308 | if (NULL != adcc->ds) { | 1525 | if (NULL != adcc->ds) |
1309 | GNUNET_FS_directory_scan_abort(adcc->ds); | 1526 | { |
1527 | GNUNET_FS_directory_scan_abort (adcc->ds); | ||
1310 | adcc->ds = NULL; | 1528 | adcc->ds = NULL; |
1311 | } | 1529 | } |
1312 | } | 1530 | } |
@@ -1322,26 +1540,33 @@ static void stop_scanner_task(void *cls) { | |||
1322 | * @param reason kind of progress that was made | 1540 | * @param reason kind of progress that was made |
1323 | */ | 1541 | */ |
1324 | static void | 1542 | static void |
1325 | directory_scan_cb(void *cls, const char *filename, int is_directory, | 1543 | directory_scan_cb (void *cls, |
1326 | enum GNUNET_FS_DirScannerProgressUpdateReason reason) { | 1544 | const char *filename, |
1545 | int is_directory, | ||
1546 | enum GNUNET_FS_DirScannerProgressUpdateReason reason) | ||
1547 | { | ||
1327 | struct AddDirClientContext *adcc = cls; | 1548 | struct AddDirClientContext *adcc = cls; |
1328 | static struct GNUNET_TIME_Absolute last_pulse; | 1549 | static struct GNUNET_TIME_Absolute last_pulse; |
1329 | char *s; | 1550 | char *s; |
1330 | gdouble fraction; | 1551 | gdouble fraction; |
1331 | 1552 | ||
1332 | switch (reason) { | 1553 | switch (reason) |
1554 | { | ||
1333 | case GNUNET_FS_DIRSCANNER_FILE_START: | 1555 | case GNUNET_FS_DIRSCANNER_FILE_START: |
1334 | GNUNET_assert(NULL != filename); | 1556 | GNUNET_assert (NULL != filename); |
1335 | if (GNUNET_TIME_absolute_get_duration(last_pulse).rel_value_us > 100000LL) { | 1557 | if (GNUNET_TIME_absolute_get_duration (last_pulse).rel_value_us > 100000LL) |
1336 | gtk_progress_bar_pulse(adcc->progress_dialog_bar); | 1558 | { |
1337 | last_pulse = GNUNET_TIME_absolute_get(); | 1559 | gtk_progress_bar_pulse (adcc->progress_dialog_bar); |
1560 | last_pulse = GNUNET_TIME_absolute_get (); | ||
1338 | } | 1561 | } |
1339 | #if VERBOSE_PROGRESS | 1562 | #if VERBOSE_PROGRESS |
1340 | if (is_directory == GNUNET_YES) { | 1563 | if (is_directory == GNUNET_YES) |
1341 | GNUNET_asprintf(&s, _("Scanning directory `%s'.\n"), filename); | 1564 | { |
1342 | insert_progress_dialog_text(adcc, s); | 1565 | GNUNET_asprintf (&s, _ ("Scanning directory `%s'.\n"), filename); |
1343 | GNUNET_free(s); | 1566 | insert_progress_dialog_text (adcc, s); |
1344 | } else | 1567 | GNUNET_free (s); |
1568 | } | ||
1569 | else | ||
1345 | adcc->total++; | 1570 | adcc->total++; |
1346 | #else | 1571 | #else |
1347 | if (is_directory != GNUNET_YES) | 1572 | if (is_directory != GNUNET_YES) |
@@ -1349,60 +1574,70 @@ directory_scan_cb(void *cls, const char *filename, int is_directory, | |||
1349 | #endif | 1574 | #endif |
1350 | break; | 1575 | break; |
1351 | case GNUNET_FS_DIRSCANNER_FILE_IGNORED: | 1576 | case GNUNET_FS_DIRSCANNER_FILE_IGNORED: |
1352 | GNUNET_assert(NULL != filename); | 1577 | GNUNET_assert (NULL != filename); |
1353 | GNUNET_asprintf(&s, _("Failed to scan `%s' (access error). Skipping.\n"), | 1578 | GNUNET_asprintf (&s, |
1354 | filename); | 1579 | _ ("Failed to scan `%s' (access error). Skipping.\n"), |
1355 | #if !VERBOSE_PROGRESS | 1580 | filename); |
1356 | gtk_widget_show(GTK_WIDGET(gtk_builder_get_object( | 1581 | #if ! VERBOSE_PROGRESS |
1357 | adcc->progress_dialog_builder, | 1582 | gtk_widget_show (GTK_WIDGET ( |
1358 | "GNUNET_FS_GTK_progress_dialog_scrolled_window"))); | 1583 | gtk_builder_get_object (adcc->progress_dialog_builder, |
1584 | "GNUNET_FS_GTK_progress_dialog_scrolled_window"))); | ||
1359 | #endif | 1585 | #endif |
1360 | insert_progress_dialog_text(adcc, s); | 1586 | insert_progress_dialog_text (adcc, s); |
1361 | GNUNET_free(s); | 1587 | GNUNET_free (s); |
1362 | break; | 1588 | break; |
1363 | case GNUNET_FS_DIRSCANNER_ALL_COUNTED: | 1589 | case GNUNET_FS_DIRSCANNER_ALL_COUNTED: |
1364 | fraction = (adcc->total == 0) ? 1.0 : (1.0 * adcc->done) / adcc->total; | 1590 | fraction = (adcc->total == 0) ? 1.0 : (1.0 * adcc->done) / adcc->total; |
1365 | GNUNET_asprintf(&s, "%u/%u (%3f%%)", adcc->done, adcc->total, | 1591 | GNUNET_asprintf (&s, |
1366 | 100.0 * fraction); | 1592 | "%u/%u (%3f%%)", |
1367 | gtk_progress_bar_set_text(adcc->progress_dialog_bar, s); | 1593 | adcc->done, |
1368 | GNUNET_free(s); | 1594 | adcc->total, |
1369 | gtk_progress_bar_set_fraction(adcc->progress_dialog_bar, fraction); | 1595 | 100.0 * fraction); |
1596 | gtk_progress_bar_set_text (adcc->progress_dialog_bar, s); | ||
1597 | GNUNET_free (s); | ||
1598 | gtk_progress_bar_set_fraction (adcc->progress_dialog_bar, fraction); | ||
1370 | break; | 1599 | break; |
1371 | case GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED: | 1600 | case GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED: |
1372 | GNUNET_assert(NULL != filename); | 1601 | GNUNET_assert (NULL != filename); |
1373 | #if VERBOSE_PROGRESS | 1602 | #if VERBOSE_PROGRESS |
1374 | GNUNET_asprintf(&s, _("Processed file `%s'.\n"), filename); | 1603 | GNUNET_asprintf (&s, _ ("Processed file `%s'.\n"), filename); |
1375 | insert_progress_dialog_text(adcc, s); | 1604 | insert_progress_dialog_text (adcc, s); |
1376 | GNUNET_free(s); | 1605 | GNUNET_free (s); |
1377 | #endif | 1606 | #endif |
1378 | adcc->done++; | 1607 | adcc->done++; |
1379 | GNUNET_assert(adcc->done <= adcc->total); | 1608 | GNUNET_assert (adcc->done <= adcc->total); |
1380 | fraction = (adcc->total == 0) ? 1.0 : (1.0 * adcc->done) / adcc->total; | 1609 | fraction = (adcc->total == 0) ? 1.0 : (1.0 * adcc->done) / adcc->total; |
1381 | GNUNET_asprintf(&s, "%u/%u (%3f%%)", adcc->done, adcc->total, | 1610 | GNUNET_asprintf (&s, |
1382 | 100.0 * fraction); | 1611 | "%u/%u (%3f%%)", |
1383 | gtk_progress_bar_set_text(adcc->progress_dialog_bar, s); | 1612 | adcc->done, |
1384 | GNUNET_free(s); | 1613 | adcc->total, |
1385 | gtk_progress_bar_set_fraction(adcc->progress_dialog_bar, fraction); | 1614 | 100.0 * fraction); |
1615 | gtk_progress_bar_set_text (adcc->progress_dialog_bar, s); | ||
1616 | GNUNET_free (s); | ||
1617 | gtk_progress_bar_set_fraction (adcc->progress_dialog_bar, fraction); | ||
1386 | break; | 1618 | break; |
1387 | case GNUNET_FS_DIRSCANNER_INTERNAL_ERROR: | 1619 | case GNUNET_FS_DIRSCANNER_INTERNAL_ERROR: |
1388 | if ((NULL != adcc->ds) && (NULL == adcc->kill_task)) { | 1620 | if ((NULL != adcc->ds) && (NULL == adcc->kill_task)) |
1389 | insert_progress_dialog_text(adcc, _("Operation failed (press cancel)\n")); | 1621 | { |
1390 | adcc->kill_task = GNUNET_SCHEDULER_add_now(&stop_scanner_task, adcc); | 1622 | insert_progress_dialog_text (adcc, |
1623 | _ ("Operation failed (press cancel)\n")); | ||
1624 | adcc->kill_task = GNUNET_SCHEDULER_add_now (&stop_scanner_task, adcc); | ||
1391 | } | 1625 | } |
1392 | break; | 1626 | break; |
1393 | case GNUNET_FS_DIRSCANNER_FINISHED: { | 1627 | case GNUNET_FS_DIRSCANNER_FINISHED: { |
1394 | struct GNUNET_FS_ShareTreeItem *directory_scan_result; | 1628 | struct GNUNET_FS_ShareTreeItem *directory_scan_result; |
1395 | 1629 | ||
1396 | insert_progress_dialog_text(adcc, _("Scanner has finished.\n")); | 1630 | insert_progress_dialog_text (adcc, _ ("Scanner has finished.\n")); |
1397 | directory_scan_result = GNUNET_FS_directory_scan_get_result(adcc->ds); | 1631 | directory_scan_result = GNUNET_FS_directory_scan_get_result (adcc->ds); |
1398 | adcc->ds = NULL; | 1632 | adcc->ds = NULL; |
1399 | GNUNET_FS_share_tree_trim(directory_scan_result); | 1633 | GNUNET_FS_share_tree_trim (directory_scan_result); |
1400 | add_share_items_to_treestore(adcc, directory_scan_result, NULL); | 1634 | add_share_items_to_treestore (adcc, directory_scan_result, NULL); |
1401 | GNUNET_FS_share_tree_free(directory_scan_result); | 1635 | GNUNET_FS_share_tree_free (directory_scan_result); |
1402 | destroy_progress_dialog(adcc); | 1636 | destroy_progress_dialog (adcc); |
1403 | } break; | 1637 | } |
1638 | break; | ||
1404 | default: | 1639 | default: |
1405 | GNUNET_break(0); | 1640 | GNUNET_break (0); |
1406 | break; | 1641 | break; |
1407 | } | 1642 | } |
1408 | } | 1643 | } |
@@ -1417,47 +1652,54 @@ directory_scan_cb(void *cls, const char *filename, int is_directory, | |||
1417 | * @param bo options for the operation | 1652 | * @param bo options for the operation |
1418 | * @param do_index should we index or insert files (by default) | 1653 | * @param do_index should we index or insert files (by default) |
1419 | */ | 1654 | */ |
1420 | static void scan_file_or_directory(struct MainPublishingDialogContext *ctx, | 1655 | static void |
1421 | gchar *filename, | 1656 | scan_file_or_directory (struct MainPublishingDialogContext *ctx, |
1422 | struct GNUNET_FS_BlockOptions *bo, | 1657 | gchar *filename, |
1423 | int do_index) { | 1658 | struct GNUNET_FS_BlockOptions *bo, |
1659 | int do_index) | ||
1660 | { | ||
1424 | struct AddDirClientContext *adcc; | 1661 | struct AddDirClientContext *adcc; |
1425 | 1662 | ||
1426 | adcc = GNUNET_new(struct AddDirClientContext); | 1663 | adcc = GNUNET_new (struct AddDirClientContext); |
1427 | adcc->ctx = ctx; | 1664 | adcc->ctx = ctx; |
1428 | GNUNET_CONTAINER_DLL_insert_tail(ctx->adddir_head, ctx->adddir_tail, adcc); | 1665 | GNUNET_CONTAINER_DLL_insert_tail (ctx->adddir_head, ctx->adddir_tail, adcc); |
1429 | adcc->directory_scan_bo = *bo; | 1666 | adcc->directory_scan_bo = *bo; |
1430 | adcc->directory_scan_do_index = do_index; | 1667 | adcc->directory_scan_do_index = do_index; |
1431 | 1668 | ||
1432 | /* setup the dialog and get the widgets we need most */ | 1669 | /* setup the dialog and get the widgets we need most */ |
1433 | adcc->progress_dialog_builder = | 1670 | adcc->progress_dialog_builder = |
1434 | GNUNET_GTK_get_new_builder("gnunet_fs_gtk_progress_dialog.glade", adcc); | 1671 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_progress_dialog.glade", adcc); |
1435 | adcc->progress_dialog = GTK_WIDGET(gtk_builder_get_object( | 1672 | adcc->progress_dialog = |
1436 | adcc->progress_dialog_builder, "GNUNET_FS_GTK_progress_dialog")); | 1673 | GTK_WIDGET (gtk_builder_get_object (adcc->progress_dialog_builder, |
1437 | adcc->progress_dialog_bar = GTK_PROGRESS_BAR( | 1674 | "GNUNET_FS_GTK_progress_dialog")); |
1438 | gtk_builder_get_object(adcc->progress_dialog_builder, | 1675 | adcc->progress_dialog_bar = GTK_PROGRESS_BAR ( |
1439 | "GNUNET_FS_GTK_progress_dialog_progressbar")); | 1676 | gtk_builder_get_object (adcc->progress_dialog_builder, |
1440 | adcc->progress_dialog_textview = GTK_TEXT_VIEW(gtk_builder_get_object( | 1677 | "GNUNET_FS_GTK_progress_dialog_progressbar")); |
1441 | adcc->progress_dialog_builder, "GNUNET_FS_GTK_progress_dialog_textview")); | 1678 | adcc->progress_dialog_textview = GTK_TEXT_VIEW ( |
1442 | adcc->textview_vertical_adjustment = GTK_ADJUSTMENT(gtk_builder_get_object( | 1679 | gtk_builder_get_object (adcc->progress_dialog_builder, |
1443 | adcc->progress_dialog_builder, | 1680 | "GNUNET_FS_GTK_progress_dialog_textview")); |
1444 | "GNUNET_FS_GTK_progress_dialog_textview_vertical_adjustment")); | 1681 | adcc->textview_vertical_adjustment = GTK_ADJUSTMENT (gtk_builder_get_object ( |
1445 | adcc->progress_dialog_textbuffer = GTK_TEXT_BUFFER( | 1682 | adcc->progress_dialog_builder, |
1446 | gtk_builder_get_object(adcc->progress_dialog_builder, | 1683 | "GNUNET_FS_GTK_progress_dialog_textview_vertical_adjustment")); |
1447 | "GNUNET_FS_GTK_progress_dialog_textbuffer")); | 1684 | adcc->progress_dialog_textbuffer = GTK_TEXT_BUFFER ( |
1685 | gtk_builder_get_object (adcc->progress_dialog_builder, | ||
1686 | "GNUNET_FS_GTK_progress_dialog_textbuffer")); | ||
1448 | 1687 | ||
1449 | /* show the window */ | 1688 | /* show the window */ |
1450 | gtk_window_set_transient_for(GTK_WINDOW(adcc->progress_dialog), | 1689 | gtk_window_set_transient_for (GTK_WINDOW (adcc->progress_dialog), |
1451 | adcc->ctx->master_pubdialog); | 1690 | adcc->ctx->master_pubdialog); |
1452 | gtk_window_set_title(GTK_WINDOW(adcc->progress_dialog), filename); | 1691 | gtk_window_set_title (GTK_WINDOW (adcc->progress_dialog), filename); |
1453 | gtk_window_present(GTK_WINDOW(adcc->progress_dialog)); | 1692 | gtk_window_present (GTK_WINDOW (adcc->progress_dialog)); |
1454 | 1693 | ||
1455 | /* actually start the scan */ | 1694 | /* actually start the scan */ |
1456 | adcc->ds = GNUNET_FS_directory_scan_start(filename, GNUNET_NO, NULL, | 1695 | adcc->ds = GNUNET_FS_directory_scan_start (filename, |
1457 | &directory_scan_cb, adcc); | 1696 | GNUNET_NO, |
1697 | NULL, | ||
1698 | &directory_scan_cb, | ||
1699 | adcc); | ||
1458 | 1700 | ||
1459 | /* disables 'cancel' button of the master dialog */ | 1701 | /* disables 'cancel' button of the master dialog */ |
1460 | update_selectivity_execute_cancel(ctx); | 1702 | update_selectivity_execute_cancel (ctx); |
1461 | } | 1703 | } |
1462 | 1704 | ||
1463 | /** | 1705 | /** |
@@ -1467,50 +1709,54 @@ static void scan_file_or_directory(struct MainPublishingDialogContext *ctx, | |||
1467 | * @param response_id result of the dialog (GTK_RESPONSE_OK means to "run") | 1709 | * @param response_id result of the dialog (GTK_RESPONSE_OK means to "run") |
1468 | * @param user_data master publishing dialog context of our window | 1710 | * @param user_data master publishing dialog context of our window |
1469 | */ | 1711 | */ |
1470 | void GNUNET_GTK_publish_directory_dialog_response_cb(GtkDialog *dialog, | 1712 | void |
1471 | gint response_id, | 1713 | GNUNET_GTK_publish_directory_dialog_response_cb (GtkDialog *dialog, |
1472 | gpointer user_data) { | 1714 | gint response_id, |
1715 | gpointer user_data) | ||
1716 | { | ||
1473 | struct MainPublishingDialogContext *ctx = user_data; | 1717 | struct MainPublishingDialogContext *ctx = user_data; |
1474 | 1718 | ||
1475 | if (GTK_RESPONSE_OK == response_id) { | 1719 | if (GTK_RESPONSE_OK == response_id) |
1720 | { | ||
1476 | char *filename; | 1721 | char *filename; |
1477 | int do_index; | 1722 | int do_index; |
1478 | struct GNUNET_FS_BlockOptions bo; | 1723 | struct GNUNET_FS_BlockOptions bo; |
1479 | 1724 | ||
1480 | filename = | 1725 | filename = |
1481 | GNUNET_GTK_filechooser_get_filename_utf8(GTK_FILE_CHOOSER(dialog)); | 1726 | GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER (dialog)); |
1482 | if (!GNUNET_GTK_get_selected_anonymity_level( | 1727 | if (! GNUNET_GTK_get_selected_anonymity_level ( |
1483 | ctx->open_directory_builder, | 1728 | ctx->open_directory_builder, |
1484 | "GNUNET_GTK_publish_directory_dialog_anonymity_combobox", | 1729 | "GNUNET_GTK_publish_directory_dialog_anonymity_combobox", |
1485 | &bo.anonymity_level)) { | 1730 | &bo.anonymity_level)) |
1486 | GNUNET_break(0); | 1731 | { |
1732 | GNUNET_break (0); | ||
1487 | bo.anonymity_level = 1; | 1733 | bo.anonymity_level = 1; |
1488 | } | 1734 | } |
1489 | bo.content_priority = | 1735 | bo.content_priority = |
1490 | gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object( | 1736 | gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object ( |
1491 | ctx->open_directory_builder, | 1737 | ctx->open_directory_builder, |
1492 | "GNUNET_GTK_publish_directory_dialog_priority_spin_button"))); | 1738 | "GNUNET_GTK_publish_directory_dialog_priority_spin_button"))); |
1493 | bo.replication_level = | 1739 | bo.replication_level = |
1494 | gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object( | 1740 | gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object ( |
1495 | ctx->open_directory_builder, | 1741 | ctx->open_directory_builder, |
1496 | "GNUNET_GTK_publish_directory_dialog_replication_spin_button"))); | 1742 | "GNUNET_GTK_publish_directory_dialog_replication_spin_button"))); |
1497 | { | 1743 | { |
1498 | GtkSpinButton *sb; | 1744 | GtkSpinButton *sb; |
1499 | 1745 | ||
1500 | sb = GTK_SPIN_BUTTON(gtk_builder_get_object( | 1746 | sb = GTK_SPIN_BUTTON (gtk_builder_get_object ( |
1501 | ctx->open_directory_builder, | 1747 | ctx->open_directory_builder, |
1502 | "GNUNET_GTK_publish_directory_dialog_expiration_year_spin_button")); | 1748 | "GNUNET_GTK_publish_directory_dialog_expiration_year_spin_button")); |
1503 | bo.expiration_time = GNUNET_GTK_get_expiration_time(sb); | 1749 | bo.expiration_time = GNUNET_GTK_get_expiration_time (sb); |
1504 | } | 1750 | } |
1505 | do_index = | 1751 | do_index = |
1506 | gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object( | 1752 | gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object ( |
1507 | ctx->open_directory_builder, | 1753 | ctx->open_directory_builder, |
1508 | "GNUNET_GTK_publish_directory_dialog_do_index_checkbutton"))); | 1754 | "GNUNET_GTK_publish_directory_dialog_do_index_checkbutton"))); |
1509 | scan_file_or_directory(ctx, filename, &bo, do_index); | 1755 | scan_file_or_directory (ctx, filename, &bo, do_index); |
1510 | g_free(filename); | 1756 | g_free (filename); |
1511 | } | 1757 | } |
1512 | gtk_widget_destroy(GTK_WIDGET(dialog)); | 1758 | gtk_widget_destroy (GTK_WIDGET (dialog)); |
1513 | g_object_unref(G_OBJECT(ctx->open_directory_builder)); | 1759 | g_object_unref (G_OBJECT (ctx->open_directory_builder)); |
1514 | ctx->open_directory_builder = NULL; | 1760 | ctx->open_directory_builder = NULL; |
1515 | } | 1761 | } |
1516 | 1762 | ||
@@ -1521,51 +1767,55 @@ void GNUNET_GTK_publish_directory_dialog_response_cb(GtkDialog *dialog, | |||
1521 | * @param response_id result of the dialog (GTK_RESPONSE_OK means to "run") | 1767 | * @param response_id result of the dialog (GTK_RESPONSE_OK means to "run") |
1522 | * @param user_data master publishing dialog context of our window | 1768 | * @param user_data master publishing dialog context of our window |
1523 | */ | 1769 | */ |
1524 | void GNUNET_GTK_publish_file_dialog_response_cb(GtkDialog *dialog, | 1770 | void |
1525 | gint response_id, | 1771 | GNUNET_GTK_publish_file_dialog_response_cb (GtkDialog *dialog, |
1526 | gpointer user_data) { | 1772 | gint response_id, |
1773 | gpointer user_data) | ||
1774 | { | ||
1527 | struct MainPublishingDialogContext *ctx = user_data; | 1775 | struct MainPublishingDialogContext *ctx = user_data; |
1528 | 1776 | ||
1529 | if (GTK_RESPONSE_OK == response_id) { | 1777 | if (GTK_RESPONSE_OK == response_id) |
1778 | { | ||
1530 | char *filename; | 1779 | char *filename; |
1531 | struct GNUNET_FS_BlockOptions bo; | 1780 | struct GNUNET_FS_BlockOptions bo; |
1532 | int do_index; | 1781 | int do_index; |
1533 | 1782 | ||
1534 | filename = | 1783 | filename = |
1535 | GNUNET_GTK_filechooser_get_filename_utf8(GTK_FILE_CHOOSER(dialog)); | 1784 | GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER (dialog)); |
1536 | if (!GNUNET_GTK_get_selected_anonymity_level( | 1785 | if (! GNUNET_GTK_get_selected_anonymity_level ( |
1537 | ctx->open_file_builder, | 1786 | ctx->open_file_builder, |
1538 | "GNUNET_GTK_publish_file_dialog_anonymity_combobox", | 1787 | "GNUNET_GTK_publish_file_dialog_anonymity_combobox", |
1539 | &bo.anonymity_level)) { | 1788 | &bo.anonymity_level)) |
1540 | GNUNET_break(0); | 1789 | { |
1790 | GNUNET_break (0); | ||
1541 | bo.anonymity_level = 1; | 1791 | bo.anonymity_level = 1; |
1542 | } | 1792 | } |
1543 | bo.content_priority = | 1793 | bo.content_priority = |
1544 | gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object( | 1794 | gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object ( |
1545 | ctx->open_file_builder, | 1795 | ctx->open_file_builder, |
1546 | "GNUNET_GTK_publish_file_dialog_priority_spin_button"))); | 1796 | "GNUNET_GTK_publish_file_dialog_priority_spin_button"))); |
1547 | { | 1797 | { |
1548 | GtkSpinButton *sb; | 1798 | GtkSpinButton *sb; |
1549 | 1799 | ||
1550 | sb = GTK_SPIN_BUTTON(gtk_builder_get_object( | 1800 | sb = GTK_SPIN_BUTTON (gtk_builder_get_object ( |
1551 | ctx->open_file_builder, | 1801 | ctx->open_file_builder, |
1552 | "GNUNET_GTK_publish_file_dialog_expiration_year_spin_button")); | 1802 | "GNUNET_GTK_publish_file_dialog_expiration_year_spin_button")); |
1553 | bo.expiration_time = GNUNET_GTK_get_expiration_time(sb); | 1803 | bo.expiration_time = GNUNET_GTK_get_expiration_time (sb); |
1554 | } | 1804 | } |
1555 | bo.replication_level = | 1805 | bo.replication_level = |
1556 | gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object( | 1806 | gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object ( |
1557 | ctx->open_file_builder, | 1807 | ctx->open_file_builder, |
1558 | "GNUNET_GTK_publish_file_dialog_replication_spin_button"))); | 1808 | "GNUNET_GTK_publish_file_dialog_replication_spin_button"))); |
1559 | do_index = | 1809 | do_index = |
1560 | gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object( | 1810 | gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object ( |
1561 | ctx->open_file_builder, | 1811 | ctx->open_file_builder, |
1562 | "GNUNET_GTK_publish_file_dialog_do_index_checkbutton"))); | 1812 | "GNUNET_GTK_publish_file_dialog_do_index_checkbutton"))); |
1563 | 1813 | ||
1564 | scan_file_or_directory(ctx, filename, &bo, do_index); | 1814 | scan_file_or_directory (ctx, filename, &bo, do_index); |
1565 | g_free(filename); | 1815 | g_free (filename); |
1566 | } | 1816 | } |
1567 | gtk_widget_destroy(GTK_WIDGET(dialog)); | 1817 | gtk_widget_destroy (GTK_WIDGET (dialog)); |
1568 | g_object_unref(G_OBJECT(ctx->open_file_builder)); | 1818 | g_object_unref (G_OBJECT (ctx->open_file_builder)); |
1569 | ctx->open_file_builder = NULL; | 1819 | ctx->open_file_builder = NULL; |
1570 | } | 1820 | } |
1571 | 1821 | ||
@@ -1578,50 +1828,52 @@ void GNUNET_GTK_publish_file_dialog_response_cb(GtkDialog *dialog, | |||
1578 | * @param dummy the button that was pressed | 1828 | * @param dummy the button that was pressed |
1579 | * @param user_data master publishing dialog context of our window | 1829 | * @param user_data master publishing dialog context of our window |
1580 | */ | 1830 | */ |
1581 | void GNUNET_GTK_master_publish_dialog_add_button_clicked_cb( | 1831 | void |
1582 | GtkWidget *dummy, gpointer user_data) { | 1832 | GNUNET_GTK_master_publish_dialog_add_button_clicked_cb (GtkWidget *dummy, |
1833 | gpointer user_data) | ||
1834 | { | ||
1583 | struct MainPublishingDialogContext *ctx = user_data; | 1835 | struct MainPublishingDialogContext *ctx = user_data; |
1584 | 1836 | ||
1585 | ctx->open_file_builder = GNUNET_GTK_get_new_builder( | 1837 | ctx->open_file_builder = |
1586 | "gnunet_fs_gtk_publish_file_dialog.glade", ctx); | 1838 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_publish_file_dialog.glade", ctx); |
1587 | GNUNET_GTK_setup_expiration_year_adjustment(ctx->open_file_builder); | 1839 | GNUNET_GTK_setup_expiration_year_adjustment (ctx->open_file_builder); |
1588 | 1840 | ||
1589 | /* FIXME-FEATURE: Use some kind of adjustable defaults instead of 1000, 0 and | 1841 | /* FIXME-FEATURE: Use some kind of adjustable defaults instead of 1000, 0 and |
1590 | * TRUE */ | 1842 | * TRUE */ |
1591 | gtk_spin_button_set_value( | 1843 | gtk_spin_button_set_value ( |
1592 | GTK_SPIN_BUTTON(gtk_builder_get_object( | 1844 | GTK_SPIN_BUTTON (gtk_builder_get_object ( |
1593 | ctx->open_file_builder, | 1845 | ctx->open_file_builder, |
1594 | "GNUNET_GTK_publish_file_dialog_priority_spin_button")), | 1846 | "GNUNET_GTK_publish_file_dialog_priority_spin_button")), |
1595 | 1000); | 1847 | 1000); |
1596 | gtk_spin_button_set_value( | 1848 | gtk_spin_button_set_value ( |
1597 | GTK_SPIN_BUTTON(gtk_builder_get_object( | 1849 | GTK_SPIN_BUTTON (gtk_builder_get_object ( |
1598 | ctx->open_file_builder, | 1850 | ctx->open_file_builder, |
1599 | "GNUNET_GTK_publish_file_dialog_replication_spin_button")), | 1851 | "GNUNET_GTK_publish_file_dialog_replication_spin_button")), |
1600 | 0); | 1852 | 0); |
1601 | gtk_toggle_button_set_active( | 1853 | gtk_toggle_button_set_active ( |
1602 | GTK_TOGGLE_BUTTON(gtk_builder_get_object( | 1854 | GTK_TOGGLE_BUTTON (gtk_builder_get_object ( |
1603 | ctx->open_file_builder, | 1855 | ctx->open_file_builder, |
1604 | "GNUNET_GTK_publish_file_dialog_do_index_checkbutton")), | 1856 | "GNUNET_GTK_publish_file_dialog_do_index_checkbutton")), |
1605 | TRUE); | 1857 | TRUE); |
1606 | 1858 | ||
1607 | { | 1859 | { |
1608 | GtkComboBox *combo; | 1860 | GtkComboBox *combo; |
1609 | 1861 | ||
1610 | combo = GTK_COMBO_BOX(gtk_builder_get_object( | 1862 | combo = GTK_COMBO_BOX ( |
1611 | ctx->open_file_builder, | 1863 | gtk_builder_get_object (ctx->open_file_builder, |
1612 | "GNUNET_GTK_publish_file_dialog_anonymity_combobox")); | 1864 | "GNUNET_GTK_publish_file_dialog_anonymity_combobox")); |
1613 | gtk_combo_box_set_model(combo, | 1865 | gtk_combo_box_set_model (combo, |
1614 | GNUNET_FS_GTK_get_anonymity_level_list_store()); | 1866 | GNUNET_FS_GTK_get_anonymity_level_list_store ()); |
1615 | } | 1867 | } |
1616 | 1868 | ||
1617 | /* show dialog */ | 1869 | /* show dialog */ |
1618 | { | 1870 | { |
1619 | GtkWidget *ad; | 1871 | GtkWidget *ad; |
1620 | 1872 | ||
1621 | ad = GTK_WIDGET(gtk_builder_get_object(ctx->open_file_builder, | 1873 | ad = GTK_WIDGET (gtk_builder_get_object (ctx->open_file_builder, |
1622 | "GNUNET_GTK_publish_file_dialog")); | 1874 | "GNUNET_GTK_publish_file_dialog")); |
1623 | gtk_window_set_transient_for(GTK_WINDOW(ad), ctx->master_pubdialog); | 1875 | gtk_window_set_transient_for (GTK_WINDOW (ad), ctx->master_pubdialog); |
1624 | gtk_window_present(GTK_WINDOW(ad)); | 1876 | gtk_window_present (GTK_WINDOW (ad)); |
1625 | } | 1877 | } |
1626 | } | 1878 | } |
1627 | 1879 | ||
@@ -1634,50 +1886,54 @@ void GNUNET_GTK_master_publish_dialog_add_button_clicked_cb( | |||
1634 | * @param dummy the button that was pressed | 1886 | * @param dummy the button that was pressed |
1635 | * @param user_data master publishing dialog context of our window | 1887 | * @param user_data master publishing dialog context of our window |
1636 | */ | 1888 | */ |
1637 | void GNUNET_GTK_master_publish_dialog_open_button_clicked_cb( | 1889 | void |
1638 | GtkWidget *dummy, gpointer user_data) { | 1890 | GNUNET_GTK_master_publish_dialog_open_button_clicked_cb (GtkWidget *dummy, |
1891 | gpointer user_data) | ||
1892 | { | ||
1639 | struct MainPublishingDialogContext *ctx = user_data; | 1893 | struct MainPublishingDialogContext *ctx = user_data; |
1640 | 1894 | ||
1641 | ctx->open_directory_builder = GNUNET_GTK_get_new_builder( | 1895 | ctx->open_directory_builder = |
1642 | "gnunet_fs_gtk_publish_directory_dialog.glade", ctx); | 1896 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_publish_directory_dialog.glade", |
1643 | GNUNET_GTK_setup_expiration_year_adjustment(ctx->open_directory_builder); | 1897 | ctx); |
1898 | GNUNET_GTK_setup_expiration_year_adjustment (ctx->open_directory_builder); | ||
1644 | 1899 | ||
1645 | /* FIXME-FEATURE: Use some kind of adjustable defaults instead of 1000, 0 and | 1900 | /* FIXME-FEATURE: Use some kind of adjustable defaults instead of 1000, 0 and |
1646 | * TRUE */ | 1901 | * TRUE */ |
1647 | gtk_spin_button_set_value( | 1902 | gtk_spin_button_set_value ( |
1648 | GTK_SPIN_BUTTON(gtk_builder_get_object( | 1903 | GTK_SPIN_BUTTON (gtk_builder_get_object ( |
1649 | ctx->open_directory_builder, | 1904 | ctx->open_directory_builder, |
1650 | "GNUNET_GTK_publish_directory_dialog_priority_spin_button")), | 1905 | "GNUNET_GTK_publish_directory_dialog_priority_spin_button")), |
1651 | 1000); | 1906 | 1000); |
1652 | gtk_spin_button_set_value( | 1907 | gtk_spin_button_set_value ( |
1653 | GTK_SPIN_BUTTON(gtk_builder_get_object( | 1908 | GTK_SPIN_BUTTON (gtk_builder_get_object ( |
1654 | ctx->open_directory_builder, | 1909 | ctx->open_directory_builder, |
1655 | "GNUNET_GTK_publish_directory_dialog_replication_spin_button")), | 1910 | "GNUNET_GTK_publish_directory_dialog_replication_spin_button")), |
1656 | 0); | 1911 | 0); |
1657 | gtk_toggle_button_set_active( | 1912 | gtk_toggle_button_set_active ( |
1658 | GTK_TOGGLE_BUTTON(gtk_builder_get_object( | 1913 | GTK_TOGGLE_BUTTON (gtk_builder_get_object ( |
1659 | ctx->open_directory_builder, | 1914 | ctx->open_directory_builder, |
1660 | "GNUNET_GTK_publish_directory_dialog_do_index_checkbutton")), | 1915 | "GNUNET_GTK_publish_directory_dialog_do_index_checkbutton")), |
1661 | TRUE); | 1916 | TRUE); |
1662 | 1917 | ||
1663 | { | 1918 | { |
1664 | GtkComboBox *combo; | 1919 | GtkComboBox *combo; |
1665 | 1920 | ||
1666 | combo = GTK_COMBO_BOX(gtk_builder_get_object( | 1921 | combo = GTK_COMBO_BOX (gtk_builder_get_object ( |
1667 | ctx->open_directory_builder, | 1922 | ctx->open_directory_builder, |
1668 | "GNUNET_GTK_publish_directory_dialog_anonymity_combobox")); | 1923 | "GNUNET_GTK_publish_directory_dialog_anonymity_combobox")); |
1669 | gtk_combo_box_set_model(combo, | 1924 | gtk_combo_box_set_model (combo, |
1670 | GNUNET_FS_GTK_get_anonymity_level_list_store()); | 1925 | GNUNET_FS_GTK_get_anonymity_level_list_store ()); |
1671 | } | 1926 | } |
1672 | 1927 | ||
1673 | /* show dialog */ | 1928 | /* show dialog */ |
1674 | { | 1929 | { |
1675 | GtkWidget *ad; | 1930 | GtkWidget *ad; |
1676 | 1931 | ||
1677 | ad = GTK_WIDGET(gtk_builder_get_object( | 1932 | ad = GTK_WIDGET ( |
1678 | ctx->open_directory_builder, "GNUNET_GTK_publish_directory_dialog")); | 1933 | gtk_builder_get_object (ctx->open_directory_builder, |
1679 | gtk_window_set_transient_for(GTK_WINDOW(ad), ctx->master_pubdialog); | 1934 | "GNUNET_GTK_publish_directory_dialog")); |
1680 | gtk_window_present(GTK_WINDOW(ad)); | 1935 | gtk_window_set_transient_for (GTK_WINDOW (ad), ctx->master_pubdialog); |
1936 | gtk_window_present (GTK_WINDOW (ad)); | ||
1681 | } | 1937 | } |
1682 | } | 1938 | } |
1683 | 1939 | ||
@@ -1686,7 +1942,8 @@ void GNUNET_GTK_master_publish_dialog_open_button_clicked_cb( | |||
1686 | /** | 1942 | /** |
1687 | * Context we keep while an "edit" sub-dialog is open. | 1943 | * Context we keep while an "edit" sub-dialog is open. |
1688 | */ | 1944 | */ |
1689 | struct EditPublishContext { | 1945 | struct EditPublishContext |
1946 | { | ||
1690 | /** | 1947 | /** |
1691 | * File information that is being edited | 1948 | * File information that is being edited |
1692 | */ | 1949 | */ |
@@ -1721,23 +1978,38 @@ struct EditPublishContext { | |||
1721 | * this entry from the directory, #GNUNET_SYSERR | 1978 | * this entry from the directory, #GNUNET_SYSERR |
1722 | * to abort the iteration | 1979 | * to abort the iteration |
1723 | */ | 1980 | */ |
1724 | static int update_treeview_after_edit( | 1981 | static int |
1725 | void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length, | 1982 | update_treeview_after_edit (void *cls, |
1726 | struct GNUNET_CONTAINER_MetaData *meta, struct GNUNET_FS_Uri **uri, | 1983 | struct GNUNET_FS_FileInformation *fi, |
1727 | struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info) { | 1984 | uint64_t length, |
1985 | struct GNUNET_CONTAINER_MetaData *meta, | ||
1986 | struct GNUNET_FS_Uri **uri, | ||
1987 | struct GNUNET_FS_BlockOptions *bo, | ||
1988 | int *do_index, | ||
1989 | void **client_info) | ||
1990 | { | ||
1728 | struct EditPublishContext *epc = cls; | 1991 | struct EditPublishContext *epc = cls; |
1729 | char *name; | 1992 | char *name; |
1730 | 1993 | ||
1731 | name = GNUNET_CONTAINER_meta_data_get_by_type( | 1994 | name = GNUNET_CONTAINER_meta_data_get_by_type ( |
1732 | meta, EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); | 1995 | meta, |
1733 | gtk_tree_store_set( | 1996 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); |
1734 | GTK_TREE_STORE(epc->tm), &epc->iter, PUBLISH_MC_DO_INDEX, *do_index, | 1997 | gtk_tree_store_set (GTK_TREE_STORE (epc->tm), |
1735 | PUBLISH_MC_FILENAME, name, PUBLISH_MC_ANONYMITY_LEVEL, | 1998 | &epc->iter, |
1736 | (guint)bo->anonymity_level, PUBLISH_MC_PRIORITY, | 1999 | PUBLISH_MC_DO_INDEX, |
1737 | (guint)bo->content_priority, PUBLISH_MC_EXPIRATION_TIME_ABSOLUTE, | 2000 | *do_index, |
1738 | (guint64)bo->expiration_time.abs_value_us, PUBLISH_MC_REPLICATION_LEVEL, | 2001 | PUBLISH_MC_FILENAME, |
1739 | (guint)bo->replication_level, -1); | 2002 | name, |
1740 | GNUNET_free_non_null(name); | 2003 | PUBLISH_MC_ANONYMITY_LEVEL, |
2004 | (guint) bo->anonymity_level, | ||
2005 | PUBLISH_MC_PRIORITY, | ||
2006 | (guint) bo->content_priority, | ||
2007 | PUBLISH_MC_EXPIRATION_TIME_ABSOLUTE, | ||
2008 | (guint64) bo->expiration_time.abs_value_us, | ||
2009 | PUBLISH_MC_REPLICATION_LEVEL, | ||
2010 | (guint) bo->replication_level, | ||
2011 | -1); | ||
2012 | GNUNET_free_non_null (name); | ||
1741 | return GNUNET_SYSERR; | 2013 | return GNUNET_SYSERR; |
1742 | } | 2014 | } |
1743 | 2015 | ||
@@ -1748,14 +2020,16 @@ static int update_treeview_after_edit( | |||
1748 | * @param ret GTK_RESPONSE_OK if the dialog was closed with "OK" | 2020 | * @param ret GTK_RESPONSE_OK if the dialog was closed with "OK" |
1749 | * @param root unused (namespace root name) | 2021 | * @param root unused (namespace root name) |
1750 | */ | 2022 | */ |
1751 | static void master_publish_edit_publish_dialog_cb(gpointer cls, gint ret, | 2023 | static void |
1752 | const char *root) { | 2024 | master_publish_edit_publish_dialog_cb (gpointer cls, gint ret, const char *root) |
2025 | { | ||
1753 | struct EditPublishContext *epc = cls; | 2026 | struct EditPublishContext *epc = cls; |
1754 | 2027 | ||
1755 | if (ret == GTK_RESPONSE_OK) | 2028 | if (ret == GTK_RESPONSE_OK) |
1756 | GNUNET_FS_file_information_inspect(epc->fip, &update_treeview_after_edit, | 2029 | GNUNET_FS_file_information_inspect (epc->fip, |
1757 | epc); | 2030 | &update_treeview_after_edit, |
1758 | GNUNET_free(epc); | 2031 | epc); |
2032 | GNUNET_free (epc); | ||
1759 | } | 2033 | } |
1760 | 2034 | ||
1761 | /** | 2035 | /** |
@@ -1765,24 +2039,33 @@ static void master_publish_edit_publish_dialog_cb(gpointer cls, gint ret, | |||
1765 | * @param dummy the 'edit' button | 2039 | * @param dummy the 'edit' button |
1766 | * @param user_data master publishing dialog context of our window | 2040 | * @param user_data master publishing dialog context of our window |
1767 | */ | 2041 | */ |
1768 | void GNUNET_GTK_master_publish_dialog_edit_button_clicked_cb( | 2042 | void |
1769 | GtkWidget *dummy, gpointer user_data) { | 2043 | GNUNET_GTK_master_publish_dialog_edit_button_clicked_cb (GtkWidget *dummy, |
2044 | gpointer user_data) | ||
2045 | { | ||
1770 | struct MainPublishingDialogContext *ctx = user_data; | 2046 | struct MainPublishingDialogContext *ctx = user_data; |
1771 | struct EditPublishContext *epc; | 2047 | struct EditPublishContext *epc; |
1772 | 2048 | ||
1773 | epc = GNUNET_new(struct EditPublishContext); | 2049 | epc = GNUNET_new (struct EditPublishContext); |
1774 | epc->tm = ctx->file_info_treemodel; | 2050 | epc->tm = ctx->file_info_treemodel; |
1775 | if (!gtk_tree_selection_get_selected(ctx->file_info_selection, NULL, | 2051 | if (! gtk_tree_selection_get_selected (ctx->file_info_selection, |
1776 | &epc->iter)) { | 2052 | NULL, |
1777 | GNUNET_break(0); | 2053 | &epc->iter)) |
1778 | GNUNET_free(epc); | 2054 | { |
2055 | GNUNET_break (0); | ||
2056 | GNUNET_free (epc); | ||
1779 | return; | 2057 | return; |
1780 | } | 2058 | } |
1781 | gtk_tree_model_get(ctx->file_info_treemodel, &epc->iter, | 2059 | gtk_tree_model_get (ctx->file_info_treemodel, |
1782 | PUBLISH_MC_FILE_INFORMATION_STRUCT, &epc->fip, -1); | 2060 | &epc->iter, |
1783 | GNUNET_FS_GTK_edit_publish_dialog(ctx->master_pubdialog, epc->fip, GNUNET_NO, | 2061 | PUBLISH_MC_FILE_INFORMATION_STRUCT, |
1784 | &master_publish_edit_publish_dialog_cb, | 2062 | &epc->fip, |
1785 | epc); | 2063 | -1); |
2064 | GNUNET_FS_GTK_edit_publish_dialog (ctx->master_pubdialog, | ||
2065 | epc->fip, | ||
2066 | GNUNET_NO, | ||
2067 | &master_publish_edit_publish_dialog_cb, | ||
2068 | epc); | ||
1786 | } | 2069 | } |
1787 | 2070 | ||
1788 | /* ******************** master edit dialog shutdown *********************** */ | 2071 | /* ******************** master edit dialog shutdown *********************** */ |
@@ -1797,21 +2080,27 @@ void GNUNET_GTK_master_publish_dialog_edit_button_clicked_cb( | |||
1797 | * @return file information from the given position (never NULL) | 2080 | * @return file information from the given position (never NULL) |
1798 | */ | 2081 | */ |
1799 | static struct GNUNET_FS_FileInformation * | 2082 | static struct GNUNET_FS_FileInformation * |
1800 | get_file_information(GtkTreeModel *tm, GtkTreeIter *iter) { | 2083 | get_file_information (GtkTreeModel *tm, GtkTreeIter *iter) |
2084 | { | ||
1801 | struct GNUNET_FS_FileInformation *fi; | 2085 | struct GNUNET_FS_FileInformation *fi; |
1802 | struct GNUNET_FS_FileInformation *fic; | 2086 | struct GNUNET_FS_FileInformation *fic; |
1803 | GtkTreeIter child; | 2087 | GtkTreeIter child; |
1804 | 2088 | ||
1805 | gtk_tree_model_get(tm, iter, PUBLISH_MC_FILE_INFORMATION_STRUCT, &fi, -1); | 2089 | gtk_tree_model_get (tm, iter, PUBLISH_MC_FILE_INFORMATION_STRUCT, &fi, -1); |
1806 | gtk_tree_store_set(GTK_TREE_STORE(tm), iter, | 2090 | gtk_tree_store_set (GTK_TREE_STORE (tm), |
1807 | PUBLISH_MC_FILE_INFORMATION_STRUCT, NULL, -1); | 2091 | iter, |
1808 | GNUNET_assert(fi != NULL); | 2092 | PUBLISH_MC_FILE_INFORMATION_STRUCT, |
1809 | if (gtk_tree_model_iter_children(tm, &child, iter)) { | 2093 | NULL, |
1810 | GNUNET_break(GNUNET_YES == GNUNET_FS_file_information_is_directory(fi)); | 2094 | -1); |
1811 | do { | 2095 | GNUNET_assert (fi != NULL); |
1812 | fic = get_file_information(tm, &child); | 2096 | if (gtk_tree_model_iter_children (tm, &child, iter)) |
1813 | GNUNET_break(GNUNET_OK == GNUNET_FS_file_information_add(fi, fic)); | 2097 | { |
1814 | } while (gtk_tree_model_iter_next(tm, &child)); | 2098 | GNUNET_break (GNUNET_YES == GNUNET_FS_file_information_is_directory (fi)); |
2099 | do | ||
2100 | { | ||
2101 | fic = get_file_information (tm, &child); | ||
2102 | GNUNET_break (GNUNET_OK == GNUNET_FS_file_information_add (fi, fic)); | ||
2103 | } while (gtk_tree_model_iter_next (tm, &child)); | ||
1815 | } | 2104 | } |
1816 | return fi; | 2105 | return fi; |
1817 | } | 2106 | } |
@@ -1822,19 +2111,22 @@ get_file_information(GtkTreeModel *tm, GtkTreeIter *iter) { | |||
1822 | * @param tm tree model we are cleaning up | 2111 | * @param tm tree model we are cleaning up |
1823 | * @param iter current position to clean up | 2112 | * @param iter current position to clean up |
1824 | */ | 2113 | */ |
1825 | static void free_file_information_tree_store(GtkTreeModel *tm, | 2114 | static void |
1826 | GtkTreeIter *iter) { | 2115 | free_file_information_tree_store (GtkTreeModel *tm, GtkTreeIter *iter) |
2116 | { | ||
1827 | GtkTreeIter child; | 2117 | GtkTreeIter child; |
1828 | struct GNUNET_FS_FileInformation *fip; | 2118 | struct GNUNET_FS_FileInformation *fip; |
1829 | 2119 | ||
1830 | gtk_tree_model_get(tm, iter, PUBLISH_MC_FILE_INFORMATION_STRUCT, &fip, -1); | 2120 | gtk_tree_model_get (tm, iter, PUBLISH_MC_FILE_INFORMATION_STRUCT, &fip, -1); |
1831 | if (NULL != fip) | 2121 | if (NULL != fip) |
1832 | GNUNET_FS_file_information_destroy(fip, NULL, NULL); | 2122 | GNUNET_FS_file_information_destroy (fip, NULL, NULL); |
1833 | /* recursively clean up children */ | 2123 | /* recursively clean up children */ |
1834 | if (gtk_tree_model_iter_children(tm, &child, iter)) { | 2124 | if (gtk_tree_model_iter_children (tm, &child, iter)) |
1835 | do { | 2125 | { |
1836 | free_file_information_tree_store(tm, &child); | 2126 | do |
1837 | } while (gtk_tree_model_iter_next(tm, &child)); | 2127 | { |
2128 | free_file_information_tree_store (tm, &child); | ||
2129 | } while (gtk_tree_model_iter_next (tm, &child)); | ||
1838 | } | 2130 | } |
1839 | } | 2131 | } |
1840 | 2132 | ||
@@ -1848,7 +2140,8 @@ static void free_file_information_tree_store(GtkTreeModel *tm, | |||
1848 | * open) | 2140 | * open) |
1849 | */ | 2141 | */ |
1850 | static int | 2142 | static int |
1851 | close_master_publish_dialog(struct MainPublishingDialogContext *ctx) { | 2143 | close_master_publish_dialog (struct MainPublishingDialogContext *ctx) |
2144 | { | ||
1852 | GtkTreeIter iter; | 2145 | GtkTreeIter iter; |
1853 | 2146 | ||
1854 | /* Refuse to close until all scanners are finished */ | 2147 | /* Refuse to close until all scanners are finished */ |
@@ -1856,20 +2149,21 @@ close_master_publish_dialog(struct MainPublishingDialogContext *ctx) { | |||
1856 | return GNUNET_NO; | 2149 | return GNUNET_NO; |
1857 | 2150 | ||
1858 | /* free state from the identifiers treemodel */ | 2151 | /* free state from the identifiers treemodel */ |
1859 | gtk_tree_store_clear(GTK_TREE_STORE(ctx->identifiers_treemodel)); | 2152 | gtk_tree_store_clear (GTK_TREE_STORE (ctx->identifiers_treemodel)); |
1860 | 2153 | ||
1861 | /* free state from the file info treemodel */ | 2154 | /* free state from the file info treemodel */ |
1862 | if (gtk_tree_model_get_iter_first(ctx->file_info_treemodel, &iter)) | 2155 | if (gtk_tree_model_get_iter_first (ctx->file_info_treemodel, &iter)) |
1863 | do { | 2156 | do |
1864 | free_file_information_tree_store(ctx->file_info_treemodel, &iter); | 2157 | { |
1865 | } while (gtk_tree_model_iter_next(ctx->file_info_treemodel, &iter)); | 2158 | free_file_information_tree_store (ctx->file_info_treemodel, &iter); |
1866 | gtk_tree_store_clear(GTK_TREE_STORE(ctx->file_info_treemodel)); | 2159 | } while (gtk_tree_model_iter_next (ctx->file_info_treemodel, &iter)); |
1867 | GNUNET_IDENTITY_disconnect(ctx->identity); | 2160 | gtk_tree_store_clear (GTK_TREE_STORE (ctx->file_info_treemodel)); |
1868 | gtk_widget_destroy(GTK_WIDGET(ctx->master_pubdialog)); | 2161 | GNUNET_IDENTITY_disconnect (ctx->identity); |
1869 | g_object_unref(G_OBJECT(ctx->builder)); | 2162 | gtk_widget_destroy (GTK_WIDGET (ctx->master_pubdialog)); |
1870 | GNUNET_free_non_null(ctx->ns_name); | 2163 | g_object_unref (G_OBJECT (ctx->builder)); |
1871 | g_free(ctx->previous_id); | 2164 | GNUNET_free_non_null (ctx->ns_name); |
1872 | GNUNET_free(ctx); | 2165 | g_free (ctx->previous_id); |
2166 | GNUNET_free (ctx); | ||
1873 | return GNUNET_YES; | 2167 | return GNUNET_YES; |
1874 | } | 2168 | } |
1875 | 2169 | ||
@@ -1891,12 +2185,16 @@ close_master_publish_dialog(struct MainPublishingDialogContext *ctx) { | |||
1891 | * this entry from the directory, #GNUNET_SYSERR | 2185 | * this entry from the directory, #GNUNET_SYSERR |
1892 | * to abort the iteration | 2186 | * to abort the iteration |
1893 | */ | 2187 | */ |
1894 | static int insert_advertisement(void *cls, struct GNUNET_FS_FileInformation *fi, | 2188 | static int |
1895 | uint64_t length, | 2189 | insert_advertisement (void *cls, |
1896 | struct GNUNET_CONTAINER_MetaData *meta, | 2190 | struct GNUNET_FS_FileInformation *fi, |
1897 | struct GNUNET_FS_Uri **uri, | 2191 | uint64_t length, |
1898 | struct GNUNET_FS_BlockOptions *bo, | 2192 | struct GNUNET_CONTAINER_MetaData *meta, |
1899 | int *do_index, void **client_info) { | 2193 | struct GNUNET_FS_Uri **uri, |
2194 | struct GNUNET_FS_BlockOptions *bo, | ||
2195 | int *do_index, | ||
2196 | void **client_info) | ||
2197 | { | ||
1900 | struct MainPublishingDialogContext *ctx = cls; | 2198 | struct MainPublishingDialogContext *ctx = cls; |
1901 | struct GNUNET_CRYPTO_EcdsaPublicKey pub; | 2199 | struct GNUNET_CRYPTO_EcdsaPublicKey pub; |
1902 | struct GNUNET_FS_Uri *sks_uri; | 2200 | struct GNUNET_FS_Uri *sks_uri; |
@@ -1904,17 +2202,21 @@ static int insert_advertisement(void *cls, struct GNUNET_FS_FileInformation *fi, | |||
1904 | 2202 | ||
1905 | if (NULL == ctx->ns) | 2203 | if (NULL == ctx->ns) |
1906 | return GNUNET_SYSERR; | 2204 | return GNUNET_SYSERR; |
1907 | GNUNET_IDENTITY_ego_get_public_key(ctx->ns, &pub); | 2205 | GNUNET_IDENTITY_ego_get_public_key (ctx->ns, &pub); |
1908 | sks_uri = GNUNET_FS_uri_sks_create(&pub, "/"); | 2206 | sks_uri = GNUNET_FS_uri_sks_create (&pub, "/"); |
1909 | sks_uri_string = GNUNET_FS_uri_to_string(sks_uri); | 2207 | sks_uri_string = GNUNET_FS_uri_to_string (sks_uri); |
1910 | GNUNET_FS_uri_destroy(sks_uri); | 2208 | GNUNET_FS_uri_destroy (sks_uri); |
1911 | if (NULL == sks_uri_string) | 2209 | if (NULL == sks_uri_string) |
1912 | return GNUNET_SYSERR; | 2210 | return GNUNET_SYSERR; |
1913 | 2211 | ||
1914 | GNUNET_CONTAINER_meta_data_insert(meta, "<gnunet>", EXTRACTOR_METATYPE_URI, | 2212 | GNUNET_CONTAINER_meta_data_insert (meta, |
1915 | EXTRACTOR_METAFORMAT_UTF8, "text/plain", | 2213 | "<gnunet>", |
1916 | sks_uri_string, strlen(sks_uri_string) + 1); | 2214 | EXTRACTOR_METATYPE_URI, |
1917 | GNUNET_free(sks_uri_string); | 2215 | EXTRACTOR_METAFORMAT_UTF8, |
2216 | "text/plain", | ||
2217 | sks_uri_string, | ||
2218 | strlen (sks_uri_string) + 1); | ||
2219 | GNUNET_free (sks_uri_string); | ||
1918 | return GNUNET_SYSERR; | 2220 | return GNUNET_SYSERR; |
1919 | } | 2221 | } |
1920 | 2222 | ||
@@ -1925,8 +2227,10 @@ static int insert_advertisement(void *cls, struct GNUNET_FS_FileInformation *fi, | |||
1925 | * @param button the button that was clicked | 2227 | * @param button the button that was clicked |
1926 | * @param user_data master publishing dialog context of our window | 2228 | * @param user_data master publishing dialog context of our window |
1927 | */ | 2229 | */ |
1928 | void GNUNET_GTK_master_publish_dialog_execute_button_clicked_cb( | 2230 | void |
1929 | GtkButton *button, gpointer user_data) { | 2231 | GNUNET_GTK_master_publish_dialog_execute_button_clicked_cb (GtkButton *button, |
2232 | gpointer user_data) | ||
2233 | { | ||
1930 | struct MainPublishingDialogContext *ctx = user_data; | 2234 | struct MainPublishingDialogContext *ctx = user_data; |
1931 | gchar *namespace_id; | 2235 | gchar *namespace_id; |
1932 | struct GNUNET_IDENTITY_Ego *ns; | 2236 | struct GNUNET_IDENTITY_Ego *ns; |
@@ -1938,75 +2242,92 @@ void GNUNET_GTK_master_publish_dialog_execute_button_clicked_cb( | |||
1938 | gboolean do_own; | 2242 | gboolean do_own; |
1939 | gboolean disable_ads_insertion; | 2243 | gboolean disable_ads_insertion; |
1940 | 2244 | ||
1941 | if (NULL != ctx->adddir_head) { | 2245 | if (NULL != ctx->adddir_head) |
1942 | GNUNET_break(0); | 2246 | { |
2247 | GNUNET_break (0); | ||
1943 | return; | 2248 | return; |
1944 | } | 2249 | } |
1945 | 2250 | ||
1946 | do_global = | 2251 | do_global = |
1947 | gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ctx->global_checkbox)); | 2252 | gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ctx->global_checkbox)); |
1948 | do_updateable = | 2253 | do_updateable = |
1949 | gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ctx->updateable_checkbox)); | 2254 | gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ctx->updateable_checkbox)); |
1950 | do_own = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ctx->own_checkbox)); | 2255 | do_own = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ctx->own_checkbox)); |
1951 | 2256 | ||
1952 | disable_ads_insertion = GNUNET_CONFIGURATION_get_value_yesno( | 2257 | disable_ads_insertion = GNUNET_CONFIGURATION_get_value_yesno ( |
1953 | GNUNET_FS_GTK_get_configuration(), "gnunet-fs-gtk", | 2258 | GNUNET_FS_GTK_get_configuration (), |
1954 | "DISABLE_AUTOMATIC_NAMESPACE_ADVERTISEMENT_INSERTION"); | 2259 | "gnunet-fs-gtk", |
2260 | "DISABLE_AUTOMATIC_NAMESPACE_ADVERTISEMENT_INSERTION"); | ||
1955 | if (disable_ads_insertion == GNUNET_SYSERR) | 2261 | if (disable_ads_insertion == GNUNET_SYSERR) |
1956 | disable_ads_insertion = GNUNET_NO; | 2262 | disable_ads_insertion = GNUNET_NO; |
1957 | 2263 | ||
1958 | ns = NULL; | 2264 | ns = NULL; |
1959 | namespace_id = NULL; | 2265 | namespace_id = NULL; |
1960 | namespace_uid = NULL; | 2266 | namespace_uid = NULL; |
1961 | if (ctx->ns && do_own) { | 2267 | if (ctx->ns && do_own) |
2268 | { | ||
1962 | const gchar *id_entry_text; | 2269 | const gchar *id_entry_text; |
1963 | if (NULL != | 2270 | if (NULL != (id_entry_text = |
1964 | (id_entry_text = gtk_entry_get_text(GTK_ENTRY(ctx->identifier_entry)))) | 2271 | gtk_entry_get_text (GTK_ENTRY (ctx->identifier_entry)))) |
1965 | namespace_id = g_strdup(id_entry_text); | 2272 | namespace_id = g_strdup (id_entry_text); |
1966 | else if (!do_global) | 2273 | else if (! do_global) |
1967 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Global publication is disabled, but " | 2274 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1968 | "namespace_id is not available\n"); | 2275 | "Global publication is disabled, but " |
1969 | if ((NULL != namespace_id) && ('\0' == namespace_id[0])) { | 2276 | "namespace_id is not available\n"); |
1970 | g_free(namespace_id); | 2277 | if ((NULL != namespace_id) && ('\0' == namespace_id[0])) |
2278 | { | ||
2279 | g_free (namespace_id); | ||
1971 | namespace_id = NULL; | 2280 | namespace_id = NULL; |
1972 | } | 2281 | } |
1973 | if (NULL != namespace_id) { | 2282 | if (NULL != namespace_id) |
1974 | namespace_uid = gtk_entry_get_text(GTK_ENTRY(ctx->update_id_entry)); | 2283 | { |
2284 | namespace_uid = gtk_entry_get_text (GTK_ENTRY (ctx->update_id_entry)); | ||
1975 | if ((NULL == namespace_uid) || ('\0' == namespace_uid[0]) || | 2285 | if ((NULL == namespace_uid) || ('\0' == namespace_uid[0]) || |
1976 | (!do_updateable)) | 2286 | (! do_updateable)) |
1977 | namespace_uid = NULL; | 2287 | namespace_uid = NULL; |
1978 | ns = ctx->ns; | 2288 | ns = ctx->ns; |
1979 | } else if (!do_global) | 2289 | } |
1980 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 2290 | else if (! do_global) |
1981 | "Global publication is disabled, but namespace_id unavailable " | 2291 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1982 | "or zero-length\n"); | 2292 | "Global publication is disabled, but namespace_id unavailable " |
1983 | } else if (!do_global) | 2293 | "or zero-length\n"); |
1984 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 2294 | } |
1985 | "Global publication is disabled, ns is either NULL or disabled, " | 2295 | else if (! do_global) |
1986 | "yet 'Execute' was pressed\n"); | 2296 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1987 | if ((!do_global) && (NULL == ns)) { | 2297 | "Global publication is disabled, ns is either NULL or disabled, " |
1988 | g_free(namespace_id); | 2298 | "yet 'Execute' was pressed\n"); |
1989 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ctx->own_checkbox), FALSE); | 2299 | if ((! do_global) && (NULL == ns)) |
2300 | { | ||
2301 | g_free (namespace_id); | ||
2302 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ctx->own_checkbox), FALSE); | ||
1990 | return; | 2303 | return; |
1991 | } | 2304 | } |
1992 | if (gtk_tree_model_get_iter_first(ctx->file_info_treemodel, &iter)) { | 2305 | if (gtk_tree_model_get_iter_first (ctx->file_info_treemodel, &iter)) |
1993 | if (!do_global) | 2306 | { |
1994 | clear_keywords_from_tm(ctx); | 2307 | if (! do_global) |
1995 | do { | 2308 | clear_keywords_from_tm (ctx); |
1996 | fi = get_file_information(ctx->file_info_treemodel, &iter); | 2309 | do |
1997 | if (do_global && do_own && !disable_ads_insertion) | 2310 | { |
1998 | GNUNET_FS_file_information_inspect(fi, insert_advertisement, ctx); | 2311 | fi = get_file_information (ctx->file_info_treemodel, &iter); |
1999 | GNUNET_FS_publish_start( | 2312 | if (do_global && do_own && ! disable_ads_insertion) |
2000 | GNUNET_FS_GTK_get_fs_handle(), fi, | 2313 | GNUNET_FS_file_information_inspect (fi, insert_advertisement, ctx); |
2001 | (NULL == ns) ? NULL : GNUNET_IDENTITY_ego_get_private_key(ns), | 2314 | GNUNET_FS_publish_start (GNUNET_FS_GTK_get_fs_handle (), |
2002 | namespace_id, namespace_uid, GNUNET_FS_PUBLISH_OPTION_NONE); | 2315 | fi, |
2003 | } while (gtk_tree_model_iter_next(ctx->file_info_treemodel, &iter)); | 2316 | (NULL == ns) |
2004 | } else { | 2317 | ? NULL |
2005 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 2318 | : GNUNET_IDENTITY_ego_get_private_key (ns), |
2006 | "Failed to get first item in files tree view. Is it empty?\n"); | 2319 | namespace_id, |
2007 | } | 2320 | namespace_uid, |
2008 | g_free(namespace_id); | 2321 | GNUNET_FS_PUBLISH_OPTION_NONE); |
2009 | GNUNET_break(GNUNET_YES == close_master_publish_dialog(ctx)); | 2322 | } while (gtk_tree_model_iter_next (ctx->file_info_treemodel, &iter)); |
2323 | } | ||
2324 | else | ||
2325 | { | ||
2326 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
2327 | "Failed to get first item in files tree view. Is it empty?\n"); | ||
2328 | } | ||
2329 | g_free (namespace_id); | ||
2330 | GNUNET_break (GNUNET_YES == close_master_publish_dialog (ctx)); | ||
2010 | } | 2331 | } |
2011 | 2332 | ||
2012 | /** | 2333 | /** |
@@ -2025,13 +2346,19 @@ void GNUNET_GTK_master_publish_dialog_execute_button_clicked_cb( | |||
2025 | * modified) | 2346 | * modified) |
2026 | * @return #GNUNET_OK (to continue) | 2347 | * @return #GNUNET_OK (to continue) |
2027 | */ | 2348 | */ |
2028 | static int clear_keywords_in_file_information( | 2349 | static int |
2029 | void *cls, struct GNUNET_FS_FileInformation *fi, uint64_t length, | 2350 | clear_keywords_in_file_information (void *cls, |
2030 | struct GNUNET_CONTAINER_MetaData *meta, struct GNUNET_FS_Uri **uri, | 2351 | struct GNUNET_FS_FileInformation *fi, |
2031 | struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info) { | 2352 | uint64_t length, |
2353 | struct GNUNET_CONTAINER_MetaData *meta, | ||
2354 | struct GNUNET_FS_Uri **uri, | ||
2355 | struct GNUNET_FS_BlockOptions *bo, | ||
2356 | int *do_index, | ||
2357 | void **client_info) | ||
2358 | { | ||
2032 | if (NULL == *uri) | 2359 | if (NULL == *uri) |
2033 | return GNUNET_OK; | 2360 | return GNUNET_OK; |
2034 | GNUNET_FS_uri_destroy(*uri); | 2361 | GNUNET_FS_uri_destroy (*uri); |
2035 | *uri = NULL; | 2362 | *uri = NULL; |
2036 | return GNUNET_OK; | 2363 | return GNUNET_OK; |
2037 | } | 2364 | } |
@@ -2043,21 +2370,26 @@ static int clear_keywords_in_file_information( | |||
2043 | * @param iter current position in the recursion | 2370 | * @param iter current position in the recursion |
2044 | */ | 2371 | */ |
2045 | static void | 2372 | static void |
2046 | clear_keywords_from_file_information_in_tree_store(GtkTreeModel *tm, | 2373 | clear_keywords_from_file_information_in_tree_store (GtkTreeModel *tm, |
2047 | GtkTreeIter *iter) { | 2374 | GtkTreeIter *iter) |
2375 | { | ||
2048 | GtkTreeIter child; | 2376 | GtkTreeIter child; |
2049 | struct GNUNET_FS_FileInformation *fip; | 2377 | struct GNUNET_FS_FileInformation *fip; |
2050 | 2378 | ||
2051 | gtk_tree_model_get(tm, iter, PUBLISH_MC_FILE_INFORMATION_STRUCT, &fip, -1); | 2379 | gtk_tree_model_get (tm, iter, PUBLISH_MC_FILE_INFORMATION_STRUCT, &fip, -1); |
2052 | if (NULL != fip) { | 2380 | if (NULL != fip) |
2053 | GNUNET_FS_file_information_inspect(fip, &clear_keywords_in_file_information, | 2381 | { |
2054 | NULL); | 2382 | GNUNET_FS_file_information_inspect (fip, |
2383 | &clear_keywords_in_file_information, | ||
2384 | NULL); | ||
2055 | } | 2385 | } |
2056 | /* recursively clean up children */ | 2386 | /* recursively clean up children */ |
2057 | if (gtk_tree_model_iter_children(tm, &child, iter)) { | 2387 | if (gtk_tree_model_iter_children (tm, &child, iter)) |
2058 | do { | 2388 | { |
2059 | clear_keywords_from_file_information_in_tree_store(tm, &child); | 2389 | do |
2060 | } while (gtk_tree_model_iter_next(tm, &child)); | 2390 | { |
2391 | clear_keywords_from_file_information_in_tree_store (tm, &child); | ||
2392 | } while (gtk_tree_model_iter_next (tm, &child)); | ||
2061 | } | 2393 | } |
2062 | } | 2394 | } |
2063 | 2395 | ||
@@ -2067,15 +2399,19 @@ clear_keywords_from_file_information_in_tree_store(GtkTreeModel *tm, | |||
2067 | * | 2399 | * |
2068 | * @param ctx context | 2400 | * @param ctx context |
2069 | */ | 2401 | */ |
2070 | static void clear_keywords_from_tm(struct MainPublishingDialogContext *ctx) { | 2402 | static void |
2403 | clear_keywords_from_tm (struct MainPublishingDialogContext *ctx) | ||
2404 | { | ||
2071 | GtkTreeIter iter; | 2405 | GtkTreeIter iter; |
2072 | 2406 | ||
2073 | /* clear keywords from 'tm' */ | 2407 | /* clear keywords from 'tm' */ |
2074 | if (gtk_tree_model_get_iter_first(ctx->file_info_treemodel, &iter)) | 2408 | if (gtk_tree_model_get_iter_first (ctx->file_info_treemodel, &iter)) |
2075 | do { | 2409 | do |
2076 | clear_keywords_from_file_information_in_tree_store( | 2410 | { |
2077 | ctx->file_info_treemodel, &iter); | 2411 | clear_keywords_from_file_information_in_tree_store (ctx |
2078 | } while (gtk_tree_model_iter_next(ctx->file_info_treemodel, &iter)); | 2412 | ->file_info_treemodel, |
2413 | &iter); | ||
2414 | } while (gtk_tree_model_iter_next (ctx->file_info_treemodel, &iter)); | ||
2079 | } | 2415 | } |
2080 | 2416 | ||
2081 | /** | 2417 | /** |
@@ -2084,9 +2420,11 @@ static void clear_keywords_from_tm(struct MainPublishingDialogContext *ctx) { | |||
2084 | * @param button the button that was clicked | 2420 | * @param button the button that was clicked |
2085 | * @param user_data master publishing dialog context of our window | 2421 | * @param user_data master publishing dialog context of our window |
2086 | */ | 2422 | */ |
2087 | void GNUNET_GTK_master_publish_dialog_clear_button_clicked_cb( | 2423 | void |
2088 | GtkButton *button, gpointer user_data) { | 2424 | GNUNET_GTK_master_publish_dialog_clear_button_clicked_cb (GtkButton *button, |
2089 | clear_keywords_from_tm(user_data); | 2425 | gpointer user_data) |
2426 | { | ||
2427 | clear_keywords_from_tm (user_data); | ||
2090 | } | 2428 | } |
2091 | 2429 | ||
2092 | /** | 2430 | /** |
@@ -2095,11 +2433,13 @@ void GNUNET_GTK_master_publish_dialog_clear_button_clicked_cb( | |||
2095 | * @param button the button that was clicked | 2433 | * @param button the button that was clicked |
2096 | * @param user_data master publishing dialog context of our window | 2434 | * @param user_data master publishing dialog context of our window |
2097 | */ | 2435 | */ |
2098 | void GNUNET_GTK_master_publish_dialog_cancel_button_clicked_cb( | 2436 | void |
2099 | GtkButton *button, gpointer user_data) { | 2437 | GNUNET_GTK_master_publish_dialog_cancel_button_clicked_cb (GtkButton *button, |
2438 | gpointer user_data) | ||
2439 | { | ||
2100 | struct MainPublishingDialogContext *ctx = user_data; | 2440 | struct MainPublishingDialogContext *ctx = user_data; |
2101 | 2441 | ||
2102 | GNUNET_break(GNUNET_YES == close_master_publish_dialog(ctx)); | 2442 | GNUNET_break (GNUNET_YES == close_master_publish_dialog (ctx)); |
2103 | } | 2443 | } |
2104 | 2444 | ||
2105 | /** | 2445 | /** |
@@ -2112,12 +2452,14 @@ void GNUNET_GTK_master_publish_dialog_cancel_button_clicked_cb( | |||
2112 | * @return TRUE to refuse to close (stops other handlers from being invoked) | 2452 | * @return TRUE to refuse to close (stops other handlers from being invoked) |
2113 | * FALSE to allow closing the window | 2453 | * FALSE to allow closing the window |
2114 | */ | 2454 | */ |
2115 | gboolean GNUNET_GTK_master_publish_dialog_delete_event_cb(GtkWidget *widget, | 2455 | gboolean |
2116 | GdkEvent *event, | 2456 | GNUNET_GTK_master_publish_dialog_delete_event_cb (GtkWidget *widget, |
2117 | gpointer user_data) { | 2457 | GdkEvent *event, |
2458 | gpointer user_data) | ||
2459 | { | ||
2118 | struct MainPublishingDialogContext *ctx = user_data; | 2460 | struct MainPublishingDialogContext *ctx = user_data; |
2119 | 2461 | ||
2120 | if (GNUNET_NO == close_master_publish_dialog(ctx)) | 2462 | if (GNUNET_NO == close_master_publish_dialog (ctx)) |
2121 | return TRUE; | 2463 | return TRUE; |
2122 | return FALSE; | 2464 | return FALSE; |
2123 | } | 2465 | } |
@@ -2132,28 +2474,31 @@ gboolean GNUNET_GTK_master_publish_dialog_delete_event_cb(GtkWidget *widget, | |||
2132 | * @param param_spec parameter that was changed | 2474 | * @param param_spec parameter that was changed |
2133 | * @param user_data context | 2475 | * @param user_data context |
2134 | */ | 2476 | */ |
2135 | static void expander_callback(GObject *object, GParamSpec *param_spec, | 2477 | static void |
2136 | gpointer user_data) { | 2478 | expander_callback (GObject *object, GParamSpec *param_spec, gpointer user_data) |
2479 | { | ||
2137 | GtkExpander *expander; | 2480 | GtkExpander *expander; |
2138 | struct MainPublishingDialogContext *ctx = user_data; | 2481 | struct MainPublishingDialogContext *ctx = user_data; |
2139 | GtkAllocation scrolled_allocation; | 2482 | GtkAllocation scrolled_allocation; |
2140 | gint paned_pos; | 2483 | gint paned_pos; |
2141 | GValue gv = G_VALUE_INIT; | 2484 | GValue gv = G_VALUE_INIT; |
2142 | gboolean expanded; | 2485 | gboolean expanded; |
2143 | expander = GTK_EXPANDER(object); | 2486 | expander = GTK_EXPANDER (object); |
2144 | 2487 | ||
2145 | gtk_widget_get_allocation(GTK_WIDGET(ctx->identifiers_scrolled), | 2488 | gtk_widget_get_allocation (GTK_WIDGET (ctx->identifiers_scrolled), |
2146 | &scrolled_allocation); | 2489 | &scrolled_allocation); |
2147 | expanded = gtk_expander_get_expanded(expander); | 2490 | expanded = gtk_expander_get_expanded (expander); |
2148 | gtk_widget_set_visible(GTK_WIDGET(ctx->identifiers_scrolled), expanded); | 2491 | gtk_widget_set_visible (GTK_WIDGET (ctx->identifiers_scrolled), expanded); |
2149 | 2492 | ||
2150 | g_value_init(&gv, G_TYPE_BOOLEAN); | 2493 | g_value_init (&gv, G_TYPE_BOOLEAN); |
2151 | g_value_set_boolean(&gv, expanded); | 2494 | g_value_set_boolean (&gv, expanded); |
2152 | gtk_container_child_set_property(GTK_CONTAINER(ctx->vpaned), | 2495 | gtk_container_child_set_property (GTK_CONTAINER (ctx->vpaned), |
2153 | ctx->bottom_frame, "resize", &gv); | 2496 | ctx->bottom_frame, |
2154 | paned_pos = gtk_paned_get_position(GTK_PANED(ctx->vpaned)); | 2497 | "resize", |
2498 | &gv); | ||
2499 | paned_pos = gtk_paned_get_position (GTK_PANED (ctx->vpaned)); | ||
2155 | paned_pos = paned_pos + (scrolled_allocation.height * (expanded ? -1 : 1)); | 2500 | paned_pos = paned_pos + (scrolled_allocation.height * (expanded ? -1 : 1)); |
2156 | gtk_paned_set_position(GTK_PANED(ctx->vpaned), paned_pos); | 2501 | gtk_paned_set_position (GTK_PANED (ctx->vpaned), paned_pos); |
2157 | } | 2502 | } |
2158 | 2503 | ||
2159 | /* ******************** master edit dialog initialization ******************* */ | 2504 | /* ******************** master edit dialog initialization ******************* */ |
@@ -2161,7 +2506,8 @@ static void expander_callback(GObject *object, GParamSpec *param_spec, | |||
2161 | /** | 2506 | /** |
2162 | * Closure for 'add_updateable_to_ts'. | 2507 | * Closure for 'add_updateable_to_ts'. |
2163 | */ | 2508 | */ |
2164 | struct UpdateableContext { | 2509 | struct UpdateableContext |
2510 | { | ||
2165 | /** | 2511 | /** |
2166 | * Parent of current insertion. | 2512 | * Parent of current insertion. |
2167 | */ | 2513 | */ |
@@ -2197,9 +2543,13 @@ struct UpdateableContext { | |||
2197 | * @param last_meta associate meta data | 2543 | * @param last_meta associate meta data |
2198 | * @param next_id ID for future updates | 2544 | * @param next_id ID for future updates |
2199 | */ | 2545 | */ |
2200 | static void add_updateable_to_ts( | 2546 | static void |
2201 | void *cls, const char *last_id, const struct GNUNET_FS_Uri *last_uri, | 2547 | add_updateable_to_ts (void *cls, |
2202 | const struct GNUNET_CONTAINER_MetaData *last_meta, const char *next_id) { | 2548 | const char *last_id, |
2549 | const struct GNUNET_FS_Uri *last_uri, | ||
2550 | const struct GNUNET_CONTAINER_MetaData *last_meta, | ||
2551 | const char *next_id) | ||
2552 | { | ||
2203 | struct UpdateableContext *uc = cls; | 2553 | struct UpdateableContext *uc = cls; |
2204 | struct UpdateableContext sc; | 2554 | struct UpdateableContext sc; |
2205 | GtkTreeIter iter; | 2555 | GtkTreeIter iter; |
@@ -2221,86 +2571,129 @@ static void add_updateable_to_ts( | |||
2221 | uc->update_called = GNUNET_YES; | 2571 | uc->update_called = GNUNET_YES; |
2222 | 2572 | ||
2223 | if (next_id) | 2573 | if (next_id) |
2224 | next_id_len = strlen(next_id); | 2574 | next_id_len = strlen (next_id); |
2225 | else | 2575 | else |
2226 | next_id_len = 0; | 2576 | next_id_len = 0; |
2227 | 2577 | ||
2228 | if (last_id) | 2578 | if (last_id) |
2229 | last_id_len = strlen(last_id); | 2579 | last_id_len = strlen (last_id); |
2230 | else | 2580 | else |
2231 | last_id_len = 0; | 2581 | last_id_len = 0; |
2232 | 2582 | ||
2233 | uristring = GNUNET_FS_uri_to_string(last_uri); | 2583 | uristring = GNUNET_FS_uri_to_string (last_uri); |
2234 | if (uristring) | 2584 | if (uristring) |
2235 | urilen = strlen(uristring); | 2585 | urilen = strlen (uristring); |
2236 | else | 2586 | else |
2237 | urilen = 0; | 2587 | urilen = 0; |
2238 | 2588 | ||
2239 | mdbuf = NULL; | 2589 | mdbuf = NULL; |
2240 | mdsize = GNUNET_CONTAINER_meta_data_serialize( | 2590 | mdsize = GNUNET_CONTAINER_meta_data_serialize ( |
2241 | last_meta, &mdbuf, 64 * 1024, GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL); | 2591 | last_meta, |
2592 | &mdbuf, | ||
2593 | 64 * 1024, | ||
2594 | GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL); | ||
2242 | if (0 > mdsize) | 2595 | if (0 > mdsize) |
2243 | mdsize = 0; | 2596 | mdsize = 0; |
2244 | 2597 | ||
2245 | hashbufsize = last_id_len + next_id_len + urilen + mdsize; | 2598 | hashbufsize = last_id_len + next_id_len + urilen + mdsize; |
2246 | hashbuf = GNUNET_malloc(hashbufsize); | 2599 | hashbuf = GNUNET_malloc (hashbufsize); |
2247 | if (last_id) | 2600 | if (last_id) |
2248 | strcpy(&hashbuf[0], last_id); | 2601 | strcpy (&hashbuf[0], last_id); |
2249 | if (next_id) | 2602 | if (next_id) |
2250 | strcpy(&hashbuf[last_id_len], next_id); | 2603 | strcpy (&hashbuf[last_id_len], next_id); |
2251 | if (uristring) | 2604 | if (uristring) |
2252 | strcpy(&hashbuf[last_id_len + next_id_len], uristring); | 2605 | strcpy (&hashbuf[last_id_len + next_id_len], uristring); |
2253 | if (mdbuf) | 2606 | if (mdbuf) |
2254 | memcpy(&hashbuf[last_id_len + next_id_len + urilen], mdbuf, mdsize); | 2607 | memcpy (&hashbuf[last_id_len + next_id_len + urilen], mdbuf, mdsize); |
2255 | 2608 | ||
2256 | GNUNET_CRYPTO_hash(hashbuf, hashbufsize, &hc); | 2609 | GNUNET_CRYPTO_hash (hashbuf, hashbufsize, &hc); |
2257 | 2610 | ||
2258 | GNUNET_free(uristring); | 2611 | GNUNET_free (uristring); |
2259 | GNUNET_free_non_null(mdbuf); | 2612 | GNUNET_free_non_null (mdbuf); |
2260 | GNUNET_free(hashbuf); | 2613 | GNUNET_free (hashbuf); |
2261 | 2614 | ||
2262 | spath = NULL; | 2615 | spath = NULL; |
2263 | spath = GNUNET_CONTAINER_multihashmap_get(uc->seen, &hc); | 2616 | spath = GNUNET_CONTAINER_multihashmap_get (uc->seen, &hc); |
2264 | 2617 | ||
2265 | desc = GNUNET_FS_GTK_get_description_from_metadata(last_meta, &desc_is_a_dup); | 2618 | desc = |
2266 | if (NULL != spath) { | 2619 | GNUNET_FS_GTK_get_description_from_metadata (last_meta, &desc_is_a_dup); |
2267 | displaytext = g_strdup_printf("<i>%s</i>", last_id); | 2620 | if (NULL != spath) |
2268 | gtk_tree_store_insert_with_values( | 2621 | { |
2269 | uc->ts, &iter, uc->parent, G_MAXINT, IDENTIFIERS_MC_ID, last_id, | 2622 | displaytext = g_strdup_printf ("<i>%s</i>", last_id); |
2270 | IDENTIFIERS_MC_UPDATE_ID, next_id, IDENTIFIERS_MC_DESCRIPTION, desc, | 2623 | gtk_tree_store_insert_with_values (uc->ts, |
2271 | IDENTIFIERS_MC_PATH_TO_ORIGINAL, spath, IDENTIFIERS_MC_ID_MARKED_UP, | 2624 | &iter, |
2272 | displaytext, -1); | 2625 | uc->parent, |
2273 | } else if (NULL == uc->parent) { | 2626 | G_MAXINT, |
2274 | displaytext = g_strdup_printf("%s", last_id); | 2627 | IDENTIFIERS_MC_ID, |
2275 | gtk_tree_store_insert_with_values( | 2628 | last_id, |
2276 | uc->ts, &iter, uc->parent, G_MAXINT, IDENTIFIERS_MC_ID, last_id, | 2629 | IDENTIFIERS_MC_UPDATE_ID, |
2277 | IDENTIFIERS_MC_UPDATE_ID, next_id, IDENTIFIERS_MC_DESCRIPTION, desc, | 2630 | next_id, |
2278 | IDENTIFIERS_MC_PATH_TO_ORIGINAL, NULL, IDENTIFIERS_MC_ID_MARKED_UP, | 2631 | IDENTIFIERS_MC_DESCRIPTION, |
2279 | displaytext, -1); | 2632 | desc, |
2280 | } else { | 2633 | IDENTIFIERS_MC_PATH_TO_ORIGINAL, |
2281 | displaytext = g_strdup_printf("%s", last_id); | 2634 | spath, |
2282 | gtk_tree_store_insert_with_values( | 2635 | IDENTIFIERS_MC_ID_MARKED_UP, |
2283 | uc->ts, &iter, uc->parent, G_MAXINT, IDENTIFIERS_MC_ID, last_id, | 2636 | displaytext, |
2284 | IDENTIFIERS_MC_UPDATE_ID, next_id, IDENTIFIERS_MC_DESCRIPTION, desc, | 2637 | -1); |
2285 | IDENTIFIERS_MC_PATH_TO_ORIGINAL, NULL, IDENTIFIERS_MC_ID_MARKED_UP, | 2638 | } |
2286 | displaytext, -1); | 2639 | else if (NULL == uc->parent) |
2287 | } | 2640 | { |
2288 | g_free(displaytext); | 2641 | displaytext = g_strdup_printf ("%s", last_id); |
2289 | 2642 | gtk_tree_store_insert_with_values (uc->ts, | |
2290 | if (NULL == spath) { | 2643 | &iter, |
2644 | uc->parent, | ||
2645 | G_MAXINT, | ||
2646 | IDENTIFIERS_MC_ID, | ||
2647 | last_id, | ||
2648 | IDENTIFIERS_MC_UPDATE_ID, | ||
2649 | next_id, | ||
2650 | IDENTIFIERS_MC_DESCRIPTION, | ||
2651 | desc, | ||
2652 | IDENTIFIERS_MC_PATH_TO_ORIGINAL, | ||
2653 | NULL, | ||
2654 | IDENTIFIERS_MC_ID_MARKED_UP, | ||
2655 | displaytext, | ||
2656 | -1); | ||
2657 | } | ||
2658 | else | ||
2659 | { | ||
2660 | displaytext = g_strdup_printf ("%s", last_id); | ||
2661 | gtk_tree_store_insert_with_values (uc->ts, | ||
2662 | &iter, | ||
2663 | uc->parent, | ||
2664 | G_MAXINT, | ||
2665 | IDENTIFIERS_MC_ID, | ||
2666 | last_id, | ||
2667 | IDENTIFIERS_MC_UPDATE_ID, | ||
2668 | next_id, | ||
2669 | IDENTIFIERS_MC_DESCRIPTION, | ||
2670 | desc, | ||
2671 | IDENTIFIERS_MC_PATH_TO_ORIGINAL, | ||
2672 | NULL, | ||
2673 | IDENTIFIERS_MC_ID_MARKED_UP, | ||
2674 | displaytext, | ||
2675 | -1); | ||
2676 | } | ||
2677 | g_free (displaytext); | ||
2678 | |||
2679 | if (NULL == spath) | ||
2680 | { | ||
2291 | GtkTreePath *path; | 2681 | GtkTreePath *path; |
2292 | char *gspath; | 2682 | char *gspath; |
2293 | path = gtk_tree_model_get_path(GTK_TREE_MODEL(uc->ts), &iter); | 2683 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (uc->ts), &iter); |
2294 | spath = gtk_tree_path_to_string(path); | 2684 | spath = gtk_tree_path_to_string (path); |
2295 | gtk_tree_path_free(path); | 2685 | gtk_tree_path_free (path); |
2296 | /* for the sake of consistency, only put GNUNET_free'able things into the | 2686 | /* for the sake of consistency, only put GNUNET_free'able things into the |
2297 | * map */ | 2687 | * map */ |
2298 | gspath = GNUNET_strdup(spath); | 2688 | gspath = GNUNET_strdup (spath); |
2299 | if (GNUNET_SYSERR == GNUNET_CONTAINER_multihashmap_put( | 2689 | if (GNUNET_SYSERR == GNUNET_CONTAINER_multihashmap_put ( |
2300 | uc->seen, &hc, gspath, | 2690 | uc->seen, |
2301 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) | 2691 | &hc, |
2302 | GNUNET_free(gspath); | 2692 | gspath, |
2303 | } else | 2693 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) |
2694 | GNUNET_free (gspath); | ||
2695 | } | ||
2696 | else | ||
2304 | return; | 2697 | return; |
2305 | 2698 | ||
2306 | sc.parent = &iter; | 2699 | sc.parent = &iter; |
@@ -2308,20 +2701,33 @@ static void add_updateable_to_ts( | |||
2308 | sc.ns = uc->ns; | 2701 | sc.ns = uc->ns; |
2309 | sc.seen = uc->seen; | 2702 | sc.seen = uc->seen; |
2310 | sc.update_called = GNUNET_NO; | 2703 | sc.update_called = GNUNET_NO; |
2311 | GNUNET_FS_namespace_list_updateable( | 2704 | GNUNET_FS_namespace_list_updateable (GNUNET_FS_GTK_get_fs_handle (), |
2312 | GNUNET_FS_GTK_get_fs_handle(), | 2705 | GNUNET_IDENTITY_ego_get_private_key ( |
2313 | GNUNET_IDENTITY_ego_get_private_key(uc->ns), next_id, | 2706 | uc->ns), |
2314 | &add_updateable_to_ts, &sc); | 2707 | next_id, |
2708 | &add_updateable_to_ts, | ||
2709 | &sc); | ||
2315 | if ((sc.update_called == GNUNET_NO) && (NULL != next_id) && | 2710 | if ((sc.update_called == GNUNET_NO) && (NULL != next_id) && |
2316 | (strlen(next_id) > 0)) { | 2711 | (strlen (next_id) > 0)) |
2712 | { | ||
2317 | /* add leaf */ | 2713 | /* add leaf */ |
2318 | displaytext = g_strdup_printf("<b>%s</b>", next_id); | 2714 | displaytext = g_strdup_printf ("<b>%s</b>", next_id); |
2319 | gtk_tree_store_insert_with_values( | 2715 | gtk_tree_store_insert_with_values (uc->ts, |
2320 | uc->ts, &titer, &iter, G_MAXINT, IDENTIFIERS_MC_ID, next_id, | 2716 | &titer, |
2321 | IDENTIFIERS_MC_UPDATE_ID, NULL, IDENTIFIERS_MC_DESCRIPTION, NULL, | 2717 | &iter, |
2322 | IDENTIFIERS_MC_PATH_TO_ORIGINAL, NULL, IDENTIFIERS_MC_ID_MARKED_UP, | 2718 | G_MAXINT, |
2323 | displaytext, -1); | 2719 | IDENTIFIERS_MC_ID, |
2324 | g_free(displaytext); | 2720 | next_id, |
2721 | IDENTIFIERS_MC_UPDATE_ID, | ||
2722 | NULL, | ||
2723 | IDENTIFIERS_MC_DESCRIPTION, | ||
2724 | NULL, | ||
2725 | IDENTIFIERS_MC_PATH_TO_ORIGINAL, | ||
2726 | NULL, | ||
2727 | IDENTIFIERS_MC_ID_MARKED_UP, | ||
2728 | displaytext, | ||
2729 | -1); | ||
2730 | g_free (displaytext); | ||
2325 | } | 2731 | } |
2326 | } | 2732 | } |
2327 | 2733 | ||
@@ -2334,9 +2740,10 @@ static void add_updateable_to_ts( | |||
2334 | * @param value value from the map | 2740 | * @param value value from the map |
2335 | * @return #GNUNET_YES, always. | 2741 | * @return #GNUNET_YES, always. |
2336 | */ | 2742 | */ |
2337 | static int free_seen_paths(void *cls, const struct GNUNET_HashCode *key, | 2743 | static int |
2338 | void *value) { | 2744 | free_seen_paths (void *cls, const struct GNUNET_HashCode *key, void *value) |
2339 | GNUNET_free_non_null(value); | 2745 | { |
2746 | GNUNET_free_non_null (value); | ||
2340 | return GNUNET_YES; | 2747 | return GNUNET_YES; |
2341 | } | 2748 | } |
2342 | 2749 | ||
@@ -2347,8 +2754,10 @@ static int free_seen_paths(void *cls, const struct GNUNET_HashCode *key, | |||
2347 | * @param combo the namespace selection combo box | 2754 | * @param combo the namespace selection combo box |
2348 | * @param user_data the `struct MainPublishingDialogContext` | 2755 | * @param user_data the `struct MainPublishingDialogContext` |
2349 | */ | 2756 | */ |
2350 | void GNUNET_GTK_master_publish_dialog_ego_combobox_changed_cb( | 2757 | void |
2351 | GtkComboBox *combo, gpointer user_data) { | 2758 | GNUNET_GTK_master_publish_dialog_ego_combobox_changed_cb (GtkComboBox *combo, |
2759 | gpointer user_data) | ||
2760 | { | ||
2352 | struct MainPublishingDialogContext *ctx = user_data; | 2761 | struct MainPublishingDialogContext *ctx = user_data; |
2353 | GtkTreeIter iter; | 2762 | GtkTreeIter iter; |
2354 | GtkTreeStore *ts; | 2763 | GtkTreeStore *ts; |
@@ -2356,27 +2765,31 @@ void GNUNET_GTK_master_publish_dialog_ego_combobox_changed_cb( | |||
2356 | struct GNUNET_IDENTITY_Ego *ego; | 2765 | struct GNUNET_IDENTITY_Ego *ego; |
2357 | struct UpdateableContext uc; | 2766 | struct UpdateableContext uc; |
2358 | 2767 | ||
2359 | ts = GTK_TREE_STORE(gtk_builder_get_object( | 2768 | ts = GTK_TREE_STORE ( |
2360 | ctx->builder, "GNUNET_GTK_update_identifiers_treestore")); | 2769 | gtk_builder_get_object (ctx->builder, |
2361 | gtk_tree_store_clear(ts); | 2770 | "GNUNET_GTK_update_identifiers_treestore")); |
2362 | if (!gtk_combo_box_get_active_iter(combo, &iter)) { | 2771 | gtk_tree_store_clear (ts); |
2772 | if (! gtk_combo_box_get_active_iter (combo, &iter)) | ||
2773 | { | ||
2363 | /* entry unselected, etc. */ | 2774 | /* entry unselected, etc. */ |
2364 | ctx->ns = NULL; | 2775 | ctx->ns = NULL; |
2365 | gtk_widget_set_sensitive(ctx->identifier_entry, FALSE); | 2776 | gtk_widget_set_sensitive (ctx->identifier_entry, FALSE); |
2366 | gtk_widget_set_sensitive(ctx->updateable_checkbox, FALSE); | 2777 | gtk_widget_set_sensitive (ctx->updateable_checkbox, FALSE); |
2367 | gtk_widget_set_sensitive(ctx->update_id_entry, FALSE); | 2778 | gtk_widget_set_sensitive (ctx->update_id_entry, FALSE); |
2368 | update_selectivity_execute_cancel(ctx); | 2779 | update_selectivity_execute_cancel (ctx); |
2369 | return; | 2780 | return; |
2370 | } | 2781 | } |
2371 | tm = GTK_TREE_MODEL(gtk_builder_get_object( | 2782 | tm = GTK_TREE_MODEL ( |
2372 | ctx->builder, "GNUNET_GTK_master_publish_dialog_ego_liststore")); | 2783 | gtk_builder_get_object (ctx->builder, |
2373 | gtk_tree_model_get(tm, &iter, EGO_MC_EGO, &ego, -1); | 2784 | "GNUNET_GTK_master_publish_dialog_ego_liststore")); |
2374 | if (NULL == ego) { | 2785 | gtk_tree_model_get (tm, &iter, EGO_MC_EGO, &ego, -1); |
2375 | GNUNET_break(0); | 2786 | if (NULL == ego) |
2376 | gtk_widget_set_sensitive(ctx->identifier_entry, FALSE); | 2787 | { |
2377 | gtk_widget_set_sensitive(ctx->updateable_checkbox, FALSE); | 2788 | GNUNET_break (0); |
2378 | gtk_widget_set_sensitive(ctx->update_id_entry, FALSE); | 2789 | gtk_widget_set_sensitive (ctx->identifier_entry, FALSE); |
2379 | update_selectivity_execute_cancel(ctx); | 2790 | gtk_widget_set_sensitive (ctx->updateable_checkbox, FALSE); |
2791 | gtk_widget_set_sensitive (ctx->update_id_entry, FALSE); | ||
2792 | update_selectivity_execute_cancel (ctx); | ||
2380 | return; | 2793 | return; |
2381 | } | 2794 | } |
2382 | ctx->ns = ego; | 2795 | ctx->ns = ego; |
@@ -2384,17 +2797,20 @@ void GNUNET_GTK_master_publish_dialog_ego_combobox_changed_cb( | |||
2384 | uc.ts = ts; | 2797 | uc.ts = ts; |
2385 | uc.ns = ego; | 2798 | uc.ns = ego; |
2386 | uc.update_called = GNUNET_NO; | 2799 | uc.update_called = GNUNET_NO; |
2387 | uc.seen = GNUNET_CONTAINER_multihashmap_create(128, GNUNET_NO); | 2800 | uc.seen = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO); |
2388 | 2801 | ||
2389 | GNUNET_FS_namespace_list_updateable(GNUNET_FS_GTK_get_fs_handle(), | 2802 | GNUNET_FS_namespace_list_updateable (GNUNET_FS_GTK_get_fs_handle (), |
2390 | GNUNET_IDENTITY_ego_get_private_key(ego), | 2803 | GNUNET_IDENTITY_ego_get_private_key ( |
2391 | NULL, &add_updateable_to_ts, &uc); | 2804 | ego), |
2392 | GNUNET_CONTAINER_multihashmap_iterate(uc.seen, &free_seen_paths, NULL); | 2805 | NULL, |
2393 | GNUNET_CONTAINER_multihashmap_destroy(uc.seen); | 2806 | &add_updateable_to_ts, |
2394 | gtk_widget_set_sensitive(ctx->identifier_entry, TRUE); | 2807 | &uc); |
2395 | gtk_widget_set_sensitive(ctx->updateable_checkbox, TRUE); | 2808 | GNUNET_CONTAINER_multihashmap_iterate (uc.seen, &free_seen_paths, NULL); |
2396 | gtk_widget_set_sensitive(ctx->update_id_entry, TRUE); | 2809 | GNUNET_CONTAINER_multihashmap_destroy (uc.seen); |
2397 | update_selectivity_execute_cancel(ctx); | 2810 | gtk_widget_set_sensitive (ctx->identifier_entry, TRUE); |
2811 | gtk_widget_set_sensitive (ctx->updateable_checkbox, TRUE); | ||
2812 | gtk_widget_set_sensitive (ctx->update_id_entry, TRUE); | ||
2813 | update_selectivity_execute_cancel (ctx); | ||
2398 | } | 2814 | } |
2399 | 2815 | ||
2400 | /** | 2816 | /** |
@@ -2406,8 +2822,12 @@ void GNUNET_GTK_master_publish_dialog_ego_combobox_changed_cb( | |||
2406 | * @param ego_ctx where to store context data | 2822 | * @param ego_ctx where to store context data |
2407 | * @param name name of the namespace to add | 2823 | * @param name name of the namespace to add |
2408 | */ | 2824 | */ |
2409 | static void add_namespace_to_ts(void *cls, struct GNUNET_IDENTITY_Ego *ego, | 2825 | static void |
2410 | void **ego_ctx, const char *name) { | 2826 | add_namespace_to_ts (void *cls, |
2827 | struct GNUNET_IDENTITY_Ego *ego, | ||
2828 | void **ego_ctx, | ||
2829 | const char *name) | ||
2830 | { | ||
2411 | struct MainPublishingDialogContext *ctx = cls; | 2831 | struct MainPublishingDialogContext *ctx = cls; |
2412 | GtkListStore *ls; | 2832 | GtkListStore *ls; |
2413 | GtkTreePath *path; | 2833 | GtkTreePath *path; |
@@ -2417,38 +2837,50 @@ static void add_namespace_to_ts(void *cls, struct GNUNET_IDENTITY_Ego *ego, | |||
2417 | 2837 | ||
2418 | if (NULL == ego) | 2838 | if (NULL == ego) |
2419 | return; /* nothing to be done */ | 2839 | return; /* nothing to be done */ |
2420 | ls = GTK_LIST_STORE(gtk_builder_get_object( | 2840 | ls = GTK_LIST_STORE ( |
2421 | ctx->builder, "GNUNET_GTK_master_publish_dialog_ego_liststore")); | 2841 | gtk_builder_get_object (ctx->builder, |
2842 | "GNUNET_GTK_master_publish_dialog_ego_liststore")); | ||
2422 | rr = *ego_ctx; | 2843 | rr = *ego_ctx; |
2423 | if (NULL == rr) { | 2844 | if (NULL == rr) |
2845 | { | ||
2424 | /* insert operation */ | 2846 | /* insert operation */ |
2425 | GNUNET_assert(NULL != name); | 2847 | GNUNET_assert (NULL != name); |
2426 | gtk_list_store_insert_with_values(ls, &iter, G_MAXINT, EGO_MC_NAME, name, | 2848 | gtk_list_store_insert_with_values (ls, |
2427 | EGO_MC_EGO, ego, -1); | 2849 | &iter, |
2428 | path = gtk_tree_model_get_path(GTK_TREE_MODEL(ls), &iter); | 2850 | G_MAXINT, |
2429 | rr = gtk_tree_row_reference_new(GTK_TREE_MODEL(ls), path); | 2851 | EGO_MC_NAME, |
2430 | gtk_tree_path_free(path); | 2852 | name, |
2853 | EGO_MC_EGO, | ||
2854 | ego, | ||
2855 | -1); | ||
2856 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (ls), &iter); | ||
2857 | rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (ls), path); | ||
2858 | gtk_tree_path_free (path); | ||
2431 | *ego_ctx = rr; | 2859 | *ego_ctx = rr; |
2432 | } else if (NULL == name) { | 2860 | } |
2861 | else if (NULL == name) | ||
2862 | { | ||
2433 | /* delete operation */ | 2863 | /* delete operation */ |
2434 | path = gtk_tree_row_reference_get_path(rr); | 2864 | path = gtk_tree_row_reference_get_path (rr); |
2435 | gtk_tree_row_reference_free(rr); | 2865 | gtk_tree_row_reference_free (rr); |
2436 | GNUNET_assert(gtk_tree_model_get_iter(GTK_TREE_MODEL(ls), &iter, path)); | 2866 | GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (ls), &iter, path)); |
2437 | gtk_tree_path_free(path); | 2867 | gtk_tree_path_free (path); |
2438 | gtk_list_store_remove(ls, &iter); | 2868 | gtk_list_store_remove (ls, &iter); |
2439 | *ego_ctx = NULL; | 2869 | *ego_ctx = NULL; |
2440 | } else { | 2870 | } |
2871 | else | ||
2872 | { | ||
2441 | /* rename operation */ | 2873 | /* rename operation */ |
2442 | path = gtk_tree_row_reference_get_path(rr); | 2874 | path = gtk_tree_row_reference_get_path (rr); |
2443 | GNUNET_assert(gtk_tree_model_get_iter(GTK_TREE_MODEL(ls), &iter, path)); | 2875 | GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (ls), &iter, path)); |
2444 | gtk_list_store_set(ls, &iter, G_MAXINT, EGO_MC_NAME, name, -1); | 2876 | gtk_list_store_set (ls, &iter, G_MAXINT, EGO_MC_NAME, name, -1); |
2445 | gtk_tree_path_free(path); | 2877 | gtk_tree_path_free (path); |
2446 | } | 2878 | } |
2447 | have_ns = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(ls), &iter); | 2879 | have_ns = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ls), &iter); |
2448 | gtk_widget_set_sensitive(ctx->own_checkbox, have_ns); | 2880 | gtk_widget_set_sensitive (ctx->own_checkbox, have_ns); |
2449 | gtk_widget_set_sensitive(ctx->identifier_entry, have_ns); | 2881 | gtk_widget_set_sensitive (ctx->identifier_entry, have_ns); |
2450 | gtk_widget_set_sensitive(ctx->updateable_checkbox, have_ns); | 2882 | gtk_widget_set_sensitive (ctx->updateable_checkbox, have_ns); |
2451 | gtk_widget_set_sensitive(ctx->update_id_entry, have_ns); | 2883 | gtk_widget_set_sensitive (ctx->update_id_entry, have_ns); |
2452 | } | 2884 | } |
2453 | 2885 | ||
2454 | /** | 2886 | /** |
@@ -2457,8 +2889,10 @@ static void add_namespace_to_ts(void *cls, struct GNUNET_IDENTITY_Ego *ego, | |||
2457 | * @param dummy widget that triggered the action | 2889 | * @param dummy widget that triggered the action |
2458 | * @param user_data builder of the main window | 2890 | * @param user_data builder of the main window |
2459 | */ | 2891 | */ |
2460 | void GNUNET_GTK_main_menu_file_publish_activate_cb(GtkWidget *dummy, | 2892 | void |
2461 | gpointer user_data) { | 2893 | GNUNET_GTK_main_menu_file_publish_activate_cb (GtkWidget *dummy, |
2894 | gpointer user_data) | ||
2895 | { | ||
2462 | struct MainPublishingDialogContext *ctx; | 2896 | struct MainPublishingDialogContext *ctx; |
2463 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 2897 | const struct GNUNET_CONFIGURATION_Handle *cfg; |
2464 | GtkWidget *toplevel; | 2898 | GtkWidget *toplevel; |
@@ -2466,111 +2900,137 @@ void GNUNET_GTK_main_menu_file_publish_activate_cb(GtkWidget *dummy, | |||
2466 | int own_enabled; | 2900 | int own_enabled; |
2467 | int global_enabled; | 2901 | int global_enabled; |
2468 | 2902 | ||
2469 | ctx = GNUNET_new(struct MainPublishingDialogContext); | 2903 | ctx = GNUNET_new (struct MainPublishingDialogContext); |
2470 | ctx->builder = | 2904 | ctx->builder = |
2471 | GNUNET_GTK_get_new_builder("gnunet_fs_gtk_publish_dialog.glade", ctx); | 2905 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_publish_dialog.glade", ctx); |
2472 | if (NULL == ctx->builder) { | 2906 | if (NULL == ctx->builder) |
2473 | GNUNET_break(0); | 2907 | { |
2474 | GNUNET_free(ctx); | 2908 | GNUNET_break (0); |
2909 | GNUNET_free (ctx); | ||
2475 | return; | 2910 | return; |
2476 | } | 2911 | } |
2477 | 2912 | ||
2478 | /* initialize widget references */ | 2913 | /* initialize widget references */ |
2479 | ctx->up_button = GTK_WIDGET(gtk_builder_get_object( | 2914 | ctx->up_button = GTK_WIDGET ( |
2480 | ctx->builder, "GNUNET_GTK_master_publish_dialog_up_button")); | 2915 | gtk_builder_get_object (ctx->builder, |
2481 | ctx->down_button = GTK_WIDGET(gtk_builder_get_object( | 2916 | "GNUNET_GTK_master_publish_dialog_up_button")); |
2482 | ctx->builder, "GNUNET_GTK_master_publish_dialog_down_button")); | 2917 | ctx->down_button = GTK_WIDGET ( |
2483 | ctx->left_button = GTK_WIDGET(gtk_builder_get_object( | 2918 | gtk_builder_get_object (ctx->builder, |
2484 | ctx->builder, "GNUNET_GTK_master_publish_dialog_left_button")); | 2919 | "GNUNET_GTK_master_publish_dialog_down_button")); |
2485 | ctx->right_button = GTK_WIDGET(gtk_builder_get_object( | 2920 | ctx->left_button = GTK_WIDGET ( |
2486 | ctx->builder, "GNUNET_GTK_master_publish_dialog_right_button")); | 2921 | gtk_builder_get_object (ctx->builder, |
2487 | ctx->delete_button = GTK_WIDGET(gtk_builder_get_object( | 2922 | "GNUNET_GTK_master_publish_dialog_left_button")); |
2488 | ctx->builder, "GNUNET_GTK_master_publish_dialog_delete_button")); | 2923 | ctx->right_button = GTK_WIDGET ( |
2489 | ctx->edit_button = GTK_WIDGET(gtk_builder_get_object( | 2924 | gtk_builder_get_object (ctx->builder, |
2490 | ctx->builder, "GNUNET_GTK_master_publish_dialog_edit_button")); | 2925 | "GNUNET_GTK_master_publish_dialog_right_button")); |
2491 | ctx->execute_button = GTK_WIDGET(gtk_builder_get_object( | 2926 | ctx->delete_button = GTK_WIDGET ( |
2492 | ctx->builder, "GNUNET_GTK_master_publish_dialog_execute_button")); | 2927 | gtk_builder_get_object (ctx->builder, |
2493 | ctx->cancel_button = GTK_WIDGET(gtk_builder_get_object( | 2928 | "GNUNET_GTK_master_publish_dialog_delete_button")); |
2494 | ctx->builder, "GNUNET_GTK_master_publish_dialog_cancel_button")); | 2929 | ctx->edit_button = GTK_WIDGET ( |
2495 | ctx->file_info_treeview = GTK_TREE_VIEW(gtk_builder_get_object( | 2930 | gtk_builder_get_object (ctx->builder, |
2496 | ctx->builder, | 2931 | "GNUNET_GTK_master_publish_dialog_edit_button")); |
2497 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | 2932 | ctx->execute_button = GTK_WIDGET ( |
2933 | gtk_builder_get_object (ctx->builder, | ||
2934 | "GNUNET_GTK_master_publish_dialog_execute_button")); | ||
2935 | ctx->cancel_button = GTK_WIDGET ( | ||
2936 | gtk_builder_get_object (ctx->builder, | ||
2937 | "GNUNET_GTK_master_publish_dialog_cancel_button")); | ||
2938 | ctx->file_info_treeview = GTK_TREE_VIEW (gtk_builder_get_object ( | ||
2939 | ctx->builder, | ||
2940 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | ||
2498 | ctx->file_info_selection = | 2941 | ctx->file_info_selection = |
2499 | gtk_tree_view_get_selection(ctx->file_info_treeview); | 2942 | gtk_tree_view_get_selection (ctx->file_info_treeview); |
2500 | ctx->file_info_treemodel = gtk_tree_view_get_model(ctx->file_info_treeview); | 2943 | ctx->file_info_treemodel = gtk_tree_view_get_model (ctx->file_info_treeview); |
2501 | ctx->master_pubdialog = GTK_WINDOW( | 2944 | ctx->master_pubdialog = GTK_WINDOW ( |
2502 | gtk_builder_get_object(ctx->builder, "GNUNET_GTK_master_publish_dialog")); | 2945 | gtk_builder_get_object (ctx->builder, "GNUNET_GTK_master_publish_dialog")); |
2503 | 2946 | ||
2504 | ctx->global_checkbox = GTK_WIDGET(gtk_builder_get_object( | 2947 | ctx->global_checkbox = GTK_WIDGET ( |
2505 | ctx->builder, "GNUNET_GTK_master_publish_dialog_global_checkbox")); | 2948 | gtk_builder_get_object (ctx->builder, |
2506 | ctx->own_checkbox = GTK_WIDGET(gtk_builder_get_object( | 2949 | "GNUNET_GTK_master_publish_dialog_global_checkbox")); |
2507 | ctx->builder, "GNUNET_GTK_master_publish_dialog_own_checkbox")); | 2950 | ctx->own_checkbox = GTK_WIDGET ( |
2508 | ctx->updateable_checkbox = GTK_WIDGET(gtk_builder_get_object( | 2951 | gtk_builder_get_object (ctx->builder, |
2509 | ctx->builder, "GNUNET_GTK_master_publish_dialog_updateable_checkbox")); | 2952 | "GNUNET_GTK_master_publish_dialog_own_checkbox")); |
2510 | ctx->update_id_entry = GTK_WIDGET(gtk_builder_get_object( | 2953 | ctx->updateable_checkbox = GTK_WIDGET (gtk_builder_get_object ( |
2511 | ctx->builder, "GNUNET_GTK_master_publish_dialog_update_id_entry")); | 2954 | ctx->builder, |
2512 | 2955 | "GNUNET_GTK_master_publish_dialog_updateable_checkbox")); | |
2513 | ctx->own_vbox = GTK_WIDGET(gtk_builder_get_object( | 2956 | ctx->update_id_entry = GTK_WIDGET ( |
2514 | ctx->builder, "GNUNET_GTK_master_publish_dialog_own_vbox")); | 2957 | gtk_builder_get_object (ctx->builder, |
2515 | ctx->update_id_hbox = GTK_WIDGET(gtk_builder_get_object( | 2958 | "GNUNET_GTK_master_publish_dialog_update_id_entry")); |
2516 | ctx->builder, "GNUNET_GTK_master_publish_dialog_update_id_hbox")); | 2959 | |
2517 | 2960 | ctx->own_vbox = GTK_WIDGET ( | |
2518 | ctx->identifiers_expander = GTK_WIDGET(gtk_builder_get_object( | 2961 | gtk_builder_get_object (ctx->builder, |
2519 | ctx->builder, | 2962 | "GNUNET_GTK_master_publish_dialog_own_vbox")); |
2520 | "GNUNET_GTK_master_publish_dialog_previous_identifiers_expander")); | 2963 | ctx->update_id_hbox = GTK_WIDGET ( |
2521 | ctx->vpaned = GTK_WIDGET(gtk_builder_get_object( | 2964 | gtk_builder_get_object (ctx->builder, |
2522 | ctx->builder, "GNUNET_GTK_master_publish_dialog_vpaned")); | 2965 | "GNUNET_GTK_master_publish_dialog_update_id_hbox")); |
2523 | ctx->bottom_frame = GTK_WIDGET(gtk_builder_get_object( | 2966 | |
2524 | ctx->builder, "GNUNET_GTK_master_publish_dialog_bottom_frame")); | 2967 | ctx->identifiers_expander = GTK_WIDGET (gtk_builder_get_object ( |
2525 | 2968 | ctx->builder, | |
2526 | ctx->identifier_entry = GTK_WIDGET(gtk_builder_get_object( | 2969 | "GNUNET_GTK_master_publish_dialog_previous_identifiers_expander")); |
2527 | ctx->builder, "GNUNET_GTK_master_publish_dialog_identifier_entry")); | 2970 | ctx->vpaned = GTK_WIDGET ( |
2528 | ctx->identifiers_scrolled = GTK_WIDGET(gtk_builder_get_object( | 2971 | gtk_builder_get_object (ctx->builder, |
2529 | ctx->builder, | 2972 | "GNUNET_GTK_master_publish_dialog_vpaned")); |
2530 | "GNUNET_GTK_master_publish_dialog_previous_identifiers_scrolled")); | 2973 | ctx->bottom_frame = GTK_WIDGET ( |
2531 | ctx->identifiers_treeview = GTK_TREE_VIEW(gtk_builder_get_object( | 2974 | gtk_builder_get_object (ctx->builder, |
2532 | ctx->builder, | 2975 | "GNUNET_GTK_master_publish_dialog_bottom_frame")); |
2533 | "GNUNET_GTK_master_publish_dialog_previous_identifiers_treeview")); | 2976 | |
2977 | ctx->identifier_entry = GTK_WIDGET ( | ||
2978 | gtk_builder_get_object (ctx->builder, | ||
2979 | "GNUNET_GTK_master_publish_dialog_identifier_entry")); | ||
2980 | ctx->identifiers_scrolled = GTK_WIDGET (gtk_builder_get_object ( | ||
2981 | ctx->builder, | ||
2982 | "GNUNET_GTK_master_publish_dialog_previous_identifiers_scrolled")); | ||
2983 | ctx->identifiers_treeview = GTK_TREE_VIEW (gtk_builder_get_object ( | ||
2984 | ctx->builder, | ||
2985 | "GNUNET_GTK_master_publish_dialog_previous_identifiers_treeview")); | ||
2534 | ctx->identifiers_treemodel = | 2986 | ctx->identifiers_treemodel = |
2535 | gtk_tree_view_get_model(ctx->identifiers_treeview); | 2987 | gtk_tree_view_get_model (ctx->identifiers_treeview); |
2536 | ctx->identifiers_selection = | 2988 | ctx->identifiers_selection = |
2537 | gtk_tree_view_get_selection(ctx->identifiers_treeview); | 2989 | gtk_tree_view_get_selection (ctx->identifiers_treeview); |
2538 | 2990 | ||
2539 | g_signal_connect(ctx->identifiers_expander, "notify::expanded", | 2991 | g_signal_connect (ctx->identifiers_expander, |
2540 | G_CALLBACK(expander_callback), ctx); | 2992 | "notify::expanded", |
2993 | G_CALLBACK (expander_callback), | ||
2994 | ctx); | ||
2541 | 2995 | ||
2542 | cfg = GNUNET_FS_GTK_get_configuration(); | 2996 | cfg = GNUNET_FS_GTK_get_configuration (); |
2543 | ctx->identity = GNUNET_IDENTITY_connect(cfg, &add_namespace_to_ts, ctx); | 2997 | ctx->identity = GNUNET_IDENTITY_connect (cfg, &add_namespace_to_ts, ctx); |
2544 | 2998 | ||
2545 | updateable_enabled = GNUNET_CONFIGURATION_get_value_yesno( | 2999 | updateable_enabled = GNUNET_CONFIGURATION_get_value_yesno ( |
2546 | cfg, "gnunet-fs-gtk", "MAKE_UPDATEABLE_PUBLICATIONS_BY_DEFAULT"); | 3000 | cfg, |
3001 | "gnunet-fs-gtk", | ||
3002 | "MAKE_UPDATEABLE_PUBLICATIONS_BY_DEFAULT"); | ||
2547 | if (GNUNET_SYSERR == updateable_enabled) | 3003 | if (GNUNET_SYSERR == updateable_enabled) |
2548 | updateable_enabled = GNUNET_YES; | 3004 | updateable_enabled = GNUNET_YES; |
2549 | own_enabled = GNUNET_CONFIGURATION_get_value_yesno( | 3005 | own_enabled = |
2550 | cfg, "gnunet-fs-gtk", "MAKE_NAMESPACE_PUBLICATIONS_BY_DEFAULT"); | 3006 | GNUNET_CONFIGURATION_get_value_yesno (cfg, |
3007 | "gnunet-fs-gtk", | ||
3008 | "MAKE_NAMESPACE_PUBLICATIONS_BY_DEFAULT"); | ||
2551 | if (GNUNET_SYSERR == own_enabled) | 3009 | if (GNUNET_SYSERR == own_enabled) |
2552 | own_enabled = GNUNET_NO; | 3010 | own_enabled = GNUNET_NO; |
2553 | global_enabled = GNUNET_CONFIGURATION_get_value_yesno( | 3011 | global_enabled = |
2554 | cfg, "gnunet-fs-gtk", "MAKE_GLOBAL_PUBLICATIONS_BY_DEFAULT"); | 3012 | GNUNET_CONFIGURATION_get_value_yesno (cfg, |
3013 | "gnunet-fs-gtk", | ||
3014 | "MAKE_GLOBAL_PUBLICATIONS_BY_DEFAULT"); | ||
2555 | if (GNUNET_SYSERR == global_enabled) | 3015 | if (GNUNET_SYSERR == global_enabled) |
2556 | global_enabled = GNUNET_YES; | 3016 | global_enabled = GNUNET_YES; |
2557 | 3017 | ||
2558 | /* This will emit appropriate signals, their handlers will hide | 3018 | /* This will emit appropriate signals, their handlers will hide |
2559 | * parts of the dialog as needed. | 3019 | * parts of the dialog as needed. |
2560 | */ | 3020 | */ |
2561 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ctx->updateable_checkbox), | 3021 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ctx->updateable_checkbox), |
2562 | GNUNET_YES == updateable_enabled); | 3022 | GNUNET_YES == updateable_enabled); |
2563 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ctx->own_checkbox), | 3023 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ctx->own_checkbox), |
2564 | GNUNET_YES == own_enabled); | 3024 | GNUNET_YES == own_enabled); |
2565 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ctx->global_checkbox), | 3025 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ctx->global_checkbox), |
2566 | GNUNET_YES == global_enabled); | 3026 | GNUNET_YES == global_enabled); |
2567 | 3027 | ||
2568 | /* show dialog */ | 3028 | /* show dialog */ |
2569 | toplevel = gtk_widget_get_toplevel(dummy); | 3029 | toplevel = gtk_widget_get_toplevel (dummy); |
2570 | if (GTK_IS_WINDOW(toplevel)) | 3030 | if (GTK_IS_WINDOW (toplevel)) |
2571 | gtk_window_set_transient_for(GTK_WINDOW(ctx->master_pubdialog), | 3031 | gtk_window_set_transient_for (GTK_WINDOW (ctx->master_pubdialog), |
2572 | GTK_WINDOW(toplevel)); | 3032 | GTK_WINDOW (toplevel)); |
2573 | gtk_window_present(GTK_WINDOW(ctx->master_pubdialog)); | 3033 | gtk_window_present (GTK_WINDOW (ctx->master_pubdialog)); |
2574 | } | 3034 | } |
2575 | 3035 | ||
2576 | /* end of gnunet-fs-gtk_publish-dialog.c */ | 3036 | /* end of gnunet-fs-gtk_publish-dialog.c */ |
diff --git a/src/fs/gnunet-fs-gtk_publish-edit-dialog.c b/src/fs/gnunet-fs-gtk_publish-edit-dialog.c index 7f7f2bd2..b988fc3a 100644 --- a/src/fs/gnunet-fs-gtk_publish-edit-dialog.c +++ b/src/fs/gnunet-fs-gtk_publish-edit-dialog.c | |||
@@ -33,93 +33,93 @@ | |||
33 | * Columns in the publication metadata model. | 33 | * Columns in the publication metadata model. |
34 | */ | 34 | */ |
35 | enum PUBLISH_MetadataModelColumns | 35 | enum PUBLISH_MetadataModelColumns |
36 | { | 36 | { |
37 | /** | 37 | /** |
38 | * A guint. | 38 | * A guint. |
39 | */ | 39 | */ |
40 | PUBLISH_METADATA_MC_TYPE = 0, | 40 | PUBLISH_METADATA_MC_TYPE = 0, |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * A guint. | 43 | * A guint. |
44 | */ | 44 | */ |
45 | PUBLISH_METADATA_MC_FORMAT = 1, | 45 | PUBLISH_METADATA_MC_FORMAT = 1, |
46 | 46 | ||
47 | /** | 47 | /** |
48 | * A gchararray. | 48 | * A gchararray. |
49 | */ | 49 | */ |
50 | PUBLISH_METADATA_MC_TYPE_NAME = 2, | 50 | PUBLISH_METADATA_MC_TYPE_NAME = 2, |
51 | 51 | ||
52 | /** | 52 | /** |
53 | * A gchararray. | 53 | * A gchararray. |
54 | */ | 54 | */ |
55 | PUBLISH_METADATA_MC_VALUE = 3, | 55 | PUBLISH_METADATA_MC_VALUE = 3, |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * A gchararray. | 58 | * A gchararray. |
59 | */ | 59 | */ |
60 | PUBLISH_METADATA_MC_DESCRIPTION = 4, | 60 | PUBLISH_METADATA_MC_DESCRIPTION = 4, |
61 | }; | 61 | }; |
62 | 62 | ||
63 | 63 | ||
64 | /** | 64 | /** |
65 | * Columns in the publication metadata types model. | 65 | * Columns in the publication metadata types model. |
66 | */ | 66 | */ |
67 | enum PUBLISH_MetadataTypesModelColumns | 67 | enum PUBLISH_MetadataTypesModelColumns |
68 | { | 68 | { |
69 | /** | 69 | /** |
70 | * A gint. | 70 | * A gint. |
71 | */ | 71 | */ |
72 | PUBLISH_METADATA_TYPES_MC_TYPE = 0, | 72 | PUBLISH_METADATA_TYPES_MC_TYPE = 0, |
73 | 73 | ||
74 | /** | 74 | /** |
75 | * A gint. | 75 | * A gint. |
76 | */ | 76 | */ |
77 | PUBLISH_METADATA_TYPES_MC_FORMAT = 1, | 77 | PUBLISH_METADATA_TYPES_MC_FORMAT = 1, |
78 | 78 | ||
79 | /** | 79 | /** |
80 | * A gchararray. | 80 | * A gchararray. |
81 | */ | 81 | */ |
82 | PUBLISH_METADATA_TYPES_MC_TYPE_NAME = 2, | 82 | PUBLISH_METADATA_TYPES_MC_TYPE_NAME = 2, |
83 | 83 | ||
84 | /** | 84 | /** |
85 | * A gchararray. | 85 | * A gchararray. |
86 | */ | 86 | */ |
87 | PUBLISH_METADATA_TYPES_MC_DESCRIPTION = 3 | 87 | PUBLISH_METADATA_TYPES_MC_DESCRIPTION = 3 |
88 | }; | 88 | }; |
89 | 89 | ||
90 | 90 | ||
91 | /** | 91 | /** |
92 | * Columns in the publication types model. | 92 | * Columns in the publication types model. |
93 | */ | 93 | */ |
94 | enum PUBLISH_TypesModelColumns | 94 | enum PUBLISH_TypesModelColumns |
95 | { | 95 | { |
96 | /** | 96 | /** |
97 | * A gint. | 97 | * A gint. |
98 | */ | 98 | */ |
99 | PUBLISH_TYPES_MC_TYPE = 0, | 99 | PUBLISH_TYPES_MC_TYPE = 0, |
100 | 100 | ||
101 | /** | 101 | /** |
102 | * A gchararray. | 102 | * A gchararray. |
103 | */ | 103 | */ |
104 | PUBLISH_TYPES_MC_TYPE_NAME = 1 | 104 | PUBLISH_TYPES_MC_TYPE_NAME = 1 |
105 | }; | 105 | }; |
106 | 106 | ||
107 | 107 | ||
108 | /** | 108 | /** |
109 | * Columns in the publication keywords model. | 109 | * Columns in the publication keywords model. |
110 | */ | 110 | */ |
111 | enum PUBLISH_KeywordsModelColumns | 111 | enum PUBLISH_KeywordsModelColumns |
112 | { | 112 | { |
113 | /** | 113 | /** |
114 | * A gchararray. | 114 | * A gchararray. |
115 | */ | 115 | */ |
116 | PUBLISH_TYPES_MC_KEYWORD = 0, | 116 | PUBLISH_TYPES_MC_KEYWORD = 0, |
117 | 117 | ||
118 | /** | 118 | /** |
119 | * A gboolean. | 119 | * A gboolean. |
120 | */ | 120 | */ |
121 | PUBLISH_TYPES_MC_ADDED = 1 | 121 | PUBLISH_TYPES_MC_ADDED = 1 |
122 | }; | 122 | }; |
123 | 123 | ||
124 | 124 | ||
125 | /** | 125 | /** |
@@ -259,7 +259,6 @@ struct EditPublicationDialogContext | |||
259 | * Is it allowed for the user to supply keywords in this dialog? | 259 | * Is it allowed for the user to supply keywords in this dialog? |
260 | */ | 260 | */ |
261 | int allow_no_keywords; | 261 | int allow_no_keywords; |
262 | |||
263 | }; | 262 | }; |
264 | 263 | ||
265 | 264 | ||
@@ -277,11 +276,9 @@ free_edit_dialog_context (struct EditPublicationDialogContext *ctx) | |||
277 | } | 276 | } |
278 | 277 | ||
279 | 278 | ||
280 | |||
281 | /* ****************** metadata editing ******************** */ | 279 | /* ****************** metadata editing ******************** */ |
282 | 280 | ||
283 | 281 | ||
284 | |||
285 | /** | 282 | /** |
286 | * Update the set of metatypes listed in the dialog based on the | 283 | * Update the set of metatypes listed in the dialog based on the |
287 | * given code. | 284 | * given code. |
@@ -300,7 +297,8 @@ change_metatypes (struct EditPublicationDialogContext *ctx, gint code) | |||
300 | #endif | 297 | #endif |
301 | 298 | ||
302 | /* double-check that 'code' is valid */ | 299 | /* double-check that 'code' is valid */ |
303 | for (pubtype_count = 0; NULL != types[pubtype_count]; pubtype_count++) ; | 300 | for (pubtype_count = 0; NULL != types[pubtype_count]; pubtype_count++) |
301 | ; | ||
304 | GNUNET_assert (code < pubtype_count); | 302 | GNUNET_assert (code < pubtype_count); |
305 | 303 | ||
306 | /* clear existing selection of metatypes */ | 304 | /* clear existing selection of metatypes */ |
@@ -309,19 +307,20 @@ change_metatypes (struct EditPublicationDialogContext *ctx, gint code) | |||
309 | max_type = EXTRACTOR_metatype_get_max (); | 307 | max_type = EXTRACTOR_metatype_get_max (); |
310 | /* add new types based on selection */ | 308 | /* add new types based on selection */ |
311 | for (i = 0; types[code][i] != EXTRACTOR_METATYPE_RESERVED; i++) | 309 | for (i = 0; types[code][i] != EXTRACTOR_METATYPE_RESERVED; i++) |
312 | if ( (types[code][i] < max_type) && (types[code][i] > 0) ) | 310 | if ((types[code][i] < max_type) && (types[code][i] > 0)) |
313 | gtk_list_store_insert_with_values (ctx->metatypes_liststore, | 311 | gtk_list_store_insert_with_values (ctx->metatypes_liststore, |
314 | &iter, G_MAXINT, | 312 | &iter, |
313 | G_MAXINT, | ||
315 | PUBLISH_METADATA_TYPES_MC_TYPE, | 314 | PUBLISH_METADATA_TYPES_MC_TYPE, |
316 | types[code][i], | 315 | types[code][i], |
317 | PUBLISH_METADATA_TYPES_MC_FORMAT, | 316 | PUBLISH_METADATA_TYPES_MC_FORMAT, |
318 | EXTRACTOR_METAFORMAT_UTF8, | 317 | EXTRACTOR_METAFORMAT_UTF8, |
319 | PUBLISH_METADATA_TYPES_MC_TYPE_NAME, | 318 | PUBLISH_METADATA_TYPES_MC_TYPE_NAME, |
320 | EXTRACTOR_metatype_to_string | 319 | EXTRACTOR_metatype_to_string ( |
321 | (types [code][i]), | 320 | types[code][i]), |
322 | PUBLISH_METADATA_TYPES_MC_DESCRIPTION, | 321 | PUBLISH_METADATA_TYPES_MC_DESCRIPTION, |
323 | EXTRACTOR_metatype_to_description | 322 | EXTRACTOR_metatype_to_description ( |
324 | (types[code][i]), | 323 | types[code][i]), |
325 | -1); | 324 | -1); |
326 | #endif | 325 | #endif |
327 | } | 326 | } |
@@ -335,7 +334,7 @@ change_metatypes (struct EditPublicationDialogContext *ctx, gint code) | |||
335 | * @param user_data the 'struct EditPublicationDialogContext' | 334 | * @param user_data the 'struct EditPublicationDialogContext' |
336 | */ | 335 | */ |
337 | void | 336 | void |
338 | GNUNET_GTK_edit_publication_type_combo_changed_cb (GtkComboBox * widget, | 337 | GNUNET_GTK_edit_publication_type_combo_changed_cb (GtkComboBox *widget, |
339 | gpointer user_data) | 338 | gpointer user_data) |
340 | { | 339 | { |
341 | struct EditPublicationDialogContext *ctx = user_data; | 340 | struct EditPublicationDialogContext *ctx = user_data; |
@@ -344,8 +343,11 @@ GNUNET_GTK_edit_publication_type_combo_changed_cb (GtkComboBox * widget, | |||
344 | 343 | ||
345 | if (! gtk_combo_box_get_active_iter (widget, &iter)) | 344 | if (! gtk_combo_box_get_active_iter (widget, &iter)) |
346 | return; | 345 | return; |
347 | gtk_tree_model_get (GTK_TREE_MODEL (ctx->pubtypes_liststore), &iter, | 346 | gtk_tree_model_get (GTK_TREE_MODEL (ctx->pubtypes_liststore), |
348 | PUBLISH_TYPES_MC_TYPE, &code, -1); | 347 | &iter, |
348 | PUBLISH_TYPES_MC_TYPE, | ||
349 | &code, | ||
350 | -1); | ||
349 | change_metatypes (ctx, code); | 351 | change_metatypes (ctx, code); |
350 | } | 352 | } |
351 | 353 | ||
@@ -358,14 +360,15 @@ GNUNET_GTK_edit_publication_type_combo_changed_cb (GtkComboBox * widget, | |||
358 | * @param user_data the 'struct EditPublicationDialogContext' | 360 | * @param user_data the 'struct EditPublicationDialogContext' |
359 | */ | 361 | */ |
360 | void | 362 | void |
361 | GNUNET_GTK_edit_publication_metadata_treeview_selection_changed_cb (GtkTreeSelection *ts, | 363 | GNUNET_GTK_edit_publication_metadata_treeview_selection_changed_cb ( |
362 | gpointer user_data) | 364 | GtkTreeSelection *ts, |
365 | gpointer user_data) | ||
363 | { | 366 | { |
364 | struct EditPublicationDialogContext *ctx = user_data; | 367 | struct EditPublicationDialogContext *ctx = user_data; |
365 | 368 | ||
366 | gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object | 369 | gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object ( |
367 | (ctx->builder, | 370 | ctx->builder, |
368 | "GNUNET_GTK_edit_publication_delete_button")), | 371 | "GNUNET_GTK_edit_publication_delete_button")), |
369 | gtk_tree_selection_get_selected (ts, NULL, NULL)); | 372 | gtk_tree_selection_get_selected (ts, NULL, NULL)); |
370 | } | 373 | } |
371 | 374 | ||
@@ -381,18 +384,20 @@ GNUNET_GTK_edit_publication_metadata_treeview_selection_changed_cb (GtkTreeSelec | |||
381 | * @param user_data the 'struct EditPublicationDialogContext' | 384 | * @param user_data the 'struct EditPublicationDialogContext' |
382 | */ | 385 | */ |
383 | void | 386 | void |
384 | GNUNET_GTK_edit_publication_metadata_tree_view_type_renderer_edited_cb (GtkCellRendererText *renderer, | 387 | GNUNET_GTK_edit_publication_metadata_tree_view_type_renderer_edited_cb ( |
385 | gchar * path, | 388 | GtkCellRendererText *renderer, |
386 | gchar * new_text, | 389 | gchar *path, |
387 | gpointer user_data) | 390 | gchar *new_text, |
391 | gpointer user_data) | ||
388 | { | 392 | { |
389 | struct EditPublicationDialogContext *ctx = user_data; | 393 | struct EditPublicationDialogContext *ctx = user_data; |
390 | GtkTreeIter iter; | 394 | GtkTreeIter iter; |
391 | gint type_id; | 395 | gint type_id; |
392 | 396 | ||
393 | if (! gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (ctx->meta_liststore), | 397 | if (! gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL ( |
394 | &iter, | 398 | ctx->meta_liststore), |
395 | path)) | 399 | &iter, |
400 | path)) | ||
396 | { | 401 | { |
397 | GNUNET_break (0); | 402 | GNUNET_break (0); |
398 | return; | 403 | return; |
@@ -404,9 +409,12 @@ GNUNET_GTK_edit_publication_metadata_tree_view_type_renderer_edited_cb (GtkCellR | |||
404 | } | 409 | } |
405 | type_id = ctx->meta_combo_selected_type_id; | 410 | type_id = ctx->meta_combo_selected_type_id; |
406 | ctx->meta_combo_selected_type_id = -1; | 411 | ctx->meta_combo_selected_type_id = -1; |
407 | gtk_list_store_set (ctx->meta_liststore, &iter, | 412 | gtk_list_store_set (ctx->meta_liststore, |
408 | PUBLISH_METADATA_MC_TYPE, type_id, | 413 | &iter, |
409 | PUBLISH_METADATA_MC_FORMAT, EXTRACTOR_METAFORMAT_UTF8, | 414 | PUBLISH_METADATA_MC_TYPE, |
415 | type_id, | ||
416 | PUBLISH_METADATA_MC_FORMAT, | ||
417 | EXTRACTOR_METAFORMAT_UTF8, | ||
410 | #if HAVE_EXTRACTOR | 418 | #if HAVE_EXTRACTOR |
411 | PUBLISH_METADATA_MC_TYPE_NAME, | 419 | PUBLISH_METADATA_MC_TYPE_NAME, |
412 | EXTRACTOR_metatype_to_string (type_id), | 420 | EXTRACTOR_metatype_to_string (type_id), |
@@ -429,19 +437,21 @@ GNUNET_GTK_edit_publication_metadata_tree_view_type_renderer_edited_cb (GtkCellR | |||
429 | * @param user_data the 'struct EditPublicationDialogContext' | 437 | * @param user_data the 'struct EditPublicationDialogContext' |
430 | */ | 438 | */ |
431 | void | 439 | void |
432 | GNUNET_GTK_edit_publication_metadata_tree_view_type_renderer_changed_cb (GtkCellRendererCombo * combo, | 440 | GNUNET_GTK_edit_publication_metadata_tree_view_type_renderer_changed_cb ( |
433 | gchar * path_string, | 441 | GtkCellRendererCombo *combo, |
434 | GtkTreeIter * new_iter, | 442 | gchar *path_string, |
435 | gpointer user_data) | 443 | GtkTreeIter *new_iter, |
444 | gpointer user_data) | ||
436 | { | 445 | { |
437 | struct EditPublicationDialogContext *ctx = user_data; | 446 | struct EditPublicationDialogContext *ctx = user_data; |
438 | GtkTreeModel *combo_model; | 447 | GtkTreeModel *combo_model; |
439 | gint type_id; | 448 | gint type_id; |
440 | 449 | ||
441 | g_object_get (combo, | 450 | g_object_get (combo, "model", &combo_model, NULL); |
442 | "model", &combo_model, NULL); | 451 | gtk_tree_model_get (combo_model, |
443 | gtk_tree_model_get (combo_model, new_iter, | 452 | new_iter, |
444 | PUBLISH_METADATA_MC_TYPE, &type_id, | 453 | PUBLISH_METADATA_MC_TYPE, |
454 | &type_id, | ||
445 | -1); | 455 | -1); |
446 | ctx->meta_combo_selected_type_id = type_id; | 456 | ctx->meta_combo_selected_type_id = type_id; |
447 | } | 457 | } |
@@ -458,10 +468,11 @@ GNUNET_GTK_edit_publication_metadata_tree_view_type_renderer_changed_cb (GtkCell | |||
458 | * @param user_data the 'struct EditPublicationDialogContext' | 468 | * @param user_data the 'struct EditPublicationDialogContext' |
459 | */ | 469 | */ |
460 | void | 470 | void |
461 | GNUNET_GTK_edit_publication_metadata_tree_view_value_renderer_edited_cb (GtkCellRendererText * renderer, | 471 | GNUNET_GTK_edit_publication_metadata_tree_view_value_renderer_edited_cb ( |
462 | gchar * path, | 472 | GtkCellRendererText *renderer, |
463 | gchar * new_text, | 473 | gchar *path, |
464 | gpointer user_data) | 474 | gchar *new_text, |
475 | gpointer user_data) | ||
465 | { | 476 | { |
466 | struct EditPublicationDialogContext *ctx = user_data; | 477 | struct EditPublicationDialogContext *ctx = user_data; |
467 | GtkTreeIter iter; | 478 | GtkTreeIter iter; |
@@ -471,16 +482,20 @@ GNUNET_GTK_edit_publication_metadata_tree_view_value_renderer_edited_cb (GtkCell | |||
471 | size_t slen; | 482 | size_t slen; |
472 | char *pos; | 483 | char *pos; |
473 | 484 | ||
474 | if (! gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (ctx->meta_liststore), | 485 | if (! gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL ( |
475 | &iter, | 486 | ctx->meta_liststore), |
476 | path)) | 487 | &iter, |
488 | path)) | ||
477 | { | 489 | { |
478 | GNUNET_break (0); | 490 | GNUNET_break (0); |
479 | return; | 491 | return; |
480 | } | 492 | } |
481 | 493 | ||
482 | gtk_tree_model_get (GTK_TREE_MODEL (ctx->meta_liststore), &iter, | 494 | gtk_tree_model_get (GTK_TREE_MODEL (ctx->meta_liststore), |
483 | PUBLISH_METADATA_MC_TYPE, &metatype, -1); | 495 | &iter, |
496 | PUBLISH_METADATA_MC_TYPE, | ||
497 | &metatype, | ||
498 | -1); | ||
484 | if (metatype == EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME) | 499 | if (metatype == EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME) |
485 | { | 500 | { |
486 | /* apply filename rules */ | 501 | /* apply filename rules */ |
@@ -491,17 +506,17 @@ GNUNET_GTK_edit_publication_metadata_tree_view_value_renderer_edited_cb (GtkCell | |||
491 | 506 | ||
492 | /* if user put '/' at the end, remove it' */ | 507 | /* if user put '/' at the end, remove it' */ |
493 | slen = strlen (avalue); | 508 | slen = strlen (avalue); |
494 | while ( (slen > 1) && (avalue[slen - 1] == '\\')) | 509 | while ((slen > 1) && (avalue[slen - 1] == '\\')) |
495 | { | 510 | { |
496 | avalue[slen - 1] = '\0'; | 511 | avalue[slen - 1] = '\0'; |
497 | slen--; | 512 | slen--; |
498 | } | 513 | } |
499 | 514 | ||
500 | /* However, directories must end with '/', so add it */ | 515 | /* However, directories must end with '/', so add it */ |
501 | if ( (new_text[strlen (new_text) - 1] != '/') && | 516 | if ((new_text[strlen (new_text) - 1] != '/') && |
502 | ctx->is_directory == GNUNET_YES) | 517 | ctx->is_directory == GNUNET_YES) |
503 | { | 518 | { |
504 | char * tmp; | 519 | char *tmp; |
505 | 520 | ||
506 | GNUNET_asprintf (&tmp, "%s/", avalue); | 521 | GNUNET_asprintf (&tmp, "%s/", avalue); |
507 | GNUNET_free (avalue); | 522 | GNUNET_free (avalue); |
@@ -519,8 +534,10 @@ GNUNET_GTK_edit_publication_metadata_tree_view_value_renderer_edited_cb (GtkCell | |||
519 | ivalue = new_text; | 534 | ivalue = new_text; |
520 | avalue = NULL; | 535 | avalue = NULL; |
521 | } | 536 | } |
522 | gtk_list_store_set (ctx->meta_liststore, &iter, | 537 | gtk_list_store_set (ctx->meta_liststore, |
523 | PUBLISH_METADATA_MC_VALUE, ivalue, | 538 | &iter, |
539 | PUBLISH_METADATA_MC_VALUE, | ||
540 | ivalue, | ||
524 | -1); | 541 | -1); |
525 | GNUNET_free_non_null (avalue); | 542 | GNUNET_free_non_null (avalue); |
526 | } | 543 | } |
@@ -534,22 +551,25 @@ GNUNET_GTK_edit_publication_metadata_tree_view_value_renderer_edited_cb (GtkCell | |||
534 | * @param user_data the 'struct EditPublicationDialogContext' | 551 | * @param user_data the 'struct EditPublicationDialogContext' |
535 | */ | 552 | */ |
536 | void | 553 | void |
537 | GNUNET_GTK_edit_publication_add_button_clicked_cb (GtkButton * button, | 554 | GNUNET_GTK_edit_publication_add_button_clicked_cb (GtkButton *button, |
538 | gpointer user_data) | 555 | gpointer user_data) |
539 | { | 556 | { |
540 | struct EditPublicationDialogContext *ctx = user_data; | 557 | struct EditPublicationDialogContext *ctx = user_data; |
541 | GtkTreeIter iter; | 558 | GtkTreeIter iter; |
542 | 559 | ||
543 | gtk_list_store_insert_with_values (ctx->meta_liststore, | 560 | gtk_list_store_insert_with_values (ctx->meta_liststore, |
544 | &iter, 0, | 561 | &iter, |
545 | PUBLISH_METADATA_MC_TYPE, 0, | 562 | 0, |
563 | PUBLISH_METADATA_MC_TYPE, | ||
564 | 0, | ||
546 | PUBLISH_METADATA_MC_FORMAT, | 565 | PUBLISH_METADATA_MC_FORMAT, |
547 | EXTRACTOR_METAFORMAT_UTF8, | 566 | EXTRACTOR_METAFORMAT_UTF8, |
548 | PUBLISH_METADATA_MC_TYPE_NAME, | 567 | PUBLISH_METADATA_MC_TYPE_NAME, |
549 | _("Select a type"), | 568 | _ ("Select a type"), |
550 | PUBLISH_METADATA_MC_VALUE, | 569 | PUBLISH_METADATA_MC_VALUE, |
551 | _("Specify a value"), | 570 | _ ("Specify a value"), |
552 | PUBLISH_METADATA_MC_DESCRIPTION, NULL, | 571 | PUBLISH_METADATA_MC_DESCRIPTION, |
572 | NULL, | ||
553 | -1); | 573 | -1); |
554 | } | 574 | } |
555 | 575 | ||
@@ -562,7 +582,7 @@ GNUNET_GTK_edit_publication_add_button_clicked_cb (GtkButton * button, | |||
562 | * @param user_data the 'struct EditPublicationDialogContext' | 582 | * @param user_data the 'struct EditPublicationDialogContext' |
563 | */ | 583 | */ |
564 | void | 584 | void |
565 | GNUNET_GTK_edit_publication_delete_button_clicked_cb (GtkButton * button, | 585 | GNUNET_GTK_edit_publication_delete_button_clicked_cb (GtkButton *button, |
566 | gpointer user_data) | 586 | gpointer user_data) |
567 | { | 587 | { |
568 | struct EditPublicationDialogContext *ctx = user_data; | 588 | struct EditPublicationDialogContext *ctx = user_data; |
@@ -588,8 +608,9 @@ GNUNET_GTK_edit_publication_delete_button_clicked_cb (GtkButton * button, | |||
588 | * @param user_data the 'struct EditPublicationDialogContext' | 608 | * @param user_data the 'struct EditPublicationDialogContext' |
589 | */ | 609 | */ |
590 | void | 610 | void |
591 | GNUNET_GTK_edit_publication_metadata_preview_file_chooser_button_file_set_cb (GtkFileChooserButton * widget, | 611 | GNUNET_GTK_edit_publication_metadata_preview_file_chooser_button_file_set_cb ( |
592 | gpointer user_data) | 612 | GtkFileChooserButton *widget, |
613 | gpointer user_data) | ||
593 | { | 614 | { |
594 | struct EditPublicationDialogContext *ctx = user_data; | 615 | struct EditPublicationDialogContext *ctx = user_data; |
595 | gchar *fn; | 616 | gchar *fn; |
@@ -604,7 +625,6 @@ GNUNET_GTK_edit_publication_metadata_preview_file_chooser_button_file_set_cb (Gt | |||
604 | /* ****************** keyword list editing ******************** */ | 625 | /* ****************** keyword list editing ******************** */ |
605 | 626 | ||
606 | 627 | ||
607 | |||
608 | /** | 628 | /** |
609 | * The user has changed the selection in the keyword tree view. | 629 | * The user has changed the selection in the keyword tree view. |
610 | * Update the sensitivity of the 'delete' button. | 630 | * Update the sensitivity of the 'delete' button. |
@@ -613,15 +633,17 @@ GNUNET_GTK_edit_publication_metadata_preview_file_chooser_button_file_set_cb (Gt | |||
613 | * @param user_data the 'struct EditPublicationDialogContext' | 633 | * @param user_data the 'struct EditPublicationDialogContext' |
614 | */ | 634 | */ |
615 | void | 635 | void |
616 | GNUNET_GTK_edit_publication_keyword_list_treeview_selection_changed_cb (GtkTreeSelection *ts, | 636 | GNUNET_GTK_edit_publication_keyword_list_treeview_selection_changed_cb ( |
617 | gpointer user_data) | 637 | GtkTreeSelection *ts, |
638 | gpointer user_data) | ||
618 | { | 639 | { |
619 | struct EditPublicationDialogContext *ctx = user_data; | 640 | struct EditPublicationDialogContext *ctx = user_data; |
620 | 641 | ||
621 | gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object | 642 | gtk_widget_set_sensitive ( |
622 | (ctx->builder, | 643 | GTK_WIDGET (gtk_builder_get_object ( |
623 | "GNUNET_GTK_edit_publication_keyword_list_del_button")), | 644 | ctx->builder, |
624 | gtk_tree_selection_get_selected (ts, NULL, NULL)); | 645 | "GNUNET_GTK_edit_publication_keyword_list_del_button")), |
646 | gtk_tree_selection_get_selected (ts, NULL, NULL)); | ||
625 | } | 647 | } |
626 | 648 | ||
627 | 649 | ||
@@ -633,16 +655,18 @@ GNUNET_GTK_edit_publication_keyword_list_treeview_selection_changed_cb (GtkTreeS | |||
633 | * @param user_data the 'struct EditPublicationDialogContext' | 655 | * @param user_data the 'struct EditPublicationDialogContext' |
634 | */ | 656 | */ |
635 | void | 657 | void |
636 | GNUNET_GTK_edit_publication_keyword_entry_changed_cb (GtkEditable * editable, | 658 | GNUNET_GTK_edit_publication_keyword_entry_changed_cb (GtkEditable *editable, |
637 | gpointer user_data) | 659 | gpointer user_data) |
638 | { | 660 | { |
639 | struct EditPublicationDialogContext *ctx = user_data; | 661 | struct EditPublicationDialogContext *ctx = user_data; |
640 | const char *keyword; | 662 | const char *keyword; |
641 | 663 | ||
642 | keyword = gtk_entry_get_text (ctx->keyword_entry); | 664 | keyword = gtk_entry_get_text (ctx->keyword_entry); |
643 | gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (ctx->builder, | 665 | gtk_widget_set_sensitive ( |
644 | "GNUNET_GTK_edit_publication_keyword_list_add_button")), | 666 | GTK_WIDGET (gtk_builder_get_object ( |
645 | (strlen (keyword) > 0) ? TRUE : FALSE); | 667 | ctx->builder, |
668 | "GNUNET_GTK_edit_publication_keyword_list_add_button")), | ||
669 | (strlen (keyword) > 0) ? TRUE : FALSE); | ||
646 | } | 670 | } |
647 | 671 | ||
648 | 672 | ||
@@ -658,9 +682,10 @@ update_confirm_sensitivity (struct EditPublicationDialogContext *ctx) | |||
658 | { | 682 | { |
659 | GtkTreeIter iter; | 683 | GtkTreeIter iter; |
660 | 684 | ||
661 | if ( (! ctx->allow_no_keywords) && | 685 | if ((! ctx->allow_no_keywords) && |
662 | (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ctx->keywords_liststore), | 686 | (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL ( |
663 | &iter)) ) | 687 | ctx->keywords_liststore), |
688 | &iter))) | ||
664 | gtk_widget_set_sensitive (ctx->confirm_button, FALSE); | 689 | gtk_widget_set_sensitive (ctx->confirm_button, FALSE); |
665 | else | 690 | else |
666 | gtk_widget_set_sensitive (ctx->confirm_button, TRUE); | 691 | gtk_widget_set_sensitive (ctx->confirm_button, TRUE); |
@@ -675,9 +700,9 @@ update_confirm_sensitivity (struct EditPublicationDialogContext *ctx) | |||
675 | * @param user_data the 'struct EditPublicationDialogContext' | 700 | * @param user_data the 'struct EditPublicationDialogContext' |
676 | */ | 701 | */ |
677 | void | 702 | void |
678 | GNUNET_GTK_edit_publication_keyword_list_del_button_clicked_cb (GtkButton * | 703 | GNUNET_GTK_edit_publication_keyword_list_del_button_clicked_cb ( |
679 | button, | 704 | GtkButton *button, |
680 | gpointer user_data) | 705 | gpointer user_data) |
681 | { | 706 | { |
682 | struct EditPublicationDialogContext *ctx = user_data; | 707 | struct EditPublicationDialogContext *ctx = user_data; |
683 | GtkTreeIter iter; | 708 | GtkTreeIter iter; |
@@ -705,9 +730,9 @@ GNUNET_GTK_edit_publication_keyword_list_del_button_clicked_cb (GtkButton * | |||
705 | * @param user_data the 'struct EditPublicationDialogContext' | 730 | * @param user_data the 'struct EditPublicationDialogContext' |
706 | */ | 731 | */ |
707 | void | 732 | void |
708 | GNUNET_GTK_edit_publication_keyword_list_add_button_clicked_cb (GtkButton * | 733 | GNUNET_GTK_edit_publication_keyword_list_add_button_clicked_cb ( |
709 | button, | 734 | GtkButton *button, |
710 | gpointer user_data) | 735 | gpointer user_data) |
711 | { | 736 | { |
712 | struct EditPublicationDialogContext *ctx = user_data; | 737 | struct EditPublicationDialogContext *ctx = user_data; |
713 | const char *keyword; | 738 | const char *keyword; |
@@ -717,9 +742,12 @@ GNUNET_GTK_edit_publication_keyword_list_add_button_clicked_cb (GtkButton * | |||
717 | if (strlen (keyword) == 0) | 742 | if (strlen (keyword) == 0) |
718 | return; | 743 | return; |
719 | gtk_list_store_insert_with_values (ctx->keywords_liststore, | 744 | gtk_list_store_insert_with_values (ctx->keywords_liststore, |
720 | &iter, G_MAXINT, | 745 | &iter, |
721 | PUBLISH_TYPES_MC_KEYWORD, keyword, | 746 | G_MAXINT, |
722 | PUBLISH_TYPES_MC_ADDED, TRUE, | 747 | PUBLISH_TYPES_MC_KEYWORD, |
748 | keyword, | ||
749 | PUBLISH_TYPES_MC_ADDED, | ||
750 | TRUE, | ||
723 | -1); | 751 | -1); |
724 | gtk_entry_set_text (ctx->keyword_entry, ""); | 752 | gtk_entry_set_text (ctx->keyword_entry, ""); |
725 | update_confirm_sensitivity (ctx); | 753 | update_confirm_sensitivity (ctx); |
@@ -736,11 +764,10 @@ GNUNET_GTK_edit_publication_keyword_list_add_button_clicked_cb (GtkButton * | |||
736 | * @return TRUE if we handled the event, FALSE if not | 764 | * @return TRUE if we handled the event, FALSE if not |
737 | */ | 765 | */ |
738 | gboolean | 766 | gboolean |
739 | GNUNET_GTK_edit_publication_keyword_entry_key_press_event_cb (GtkWidget * | 767 | GNUNET_GTK_edit_publication_keyword_entry_key_press_event_cb ( |
740 | widget, | 768 | GtkWidget *widget, |
741 | GdkEventKey * | 769 | GdkEventKey *event, |
742 | event, | 770 | gpointer user_data) |
743 | gpointer user_data) | ||
744 | { | 771 | { |
745 | struct EditPublicationDialogContext *ctx = user_data; | 772 | struct EditPublicationDialogContext *ctx = user_data; |
746 | 773 | ||
@@ -751,7 +778,6 @@ GNUNET_GTK_edit_publication_keyword_entry_key_press_event_cb (GtkWidget * | |||
751 | } | 778 | } |
752 | 779 | ||
753 | 780 | ||
754 | |||
755 | /* ****************** handlers for closing the dialog ******************** */ | 781 | /* ****************** handlers for closing the dialog ******************** */ |
756 | 782 | ||
757 | 783 | ||
@@ -762,7 +788,7 @@ GNUNET_GTK_edit_publication_keyword_entry_key_press_event_cb (GtkWidget * | |||
762 | * @param user_data the 'struct EditPublicationDialogContext' | 788 | * @param user_data the 'struct EditPublicationDialogContext' |
763 | */ | 789 | */ |
764 | void | 790 | void |
765 | GNUNET_GTK_edit_publication_cancel_button_clicked_cb (GtkButton * button, | 791 | GNUNET_GTK_edit_publication_cancel_button_clicked_cb (GtkButton *button, |
766 | gpointer user_data) | 792 | gpointer user_data) |
767 | { | 793 | { |
768 | struct EditPublicationDialogContext *ctx = user_data; | 794 | struct EditPublicationDialogContext *ctx = user_data; |
@@ -781,8 +807,8 @@ GNUNET_GTK_edit_publication_cancel_button_clicked_cb (GtkButton * button, | |||
781 | * @return TRUE (always) | 807 | * @return TRUE (always) |
782 | */ | 808 | */ |
783 | gboolean | 809 | gboolean |
784 | GNUNET_GTK_edit_publication_window_delete_event_cb (GtkWidget * widget, | 810 | GNUNET_GTK_edit_publication_window_delete_event_cb (GtkWidget *widget, |
785 | GdkEvent * event, | 811 | GdkEvent *event, |
786 | gpointer user_data) | 812 | gpointer user_data) |
787 | { | 813 | { |
788 | struct EditPublicationDialogContext *ctx = user_data; | 814 | struct EditPublicationDialogContext *ctx = user_data; |
@@ -819,10 +845,12 @@ GNUNET_GTK_edit_publication_window_delete_event_cb (GtkWidget * widget, | |||
819 | * @return 0 to continue extracting | 845 | * @return 0 to continue extracting |
820 | */ | 846 | */ |
821 | static int | 847 | static int |
822 | preserve_meta_items (void *cls, const char *plugin_name, | 848 | preserve_meta_items (void *cls, |
849 | const char *plugin_name, | ||
823 | enum EXTRACTOR_MetaType type, | 850 | enum EXTRACTOR_MetaType type, |
824 | enum EXTRACTOR_MetaFormat format, | 851 | enum EXTRACTOR_MetaFormat format, |
825 | const char *data_mime_type, const char *data, | 852 | const char *data_mime_type, |
853 | const char *data, | ||
826 | size_t data_len) | 854 | size_t data_len) |
827 | { | 855 | { |
828 | struct EditPublicationDialogContext *ctx = cls; | 856 | struct EditPublicationDialogContext *ctx = cls; |
@@ -837,14 +865,20 @@ preserve_meta_items (void *cls, const char *plugin_name, | |||
837 | { | 865 | { |
838 | case EXTRACTOR_METAFORMAT_UTF8: | 866 | case EXTRACTOR_METAFORMAT_UTF8: |
839 | case EXTRACTOR_METAFORMAT_C_STRING: | 867 | case EXTRACTOR_METAFORMAT_C_STRING: |
840 | if (TRUE == gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ctx->meta_liststore), &iter)) | 868 | if (TRUE == |
869 | gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ctx->meta_liststore), | ||
870 | &iter)) | ||
841 | { | 871 | { |
842 | do | 872 | do |
843 | { | 873 | { |
844 | gtk_tree_model_get (GTK_TREE_MODEL (ctx->meta_liststore), &iter, | 874 | gtk_tree_model_get (GTK_TREE_MODEL (ctx->meta_liststore), |
845 | PUBLISH_METADATA_MC_TYPE, &ntype, | 875 | &iter, |
846 | PUBLISH_METADATA_MC_FORMAT, &nformat, | 876 | PUBLISH_METADATA_MC_TYPE, |
847 | PUBLISH_METADATA_MC_VALUE, &value, | 877 | &ntype, |
878 | PUBLISH_METADATA_MC_FORMAT, | ||
879 | &nformat, | ||
880 | PUBLISH_METADATA_MC_VALUE, | ||
881 | &value, | ||
848 | -1); | 882 | -1); |
849 | if ((ntype == type) && (nformat == format) && | 883 | if ((ntype == type) && (nformat == format) && |
850 | (0 == strcmp (value, data))) | 884 | (0 == strcmp (value, data))) |
@@ -855,8 +889,9 @@ preserve_meta_items (void *cls, const char *plugin_name, | |||
855 | break; | 889 | break; |
856 | } | 890 | } |
857 | g_free (value); | 891 | g_free (value); |
858 | } | 892 | } while ( |
859 | while (TRUE == gtk_tree_model_iter_next (GTK_TREE_MODEL (ctx->meta_liststore), &iter)); | 893 | TRUE == |
894 | gtk_tree_model_iter_next (GTK_TREE_MODEL (ctx->meta_liststore), &iter)); | ||
860 | } | 895 | } |
861 | break; | 896 | break; |
862 | case EXTRACTOR_METAFORMAT_UNKNOWN: | 897 | case EXTRACTOR_METAFORMAT_UNKNOWN: |
@@ -871,9 +906,13 @@ preserve_meta_items (void *cls, const char *plugin_name, | |||
871 | } | 906 | } |
872 | if (GNUNET_YES == keep) | 907 | if (GNUNET_YES == keep) |
873 | GNUNET_break (GNUNET_OK == | 908 | GNUNET_break (GNUNET_OK == |
874 | GNUNET_CONTAINER_meta_data_insert (ctx->md, plugin_name, type, | 909 | GNUNET_CONTAINER_meta_data_insert (ctx->md, |
875 | format, data_mime_type, | 910 | plugin_name, |
876 | data, data_len)); | 911 | type, |
912 | format, | ||
913 | data_mime_type, | ||
914 | data, | ||
915 | data_len)); | ||
877 | return 0; | 916 | return 0; |
878 | } | 917 | } |
879 | 918 | ||
@@ -898,17 +937,17 @@ preserve_meta_items (void *cls, const char *plugin_name, | |||
898 | */ | 937 | */ |
899 | static int | 938 | static int |
900 | le_callback (void *cls, | 939 | le_callback (void *cls, |
901 | const char *plugin_name, | 940 | const char *plugin_name, |
902 | enum EXTRACTOR_MetaType type, | 941 | enum EXTRACTOR_MetaType type, |
903 | enum EXTRACTOR_MetaFormat format, | 942 | enum EXTRACTOR_MetaFormat format, |
904 | const char *data_mime_type, | 943 | const char *data_mime_type, |
905 | const char *data, | 944 | const char *data, |
906 | size_t data_len) | 945 | size_t data_len) |
907 | { | 946 | { |
908 | char **ret = cls; | 947 | char **ret = cls; |
909 | 948 | ||
910 | if ( (EXTRACTOR_METATYPE_MIMETYPE == type) && | 949 | if ((EXTRACTOR_METATYPE_MIMETYPE == type) && |
911 | (EXTRACTOR_METAFORMAT_BINARY != format) ) | 950 | (EXTRACTOR_METAFORMAT_BINARY != format)) |
912 | { | 951 | { |
913 | *ret = GNUNET_strdup (data); | 952 | *ret = GNUNET_strdup (data); |
914 | return 1; | 953 | return 1; |
@@ -925,24 +964,18 @@ le_callback (void *cls, | |||
925 | * @param data_size number of bytes in 'data' | 964 | * @param data_size number of bytes in 'data' |
926 | */ | 965 | */ |
927 | static char * | 966 | static char * |
928 | get_mime_type (const void *data, | 967 | get_mime_type (const void *data, gsize data_size) |
929 | gsize data_size) | ||
930 | { | 968 | { |
931 | #if HAVE_EXTRACTOR | 969 | #if HAVE_EXTRACTOR |
932 | char *ret; | 970 | char *ret; |
933 | struct EXTRACTOR_PluginList *pl; | 971 | struct EXTRACTOR_PluginList *pl; |
934 | 972 | ||
935 | pl = EXTRACTOR_plugin_add (NULL, | 973 | pl = |
936 | "mime", | 974 | EXTRACTOR_plugin_add (NULL, "mime", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); |
937 | NULL, | ||
938 | EXTRACTOR_OPTION_DEFAULT_POLICY); | ||
939 | if (NULL == pl) | 975 | if (NULL == pl) |
940 | return NULL; | 976 | return NULL; |
941 | ret = NULL; | 977 | ret = NULL; |
942 | EXTRACTOR_extract (pl, | 978 | EXTRACTOR_extract (pl, NULL, data, data_size, &le_callback, &ret); |
943 | NULL, | ||
944 | data, data_size, | ||
945 | &le_callback, &ret); | ||
946 | EXTRACTOR_plugin_remove_all (pl); | 979 | EXTRACTOR_plugin_remove_all (pl); |
947 | return ret; | 980 | return ret; |
948 | #else | 981 | #else |
@@ -966,11 +999,13 @@ get_mime_type (const void *data, | |||
966 | * @return #GNUNET_SYSERR (aborts after first call) | 999 | * @return #GNUNET_SYSERR (aborts after first call) |
967 | */ | 1000 | */ |
968 | static int | 1001 | static int |
969 | file_information_update (void *cls, struct GNUNET_FS_FileInformation *fi, | 1002 | file_information_update (void *cls, |
1003 | struct GNUNET_FS_FileInformation *fi, | ||
970 | uint64_t length, | 1004 | uint64_t length, |
971 | struct GNUNET_CONTAINER_MetaData *meta, | 1005 | struct GNUNET_CONTAINER_MetaData *meta, |
972 | struct GNUNET_FS_Uri **uri, | 1006 | struct GNUNET_FS_Uri **uri, |
973 | struct GNUNET_FS_BlockOptions *bo, int *do_index, | 1007 | struct GNUNET_FS_BlockOptions *bo, |
1008 | int *do_index, | ||
974 | void **client_info) | 1009 | void **client_info) |
975 | { | 1010 | { |
976 | struct EditPublicationDialogContext *ctx = cls; | 1011 | struct EditPublicationDialogContext *ctx = cls; |
@@ -979,8 +1014,9 @@ file_information_update (void *cls, struct GNUNET_FS_FileInformation *fi, | |||
979 | 1014 | ||
980 | /* gather publishing options */ | 1015 | /* gather publishing options */ |
981 | *do_index = gtk_toggle_button_get_active (ctx->index_checkbutton); | 1016 | *do_index = gtk_toggle_button_get_active (ctx->index_checkbutton); |
982 | GNUNET_break (GNUNET_GTK_get_selected_anonymity_combo_level (ctx->anonymity_combo, | 1017 | GNUNET_break ( |
983 | &bo->anonymity_level)); | 1018 | GNUNET_GTK_get_selected_anonymity_combo_level (ctx->anonymity_combo, |
1019 | &bo->anonymity_level)); | ||
984 | bo->content_priority = gtk_spin_button_get_value (ctx->priority_spin); | 1020 | bo->content_priority = gtk_spin_button_get_value (ctx->priority_spin); |
985 | bo->replication_level = gtk_spin_button_get_value (ctx->replication_spin); | 1021 | bo->replication_level = gtk_spin_button_get_value (ctx->replication_spin); |
986 | year = gtk_spin_button_get_value (ctx->expiration_year_spin); | 1022 | year = gtk_spin_button_get_value (ctx->expiration_year_spin); |
@@ -990,29 +1026,30 @@ file_information_update (void *cls, struct GNUNET_FS_FileInformation *fi, | |||
990 | if (NULL != (*uri)) | 1026 | if (NULL != (*uri)) |
991 | GNUNET_FS_uri_destroy (*uri); | 1027 | GNUNET_FS_uri_destroy (*uri); |
992 | *uri = NULL; | 1028 | *uri = NULL; |
993 | if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ctx->keywords_liststore), &iter)) | 1029 | if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ctx->keywords_liststore), |
1030 | &iter)) | ||
994 | { | 1031 | { |
995 | do | 1032 | do |
996 | { | 1033 | { |
997 | gchar *value; | 1034 | gchar *value; |
998 | 1035 | ||
999 | gtk_tree_model_get (GTK_TREE_MODEL (ctx->keywords_liststore), &iter, | 1036 | gtk_tree_model_get (GTK_TREE_MODEL (ctx->keywords_liststore), |
1000 | PUBLISH_TYPES_MC_KEYWORD, &value, | 1037 | &iter, |
1038 | PUBLISH_TYPES_MC_KEYWORD, | ||
1039 | &value, | ||
1001 | -1); | 1040 | -1); |
1002 | if (NULL == *uri) | 1041 | if (NULL == *uri) |
1003 | *uri = GNUNET_FS_uri_ksk_create_from_args (1, (const char **) &value); | 1042 | *uri = GNUNET_FS_uri_ksk_create_from_args (1, (const char **) &value); |
1004 | else | 1043 | else |
1005 | GNUNET_FS_uri_ksk_add_keyword (*uri, value, GNUNET_NO); | 1044 | GNUNET_FS_uri_ksk_add_keyword (*uri, value, GNUNET_NO); |
1006 | g_free (value); | 1045 | g_free (value); |
1007 | } | 1046 | } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (ctx->keywords_liststore), |
1008 | while (gtk_tree_model_iter_next (GTK_TREE_MODEL (ctx->keywords_liststore), &iter)); | 1047 | &iter)); |
1009 | } | 1048 | } |
1010 | 1049 | ||
1011 | /* update meta data; first, we copy the unchanged values from the original meta data */ | 1050 | /* update meta data; first, we copy the unchanged values from the original meta data */ |
1012 | ctx->md = GNUNET_CONTAINER_meta_data_create (); | 1051 | ctx->md = GNUNET_CONTAINER_meta_data_create (); |
1013 | GNUNET_CONTAINER_meta_data_iterate (meta, | 1052 | GNUNET_CONTAINER_meta_data_iterate (meta, &preserve_meta_items, ctx); |
1014 | &preserve_meta_items, | ||
1015 | ctx); | ||
1016 | /* clear original meta data */ | 1053 | /* clear original meta data */ |
1017 | GNUNET_CONTAINER_meta_data_clear (meta); | 1054 | GNUNET_CONTAINER_meta_data_clear (meta); |
1018 | /* add all of the 'preserved' values */ | 1055 | /* add all of the 'preserved' values */ |
@@ -1021,7 +1058,8 @@ file_information_update (void *cls, struct GNUNET_FS_FileInformation *fi, | |||
1021 | ctx->md = NULL; | 1058 | ctx->md = NULL; |
1022 | /* now add all of the values from the model; adding will simply do | 1059 | /* now add all of the values from the model; adding will simply do |
1023 | nothing for values that are already in the set because they were preserved */ | 1060 | nothing for values that are already in the set because they were preserved */ |
1024 | if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ctx->meta_liststore), &iter)) | 1061 | if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ctx->meta_liststore), |
1062 | &iter)) | ||
1025 | { | 1063 | { |
1026 | do | 1064 | do |
1027 | { | 1065 | { |
@@ -1029,20 +1067,28 @@ file_information_update (void *cls, struct GNUNET_FS_FileInformation *fi, | |||
1029 | guint nformat; | 1067 | guint nformat; |
1030 | gchar *value; | 1068 | gchar *value; |
1031 | 1069 | ||
1032 | gtk_tree_model_get (GTK_TREE_MODEL (ctx->meta_liststore), &iter, | 1070 | gtk_tree_model_get (GTK_TREE_MODEL (ctx->meta_liststore), |
1033 | PUBLISH_METADATA_MC_TYPE, &ntype, | 1071 | &iter, |
1034 | PUBLISH_METADATA_MC_FORMAT, &nformat, | 1072 | PUBLISH_METADATA_MC_TYPE, |
1035 | PUBLISH_METADATA_MC_VALUE, &value, | 1073 | &ntype, |
1074 | PUBLISH_METADATA_MC_FORMAT, | ||
1075 | &nformat, | ||
1076 | PUBLISH_METADATA_MC_VALUE, | ||
1077 | &value, | ||
1036 | -1); | 1078 | -1); |
1037 | if (ntype > 0) | 1079 | if (ntype > 0) |
1038 | { | 1080 | { |
1039 | GNUNET_CONTAINER_meta_data_insert (meta, "<user>", ntype, nformat, | 1081 | GNUNET_CONTAINER_meta_data_insert (meta, |
1040 | "text/plain", value, | 1082 | "<user>", |
1083 | ntype, | ||
1084 | nformat, | ||
1085 | "text/plain", | ||
1086 | value, | ||
1041 | strlen (value) + 1); | 1087 | strlen (value) + 1); |
1042 | } | 1088 | } |
1043 | g_free (value); | 1089 | g_free (value); |
1044 | } | 1090 | } while ( |
1045 | while (gtk_tree_model_iter_next (GTK_TREE_MODEL (ctx->meta_liststore), &iter)); | 1091 | gtk_tree_model_iter_next (GTK_TREE_MODEL (ctx->meta_liststore), &iter)); |
1046 | } | 1092 | } |
1047 | 1093 | ||
1048 | /* finally, if we got a new preview, add it as well */ | 1094 | /* finally, if we got a new preview, add it as well */ |
@@ -1054,15 +1100,16 @@ file_information_update (void *cls, struct GNUNET_FS_FileInformation *fi, | |||
1054 | char *mime; | 1100 | char *mime; |
1055 | GFile *f; | 1101 | GFile *f; |
1056 | 1102 | ||
1057 | fn = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER | 1103 | fn = |
1058 | (gtk_builder_get_object | 1104 | gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (gtk_builder_get_object ( |
1059 | (ctx->builder, | 1105 | ctx->builder, |
1060 | "GNUNET_GTK_edit_publication_metadata_preview_file_chooser_button"))); | 1106 | "GNUNET_GTK_edit_publication_metadata_preview_file_chooser_button"))); |
1061 | f = g_file_new_for_path (fn); | 1107 | f = g_file_new_for_path (fn); |
1062 | if (! g_file_load_contents (f, NULL, &data, &data_size, NULL, NULL)) | 1108 | if (! g_file_load_contents (f, NULL, &data, &data_size, NULL, NULL)) |
1063 | { | 1109 | { |
1064 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1110 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1065 | _("Could not load preview `%s' into memory\n"), fn); | 1111 | _ ("Could not load preview `%s' into memory\n"), |
1112 | fn); | ||
1066 | } | 1113 | } |
1067 | else | 1114 | else |
1068 | { | 1115 | { |
@@ -1070,29 +1117,36 @@ file_information_update (void *cls, struct GNUNET_FS_FileInformation *fi, | |||
1070 | #if LINUX | 1117 | #if LINUX |
1071 | if (NULL == mime) | 1118 | if (NULL == mime) |
1072 | { | 1119 | { |
1073 | /* fall back to Gtk mime-detection; this only works on GNU */ | 1120 | /* fall back to Gtk mime-detection; this only works on GNU */ |
1074 | GFileInfo *finfo; | 1121 | GFileInfo *finfo; |
1075 | const char *gmime; | 1122 | const char *gmime; |
1076 | 1123 | ||
1077 | finfo = g_file_query_info (f, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, | 1124 | finfo = g_file_query_info (f, |
1078 | 0, NULL, NULL); | 1125 | G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, |
1079 | gmime = g_file_info_get_attribute_string (finfo, | 1126 | 0, |
1080 | G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE); | 1127 | NULL, |
1081 | if (NULL != gmime) | 1128 | NULL); |
1082 | mime = GNUNET_strdup (gmime); | 1129 | gmime = |
1083 | g_object_unref (finfo); | 1130 | g_file_info_get_attribute_string (finfo, |
1131 | G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE); | ||
1132 | if (NULL != gmime) | ||
1133 | mime = GNUNET_strdup (gmime); | ||
1134 | g_object_unref (finfo); | ||
1084 | } | 1135 | } |
1085 | #endif | 1136 | #endif |
1086 | GNUNET_CONTAINER_meta_data_insert (meta, "<user>", | 1137 | GNUNET_CONTAINER_meta_data_insert (meta, |
1138 | "<user>", | ||
1087 | EXTRACTOR_METATYPE_THUMBNAIL, | 1139 | EXTRACTOR_METATYPE_THUMBNAIL, |
1088 | EXTRACTOR_METAFORMAT_BINARY, mime, | 1140 | EXTRACTOR_METAFORMAT_BINARY, |
1089 | data, data_size); | 1141 | mime, |
1142 | data, | ||
1143 | data_size); | ||
1090 | GNUNET_free_non_null (mime); | 1144 | GNUNET_free_non_null (mime); |
1091 | } | 1145 | } |
1092 | g_object_unref (f); | 1146 | g_object_unref (f); |
1093 | g_free (fn); | 1147 | g_free (fn); |
1094 | } | 1148 | } |
1095 | return GNUNET_SYSERR; /* only visit top-level item */ | 1149 | return GNUNET_SYSERR; /* only visit top-level item */ |
1096 | } | 1150 | } |
1097 | 1151 | ||
1098 | 1152 | ||
@@ -1105,29 +1159,23 @@ file_information_update (void *cls, struct GNUNET_FS_FileInformation *fi, | |||
1105 | * @param user_data the 'struct EditPublicationDialogContext' | 1159 | * @param user_data the 'struct EditPublicationDialogContext' |
1106 | */ | 1160 | */ |
1107 | void | 1161 | void |
1108 | GNUNET_GTK_edit_publication_confirm_button_clicked_cb (GtkButton * button, | 1162 | GNUNET_GTK_edit_publication_confirm_button_clicked_cb (GtkButton *button, |
1109 | gpointer user_data) | 1163 | gpointer user_data) |
1110 | { | 1164 | { |
1111 | struct EditPublicationDialogContext *ctx = user_data; | 1165 | struct EditPublicationDialogContext *ctx = user_data; |
1112 | 1166 | ||
1113 | /* push back changes to file-information */ | 1167 | /* push back changes to file-information */ |
1114 | GNUNET_FS_file_information_inspect (ctx->fip, | 1168 | GNUNET_FS_file_information_inspect (ctx->fip, &file_information_update, ctx); |
1115 | &file_information_update, | ||
1116 | ctx); | ||
1117 | /* call our continuation */ | 1169 | /* call our continuation */ |
1118 | ctx->cb (ctx->cb_cls, | 1170 | ctx->cb (ctx->cb_cls, GTK_RESPONSE_OK, gtk_entry_get_text (ctx->root_entry)); |
1119 | GTK_RESPONSE_OK, | ||
1120 | gtk_entry_get_text (ctx->root_entry)); | ||
1121 | /* free resources from the edit dialog */ | 1171 | /* free resources from the edit dialog */ |
1122 | free_edit_dialog_context (ctx); | 1172 | free_edit_dialog_context (ctx); |
1123 | } | 1173 | } |
1124 | 1174 | ||
1125 | 1175 | ||
1126 | |||
1127 | /* ****************** code for initialization of the dialog ******************** */ | 1176 | /* ****************** code for initialization of the dialog ******************** */ |
1128 | 1177 | ||
1129 | 1178 | ||
1130 | |||
1131 | /** | 1179 | /** |
1132 | * Add each of the keywords to the keyword list store. | 1180 | * Add each of the keywords to the keyword list store. |
1133 | * | 1181 | * |
@@ -1143,9 +1191,13 @@ add_keyword (void *cls, const char *keyword, int is_mandatory) | |||
1143 | GtkTreeIter iter; | 1191 | GtkTreeIter iter; |
1144 | 1192 | ||
1145 | ls = GTK_LIST_STORE (cls); | 1193 | ls = GTK_LIST_STORE (cls); |
1146 | gtk_list_store_insert_with_values (ls, &iter, G_MAXINT, | 1194 | gtk_list_store_insert_with_values (ls, |
1147 | PUBLISH_TYPES_MC_KEYWORD, keyword, | 1195 | &iter, |
1148 | PUBLISH_TYPES_MC_ADDED, FALSE, | 1196 | G_MAXINT, |
1197 | PUBLISH_TYPES_MC_KEYWORD, | ||
1198 | keyword, | ||
1199 | PUBLISH_TYPES_MC_ADDED, | ||
1200 | FALSE, | ||
1149 | -1); | 1201 | -1); |
1150 | return GNUNET_OK; | 1202 | return GNUNET_OK; |
1151 | } | 1203 | } |
@@ -1169,19 +1221,18 @@ add_keyword (void *cls, const char *keyword, int is_mandatory) | |||
1169 | */ | 1221 | */ |
1170 | static int | 1222 | static int |
1171 | set_window_title_to_filename (void *cls, | 1223 | set_window_title_to_filename (void *cls, |
1172 | const char *plugin_name, | 1224 | const char *plugin_name, |
1173 | enum EXTRACTOR_MetaType type, | 1225 | enum EXTRACTOR_MetaType type, |
1174 | enum EXTRACTOR_MetaFormat format, | 1226 | enum EXTRACTOR_MetaFormat format, |
1175 | const char *data_mime_type, | 1227 | const char *data_mime_type, |
1176 | const char *data, | 1228 | const char *data, |
1177 | size_t data_len) | 1229 | size_t data_len) |
1178 | { | 1230 | { |
1179 | char *utf8; | 1231 | char *utf8; |
1180 | 1232 | ||
1181 | if (EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME != type) | 1233 | if (EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME != type) |
1182 | return 0; | 1234 | return 0; |
1183 | utf8 = GNUNET_FS_GTK_dubious_meta_to_utf8 (format, | 1235 | utf8 = GNUNET_FS_GTK_dubious_meta_to_utf8 (format, data, data_len); |
1184 | data, data_len); | ||
1185 | if (NULL == utf8) | 1236 | if (NULL == utf8) |
1186 | return 0; | 1237 | return 0; |
1187 | gtk_window_set_title (GTK_WINDOW (cls), utf8); | 1238 | gtk_window_set_title (GTK_WINDOW (cls), utf8); |
@@ -1205,12 +1256,13 @@ set_window_title_to_filename (void *cls, | |||
1205 | */ | 1256 | */ |
1206 | static int | 1257 | static int |
1207 | file_information_import (void *cls, | 1258 | file_information_import (void *cls, |
1208 | struct GNUNET_FS_FileInformation *fi, | 1259 | struct GNUNET_FS_FileInformation *fi, |
1209 | uint64_t length, | 1260 | uint64_t length, |
1210 | struct GNUNET_CONTAINER_MetaData *meta, | 1261 | struct GNUNET_CONTAINER_MetaData *meta, |
1211 | struct GNUNET_FS_Uri **uri, | 1262 | struct GNUNET_FS_Uri **uri, |
1212 | struct GNUNET_FS_BlockOptions *bo, int *do_index, | 1263 | struct GNUNET_FS_BlockOptions *bo, |
1213 | void **client_info) | 1264 | int *do_index, |
1265 | void **client_info) | ||
1214 | { | 1266 | { |
1215 | struct EditPublicationDialogContext *ctx = cls; | 1267 | struct EditPublicationDialogContext *ctx = cls; |
1216 | GdkPixbuf *pixbuf; | 1268 | GdkPixbuf *pixbuf; |
@@ -1220,7 +1272,7 @@ file_information_import (void *cls, | |||
1220 | year = (int) GNUNET_TIME_time_to_year (bo->expiration_time); | 1272 | year = (int) GNUNET_TIME_time_to_year (bo->expiration_time); |
1221 | gtk_spin_button_set_value (ctx->expiration_year_spin, year); | 1273 | gtk_spin_button_set_value (ctx->expiration_year_spin, year); |
1222 | GNUNET_GTK_select_anonymity_combo_level (ctx->anonymity_combo, | 1274 | GNUNET_GTK_select_anonymity_combo_level (ctx->anonymity_combo, |
1223 | bo->anonymity_level); | 1275 | bo->anonymity_level); |
1224 | gtk_spin_button_set_value (ctx->priority_spin, bo->content_priority); | 1276 | gtk_spin_button_set_value (ctx->priority_spin, bo->content_priority); |
1225 | gtk_spin_button_set_value (ctx->replication_spin, bo->replication_level); | 1277 | gtk_spin_button_set_value (ctx->replication_spin, bo->replication_level); |
1226 | gtk_toggle_button_set_active (ctx->index_checkbutton, *do_index); | 1278 | gtk_toggle_button_set_active (ctx->index_checkbutton, *do_index); |
@@ -1228,7 +1280,9 @@ file_information_import (void *cls, | |||
1228 | 1280 | ||
1229 | /* import keywords */ | 1281 | /* import keywords */ |
1230 | if (NULL != *uri) | 1282 | if (NULL != *uri) |
1231 | GNUNET_FS_uri_ksk_get_keywords (*uri, &add_keyword, ctx->keywords_liststore); | 1283 | GNUNET_FS_uri_ksk_get_keywords (*uri, |
1284 | &add_keyword, | ||
1285 | ctx->keywords_liststore); | ||
1232 | 1286 | ||
1233 | /* import meta data */ | 1287 | /* import meta data */ |
1234 | if (NULL != meta) | 1288 | if (NULL != meta) |
@@ -1244,11 +1298,11 @@ file_information_import (void *cls, | |||
1244 | } | 1298 | } |
1245 | 1299 | ||
1246 | /* Also update window title based on filename */ | 1300 | /* Also update window title based on filename */ |
1247 | gtk_window_set_title (ctx->edit_publication_window, _("<unnamed>")); | 1301 | gtk_window_set_title (ctx->edit_publication_window, _ ("<unnamed>")); |
1248 | GNUNET_CONTAINER_meta_data_iterate (meta, | 1302 | GNUNET_CONTAINER_meta_data_iterate (meta, |
1249 | &set_window_title_to_filename, | 1303 | &set_window_title_to_filename, |
1250 | ctx->edit_publication_window); | 1304 | ctx->edit_publication_window); |
1251 | return GNUNET_SYSERR; /* only visit top-level item */ | 1305 | return GNUNET_SYSERR; /* only visit top-level item */ |
1252 | } | 1306 | } |
1253 | 1307 | ||
1254 | 1308 | ||
@@ -1264,7 +1318,7 @@ file_information_import (void *cls, | |||
1264 | * @param cb_cls closure for @a cb | 1318 | * @param cb_cls closure for @a cb |
1265 | */ | 1319 | */ |
1266 | void | 1320 | void |
1267 | GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, | 1321 | GNUNET_FS_GTK_edit_publish_dialog (GtkWindow *parent, |
1268 | struct GNUNET_FS_FileInformation *fip, | 1322 | struct GNUNET_FS_FileInformation *fip, |
1269 | int is_namespace_edit, | 1323 | int is_namespace_edit, |
1270 | GNUNET_FS_GTK_EditPublishDialogCallback cb, | 1324 | GNUNET_FS_GTK_EditPublishDialogCallback cb, |
@@ -1285,7 +1339,8 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, | |||
1285 | ctx->cb = cb; | 1339 | ctx->cb = cb; |
1286 | ctx->cb_cls = cb_cls; | 1340 | ctx->cb_cls = cb_cls; |
1287 | ctx->meta_combo_selected_type_id = -1; | 1341 | ctx->meta_combo_selected_type_id = -1; |
1288 | ctx->builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_edit_publication.glade", ctx); | 1342 | ctx->builder = |
1343 | GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_edit_publication.glade", ctx); | ||
1289 | 1344 | ||
1290 | if (NULL == ctx->builder) | 1345 | if (NULL == ctx->builder) |
1291 | { | 1346 | { |
@@ -1294,69 +1349,70 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, | |||
1294 | } | 1349 | } |
1295 | 1350 | ||
1296 | /* obtain various widgets for use later */ | 1351 | /* obtain various widgets for use later */ |
1297 | ctx->pubtypes_liststore = | 1352 | ctx->pubtypes_liststore = GTK_LIST_STORE ( |
1298 | GTK_LIST_STORE (gtk_builder_get_object | 1353 | gtk_builder_get_object (ctx->builder, |
1299 | (ctx->builder, "GNUNET_GTK_publication_types_liststore")); | 1354 | "GNUNET_GTK_publication_types_liststore")); |
1300 | ctx->metatypes_liststore = | 1355 | ctx->metatypes_liststore = GTK_LIST_STORE ( |
1301 | GTK_LIST_STORE (gtk_builder_get_object | 1356 | gtk_builder_get_object (ctx->builder, |
1302 | (ctx->builder, | 1357 | "GNUNET_GTK_publication_metadata_types_liststore")); |
1303 | "GNUNET_GTK_publication_metadata_types_liststore")); | 1358 | ctx->meta_treeview = GTK_TREE_VIEW ( |
1304 | ctx->meta_treeview = GTK_TREE_VIEW (gtk_builder_get_object | 1359 | gtk_builder_get_object (ctx->builder, |
1305 | (ctx->builder, | 1360 | "GNUNET_GTK_edit_publication_metadata_tree_view")); |
1306 | "GNUNET_GTK_edit_publication_metadata_tree_view")); | 1361 | ctx->keywords_treeview = GTK_TREE_VIEW ( |
1307 | ctx->keywords_treeview = GTK_TREE_VIEW (gtk_builder_get_object | 1362 | gtk_builder_get_object (ctx->builder, |
1308 | (ctx->builder, | 1363 | "GNUNET_GTK_edit_publication_keyword_list_tree_view")); |
1309 | "GNUNET_GTK_edit_publication_keyword_list_tree_view")); | ||
1310 | ctx->edit_publication_window = | 1364 | ctx->edit_publication_window = |
1311 | GTK_WINDOW (gtk_builder_get_object (ctx->builder, | 1365 | GTK_WINDOW (gtk_builder_get_object (ctx->builder, |
1312 | "GNUNET_GTK_edit_publication_window")); | 1366 | "GNUNET_GTK_edit_publication_window")); |
1313 | ctx->keywords_liststore = GTK_LIST_STORE (gtk_builder_get_object | 1367 | ctx->keywords_liststore = GTK_LIST_STORE ( |
1314 | (ctx->builder, "GNUNET_GTK_publication_keywords_liststore")); | 1368 | gtk_builder_get_object (ctx->builder, |
1315 | ctx->keyword_entry = | 1369 | "GNUNET_GTK_publication_keywords_liststore")); |
1316 | GTK_ENTRY (gtk_builder_get_object | 1370 | ctx->keyword_entry = GTK_ENTRY ( |
1317 | (ctx->builder, "GNUNET_GTK_edit_publication_keyword_entry")); | 1371 | gtk_builder_get_object (ctx->builder, |
1318 | ctx->confirm_button = GTK_WIDGET (gtk_builder_get_object | 1372 | "GNUNET_GTK_edit_publication_keyword_entry")); |
1319 | (ctx->builder, "GNUNET_GTK_edit_publication_confirm_button")); | 1373 | ctx->confirm_button = GTK_WIDGET ( |
1320 | ctx->preview_image = | 1374 | gtk_builder_get_object (ctx->builder, |
1321 | GTK_IMAGE (gtk_builder_get_object | 1375 | "GNUNET_GTK_edit_publication_confirm_button")); |
1322 | (ctx->builder, | 1376 | ctx->preview_image = GTK_IMAGE ( |
1323 | "GNUNET_GTK_edit_publication_metadata_preview_image")); | 1377 | gtk_builder_get_object (ctx->builder, |
1324 | ctx->meta_liststore = GTK_LIST_STORE (gtk_builder_get_object | 1378 | "GNUNET_GTK_edit_publication_metadata_preview_image")); |
1325 | (ctx->builder, | 1379 | ctx->meta_liststore = GTK_LIST_STORE ( |
1326 | "GNUNET_GTK_publication_metadata_liststore")); | 1380 | gtk_builder_get_object (ctx->builder, |
1327 | ctx->root_entry = GTK_ENTRY (gtk_builder_get_object | 1381 | "GNUNET_GTK_publication_metadata_liststore")); |
1328 | (ctx->builder, "GNUNET_GTK_edit_publication_root_entry")); | 1382 | ctx->root_entry = GTK_ENTRY ( |
1329 | ctx->expiration_year_spin = GTK_SPIN_BUTTON | 1383 | gtk_builder_get_object (ctx->builder, |
1330 | (gtk_builder_get_object | 1384 | "GNUNET_GTK_edit_publication_root_entry")); |
1331 | (ctx->builder, | 1385 | ctx->expiration_year_spin = GTK_SPIN_BUTTON (gtk_builder_get_object ( |
1332 | "GNUNET_GTK_edit_publication_expiration_year_spin_button")); | 1386 | ctx->builder, |
1333 | ctx->priority_spin = GTK_SPIN_BUTTON | 1387 | "GNUNET_GTK_edit_publication_expiration_year_spin_button")); |
1334 | (gtk_builder_get_object | 1388 | ctx->priority_spin = GTK_SPIN_BUTTON ( |
1335 | (ctx->builder, | 1389 | gtk_builder_get_object (ctx->builder, |
1336 | "GNUNET_GTK_edit_publication_priority_spin_button")); | 1390 | "GNUNET_GTK_edit_publication_priority_spin_button")); |
1337 | ctx->replication_spin = GTK_SPIN_BUTTON | 1391 | ctx->replication_spin = GTK_SPIN_BUTTON ( |
1338 | (gtk_builder_get_object | 1392 | gtk_builder_get_object (ctx->builder, |
1339 | (ctx->builder, | 1393 | "GNUNET_GTK_edit_publication_replication_spin_button")); |
1340 | "GNUNET_GTK_edit_publication_replication_spin_button")); | 1394 | ctx->index_checkbutton = GTK_TOGGLE_BUTTON ( |
1341 | ctx->index_checkbutton = GTK_TOGGLE_BUTTON | 1395 | gtk_builder_get_object (ctx->builder, |
1342 | (gtk_builder_get_object | 1396 | "GNUNET_GTK_edit_publication_index_checkbutton")); |
1343 | (ctx->builder, | 1397 | ctx->anonymity_combo = GTK_COMBO_BOX ( |
1344 | "GNUNET_GTK_edit_publication_index_checkbutton")); | 1398 | gtk_builder_get_object (ctx->builder, |
1345 | ctx->anonymity_combo = GTK_COMBO_BOX (gtk_builder_get_object (ctx->builder, | 1399 | "GNUNET_GTK_edit_publication_anonymity_combobox")); |
1346 | "GNUNET_GTK_edit_publication_anonymity_combobox")); | ||
1347 | 1400 | ||
1348 | /* Basic initialization of widgets models and visibility */ | 1401 | /* Basic initialization of widgets models and visibility */ |
1349 | gtk_combo_box_set_model (ctx->anonymity_combo, | 1402 | gtk_combo_box_set_model (ctx->anonymity_combo, |
1350 | GNUNET_FS_GTK_get_anonymity_level_list_store ()); | 1403 | GNUNET_FS_GTK_get_anonymity_level_list_store ()); |
1351 | GNUNET_GTK_setup_expiration_year_adjustment (ctx->builder); | 1404 | GNUNET_GTK_setup_expiration_year_adjustment (ctx->builder); |
1352 | 1405 | ||
1353 | pubtypes_combo = | 1406 | pubtypes_combo = GTK_COMBO_BOX ( |
1354 | GTK_COMBO_BOX (gtk_builder_get_object | 1407 | gtk_builder_get_object (ctx->builder, |
1355 | (ctx->builder, "GNUNET_GTK_edit_publication_type_combo")); | 1408 | "GNUNET_GTK_edit_publication_type_combo")); |
1356 | if (gtk_combo_box_get_active_iter (pubtypes_combo, &iter)) | 1409 | if (gtk_combo_box_get_active_iter (pubtypes_combo, &iter)) |
1357 | { | 1410 | { |
1358 | gtk_tree_model_get (GTK_TREE_MODEL (ctx->pubtypes_liststore), &iter, | 1411 | gtk_tree_model_get (GTK_TREE_MODEL (ctx->pubtypes_liststore), |
1359 | PUBLISH_TYPES_MC_TYPE, &code, -1); | 1412 | &iter, |
1413 | PUBLISH_TYPES_MC_TYPE, | ||
1414 | &code, | ||
1415 | -1); | ||
1360 | change_metatypes (ctx, 0); | 1416 | change_metatypes (ctx, 0); |
1361 | } | 1417 | } |
1362 | else | 1418 | else |
@@ -1364,20 +1420,21 @@ GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, | |||
1364 | 1420 | ||
1365 | /* indexing does not apply to directories */ | 1421 | /* indexing does not apply to directories */ |
1366 | gtk_widget_set_visible (GTK_WIDGET (ctx->index_checkbutton), | 1422 | gtk_widget_set_visible (GTK_WIDGET (ctx->index_checkbutton), |
1367 | ctx->is_directory != GNUNET_YES); | 1423 | ctx->is_directory != GNUNET_YES); |
1368 | index_label = GTK_LABEL (gtk_builder_get_object | 1424 | index_label = GTK_LABEL ( |
1369 | (ctx->builder, | 1425 | gtk_builder_get_object (ctx->builder, |
1370 | "GNUNET_GTK_edit_publication_index_label")); | 1426 | "GNUNET_GTK_edit_publication_index_label")); |
1371 | gtk_widget_set_visible (GTK_WIDGET (index_label), | 1427 | gtk_widget_set_visible (GTK_WIDGET (index_label), |
1372 | ctx->is_directory != GNUNET_YES); | 1428 | ctx->is_directory != GNUNET_YES); |
1373 | 1429 | ||
1374 | /* show root label only for namespaces */ | 1430 | /* show root label only for namespaces */ |
1375 | gtk_widget_set_visible (GTK_WIDGET (ctx->root_entry), | 1431 | gtk_widget_set_visible (GTK_WIDGET (ctx->root_entry), |
1376 | is_namespace_edit ? TRUE : FALSE); | 1432 | is_namespace_edit ? TRUE : FALSE); |
1377 | root_label = GTK_LABEL (gtk_builder_get_object | 1433 | root_label = GTK_LABEL ( |
1378 | (ctx->builder, "GNUNET_GTK_edit_publication_root_label")); | 1434 | gtk_builder_get_object (ctx->builder, |
1435 | "GNUNET_GTK_edit_publication_root_label")); | ||
1379 | gtk_widget_set_visible (GTK_WIDGET (root_label), | 1436 | gtk_widget_set_visible (GTK_WIDGET (root_label), |
1380 | is_namespace_edit ? TRUE : FALSE); | 1437 | is_namespace_edit ? TRUE : FALSE); |
1381 | 1438 | ||
1382 | /* import meta data and options */ | 1439 | /* import meta data and options */ |
1383 | GNUNET_FS_file_information_inspect (fip, &file_information_import, ctx); | 1440 | GNUNET_FS_file_information_inspect (fip, &file_information_import, ctx); |
diff --git a/src/fs/gnunet-fs-gtk_publish-edit-dialog.h b/src/fs/gnunet-fs-gtk_publish-edit-dialog.h index 6416579e..c12a5ecb 100644 --- a/src/fs/gnunet-fs-gtk_publish-edit-dialog.h +++ b/src/fs/gnunet-fs-gtk_publish-edit-dialog.h | |||
@@ -38,7 +38,7 @@ | |||
38 | * @param root namespace root, NULL for file publishing | 38 | * @param root namespace root, NULL for file publishing |
39 | */ | 39 | */ |
40 | typedef void (*GNUNET_FS_GTK_EditPublishDialogCallback) (gpointer cls, | 40 | typedef void (*GNUNET_FS_GTK_EditPublishDialogCallback) (gpointer cls, |
41 | int ret, | 41 | int ret, |
42 | const char *root); | 42 | const char *root); |
43 | 43 | ||
44 | 44 | ||
@@ -54,7 +54,7 @@ typedef void (*GNUNET_FS_GTK_EditPublishDialogCallback) (gpointer cls, | |||
54 | * @param cb_cls closure for 'cb' | 54 | * @param cb_cls closure for 'cb' |
55 | */ | 55 | */ |
56 | void | 56 | void |
57 | GNUNET_FS_GTK_edit_publish_dialog (GtkWindow * parent, | 57 | GNUNET_FS_GTK_edit_publish_dialog (GtkWindow *parent, |
58 | struct GNUNET_FS_FileInformation *fip, | 58 | struct GNUNET_FS_FileInformation *fip, |
59 | int is_namespace_edit, | 59 | int is_namespace_edit, |
60 | GNUNET_FS_GTK_EditPublishDialogCallback cb, | 60 | GNUNET_FS_GTK_EditPublishDialogCallback cb, |
diff --git a/src/fs/gnunet-fs-gtk_unindex.c b/src/fs/gnunet-fs-gtk_unindex.c index 9b9f0af4..4c488c2e 100644 --- a/src/fs/gnunet-fs-gtk_unindex.c +++ b/src/fs/gnunet-fs-gtk_unindex.c | |||
@@ -33,47 +33,47 @@ | |||
33 | * Columns in the unindex model. | 33 | * Columns in the unindex model. |
34 | */ | 34 | */ |
35 | enum UNINDEX_ModelColumns | 35 | enum UNINDEX_ModelColumns |
36 | { | 36 | { |
37 | /** | 37 | /** |
38 | * A gchararray. | 38 | * A gchararray. |
39 | */ | 39 | */ |
40 | UNINDEX_MC_FILENAME = 0, | 40 | UNINDEX_MC_FILENAME = 0, |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * A guint64. | 43 | * A guint64. |
44 | */ | 44 | */ |
45 | UNINDEX_MC_FILESIZE = 1, | 45 | UNINDEX_MC_FILESIZE = 1, |
46 | 46 | ||
47 | /** | 47 | /** |
48 | * A gchararray representing a color. | 48 | * A gchararray representing a color. |
49 | */ | 49 | */ |
50 | UNINDEX_MC_BACKGROUND_COLOR = 2, | 50 | UNINDEX_MC_BACKGROUND_COLOR = 2, |
51 | 51 | ||
52 | /** | 52 | /** |
53 | * A 'struct UnindexEntry' (gpointer) | 53 | * A 'struct UnindexEntry' (gpointer) |
54 | */ | 54 | */ |
55 | UNINDEX_MC_UNINDEX_CONTEXT = 3, | 55 | UNINDEX_MC_UNINDEX_CONTEXT = 3, |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * A gfloat. | 58 | * A gfloat. |
59 | */ | 59 | */ |
60 | UNINDEX_MC_UNINDEX_PROGRESS = 4, | 60 | UNINDEX_MC_UNINDEX_PROGRESS = 4, |
61 | 61 | ||
62 | /** | 62 | /** |
63 | * A boolean. | 63 | * A boolean. |
64 | */ | 64 | */ |
65 | UNINDEX_MC_PROGRESS_VISIBLE = 5, | 65 | UNINDEX_MC_PROGRESS_VISIBLE = 5, |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * A gchararray. | 68 | * A gchararray. |
69 | */ | 69 | */ |
70 | UNINDEX_MC_ERROR = 6, | 70 | UNINDEX_MC_ERROR = 6, |
71 | 71 | ||
72 | /** | 72 | /** |
73 | * A GdkPixbuf. | 73 | * A GdkPixbuf. |
74 | */ | 74 | */ |
75 | UNINDEX_MC_STATUS_ICON = 7 | 75 | UNINDEX_MC_STATUS_ICON = 7 |
76 | }; | 76 | }; |
77 | 77 | ||
78 | 78 | ||
79 | /** | 79 | /** |
@@ -187,8 +187,7 @@ static struct UnindexEntry *ue_tail; | |||
187 | * @param user_data the unindex context | 187 | * @param user_data the unindex context |
188 | */ | 188 | */ |
189 | void | 189 | void |
190 | GNUNET_FS_GTK_unindex_button_clicked_cb (GtkWidget * dummy, | 190 | GNUNET_FS_GTK_unindex_button_clicked_cb (GtkWidget *dummy, gpointer user_data) |
191 | gpointer user_data) | ||
192 | { | 191 | { |
193 | struct UnindexDialogContext *udc = user_data; | 192 | struct UnindexDialogContext *udc = user_data; |
194 | GtkTreeIter iter; | 193 | GtkTreeIter iter; |
@@ -203,11 +202,15 @@ GNUNET_FS_GTK_unindex_button_clicked_cb (GtkWidget * dummy, | |||
203 | GNUNET_break (0); | 202 | GNUNET_break (0); |
204 | return; | 203 | return; |
205 | } | 204 | } |
206 | gtk_tree_model_get (udc->model, &iter, | 205 | gtk_tree_model_get (udc->model, |
207 | UNINDEX_MC_FILENAME, &filename, | 206 | &iter, |
208 | UNINDEX_MC_FILESIZE, &filesize, | 207 | UNINDEX_MC_FILENAME, |
209 | UNINDEX_MC_UNINDEX_CONTEXT, &ue, | 208 | &filename, |
210 | -1); | 209 | UNINDEX_MC_FILESIZE, |
210 | &filesize, | ||
211 | UNINDEX_MC_UNINDEX_CONTEXT, | ||
212 | &ue, | ||
213 | -1); | ||
211 | if (NULL != ue) | 214 | if (NULL != ue) |
212 | { | 215 | { |
213 | GNUNET_break (0); | 216 | GNUNET_break (0); |
@@ -221,15 +224,19 @@ GNUNET_FS_GTK_unindex_button_clicked_cb (GtkWidget * dummy, | |||
221 | path = gtk_tree_model_get_path (udc->model, &iter); | 224 | path = gtk_tree_model_get_path (udc->model, &iter); |
222 | ue->rr = gtk_tree_row_reference_new (udc->model, path); | 225 | ue->rr = gtk_tree_row_reference_new (udc->model, path); |
223 | gtk_tree_path_free (path); | 226 | gtk_tree_path_free (path); |
224 | ue->uc = GNUNET_FS_unindex_start (GNUNET_FS_GTK_get_fs_handle (), | 227 | ue->uc = |
225 | filename, ue); | 228 | GNUNET_FS_unindex_start (GNUNET_FS_GTK_get_fs_handle (), filename, ue); |
226 | gtk_list_store_set (GTK_LIST_STORE (udc->model), | 229 | gtk_list_store_set (GTK_LIST_STORE (udc->model), |
227 | &iter, | 230 | &iter, |
228 | UNINDEX_MC_BACKGROUND_COLOR, "yellow", | 231 | UNINDEX_MC_BACKGROUND_COLOR, |
229 | UNINDEX_MC_UNINDEX_CONTEXT, ue, | 232 | "yellow", |
230 | UNINDEX_MC_UNINDEX_PROGRESS, 0, | 233 | UNINDEX_MC_UNINDEX_CONTEXT, |
231 | UNINDEX_MC_PROGRESS_VISIBLE, TRUE, | 234 | ue, |
232 | -1); | 235 | UNINDEX_MC_UNINDEX_PROGRESS, |
236 | 0, | ||
237 | UNINDEX_MC_PROGRESS_VISIBLE, | ||
238 | TRUE, | ||
239 | -1); | ||
233 | gtk_widget_set_sensitive (udc->unindex_button, FALSE); | 240 | gtk_widget_set_sensitive (udc->unindex_button, FALSE); |
234 | } | 241 | } |
235 | 242 | ||
@@ -241,8 +248,8 @@ GNUNET_FS_GTK_unindex_button_clicked_cb (GtkWidget * dummy, | |||
241 | * @param user_data the unindex context | 248 | * @param user_data the unindex context |
242 | */ | 249 | */ |
243 | void | 250 | void |
244 | GNUNET_FS_GTK_unindex_close_button_clicked_cb (GtkWidget * dummy, | 251 | GNUNET_FS_GTK_unindex_close_button_clicked_cb (GtkWidget *dummy, |
245 | gpointer user_data) | 252 | gpointer user_data) |
246 | { | 253 | { |
247 | struct UnindexDialogContext *udc = user_data; | 254 | struct UnindexDialogContext *udc = user_data; |
248 | GtkTreeIter iter; | 255 | GtkTreeIter iter; |
@@ -256,16 +263,17 @@ GNUNET_FS_GTK_unindex_close_button_clicked_cb (GtkWidget * dummy, | |||
256 | if (gtk_tree_model_get_iter_first (udc->model, &iter)) | 263 | if (gtk_tree_model_get_iter_first (udc->model, &iter)) |
257 | do | 264 | do |
258 | { | 265 | { |
259 | gtk_tree_model_get (udc->model, &iter, | 266 | gtk_tree_model_get (udc->model, |
260 | UNINDEX_MC_UNINDEX_CONTEXT, &ue, | 267 | &iter, |
261 | -1); | 268 | UNINDEX_MC_UNINDEX_CONTEXT, |
269 | &ue, | ||
270 | -1); | ||
262 | if (NULL != ue) | 271 | if (NULL != ue) |
263 | { | 272 | { |
264 | gtk_tree_row_reference_free (ue->rr); | 273 | gtk_tree_row_reference_free (ue->rr); |
265 | ue->rr = NULL; | 274 | ue->rr = NULL; |
266 | } | 275 | } |
267 | } | 276 | } while (TRUE == gtk_tree_model_iter_next (udc->model, &iter)); |
268 | while (TRUE == gtk_tree_model_iter_next (udc->model, &iter)); | ||
269 | gtk_widget_destroy (udc->dialog); | 277 | gtk_widget_destroy (udc->dialog); |
270 | g_object_unref (G_OBJECT (udc->builder)); | 278 | g_object_unref (G_OBJECT (udc->builder)); |
271 | GNUNET_free (udc); | 279 | GNUNET_free (udc); |
@@ -281,7 +289,7 @@ GNUNET_FS_GTK_unindex_close_button_clicked_cb (GtkWidget * dummy, | |||
281 | */ | 289 | */ |
282 | void | 290 | void |
283 | GNUNET_FS_GTK_unindex_treeview_selection_changed_cb (GtkTreeSelection *ts, | 291 | GNUNET_FS_GTK_unindex_treeview_selection_changed_cb (GtkTreeSelection *ts, |
284 | gpointer user_data) | 292 | gpointer user_data) |
285 | { | 293 | { |
286 | struct UnindexDialogContext *udc = user_data; | 294 | struct UnindexDialogContext *udc = user_data; |
287 | GtkTreeIter iter; | 295 | GtkTreeIter iter; |
@@ -290,9 +298,7 @@ GNUNET_FS_GTK_unindex_treeview_selection_changed_cb (GtkTreeSelection *ts, | |||
290 | /* find out if a file is selected */ | 298 | /* find out if a file is selected */ |
291 | if (gtk_tree_selection_get_selected (udc->selection, NULL, &iter)) | 299 | if (gtk_tree_selection_get_selected (udc->selection, NULL, &iter)) |
292 | { | 300 | { |
293 | gtk_tree_model_get (udc->model, &iter, | 301 | gtk_tree_model_get (udc->model, &iter, UNINDEX_MC_UNINDEX_CONTEXT, &ue, -1); |
294 | UNINDEX_MC_UNINDEX_CONTEXT, &ue, | ||
295 | -1); | ||
296 | if (NULL == ue) | 302 | if (NULL == ue) |
297 | { | 303 | { |
298 | /* selected file not already being unindexed, enable button! */ | 304 | /* selected file not already being unindexed, enable button! */ |
@@ -313,8 +319,9 @@ GNUNET_FS_GTK_unindex_treeview_selection_changed_cb (GtkTreeSelection *ts, | |||
313 | * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort | 319 | * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort |
314 | */ | 320 | */ |
315 | static int | 321 | static int |
316 | add_indexed_file (void *cls, const char *filename, | 322 | add_indexed_file (void *cls, |
317 | const struct GNUNET_HashCode * file_id) | 323 | const char *filename, |
324 | const struct GNUNET_HashCode *file_id) | ||
318 | { | 325 | { |
319 | struct UnindexDialogContext *udc = cls; | 326 | struct UnindexDialogContext *udc = cls; |
320 | GtkTreeIter iter; | 327 | GtkTreeIter iter; |
@@ -329,13 +336,11 @@ add_indexed_file (void *cls, const char *filename, | |||
329 | return GNUNET_OK; | 336 | return GNUNET_OK; |
330 | } | 337 | } |
331 | if (GNUNET_OK != | 338 | if (GNUNET_OK != |
332 | GNUNET_DISK_file_size (filename, | 339 | GNUNET_DISK_file_size (filename, &filesize, GNUNET_YES, GNUNET_YES)) |
333 | &filesize, | ||
334 | GNUNET_YES, GNUNET_YES)) | ||
335 | { | 340 | { |
336 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 341 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
337 | _("Could not access indexed file `%s'\n"), | 342 | _ ("Could not access indexed file `%s'\n"), |
338 | filename); | 343 | filename); |
339 | return GNUNET_OK; | 344 | return GNUNET_OK; |
340 | } | 345 | } |
341 | for (ue = ue_head; ue != NULL; ue = ue->next) | 346 | for (ue = ue_head; ue != NULL; ue = ue->next) |
@@ -344,12 +349,17 @@ add_indexed_file (void *cls, const char *filename, | |||
344 | if (NULL == ue) | 349 | if (NULL == ue) |
345 | { | 350 | { |
346 | gtk_list_store_insert_with_values (GTK_LIST_STORE (udc->model), | 351 | gtk_list_store_insert_with_values (GTK_LIST_STORE (udc->model), |
347 | &iter, G_MAXINT, | 352 | &iter, |
348 | UNINDEX_MC_FILENAME, filename, | 353 | G_MAXINT, |
349 | UNINDEX_MC_FILESIZE, (guint64) filesize, | 354 | UNINDEX_MC_FILENAME, |
350 | UNINDEX_MC_BACKGROUND_COLOR, "white", | 355 | filename, |
351 | UNINDEX_MC_PROGRESS_VISIBLE, FALSE, | 356 | UNINDEX_MC_FILESIZE, |
352 | -1); | 357 | (guint64) filesize, |
358 | UNINDEX_MC_BACKGROUND_COLOR, | ||
359 | "white", | ||
360 | UNINDEX_MC_PROGRESS_VISIBLE, | ||
361 | FALSE, | ||
362 | -1); | ||
353 | } | 363 | } |
354 | else | 364 | else |
355 | { | 365 | { |
@@ -359,15 +369,23 @@ add_indexed_file (void *cls, const char *filename, | |||
359 | return GNUNET_OK; | 369 | return GNUNET_OK; |
360 | } | 370 | } |
361 | gtk_list_store_insert_with_values (GTK_LIST_STORE (udc->model), | 371 | gtk_list_store_insert_with_values (GTK_LIST_STORE (udc->model), |
362 | &iter, G_MAXINT, | 372 | &iter, |
363 | UNINDEX_MC_FILENAME, filename, | 373 | G_MAXINT, |
364 | UNINDEX_MC_FILESIZE, (guint64) filesize, | 374 | UNINDEX_MC_FILENAME, |
365 | UNINDEX_MC_BACKGROUND_COLOR, (NULL == ue->emsg) ? "yellow" : "red", | 375 | filename, |
366 | UNINDEX_MC_UNINDEX_CONTEXT, ue, | 376 | UNINDEX_MC_FILESIZE, |
367 | UNINDEX_MC_UNINDEX_PROGRESS, ue->progress, | 377 | (guint64) filesize, |
368 | UNINDEX_MC_PROGRESS_VISIBLE, TRUE, | 378 | UNINDEX_MC_BACKGROUND_COLOR, |
369 | UNINDEX_MC_ERROR, ue->emsg, | 379 | (NULL == ue->emsg) ? "yellow" : "red", |
370 | -1); | 380 | UNINDEX_MC_UNINDEX_CONTEXT, |
381 | ue, | ||
382 | UNINDEX_MC_UNINDEX_PROGRESS, | ||
383 | ue->progress, | ||
384 | UNINDEX_MC_PROGRESS_VISIBLE, | ||
385 | TRUE, | ||
386 | UNINDEX_MC_ERROR, | ||
387 | ue->emsg, | ||
388 | -1); | ||
371 | path = gtk_tree_model_get_path (udc->model, &iter); | 389 | path = gtk_tree_model_get_path (udc->model, &iter); |
372 | ue->rr = gtk_tree_row_reference_new (udc->model, path); | 390 | ue->rr = gtk_tree_row_reference_new (udc->model, path); |
373 | } | 391 | } |
@@ -382,8 +400,7 @@ add_indexed_file (void *cls, const char *filename, | |||
382 | * @param data the main dialog builder, unused | 400 | * @param data the main dialog builder, unused |
383 | */ | 401 | */ |
384 | void | 402 | void |
385 | GNUNET_GTK_main_menu_unindex_activate_cb (GtkWidget * dummy, | 403 | GNUNET_GTK_main_menu_unindex_activate_cb (GtkWidget *dummy, gpointer data) |
386 | gpointer data) | ||
387 | { | 404 | { |
388 | GtkWidget *toplevel; | 405 | GtkWidget *toplevel; |
389 | struct UnindexDialogContext *udc; | 406 | struct UnindexDialogContext *udc; |
@@ -403,21 +420,22 @@ GNUNET_GTK_main_menu_unindex_activate_cb (GtkWidget * dummy, | |||
403 | GNUNET_free (udc); | 420 | GNUNET_free (udc); |
404 | return; | 421 | return; |
405 | } | 422 | } |
406 | udc->dialog = GTK_WIDGET (gtk_builder_get_object | 423 | udc->dialog = GTK_WIDGET ( |
407 | (udc->builder, "GNUNET_FS_GTK_unindex_dialog")); | 424 | gtk_builder_get_object (udc->builder, "GNUNET_FS_GTK_unindex_dialog")); |
408 | udc->treeview = GTK_TREE_VIEW (gtk_builder_get_object | 425 | udc->treeview = GTK_TREE_VIEW ( |
409 | (udc->builder, "GNUNET_FS_GTK_unindex_treeview")); | 426 | gtk_builder_get_object (udc->builder, "GNUNET_FS_GTK_unindex_treeview")); |
410 | udc->selection = gtk_tree_view_get_selection (udc->treeview); | 427 | udc->selection = gtk_tree_view_get_selection (udc->treeview); |
411 | udc->unindex_button = GTK_WIDGET (gtk_builder_get_object | 428 | udc->unindex_button = GTK_WIDGET ( |
412 | (udc->builder, "GNUNET_FS_GTK_unindex_button")); | 429 | gtk_builder_get_object (udc->builder, "GNUNET_FS_GTK_unindex_button")); |
413 | udc->model = GTK_TREE_MODEL (gtk_builder_get_object | 430 | udc->model = GTK_TREE_MODEL ( |
414 | (udc->builder, "GNUNET_FS_GTK_unindex_liststore")); | 431 | gtk_builder_get_object (udc->builder, "GNUNET_FS_GTK_unindex_liststore")); |
415 | udc->gic = GNUNET_FS_get_indexed_files (GNUNET_FS_GTK_get_fs_handle (), | 432 | udc->gic = GNUNET_FS_get_indexed_files (GNUNET_FS_GTK_get_fs_handle (), |
416 | &add_indexed_file, | 433 | &add_indexed_file, |
417 | udc); | 434 | udc); |
418 | toplevel = gtk_widget_get_toplevel (dummy); | 435 | toplevel = gtk_widget_get_toplevel (dummy); |
419 | if (GTK_IS_WINDOW (toplevel)) | 436 | if (GTK_IS_WINDOW (toplevel)) |
420 | gtk_window_set_transient_for (GTK_WINDOW (udc->dialog), GTK_WINDOW (toplevel)); | 437 | gtk_window_set_transient_for (GTK_WINDOW (udc->dialog), |
438 | GTK_WINDOW (toplevel)); | ||
421 | gtk_window_present (GTK_WINDOW (udc->dialog)); | 439 | gtk_window_present (GTK_WINDOW (udc->dialog)); |
422 | master_udc = udc; | 440 | master_udc = udc; |
423 | } | 441 | } |
@@ -436,10 +454,10 @@ GNUNET_GTK_main_menu_unindex_activate_cb (GtkWidget * dummy, | |||
436 | */ | 454 | */ |
437 | struct UnindexEntry * | 455 | struct UnindexEntry * |
438 | GNUNET_FS_GTK_unindex_handle_resume_ (struct GNUNET_FS_UnindexContext *uc, | 456 | GNUNET_FS_GTK_unindex_handle_resume_ (struct GNUNET_FS_UnindexContext *uc, |
439 | const char *filename, | 457 | const char *filename, |
440 | uint64_t filesize, | 458 | uint64_t filesize, |
441 | uint64_t completed, | 459 | uint64_t completed, |
442 | const char *emsg) | 460 | const char *emsg) |
443 | { | 461 | { |
444 | struct UnindexEntry *ue; | 462 | struct UnindexEntry *ue; |
445 | 463 | ||
@@ -450,9 +468,7 @@ GNUNET_FS_GTK_unindex_handle_resume_ (struct GNUNET_FS_UnindexContext *uc, | |||
450 | ue->filesize = filesize; | 468 | ue->filesize = filesize; |
451 | ue->uc = uc; | 469 | ue->uc = uc; |
452 | ue->progress = (gint) ((100LL * completed) / filesize); | 470 | ue->progress = (gint) ((100LL * completed) / filesize); |
453 | GNUNET_CONTAINER_DLL_insert (ue_head, | 471 | GNUNET_CONTAINER_DLL_insert (ue_head, ue_tail, ue); |
454 | ue_tail, | ||
455 | ue); | ||
456 | return ue; | 472 | return ue; |
457 | } | 473 | } |
458 | 474 | ||
@@ -475,18 +491,15 @@ GNUNET_FS_GTK_unindex_handle_stop_ (struct UnindexEntry *ue) | |||
475 | model = gtk_tree_row_reference_get_model (ue->rr); | 491 | model = gtk_tree_row_reference_get_model (ue->rr); |
476 | gtk_tree_row_reference_free (ue->rr); | 492 | gtk_tree_row_reference_free (ue->rr); |
477 | ue->rr = NULL; | 493 | ue->rr = NULL; |
478 | GNUNET_assert (TRUE == gtk_tree_model_get_iter (model, | 494 | GNUNET_assert (TRUE == gtk_tree_model_get_iter (model, &iter, path)); |
479 | &iter, | ||
480 | path)); | ||
481 | gtk_tree_path_free (path); | 495 | gtk_tree_path_free (path); |
482 | gtk_list_store_set (GTK_LIST_STORE (model), | 496 | gtk_list_store_set (GTK_LIST_STORE (model), |
483 | &iter, | 497 | &iter, |
484 | UNINDEX_MC_UNINDEX_CONTEXT, NULL, | 498 | UNINDEX_MC_UNINDEX_CONTEXT, |
485 | -1); | 499 | NULL, |
500 | -1); | ||
486 | } | 501 | } |
487 | GNUNET_CONTAINER_DLL_remove (ue_head, | 502 | GNUNET_CONTAINER_DLL_remove (ue_head, ue_tail, ue); |
488 | ue_tail, | ||
489 | ue); | ||
490 | GNUNET_free_non_null (ue->emsg); | 503 | GNUNET_free_non_null (ue->emsg); |
491 | GNUNET_free (ue->filename); | 504 | GNUNET_free (ue->filename); |
492 | GNUNET_free (ue); | 505 | GNUNET_free (ue); |
@@ -500,8 +513,7 @@ GNUNET_FS_GTK_unindex_handle_stop_ (struct UnindexEntry *ue) | |||
500 | * @param emsg error message | 513 | * @param emsg error message |
501 | */ | 514 | */ |
502 | void | 515 | void |
503 | GNUNET_FS_GTK_unindex_handle_error_ (struct UnindexEntry *ue, | 516 | GNUNET_FS_GTK_unindex_handle_error_ (struct UnindexEntry *ue, const char *emsg) |
504 | const char *emsg) | ||
505 | { | 517 | { |
506 | GtkTreePath *path; | 518 | GtkTreePath *path; |
507 | GtkTreeIter iter; | 519 | GtkTreeIter iter; |
@@ -512,15 +524,15 @@ GNUNET_FS_GTK_unindex_handle_error_ (struct UnindexEntry *ue, | |||
512 | return; | 524 | return; |
513 | path = gtk_tree_row_reference_get_path (ue->rr); | 525 | path = gtk_tree_row_reference_get_path (ue->rr); |
514 | model = gtk_tree_row_reference_get_model (ue->rr); | 526 | model = gtk_tree_row_reference_get_model (ue->rr); |
515 | GNUNET_assert (TRUE == gtk_tree_model_get_iter (model, | 527 | GNUNET_assert (TRUE == gtk_tree_model_get_iter (model, &iter, path)); |
516 | &iter, | ||
517 | path)); | ||
518 | gtk_tree_path_free (path); | 528 | gtk_tree_path_free (path); |
519 | gtk_list_store_set (GTK_LIST_STORE (model), | 529 | gtk_list_store_set (GTK_LIST_STORE (model), |
520 | &iter, | 530 | &iter, |
521 | UNINDEX_MC_BACKGROUND_COLOR, "red", | 531 | UNINDEX_MC_BACKGROUND_COLOR, |
522 | UNINDEX_MC_ERROR, emsg, | 532 | "red", |
523 | -1); | 533 | UNINDEX_MC_ERROR, |
534 | emsg, | ||
535 | -1); | ||
524 | } | 536 | } |
525 | 537 | ||
526 | 538 | ||
@@ -532,7 +544,7 @@ GNUNET_FS_GTK_unindex_handle_error_ (struct UnindexEntry *ue, | |||
532 | */ | 544 | */ |
533 | void | 545 | void |
534 | GNUNET_FS_GTK_unindex_handle_progress_ (struct UnindexEntry *ue, | 546 | GNUNET_FS_GTK_unindex_handle_progress_ (struct UnindexEntry *ue, |
535 | uint64_t completed) | 547 | uint64_t completed) |
536 | { | 548 | { |
537 | GtkTreePath *path; | 549 | GtkTreePath *path; |
538 | GtkTreeIter iter; | 550 | GtkTreeIter iter; |
@@ -543,14 +555,13 @@ GNUNET_FS_GTK_unindex_handle_progress_ (struct UnindexEntry *ue, | |||
543 | return; | 555 | return; |
544 | path = gtk_tree_row_reference_get_path (ue->rr); | 556 | path = gtk_tree_row_reference_get_path (ue->rr); |
545 | model = gtk_tree_row_reference_get_model (ue->rr); | 557 | model = gtk_tree_row_reference_get_model (ue->rr); |
546 | GNUNET_assert (TRUE == gtk_tree_model_get_iter (model, | 558 | GNUNET_assert (TRUE == gtk_tree_model_get_iter (model, &iter, path)); |
547 | &iter, | ||
548 | path)); | ||
549 | gtk_tree_path_free (path); | 559 | gtk_tree_path_free (path); |
550 | gtk_list_store_set (GTK_LIST_STORE (model), | 560 | gtk_list_store_set (GTK_LIST_STORE (model), |
551 | &iter, | 561 | &iter, |
552 | UNINDEX_MC_UNINDEX_PROGRESS, ue->progress, | 562 | UNINDEX_MC_UNINDEX_PROGRESS, |
553 | -1); | 563 | ue->progress, |
564 | -1); | ||
554 | } | 565 | } |
555 | 566 | ||
556 | 567 | ||
@@ -570,12 +581,9 @@ GNUNET_FS_GTK_unindex_handle_completed_ (struct UnindexEntry *ue) | |||
570 | { | 581 | { |
571 | path = gtk_tree_row_reference_get_path (ue->rr); | 582 | path = gtk_tree_row_reference_get_path (ue->rr); |
572 | model = gtk_tree_row_reference_get_model (ue->rr); | 583 | model = gtk_tree_row_reference_get_model (ue->rr); |
573 | GNUNET_assert (TRUE == gtk_tree_model_get_iter (model, | 584 | GNUNET_assert (TRUE == gtk_tree_model_get_iter (model, &iter, path)); |
574 | &iter, | ||
575 | path)); | ||
576 | gtk_tree_path_free (path); | 585 | gtk_tree_path_free (path); |
577 | gtk_list_store_remove (GTK_LIST_STORE (model), | 586 | gtk_list_store_remove (GTK_LIST_STORE (model), &iter); |
578 | &iter); | ||
579 | gtk_tree_row_reference_free (ue->rr); | 587 | gtk_tree_row_reference_free (ue->rr); |
580 | ue->rr = NULL; | 588 | ue->rr = NULL; |
581 | } | 589 | } |
@@ -583,5 +591,4 @@ GNUNET_FS_GTK_unindex_handle_completed_ (struct UnindexEntry *ue) | |||
583 | } | 591 | } |
584 | 592 | ||
585 | 593 | ||
586 | |||
587 | /* end of gnunet-fs-gtk_unindex.c */ | 594 | /* end of gnunet-fs-gtk_unindex.c */ |
diff --git a/src/fs/gnunet-fs-gtk_unindex.h b/src/fs/gnunet-fs-gtk_unindex.h index 4cf22f49..a785ae46 100644 --- a/src/fs/gnunet-fs-gtk_unindex.h +++ b/src/fs/gnunet-fs-gtk_unindex.h | |||
@@ -49,10 +49,10 @@ struct UnindexEntry; | |||
49 | */ | 49 | */ |
50 | struct UnindexEntry * | 50 | struct UnindexEntry * |
51 | GNUNET_FS_GTK_unindex_handle_resume_ (struct GNUNET_FS_UnindexContext *uc, | 51 | GNUNET_FS_GTK_unindex_handle_resume_ (struct GNUNET_FS_UnindexContext *uc, |
52 | const char *filename, | 52 | const char *filename, |
53 | uint64_t filesize, | 53 | uint64_t filesize, |
54 | uint64_t completed, | 54 | uint64_t completed, |
55 | const char *emsg); | 55 | const char *emsg); |
56 | 56 | ||
57 | 57 | ||
58 | /** | 58 | /** |
@@ -71,8 +71,7 @@ GNUNET_FS_GTK_unindex_handle_stop_ (struct UnindexEntry *ue); | |||
71 | * @param emsg error message | 71 | * @param emsg error message |
72 | */ | 72 | */ |
73 | void | 73 | void |
74 | GNUNET_FS_GTK_unindex_handle_error_ (struct UnindexEntry *ue, | 74 | GNUNET_FS_GTK_unindex_handle_error_ (struct UnindexEntry *ue, const char *emsg); |
75 | const char *emsg); | ||
76 | 75 | ||
77 | 76 | ||
78 | /** | 77 | /** |
@@ -83,7 +82,7 @@ GNUNET_FS_GTK_unindex_handle_error_ (struct UnindexEntry *ue, | |||
83 | */ | 82 | */ |
84 | void | 83 | void |
85 | GNUNET_FS_GTK_unindex_handle_progress_ (struct UnindexEntry *ue, | 84 | GNUNET_FS_GTK_unindex_handle_progress_ (struct UnindexEntry *ue, |
86 | uint64_t completed); | 85 | uint64_t completed); |
87 | 86 | ||
88 | 87 | ||
89 | /** | 88 | /** |
@@ -95,6 +94,4 @@ void | |||
95 | GNUNET_FS_GTK_unindex_handle_completed_ (struct UnindexEntry *ue); | 94 | GNUNET_FS_GTK_unindex_handle_completed_ (struct UnindexEntry *ue); |
96 | 95 | ||
97 | 96 | ||
98 | |||
99 | |||
100 | #endif | 97 | #endif |
diff --git a/src/fs/metatypes.c b/src/fs/metatypes.c index 1c1ae6fc..9b49ef4f 100644 --- a/src/fs/metatypes.c +++ b/src/fs/metatypes.c | |||
@@ -1,235 +1,216 @@ | |||
1 | /* *INDENT-OFF* */ | 1 | /* *INDENT-OFF* */ |
2 | 2 | ||
3 | gint types_generic[] = { | 3 | gint types_generic[] = {EXTRACTOR_METATYPE_MIMETYPE, |
4 | EXTRACTOR_METATYPE_MIMETYPE, | 4 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, |
5 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, | 5 | EXTRACTOR_METATYPE_TITLE, |
6 | EXTRACTOR_METATYPE_TITLE, | 6 | EXTRACTOR_METATYPE_KEYWORDS, |
7 | EXTRACTOR_METATYPE_KEYWORDS, | 7 | EXTRACTOR_METATYPE_SUBJECT, |
8 | EXTRACTOR_METATYPE_SUBJECT, | 8 | EXTRACTOR_METATYPE_DESCRIPTION, |
9 | EXTRACTOR_METATYPE_DESCRIPTION, | 9 | EXTRACTOR_METATYPE_COMMENT, |
10 | EXTRACTOR_METATYPE_COMMENT, | ||
11 | #if HAVE_EXTRACTOR_H | 10 | #if HAVE_EXTRACTOR_H |
12 | EXTRACTOR_METATYPE_COPYRIGHT, | 11 | EXTRACTOR_METATYPE_COPYRIGHT, |
13 | EXTRACTOR_METATYPE_URI, | 12 | EXTRACTOR_METATYPE_URI, |
14 | EXTRACTOR_METATYPE_CREATOR, | 13 | EXTRACTOR_METATYPE_CREATOR, |
15 | EXTRACTOR_METATYPE_CREATION_DATE, | 14 | EXTRACTOR_METATYPE_CREATION_DATE, |
16 | #endif | 15 | #endif |
17 | EXTRACTOR_METATYPE_RESERVED | 16 | EXTRACTOR_METATYPE_RESERVED}; |
18 | }; | ||
19 | 17 | ||
20 | 18 | ||
21 | gint types_text[] = | 19 | gint types_text[] = {EXTRACTOR_METATYPE_MIMETYPE, |
22 | { | 20 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, |
23 | EXTRACTOR_METATYPE_MIMETYPE, | 21 | EXTRACTOR_METATYPE_TITLE, |
24 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, | 22 | EXTRACTOR_METATYPE_KEYWORDS, |
25 | EXTRACTOR_METATYPE_TITLE, | ||
26 | EXTRACTOR_METATYPE_KEYWORDS, | ||
27 | #if HAVE_EXTRACTOR_H | 23 | #if HAVE_EXTRACTOR_H |
28 | EXTRACTOR_METATYPE_ABSTRACT, | 24 | EXTRACTOR_METATYPE_ABSTRACT, |
29 | EXTRACTOR_METATYPE_SUMMARY, | 25 | EXTRACTOR_METATYPE_SUMMARY, |
30 | EXTRACTOR_METATYPE_SUBJECT, | 26 | EXTRACTOR_METATYPE_SUBJECT, |
31 | EXTRACTOR_METATYPE_AUTHOR_NAME, | 27 | EXTRACTOR_METATYPE_AUTHOR_NAME, |
32 | EXTRACTOR_METATYPE_AUTHOR_EMAIL, | 28 | EXTRACTOR_METATYPE_AUTHOR_EMAIL, |
33 | EXTRACTOR_METATYPE_AUTHOR_INSTITUTION, | 29 | EXTRACTOR_METATYPE_AUTHOR_INSTITUTION, |
34 | EXTRACTOR_METATYPE_DESCRIPTION, | 30 | EXTRACTOR_METATYPE_DESCRIPTION, |
35 | EXTRACTOR_METATYPE_LANGUAGE, | 31 | EXTRACTOR_METATYPE_LANGUAGE, |
36 | EXTRACTOR_METATYPE_COPYRIGHT, | 32 | EXTRACTOR_METATYPE_COPYRIGHT, |
37 | EXTRACTOR_METATYPE_COMMENT, | 33 | EXTRACTOR_METATYPE_COMMENT, |
38 | EXTRACTOR_METATYPE_BOOK_TITLE, | 34 | EXTRACTOR_METATYPE_BOOK_TITLE, |
39 | EXTRACTOR_METATYPE_BOOK_EDITION, | 35 | EXTRACTOR_METATYPE_BOOK_EDITION, |
40 | EXTRACTOR_METATYPE_BOOK_CHAPTER_NUMBER, | 36 | EXTRACTOR_METATYPE_BOOK_CHAPTER_NUMBER, |
41 | EXTRACTOR_METATYPE_JOURNAL_NAME, | 37 | EXTRACTOR_METATYPE_JOURNAL_NAME, |
42 | EXTRACTOR_METATYPE_JOURNAL_VOLUME, | 38 | EXTRACTOR_METATYPE_JOURNAL_VOLUME, |
43 | EXTRACTOR_METATYPE_JOURNAL_NUMBER, | 39 | EXTRACTOR_METATYPE_JOURNAL_NUMBER, |
44 | EXTRACTOR_METATYPE_PAGE_COUNT, | 40 | EXTRACTOR_METATYPE_PAGE_COUNT, |
45 | EXTRACTOR_METATYPE_PAGE_RANGE, | 41 | EXTRACTOR_METATYPE_PAGE_RANGE, |
46 | EXTRACTOR_METATYPE_PUBLISHER, | 42 | EXTRACTOR_METATYPE_PUBLISHER, |
47 | EXTRACTOR_METATYPE_PUBLISHER_ADDRESS, | 43 | EXTRACTOR_METATYPE_PUBLISHER_ADDRESS, |
48 | EXTRACTOR_METATYPE_PUBLISHER_INSTITUTION, | 44 | EXTRACTOR_METATYPE_PUBLISHER_INSTITUTION, |
49 | EXTRACTOR_METATYPE_PUBLISHER_SERIES, | 45 | EXTRACTOR_METATYPE_PUBLISHER_SERIES, |
50 | EXTRACTOR_METATYPE_PUBLICATION_TYPE, | 46 | EXTRACTOR_METATYPE_PUBLICATION_TYPE, |
51 | EXTRACTOR_METATYPE_PUBLICATION_DATE, | 47 | EXTRACTOR_METATYPE_PUBLICATION_DATE, |
52 | EXTRACTOR_METATYPE_URL, | 48 | EXTRACTOR_METATYPE_URL, |
53 | EXTRACTOR_METATYPE_CREATOR, | 49 | EXTRACTOR_METATYPE_CREATOR, |
54 | EXTRACTOR_METATYPE_CREATION_DATE, | 50 | EXTRACTOR_METATYPE_CREATION_DATE, |
55 | EXTRACTOR_METATYPE_MODIFICATION_DATE, | 51 | EXTRACTOR_METATYPE_MODIFICATION_DATE, |
56 | EXTRACTOR_METATYPE_CHARACTER_SET, | 52 | EXTRACTOR_METATYPE_CHARACTER_SET, |
57 | EXTRACTOR_METATYPE_LINE_COUNT, | 53 | EXTRACTOR_METATYPE_LINE_COUNT, |
58 | EXTRACTOR_METATYPE_WORD_COUNT, | 54 | EXTRACTOR_METATYPE_WORD_COUNT, |
59 | EXTRACTOR_METATYPE_PAGE_ORIENTATION, | 55 | EXTRACTOR_METATYPE_PAGE_ORIENTATION, |
60 | EXTRACTOR_METATYPE_PAPER_SIZE, | 56 | EXTRACTOR_METATYPE_PAPER_SIZE, |
61 | EXTRACTOR_METATYPE_TEMPLATE, | 57 | EXTRACTOR_METATYPE_TEMPLATE, |
62 | EXTRACTOR_METATYPE_REVISION_HISTORY, | 58 | EXTRACTOR_METATYPE_REVISION_HISTORY, |
63 | EXTRACTOR_METATYPE_REVISION_NUMBER, | 59 | EXTRACTOR_METATYPE_REVISION_NUMBER, |
64 | #endif | 60 | #endif |
65 | EXTRACTOR_METATYPE_RESERVED | 61 | EXTRACTOR_METATYPE_RESERVED}; |
66 | }; | ||
67 | 62 | ||
68 | 63 | ||
69 | gint types_music[] = | 64 | gint types_music[] = {EXTRACTOR_METATYPE_MIMETYPE, |
70 | { | 65 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, |
71 | EXTRACTOR_METATYPE_MIMETYPE, | 66 | EXTRACTOR_METATYPE_TITLE, |
72 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, | 67 | EXTRACTOR_METATYPE_ARTIST, |
73 | EXTRACTOR_METATYPE_TITLE, | ||
74 | EXTRACTOR_METATYPE_ARTIST, | ||
75 | #if HAVE_EXTRACTOR_H | 68 | #if HAVE_EXTRACTOR_H |
76 | EXTRACTOR_METATYPE_COMPOSER, | 69 | EXTRACTOR_METATYPE_COMPOSER, |
77 | EXTRACTOR_METATYPE_CONDUCTOR, | 70 | EXTRACTOR_METATYPE_CONDUCTOR, |
78 | EXTRACTOR_METATYPE_ALBUM, | 71 | EXTRACTOR_METATYPE_ALBUM, |
79 | EXTRACTOR_METATYPE_DURATION, | 72 | EXTRACTOR_METATYPE_DURATION, |
80 | EXTRACTOR_METATYPE_KEYWORDS, | 73 | EXTRACTOR_METATYPE_KEYWORDS, |
81 | EXTRACTOR_METATYPE_DESCRIPTION, | 74 | EXTRACTOR_METATYPE_DESCRIPTION, |
82 | EXTRACTOR_METATYPE_GENRE, | 75 | EXTRACTOR_METATYPE_GENRE, |
83 | EXTRACTOR_METATYPE_MOOD, | 76 | EXTRACTOR_METATYPE_MOOD, |
84 | EXTRACTOR_METATYPE_TRACK_NUMBER, | 77 | EXTRACTOR_METATYPE_TRACK_NUMBER, |
85 | EXTRACTOR_METATYPE_LANGUAGE, | 78 | EXTRACTOR_METATYPE_LANGUAGE, |
86 | EXTRACTOR_METATYPE_COMMENT, | 79 | EXTRACTOR_METATYPE_COMMENT, |
87 | EXTRACTOR_METATYPE_ISRC, | 80 | EXTRACTOR_METATYPE_ISRC, |
88 | EXTRACTOR_METATYPE_LYRICS, | 81 | EXTRACTOR_METATYPE_LYRICS, |
89 | EXTRACTOR_METATYPE_COPYRIGHT, | 82 | EXTRACTOR_METATYPE_COPYRIGHT, |
90 | EXTRACTOR_METATYPE_PUBLISHER, | 83 | EXTRACTOR_METATYPE_PUBLISHER, |
91 | EXTRACTOR_METATYPE_PERFORMER, | 84 | EXTRACTOR_METATYPE_PERFORMER, |
92 | EXTRACTOR_METATYPE_PRODUCER, | 85 | EXTRACTOR_METATYPE_PRODUCER, |
93 | EXTRACTOR_METATYPE_SONG_VERSION, | 86 | EXTRACTOR_METATYPE_SONG_VERSION, |
94 | EXTRACTOR_METATYPE_URI, | 87 | EXTRACTOR_METATYPE_URI, |
95 | EXTRACTOR_METATYPE_CREATION_DATE, | 88 | EXTRACTOR_METATYPE_CREATION_DATE, |
96 | EXTRACTOR_METATYPE_DISCLAIMER, | 89 | EXTRACTOR_METATYPE_DISCLAIMER, |
97 | EXTRACTOR_METATYPE_WRITER, | 90 | EXTRACTOR_METATYPE_WRITER, |
98 | EXTRACTOR_METATYPE_CONTRIBUTOR_NAME, | 91 | EXTRACTOR_METATYPE_CONTRIBUTOR_NAME, |
99 | EXTRACTOR_METATYPE_SONG_COUNT, | 92 | EXTRACTOR_METATYPE_SONG_COUNT, |
100 | EXTRACTOR_METATYPE_STARTING_SONG, | 93 | EXTRACTOR_METATYPE_STARTING_SONG, |
101 | EXTRACTOR_METATYPE_BEATS_PER_MINUTE, | 94 | EXTRACTOR_METATYPE_BEATS_PER_MINUTE, |
102 | EXTRACTOR_METATYPE_ORIGINAL_TITLE, | 95 | EXTRACTOR_METATYPE_ORIGINAL_TITLE, |
103 | EXTRACTOR_METATYPE_ORIGINAL_ARTIST, | 96 | EXTRACTOR_METATYPE_ORIGINAL_ARTIST, |
104 | EXTRACTOR_METATYPE_ORIGINAL_WRITER, | 97 | EXTRACTOR_METATYPE_ORIGINAL_WRITER, |
105 | EXTRACTOR_METATYPE_ORIGINAL_RELEASE_YEAR, | 98 | EXTRACTOR_METATYPE_ORIGINAL_RELEASE_YEAR, |
106 | EXTRACTOR_METATYPE_ORIGINAL_PERFORMER, | 99 | EXTRACTOR_METATYPE_ORIGINAL_PERFORMER, |
107 | EXTRACTOR_METATYPE_MUSICIAN_CREDITS_LIST, | 100 | EXTRACTOR_METATYPE_MUSICIAN_CREDITS_LIST, |
108 | EXTRACTOR_METATYPE_SUBTITLE, | 101 | EXTRACTOR_METATYPE_SUBTITLE, |
109 | #endif | 102 | #endif |
110 | EXTRACTOR_METATYPE_RESERVED | 103 | EXTRACTOR_METATYPE_RESERVED}; |
111 | }; | ||
112 | 104 | ||
113 | 105 | ||
114 | gint types_video[] = | 106 | gint types_video[] = {EXTRACTOR_METATYPE_MIMETYPE, |
115 | { | 107 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, |
116 | EXTRACTOR_METATYPE_MIMETYPE, | 108 | EXTRACTOR_METATYPE_TITLE, |
117 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, | ||
118 | EXTRACTOR_METATYPE_TITLE, | ||
119 | #if HAVE_EXTRACTOR_H | 109 | #if HAVE_EXTRACTOR_H |
120 | EXTRACTOR_METATYPE_GENRE, | 110 | EXTRACTOR_METATYPE_GENRE, |
121 | EXTRACTOR_METATYPE_KEYWORDS, | 111 | EXTRACTOR_METATYPE_KEYWORDS, |
122 | EXTRACTOR_METATYPE_SUMMARY, | 112 | EXTRACTOR_METATYPE_SUMMARY, |
123 | EXTRACTOR_METATYPE_DESCRIPTION, | 113 | EXTRACTOR_METATYPE_DESCRIPTION, |
124 | EXTRACTOR_METATYPE_DURATION, | 114 | EXTRACTOR_METATYPE_DURATION, |
125 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, | 115 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, |
126 | EXTRACTOR_METATYPE_COMMENT, | 116 | EXTRACTOR_METATYPE_COMMENT, |
127 | EXTRACTOR_METATYPE_CREATOR, | 117 | EXTRACTOR_METATYPE_CREATOR, |
128 | EXTRACTOR_METATYPE_WRITER, | 118 | EXTRACTOR_METATYPE_WRITER, |
129 | EXTRACTOR_METATYPE_MOVIE_DIRECTOR, | 119 | EXTRACTOR_METATYPE_MOVIE_DIRECTOR, |
130 | EXTRACTOR_METATYPE_PRODUCER, | 120 | EXTRACTOR_METATYPE_PRODUCER, |
131 | EXTRACTOR_METATYPE_PUBLISHER, | 121 | EXTRACTOR_METATYPE_PUBLISHER, |
132 | EXTRACTOR_METATYPE_NETWORK_NAME, | 122 | EXTRACTOR_METATYPE_NETWORK_NAME, |
133 | EXTRACTOR_METATYPE_SHOW_NAME, | 123 | EXTRACTOR_METATYPE_SHOW_NAME, |
134 | EXTRACTOR_METATYPE_CHAPTER_NAME, | 124 | EXTRACTOR_METATYPE_CHAPTER_NAME, |
135 | EXTRACTOR_METATYPE_MUSICIAN_CREDITS_LIST, | 125 | EXTRACTOR_METATYPE_MUSICIAN_CREDITS_LIST, |
136 | EXTRACTOR_METATYPE_COPYRIGHT, | 126 | EXTRACTOR_METATYPE_COPYRIGHT, |
137 | EXTRACTOR_METATYPE_URI, | 127 | EXTRACTOR_METATYPE_URI, |
138 | EXTRACTOR_METATYPE_LOCATION_CITY, | 128 | EXTRACTOR_METATYPE_LOCATION_CITY, |
139 | EXTRACTOR_METATYPE_LOCATION_COUNTRY, | 129 | EXTRACTOR_METATYPE_LOCATION_COUNTRY, |
140 | EXTRACTOR_METATYPE_LOCATION_COUNTRY_CODE, | 130 | EXTRACTOR_METATYPE_LOCATION_COUNTRY_CODE, |
141 | EXTRACTOR_METATYPE_CREATION_DATE, | 131 | EXTRACTOR_METATYPE_CREATION_DATE, |
142 | EXTRACTOR_METATYPE_PERFORMER, | 132 | EXTRACTOR_METATYPE_PERFORMER, |
143 | #endif | 133 | #endif |
144 | EXTRACTOR_METATYPE_RESERVED | 134 | EXTRACTOR_METATYPE_RESERVED}; |
145 | }; | ||
146 | 135 | ||
147 | 136 | ||
148 | gint types_image[] = | 137 | gint types_image[] = {EXTRACTOR_METATYPE_MIMETYPE, |
149 | { | 138 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, |
150 | EXTRACTOR_METATYPE_MIMETYPE, | 139 | EXTRACTOR_METATYPE_TITLE, |
151 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, | 140 | EXTRACTOR_METATYPE_KEYWORDS, |
152 | EXTRACTOR_METATYPE_TITLE, | 141 | EXTRACTOR_METATYPE_DESCRIPTION, |
153 | EXTRACTOR_METATYPE_KEYWORDS, | ||
154 | EXTRACTOR_METATYPE_DESCRIPTION, | ||
155 | #if HAVE_EXTRACTOR_H | 142 | #if HAVE_EXTRACTOR_H |
156 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, | 143 | EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, |
157 | EXTRACTOR_METATYPE_IMAGE_RESOLUTION, | 144 | EXTRACTOR_METATYPE_IMAGE_RESOLUTION, |
158 | EXTRACTOR_METATYPE_COMMENT, | 145 | EXTRACTOR_METATYPE_COMMENT, |
159 | EXTRACTOR_METATYPE_COPYRIGHT, | 146 | EXTRACTOR_METATYPE_COPYRIGHT, |
160 | EXTRACTOR_METATYPE_SUBJECT, | 147 | EXTRACTOR_METATYPE_SUBJECT, |
161 | EXTRACTOR_METATYPE_CREATOR, | 148 | EXTRACTOR_METATYPE_CREATOR, |
162 | EXTRACTOR_METATYPE_CREATION_DATE, | 149 | EXTRACTOR_METATYPE_CREATION_DATE, |
163 | EXTRACTOR_METATYPE_URI, | 150 | EXTRACTOR_METATYPE_URI, |
164 | EXTRACTOR_METATYPE_LOCATION_CITY, | 151 | EXTRACTOR_METATYPE_LOCATION_CITY, |
165 | EXTRACTOR_METATYPE_LOCATION_COUNTRY, | 152 | EXTRACTOR_METATYPE_LOCATION_COUNTRY, |
166 | EXTRACTOR_METATYPE_LOCATION_COUNTRY_CODE, | 153 | EXTRACTOR_METATYPE_LOCATION_COUNTRY_CODE, |
167 | EXTRACTOR_METATYPE_ORGANIZATION, | 154 | EXTRACTOR_METATYPE_ORGANIZATION, |
168 | #endif | 155 | #endif |
169 | EXTRACTOR_METATYPE_RESERVED | 156 | EXTRACTOR_METATYPE_RESERVED}; |
170 | }; | ||
171 | 157 | ||
172 | 158 | ||
173 | gint types_namespace[] = | 159 | gint types_namespace[] = {/* Namespace */ |
174 | { /* Namespace */ | 160 | EXTRACTOR_METATYPE_MIMETYPE, |
175 | EXTRACTOR_METATYPE_MIMETYPE, | 161 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, |
176 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, | 162 | EXTRACTOR_METATYPE_COMMENT, |
177 | EXTRACTOR_METATYPE_COMMENT, | 163 | EXTRACTOR_METATYPE_TITLE, |
178 | EXTRACTOR_METATYPE_TITLE, | 164 | EXTRACTOR_METATYPE_DESCRIPTION, |
179 | EXTRACTOR_METATYPE_DESCRIPTION, | ||
180 | #if HAVE_EXTRACTOR_H | 165 | #if HAVE_EXTRACTOR_H |
181 | EXTRACTOR_METATYPE_COPYRIGHT, | 166 | EXTRACTOR_METATYPE_COPYRIGHT, |
182 | EXTRACTOR_METATYPE_RIGHTS, | 167 | EXTRACTOR_METATYPE_RIGHTS, |
183 | EXTRACTOR_METATYPE_KEYWORDS, | 168 | EXTRACTOR_METATYPE_KEYWORDS, |
184 | EXTRACTOR_METATYPE_ABSTRACT, | 169 | EXTRACTOR_METATYPE_ABSTRACT, |
185 | EXTRACTOR_METATYPE_SUMMARY, | 170 | EXTRACTOR_METATYPE_SUMMARY, |
186 | EXTRACTOR_METATYPE_SUBJECT, | 171 | EXTRACTOR_METATYPE_SUBJECT, |
187 | EXTRACTOR_METATYPE_CREATOR, | 172 | EXTRACTOR_METATYPE_CREATOR, |
188 | EXTRACTOR_METATYPE_RATING, | 173 | EXTRACTOR_METATYPE_RATING, |
189 | EXTRACTOR_METATYPE_ORGANIZATION, | 174 | EXTRACTOR_METATYPE_ORGANIZATION, |
190 | EXTRACTOR_METATYPE_RIPPER, | 175 | EXTRACTOR_METATYPE_RIPPER, |
191 | EXTRACTOR_METATYPE_PRODUCER, | 176 | EXTRACTOR_METATYPE_PRODUCER, |
192 | EXTRACTOR_METATYPE_GROUP, | 177 | EXTRACTOR_METATYPE_GROUP, |
193 | #endif | 178 | #endif |
194 | EXTRACTOR_METATYPE_RESERVED | 179 | EXTRACTOR_METATYPE_RESERVED}; |
195 | }; | ||
196 | 180 | ||
197 | 181 | ||
198 | gint types_software[] = | 182 | gint types_software[] = {EXTRACTOR_METATYPE_MIMETYPE, |
199 | { | 183 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, |
200 | EXTRACTOR_METATYPE_MIMETYPE, | 184 | EXTRACTOR_METATYPE_PACKAGE_NAME, |
201 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, | ||
202 | EXTRACTOR_METATYPE_PACKAGE_NAME, | ||
203 | #if HAVE_EXTRACTOR_H | 185 | #if HAVE_EXTRACTOR_H |
204 | EXTRACTOR_METATYPE_PACKAGE_VERSION, | 186 | EXTRACTOR_METATYPE_PACKAGE_VERSION, |
205 | EXTRACTOR_METATYPE_TARGET_ARCHITECTURE, | 187 | EXTRACTOR_METATYPE_TARGET_ARCHITECTURE, |
206 | EXTRACTOR_METATYPE_LICENSE, | 188 | EXTRACTOR_METATYPE_LICENSE, |
207 | EXTRACTOR_METATYPE_TARGET_OS, | 189 | EXTRACTOR_METATYPE_TARGET_OS, |
208 | EXTRACTOR_METATYPE_COMMENT, | 190 | EXTRACTOR_METATYPE_COMMENT, |
209 | EXTRACTOR_METATYPE_SECTION, | 191 | EXTRACTOR_METATYPE_SECTION, |
210 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, | 192 | EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY, |
211 | EXTRACTOR_METATYPE_PACKAGE_CONFLICTS, | 193 | EXTRACTOR_METATYPE_PACKAGE_CONFLICTS, |
212 | EXTRACTOR_METATYPE_PACKAGE_REPLACES, | 194 | EXTRACTOR_METATYPE_PACKAGE_REPLACES, |
213 | EXTRACTOR_METATYPE_PACKAGE_PROVIDES, | 195 | EXTRACTOR_METATYPE_PACKAGE_PROVIDES, |
214 | EXTRACTOR_METATYPE_PACKAGE_RECOMMENDS, | 196 | EXTRACTOR_METATYPE_PACKAGE_RECOMMENDS, |
215 | EXTRACTOR_METATYPE_PACKAGE_SUGGESTS, | 197 | EXTRACTOR_METATYPE_PACKAGE_SUGGESTS, |
216 | EXTRACTOR_METATYPE_PACKAGE_MAINTAINER, | 198 | EXTRACTOR_METATYPE_PACKAGE_MAINTAINER, |
217 | EXTRACTOR_METATYPE_PACKAGE_INSTALLED_SIZE, | 199 | EXTRACTOR_METATYPE_PACKAGE_INSTALLED_SIZE, |
218 | EXTRACTOR_METATYPE_PACKAGE_SOURCE, | 200 | EXTRACTOR_METATYPE_PACKAGE_SOURCE, |
219 | EXTRACTOR_METATYPE_PACKAGE_ESSENTIAL, | 201 | EXTRACTOR_METATYPE_PACKAGE_ESSENTIAL, |
220 | EXTRACTOR_METATYPE_PACKAGE_PRE_DEPENDENCY, | 202 | EXTRACTOR_METATYPE_PACKAGE_PRE_DEPENDENCY, |
221 | EXTRACTOR_METATYPE_PACKAGE_DISTRIBUTION, | 203 | EXTRACTOR_METATYPE_PACKAGE_DISTRIBUTION, |
222 | EXTRACTOR_METATYPE_BUILDHOST, | 204 | EXTRACTOR_METATYPE_BUILDHOST, |
223 | EXTRACTOR_METATYPE_VENDOR, | 205 | EXTRACTOR_METATYPE_VENDOR, |
224 | EXTRACTOR_METATYPE_SOFTWARE_VERSION, | 206 | EXTRACTOR_METATYPE_SOFTWARE_VERSION, |
225 | EXTRACTOR_METATYPE_TARGET_PLATFORM, | 207 | EXTRACTOR_METATYPE_TARGET_PLATFORM, |
226 | EXTRACTOR_METATYPE_RESOURCE_TYPE, | 208 | EXTRACTOR_METATYPE_RESOURCE_TYPE, |
227 | EXTRACTOR_METATYPE_LIBRARY_SEARCH_PATH, | 209 | EXTRACTOR_METATYPE_LIBRARY_SEARCH_PATH, |
228 | EXTRACTOR_METATYPE_LIBRARY_DEPENDENCY, | 210 | EXTRACTOR_METATYPE_LIBRARY_DEPENDENCY, |
229 | EXTRACTOR_METATYPE_UPLOAD_PRIORITY, | 211 | EXTRACTOR_METATYPE_UPLOAD_PRIORITY, |
230 | #endif | 212 | #endif |
231 | EXTRACTOR_METATYPE_RESERVED | 213 | EXTRACTOR_METATYPE_RESERVED}; |
232 | }; | ||
233 | 214 | ||
234 | 215 | ||
235 | /** | 216 | /** |
@@ -237,15 +218,13 @@ gint types_software[] = | |||
237 | * FIXME-FEATURE-UNCLEAN-MAYBE: should probably move that name list in | 218 | * FIXME-FEATURE-UNCLEAN-MAYBE: should probably move that name list in |
238 | * here and only have one place for both... | 219 | * here and only have one place for both... |
239 | */ | 220 | */ |
240 | gint *types[] = { | 221 | gint *types[] = {types_generic, |
241 | types_generic, | 222 | types_text, |
242 | types_text, | 223 | types_music, |
243 | types_music, | 224 | types_video, |
244 | types_video, | 225 | types_image, |
245 | types_image, | 226 | types_software, |
246 | types_software, | 227 | types_namespace, |
247 | types_namespace, | 228 | NULL}; |
248 | NULL | ||
249 | }; | ||
250 | 229 | ||
251 | /* *INDENT-ON* */ | 230 | /* *INDENT-ON* */ |