From df6e30ad7e1c0077b96f11945231f8b0eab00e38 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 3 Feb 2012 21:41:41 +0000 Subject: -misc bugfixes --- contrib/gnunet_fs_gtk_publish_tab.glade | 19 +++-------- src/fs/gnunet-fs-gtk_download-save-as.c | 2 +- src/fs/gnunet-fs-gtk_event-handler.c | 52 +++++++++++++++++++++++++----- src/fs/gnunet-fs-gtk_publish-edit-dialog.c | 4 ++- 4 files changed, 53 insertions(+), 24 deletions(-) diff --git a/contrib/gnunet_fs_gtk_publish_tab.glade b/contrib/gnunet_fs_gtk_publish_tab.glade index 94f3d812..30e3f782 100644 --- a/contrib/gnunet_fs_gtk_publish_tab.glade +++ b/contrib/gnunet_fs_gtk_publish_tab.glade @@ -1,6 +1,7 @@ - + + @@ -18,7 +19,6 @@ - False You should never see this @@ -32,13 +32,10 @@ _publish_frame_tree_store True True - - - autosize - Filename + Filename True @@ -53,7 +50,7 @@ autosize - Size + Size @@ -69,21 +66,17 @@ - False True - False 5 30 True - False Publishing - True False 5 0 @@ -91,16 +84,14 @@ - False True True True - False half + True - False gtk-close 2 diff --git a/src/fs/gnunet-fs-gtk_download-save-as.c b/src/fs/gnunet-fs-gtk_download-save-as.c index 812e073d..f020111c 100644 --- a/src/fs/gnunet-fs-gtk_download-save-as.c +++ b/src/fs/gnunet-fs-gtk_download-save-as.c @@ -263,7 +263,7 @@ GNUNET_FS_GTK_download_context_start_download (struct DownloadContext *dc) opt = GNUNET_FS_DOWNLOAD_OPTION_NONE; if (dc->is_recursive) opt |= GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE; - len = GNUNET_FS_uri_chk_get_file_size (dc->uri); + len = GNUNET_FS_uri_chk_get_file_size (de->uri); if (NULL != dc->sr) { GNUNET_break (NULL != diff --git a/src/fs/gnunet-fs-gtk_event-handler.c b/src/fs/gnunet-fs-gtk_event-handler.c index bd2378e1..a7aef9ba 100644 --- a/src/fs/gnunet-fs-gtk_event-handler.c +++ b/src/fs/gnunet-fs-gtk_event-handler.c @@ -156,6 +156,26 @@ static struct SearchTab *current_context_search_tab; /* ***************** Search event handling ****************** */ + +/** + * Clear the metadata list and the preview widget. + */ +static void +clear_metadata_display () +{ + GtkImage *image; + GtkListStore *ms; + + image = + GTK_IMAGE (GNUNET_FS_GTK_get_main_window_object + ("GNUNET_GTK_main_window_preview_image")); + gtk_image_clear (image); + ms = GTK_LIST_STORE (GNUNET_FS_GTK_get_main_window_object + ("GNUNET_GTK_meta_data_list_store")); + gtk_list_store_clear (ms); +} + + /** * This should get the default download directory (so that GNUnet * won't offer the user to download files to the 'bin' subdirectory, @@ -605,11 +625,6 @@ search_list_popup (GtkTreeModel *tm, struct SearchResult *sr; struct GNUNET_FS_Uri *uri; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Creating a menu for SR=%p, DE=%p\n", - sr, - sr->download); - /* FIXME-UNCLEAN: move these to some menu context struct (de-globalize) */ current_context_search_tab = tab; @@ -623,7 +638,13 @@ search_list_popup (GtkTreeModel *tm, gtk_tree_path_free (path); gtk_tree_model_get (tm, iter, 1, &uri, 9, &sr, -1); - + /* FIXME-BUG: 'sr' can be NULL here, somehow some code fails to setup the record.. */ + if (NULL == sr) + { + /* FIXME-BUG: this prevents the crash for now, but does not solve the problem */ + GNUNET_break (0); + return FALSE; + } menu = GTK_MENU (gtk_menu_new ()); if ( (NULL == sr->download) && (NULL != uri) ) @@ -787,6 +808,7 @@ close_search_tab (struct SearchTab *tab) GNUNET_free (tab); return; } + clear_metadata_display (); notebook = GTK_NOTEBOOK (GNUNET_FS_GTK_get_main_window_object ("GNUNET_GTK_main_window_notebook")); @@ -1617,6 +1639,13 @@ stop_download (struct DownloadEntry *de) } gtk_tree_path_free (path); gtk_tree_model_get (tm, &iter, 9, &search_result, -1); + /* FIXME-BUG: 'search_result' can be NULL here, somehow some code fails to setup the record.. */ + if (NULL == search_result) + { + /* FIXME-BUG: this prevents the crash for now, but does not solve the problem */ + GNUNET_break (0); + return; + } GNUNET_assert (search_result->download == de); search_result->download = NULL; change_download_color (de, "white"); @@ -1763,11 +1792,17 @@ mark_download_progress (struct DownloadEntry *de, uint64_t size, return; } gtk_tree_path_free (path); - /* FIXME-FEATURE: update availability-score here as well! */ + /* FIXME-DESIGN: should we replace the 'availability' with + 'progress' once the download has started and re-use the + space in the display? Probably yes, at least once we have + a custom CellRenderer... */ gtk_tree_store_set (de->ts, &iter, 4, (guint) ((size > 0) ? (100 * completed / - size) : 100) /* progress */ , + size) : 100) /* progress */, + 5, (guint) ((size > + 0) ? (100 * completed / + size) : 100) /* availability == progress */, 14, completed, -1); if ( (depth == 0) && @@ -2287,6 +2322,7 @@ GNUNET_FS_GTK_publish_label_close_button_clicked (GtkButton * button, } while (TRUE == gtk_tree_model_iter_next (tm, &iter)); } + clear_metadata_display (); /* remove tab from notebook */ notebook = diff --git a/src/fs/gnunet-fs-gtk_publish-edit-dialog.c b/src/fs/gnunet-fs-gtk_publish-edit-dialog.c index 48b91b8f..53ad9e51 100644 --- a/src/fs/gnunet-fs-gtk_publish-edit-dialog.c +++ b/src/fs/gnunet-fs-gtk_publish-edit-dialog.c @@ -842,9 +842,11 @@ file_information_update (void *cls, struct GNUNET_FS_FileInformation *fi, gtk_tree_model_get (GTK_TREE_MODEL (ctx->meta_liststore), &iter, 0, &ntype, 1, &nformat, 3, &value, -1); if (ntype > 0) - GNUNET_CONTAINER_meta_data_insert (ctx->md, "", ntype, nformat, + { + GNUNET_CONTAINER_meta_data_insert (meta, "", ntype, nformat, "text/plain", value, strlen (value) + 1); + } g_free (value); } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (ctx->meta_liststore), &iter)); -- cgit v1.2.3