(trunk gtk) kill "pref_flag_t" in a burlap sack and throw it off the cliff into the freezing water below

This commit is contained in:
Charles Kerr 2010-12-22 06:11:49 +00:00
parent 28ec370476
commit b86e1e1056
7 changed files with 35 additions and 66 deletions

View File

@ -407,14 +407,12 @@ onAddDialogResponse( GtkDialog * dialog,
GtkFileChooser * chooser = GTK_FILE_CHOOSER( dialog );
GtkWidget * w = gtk_file_chooser_get_extra_widget( chooser );
GtkToggleButton * tb = GTK_TOGGLE_BUTTON( w );
const gboolean showOptions = gtk_toggle_button_get_active( tb );
const pref_flag_t start = PREF_FLAG_DEFAULT;
const pref_flag_t prompt = showOptions
? PREF_FLAG_TRUE
: PREF_FLAG_FALSE;
const gboolean doStart = pref_flag_get( TR_PREFS_KEY_START );
const gboolean doPrompt = gtk_toggle_button_get_active( tb );
const gboolean doNotify = FALSE;
GSList * l = gtk_file_chooser_get_filenames( chooser );
tr_core_add_list( core, l, start, prompt, FALSE );
tr_core_add_list( core, l, doStart, doPrompt, doNotify );
}
gtk_widget_destroy( GTK_WIDGET( dialog ) );

View File

@ -48,8 +48,7 @@ static char * gl_lockpath = NULL;
/* errstr may be NULL, this might be called before GTK is initialized */
gboolean
cf_init( const char * configDir,
char ** errstr )
cf_init( const char * configDir, char ** errstr )
{
if( errstr != NULL )
*errstr = NULL;
@ -74,9 +73,7 @@ cf_init( const char * configDir,
/* errstr may be NULL, this might be called before GTK is initialized */
static gboolean
lockfile( const char * filename,
gtr_lockfile_state_t * tr_state,
char ** errstr )
lockfile( const char * filename, gtr_lockfile_state_t * tr_state, char ** errstr )
{
const gtr_lockfile_state_t state = gtr_lockfile( filename );
const gboolean success = state == GTR_LOCKFILE_SUCCESS;
@ -247,8 +244,7 @@ pref_int_get( const char * key )
}
void
pref_int_set( const char * key,
int64_t value )
pref_int_set( const char * key, int64_t value )
{
tr_bencDictAddInt( getPrefs( ), key, value );
}
@ -262,8 +258,7 @@ pref_double_get( const char * key )
}
void
pref_double_set( const char * key,
double value )
pref_double_set( const char * key, double value )
{
tr_bencDictAddReal( getPrefs( ), key, value );
}
@ -280,26 +275,8 @@ pref_flag_get( const char * key )
return boolVal != 0;
}
gboolean
pref_flag_eval( pref_flag_t val,
const char * key )
{
switch( val )
{
case PREF_FLAG_TRUE:
return TRUE;
case PREF_FLAG_FALSE:
return FALSE;
default:
return pref_flag_get( key );
}
}
void
pref_flag_set( const char * key,
gboolean value )
pref_flag_set( const char * key, gboolean value )
{
tr_bencDictAddBool( getPrefs( ), key, value );
}
@ -351,8 +328,7 @@ getCompat121PrefsFilename( void )
}
static void
translate_keyfile_to_json( const char * old_file,
const char * new_file )
translate_keyfile_to_json( const char * old_file, const char * new_file )
{
tr_benc dict;
GKeyFile * keyfile;

View File

@ -48,19 +48,6 @@ struct tr_benc* pref_get_all ( void );
***
**/
enum
{
PREF_FLAG_DEFAULT = 0,
PREF_FLAG_FALSE = 1,
PREF_FLAG_TRUE = 2
};
typedef int pref_flag_t;
gboolean pref_flag_eval( pref_flag_t val,
const char * key );
/**
***
**/

View File

@ -21,6 +21,7 @@
#include <libtransmission/utils.h> /* tr_free */
#include "actions.h"
#include "conf.h"
#include "details.h"
#include "favicon.h" /* gtr_get_favicon() */
#include "file-list.h"

View File

@ -844,9 +844,9 @@ appsetup( TrWindow * wind,
gboolean forcepause,
gboolean isIconified )
{
const pref_flag_t start =
forcepause ? PREF_FLAG_FALSE : PREF_FLAG_DEFAULT;
const pref_flag_t prompt = PREF_FLAG_DEFAULT;
const gboolean doStart = pref_flag_get( TR_PREFS_KEY_START ) && !forcepause;
const gboolean doPrompt = pref_flag_get( PREF_KEY_OPTIONS_PROMPT );
const gboolean doNotify = TRUE;
/* fill out cbdata */
cbdata->wind = NULL;
@ -873,7 +873,7 @@ appsetup( TrWindow * wind,
/* add torrents from command-line and saved state */
tr_core_load( cbdata->core, forcepause );
tr_core_add_list( cbdata->core, torrentFiles, start, prompt, TRUE );
tr_core_add_list( cbdata->core, torrentFiles, doStart, doPrompt, doNotify );
torrentFiles = NULL;
tr_core_torrents_added( cbdata->core );

View File

@ -1189,15 +1189,13 @@ tr_core_present_window( TrCore * core UNUSED,
void
tr_core_add_list( TrCore * core,
GSList * torrentFiles,
pref_flag_t start,
pref_flag_t prompt,
gboolean doStart,
gboolean doPrompt,
gboolean doNotify )
{
const gboolean doStart = pref_flag_eval( start, TR_PREFS_KEY_START );
const gboolean doPrompt = pref_flag_eval( prompt, PREF_KEY_OPTIONS_PROMPT );
GSList * l;
for( l = torrentFiles; l != NULL; l = l->next )
for( l=torrentFiles; l!=NULL; l=l->next )
{
char * filename = l->data;
add_filename( core, filename, doStart, doPrompt, doNotify );
@ -1209,6 +1207,15 @@ tr_core_add_list( TrCore * core,
g_slist_free( torrentFiles );
}
void
tr_core_add_list_defaults( TrCore * core, GSList * torrentFiles, gboolean doNotify )
{
const gboolean doStart = pref_flag_get( TR_PREFS_KEY_START );
const gboolean doPrompt = pref_flag_get( PREF_KEY_OPTIONS_PROMPT );
tr_core_add_list( core, torrentFiles, doStart, doPrompt, doNotify );
}
void
tr_core_torrents_added( TrCore * self )
{

View File

@ -29,7 +29,6 @@
#include <gtk/gtk.h>
#include <libtransmission/transmission.h>
#include "conf.h" /* pref_flag_t */
#include "tr-torrent.h"
#define TR_CORE_TYPE ( tr_core_get_type( ) )
@ -104,14 +103,15 @@ void tr_core_load( TrCore * self, gboolean forcepaused );
* May pop up dialogs for each torrent if that preference is enabled.
* May trigger one or more "error" signals with TR_CORE_ERR_ADD_TORRENT
*/
void tr_core_add_list( TrCore * self,
GSList * torrentFiles,
pref_flag_t start,
pref_flag_t prompt,
gboolean doNotify );
void tr_core_add_list( TrCore * self,
GSList * torrentFiles,
gboolean doStart,
gboolean doPrompt,
gboolean doNotify );
#define tr_core_add_list_defaults( c, l, doNotify ) \
tr_core_add_list( c, l, PREF_FLAG_DEFAULT, PREF_FLAG_DEFAULT, doNotify )
void tr_core_add_list_defaults( TrCore * core,
GSList * torrentFiles,
gboolean doNotify );
/** @brief Add a torrent. */