From 37ddf86b521f1655724bd895849905fd023c7915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1=D1?= =?UTF-8?q?=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Mon, 12 Dec 2011 00:43:48 +0400 Subject: [PATCH 1/2] A lump of GUI changes and tweaks * Real namespaces are now fetched from FS instead of dummies * Used Size Group to make entries and combobox in search bar have the same height * Reworked namespace selection toggle button - now it consists of separate label and button. Could have made it to look more comboboxy, but there seems to be no pressing need for that. * Removed some unneded widgets. * MIME type selector now has more columns, and got an entry to input arbitrary MIME type. --- contrib/gnunet_fs_gtk_main_window.glade | 237 +++++++++++++++++++----------- src/fs/gnunet-fs-gtk.c | 85 ++++++++++-- 2 files changed, 223 insertions(+), 99 deletions(-) diff --git a/contrib/gnunet_fs_gtk_main_window.glade b/contrib/gnunet_fs_gtk_main_window.glade index 799c1b1..4fdc888 100644 --- a/contrib/gnunet_fs_gtk_main_window.glade +++ b/contrib/gnunet_fs_gtk_main_window.glade @@ -2,70 +2,6 @@ - - - - - - - - - - - - - - True - False - gtk-go-up - - - True - False - gtk-new - - - True - False - gtk-find - - - True - False - gtk-go-down - - - True - False - gtk-index - - - - - - - - - - - - - None - 0 - #AAAA00000000 - - - Normal - 1 - #000000000000 - - - Paranoid - 10 - #0000AAAA0000 - - - False gnunet-fs-gtk @@ -389,30 +325,51 @@ + + True + False + <none> + True + + + False + False + 1 + + + True False + 0 0 - <none> False + 21 + 21 True True True GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK - image10 right + + + True + False + down + + False False - 1 + 2 @@ -424,7 +381,7 @@ False False - 2 + 3 @@ -442,7 +399,7 @@ True True - 3 + 4 @@ -454,7 +411,7 @@ False False - 4 + 5 @@ -487,7 +444,7 @@ False False - 5 + 6 @@ -499,14 +456,13 @@ False False - 6 + 7 True False - 0 0 @@ -514,16 +470,38 @@ False main_window_search_mime_liststore 0 + True + 0 + + - 0 + 1 - 1 + 0 + + + + + + 2 + + + + + + 3 + + + + + + 4 @@ -532,7 +510,7 @@ False False - 7 + 8 @@ -554,7 +532,7 @@ False False - 8 + 9 @@ -690,18 +668,16 @@ - + - - - + - + + + + + - - - - @@ -716,6 +692,20 @@ 10 10 + + + + + + + + + + + + + + 100 1 @@ -733,7 +723,27 @@ False gtk-open - + + True + False + gtk-go-up + + + True + False + gtk-new + + + True + False + gtk-find + + + True + False + gtk-go-down + + True False gtk-index @@ -753,29 +763,74 @@ False gtk-index + + + + + + + + + + + + None + 0 + #AAAA00000000 + + + Normal + 1 + #000000000000 + + + Paranoid + 10 + #0000AAAA0000 + + + + + + + + + Any + + + plain/text Text + txt + N/A + N/A application/zip Zip + zip + lossless + free audio/mpeg MPEG audio + mp3, mp2, mpeg + lossy + non-free @@ -791,6 +846,14 @@ + + vertical + + + + + + False GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK diff --git a/src/fs/gnunet-fs-gtk.c b/src/fs/gnunet-fs-gtk.c index 68c6be6..6833783 100644 --- a/src/fs/gnunet-fs-gtk.c +++ b/src/fs/gnunet-fs-gtk.c @@ -351,6 +351,7 @@ namespace_selector_treeview_cursor_changed_cb (GtkWidget *widget, { GtkBuilder *builder; GtkToggleButton *toggle_button; + GtkLabel *sel_namespace_label; gchar *value; GtkTreePath *treepath; @@ -363,9 +364,13 @@ namespace_selector_treeview_cursor_changed_cb (GtkWidget *widget, if (!toggle_button) return; + sel_namespace_label = GTK_LABEL (gtk_builder_get_object (builder, "main_window_search_selected_namespace_label")); + if (sel_namespace_label) + return; + if (GNUNET_GTK_get_tree_string (GTK_TREE_VIEW (widget), treepath, 0, &value)) - gtk_button_set_label (GTK_BUTTON (toggle_button), value); + gtk_label_set_text (sel_namespace_label, value); gtk_tree_path_free (treepath); @@ -446,6 +451,64 @@ main_window_search_button_clicked_cb (GtkButton *button, gpointer user_data) GNUNET_FS_uri_destroy (uri); } +/** + * Add pseudonym data to tree store + * + * @param cls closure (the 'GtkListStore') + * @param pseudonym hash code of public key of pseudonym + * @param md meta data known about the pseudonym + * @param rating the local rating of the pseudonym + * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort + */ +static int +add_namespace_to_ts (void *cls, const GNUNET_HashCode * pseudonym, + const struct GNUNET_CONTAINER_MetaData *md, int rating) +{ + GtkTreeStore *ts = cls; + char *root; + char *ns_name; + GNUNET_HashCode *nsid; + char *description; + char *uris; + char *emsg; + struct GNUNET_FS_Uri *uri; + GtkTreeIter iter; + + ns_name = + GNUNET_PSEUDONYM_id_to_name (GNUNET_FS_GTK_get_configuration (), + pseudonym); + nsid = GNUNET_malloc (sizeof (GNUNET_HashCode)); + *nsid = *pseudonym; + root = NULL; + uris = GNUNET_CONTAINER_meta_data_get_by_type (md, EXTRACTOR_METATYPE_URI); + if (uris != NULL) + { + emsg = NULL; + uri = GNUNET_FS_uri_parse (uris, &emsg); + if (uri == NULL) + GNUNET_free (emsg); + root = GNUNET_FS_uri_sks_get_content_id (uri); + GNUNET_FS_uri_destroy (uri); + } + description = + GNUNET_CONTAINER_meta_data_get_first_by_types (md, + EXTRACTOR_METATYPE_TITLE, + EXTRACTOR_METATYPE_BOOK_TITLE, + EXTRACTOR_METATYPE_DESCRIPTION, + EXTRACTOR_METATYPE_SUMMARY, + EXTRACTOR_METATYPE_ALBUM, + EXTRACTOR_METATYPE_COMMENT, + EXTRACTOR_METATYPE_SUBJECT, + EXTRACTOR_METATYPE_KEYWORDS, + -1); + gtk_tree_store_insert_with_values (ts, &iter, NULL, G_MAXINT, 0, ns_name, 1, + nsid, 2, root, 3, description, -1); + GNUNET_free (ns_name); + GNUNET_free_non_null (root); + GNUNET_free_non_null (description); + return GNUNET_OK; +} + void GNUNET_GTK_main_window_realize_cb (GtkWidget *widget, gpointer user_data) { @@ -453,7 +516,6 @@ GNUNET_GTK_main_window_realize_cb (GtkWidget *widget, gpointer user_data) GtkTreeView *namespace_tree; GtkTreeStore *namespace_treestore; GtkBuilder *builder; - GtkToggleButton *toggle_button; GtkWidget *namespace_selector_window; builder = GTK_BUILDER (user_data); @@ -463,24 +525,23 @@ GNUNET_GTK_main_window_realize_cb (GtkWidget *widget, gpointer user_data) namespace_tree = GTK_TREE_VIEW (GNUNET_FS_GTK_get_main_window_object ("namespace_selector_treeview")); - /* TODO: fetch real values from somewhere instead of filling the store with dummies */ - gtk_tree_store_insert_with_values (namespace_treestore, &iter, NULL, 0, 0, "Any", 1, NULL, 2, "", 3, "Do not search in any particular namespace", -1); - gtk_tree_store_insert_with_values (namespace_treestore, &iter, NULL, 1, 0, "foo", 1, NULL, 2, "IAMTHEBESTOBEYMENOCARRIER", 3, "Tooltip1", -1); - gtk_tree_store_insert_with_values (namespace_treestore, &iter, NULL, 2, 0, "bar", 1, NULL, 2, "NOONEWILLKNOWTHISIDBECAUSEITSSECRET", 3, "Tooltip2", -1); - gtk_tree_store_insert_with_values (namespace_treestore, &iter, NULL, 3, 0, "baz", 1, NULL, 2, "SSLOPENSSHGNUGTKGNUNETFTWYAYA", 3, "Tooltip3", -1); + gtk_tree_store_insert_with_values (namespace_treestore, &iter, NULL, + G_MAXINT, 0, "Any", 1, NULL, 2, "", 3, + "Do not search in any particular namespace", -1); + GNUNET_PSEUDONYM_list_all (GNUNET_FS_GTK_get_configuration (), + &add_namespace_to_ts, namespace_treestore); /* FIXME: read currently selected namespace from somewhere instead of selecting 0th item */ if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (namespace_treestore), &iter)) { gchar *value; + GtkLabel *sel_namespace_label; GtkTreePath *treepath = gtk_tree_path_new_first (); gtk_tree_selection_select_iter (gtk_tree_view_get_selection ( namespace_tree), &iter); - toggle_button = GTK_TOGGLE_BUTTON (GNUNET_FS_GTK_get_main_window_object - ("main_window_search_namespace_dropdown_button")); - if (GNUNET_GTK_get_tree_string (namespace_tree, - treepath, 0, &value)) - gtk_button_set_label (GTK_BUTTON (toggle_button), value); + sel_namespace_label = GTK_LABEL (gtk_builder_get_object (builder, "main_window_search_selected_namespace_label")); + if (GNUNET_GTK_get_tree_string (namespace_tree, treepath, 0, &value)) + gtk_label_set_text (sel_namespace_label, value); gtk_tree_path_free (treepath); } -- 1.7.4