diff options
Diffstat (limited to 'src/plugins/fs/search.c')
-rw-r--r-- | src/plugins/fs/search.c | 81 |
1 files changed, 72 insertions, 9 deletions
diff --git a/src/plugins/fs/search.c b/src/plugins/fs/search.c index f6a96470..11be760d 100644 --- a/src/plugins/fs/search.c +++ b/src/plugins/fs/search.c | |||
@@ -33,6 +33,9 @@ | |||
33 | #include <extractor.h> | 33 | #include <extractor.h> |
34 | #include <GNUnet/gnunet_util_crypto.h> | 34 | #include <GNUnet/gnunet_util_crypto.h> |
35 | #include <GNUnet/gnunet_namespace_lib.h> | 35 | #include <GNUnet/gnunet_namespace_lib.h> |
36 | #ifdef HAVE_GIO | ||
37 | #include <gio/gio.h> | ||
38 | #endif | ||
36 | 39 | ||
37 | 40 | ||
38 | /** | 41 | /** |
@@ -198,16 +201,23 @@ addEntryToSearchTree (SearchList * searchContext, | |||
198 | const GNUNET_ECRS_FileInfo * info, GtkTreeIter * iter) | 201 | const GNUNET_ECRS_FileInfo * info, GtkTreeIter * iter) |
199 | { | 202 | { |
200 | char *name; | 203 | char *name; |
204 | char *rawMime; | ||
201 | char *mime; | 205 | char *mime; |
202 | char *desc; | 206 | char *desc; |
203 | unsigned long long size; | 207 | unsigned long long size; |
204 | char *size_h; | 208 | char *size_h; |
205 | GdkPixbuf *pixbuf; | 209 | GdkPixbuf *pixbuf; |
206 | GdkPixbuf *rankbuf; | 210 | GdkPixbuf *rankbuf; |
211 | #ifdef HAVE_GIO | ||
212 | GdkPixbuf *icon = NULL; | ||
213 | GIcon *gicon = NULL; | ||
214 | const gchar **iconNames; | ||
215 | int i = 0; | ||
216 | #endif | ||
207 | enum GNUNET_URITRACK_STATE state; | 217 | enum GNUNET_URITRACK_STATE state; |
208 | 218 | ||
209 | state = GNUNET_URITRACK_get_state (ectx, cfg, info->uri); | 219 | state = GNUNET_URITRACK_get_state (ectx, cfg, info->uri); |
210 | mime = getMimeTypeFromMetaData (info->meta); | 220 | rawMime = getMimeTypeFromMetaData (info->meta); |
211 | desc = getDescriptionFromMetaData (info->meta); | 221 | desc = getDescriptionFromMetaData (info->meta); |
212 | name = getFileNameFromMetaData (info->meta); | 222 | name = getFileNameFromMetaData (info->meta); |
213 | size = GNUNET_ECRS_uri_test_chk (info->uri) | 223 | size = GNUNET_ECRS_uri_test_chk (info->uri) |
@@ -218,11 +228,41 @@ addEntryToSearchTree (SearchList * searchContext, | |||
218 | rankbuf = make_ranking_pixbuf (0, 0, 1, | 228 | rankbuf = make_ranking_pixbuf (0, 0, 1, |
219 | GNUNET_ECRS_uri_get_keyword_count_from_ksk | 229 | GNUNET_ECRS_uri_get_keyword_count_from_ksk |
220 | (searchContext->uri)); | 230 | (searchContext->uri)); |
221 | gtk_tree_store_set (searchContext->tree, iter, SEARCH_NAME, name, | 231 | #ifdef HAVE_GIO |
222 | SEARCH_SIZE, size, SEARCH_HSIZE, size_h, SEARCH_MIME, | 232 | if (0 == strcmp(rawMime, GNUNET_DIRECTORY_MIME)) |
223 | mime, SEARCH_DESC, desc, SEARCH_PIXBUF, pixbuf, | 233 | { |
224 | SEARCH_URI, GNUNET_ECRS_uri_duplicate (info->uri), | 234 | mime = GNUNET_strdup(_("Directory")); |
225 | SEARCH_META, | 235 | icon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), |
236 | "folder", 16, 0, (GError **)NULL); | ||
237 | } | ||
238 | else | ||
239 | { | ||
240 | mime = g_content_type_get_description (rawMime); | ||
241 | gicon = g_content_type_get_icon (rawMime); | ||
242 | if (G_IS_THEMED_ICON (gicon)) | ||
243 | { | ||
244 | iconNames = (const gchar **)g_themed_icon_get_names | ||
245 | (G_THEMED_ICON (gicon)); | ||
246 | do { | ||
247 | icon = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), | ||
248 | iconNames[i], 16, 0, | ||
249 | (GError **)NULL); | ||
250 | i++; | ||
251 | } while ( (icon == NULL) && iconNames[i] ); | ||
252 | } | ||
253 | } | ||
254 | #else | ||
255 | mime = rawMime; | ||
256 | #endif | ||
257 | |||
258 | gtk_tree_store_set (searchContext->tree, iter, | ||
259 | #ifdef HAVE_GIO | ||
260 | SEARCH_ICON, icon, | ||
261 | #endif | ||
262 | SEARCH_NAME, name, SEARCH_SIZE, size, SEARCH_HSIZE, | ||
263 | size_h, SEARCH_MIME, mime, SEARCH_DESC, desc, | ||
264 | SEARCH_PIXBUF, pixbuf, SEARCH_URI, | ||
265 | GNUNET_ECRS_uri_duplicate (info->uri), SEARCH_META, | ||
226 | GNUNET_meta_data_duplicate (info->meta), | 266 | GNUNET_meta_data_duplicate (info->meta), |
227 | SEARCH_CELL_BG_COLOR, getColorCode (state), | 267 | SEARCH_CELL_BG_COLOR, getColorCode (state), |
228 | SEARCH_CELL_FG_COLOR, "black", SEARCH_INTERNAL, | 268 | SEARCH_CELL_FG_COLOR, "black", SEARCH_INTERNAL, |
@@ -233,10 +273,16 @@ addEntryToSearchTree (SearchList * searchContext, | |||
233 | g_object_unref (rankbuf); | 273 | g_object_unref (rankbuf); |
234 | if (pixbuf != NULL) | 274 | if (pixbuf != NULL) |
235 | g_object_unref (pixbuf); | 275 | g_object_unref (pixbuf); |
276 | #ifdef HAVE_GIO | ||
277 | if (gicon != NULL) | ||
278 | g_object_unref (gicon); | ||
279 | if (icon != NULL) | ||
280 | g_object_unref (icon); | ||
281 | #endif | ||
236 | GNUNET_free (size_h); | 282 | GNUNET_free (size_h); |
237 | GNUNET_free (name); | 283 | GNUNET_free (name); |
238 | GNUNET_free (desc); | 284 | GNUNET_free (desc); |
239 | GNUNET_free (mime); | 285 | GNUNET_free (rawMime); |
240 | } | 286 | } |
241 | 287 | ||
242 | /** | 288 | /** |
@@ -666,7 +712,10 @@ fs_search_started (struct GNUNET_FSUI_SearchList * fsui_list, | |||
666 | g_signal_connect_swapped (list->treeview, | 712 | g_signal_connect_swapped (list->treeview, |
667 | "button-press-event", | 713 | "button-press-event", |
668 | G_CALLBACK (search_click_handler), list); | 714 | G_CALLBACK (search_click_handler), list); |
669 | list->tree = gtk_tree_store_new (SEARCH_NUM, G_TYPE_STRING, /* name */ | 715 | list->tree = gtk_tree_store_new (SEARCH_NUM, G_TYPE_STRING, /* name */ |
716 | #ifdef HAVE_GIO | ||
717 | GDK_TYPE_PIXBUF, /* icon */ | ||
718 | #endif | ||
670 | G_TYPE_UINT64, /* size */ | 719 | G_TYPE_UINT64, /* size */ |
671 | G_TYPE_STRING, /* human-readable size */ | 720 | G_TYPE_STRING, /* human-readable size */ |
672 | G_TYPE_STRING, /* mime-type */ | 721 | G_TYPE_STRING, /* mime-type */ |
@@ -712,6 +761,20 @@ fs_search_started (struct GNUNET_FSUI_SearchList * fsui_list, | |||
712 | gtk_tree_view_column_set_sort_column_id (column, SEARCH_STATUS); | 761 | gtk_tree_view_column_set_sort_column_id (column, SEARCH_STATUS); |
713 | gtk_tree_view_column_set_min_width (column, 0); | 762 | gtk_tree_view_column_set_min_width (column, 0); |
714 | 763 | ||
764 | #ifdef HAVE_GIO | ||
765 | renderer = gtk_cell_renderer_pixbuf_new (); | ||
766 | col = gtk_tree_view_insert_column_with_attributes (list->treeview, | ||
767 | -1, | ||
768 | NULL, | ||
769 | renderer, | ||
770 | "pixbuf", | ||
771 | SEARCH_ICON, NULL); | ||
772 | column = gtk_tree_view_get_column (list->treeview, col - 1); | ||
773 | gtk_tree_view_column_set_resizable (column, TRUE); | ||
774 | gtk_tree_view_column_set_reorderable (column, FALSE); | ||
775 | gtk_tree_view_column_set_min_width (column, 20); | ||
776 | #endif | ||
777 | |||
715 | renderer = gtk_cell_renderer_text_new (); | 778 | renderer = gtk_cell_renderer_text_new (); |
716 | col = gtk_tree_view_insert_column_with_attributes (list->treeview, | 779 | col = gtk_tree_view_insert_column_with_attributes (list->treeview, |
717 | -1, | 780 | -1, |
@@ -745,7 +808,7 @@ fs_search_started (struct GNUNET_FSUI_SearchList * fsui_list, | |||
745 | renderer = gtk_cell_renderer_text_new (); | 808 | renderer = gtk_cell_renderer_text_new (); |
746 | col = gtk_tree_view_insert_column_with_attributes (list->treeview, | 809 | col = gtk_tree_view_insert_column_with_attributes (list->treeview, |
747 | -1, | 810 | -1, |
748 | _("Mime-type"), | 811 | _("Type"), |
749 | renderer, | 812 | renderer, |
750 | "text", SEARCH_MIME, | 813 | "text", SEARCH_MIME, |
751 | NULL); | 814 | NULL); |