diff options
author | Alan Fitton <alan@eth0.org.uk> | 2012-06-20 09:45:26 +0100 |
---|---|---|
committer | Alan Fitton <alan@eth0.org.uk> | 2012-06-20 09:45:26 +0100 |
commit | 8f788a8c67c61c85f05e6bd9227c39c00870e8a0 (patch) | |
tree | 549febe39dae54576aaa1a06e8f3386f847f41d5 /src/trg-torrent-add-dialog.c | |
parent | 338e194636b91413e765c8ac26079a972ed5cf56 (diff) |
truncate magnet links to 75 chars in add dialog, these can easily make the dialog oversized.
Diffstat (limited to 'src/trg-torrent-add-dialog.c')
-rw-r--r-- | src/trg-torrent-add-dialog.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/trg-torrent-add-dialog.c b/src/trg-torrent-add-dialog.c index 8cf56c3..b0cc87f 100644 --- a/src/trg-torrent-add-dialog.c +++ b/src/trg-torrent-add-dialog.c @@ -72,6 +72,8 @@ struct _TrgTorrentAddDialogPrivate { GtkWidget *delete_check; }; +#define MAGNET_MAX_LINK_WIDTH 75 + static void trg_torrent_add_dialog_set_property(GObject * object, guint prop_id, const GValue * value, @@ -526,7 +528,16 @@ trg_torrent_add_dialog_set_filenames(TrgTorrentAddDialog * d, if (nfiles == 1) { gchar *file_name = (gchar *) filenames->data; if (is_url(file_name) || is_magnet(file_name)) { - gtk_button_set_label(chooser, file_name); + if (strlen(file_name) > MAGNET_MAX_LINK_WIDTH) { + gchar *file_name_trunc = g_strndup(file_name, MAGNET_MAX_LINK_WIDTH); + gchar *file_name_trunc_fmt = g_strdup_printf("%s ...", file_name_trunc); + gtk_button_set_label(chooser, file_name_trunc_fmt); + g_free(file_name_trunc); + g_free(file_name_trunc_fmt); + } else { + gtk_button_set_label(chooser, file_name); + } + gtk_widget_set_sensitive(priv->file_list, FALSE); gtk_widget_set_sensitive(priv->delete_check, FALSE); } else { |