(trunk gtk) minor cleanup to last night's ComboBox utilities
This commit is contained in:
parent
feb6e6b785
commit
f4438e6983
|
@ -261,7 +261,7 @@ refreshOptions( struct DetailsImpl * di, tr_torrent ** torrents, int n )
|
|||
break;
|
||||
if( i == n ) {
|
||||
g_signal_handler_block( di->bandwidthCombo, di->bandwidthComboTag );
|
||||
gtr_priority_combo_set_value( di->bandwidthCombo, baseline );
|
||||
gtr_priority_combo_set_value( GTK_COMBO_BOX( di->bandwidthCombo ), baseline );
|
||||
g_signal_handler_unblock( di->bandwidthCombo, di->bandwidthComboTag );
|
||||
}
|
||||
else
|
||||
|
@ -418,9 +418,9 @@ max_peers_spun_cb( GtkSpinButton * s, struct DetailsImpl * di )
|
|||
}
|
||||
|
||||
static void
|
||||
onPriorityChanged( GtkComboBox * w, struct DetailsImpl * di )
|
||||
onPriorityChanged( GtkComboBox * combo_box, struct DetailsImpl * di )
|
||||
{
|
||||
const tr_priority_t priority = gtr_priority_combo_get_value( GTK_WIDGET( w ) );
|
||||
const tr_priority_t priority = gtr_priority_combo_get_value( combo_box );
|
||||
torrent_set_int( di, "bandwidthPriority", priority );
|
||||
}
|
||||
|
||||
|
|
|
@ -55,10 +55,10 @@ static struct tr_msg_list * myHead = NULL;
|
|||
***/
|
||||
|
||||
static void
|
||||
level_combo_changed_cb( GtkWidget * w, gpointer gdata )
|
||||
level_combo_changed_cb( GtkComboBox * combo_box, gpointer gdata )
|
||||
{
|
||||
struct MsgData * data = gdata;
|
||||
const int level = gtr_combo_box_get_active_val( w );
|
||||
const int level = gtr_combo_box_get_active_enum( combo_box );
|
||||
|
||||
tr_setMessageLevel( level );
|
||||
tr_core_set_pref_int( data->core, TR_PREFS_KEY_MSGLEVEL, level );
|
||||
|
@ -365,7 +365,7 @@ debug_level_combo_new( void )
|
|||
_( "Information" ), TR_MSG_INF,
|
||||
_( "Debug" ), TR_MSG_DBG,
|
||||
NULL );
|
||||
gtr_combo_box_set_active_val( w, pref_int_get( TR_PREFS_KEY_MSGLEVEL ) );
|
||||
gtr_combo_box_set_active_enum( GTK_COMBO_BOX( w ), pref_int_get( TR_PREFS_KEY_MSGLEVEL ) );
|
||||
return w;
|
||||
}
|
||||
|
||||
|
|
|
@ -448,10 +448,10 @@ onBlocklistUpdate( GtkButton * w, gpointer gdata )
|
|||
}
|
||||
|
||||
static void
|
||||
onIntComboChanged( GtkComboBox * w, gpointer core )
|
||||
onIntComboChanged( GtkComboBox * combo_box, gpointer core )
|
||||
{
|
||||
const int val = gtr_combo_box_get_active_val( GTK_WIDGET( w ) );
|
||||
const char * key = g_object_get_data( G_OBJECT( w ), PREF_KEY );
|
||||
const int val = gtr_combo_box_get_active_enum( combo_box );
|
||||
const char * key = g_object_get_data( G_OBJECT( combo_box ), PREF_KEY );
|
||||
tr_core_set_pref_int( TR_CORE( core ), key, val );
|
||||
}
|
||||
|
||||
|
@ -462,7 +462,7 @@ new_encryption_combo( GObject * core, const char * key )
|
|||
_( "Prefer encryption" ), TR_ENCRYPTION_PREFERRED,
|
||||
_( "Require encryption" ), TR_ENCRYPTION_REQUIRED,
|
||||
NULL );
|
||||
gtr_combo_box_set_active_val( w, pref_int_get( key ) );
|
||||
gtr_combo_box_set_active_enum( GTK_COMBO_BOX( w ), pref_int_get( key ) );
|
||||
g_object_set_data_full( G_OBJECT( w ), PREF_KEY, tr_strdup( key ), g_free );
|
||||
g_signal_connect( w, "changed", G_CALLBACK( onIntComboChanged ), core );
|
||||
return w;
|
||||
|
@ -917,7 +917,7 @@ proxy_combo_box_new( GObject * core, const char * key )
|
|||
"SOCKS4", TR_PROXY_SOCKS4,
|
||||
"SOCKS5", TR_PROXY_SOCKS5,
|
||||
NULL );
|
||||
gtr_combo_box_set_active_val( w, pref_int_get( key ) );
|
||||
gtr_combo_box_set_active_enum( GTK_COMBO_BOX( w ), pref_int_get( key ) );
|
||||
g_object_set_data_full( G_OBJECT( w ), PREF_KEY, tr_strdup( key ), g_free );
|
||||
g_signal_connect( w, "changed", G_CALLBACK( onIntComboChanged ), core );
|
||||
return w;
|
||||
|
@ -1083,7 +1083,7 @@ new_week_combo( GObject * core, const char * key )
|
|||
_( "Friday" ), TR_SCHED_FRI,
|
||||
_( "Saturday" ), TR_SCHED_SAT,
|
||||
NULL );
|
||||
gtr_combo_box_set_active_val( w, pref_int_get( key ) );
|
||||
gtr_combo_box_set_active_enum( GTK_COMBO_BOX( w ), pref_int_get( key ) );
|
||||
g_object_set_data_full( G_OBJECT( w ), PREF_KEY, tr_strdup( key ), g_free );
|
||||
g_signal_connect( w, "changed", G_CALLBACK( onIntComboChanged ), core );
|
||||
return w;
|
||||
|
|
12
gtk/util.c
12
gtk/util.c
|
@ -653,17 +653,16 @@ gtr_button_new_from_stock( const char * stock,
|
|||
***/
|
||||
|
||||
void
|
||||
gtr_combo_box_set_active_val( GtkWidget * w, int value )
|
||||
gtr_combo_box_set_active_enum( GtkComboBox * combo_box, int value )
|
||||
{
|
||||
int i;
|
||||
int currentValue;
|
||||
const int column = 0;
|
||||
GtkTreeIter iter;
|
||||
GtkComboBox * combobox = GTK_COMBO_BOX( w );
|
||||
GtkTreeModel * model = gtk_combo_box_get_model( combobox );
|
||||
GtkTreeModel * model = gtk_combo_box_get_model( combo_box );
|
||||
|
||||
/* do the value and current value match? */
|
||||
if( gtk_combo_box_get_active_iter( combobox, &iter ) ) {
|
||||
if( gtk_combo_box_get_active_iter( combo_box, &iter ) ) {
|
||||
gtk_tree_model_get( model, &iter, column, ¤tValue, -1 );
|
||||
if( currentValue == value )
|
||||
return;
|
||||
|
@ -674,7 +673,7 @@ gtr_combo_box_set_active_val( GtkWidget * w, int value )
|
|||
while(( gtk_tree_model_iter_nth_child( model, &iter, NULL, i++ ))) {
|
||||
gtk_tree_model_get( model, &iter, column, ¤tValue, -1 );
|
||||
if( currentValue == value ) {
|
||||
gtk_combo_box_set_active_iter( combobox, &iter );
|
||||
gtk_combo_box_set_active_iter( combo_box, &iter );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -713,11 +712,10 @@ gtr_combo_box_new_enum( const char * text_1, ... )
|
|||
}
|
||||
|
||||
int
|
||||
gtr_combo_box_get_active_val( GtkWidget * w )
|
||||
gtr_combo_box_get_active_enum( GtkComboBox * combo_box )
|
||||
{
|
||||
int value = 0;
|
||||
GtkTreeIter iter;
|
||||
GtkComboBox * combo_box = GTK_COMBO_BOX( w );
|
||||
|
||||
if( gtk_combo_box_get_active_iter( combo_box, &iter ) )
|
||||
gtk_tree_model_get( gtk_combo_box_get_model( combo_box ), &iter, 0, &value, -1 );
|
||||
|
|
10
gtk/util.h
10
gtk/util.h
|
@ -169,12 +169,12 @@ GtkWidget * gtr_button_new_from_stock( const char * stock,
|
|||
***/
|
||||
|
||||
GtkWidget * gtr_priority_combo_new( void );
|
||||
#define gtr_priority_combo_get_value(w) gtr_combo_box_get_active_val(w)
|
||||
#define gtr_priority_combo_set_value(w,val) gtr_combo_box_set_active_val(w,val)
|
||||
#define gtr_priority_combo_get_value(w) gtr_combo_box_get_active_enum(w)
|
||||
#define gtr_priority_combo_set_value(w,val) gtr_combo_box_set_active_enum(w,val)
|
||||
|
||||
GtkWidget * gtr_combo_box_new_enum( const char * text_1, ... );
|
||||
int gtr_combo_box_get_active_val( GtkWidget * w );
|
||||
void gtr_combo_box_set_active_val( GtkWidget * w, int value );
|
||||
GtkWidget * gtr_combo_box_new_enum ( const char * text_1, ... );
|
||||
int gtr_combo_box_get_active_enum ( GtkComboBox * );
|
||||
void gtr_combo_box_set_active_enum ( GtkComboBox *, int value );
|
||||
|
||||
/***
|
||||
****
|
||||
|
|
Loading…
Reference in New Issue