From 443b30ab07f545127df4c1012fcd6534241a2fe1 Mon Sep 17 00:00:00 2001 From: Alan Fitton Date: Sat, 15 Sep 2012 10:04:51 +0100 Subject: save the torrent dialog (transmission style) tree view layout even if cancel is clicked --- src/trg-torrent-props-dialog.c | 53 ++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 31 deletions(-) (limited to 'src/trg-torrent-props-dialog.c') diff --git a/src/trg-torrent-props-dialog.c b/src/trg-torrent-props-dialog.c index da93279..2060b6b 100644 --- a/src/trg-torrent-props-dialog.c +++ b/src/trg-torrent-props-dialog.c @@ -136,53 +136,44 @@ static void trg_torrent_props_response_cb(GtkDialog * dialog, gint res_id, gpointer data G_GNUC_UNUSED) { TrgTorrentPropsDialogPrivate *priv = GET_PRIVATE(dialog); - JsonNode *request; - JsonObject *args; - if (priv->peersTv) + if (priv->show_details) { + TrgPrefs *prefs = trg_client_get_prefs(priv->client); + gint width, height; + gtk_window_get_size(GTK_WINDOW(dialog), &width, &height); + trg_prefs_set_int(prefs, "dialog-width", width, TRG_PREFS_GLOBAL); + trg_prefs_set_int(prefs, "dialog-height", height, + TRG_PREFS_GLOBAL); + trg_tree_view_persist(TRG_TREE_VIEW(priv->peersTv), TRG_TREE_VIEW_PERSIST_SORT | TRG_TREE_VIEW_PERSIST_LAYOUT); - if (priv->filesTv) trg_tree_view_persist(TRG_TREE_VIEW(priv->filesTv), TRG_TREE_VIEW_PERSIST_SORT | TRG_TREE_VIEW_PERSIST_LAYOUT); - - if (priv->trackersTv) trg_tree_view_persist(TRG_TREE_VIEW(priv->trackersTv), TRG_TREE_VIEW_PERSIST_SORT | TRG_TREE_VIEW_PERSIST_LAYOUT); + } if (res_id != GTK_RESPONSE_OK) { - gtk_widget_destroy(GTK_WIDGET(dialog)); json_array_unref(priv->targetIds); - return; - } - - request = torrent_set(priv->targetIds); - args = node_get_arguments(request); - - json_object_set_int_member(args, FIELD_SEED_RATIO_MODE, - gtk_combo_box_get_active(GTK_COMBO_BOX - (priv->seedRatioMode))); - json_object_set_int_member(args, FIELD_BANDWIDTH_PRIORITY, - gtk_combo_box_get_active(GTK_COMBO_BOX - (priv->bandwidthPriorityCombo)) - - 1); + } else { + JsonNode *request = torrent_set(priv->targetIds); + JsonObject *args = node_get_arguments(request); - trg_json_widgets_save(priv->widgets, args); - trg_json_widget_desc_list_free(priv->widgets); + json_object_set_int_member(args, FIELD_SEED_RATIO_MODE, + gtk_combo_box_get_active(GTK_COMBO_BOX + (priv->seedRatioMode) )); + json_object_set_int_member(args, FIELD_BANDWIDTH_PRIORITY, + gtk_combo_box_get_active(GTK_COMBO_BOX + (priv->bandwidthPriorityCombo) ) - 1); - dispatch_async(priv->client, request, on_generic_interactive_action, - priv->parent); + trg_json_widgets_save(priv->widgets, args); + trg_json_widget_desc_list_free(priv->widgets); - if (priv->show_details) { - TrgPrefs *prefs = trg_client_get_prefs(priv->client); - gint width, height; - gtk_window_get_size(GTK_WINDOW(dialog), &width, &height); - trg_prefs_set_int(prefs, "dialog-width", width, TRG_PREFS_GLOBAL); - trg_prefs_set_int(prefs, "dialog-height", height, - TRG_PREFS_GLOBAL); + dispatch_async(priv->client, request, on_generic_interactive_action, + priv->parent); } gtk_widget_destroy(GTK_WIDGET(dialog)); -- cgit v1.2.3