Changeset 232


Ignore:
Timestamp:
Apr 15, 2006, 3:22:04 AM (16 years ago)
Author:
joshe
Message:

Turn the download limit off by default.

Location:
trunk/gtk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/dialogs.c

    r212 r232  
    9090  const char *pref;
    9191  struct prefdata *data = g_new0(struct prefdata, 1);
    92   struct { GtkWidget *on; GtkWidget *num; GtkWidget *label; gboolean first;
     92  struct { GtkWidget *on; GtkWidget *num; GtkWidget *label; gboolean defuse;
    9393    const char *usepref; const char *numpref; long def; } lim[] = {
    9494    { gtk_check_button_new_with_mnemonic(_("_Limit download speed")),
    9595      gtk_spin_button_new_with_range(0, G_MAXLONG, 1),
    9696      gtk_label_new_with_mnemonic(_("Maximum _download speed:")),
    97       FALSE, PREF_USEDOWNLIMIT, PREF_DOWNLIMIT, DEFAULT_DOWNLIMIT, },
     97      DEF_USEDOWNLIMIT, PREF_USEDOWNLIMIT, PREF_DOWNLIMIT, DEF_DOWNLIMIT, },
    9898    { gtk_check_button_new_with_mnemonic(_("Li_mit upload speed")),
    9999      gtk_spin_button_new_with_range(0, G_MAXLONG, 1),
    100100      gtk_label_new_with_mnemonic(_("Maximum _upload speed:")),
    101       TRUE, PREF_USEUPLIMIT, PREF_UPLIMIT, DEFAULT_UPLIMIT, },
     101      DEF_USEUPLIMIT, PREF_USEUPLIMIT, PREF_UPLIMIT, DEF_UPLIMIT, },
    102102  };
    103103  unsigned int ii;
     
    128128    pref = cf_getpref(lim[ii].usepref);
    129129    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lim[ii].on),
    130       (NULL == pref ? lim[ii].first : strbool(pref)));
     130      (NULL == pref ? lim[ii].defuse : strbool(pref)));
    131131    array = g_new(GtkWidget*, 2);
    132132    g_signal_connect_data(lim[ii].on, "clicked", G_CALLBACK(clicklimitbox),
     
    262262void
    263263setlimit(tr_handle_t *tr) {
     264  struct { void (*func)(tr_handle_t*, int);
     265    const char *use; const char *num; gboolean defuse; long def; } lim[] = {
     266    {tr_setDownloadLimit, PREF_USEDOWNLIMIT, PREF_DOWNLIMIT,
     267                          DEF_USEDOWNLIMIT,  DEF_DOWNLIMIT},
     268    {tr_setUploadLimit,   PREF_USEUPLIMIT,   PREF_UPLIMIT,
     269                          DEF_USEUPLIMIT,    DEF_UPLIMIT},
     270  };
    264271  const char *pref;
    265   struct { void (*func)(tr_handle_t*, int);
    266     const char *use; const char *num; long def; } lim[] = {
    267     {tr_setDownloadLimit, PREF_USEDOWNLIMIT, PREF_DOWNLIMIT,DEFAULT_DOWNLIMIT},
    268     {tr_setUploadLimit,   PREF_USEUPLIMIT,   PREF_UPLIMIT,  DEFAULT_UPLIMIT},
    269   };
    270272  unsigned int ii;
    271273
    272274  for(ii = 0; ii < ALEN(lim); ii++) {
    273     if(NULL != (pref = cf_getpref(lim[ii].use)) && !strbool(pref))
     275    pref = cf_getpref(lim[ii].use);
     276    if(!(NULL == pref ? lim[ii].defuse : strbool(pref)))
    274277      lim[ii].func(tr, -1);
    275     else if(NULL != (pref = cf_getpref(lim[ii].num)))
    276       lim[ii].func(tr, strtol(pref, NULL, 10));
    277     else
    278       lim[ii].func(tr, lim[ii].def);
     278    else {
     279      pref = cf_getpref(lim[ii].num);
     280      lim[ii].func(tr, (NULL == pref ? lim[ii].def : strtol(pref, NULL, 10)));
     281    }
    279282  }
    280283}
  • trunk/gtk/dialogs.h

    r212 r232  
    3838#define PREF_DIR                "download-directory"
    3939
    40 #define DEFAULT_DOWNLIMIT       100
    41 #define DEFAULT_UPLIMIT         20
     40/* default values for a couple prefs */
     41#define DEF_DOWNLIMIT           100
     42#define DEF_USEDOWNLIMIT        FALSE
     43#define DEF_UPLIMIT             20
     44#define DEF_USEUPLIMIT          TRUE
    4245
    4346typedef gboolean (*add_torrent_func_t)(void *, const char *, const char *, gboolean, GList **);
Note: See TracChangeset for help on using the changeset viewer.