Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small UI improvements (GTK, Qt) #11

Merged
merged 1 commit into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@

### GTK+ Client
- Stop eating the last message at each refresh of the Message Log
- UI: better visual torrent separation

### Qt Client
- Fix download percentage bar glitch ([#3150](https://github.com/transmission/transmission/issues/3150))
- UI: move the status line above the progress bar


## [Transmission 3.00](https://github.com/transmission/transmission/releases/tag/3.00) (2020-05-03)
Expand Down
44 changes: 22 additions & 22 deletions gtk/torrent-cell-renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static void getProgressString(GString* gstr, tr_torrent const* tor, tr_info cons
%4$s is how much we've uploaded,
%5$s is our upload-to-download ratio,
%6$s is the ratio we want to reach before we stop uploading */
_("%1$s of %2$s (%3$s%%), uploaded %4$s (Ratio: %5$s Goal: %6$s)"),
_("%1$s of %2$s (%3$s%%), uploaded %4$s (Ratio: <b>%5$s</b> Goal: %6$s)"),
tr_strlsize(buf1, haveTotal, sizeof(buf1)),
tr_strlsize(buf2, info->totalSize, sizeof(buf2)),
tr_strlpercent(buf3, st->percentComplete * 100.0, sizeof(buf3)),
Expand All @@ -88,7 +88,7 @@ static void getProgressString(GString* gstr, tr_torrent const* tor, tr_info cons
%3$s%% is a percentage of the two,
%4$s is how much we've uploaded,
%5$s is our upload-to-download ratio */
_("%1$s of %2$s (%3$s%%), uploaded %4$s (Ratio: %5$s)"),
_("%1$s of %2$s (%3$s%%), uploaded %4$s (Ratio: <b>%5$s</b>)"),
tr_strlsize(buf1, haveTotal, sizeof(buf1)),
tr_strlsize(buf2, info->totalSize, sizeof(buf2)),
tr_strlpercent(buf3, st->percentComplete * 100.0, sizeof(buf3)),
Expand All @@ -105,7 +105,7 @@ static void getProgressString(GString* gstr, tr_torrent const* tor, tr_info cons
%2$s is how much we've uploaded,
%3$s is our upload-to-download ratio,
%4$s is the ratio we want to reach before we stop uploading */
_("%1$s, uploaded %2$s (Ratio: %3$s Goal: %4$s)"),
_("%1$s, uploaded %2$s (Ratio: <b>%3$s</b> Goal: %4$s)"),
tr_strlsize(buf1, info->totalSize, sizeof(buf1)),
tr_strlsize(buf2, st->uploadedEver, sizeof(buf2)),
tr_strlratio(buf3, st->ratio, sizeof(buf3)),
Expand All @@ -117,7 +117,7 @@ static void getProgressString(GString* gstr, tr_torrent const* tor, tr_info cons
/* %1$s is the torrent's total size,
%2$s is how much we've uploaded,
%3$s is our upload-to-download ratio */
_("%1$s, uploaded %2$s (Ratio: %3$s)"),
_("%1$s, uploaded %2$s (Ratio: <b>%3$s</b>)"),
tr_strlsize(buf1, info->totalSize, sizeof(buf1)),
tr_strlsize(buf2, st->uploadedEver, sizeof(buf2)),
tr_strlratio(buf3, st->ratio, sizeof(buf3)));
Expand Down Expand Up @@ -216,7 +216,7 @@ static void getShortStatusString(GString* gstr, tr_torrent const* tor, tr_stat c
tr_strlratio(ratioStr, st->ratio, sizeof(ratioStr));
getShortTransferString(tor, st, uploadSpeed_KBps, downloadSpeed_KBps, speedStr, sizeof(speedStr));
/* download/upload speed, ratio */
g_string_append_printf(gstr, "%1$s Ratio: %2$s", speedStr, ratioStr);
g_string_append_printf(gstr, "%1$s Ratio: <b>%2$s</b>", speedStr, ratioStr);
break;
}

Expand Down Expand Up @@ -397,7 +397,7 @@ static void get_size_compact(TorrentCellRenderer* cell, GtkWidget* widget, gint*
gtr_cell_renderer_get_preferred_size(p->icon_renderer, widget, NULL, &icon_size);
g_object_set(p->text_renderer, "text", name, "ellipsize", PANGO_ELLIPSIZE_NONE, "scale", 1.0, NULL);
gtr_cell_renderer_get_preferred_size(p->text_renderer, widget, NULL, &name_size);
g_object_set(p->text_renderer, "text", gstr_stat->str, "scale", SMALL_SCALE, NULL);
g_object_set(p->text_renderer, "markup", gstr_stat->str, "scale", SMALL_SCALE, NULL);
gtr_cell_renderer_get_preferred_size(p->text_renderer, widget, NULL, &stat_size);

/**
Expand Down Expand Up @@ -452,9 +452,9 @@ static void get_size_full(TorrentCellRenderer* cell, GtkWidget* widget, gint* wi
g_object_set(p->text_renderer, "text", name, "weight", PANGO_WEIGHT_BOLD, "scale", 1.0, "ellipsize", PANGO_ELLIPSIZE_NONE,
NULL);
gtr_cell_renderer_get_preferred_size(p->text_renderer, widget, NULL, &name_size);
g_object_set(p->text_renderer, "text", gstr_prog->str, "weight", PANGO_WEIGHT_NORMAL, "scale", SMALL_SCALE, NULL);
g_object_set(p->text_renderer, "markup", gstr_prog->str, "weight", PANGO_WEIGHT_NORMAL, "scale", SMALL_SCALE, NULL);
gtr_cell_renderer_get_preferred_size(p->text_renderer, widget, NULL, &prog_size);
g_object_set(p->text_renderer, "text", gstr_stat->str, NULL);
g_object_set(p->text_renderer, "markup", gstr_stat->str, NULL);
gtr_cell_renderer_get_preferred_size(p->text_renderer, widget, NULL, &stat_size);

/**
Expand Down Expand Up @@ -614,7 +614,7 @@ static void render_compact(TorrentCellRenderer* cell, GtrDrawable* window, GtkWi
g_object_set(p->text_renderer, "text", name, "ellipsize", PANGO_ELLIPSIZE_NONE, "scale", 1.0, NULL);
gtr_cell_renderer_get_preferred_size(p->text_renderer, widget, NULL, &size);
name_area.width = size.width;
g_object_set(p->text_renderer, "text", gstr_stat->str, "scale", SMALL_SCALE, NULL);
g_object_set(p->text_renderer, "markup", gstr_stat->str, "scale", SMALL_SCALE, NULL);
gtr_cell_renderer_get_preferred_size(p->text_renderer, widget, NULL, &size);
stat_area.width = size.width;

Expand All @@ -634,7 +634,7 @@ static void render_compact(TorrentCellRenderer* cell, GtrDrawable* window, GtkWi
gtr_cell_renderer_render(p->icon_renderer, window, widget, &icon_area, flags);
g_object_set(p->progress_renderer, "value", (int)(percentDone * 100.0), "text", NULL, "sensitive", sensitive, NULL);
gtr_cell_renderer_render(p->progress_renderer, window, widget, &prog_area, flags);
g_object_set(p->text_renderer, "text", gstr_stat->str, "scale", SMALL_SCALE, "ellipsize", PANGO_ELLIPSIZE_END,
g_object_set(p->text_renderer, "markup", gstr_stat->str, "scale", SMALL_SCALE, "ellipsize", PANGO_ELLIPSIZE_END,
FOREGROUND_COLOR_KEY, &text_color, NULL);
gtr_cell_renderer_render(p->text_renderer, window, widget, &stat_area, flags);
g_object_set(p->text_renderer, "text", name, "scale", 1.0, FOREGROUND_COLOR_KEY, &text_color, NULL);
Expand Down Expand Up @@ -691,11 +691,11 @@ static void render_full(TorrentCellRenderer* cell, GtrDrawable* window, GtkWidge
gtr_cell_renderer_get_preferred_size(p->text_renderer, widget, NULL, &size);
name_area.width = size.width;
name_area.height = size.height;
g_object_set(p->text_renderer, "text", gstr_prog->str, "weight", PANGO_WEIGHT_NORMAL, "scale", SMALL_SCALE, NULL);
g_object_set(p->text_renderer, "markup", gstr_prog->str, "weight", PANGO_WEIGHT_NORMAL, "scale", SMALL_SCALE, NULL);
gtr_cell_renderer_get_preferred_size(p->text_renderer, widget, NULL, &size);
prog_area.width = size.width;
prog_area.height = size.height;
g_object_set(p->text_renderer, "text", gstr_stat->str, NULL);
g_object_set(p->text_renderer, "markup", gstr_stat->str, NULL);
gtr_cell_renderer_get_preferred_size(p->text_renderer, widget, NULL, &size);
stat_area.width = size.width;
stat_area.height = size.height;
Expand Down Expand Up @@ -724,17 +724,17 @@ static void render_full(TorrentCellRenderer* cell, GtrDrawable* window, GtkWidge
prog_area.y = name_area.y + name_area.height;
prog_area.width = name_area.width;

/* status */
stat_area.x = prog_area.x;
stat_area.y = prog_area.y + prog_area.height + GUI_PAD_SMALL;
stat_area.width = prog_area.width;

/* progressbar */
prct_area.x = prog_area.x;
prct_area.y = prog_area.y + prog_area.height + GUI_PAD_SMALL;
prct_area.width = prog_area.width;
prct_area.x = stat_area.x;
prct_area.y = stat_area.y + stat_area.height + GUI_PAD_SMALL;
prct_area.width = stat_area.width;
prct_area.height = p->bar_height;

/* status */
stat_area.x = prct_area.x;
stat_area.y = prct_area.y + prct_area.height + GUI_PAD_SMALL;
stat_area.width = prct_area.width;

/**
*** RENDER
**/
Expand All @@ -744,11 +744,11 @@ static void render_full(TorrentCellRenderer* cell, GtrDrawable* window, GtkWidge
g_object_set(p->text_renderer, "text", name, "scale", 1.0, FOREGROUND_COLOR_KEY, &text_color, "ellipsize",
PANGO_ELLIPSIZE_END, "weight", PANGO_WEIGHT_BOLD, NULL);
gtr_cell_renderer_render(p->text_renderer, window, widget, &name_area, flags);
g_object_set(p->text_renderer, "text", gstr_prog->str, "scale", SMALL_SCALE, "weight", PANGO_WEIGHT_NORMAL, NULL);
g_object_set(p->text_renderer, "markup", gstr_prog->str, "scale", SMALL_SCALE, "weight", PANGO_WEIGHT_NORMAL, NULL);
gtr_cell_renderer_render(p->text_renderer, window, widget, &prog_area, flags);
g_object_set(p->progress_renderer, "value", (int)(percentDone * 100.0), "text", "", "sensitive", sensitive, NULL);
gtr_cell_renderer_render(p->progress_renderer, window, widget, &prct_area, flags);
g_object_set(p->text_renderer, "text", gstr_stat->str, FOREGROUND_COLOR_KEY, &text_color, NULL);
g_object_set(p->text_renderer, "markup", gstr_stat->str, FOREGROUND_COLOR_KEY, &text_color, NULL);
gtr_cell_renderer_render(p->text_renderer, window, widget, &stat_area, flags);

/* cleanup */
Expand Down
4 changes: 4 additions & 0 deletions gtk/tr-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ static GtkWidget* makeview(PrivateData* p)
gtk_tree_view_set_headers_visible(tree_view, FALSE);
gtk_tree_view_set_fixed_height_mode(tree_view, TRUE);

GtkCssProvider *provider = gtk_css_provider_new();
gtk_css_provider_load_from_data(provider, ".view {border: 1px solid #d0d0d0;}", -1, NULL);
gtk_style_context_add_provider(gtk_widget_get_style_context(view), GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);

p->selection = gtk_tree_view_get_selection(tree_view);

p->column = col = GTK_TREE_VIEW_COLUMN(g_object_new(GTK_TYPE_TREE_VIEW_COLUMN, "title", _("Torrent"), "resizable", TRUE,
Expand Down
4 changes: 2 additions & 2 deletions qt/TorrentDelegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ ItemLayout::ItemLayout(QString const& nameText, QString const& statusText, QStri

nameRect = baseRect.adjusted(0, 0, 0, nameSize.height());
statusRect = nameRect.adjusted(0, nameRect.height() + 1, 0, statusSize.height() + 1);
barRect = statusRect.adjusted(0, statusRect.height() + 1, 0, BAR_HEIGHT + 1);
progressRect = barRect.adjusted(0, barRect.height() + 1, 0, progressSize.height() + 1);
progressRect = statusRect.adjusted(0, statusRect.height() + 1, 0, progressSize.height() + 1);
barRect = progressRect.adjusted(0, progressRect.height() + 1, 0, BAR_HEIGHT + 1);
iconRect = style->alignedRect(direction, Qt::AlignLeft | Qt::AlignVCenter, QSize(iconSize, iconSize),
QRect(topLeft, QSize(width, progressRect.bottom() - nameRect.top())));
emblemRect = style->alignedRect(direction, Qt::AlignRight | Qt::AlignBottom,
Expand Down