From c10b672d05b8b6b68bbc1ccb92da8b5caa451c68 Mon Sep 17 00:00:00 2001 From: Alan Fitton Date: Mon, 14 Feb 2011 20:15:52 +0000 Subject: cache-size-mb was implemented 2.10, so check if it's present (will support >= 2.0) --- src/session-get.c | 5 ++++- src/trg-main-window.c | 6 +++--- src/trg-remote-prefs-dialog.c | 20 ++++++++++++-------- src/trg-torrent-props-dialog.c | 6 ++---- 4 files changed, 21 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/session-get.c b/src/session-get.c index 4ded820..f89175b 100644 --- a/src/session-get.c +++ b/src/session-get.c @@ -111,7 +111,10 @@ gboolean session_get_torrent_done_enabled(JsonObject * s) gint64 session_get_cache_size_mb(JsonObject * s) { - return json_object_get_int_member(s, SGET_CACHE_SIZE_MB); + if (json_object_has_member(s, SGET_CACHE_SIZE_MB)) + return json_object_get_int_member(s, SGET_CACHE_SIZE_MB); + else + return -1; } gdouble session_get_seed_ratio_limit(JsonObject * s) diff --git a/src/trg-main-window.c b/src/trg-main-window.c index 0a2f95d..7b73cc2 100644 --- a/src/trg-main-window.c +++ b/src/trg-main-window.c @@ -123,9 +123,9 @@ static gboolean trg_torrent_tree_view_visible_func(GtkTreeModel * model, GtkTreeIter * iter, gpointer data); static TrgTorrentTreeView - *trg_main_window_torrent_tree_view_new(TrgMainWindow * win, - GtkTreeModel * model, - TrgStateSelector * selector); + * trg_main_window_torrent_tree_view_new(TrgMainWindow * win, + GtkTreeModel * model, + TrgStateSelector * selector); static gboolean trg_dialog_error_handler(TrgMainWindow * win, JsonObject * response, int status); diff --git a/src/trg-remote-prefs-dialog.c b/src/trg-remote-prefs-dialog.c index c27fc35..5d5d8a5 100644 --- a/src/trg-remote-prefs-dialog.c +++ b/src/trg-remote-prefs-dialog.c @@ -98,8 +98,9 @@ static void update_session(GtkDialog * dlg) args); gtk_toggle_button_json_out(GTK_TOGGLE_BUTTON (priv->start_added_torrent_check), args); - gtk_spin_button_json_int_out(GTK_SPIN_BUTTON(priv->cache_size_mb_spin), - args); + if (priv->cache_size_mb_spin != NULL) + gtk_spin_button_json_int_out(GTK_SPIN_BUTTON + (priv->cache_size_mb_spin), args); /* Connection */ @@ -351,6 +352,7 @@ static GtkWidget *trg_rprefs_generalPage(TrgRemotePrefsDialog * win, GtkWidget *w, *tb, *t; gint row = 0; + gint64 cache_size_mb; t = hig_workarea_create(); @@ -391,12 +393,14 @@ static GtkWidget *trg_rprefs_generalPage(TrgRemotePrefsDialog * win, G_CALLBACK(toggle_active_arg_is_sensitive), w); hig_workarea_add_row_w(t, &row, tb, w, NULL); - w = priv->cache_size_mb_spin = - gtk_spin_button_new_with_range(0, INT_MAX, 1); - widget_set_json_key(w, SGET_CACHE_SIZE_MB); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), - session_get_cache_size_mb(s)); - hig_workarea_add_row(t, &row, "Cache size (MB)", w, w); + cache_size_mb = session_get_cache_size_mb(s); + if (cache_size_mb >= 0) { + w = priv->cache_size_mb_spin = + gtk_spin_button_new_with_range(0, INT_MAX, 1); + widget_set_json_key(w, SGET_CACHE_SIZE_MB); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), cache_size_mb); + hig_workarea_add_row(t, &row, "Cache size (MB)", w, w); + } w = priv->rename_partial_files_check = hig_workarea_add_wide_checkbutton(t, &row, diff --git a/src/trg-torrent-props-dialog.c b/src/trg-torrent-props-dialog.c index 477b15f..827e643 100644 --- a/src/trg-torrent-props-dialog.c +++ b/src/trg-torrent-props-dialog.c @@ -137,12 +137,10 @@ trg_torrent_props_response_cb(GtkDialog * dlg, gint res_id, (priv->seedRatioLimit), args); json_object_set_int_member(args, FIELD_SEED_RATIO_MODE, gtk_combo_box_get_active(GTK_COMBO_BOX - (priv-> - seedRatioMode))); + (priv->seedRatioMode))); json_object_set_int_member(args, FIELD_BANDWIDTH_PRIORITY, gtk_combo_box_get_active(GTK_COMBO_BOX - (priv-> - bandwidthPriorityCombo)) + (priv->bandwidthPriorityCombo)) + 1); gtk_spin_button_json_int_out(GTK_SPIN_BUTTON -- cgit v1.2.3