aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2012-06-22 17:00:12 +0800
committerCarlos Garcia Campos <carlosgc@gnome.org>2012-06-26 01:41:53 +0800
commit213a7c80120f416b7082e54157904a638296c5cd (patch)
tree2d288e173b6d7b32866ca41aa2e603aa4dce4dff /lib
parentfb062ec392862e2f14ca3b6466e200a31dee2737 (diff)
downloadgsoc2013-epiphany-213a7c80120f416b7082e54157904a638296c5cd.tar
gsoc2013-epiphany-213a7c80120f416b7082e54157904a638296c5cd.tar.gz
gsoc2013-epiphany-213a7c80120f416b7082e54157904a638296c5cd.tar.bz2
gsoc2013-epiphany-213a7c80120f416b7082e54157904a638296c5cd.tar.lz
gsoc2013-epiphany-213a7c80120f416b7082e54157904a638296c5cd.tar.xz
gsoc2013-epiphany-213a7c80120f416b7082e54157904a638296c5cd.tar.zst
gsoc2013-epiphany-213a7c80120f416b7082e54157904a638296c5cd.zip
ephy-download-widget: add get_destination_basename_from_download() helper function
Diffstat (limited to 'lib')
-rw-r--r--lib/widgets/ephy-download-widget.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/lib/widgets/ephy-download-widget.c b/lib/widgets/ephy-download-widget.c
index 09000bd58..40f3b96bf 100644
--- a/lib/widgets/ephy-download-widget.c
+++ b/lib/widgets/ephy-download-widget.c
@@ -79,6 +79,30 @@ get_gicon_from_download (EphyDownload *ephy_download)
}
static char *
+get_destination_basename_from_download (EphyDownload *ephy_download)
+{
+ WebKitDownload *download;
+ const char *dest;
+ char *basename;
+ char *unescaped;
+
+ download = ephy_download_get_webkit_download (ephy_download);
+#ifdef HAVE_WEBKIT2
+ dest = NULL;
+#else
+ dest = webkit_download_get_destination_uri (download);
+#endif
+ if (!dest)
+ return NULL;
+
+ basename = g_filename_display_basename (dest);
+ unescaped = g_uri_unescape_string (basename, NULL);
+ g_free (basename);
+
+ return unescaped;
+}
+
+static char *
format_interval (gdouble interval)
{
int hours, mins, secs;
@@ -515,7 +539,7 @@ ephy_download_widget_new (EphyDownload *ephy_download)
GtkWidget *menu;
GtkWidget *remain;
- char *dest, *basename;
+ char *dest;
WebKitDownload *download;
GIcon *gicon;
@@ -525,14 +549,6 @@ ephy_download_widget_new (EphyDownload *ephy_download)
"download", ephy_download, NULL);
download = ephy_download_get_webkit_download (ephy_download);
-#ifdef HAVE_WEBKIT2
- /* TODO: Downloads */
- basename = g_strdup ("");
-#else
- basename = g_filename_display_basename (webkit_download_get_destination_uri (download));
-#endif
- dest = g_uri_unescape_string (basename, NULL);
-
grid = gtk_grid_new ();
button = totem_glow_button_new ();
@@ -542,6 +558,7 @@ ephy_download_widget_new (EphyDownload *ephy_download)
icon = gtk_image_new_from_gicon (gicon, GTK_ICON_SIZE_LARGE_TOOLBAR);
g_object_unref (gicon);
+ dest = get_destination_basename_from_download (ephy_download);
text = gtk_label_new (dest);
gtk_misc_set_alignment (GTK_MISC (text), 0, 0.5);
gtk_label_set_ellipsize (GTK_LABEL (text), PANGO_ELLIPSIZE_END);
@@ -555,8 +572,6 @@ ephy_download_widget_new (EphyDownload *ephy_download)
gtk_grid_attach (GTK_GRID (grid), remain, 1, 1, 1, 1);
gtk_widget_set_tooltip_text (GTK_WIDGET (widget), dest);
-
- g_free (basename);
g_free (dest);
widget->priv->icon = icon;