summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Alan Fitton <ajf@eth0.org.uk>2011-04-14 21:26:45 +0000
committerGravatar Alan Fitton <ajf@eth0.org.uk>2011-04-14 21:26:45 +0000
commit4a6cfa60774e14c8136fb6903fe72c1e07d720d7 (patch)
tree7a8752f1af5f9681b6adb9f1c3610c56da607f96 /src
parent9cc8920afb3e2b1274ce36e1a0a8033783ae15e8 (diff)
show speed limits in status bar, thanks to jdhore for the patch.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/trg-main-window.c16
-rw-r--r--src/trg-status-bar.c34
-rw-r--r--src/trg-status-bar.h2
-rw-r--r--src/trg-torrent-add-dialog.c2
5 files changed, 40 insertions, 16 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 229211f..11086c4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -23,7 +23,7 @@ schemadir = @GCONF_SCHEMA_FILE_DIR@
schema_DATA = transmission-remote-gtk.schemas
bin_PROGRAMS = transmission-remote-gtk
-INCLUDES = --pedantic -Wall -I.. -O2 -DTRGLICENSE=\""$(trglicense)"\" -DTRGLOCALEDIR=\""$(trglocaledir)"\" $(jsonglib_CFLAGS) $(gthread_CFLAGS) $(gtk_CFLAGS) $(gconf_CFLAGS) $(gio_CFLAGS) $(unique_CFLAGS) $(notify_CFLAGS)
+INCLUDES = --pedantic -Wall -I.. -O2 -DTRGLICENSE=\""$(trglicense)"\" -DTRGLOCALEDIR=\""$(trglocaledir)"\" $(jsonglib_CFLAGS) $(gthread_CFLAGS) $(gtk_CFLAGS) $(gconf_CFLAGS) $(gio_CFLAGS) $(unique_CFLAGS) $(notify_CFLAGS) -std=gnu99
transmission_remote_gtk_SOURCES = main.c \
requests.c \
diff --git a/src/trg-main-window.c b/src/trg-main-window.c
index bafa3e6..17af3e3 100644
--- a/src/trg-main-window.c
+++ b/src/trg-main-window.c
@@ -935,7 +935,7 @@ on_torrent_get(JsonObject * response, int mode, int status, gpointer data)
update_selected_torrent_notebook(TRG_MAIN_WINDOW(data), mode);
- trg_status_bar_update(priv->statusBar, &stats);
+ trg_status_bar_update(priv->statusBar, &stats, client);
if (priv->graphNotebookIndex >= 0)
trg_torrent_graph_set_speed(priv->graph, &stats);
@@ -1410,7 +1410,7 @@ static GtkWidget *limit_item_new(TrgMainWindow * win, GtkWidget * menu,
gboolean active = limit < 0 ? FALSE : (currentLimit == (gint64) limit);
if (limit >= 1000)
- g_snprintf(speed, sizeof(speed), "%.2f MB/s", limit / 1000);
+ g_snprintf(speed, sizeof(speed), "%.2f MB/s", limit / 1024);
else
g_snprintf(speed, sizeof(speed), "%.0f KB/s", limit);
@@ -1482,12 +1482,12 @@ static GtkWidget *limit_menu_new(TrgMainWindow * win, gchar * title,
limit_item_new(win, menu, limit, 400);
limit_item_new(win, menu, limit, 500);
limit_item_new(win, menu, limit, 750);
- limit_item_new(win, menu, limit, 1000);
- limit_item_new(win, menu, limit, 1250);
- limit_item_new(win, menu, limit, 1500);
- limit_item_new(win, menu, limit, 2000);
- limit_item_new(win, menu, limit, 2500);
- limit_item_new(win, menu, limit, 3000);
+ limit_item_new(win, menu, limit, 1024);
+ limit_item_new(win, menu, limit, 1280);
+ limit_item_new(win, menu, limit, 1536);
+ limit_item_new(win, menu, limit, 2048);
+ limit_item_new(win, menu, limit, 2560);
+ limit_item_new(win, menu, limit, 3072);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(toplevel), menu);
diff --git a/src/trg-status-bar.c b/src/trg-status-bar.c
index c5a0ca1..34b53ed 100644
--- a/src/trg-status-bar.c
+++ b/src/trg-status-bar.c
@@ -78,25 +78,49 @@ void trg_status_bar_connect(TrgStatusBar * sb, JsonObject * session)
}
void trg_status_bar_update(TrgStatusBar * sb,
- trg_torrent_model_update_stats * stats)
+ trg_torrent_model_update_stats * stats, trg_client * client)
{
TrgStatusBarPrivate *priv;
gchar *statusBarUpdate;
+ gint64 uplimitraw, downlimitraw;
gchar downRateTotalString[32], upRateTotalString[32];
+ gchar uplimit[64], downlimit[64];
priv = TRG_STATUS_BAR_GET_PRIVATE(sb);
+ /* The session should always exist otherwise this function wouldn't be called */
+ downlimitraw = json_object_get_boolean_member(client->session, SGET_SPEED_LIMIT_DOWN_ENABLED) ?
+ json_object_get_int_member(client->session, SGET_SPEED_LIMIT_DOWN) : -1;
+
+ uplimitraw = json_object_get_boolean_member(client->session, SGET_SPEED_LIMIT_UP_ENABLED) ?
+ json_object_get_int_member(client->session, SGET_SPEED_LIMIT_UP) : -1;
+
trg_strlspeed(downRateTotalString,
stats->downRateTotal / KILOBYTE_FACTOR);
trg_strlspeed(upRateTotalString, stats->upRateTotal / KILOBYTE_FACTOR);
+ if (uplimitraw >= 0)
+ {
+ gchar uplimitstring[32];
+ trg_strlspeed(uplimitstring, uplimitraw);
+ g_snprintf(uplimit, sizeof(uplimit), _( " (Limit: %s)" ), uplimitstring);
+ }
+
+ if (downlimitraw >= 0)
+ {
+ gchar downlimitstring[32];
+ trg_strlspeed(downlimitstring, downlimitraw);
+ g_snprintf(downlimit, sizeof(downlimit), _( " (Limit: %s)" ), downlimitstring);
+ }
+
statusBarUpdate =
g_strdup_printf
(ngettext
- ("%d torrent .. Down %s, Up %s .. %d seeding, %d downloading, %d paused",
- "%d torrents .. Down %s, Up %s .. %d seeding, %d downloading, %d paused",
- stats->count), stats->count, downRateTotalString,
- upRateTotalString, stats->seeding, stats->down, stats->paused);
+ ("%d torrent .. Down %s%s, Up %s%s .. %d seeding, %d downloading, %d paused",
+ "%d torrents .. Down %s%s, Up %s%s .. %d seeding, %d downloading, %d paused",
+ stats->count), stats->count, downRateTotalString, downlimitraw >= 0 ? downlimit : "",
+ upRateTotalString, uplimitraw >= 0 ? uplimit : "",
+ stats->seeding, stats->down, stats->paused);
gtk_statusbar_pop(GTK_STATUSBAR(sb), priv->countSpeedsCtx);
gtk_statusbar_push(GTK_STATUSBAR(sb),
priv->countSpeedsCtx, statusBarUpdate);
diff --git a/src/trg-status-bar.h b/src/trg-status-bar.h
index 5908c9f..27f2c44 100644
--- a/src/trg-status-bar.h
+++ b/src/trg-status-bar.h
@@ -52,7 +52,7 @@ TrgStatusBar *trg_status_bar_new();
G_END_DECLS
void trg_status_bar_update(TrgStatusBar * sb,
- trg_torrent_model_update_stats * stats);
+ trg_torrent_model_update_stats * stats, trg_client * client);
void trg_status_bar_connect(TrgStatusBar * sb, JsonObject * session);
void trg_status_bar_push_connection_msg(TrgStatusBar * sb,
const gchar * msg);
diff --git a/src/trg-torrent-add-dialog.c b/src/trg-torrent-add-dialog.c
index 5ea7a6a..0b018a0 100644
--- a/src/trg-torrent-add-dialog.c
+++ b/src/trg-torrent-add-dialog.c
@@ -241,7 +241,7 @@ static void launch_add_thread(struct add_torrent_threadfunc_args *args)
GError *error = NULL;
g_thread_create(add_files_threadfunc, args, FALSE, &error);
- if (error != NULL) {
+ if (error) {
g_printf("thread creation error: %s\n", error->message);
g_error_free(error);
g_str_slist_free(args->list);