diff options
author | Alan Fitton <ajf@eth0.org.uk> | 2011-09-11 12:34:10 +0000 |
---|---|---|
committer | Alan Fitton <ajf@eth0.org.uk> | 2011-09-11 12:34:10 +0000 |
commit | fccdb76b5140f0764a5e6ad035e67519b5ee6f6a (patch) | |
tree | a516acfcc216f49f5bdefe6fed0173a10069917a /src | |
parent | be569c0953fcd777ae00ae41feb9c673e4df2f23 (diff) |
queue position setting
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/protocol-constants.h | 1 | ||||
-rw-r--r-- | src/requests.c | 1 | ||||
-rw-r--r-- | src/torrent.c | 8 | ||||
-rw-r--r-- | src/torrent.h | 1 | ||||
-rw-r--r-- | src/trg-cell-renderer-numgteqthan.c (renamed from src/trg-cell-renderer-numgtzero.c) | 62 | ||||
-rw-r--r-- | src/trg-cell-renderer-numgteqthan.h (renamed from src/trg-cell-renderer-numgtzero.h) | 36 | ||||
-rw-r--r-- | src/trg-main-window.c | 6 | ||||
-rw-r--r-- | src/trg-torrent-model.c | 3 | ||||
-rw-r--r-- | src/trg-torrent-model.h | 1 | ||||
-rw-r--r-- | src/trg-torrent-props-dialog.c | 7 | ||||
-rw-r--r-- | src/trg-torrent-tree-view.c | 3 | ||||
-rw-r--r-- | src/trg-tree-view.c | 13 | ||||
-rw-r--r-- | src/trg-tree-view.h | 1 |
14 files changed, 100 insertions, 45 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 49da641..e626f90 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -63,7 +63,7 @@ transmission_remote_gtk_SOURCES = main.c \ trg-cell-renderer-wanted.c \ trg-cell-renderer-priority.c \ trg-cell-renderer-epoch.c \ - trg-cell-renderer-numgtzero.c \ + trg-cell-renderer-numgteqthan.c \ trg-torrent-move-dialog.c \ trg-stats-dialog.c \ trg-torrent-graph.c \ diff --git a/src/protocol-constants.h b/src/protocol-constants.h index ccc91c4..33ceaa0 100644 --- a/src/protocol-constants.h +++ b/src/protocol-constants.h @@ -82,6 +82,7 @@ #define FIELD_PEERS_SENDING_TO_US "peersSendingToUs" #define FIELD_PEERS_GETTING_FROM_US "peersGettingFromUs" #define FIELD_PEERS_CONNECTED "peersConnected" +#define FIELD_QUEUE_POSITION "queuePosition" #define FIELD_FILES_WANTED "files-wanted" #define FIELD_FILES_UNWANTED "files-unwanted" diff --git a/src/requests.c b/src/requests.c index baefbc5..9f40bc2 100644 --- a/src/requests.c +++ b/src/requests.c @@ -142,6 +142,7 @@ JsonNode *torrent_get(gint64 id) json_array_add_string_element(fields, FIELD_ADDED_DATE); json_array_add_string_element(fields, FIELD_UPLOADEDEVER); json_array_add_string_element(fields, FIELD_SIZEWHENDONE); + json_array_add_string_element(fields, FIELD_QUEUE_POSITION); json_array_add_string_element(fields, FIELD_ID); json_array_add_string_element(fields, FIELD_NAME); json_array_add_string_element(fields, FIELD_PERCENTDONE); diff --git a/src/torrent.c b/src/torrent.c index 73fa66a..7b7ad07 100644 --- a/src/torrent.c +++ b/src/torrent.c @@ -387,6 +387,14 @@ gint64 torrent_get_peers_getting_from_us(JsonObject *args) return json_object_get_int_member(args, FIELD_PEERS_GETTING_FROM_US); } +gint64 torrent_get_queue_position(JsonObject *args) +{ + if (json_object_has_member(args, FIELD_QUEUE_POSITION)) + return json_object_get_int_member(args, FIELD_QUEUE_POSITION); + else + return -1; +} + /* tracker stats */ gint64 tracker_stats_get_id(JsonObject * t) diff --git a/src/torrent.h b/src/torrent.h index fc3f752..2e3ca16 100644 --- a/src/torrent.h +++ b/src/torrent.h @@ -82,6 +82,7 @@ gdouble torrent_get_seed_ratio_limit(JsonObject * t); gint64 torrent_get_seed_ratio_mode(JsonObject * t); gint64 torrent_get_peer_limit(JsonObject * t); gboolean torrent_has_tracker(JsonObject * t, GRegex * rx, gchar * search); +gint64 torrent_get_queue_position(JsonObject *args); /* outer response object */ diff --git a/src/trg-cell-renderer-numgtzero.c b/src/trg-cell-renderer-numgteqthan.c index 3ce9e47..a2bbd4a 100644 --- a/src/trg-cell-renderer-numgtzero.c +++ b/src/trg-cell-renderer-numgteqthan.c @@ -20,30 +20,32 @@ #include <stdint.h> #include <gtk/gtk.h> -#include "trg-cell-renderer-numgtzero.h" +#include "trg-cell-renderer-numgteqthan.h" #include "util.h" enum { PROP_0, - PROP_VALUE_VALUE + PROP_VALUE_VALUE, + PROP_MINVALUE }; -G_DEFINE_TYPE(TrgCellRendererNumgtzero, trg_cell_renderer_numgtzero, +G_DEFINE_TYPE(TrgCellRendererNumGtEqThan, trg_cell_renderer_numgteqthan, GTK_TYPE_CELL_RENDERER_TEXT) -#define TRG_CELL_RENDERER_NUMGTZERO_GET_PRIVATE(o) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRG_TYPE_CELL_RENDERER_NUMGTZERO, TrgCellRendererNumgtzeroPrivate)) -typedef struct _TrgCellRendererNumgtzeroPrivate TrgCellRendererNumgtzeroPrivate; +#define TRG_CELL_RENDERER_NUMGTEQTHAN_GET_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRG_TYPE_CELL_RENDERER_NUMGTEQTHAN, TrgCellRendererNumGtEqThanPrivate)) +typedef struct _TrgCellRendererNumGtEqThanPrivate TrgCellRendererNumGtEqThanPrivate; -struct _TrgCellRendererNumgtzeroPrivate { +struct _TrgCellRendererNumGtEqThanPrivate { gint64 value_value; + gint64 minvalue; }; static void -trg_cell_renderer_numgtzero_get_property(GObject * object, guint property_id, +trg_cell_renderer_numgteqthan_get_property(GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { - TrgCellRendererNumgtzeroPrivate *priv = - TRG_CELL_RENDERER_NUMGTZERO_GET_PRIVATE(object); + TrgCellRendererNumGtEqThanPrivate *priv = + TRG_CELL_RENDERER_NUMGTEQTHAN_GET_PRIVATE(object); switch (property_id) { case PROP_VALUE_VALUE: g_value_set_int64(value, priv->value_value); @@ -54,33 +56,35 @@ trg_cell_renderer_numgtzero_get_property(GObject * object, guint property_id, } static void -trg_cell_renderer_numgtzero_set_property(GObject * object, guint property_id, +trg_cell_renderer_numgteqthan_set_property(GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) { - TrgCellRendererNumgtzeroPrivate *priv = - TRG_CELL_RENDERER_NUMGTZERO_GET_PRIVATE(object); + TrgCellRendererNumGtEqThanPrivate *priv = + TRG_CELL_RENDERER_NUMGTEQTHAN_GET_PRIVATE(object); if (property_id == PROP_VALUE_VALUE) { priv->value_value = g_value_get_int64(value); - if (priv->value_value > 0) { + if (priv->value_value >= priv->minvalue) { gchar size_text[32]; g_snprintf(size_text, sizeof(size_text), "%ld", priv->value_value); g_object_set(object, "text", size_text, NULL); } else { g_object_set(object, "text", "", NULL); } + } else if (property_id == PROP_MINVALUE) { + priv->minvalue = g_value_get_int64(value); } else { G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); } } static void -trg_cell_renderer_numgtzero_class_init(TrgCellRendererNumgtzeroClass * klass) +trg_cell_renderer_numgteqthan_class_init(TrgCellRendererNumGtEqThanClass * klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); - object_class->get_property = trg_cell_renderer_numgtzero_get_property; - object_class->set_property = trg_cell_renderer_numgtzero_set_property; + object_class->get_property = trg_cell_renderer_numgteqthan_get_property; + object_class->set_property = trg_cell_renderer_numgteqthan_set_property; g_object_class_install_property(object_class, PROP_VALUE_VALUE, @@ -98,16 +102,32 @@ trg_cell_renderer_numgtzero_class_init(TrgCellRendererNumgtzeroClass * klass) | G_PARAM_STATIC_BLURB)); - g_type_class_add_private(klass, sizeof(TrgCellRendererNumgtzeroPrivate)); + g_object_class_install_property(object_class, + PROP_MINVALUE, + g_param_spec_int64("minvalue", + "Min Value", + "Min Value", + INT64_MIN, + INT64_MAX, + 1, + G_PARAM_READWRITE + | + G_PARAM_STATIC_NAME + | + G_PARAM_STATIC_NICK + | + G_PARAM_STATIC_BLURB)); + + g_type_class_add_private(klass, sizeof(TrgCellRendererNumGtEqThanPrivate)); } -static void trg_cell_renderer_numgtzero_init(TrgCellRendererNumgtzero * self) +static void trg_cell_renderer_numgteqthan_init(TrgCellRendererNumGtEqThan * self) { g_object_set(self, "xalign", 1.0f, NULL); } -GtkCellRenderer *trg_cell_renderer_numgtzero_new(void) +GtkCellRenderer *trg_cell_renderer_numgteqthan_new(gint64 minvalue) { return - GTK_CELL_RENDERER(g_object_new(TRG_TYPE_CELL_RENDERER_NUMGTZERO, NULL)); + GTK_CELL_RENDERER(g_object_new(TRG_TYPE_CELL_RENDERER_NUMGTEQTHAN, "minvalue", minvalue, NULL)); } diff --git a/src/trg-cell-renderer-numgtzero.h b/src/trg-cell-renderer-numgteqthan.h index 79d86a9..dca71c6 100644 --- a/src/trg-cell-renderer-numgtzero.h +++ b/src/trg-cell-renderer-numgteqthan.h @@ -17,35 +17,35 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef TRG_CELL_RENDERER_NUMGTZERO_H_ -#define TRG_CELL_RENDERER_NUMGTZERO_H_ +#ifndef TRG_CELL_RENDERER_NUMGTEQTHAN_H_ +#define TRG_CELL_RENDERER_NUMGTEQTHAN_H_ #include <glib-object.h> #include <gtk/gtk.h> G_BEGIN_DECLS -#define TRG_TYPE_CELL_RENDERER_NUMGTZERO trg_cell_renderer_numgtzero_get_type() -#define TRG_CELL_RENDERER_NUMGTZERO(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), TRG_TYPE_CELL_RENDERER_NUMGTZERO, TrgCellRendererNumgtzero)) -#define TRG_CELL_RENDERER_NUMGTZERO_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), TRG_TYPE_CELL_RENDERER_NUMGTZERO, TrgCellRendererNumgtzeroClass)) -#define TRG_IS_CELL_RENDERER_NUMGTZERO(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TRG_TYPE_CELL_RENDERER_NUMGTZERO)) -#define TRG_IS_CELL_RENDERER_NUMGTZERO_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), TRG_TYPE_CELL_RENDERER_NUMGTZERO)) -#define TRG_CELL_RENDERER_NUMGTZERO_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), TRG_TYPE_CELL_RENDERER_NUMGTZERO, TrgCellRendererNumgtzeroClass)) +#define TRG_TYPE_CELL_RENDERER_NUMGTEQTHAN trg_cell_renderer_numgteqthan_get_type() +#define TRG_CELL_RENDERER_NUMGTEQTHAN(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), TRG_TYPE_CELL_RENDERER_NUMGTEQTHAN, TrgCellRendererNumGtEqThan)) +#define TRG_CELL_RENDERER_NUMGTEQTHAN_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), TRG_TYPE_CELL_RENDERER_NUMGTEQTHAN, TrgCellRendererNumGtEqThanClass)) +#define TRG_IS_CELL_RENDERER_NUMGTEQTHAN(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TRG_TYPE_CELL_RENDERER_NUMGTEQTHAN)) +#define TRG_IS_CELL_RENDERER_NUMGTEQTHAN_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), TRG_TYPE_CELL_RENDERER_NUMGTEQTHAN)) +#define TRG_CELL_RENDERER_NUMGTEQTHAN_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), TRG_TYPE_CELL_RENDERER_NUMGTEQTHAN, TrgCellRendererNumGtEqThanClass)) typedef struct { GtkCellRendererText parent; -} TrgCellRendererNumgtzero; +} TrgCellRendererNumGtEqThan; typedef struct { GtkCellRendererTextClass parent_class; -} TrgCellRendererNumgtzeroClass; +} TrgCellRendererNumGtEqThanClass; -GType trg_cell_renderer_numgtzero_get_type(void); +GType trg_cell_renderer_numgteqthan_get_type(void); -GtkCellRenderer *trg_cell_renderer_numgtzero_new(void); +GtkCellRenderer *trg_cell_renderer_numgteqthan_new(gint64 minvalue); G_END_DECLS -#endif /* TRG_CELL_RENDERER_NUMGTZERO_H_ */ +#endif /* TRG_CELL_RENDERER_NUMGTEQTHAN_H_ */ diff --git a/src/trg-main-window.c b/src/trg-main-window.c index 972ba2d..0fee170 100644 --- a/src/trg-main-window.c +++ b/src/trg-main-window.c @@ -1050,6 +1050,8 @@ void on_generic_interactive_action(JsonObject * response, int status, if (status == CURLE_OK) { gint64 id; + gint updateStatus; + JsonObject *updateResponse; if (json_object_has_member(response, PARAM_TAG)) id = json_object_get_int_member(response, PARAM_TAG); else if (trg_client_get_activeonlyupdate(tc)) @@ -1057,8 +1059,8 @@ void on_generic_interactive_action(JsonObject * response, int status, else id = -1; - dispatch_async(priv->client, torrent_get(id), - on_torrent_get_interactive, data); + updateResponse = dispatch(tc, torrent_get(id), &updateStatus); + on_torrent_get_interactive(updateResponse, updateStatus, data); } } diff --git a/src/trg-torrent-model.c b/src/trg-torrent-model.c index 5438802..c4b29d0 100644 --- a/src/trg-torrent-model.c +++ b/src/trg-torrent-model.c @@ -177,6 +177,7 @@ static void trg_torrent_model_init(TrgTorrentModel * self) column_types[TORRENT_COLUMN_PEERS_FROM_US] = G_TYPE_INT64; column_types[TORRENT_COLUMN_PEERS_TO_US] = G_TYPE_INT64; column_types[TORRENT_COLUMN_TRACKERHOST] = G_TYPE_STRING; + column_types[TORRENT_COLUMN_QUEUE_POSITION] = G_TYPE_INT64; gtk_list_store_set_column_types(GTK_LIST_STORE(self), TORRENT_COLUMN_COLUMNS, column_types); @@ -306,6 +307,7 @@ update_torrent_iter(TrgTorrentModel * model, gint64 rpcv, gint64 serial, torrent_get_peers_getting_from_us(t), -1); gtk_list_store_set(ls, iter, TORRENT_COLUMN_TRACKERHOST, firstTracker ? tracker_stats_get_host(firstTracker) : "", -1); + gtk_list_store_set(ls, iter, TORRENT_COLUMN_QUEUE_POSITION, torrent_get_queue_position(t), -1); #else gtk_list_store_set(ls, iter, TORRENT_COLUMN_ICON, statusIcon, @@ -327,6 +329,7 @@ update_torrent_iter(TrgTorrentModel * model, gint64 rpcv, gint64 serial, TORRENT_COLUMN_PEERS_CONNECTED, torrent_get_peers_connected(t), TORRENT_COLUMN_PEERS_TO_US, torrent_get_peers_sending_to_us(t), TORRENT_COLUMN_PEERS_FROM_US, torrent_get_peers_getting_from_us(t), + TORRENT_COLUMN_QUEUE_POSITION, torrent_get_queue_position(t), TORRENT_COLUMN_RATIO, uploaded > 0 diff --git a/src/trg-torrent-model.h b/src/trg-torrent-model.h index a5d082f..e0fb4c5 100644 --- a/src/trg-torrent-model.h +++ b/src/trg-torrent-model.h @@ -105,6 +105,7 @@ enum { TORRENT_COLUMN_FROMPEX, TORRENT_COLUMN_FROMDHT, TORRENT_COLUMN_TRACKERHOST, + TORRENT_COLUMN_QUEUE_POSITION, TORRENT_COLUMN_COLUMNS }; diff --git a/src/trg-torrent-props-dialog.c b/src/trg-torrent-props-dialog.c index 73f21ac..35afb6d 100644 --- a/src/trg-torrent-props-dialog.c +++ b/src/trg-torrent-props-dialog.c @@ -169,8 +169,14 @@ static GtkWidget *trg_props_limitsPage(TrgTorrentPropsDialog * win, gtk_combo_box_append_text(GTK_COMBO_BOX(w), _("High")); gtk_combo_box_set_active(GTK_COMBO_BOX(w), torrent_get_bandwidth_priority(json) + 1); + hig_workarea_add_row(t, &row, _("Torrent priority:"), w, NULL); + if (json_object_has_member(json, FIELD_QUEUE_POSITION)) { + w = trg_json_widget_spin_new_int(&priv->widgets, json, FIELD_QUEUE_POSITION, NULL, 0, INT_MAX, 1); + hig_workarea_add_row(t, &row, _("Queue Position:"), w, w); + } + tb = trg_json_widget_check_new(&priv->widgets, json, FIELD_DOWNLOAD_LIMITED, _("Limit download speed (Kbps)"), NULL); w = trg_json_widget_spin_new_int(&priv->widgets, json, FIELD_DOWNLOAD_LIMIT, tb, 0, INT_MAX, 1); hig_workarea_add_row_w(t, &row, tb, w, NULL); @@ -182,7 +188,6 @@ static GtkWidget *trg_props_limitsPage(TrgTorrentPropsDialog * win, hig_workarea_add_section_title(t, &row, _("Seeding")); w = priv->seedRatioMode = gtk_combo_box_new_text(); - //widget_set_json_key(GTK_WIDGET(w), FIELD_SEED_RATIO_MODE); gtk_combo_box_append_text(GTK_COMBO_BOX(w), _("Use global settings")); gtk_combo_box_append_text(GTK_COMBO_BOX(w), _("Stop seeding at ratio")); diff --git a/src/trg-torrent-tree-view.c b/src/trg-torrent-tree-view.c index 77fb9b4..f426c26 100644 --- a/src/trg-torrent-tree-view.c +++ b/src/trg-torrent-tree-view.c @@ -101,6 +101,9 @@ static void trg_torrent_tree_view_init(TrgTorrentTreeView * tttv) trg_tree_view_reg_column(ttv, TRG_COLTYPE_PRIO, TORRENT_COLUMN_BANDWIDTH_PRIORITY, _("Priority"), "priority", TRG_COLUMN_EXTRA); + trg_tree_view_reg_column(ttv, TRG_COLTYPE_NUMGTEQZERO, + TORRENT_COLUMN_QUEUE_POSITION, + _("Queue Position"), "queue-position", TRG_COLUMN_EXTRA); trg_tree_view_reg_column(ttv, TRG_COLTYPE_EPOCH, TORRENT_COLUMN_DONE_DATE, _("Completed"), "done-date", TRG_COLUMN_EXTRA); diff --git a/src/trg-tree-view.c b/src/trg-tree-view.c index d75b35a..9fccb57 100644 --- a/src/trg-tree-view.c +++ b/src/trg-tree-view.c @@ -31,7 +31,7 @@ #include "trg-cell-renderer-epoch.h" #include "trg-cell-renderer-wanted.h" #include "trg-cell-renderer-priority.h" -#include "trg-cell-renderer-numgtzero.h" +#include "trg-cell-renderer-numgteqthan.h" enum { PROP_0, @@ -333,7 +333,16 @@ static void trg_tree_view_add_column_after(TrgTreeView * tv, NULL); break; case TRG_COLTYPE_NUMGTZERO: - renderer = trg_cell_renderer_numgtzero_new(); + renderer = trg_cell_renderer_numgteqthan_new(1); + column = + gtk_tree_view_column_new_with_attributes(desc->header, + renderer, + "value", + desc->model_column, + NULL); + break; + case TRG_COLTYPE_NUMGTEQZERO: + renderer = trg_cell_renderer_numgteqthan_new(0); column = gtk_tree_view_column_new_with_attributes(desc->header, renderer, diff --git a/src/trg-tree-view.h b/src/trg-tree-view.h index 3a4e4ba..7a512dd 100644 --- a/src/trg-tree-view.h +++ b/src/trg-tree-view.h @@ -62,6 +62,7 @@ enum { TRG_COLTYPE_WANT, TRG_COLTYPE_PRIO, TRG_COLTYPE_NUMGTZERO, + TRG_COLTYPE_NUMGTEQZERO } TrgColumnType; typedef struct { |