1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
|
/*
This file is part of GNUnet
(C) 2011, 2012, 2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/**
* @file src/fs/gnunet-fs-gtk_main-window-search.c
* @author Christian Grothoff
* @brief event handlers for the search function in the main window
*/
#include "gnunet-fs-gtk_common.h"
#include "gnunet-fs-gtk.h"
#include "gnunet-fs-gtk_anonymity-widgets.h"
#include <gnunet/gnunet_gnsrecord_lib.h>
/**
* How long until we decide a SKS namespace GNS lookup has failed?
*/
#define LOOKUP_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2)
/**
* Start a search.
*
* @param uri uri to search for, freed in this function
* @param anonymity_level degree of anonymity to apply for the search
*/
static void
search_for_uri (struct GNUNET_FS_Uri *uri,
guint anonymity_level)
{
GNUNET_FS_search_start (GNUNET_FS_GTK_get_fs_handle (),
uri, anonymity_level,
GNUNET_FS_SEARCH_OPTION_NONE, NULL);
GNUNET_FS_uri_destroy (uri);
}
/**
* Abort the given search lookup.
*
* @param sl lookup to abort.
*/
void
abort_search_lookup (struct SearchLookup *sl)
{
struct GNUNET_GTK_MainWindowContext *main_ctx = GNUNET_FS_GTK_get_main_context ();
GNUNET_CONTAINER_DLL_remove (main_ctx->sl_head,
main_ctx->sl_tail,
sl);
if (GNUNET_SCHEDULER_NO_TASK != sl->timeout_task)
{
GNUNET_SCHEDULER_cancel (sl->timeout_task);
sl->timeout_task = GNUNET_SCHEDULER_NO_TASK;
}
if (NULL != sl->gns)
{
GNUNET_GNS_lookup_cancel (sl->gns);
sl->gns = NULL;
}
g_free (sl->keywords);
GNUNET_free (sl);
}
/**
* Task run when the GNS timeout during the resolution of
* the GNS namespace times out.
*
* @param cls the 'struct SearchLookup'
* @param tc scheduler context
*/
static void
timeout_search_lookup (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct SearchLookup *sl = cls;
sl->timeout_task = GNUNET_SCHEDULER_NO_TASK;
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Failed to resolve namespace in time\n"));
abort_search_lookup (sl);
}
/**
* Iterator called on obtained result for a GNS lookup for
* the public key of a namespace identifier.
*
* @param cls closure
* @param rd_count number of records in @a rd
* @param rd the records in reply
*/
static void
handle_gns_result (void *cls,
uint32_t rd_count,
const struct GNUNET_NAMESTORE_RecordData *rd)
{
struct SearchLookup *sl = cls;
unsigned int i;
struct GNUNET_FS_Uri *uri;
sl->gns = NULL;
for (i=0;i<rd_count;i++)
{
if (GNUNET_GNSRECORD_TYPE_PKEY != rd[i].record_type)
continue;
if (sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) != rd[i].data_size)
{
GNUNET_break_op (0);
continue;
}
uri = GNUNET_FS_uri_sks_create (rd[i].data, sl->keywords);
search_for_uri (uri, sl->anonymity_level);
abort_search_lookup (sl);
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Failed to resolve namespace in time\n"));
abort_search_lookup (sl);
}
/**
* Start a search.
*
* @param main_ctx the main window context
*/
static void
start_search (struct GNUNET_GTK_MainWindowContext *main_ctx)
{
guint anonymity_level;
gchar *keywords;
gchar *mime_keyword;
const char *nsid;
struct GNUNET_FS_Uri *uri;
struct GNUNET_CRYPTO_EcdsaPublicKey pub_sks_zone;
struct SearchLookup *sl;
char *emsg;
/* get anonymity level */
if (!GNUNET_GTK_get_selected_anonymity_level
(main_ctx->builder, "main_window_search_anonymity_combobox", &anonymity_level))
{
GNUNET_break (0);
return;
}
/* get selected mime type */
{
GtkComboBox *mime_combo;
GtkTreeModel *mime_model;
GtkTreeIter iter;
mime_combo = GTK_COMBO_BOX (GNUNET_FS_GTK_get_main_window_object
("main_window_search_mime_combobox"));
mime_model = gtk_combo_box_get_model (mime_combo);
mime_keyword = NULL;
if ( (NULL != mime_model) &&
gtk_combo_box_get_active_iter (mime_combo, &iter))
gtk_tree_model_get (mime_model, &iter,
GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_MIME_MC_MIME,
&mime_keyword,
-1);
if ( (NULL != mime_keyword) &&
(0 == strcmp (mime_keyword, " ")) )
{
g_free (mime_keyword);
mime_keyword = NULL;
}
}
{
GtkComboBox *namespace_box;
namespace_box = GTK_COMBO_BOX (GNUNET_FS_GTK_get_main_window_object ("main_window_search_namespace_combobox"));
nsid = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (namespace_box))));
if ( (NULL != nsid) &&
( (0 == strcasecmp (nsid,
"<none>")) ||
(0 == strcasecmp (nsid,
_("<none>"))) ) )
nsid = NULL;
}
/* get keywords and compose keyword string */
{
const char *entry_keywords;
entry_keywords = gtk_entry_get_text (main_ctx->search_entry);
if (NULL != mime_keyword)
{
keywords = g_strdup_printf ("%s +%s",
entry_keywords,
mime_keyword);
g_free (mime_keyword);
}
else
{
keywords = g_strdup (entry_keywords);
}
}
/* build KSK/SKS URI */
if ( (NULL != nsid) &&
(0 < strlen (nsid)) )
{
sl = GNUNET_new (struct SearchLookup);
sl->keywords = keywords;
sl->anonymity_level = anonymity_level;
sl->timeout_task = GNUNET_SCHEDULER_add_delayed (LOOKUP_TIMEOUT,
&timeout_search_lookup, sl);
GNUNET_CRYPTO_ecdsa_key_get_public (main_ctx->sks_zone,
&pub_sks_zone);
sl->gns = GNUNET_GNS_lookup (main_ctx->gns,
nsid,
&pub_sks_zone,
GNUNET_GNSRECORD_TYPE_PKEY,
GNUNET_NO,
NULL /* no shortening */,
&handle_gns_result,
sl);
GNUNET_CONTAINER_DLL_insert (main_ctx->sl_head,
main_ctx->sl_tail,
sl);
return;
}
emsg = NULL;
uri = GNUNET_FS_uri_ksk_create (keywords, &emsg);
if (NULL == uri)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Invalid keyword string `%s': %s"),
keywords, emsg);
g_free (keywords);
GNUNET_free_non_null (emsg);
return;
}
g_free (keywords);
search_for_uri (uri, anonymity_level);
}
/**
* User clicked on the 'search' button in the main window.
*
* @param button the search button
* @param user_data the main window context builder
*/
void
main_window_search_button_clicked_cb (GtkButton * button,
gpointer user_data)
{
struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
start_search (main_ctx);
}
/**
* User pushed a key (possibly ENTER) in the search entry widget.
* Start the search if it was ENTER.
*
* @param widget the entry widget
* @param event the key stroke
* @param user_data the main window context
* @return FALSE if this was not ENTER, TRUE if it was
*/
gboolean
main_window_search_entry_key_press_event_cb (GtkWidget * widget,
GdkEventKey * event,
gpointer user_data)
{
struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
if (event->keyval == GDK_KEY_Return)
{
start_search (main_ctx);
return TRUE;
}
return FALSE;
}
/**
* Asynchronously clean up PseuLookupContext.
*
* @param cls the `struct PseuLookupContext` to clean up.
* @param tc scheduler context
*/
static void
end_pseu_lookup (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct PseuLookupContext *lctx = cls;
if (NULL != lctx->progress_dialog_builder)
{
gtk_widget_destroy (lctx->progress_dialog);
g_object_unref (G_OBJECT (lctx->progress_dialog_builder));
lctx->progress_dialog_builder = NULL;
}
if (NULL != lctx->nick_dialog_builder)
{
gtk_widget_destroy (lctx->nick_dialog);
g_object_unref (G_OBJECT (lctx->nick_dialog_builder));
lctx->nick_dialog_builder = NULL;
}
if (NULL != lctx->lr)
{
GNUNET_GNS_lookup_cancel (lctx->lr);
lctx->lr = NULL;
}
if (NULL != lctx->qe)
{
GNUNET_NAMESTORE_cancel (lctx->qe);
lctx->qe = NULL;
}
if (NULL != lctx->namestore)
{
GNUNET_NAMESTORE_disconnect (lctx->namestore);
lctx->namestore = NULL;
}
GNUNET_free_non_null (lctx->nick);
GNUNET_free (lctx);
}
/**
* Abort the given PSEU lookup.
*
* @param lctx lookup to abort.
*/
void
abort_pseu_lookup (struct PseuLookupContext *lctx)
{
struct GNUNET_GTK_MainWindowContext *main_ctx = lctx->main_ctx;
GNUNET_CONTAINER_DLL_remove (main_ctx->lctx_head,
main_ctx->lctx_tail,
lctx);
(void) GNUNET_SCHEDULER_add_now (&end_pseu_lookup,
lctx);
}
/**
* Continuation called to notify client about result of the
* operation.
*
* @param cls closure
* @param success #GNUNET_SYSERR on failure (including timeout/queue drop/failure to validate)
* #GNUNET_NO if content was already there or not found
* #GNUNET_YES (or other positive value) on success
* @param emsg NULL on success, otherwise an error message
*/
static void
store_continuation (void *cls,
int32_t success,
const char *emsg)
{
struct PseuLookupContext *lctx = cls;
lctx->qe = NULL;
if (NULL != emsg)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Failed to save record: %s\n"),
emsg);
gdk_beep ();
}
abort_pseu_lookup (lctx);
}
/**
* Save the namespace under the given nickname.
*
* @param lctx namespace request we are processing
* @param nick nickname to store the namespace under
*/
static void
save_pseudonym_with_nick (struct PseuLookupContext *lctx,
const char *nick)
{
struct GNUNET_NAMESTORE_RecordData rd;
struct GNUNET_GTK_MainWindowContext *main_ctx;
GNUNET_break (NULL == lctx->nick);
lctx->nick = GNUNET_strdup (nick);
/* again, show progress indicator, this should be fast though... */
lctx->progress_dialog_builder
= GNUNET_GTK_get_new_builder
("gnunet_fs_gtk_pseu_progress_dialog.glade",
lctx);
lctx->progress_dialog
= GTK_WIDGET (gtk_builder_get_object
(lctx->progress_dialog_builder,
"GNUNET_FS_GTK_pseu_progress_dialog"));
/* show the window */
gtk_window_present (GTK_WINDOW (lctx->progress_dialog));
memset (&rd, 0, sizeof (rd));
rd.data_size = sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey);
rd.data = &lctx->pkey;
rd.flags = GNUNET_NAMESTORE_RF_PRIVATE;
rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
rd.record_type = GNUNET_GNSRECORD_TYPE_PKEY;
main_ctx = GNUNET_FS_GTK_get_main_context ();
lctx->namestore = GNUNET_NAMESTORE_connect (main_ctx->cfg);
GNUNET_assert (NULL != lctx->namestore);
lctx->qe = GNUNET_NAMESTORE_records_store (lctx->namestore,
main_ctx->sks_zone,
nick,
1, &rd,
&store_continuation, lctx);
}
/**
* User clicked on the 'execute' button in nickname dialog.
* Store the selected namespace in the "sks-fs" zone under
* the given nickname.
*
* @param button the "execute" button
* @param user_data the `struct PseuLookupContext`
*/
void
GNUNET_GTK_enter_nick_window_execute_button_clicked_cb (GtkButton * button,
gpointer user_data)
{
struct PseuLookupContext *lctx = user_data;
GtkEntry *entry;
const char *nick;
entry = GTK_ENTRY (gtk_builder_get_object
(lctx->nick_dialog_builder,
"GNUNET_GTK_enter_nick_window_nick_entry"));
nick = gtk_entry_get_text (entry);
if ( (NULL == nick) ||
(0 == strlen (nick) ))
{
GNUNET_break (0);
abort_pseu_lookup (lctx);
return;
}
save_pseudonym_with_nick (lctx, nick);
gtk_widget_destroy (lctx->nick_dialog);
g_object_unref (G_OBJECT (lctx->nick_dialog_builder));
lctx->nick_dialog_builder = NULL;
lctx->nick_dialog = NULL;
}
/**
* User edited the nickname. Update sensitivity of the execute button.
*
* @param widget the entry that was changed
* @param user_data the `struct PseuLookupContext`
*/
void
GNUNET_GTK_enter_nick_window_nick_entry_changed_cb (GtkWidget *widget,
gpointer user_data)
{
struct PseuLookupContext *lctx = user_data;
const gchar *new_text;
GtkButton * button;
new_text = gtk_entry_get_text (GTK_ENTRY (widget));
button = GTK_BUTTON (gtk_builder_get_object (lctx->nick_dialog_builder,
"GNUNET_GTK_enter_nick_window_execute_button"));
gtk_widget_set_sensitive (GTK_WIDGET (button),
(GNUNET_OK == GNUNET_DNSPARSER_check_label (new_text)) ? TRUE : FALSE);
}
/**
* User clicked on the 'cancel' button in nickname dialog.
* Abort the operation.
*
* @param button the "cancel" button
* @param user_data the `struct PseuLookupContext`
*/
void
GNUNET_GTK_enter_nick_window_cancel_button_clicked_cb (GtkButton * button,
gpointer user_data)
{
struct PseuLookupContext *lctx = user_data;
abort_pseu_lookup (lctx);
}
/**
* Run the dialog asking the user to specify a nickname for
* the namespace.
*
* @param lctx namespace request we are processing
*/
static void
ask_for_nickname (struct PseuLookupContext *lctx)
{
/* setup the dialog and get the widgets we need most */
lctx->nick_dialog_builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_enter_nick_dialog.glade",
lctx);
lctx->nick_dialog = GTK_WIDGET (gtk_builder_get_object (lctx->nick_dialog_builder,
"GNUNET_GTK_enter_nick_window"));
/* show the window */
gtk_window_present (GTK_WINDOW (lctx->nick_dialog));
}
/**
* Iterator called on obtained result for a GNS lookup for
* the PSEU lookup when "saving" a zone. The actual saving
* should already have happened via the shortening of GNS,
* so we only need to clean up.
*
* @param cls closure with the `struct PseuLookupContext`
* @param rd_count number of records in @a rd
* @param rd the records in reply
*/
static void
lookup_finished (void *cls,
uint32_t rd_count,
const struct GNUNET_NAMESTORE_RecordData *rd)
{
struct PseuLookupContext *lctx = cls;
unsigned int i;
const char *nick;
lctx->lr = NULL;
if (NULL != lctx->progress_dialog_builder)
{
gtk_widget_destroy (lctx->progress_dialog);
g_object_unref (G_OBJECT (lctx->progress_dialog_builder));
lctx->progress_dialog_builder = NULL;
lctx->progress_dialog = NULL;
}
for (i=0;i<rd_count;i++)
{
if (GNUNET_GNSRECORD_TYPE_PSEU == rd[i].record_type)
{
nick = rd[i].data;
if ('\0' != nick[rd[i].data_size - 1])
{
GNUNET_break (0);
continue;
}
save_pseudonym_with_nick (lctx,
nick);
return;
}
}
/* no valid PSEU record found */
ask_for_nickname (lctx);
}
/**
* User clicked on the 'cancel' button of the progress dialog.
* Cancel the operation.
*
* @param button the cancel button
* @param user_data the `struct PseuLookupContext` of our window
*/
void
GNUNET_FS_GTK_pseu_progress_dialog_cancel_button_clicked_cb (GtkButton *button,
gpointer user_data)
{
struct PseuLookupContext *lctx = user_data;
if (NULL != lctx->progress_dialog_builder)
{
gtk_widget_destroy (lctx->progress_dialog);
g_object_unref (G_OBJECT (lctx->progress_dialog_builder));
lctx->progress_dialog_builder = NULL;
lctx->progress_dialog = NULL;
}
if (NULL != lctx->nick)
abort_pseu_lookup (lctx);
else
ask_for_nickname (lctx);
}
/**
* User attempted to close the nick dialog. Refuse.
*
* @param widget the widget emitting the event
* @param event the event
* @param cls progress dialog context of our window
* @return TRUE to refuse to close
*/
gboolean
GNUNET_GTK_enter_nick_window_delete_event_cb (GtkWidget *widget,
GdkEvent * event,
void *cls)
{
/* Don't allow GTK to kill the window, user must click execute or cancel */
gdk_beep ();
return TRUE;
}
/**
* User attempted to close the progress dialog. Refuse.
*
* @param widget the widget emitting the event
* @param event the event
* @param cls progress dialog context of our window
* @return TRUE to refuse to close
*/
gboolean
GNUNET_FS_GTK_pseu_progress_dialog_delete_event_cb (GtkWidget *widget,
GdkEvent * event,
void *cls)
{
/* Don't allow GTK to kill the window, until the search is finished */
gdk_beep ();
return TRUE;
}
/**
* User clicked on the 'save' button in the search line of the main window.
* Store the selected namespace in the "sks-fs" zone.
*
* @param button the "save" button
* @param user_data the main window context builder
*/
void
GNUNET_FS_GTK_save_button_clicked_cb (GtkButton * button,
gpointer user_data)
{
struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
GtkComboBox *widget;
const gchar *text;
struct GNUNET_CRYPTO_EcdsaPublicKey pkey;
int ret;
struct PseuLookupContext *lctx;
guint anonymity_level;
if (NULL == main_ctx->gns)
{
GNUNET_break (0);
return;
}
/* get anonymity level */
if (!GNUNET_GTK_get_selected_anonymity_level
(main_ctx->builder, "main_window_search_anonymity_combobox", &anonymity_level))
{
GNUNET_break (0);
return;
}
widget = GTK_COMBO_BOX (GNUNET_FS_GTK_get_main_window_object
("main_window_search_namespace_combobox"));
text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (widget))));
ret = GNUNET_NAMESTORE_zkey_to_pkey (text, &pkey);
if (GNUNET_OK != ret)
{
GNUNET_break (0);
return;
}
lctx = GNUNET_new (struct PseuLookupContext);
lctx->pkey = pkey;
lctx->main_ctx = main_ctx;
GNUNET_CONTAINER_DLL_insert (main_ctx->lctx_head,
main_ctx->lctx_tail,
lctx);
if (0 == anonymity_level)
{
/* setup the dialog and get the widgets we need most */
lctx->progress_dialog_builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_pseu_progress_dialog.glade",
lctx);
lctx->progress_dialog = GTK_WIDGET (gtk_builder_get_object (lctx->progress_dialog_builder,
"GNUNET_FS_GTK_pseu_progress_dialog"));
/* show the window */
gtk_window_present (GTK_WINDOW (lctx->progress_dialog));
lctx->lr = GNUNET_GNS_lookup (main_ctx->gns,
GNUNET_GNS_MASTERZONE_STR,
&pkey,
GNUNET_GNSRECORD_TYPE_PSEU,
GNUNET_NO,
NULL,
&lookup_finished,
lctx);
}
else
{
/* anonymous operation; cannot use GNS/DHT, so user
must make a suggestion himself */
ask_for_nickname (lctx);
}
/* do not allow save again just yet */
gtk_widget_set_sensitive (GTK_WIDGET (button),
FALSE);
}
/**
* The user has somehow changed the selectionin the namespace combo box entry.
* Update the visibility of the "save" button.
*
* @param widget the combo box
* @param user_data the main window context builder (unused)
*/
void
main_window_search_namespace_combobox_changed_cb (GtkComboBox *widget,
gpointer user_data)
{
GtkButton *button;
const gchar *text;
struct GNUNET_CRYPTO_EcdsaPublicKey pkey;
int ret;
text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (widget))));
ret = GNUNET_NAMESTORE_zkey_to_pkey (text, &pkey);
button = GTK_BUTTON (GNUNET_FS_GTK_get_main_window_object
("GNUNET_FS_GTK_save_button"));
gtk_widget_set_visible (GTK_WIDGET (button),
(GNUNET_OK == ret) ? TRUE : FALSE);
gtk_widget_set_sensitive (GTK_WIDGET (button),
(GNUNET_OK == ret) ? TRUE : FALSE);
}
/* end of gnunet-fs-gtk_main-window-search.c */
|