diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-12-16 18:58:07 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-12-16 18:58:07 +0000 |
commit | a3c07ab17860c74cce2e192a387fe1d1ff12de78 (patch) | |
tree | ed360a0465fafd04d1a8a53b785c52b7a57b1f36 | |
parent | e8592b4424a075c8301f8c78520a86c4cf51071e (diff) | |
download | gnunet-gtk-a3c07ab17860c74cce2e192a387fe1d1ff12de78.tar.gz gnunet-gtk-a3c07ab17860c74cce2e192a387fe1d1ff12de78.zip |
LRN: [PATCH 1/2] Multiple GUI changes (#1759)
* Rename "Key" column to "Root"
* Make namespace selector focusable
* Namespace selector now tracks mouse pointer
* Namespace is chosen by a single click
* Namespace list is populated by namespace descovery callback
instead of namespace list callback
(adds found namespaces on the fly)
* Normalized cell background for search results
Now rows look like they have uniform background
* Add tooltips with full query text to search tab
* Root is added to the query when a search in namespace is made
-rw-r--r-- | contrib/gnunet_fs_gtk_main_window.glade | 90 | ||||
-rw-r--r-- | contrib/gnunet_fs_gtk_search_tab.glade | 5 | ||||
-rw-r--r-- | src/fs/gnunet-fs-gtk-event_handler.c | 1 | ||||
-rw-r--r-- | src/fs/gnunet-fs-gtk.c | 138 |
4 files changed, 172 insertions, 62 deletions
diff --git a/contrib/gnunet_fs_gtk_main_window.glade b/contrib/gnunet_fs_gtk_main_window.glade index ac572bb2..5183ba9c 100644 --- a/contrib/gnunet_fs_gtk_main_window.glade +++ b/contrib/gnunet_fs_gtk_main_window.glade | |||
@@ -676,38 +676,6 @@ | |||
676 | <column type="gchararray"/> | 676 | <column type="gchararray"/> |
677 | </columns> | 677 | </columns> |
678 | </object> | 678 | </object> |
679 | <object class="GtkAdjustment" id="adjustment1"> | ||
680 | <property name="upper">100</property> | ||
681 | <property name="step_increment">1</property> | ||
682 | <property name="page_increment">10</property> | ||
683 | <property name="page_size">10</property> | ||
684 | </object> | ||
685 | <object class="GtkAdjustment" id="adjustment2"> | ||
686 | <property name="upper">100</property> | ||
687 | <property name="step_increment">1</property> | ||
688 | <property name="page_increment">10</property> | ||
689 | <property name="page_size">10</property> | ||
690 | </object> | ||
691 | <object class="GtkImage" id="image3"> | ||
692 | <property name="visible">True</property> | ||
693 | <property name="can_focus">False</property> | ||
694 | <property name="stock">gtk-new</property> | ||
695 | </object> | ||
696 | <object class="GtkImage" id="image4"> | ||
697 | <property name="visible">True</property> | ||
698 | <property name="can_focus">False</property> | ||
699 | <property name="stock">gtk-find</property> | ||
700 | </object> | ||
701 | <object class="GtkImage" id="image5"> | ||
702 | <property name="visible">True</property> | ||
703 | <property name="can_focus">False</property> | ||
704 | <property name="stock">gtk-go-down</property> | ||
705 | </object> | ||
706 | <object class="GtkImage" id="image6"> | ||
707 | <property name="visible">True</property> | ||
708 | <property name="can_focus">False</property> | ||
709 | <property name="stock">gtk-index</property> | ||
710 | </object> | ||
711 | <object class="GtkListStore" id="GNUNET_GTK_peer_info_list_store"> | 679 | <object class="GtkListStore" id="GNUNET_GTK_peer_info_list_store"> |
712 | <columns> | 680 | <columns> |
713 | <!-- column-name peer_identity --> | 681 | <!-- column-name peer_identity --> |
@@ -722,6 +690,18 @@ | |||
722 | <column type="guint64"/> | 690 | <column type="guint64"/> |
723 | </columns> | 691 | </columns> |
724 | </object> | 692 | </object> |
693 | <object class="GtkAdjustment" id="adjustment1"> | ||
694 | <property name="upper">100</property> | ||
695 | <property name="step_increment">1</property> | ||
696 | <property name="page_increment">10</property> | ||
697 | <property name="page_size">10</property> | ||
698 | </object> | ||
699 | <object class="GtkAdjustment" id="adjustment2"> | ||
700 | <property name="upper">100</property> | ||
701 | <property name="step_increment">1</property> | ||
702 | <property name="page_increment">10</property> | ||
703 | <property name="page_size">10</property> | ||
704 | </object> | ||
725 | <object class="GtkAdjustment" id="adjustment3"> | 705 | <object class="GtkAdjustment" id="adjustment3"> |
726 | <property name="upper">100</property> | 706 | <property name="upper">100</property> |
727 | <property name="step_increment">1</property> | 707 | <property name="step_increment">1</property> |
@@ -744,6 +724,26 @@ | |||
744 | <property name="can_focus">False</property> | 724 | <property name="can_focus">False</property> |
745 | <property name="stock">gtk-go-up</property> | 725 | <property name="stock">gtk-go-up</property> |
746 | </object> | 726 | </object> |
727 | <object class="GtkImage" id="image3"> | ||
728 | <property name="visible">True</property> | ||
729 | <property name="can_focus">False</property> | ||
730 | <property name="stock">gtk-new</property> | ||
731 | </object> | ||
732 | <object class="GtkImage" id="image4"> | ||
733 | <property name="visible">True</property> | ||
734 | <property name="can_focus">False</property> | ||
735 | <property name="stock">gtk-find</property> | ||
736 | </object> | ||
737 | <object class="GtkImage" id="image5"> | ||
738 | <property name="visible">True</property> | ||
739 | <property name="can_focus">False</property> | ||
740 | <property name="stock">gtk-go-down</property> | ||
741 | </object> | ||
742 | <object class="GtkImage" id="image6"> | ||
743 | <property name="visible">True</property> | ||
744 | <property name="can_focus">False</property> | ||
745 | <property name="stock">gtk-index</property> | ||
746 | </object> | ||
747 | <object class="GtkImage" id="image7"> | 747 | <object class="GtkImage" id="image7"> |
748 | <property name="visible">True</property> | 748 | <property name="visible">True</property> |
749 | <property name="can_focus">False</property> | 749 | <property name="can_focus">False</property> |
@@ -786,6 +786,14 @@ | |||
786 | </row> | 786 | </row> |
787 | </data> | 787 | </data> |
788 | </object> | 788 | </object> |
789 | <object class="GtkSizeGroup" id="enties_and_comboboxes_sizegroup"> | ||
790 | <property name="mode">vertical</property> | ||
791 | <widgets> | ||
792 | <widget name="main_window_search_entry"/> | ||
793 | <widget name="main_window_search_anonymity_combobox"/> | ||
794 | <widget name="main_window_search_mime_combobox"/> | ||
795 | </widgets> | ||
796 | </object> | ||
789 | <object class="GtkListStore" id="main_window_search_mime_liststore"> | 797 | <object class="GtkListStore" id="main_window_search_mime_liststore"> |
790 | <columns> | 798 | <columns> |
791 | <!-- column-name MIME --> | 799 | <!-- column-name MIME --> |
@@ -830,21 +838,13 @@ | |||
830 | </row> | 838 | </row> |
831 | </data> | 839 | </data> |
832 | </object> | 840 | </object> |
833 | <object class="GtkSizeGroup" id="enties_and_comboboxes_sizegroup"> | ||
834 | <property name="mode">vertical</property> | ||
835 | <widgets> | ||
836 | <widget name="main_window_search_entry"/> | ||
837 | <widget name="main_window_search_anonymity_combobox"/> | ||
838 | <widget name="main_window_search_mime_combobox"/> | ||
839 | </widgets> | ||
840 | </object> | ||
841 | <object class="GtkTreeStore" id="main_window_search_namespace_treestore"> | 841 | <object class="GtkTreeStore" id="main_window_search_namespace_treestore"> |
842 | <columns> | 842 | <columns> |
843 | <!-- column-name Name --> | 843 | <!-- column-name Name --> |
844 | <column type="gchararray"/> | 844 | <column type="gchararray"/> |
845 | <!-- column-name Key --> | 845 | <!-- column-name Key --> |
846 | <column type="gpointer"/> | 846 | <column type="gpointer"/> |
847 | <!-- column-name KeyTextual --> | 847 | <!-- column-name Root --> |
848 | <column type="gchararray"/> | 848 | <column type="gchararray"/> |
849 | <!-- column-name Tooltip --> | 849 | <!-- column-name Tooltip --> |
850 | <column type="gchararray"/> | 850 | <column type="gchararray"/> |
@@ -853,7 +853,6 @@ | |||
853 | <object class="GtkWindow" id="namespace_selector_window"> | 853 | <object class="GtkWindow" id="namespace_selector_window"> |
854 | <property name="can_focus">False</property> | 854 | <property name="can_focus">False</property> |
855 | <property name="events">GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK</property> | 855 | <property name="events">GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK</property> |
856 | <property name="type">popup</property> | ||
857 | <property name="resizable">False</property> | 856 | <property name="resizable">False</property> |
858 | <property name="type_hint">dropdown-menu</property> | 857 | <property name="type_hint">dropdown-menu</property> |
859 | <property name="skip_taskbar_hint">True</property> | 858 | <property name="skip_taskbar_hint">True</property> |
@@ -869,12 +868,15 @@ | |||
869 | <object class="GtkTreeView" id="namespace_selector_treeview"> | 868 | <object class="GtkTreeView" id="namespace_selector_treeview"> |
870 | <property name="visible">True</property> | 869 | <property name="visible">True</property> |
871 | <property name="can_focus">True</property> | 870 | <property name="can_focus">True</property> |
871 | <property name="is_focus">True</property> | ||
872 | <property name="model">main_window_search_namespace_treestore</property> | 872 | <property name="model">main_window_search_namespace_treestore</property> |
873 | <property name="headers_clickable">False</property> | 873 | <property name="headers_clickable">False</property> |
874 | <property name="search_column">0</property> | 874 | <property name="search_column">0</property> |
875 | <property name="hover_selection">True</property> | ||
875 | <property name="hover_expand">True</property> | 876 | <property name="hover_expand">True</property> |
876 | <property name="tooltip_column">3</property> | 877 | <property name="tooltip_column">3</property> |
877 | <signal name="cursor-changed" handler="namespace_selector_treeview_cursor_changed_cb" swapped="no"/> | 878 | <signal name="button-press-event" handler="namespace_selector_treeview_button_press_event_cb" swapped="no"/> |
879 | <signal name="button-release-event" handler="namespace_selector_treeview_button_release_event_cb" swapped="no"/> | ||
878 | <child> | 880 | <child> |
879 | <object class="GtkTreeViewColumn" id="name_column"> | 881 | <object class="GtkTreeViewColumn" id="name_column"> |
880 | <property name="sizing">autosize</property> | 882 | <property name="sizing">autosize</property> |
@@ -890,7 +892,7 @@ | |||
890 | <child> | 892 | <child> |
891 | <object class="GtkTreeViewColumn" id="key_column"> | 893 | <object class="GtkTreeViewColumn" id="key_column"> |
892 | <property name="sizing">autosize</property> | 894 | <property name="sizing">autosize</property> |
893 | <property name="title" translatable="yes">Key</property> | 895 | <property name="title" translatable="yes">Root</property> |
894 | <child> | 896 | <child> |
895 | <object class="GtkCellRendererText" id="namespace_selector_key_column_text_cell"/> | 897 | <object class="GtkCellRendererText" id="namespace_selector_key_column_text_cell"/> |
896 | <attributes> | 898 | <attributes> |
diff --git a/contrib/gnunet_fs_gtk_search_tab.glade b/contrib/gnunet_fs_gtk_search_tab.glade index 196a60dc..93e5debb 100644 --- a/contrib/gnunet_fs_gtk_search_tab.glade +++ b/contrib/gnunet_fs_gtk_search_tab.glade | |||
@@ -89,7 +89,7 @@ | |||
89 | <child> | 89 | <child> |
90 | <object class="GtkCellRendererText" id="search_result_mime_renderer"/> | 90 | <object class="GtkCellRendererText" id="search_result_mime_renderer"/> |
91 | <attributes> | 91 | <attributes> |
92 | <attribute name="background">8</attribute> | 92 | <attribute name="cell-background">8</attribute> |
93 | <attribute name="text">10</attribute> | 93 | <attribute name="text">10</attribute> |
94 | </attributes> | 94 | </attributes> |
95 | </child> | 95 | </child> |
@@ -123,7 +123,7 @@ | |||
123 | <child> | 123 | <child> |
124 | <object class="GtkCellRendererText" id="search_result_applicability_renderer"/> | 124 | <object class="GtkCellRendererText" id="search_result_applicability_renderer"/> |
125 | <attributes> | 125 | <attributes> |
126 | <attribute name="background">8</attribute> | 126 | <attribute name="cell-background">8</attribute> |
127 | <attribute name="text">11</attribute> | 127 | <attribute name="text">11</attribute> |
128 | </attributes> | 128 | </attributes> |
129 | </child> | 129 | </child> |
@@ -138,6 +138,7 @@ | |||
138 | <child> | 138 | <child> |
139 | <object class="GtkCellRendererPixbuf" id="search_result_preview_renderer"/> | 139 | <object class="GtkCellRendererPixbuf" id="search_result_preview_renderer"/> |
140 | <attributes> | 140 | <attributes> |
141 | <attribute name="cell-background">8</attribute> | ||
141 | <attribute name="pixbuf">3</attribute> | 142 | <attribute name="pixbuf">3</attribute> |
142 | </attributes> | 143 | </attributes> |
143 | </child> | 144 | </child> |
diff --git a/src/fs/gnunet-fs-gtk-event_handler.c b/src/fs/gnunet-fs-gtk-event_handler.c index b1d89216..74c3ab5d 100644 --- a/src/fs/gnunet-fs-gtk-event_handler.c +++ b/src/fs/gnunet-fs-gtk-event_handler.c | |||
@@ -889,6 +889,7 @@ update_search_label (struct SearchTab *tab) | |||
889 | GNUNET_asprintf (&name, "%.*s%s", 20, tab->query_txt, | 889 | GNUNET_asprintf (&name, "%.*s%s", 20, tab->query_txt, |
890 | strlen (tab->query_txt) > 20 ? "..." : ""); | 890 | strlen (tab->query_txt) > 20 ? "..." : ""); |
891 | gtk_label_set_text (tab->label, name); | 891 | gtk_label_set_text (tab->label, name); |
892 | gtk_widget_set_tooltip_text (GTK_WIDGET (tab->label), tab->query_txt); | ||
892 | GNUNET_free (name); | 893 | GNUNET_free (name); |
893 | } | 894 | } |
894 | 895 | ||
diff --git a/src/fs/gnunet-fs-gtk.c b/src/fs/gnunet-fs-gtk.c index 3223ec7b..d5a6cb52 100644 --- a/src/fs/gnunet-fs-gtk.c +++ b/src/fs/gnunet-fs-gtk.c | |||
@@ -137,7 +137,9 @@ main_window_search_namespace_dropdown_button_toggled_cb (GtkToggleButton *toggle | |||
137 | gboolean active; | 137 | gboolean active; |
138 | GtkBuilder *builder = GTK_BUILDER (user_data); | 138 | GtkBuilder *builder = GTK_BUILDER (user_data); |
139 | GtkWidget *namespace_selector_window; | 139 | GtkWidget *namespace_selector_window; |
140 | GtkWidget *namespace_selector_treeview; | ||
140 | namespace_selector_window = GTK_WIDGET (gtk_builder_get_object (builder, "namespace_selector_window")); | 141 | namespace_selector_window = GTK_WIDGET (gtk_builder_get_object (builder, "namespace_selector_window")); |
142 | namespace_selector_treeview = GTK_WIDGET (gtk_builder_get_object (builder, "namespace_selector_treeview")); | ||
141 | g_object_get (G_OBJECT (togglebutton), "active", &active, NULL); | 143 | g_object_get (G_OBJECT (togglebutton), "active", &active, NULL); |
142 | if (active) | 144 | if (active) |
143 | { | 145 | { |
@@ -162,10 +164,14 @@ main_window_search_namespace_dropdown_button_toggled_cb (GtkToggleButton *toggle | |||
162 | 164 | ||
163 | gtk_window_move (GTK_WINDOW (namespace_selector_window), popup_x, popup_y); | 165 | gtk_window_move (GTK_WINDOW (namespace_selector_window), popup_x, popup_y); |
164 | 166 | ||
165 | gtk_widget_show (namespace_selector_window); | 167 | gtk_widget_show_all (namespace_selector_window); |
168 | gtk_widget_grab_focus (namespace_selector_treeview); | ||
166 | } | 169 | } |
167 | else | 170 | else |
171 | { | ||
168 | gtk_widget_hide (namespace_selector_window); | 172 | gtk_widget_hide (namespace_selector_window); |
173 | gtk_widget_grab_focus (GTK_WIDGET (togglebutton)); | ||
174 | } | ||
169 | } | 175 | } |
170 | 176 | ||
171 | gboolean | 177 | gboolean |
@@ -314,18 +320,26 @@ namespace_selector_treeview_cursor_changed_cb (GtkWidget *widget, | |||
314 | GtkBuilder *builder; | 320 | GtkBuilder *builder; |
315 | GtkToggleButton *toggle_button; | 321 | GtkToggleButton *toggle_button; |
316 | GtkLabel *sel_namespace_label; | 322 | GtkLabel *sel_namespace_label; |
323 | GtkTreeModel *model; | ||
317 | gchar *value; | 324 | gchar *value; |
318 | GtkTreePath *treepath; | 325 | GtkTreePath *treepath; |
326 | GtkTreeRowReference *ref, *old; | ||
319 | 327 | ||
320 | builder = GTK_BUILDER (user_data); | 328 | builder = GTK_BUILDER (user_data); |
321 | 329 | ||
322 | if (!get_selected_namespace_treepath_iter_model_widget (builder, &treepath, NULL, NULL, NULL)) | ||
323 | return; | ||
324 | |||
325 | toggle_button = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "main_window_search_namespace_dropdown_button")); | 330 | toggle_button = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "main_window_search_namespace_dropdown_button")); |
326 | if (!toggle_button) | 331 | if (!toggle_button) |
327 | return; | 332 | return; |
328 | 333 | ||
334 | if (!get_selected_namespace_treepath_iter_model_widget (builder, &treepath, NULL, &model, NULL)) | ||
335 | return; | ||
336 | ref = gtk_tree_row_reference_new (model, treepath); | ||
337 | old = g_object_get_data (G_OBJECT (toggle_button), "selected-row-reference"); | ||
338 | if (old) | ||
339 | gtk_tree_row_reference_free (old); | ||
340 | g_object_set_data (G_OBJECT (toggle_button), "selected-row-reference", ref); | ||
341 | |||
342 | |||
329 | sel_namespace_label = GTK_LABEL (gtk_builder_get_object (builder, "main_window_search_selected_namespace_label")); | 343 | sel_namespace_label = GTK_LABEL (gtk_builder_get_object (builder, "main_window_search_selected_namespace_label")); |
330 | if (!sel_namespace_label) | 344 | if (!sel_namespace_label) |
331 | return; | 345 | return; |
@@ -340,6 +354,72 @@ namespace_selector_treeview_cursor_changed_cb (GtkWidget *widget, | |||
340 | gtk_toggle_button_set_active (toggle_button, FALSE); | 354 | gtk_toggle_button_set_active (toggle_button, FALSE); |
341 | } | 355 | } |
342 | 356 | ||
357 | GtkTreeRowReference * | ||
358 | get_ns_selected_row (GtkTreeView *tree) | ||
359 | { | ||
360 | GtkTreeSelection *sel; | ||
361 | GList *rows, *row; | ||
362 | GtkTreeModel *model; | ||
363 | GtkTreeRowReference *ref = NULL; | ||
364 | |||
365 | sel = gtk_tree_view_get_selection (tree); | ||
366 | rows = gtk_tree_selection_get_selected_rows (sel, &model); | ||
367 | for (row = rows; row; row = row->next) | ||
368 | { | ||
369 | ref = gtk_tree_row_reference_new (model, row->data); | ||
370 | if (ref != NULL) | ||
371 | break; | ||
372 | } | ||
373 | g_list_foreach (rows, (GFunc) gtk_tree_path_free, NULL); | ||
374 | g_list_free (rows); | ||
375 | return ref; | ||
376 | } | ||
377 | |||
378 | gboolean | ||
379 | namespace_selector_treeview_button_press_event_cb (GtkWidget *widget, | ||
380 | GdkEvent *event, gpointer user_data) | ||
381 | { | ||
382 | GtkTreeRowReference *ref = NULL; | ||
383 | |||
384 | ref = get_ns_selected_row (GTK_TREE_VIEW (widget)); | ||
385 | if (ref != NULL) | ||
386 | { | ||
387 | gpointer old = g_object_get_data (G_OBJECT (widget), "pushed-rowreference"); | ||
388 | if (old) | ||
389 | gtk_tree_row_reference_free (old); | ||
390 | g_object_set_data (G_OBJECT (widget), "pushed-rowreference", ref); | ||
391 | } | ||
392 | return FALSE; | ||
393 | } | ||
394 | |||
395 | gboolean | ||
396 | namespace_selector_treeview_button_release_event_cb (GtkWidget *widget, | ||
397 | GdkEvent *event, gpointer user_data) | ||
398 | { | ||
399 | GtkTreeRowReference *ref = NULL; | ||
400 | gpointer old = g_object_get_data (G_OBJECT (widget), "pushed-rowreference"); | ||
401 | |||
402 | ref = get_ns_selected_row (GTK_TREE_VIEW (widget)); | ||
403 | if (ref && old) | ||
404 | { | ||
405 | GtkTreePath *path_ref, *path_old; | ||
406 | path_ref = gtk_tree_row_reference_get_path (ref); | ||
407 | path_old = gtk_tree_row_reference_get_path (old); | ||
408 | if (gtk_tree_path_compare (path_ref, path_old) == 0) | ||
409 | namespace_selector_treeview_cursor_changed_cb (widget, user_data); | ||
410 | if (path_ref) | ||
411 | gtk_tree_path_free (path_ref); | ||
412 | if (path_old) | ||
413 | gtk_tree_path_free (path_old); | ||
414 | } | ||
415 | if (ref) | ||
416 | gtk_tree_row_reference_free (ref); | ||
417 | if (old) | ||
418 | gtk_tree_row_reference_free (old); | ||
419 | g_object_set_data (G_OBJECT (widget), "pushed-rowreference", NULL); | ||
420 | return FALSE; | ||
421 | } | ||
422 | |||
343 | void | 423 | void |
344 | main_window_search_button_clicked_cb (GtkButton *button, gpointer user_data) | 424 | main_window_search_button_clicked_cb (GtkButton *button, gpointer user_data) |
345 | { | 425 | { |
@@ -350,17 +430,23 @@ main_window_search_button_clicked_cb (GtkButton *button, gpointer user_data) | |||
350 | GtkTreeModel *mime_model; | 430 | GtkTreeModel *mime_model; |
351 | GtkEntry *query_entry; | 431 | GtkEntry *query_entry; |
352 | guint anonymity_level; | 432 | guint anonymity_level; |
433 | GtkTreeRowReference *ref = NULL; | ||
353 | GtkTreeIter iter; | 434 | GtkTreeIter iter; |
435 | GtkToggleButton *toggle_button; | ||
354 | const char *entry_keywords; | 436 | const char *entry_keywords; |
355 | gchar *keywords; | 437 | gchar *keywords; |
356 | gchar *mime_keyword; | 438 | gchar *mime_keyword; |
357 | 439 | ||
358 | GNUNET_HashCode *nsid = NULL; | 440 | GNUNET_HashCode *nsid = NULL; |
359 | struct GNUNET_FS_Uri *uri; | 441 | struct GNUNET_FS_Uri *uri; |
442 | gchar *root = NULL; | ||
360 | char *emsg; | 443 | char *emsg; |
361 | 444 | ||
362 | builder = GTK_BUILDER (user_data); | 445 | builder = GTK_BUILDER (user_data); |
363 | 446 | ||
447 | toggle_button = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, | ||
448 | "main_window_search_namespace_dropdown_button")); | ||
449 | |||
364 | if (!get_selected_anonymity_level (builder, &anonymity_level)) | 450 | if (!get_selected_anonymity_level (builder, &anonymity_level)) |
365 | return; | 451 | return; |
366 | 452 | ||
@@ -372,23 +458,30 @@ main_window_search_button_clicked_cb (GtkButton *button, gpointer user_data) | |||
372 | mime_keyword = NULL; | 458 | mime_keyword = NULL; |
373 | gtk_tree_model_get (mime_model, &iter, 0, &mime_keyword, -1); | 459 | gtk_tree_model_get (mime_model, &iter, 0, &mime_keyword, -1); |
374 | } | 460 | } |
461 | if (mime_keyword == NULL) | ||
462 | mime_keyword = g_strdup (""); | ||
375 | 463 | ||
376 | get_selected_namespace_treepath_iter_model_widget (builder, | 464 | ref = g_object_get_data (G_OBJECT (toggle_button), "selected-row-reference"); |
377 | &namespace_treepath, &iter, &namespace_model, NULL); | 465 | if (ref) |
466 | { | ||
467 | namespace_model = gtk_tree_row_reference_get_model (ref); | ||
468 | namespace_treepath = gtk_tree_row_reference_get_path (ref); | ||
469 | gtk_tree_model_get_iter (namespace_model, &iter, namespace_treepath); | ||
470 | } | ||
378 | 471 | ||
379 | query_entry = GTK_ENTRY (gtk_builder_get_object (builder, | 472 | query_entry = GTK_ENTRY (gtk_builder_get_object (builder, |
380 | "main_window_search_entry")); | 473 | "main_window_search_entry")); |
381 | 474 | ||
382 | entry_keywords = gtk_entry_get_text (query_entry); | ||
383 | if (mime_keyword != NULL) | ||
384 | { | ||
385 | keywords = g_strdup_printf ("%s %s", entry_keywords, mime_keyword); | ||
386 | g_free (mime_keyword); | ||
387 | } | ||
388 | else | ||
389 | keywords = g_strdup (entry_keywords); | ||
390 | if (namespace_treepath != NULL) | 475 | if (namespace_treepath != NULL) |
391 | gtk_tree_model_get (namespace_model, &iter, 1, &nsid, -1); | 476 | gtk_tree_model_get (namespace_model, &iter, 1, &nsid, 2, &root, -1); |
477 | if (root == NULL) | ||
478 | root = g_strdup (""); | ||
479 | |||
480 | entry_keywords = gtk_entry_get_text (query_entry); | ||
481 | |||
482 | keywords = g_strdup_printf ("%s %s %s", entry_keywords, mime_keyword, root); | ||
483 | g_free (mime_keyword); | ||
484 | g_free (root); | ||
392 | if (nsid != NULL) | 485 | if (nsid != NULL) |
393 | { | 486 | { |
394 | uri = GNUNET_FS_uri_sks_create_from_nsid (nsid, keywords); | 487 | uri = GNUNET_FS_uri_sks_create_from_nsid (nsid, keywords); |
@@ -487,11 +580,25 @@ GNUNET_GTK_main_window_realize_cb (GtkWidget *widget, gpointer user_data) | |||
487 | namespace_tree = GTK_TREE_VIEW (GNUNET_FS_GTK_get_main_window_object | 580 | namespace_tree = GTK_TREE_VIEW (GNUNET_FS_GTK_get_main_window_object |
488 | ("namespace_selector_treeview")); | 581 | ("namespace_selector_treeview")); |
489 | 582 | ||
583 | /* FIXME: find a way to manage pseudonyms. | ||
584 | * Right now the list will be filled with ALL and ANY pseudonyms that we | ||
585 | * find, these are held as files in a special directory. | ||
586 | * I don't see an easy way to ignore certain pseudonyms in that directory, | ||
587 | * and that require for pseudonym management. Also, pseudonyms are presented | ||
588 | * in arbitrary order. We must either sort them (by name?) or let the user | ||
589 | * drag them around to change the order in which they appear in the list. | ||
590 | * All that is not possible with a simple "files in a directory" concept. | ||
591 | */ | ||
490 | gtk_tree_store_insert_with_values (namespace_treestore, &iter, NULL, | 592 | gtk_tree_store_insert_with_values (namespace_treestore, &iter, NULL, |
491 | G_MAXINT, 0, "Any", 1, NULL, 2, "", 3, | 593 | G_MAXINT, 0, "Any", 1, NULL, 2, "", 3, |
492 | "Do not search in any particular namespace", -1); | 594 | "Do not search in any particular namespace", -1); |
595 | /* | ||
493 | GNUNET_PSEUDONYM_list_all (GNUNET_FS_GTK_get_configuration (), | 596 | GNUNET_PSEUDONYM_list_all (GNUNET_FS_GTK_get_configuration (), |
494 | &add_namespace_to_ts, namespace_treestore); | 597 | &add_namespace_to_ts, namespace_treestore); |
598 | */ | ||
599 | GNUNET_PSEUDONYM_discovery_callback_register ( | ||
600 | GNUNET_FS_GTK_get_configuration (), | ||
601 | &add_namespace_to_ts, namespace_treestore); | ||
495 | 602 | ||
496 | /* FIXME: read currently selected namespace from somewhere instead of selecting 0th item */ | 603 | /* FIXME: read currently selected namespace from somewhere instead of selecting 0th item */ |
497 | if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (namespace_treestore), &iter)) | 604 | if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (namespace_treestore), &iter)) |
@@ -581,7 +688,6 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
581 | 688 | ||
582 | } | 689 | } |
583 | 690 | ||
584 | |||
585 | int | 691 | int |
586 | main (int argc, char *const *argv) | 692 | main (int argc, char *const *argv) |
587 | { | 693 | { |