diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/protocol-constants.h | 1 | ||||
-rw-r--r-- | src/requests.c | 1 | ||||
-rw-r--r-- | src/torrent.c | 5 | ||||
-rw-r--r-- | src/torrent.h | 1 | ||||
-rw-r--r-- | src/trg-general-panel.c | 148 | ||||
-rw-r--r-- | src/trg-main-window.c | 22 | ||||
-rw-r--r-- | src/trg-menu-bar.c | 17 | ||||
-rw-r--r-- | src/trg-preferences-dialog.c | 14 | ||||
-rw-r--r-- | src/trg-prefs.c | 1 | ||||
-rw-r--r-- | src/trg-prefs.h | 1 | ||||
-rw-r--r-- | src/trg-state-selector.c | 36 | ||||
-rw-r--r-- | src/trg-state-selector.h | 1 | ||||
-rw-r--r-- | src/trg-stats-dialog.c | 25 | ||||
-rw-r--r-- | src/trg-toolbar.c | 4 | ||||
-rw-r--r-- | src/trg-torrent-props-dialog.c | 14 | ||||
-rw-r--r-- | src/util.c | 2 |
16 files changed, 213 insertions, 80 deletions
diff --git a/src/protocol-constants.h b/src/protocol-constants.h index 061a10e..8fffb00 100644 --- a/src/protocol-constants.h +++ b/src/protocol-constants.h @@ -56,6 +56,7 @@ #define FIELD_ETA "eta" #define FIELD_UPLOADEDEVER "uploadedEver" #define FIELD_DOWNLOADEDEVER "downloadedEver" +#define FIELD_CORRUPTEVER "corruptEver" #define FIELD_HAVEVALID "haveValid" #define FIELD_HAVEUNCHECKED "haveUnchecked" #define FIELD_PERCENTDONE "percentDone" diff --git a/src/requests.c b/src/requests.c index 2234302..4e044ab 100644 --- a/src/requests.c +++ b/src/requests.c @@ -184,6 +184,7 @@ JsonNode *torrent_get(gint64 id) json_array_add_string_element(fields, FIELD_ADDED_DATE); json_array_add_string_element(fields, FIELD_DOWNLOADEDEVER); json_array_add_string_element(fields, FIELD_UPLOADEDEVER); + json_array_add_string_element(fields, FIELD_CORRUPTEVER); 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); diff --git a/src/torrent.c b/src/torrent.c index fc4eaa8..e5577ee 100644 --- a/src/torrent.c +++ b/src/torrent.c @@ -180,6 +180,11 @@ gint64 torrent_get_uploaded(JsonObject * t) return json_object_get_int_member(t, FIELD_UPLOADEDEVER); } +gint64 torrent_get_corrupted(JsonObject * t) +{ + return json_object_get_int_member(t, FIELD_CORRUPTEVER); +} + gint64 torrent_get_have_valid(JsonObject * t) { return json_object_get_int_member(t, FIELD_HAVEVALID); diff --git a/src/torrent.h b/src/torrent.h index cebdd76..c837046 100644 --- a/src/torrent.h +++ b/src/torrent.h @@ -51,6 +51,7 @@ gint64 torrent_get_rate_down(JsonObject * t); gint64 torrent_get_rate_up(JsonObject * t); gint64 torrent_get_eta(JsonObject * t); gint64 torrent_get_uploaded(JsonObject * t); +gint64 torrent_get_corrupted(JsonObject * t); gint64 torrent_get_downloaded(JsonObject * t); const gchar *torrent_get_errorstr(JsonObject * t); gint64 torrent_get_error(JsonObject * t); diff --git a/src/trg-general-panel.c b/src/trg-general-panel.c index cbcad42..7cb2a90 100644 --- a/src/trg-general-panel.c +++ b/src/trg-general-panel.c @@ -31,6 +31,7 @@ #include "util.h" #include "trg-general-panel.h" #include "trg-torrent-model.h" +#include "protocol-constants.h" #define TRG_GENERAL_PANEL_WIDTH_FROM_KEY 20 #define TRG_GENERAL_PANEL_WIDTH_FROM_VALUE 60 @@ -57,12 +58,15 @@ struct _TrgGeneralPanelPrivate { GtkLabel *gen_seeders_label; GtkLabel *gen_leechers_label; GtkLabel *gen_status_label; + GtkLabel *gen_priority_label; GtkLabel *gen_eta_label; GtkLabel *gen_downloaded_label; GtkLabel *gen_uploaded_label; + GtkLabel *gen_corrupted_label; GtkLabel *gen_down_rate_label; GtkLabel *gen_up_rate_label; GtkLabel *gen_ratio_label; + GtkLabel *gen_limit_label; GtkLabel *gen_completedat_label; GtkLabel *gen_downloaddir_label; GtkLabel *gen_comment_label; @@ -81,12 +85,15 @@ void trg_general_panel_clear(TrgGeneralPanel * panel) gtk_label_clear(priv->gen_seeders_label); gtk_label_clear(priv->gen_leechers_label); gtk_label_clear(priv->gen_status_label); + gtk_label_clear(priv->gen_priority_label); gtk_label_clear(priv->gen_eta_label); gtk_label_clear(priv->gen_downloaded_label); gtk_label_clear(priv->gen_uploaded_label); + gtk_label_clear(priv->gen_corrupted_label); gtk_label_clear(priv->gen_down_rate_label); gtk_label_clear(priv->gen_up_rate_label); gtk_label_clear(priv->gen_ratio_label); + gtk_label_clear(priv->gen_limit_label); gtk_label_clear(priv->gen_completedat_label); gtk_label_clear(priv->gen_downloaddir_label); gtk_label_clear(priv->gen_comment_label); @@ -115,12 +122,10 @@ trg_general_panel_update(TrgGeneralPanel * panel, JsonObject * t, GtkTreeIter * iter) { TrgGeneralPanelPrivate *priv; - gchar buf[32]; - gint sizeOfBuf; - gchar *statusString, *fullStatusString, *completedAtString, *comment, - *markup; + gchar buf[32], buf1[32]; //TODO: do it better + gchar *statusString, *fullStatusString, *completedAtString, *speed, *comment, *markup; const gchar *errorStr; - gint64 eta, uploaded, haveValid, completedAt; + gint64 eta, uploaded, corrupted, haveValid, completedAt; GtkLabel *keyLabel; gint64 seeders = 0, leechers = 0; @@ -131,16 +136,30 @@ trg_general_panel_update(TrgGeneralPanel * panel, JsonObject * t, TORRENT_COLUMN_LEECHERS, &leechers, TORRENT_COLUMN_STATUS, &statusString, -1); - sizeOfBuf = sizeof(buf); - trg_strlsize(buf, torrent_get_size_when_done(t)); gtk_label_set_text(GTK_LABEL(priv->gen_size_label), buf); - trg_strlspeed(buf, torrent_get_rate_down(t) / disk_K); - gtk_label_set_text(GTK_LABEL(priv->gen_down_rate_label), buf); - - trg_strlspeed(buf, torrent_get_rate_up(t) / disk_K); - gtk_label_set_text(GTK_LABEL(priv->gen_up_rate_label), buf); + trg_strlspeed(buf, torrent_get_rate_down(t) / disk_K); + if (torrent_get_download_limited(t)){ + trg_strlspeed(buf1, torrent_get_download_limit(t)); + speed = g_strdup_printf("%s [%s]", buf, buf1); + } else + speed = g_strdup_printf("%s", buf); + gtk_label_set_text(GTK_LABEL(priv->gen_down_rate_label), speed); + g_free(speed); + + trg_strlspeed(buf, torrent_get_rate_up(t) / disk_K); + if (torrent_get_upload_limited(t)){ + trg_strlspeed(buf1, torrent_get_upload_limit(t)); + speed = g_strdup_printf("%s [%s]", buf, buf1); + } else + speed = g_strdup_printf("%s", buf); + gtk_label_set_text(GTK_LABEL(priv->gen_up_rate_label), speed); + g_free(speed); + + corrupted = torrent_get_corrupted(t); + trg_strlsize(buf, corrupted); + gtk_label_set_text(GTK_LABEL(priv->gen_corrupted_label), buf); uploaded = torrent_get_uploaded(t); trg_strlsize(buf, uploaded); @@ -157,6 +176,9 @@ trg_general_panel_update(TrgGeneralPanel * panel, JsonObject * t, gtk_label_set_text(GTK_LABEL(priv->gen_ratio_label), _("N/A")); } + trg_strlratio(buf, torrent_get_seed_ratio_limit(t)); + gtk_label_set_text(GTK_LABEL(priv->gen_limit_label), buf); + completedAt = torrent_get_done_date(t); if (completedAt > 0) { completedAtString = epoch_to_string(completedAt); @@ -175,6 +197,18 @@ trg_general_panel_update(TrgGeneralPanel * panel, JsonObject * t, g_free(fullStatusString); g_free(statusString); + switch(torrent_get_bandwidth_priority(t)){ + case TR_PRI_LOW: + gtk_label_set_text(GTK_LABEL(priv->gen_priority_label), _("Low")); + break; + case TR_PRI_NORMAL: + gtk_label_set_text(GTK_LABEL(priv->gen_priority_label), _("Normal")); + break; + case TR_PRI_HIGH: + gtk_label_set_text(GTK_LABEL(priv->gen_priority_label), _("High")); + break; + } + trg_strlpercent(buf, torrent_get_percent_done(t)); gtk_label_set_text(GTK_LABEL(priv->gen_completed_label), buf); @@ -210,7 +244,7 @@ trg_general_panel_update(TrgGeneralPanel * panel, JsonObject * t, } if ((eta = torrent_get_eta(t)) > 0) { - tr_strltime_long(buf, eta, sizeOfBuf); + tr_strltime_long(buf, eta, sizeof(buf)); gtk_label_set_text(GTK_LABEL(priv->gen_eta_label), buf); } else { gtk_label_set_text(GTK_LABEL(priv->gen_eta_label), _("N/A")); @@ -278,48 +312,52 @@ static void trg_general_panel_init(TrgGeneralPanel * self) g_object_set(G_OBJECT(self), "n-columns", TRG_GENERAL_PANEL_COLUMNS_TOTAL, "n-rows", 7, NULL); - priv->gen_name_label = - trg_general_panel_add_label_with_width(self, _("Name"), 0, 0, -1); - - priv->gen_size_label = - trg_general_panel_add_label(self, _("Size"), 0, 1); - priv->gen_eta_label = - trg_general_panel_add_label(self, _("ETA"), 1, 1); - priv->gen_completed_label = - trg_general_panel_add_label(self, _("Completed"), 2, 1); - - priv->gen_seeders_label = - trg_general_panel_add_label(self, _("Seeders"), 0, 2); - priv->gen_down_rate_label = - trg_general_panel_add_label(self, _("Rate Down"), 1, 2); - priv->gen_downloaded_label = - trg_general_panel_add_label(self, _("Downloaded"), 2, 2); - - priv->gen_leechers_label = - trg_general_panel_add_label(self, _("Leechers"), 0, 3); - priv->gen_up_rate_label = - trg_general_panel_add_label(self, _("Rate Up"), 1, 3); - priv->gen_uploaded_label = - trg_general_panel_add_label(self, _("Uploaded"), 2, 3); - - priv->gen_status_label = - trg_general_panel_add_label(self, _("Status"), 0, 4); - priv->gen_ratio_label = - trg_general_panel_add_label(self, _("Ratio"), 1, 4); - - priv->gen_comment_label = - trg_general_panel_add_label(self, _("Comment"), 2, 4); - - priv->gen_completedat_label = - trg_general_panel_add_label_with_width(self, _("Completed At"), 0, - 5, -1); - - priv->gen_downloaddir_label = - trg_general_panel_add_label_with_width(self, _("Location"), 1, 5, - -1); - - priv->gen_error_label = - trg_general_panel_add_label_with_width(self, "", 0, 6, -1); + priv->gen_name_label = + trg_general_panel_add_label_with_width(self, _("Name"), 0, 0, -1); + + priv->gen_size_label = + trg_general_panel_add_label(self, _("Size"), 0, 1); + priv->gen_down_rate_label = + trg_general_panel_add_label(self, _("Rate Down"), 1, 1); + priv->gen_completed_label = + trg_general_panel_add_label(self, _("Completed"), 2, 1); + + priv->gen_eta_label = + trg_general_panel_add_label(self, _("ETA"), 0, 2); + priv->gen_up_rate_label = + trg_general_panel_add_label(self, _("Rate Up"), 1, 2); + priv->gen_downloaded_label = + trg_general_panel_add_label(self, _("Downloaded"), 2, 2); + + priv->gen_seeders_label = + trg_general_panel_add_label(self, _("Seeders"), 0, 3); + priv->gen_ratio_label = + trg_general_panel_add_label(self, _("Ratio"), 1, 3); + priv->gen_uploaded_label = + trg_general_panel_add_label(self, _("Uploaded"), 2, 3); + + priv->gen_leechers_label = + trg_general_panel_add_label(self, _("Leechers"), 0, 4); + priv->gen_limit_label = + trg_general_panel_add_label(self, _("Ratio limit"), 1, 4); + priv->gen_corrupted_label = + trg_general_panel_add_label(self, _("Corrupted"), 2, 4); + + priv->gen_status_label = + trg_general_panel_add_label(self, _("Status"), 0, 5); + priv->gen_priority_label = + trg_general_panel_add_label(self, _("Priority"), 1, 5); + priv->gen_completedat_label = + trg_general_panel_add_label(self, _("Completed At"), 2, 5); + + priv->gen_downloaddir_label = + trg_general_panel_add_label_with_width(self, _("Location"), 0, 6, -1); + + priv->gen_comment_label = + trg_general_panel_add_label(self, _("Comment"), 0, 7); + + priv->gen_error_label = + trg_general_panel_add_label_with_width(self, "", 0, 8, -1); for (i = 0; i < TRG_GENERAL_PANEL_COLUMNS_TOTAL; i++) gtk_table_set_col_spacing(GTK_TABLE(self), i, diff --git a/src/trg-main-window.c b/src/trg-main-window.c index 48b9d6e..d85a364 100644 --- a/src/trg-main-window.c +++ b/src/trg-main-window.c @@ -680,6 +680,16 @@ main_window_toggle_filter_trackers(GtkCheckMenuItem * w, gpointer data) (w)); } +static void +main_window_toggle_directories_first(GtkCheckMenuItem * w, gpointer data){ + TrgMainWindow *win = TRG_MAIN_WINDOW(data); + TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win); + + if (gtk_widget_is_sensitive(GTK_WIDGET(w))) + trg_state_selector_set_directories_first(priv->stateSelector, + gtk_check_menu_item_get_active(w)); +} + static TrgToolbar *trg_main_window_toolbar_new(TrgMainWindow * win) { TrgMainWindowPrivate *priv = trg_main_window_get_instance_private(win); @@ -1767,8 +1777,8 @@ static TrgMenuBar *trg_main_window_menu_bar_new(TrgMainWindow * win) *b_remove, *b_delete, *b_props, *b_local_prefs, *b_remote_prefs, *b_about, *b_view_states, *b_view_notebook, *b_view_stats, *b_add_url, *b_quit, *b_move, *b_reannounce, *b_pause_all, - *b_resume_all, *b_dir_filters, *b_tracker_filters, *b_up_queue, - *b_down_queue, *b_top_queue, *b_bottom_queue, + *b_resume_all, *b_dir_filters, *b_tracker_filters, *b_directories_first, + *b_up_queue, *b_down_queue, *b_top_queue, *b_bottom_queue, #if TRG_WITH_GRAPH *b_show_graph, #endif @@ -1799,7 +1809,7 @@ static TrgMenuBar *trg_main_window_menu_bar_new(TrgMainWindow * win) "view-states-button", &b_view_states, "view-stats-button", &b_view_stats, "about-button", &b_about, "quit-button", &b_quit, "dir-filters", &b_dir_filters, "tracker-filters", - &b_tracker_filters, + &b_tracker_filters, TRG_PREFS_KEY_DIRECTORIES_FIRST, &b_directories_first, #if TRG_WITH_GRAPH "show-graph", &b_show_graph, #endif @@ -1846,6 +1856,8 @@ static TrgMenuBar *trg_main_window_menu_bar_new(TrgMainWindow * win) G_CALLBACK(main_window_toggle_filter_dirs), win); g_signal_connect(b_tracker_filters, "toggled", G_CALLBACK(main_window_toggle_filter_trackers), win); + g_signal_connect(b_directories_first, "toggled", + G_CALLBACK(main_window_toggle_directories_first), win); g_signal_connect(b_view_states, "toggled", G_CALLBACK(view_states_toggled_cb), win); g_signal_connect(b_view_stats, "activate", @@ -2230,8 +2242,8 @@ trg_torrent_tv_view_menu(GtkWidget * treeview, trg_imagemenuitem_new(GTK_MENU_SHELL(menu), _("Remove"), GTK_STOCK_REMOVE, TRUE, G_CALLBACK(remove_cb), win); - trg_imagemenuitem_new(GTK_MENU_SHELL(menu), _("Remove & Delete"), - GTK_STOCK_CLEAR, TRUE, G_CALLBACK(delete_cb), + trg_imagemenuitem_new(GTK_MENU_SHELL(menu), _("Remove and delete data"), + GTK_STOCK_DELETE, TRUE, G_CALLBACK(delete_cb), win); cmds = trg_prefs_get_array(prefs, TRG_PREFS_KEY_EXEC_COMMANDS, diff --git a/src/trg-menu-bar.c b/src/trg-menu-bar.c index b44da6b..faf3548 100644 --- a/src/trg-menu-bar.c +++ b/src/trg-menu-bar.c @@ -65,6 +65,7 @@ enum { PROP_ACCEL_GROUP, PROP_DIR_FILTERS, PROP_TRACKER_FILTERS, + PROP_DIRECTORIES_FIRST, #if TRG_WITH_GRAPH PROP_VIEW_SHOW_GRAPH, #endif @@ -110,6 +111,7 @@ struct _TrgMenuBarPrivate { GtkWidget *mb_quit; GtkWidget *mb_directory_filters; GtkWidget *mb_tracker_filters; + GtkWidget *mb_directory_first; #if TRG_WITH_GRAPH GtkWidget *mb_view_graph; #endif @@ -300,6 +302,9 @@ trg_menu_bar_get_property(GObject * object, guint property_id, case PROP_TRACKER_FILTERS: g_value_set_object(value, priv->mb_tracker_filters); break; + case PROP_DIRECTORIES_FIRST: + g_value_set_object(value, priv->mb_directory_first); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; @@ -538,6 +543,14 @@ static GtkWidget *trg_menu_bar_view_menu_new(TrgMenuBar * mb) gtk_menu_shell_append(GTK_MENU_SHELL(viewMenu), priv->mb_tracker_filters); + priv->mb_directory_first = + trg_menu_bar_view_item_new(priv->prefs, + TRG_PREFS_KEY_DIRECTORIES_FIRST, + _("Directories first"), + priv->mb_view_states); + gtk_menu_shell_append(GTK_MENU_SHELL(viewMenu), + priv->mb_directory_first); + priv->mb_view_notebook = trg_menu_bar_view_item_new(priv->prefs, TRG_PREFS_KEY_SHOW_NOTEBOOK, @@ -733,7 +746,7 @@ static GtkWidget *trg_menu_bar_torrent_menu_new(TrgMenuBar * menu) priv->mb_delete = trg_menu_bar_item_new(GTK_MENU_SHELL(torrentMenu), - _("Remove and Delete"), GTK_STOCK_CLEAR, + _("Remove and delete data"), GTK_STOCK_DELETE, FALSE); trg_menu_bar_accel_add(menu, priv->mb_delete, GDK_Delete, GDK_SHIFT_MASK); @@ -921,6 +934,8 @@ static void trg_menu_bar_class_init(TrgMenuBarClass * klass) "dir-filters", "Dir Filters"); trg_menu_bar_install_widget_prop(object_class, PROP_TRACKER_FILTERS, "tracker-filters", "Tracker Filters"); + trg_menu_bar_install_widget_prop(object_class, PROP_DIRECTORIES_FIRST, + TRG_PREFS_KEY_DIRECTORIES_FIRST, "Directories first"); #if TRG_WITH_GRAPH trg_menu_bar_install_widget_prop(object_class, PROP_VIEW_SHOW_GRAPH, "show-graph", "Show Graph"); diff --git a/src/trg-preferences-dialog.c b/src/trg-preferences-dialog.c index 90c4123..6a0df94 100644 --- a/src/trg-preferences-dialog.c +++ b/src/trg-preferences-dialog.c @@ -330,6 +330,13 @@ static void toggle_filter_trackers(GtkToggleButton * w, gpointer win) gtk_toggle_button_get_active(w)); } +static void toggle_directories_first(GtkToggleButton * w, gpointer win){ + TrgStateSelector *selector = + trg_main_window_get_state_selector(TRG_MAIN_WINDOW(win)); + trg_state_selector_set_directories_first(selector, + gtk_toggle_button_get_active(w)); +} + #if TRG_WITH_GRAPH static void toggle_graph(GtkToggleButton * w, gpointer win) { @@ -729,6 +736,13 @@ static GtkWidget *trg_prefs_viewPage(TrgPreferencesDialog * dlg) G_CALLBACK(toggle_filter_trackers), priv->win); hig_workarea_add_wide_control(t, &row, w); + w = trgp_check_new(dlg, _("Directories first"), + TRG_PREFS_KEY_DIRECTORIES_FIRST, TRG_PREFS_GLOBAL, + GTK_TOGGLE_BUTTON(dep)); + g_signal_connect(G_OBJECT(w), "toggled", + G_CALLBACK(toggle_directories_first), priv->win); + hig_workarea_add_wide_control(t, &row, w); + w = trgp_check_new(dlg, _("Torrent Details"), TRG_PREFS_KEY_SHOW_NOTEBOOK, TRG_PREFS_GLOBAL, NULL); diff --git a/src/trg-prefs.c b/src/trg-prefs.c index e168d07..ff6b1b8 100644 --- a/src/trg-prefs.c +++ b/src/trg-prefs.c @@ -110,6 +110,7 @@ static void trg_prefs_create_defaults(TrgPrefs * p) trg_prefs_add_default_bool_true(p, TRG_PREFS_KEY_FILTER_DIRS); trg_prefs_add_default_bool_true(p, TRG_PREFS_KEY_FILTER_TRACKERS); + trg_prefs_add_default_bool_true(p, TRG_PREFS_KEY_DIRECTORIES_FIRST); trg_prefs_add_default_bool_true(p, TRG_PREFS_KEY_SHOW_GRAPH); trg_prefs_add_default_bool_true(p, TRG_PREFS_KEY_ADD_OPTIONS_DIALOG); trg_prefs_add_default_bool_true(p, TRG_PREFS_KEY_SHOW_STATE_SELECTOR); diff --git a/src/trg-prefs.h b/src/trg-prefs.h index 4245505..3923e7d 100644 --- a/src/trg-prefs.h +++ b/src/trg-prefs.h @@ -56,6 +56,7 @@ #define TRG_PREFS_KEY_SHOW_GRAPH "show-graph" #define TRG_PREFS_KEY_SYSTEM_TRAY_MINIMISE "system-tray-minimise" #define TRG_PREFS_KEY_FILTER_TRACKERS "filter-trackers" +#define TRG_PREFS_KEY_DIRECTORIES_FIRST "directories-first" #define TRG_PREFS_KEY_FILTER_DIRS "filter-dirs" #define TRG_PREFS_KEY_SHOW_STATE_SELECTOR "show-state-selector" #define TRG_PREFS_KEY_SHOW_NOTEBOOK "show-notebook" diff --git a/src/trg-state-selector.c b/src/trg-state-selector.c index cbfc244..4110f7b 100644 --- a/src/trg-state-selector.c +++ b/src/trg-state-selector.c @@ -53,6 +53,7 @@ struct _TrgStateSelectorPrivate { guint flag; gboolean showDirs; gboolean showTrackers; + gboolean dirsFirst; TrgClient *client; TrgPrefs *prefs; GHashTable *trackers; @@ -360,10 +361,13 @@ void trg_state_selector_update(TrgStateSelector * s, guint whatsChanged) updateSerial); g_free(announceHost); } else { - trg_state_selector_insert(s, priv->n_categories, - g_hash_table_size - (priv->trackers), - announceHost, &iter); + if (priv->dirsFirst){ + trg_state_selector_insert(s, priv->n_categories + + g_hash_table_size(priv->directories), -1, announceHost, &iter); + } else { + trg_state_selector_insert(s, priv->n_categories, + g_hash_table_size(priv->trackers), announceHost, &iter); + } gtk_list_store_set(GTK_LIST_STORE(model), &iter, STATE_SELECTOR_ICON, GTK_STOCK_NETWORK, @@ -394,11 +398,13 @@ void trg_state_selector_update(TrgStateSelector * s, guint whatsChanged) *) result, updateSerial); } else { - trg_state_selector_insert(s, - priv->n_categories + - g_hash_table_size - (priv->trackers), -1, dir, - &iter); + if (priv->dirsFirst){ + trg_state_selector_insert(s, priv->n_categories, + g_hash_table_size(priv->directories), dir, &iter); + } else { + trg_state_selector_insert(s, priv->n_categories + + g_hash_table_size(priv->trackers), -1, dir, &iter); + } gtk_list_store_set(GTK_LIST_STORE(model), &iter, STATE_SELECTOR_ICON, GTK_STOCK_DIRECTORY, @@ -470,6 +476,15 @@ trg_state_selector_set_show_trackers(TrgStateSelector * s, gboolean show) trg_state_selector_update(s, TORRENT_UPDATE_ADDREMOVE); } +void +trg_state_selector_set_directories_first(TrgStateSelector * s, gboolean _dirsFirst){ + TrgStateSelectorPrivate *priv = TRG_STATE_SELECTOR_GET_PRIVATE(s); + priv->dirsFirst = _dirsFirst; + g_hash_table_remove_all(priv->directories); + g_hash_table_remove_all(priv->trackers); + trg_state_selector_update(s, TORRENT_UPDATE_ADDREMOVE); +} + static void trg_state_selector_add_state(TrgStateSelector * selector, GtkTreeIter * iter, gint pos, @@ -719,6 +734,9 @@ static GObject *trg_state_selector_constructor(GType type, priv->showTrackers = trg_prefs_get_bool(priv->prefs, TRG_PREFS_KEY_FILTER_TRACKERS, TRG_PREFS_GLOBAL); + priv->dirsFirst = + trg_prefs_get_bool(priv->prefs, TRG_PREFS_KEY_DIRECTORIES_FIRST, + TRG_PREFS_GLOBAL); return object; } diff --git a/src/trg-state-selector.h b/src/trg-state-selector.h index 5107505..ece419a 100644 --- a/src/trg-state-selector.h +++ b/src/trg-state-selector.h @@ -71,6 +71,7 @@ GRegex *trg_state_selector_get_url_host_regex(TrgStateSelector * s); void trg_state_selector_disconnect(TrgStateSelector * s); void trg_state_selector_set_show_trackers(TrgStateSelector * s, gboolean show); +void trg_state_selector_set_directories_first(TrgStateSelector * s, gboolean _dirsFirst); void trg_state_selector_set_show_dirs(TrgStateSelector * s, gboolean show); void trg_state_selector_set_queues_enabled(TrgStateSelector * s, gboolean enabled); diff --git a/src/trg-stats-dialog.c b/src/trg-stats-dialog.c index 920b36c..c23628d 100644 --- a/src/trg-stats-dialog.c +++ b/src/trg-stats-dialog.c @@ -60,7 +60,7 @@ struct _TrgStatsDialogPrivate { TrgMainWindow *parent; GtkWidget *tv; GtkListStore *model; - GtkTreeRowReference *rr_up, *rr_down, *rr_files_added, + GtkTreeRowReference *rr_down, *rr_up, *rr_ratio, *rr_files_added, *rr_session_count, *rr_active, *rr_version; }; @@ -160,8 +160,7 @@ update_int_stat(JsonObject * args, GtkTreeRowReference * rr, } static void -update_size_stat(JsonObject * args, GtkTreeRowReference * rr, - gchar * jsonKey) +update_size_stat(JsonObject * args, GtkTreeRowReference * rr, gchar * jsonKey) { gchar session_val[32]; gchar cumulat_val[32]; @@ -177,6 +176,23 @@ update_size_stat(JsonObject * args, GtkTreeRowReference * rr, } static void +update_ratio_stat(JsonObject * args, GtkTreeRowReference * rr, gchar * jsonKeyA, gchar * jsonKeyB) +{ + gchar session_val[32]; + gchar cumulat_val[32]; + + trg_strlratio(session_val, + json_object_get_double_member(get_session_arg(args), jsonKeyA) / + json_object_get_double_member(get_session_arg(args), jsonKeyB) ); + + trg_strlratio(cumulat_val, + json_object_get_double_member(get_cumulat_arg(args), jsonKeyA) / + json_object_get_double_member(get_cumulat_arg(args), jsonKeyB) ); + + update_statistic(rr, session_val, cumulat_val); +} + +static void update_time_stat(JsonObject * args, GtkTreeRowReference * rr, gchar * jsonKey) { @@ -218,6 +234,7 @@ static gboolean on_stats_reply(gpointer data) update_size_stat(args, priv->rr_up, "uploadedBytes"); update_size_stat(args, priv->rr_down, "downloadedBytes"); + update_ratio_stat(args, priv->rr_ratio, "uploadedBytes", "downloadedBytes"); update_int_stat(args, priv->rr_files_added, "filesAdded"); update_int_stat(args, priv->rr_session_count, "sessionCount"); update_time_stat(args, priv->rr_active, "secondsActive"); @@ -300,6 +317,8 @@ static GObject *trg_stats_dialog_constructor(GType type, stats_dialog_add_statistic(priv->model, _("Download Total")); priv->rr_up = stats_dialog_add_statistic(priv->model, _("Upload Total")); + priv->rr_ratio = + stats_dialog_add_statistic(priv->model, _("Ratio")); priv->rr_files_added = stats_dialog_add_statistic(priv->model, _("Files Added")); priv->rr_session_count = diff --git a/src/trg-toolbar.c b/src/trg-toolbar.c index 4368eb2..cb870d3 100644 --- a/src/trg-toolbar.c +++ b/src/trg-toolbar.c @@ -233,8 +233,8 @@ static GObject *trg_toolbar_constructor(GType type, GTK_STOCK_REMOVE, FALSE); priv->tb_delete = - trg_toolbar_item_new(TRG_TOOLBAR(obj), _("Remove with data"), - &position, GTK_STOCK_CLEAR, FALSE); + trg_toolbar_item_new(TRG_TOOLBAR(obj), _("Remove and delete data"), + &position, GTK_STOCK_DELETE, FALSE); separator = gtk_separator_tool_item_new(); gtk_toolbar_insert(GTK_TOOLBAR(obj), separator, position++); diff --git a/src/trg-torrent-props-dialog.c b/src/trg-torrent-props-dialog.c index 322db0e..ae75146 100644 --- a/src/trg-torrent-props-dialog.c +++ b/src/trg-torrent-props-dialog.c @@ -333,11 +333,15 @@ static void info_page_update(TrgTorrentPropsDialog * dialog, gint64 dateCreated = torrent_get_date_created(t); gchar *dateStr = epoch_to_string(dateCreated); - if (!creator || strlen(creator) <= 0) - g_snprintf(buf, sizeof(buf), _("Created on %1$s"), dateStr); - else - g_snprintf(buf, sizeof(buf), _("Created by %1$s on %2$s"), - creator, dateStr); + if (creator && strlen(creator) > 0 && dateCreated > 0) + g_snprintf(buf, sizeof(buf), _("Created by %1$s on %2$s"), + creator, dateStr); + else if (dateCreated > 0) + g_snprintf(buf, sizeof(buf), _("Created on %1$s"), dateStr); + else if (creator && strlen(creator) > 0) + g_snprintf(buf, sizeof(buf), _("Created by %1$s"), creator); + else + g_strlcpy(buf, _("N/A"), sizeof(buf)); g_free(dateStr); gtk_label_set_text(GTK_LABEL(priv->origin_lb), buf); @@ -483,6 +483,8 @@ char *gtr_localtime2(char *buf, time_t time, size_t buflen) gchar *epoch_to_string(gint64 epoch) { + if(epoch == 0) + return g_strdup(_("N/A")); GDateTime *dt = g_date_time_new_from_unix_local(epoch); gchar *timestring = g_date_time_format(dt, "%F %H:%M:%S"); g_date_time_unref(dt); |