diff options
author | Christian Dywan <christian@twotoasts.de> | 2012-09-09 14:07:30 +0200 |
---|---|---|
committer | Christian Dywan <christian@twotoasts.de> | 2012-09-09 14:07:30 +0200 |
commit | db94ffad7dc71c80fc793baf3a8ecfbbe0c85409 (patch) | |
tree | 5b9670f8d6e47ce5a04b6e982e5602b82d7aea05 /midori/sokoke.c | |
parent | c77c2bef7c33aae7a965c18cf430e10ebd052561 (diff) | |
download | midori-db94ffad7dc71c80fc793baf3a8ecfbbe0c85409.tar.gz |
Rework downloading into Midori.Download interface
Midori.URI
get_folder
Midori.Download
is_finished
get/set_type
get_progress
get_tooltip
Consistent estimation of remaining time and speed.
get_content_type
Icons in dialog and panel.
has_wrong_checksum
Verification in both panel and toolbar.
action_clear, action_stock_id, open
Consistent behavior in both panel and toolbar.
fallback_extension
clean_filename
Merged two separate functions.
get_suggested_filename
get_filename_suggestion_for_uri
Now handles MIME types.
get_extension_for_uri
get_unique_filename
Renamed from prepare_filename.
prepare_destination_uri
has_enough_space
Diffstat (limited to 'midori/sokoke.c')
-rw-r--r-- | midori/sokoke.c | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/midori/sokoke.c b/midori/sokoke.c index 3d1cbd1f..8bca3e26 100644 --- a/midori/sokoke.c +++ b/midori/sokoke.c @@ -1302,85 +1302,6 @@ sokoke_build_thumbnail_path (const gchar* name) return path; } -gchar* -midori_download_prepare_tooltip_text (WebKitDownload* download) -{ - gdouble* last_time; - guint64* last_size; - gint hour = 3600, min = 60; - gint hours_left, minutes_left, seconds_left; - guint64 total_size = webkit_download_get_total_size (download); - guint64 current_size = webkit_download_get_current_size (download); - gdouble time_elapsed = webkit_download_get_elapsed_time (download); - gdouble time_estimated, time_diff; - gchar* current, *total, *download_speed; - gchar* hours_str, *minutes_str, *seconds_str; - GString* tooltip = g_string_new (NULL); - - time_diff = time_elapsed / current_size; - time_estimated = (total_size - current_size) * time_diff; - - hours_left = time_estimated / hour; - minutes_left = (time_estimated - (hours_left * hour)) / min; - seconds_left = (time_estimated - (hours_left * hour) - (minutes_left * min)); - - hours_str = g_strdup_printf (ngettext ("%d hour", "%d hours", hours_left), hours_left); - minutes_str = g_strdup_printf (ngettext ("%d minute", "%d minutes", minutes_left), minutes_left); - seconds_str = g_strdup_printf (ngettext ("%d second", "%d seconds", seconds_left), seconds_left); - - current = g_format_size (current_size); - total = g_format_size (total_size); - last_time = g_object_get_data (G_OBJECT (download), "last-time"); - last_size = g_object_get_data (G_OBJECT (download), "last-size"); - - /* i18n: Download tooltip (size): 4KB of 43MB */ - g_string_append_printf (tooltip, _("%s of %s"), current, total); - g_free (current); - g_free (total); - - if (time_elapsed != *last_time) - download_speed = g_format_size ( - (current_size - *last_size) / (time_elapsed - *last_time)); - else - /* i18n: Unknown number of bytes, used for transfer rate like ?B/s */ - download_speed = g_strdup (_("?B")); - - /* i18n: Download tooltip (transfer rate): (130KB/s) */ - g_string_append_printf (tooltip, _(" (%s/s)"), download_speed); - g_free (download_speed); - - if (time_estimated > 0) - { - gchar* eta = NULL; - if (hours_left > 0) - eta = g_strdup_printf ("%s, %s", hours_str, minutes_str); - else if (minutes_left >= 10) - eta = g_strdup_printf ("%s", minutes_str); - else if (minutes_left < 10 && minutes_left > 0) - eta = g_strdup_printf ("%s, %s", minutes_str, seconds_str); - else if (seconds_left > 0) - eta = g_strdup_printf ("%s", seconds_str); - if (eta != NULL) - { - /* i18n: Download tooltip (estimated time) : - 1 hour, 5 minutes remaning */ - g_string_append_printf (tooltip, _(" - %s remaining"), eta); - g_free (eta); - } - } - - g_free (hours_str); - g_free (seconds_str); - g_free (minutes_str); - - if (time_elapsed - *last_time > 5.0) - { - *last_time = time_elapsed; - *last_size = current_size; - } - - return g_string_free (tooltip, FALSE); -} - static gboolean sokoke_entry_has_placeholder_text (GtkEntry* entry) { @@ -1452,17 +1373,3 @@ sokoke_search_entry_new (const gchar* placeholder_text) return entry; } -gchar* -sokoke_get_download_filename (WebKitDownload* download) -{ - /* https://bugs.webkit.org/show_bug.cgi?id=83161 */ - /* https://d19vezwu8eufl6.cloudfront.net/nlp/slides%2F03-01-FormalizingNB.pdf */ - gchar* filename = g_strdup (webkit_download_get_suggested_filename (download)); - #ifdef G_OS_WIN32 - g_strdelimit (filename, "/\\<>:\"|?*", '_'); - #else - g_strdelimit (filename, "/", '_'); - #endif - return filename; -} - |