Commit 7f00f3bf authored by Simon Latapie's avatar Simon Latapie

* added a i_min, i_max, f_min and f_max in module_config_t structure

 * added a add_integer_with_range() and add_float_with_range()
 * gtk interface: now uses a slider when a min or a max is specified
parent ba3ec85c
......@@ -4,7 +4,7 @@
* It includes functions allowing to declare, get or set configuration options.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: configuration.h,v 1.22 2002/12/10 14:19:44 gbazin Exp $
* $Id: configuration.h,v 1.23 2003/01/06 00:37:29 garf Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -57,6 +57,10 @@ struct module_config_t
char *psz_value; /* Option value */
int i_value; /* Option value */
float f_value; /* Option value */
int i_min; /* Option minimum value */
int i_max; /* Option maximum value */
float f_min; /* Option minimum value */
float f_max; /* Option maximum value */
/* Function to call when commiting a change */
void ( * pf_callback ) ( vlc_object_t * );
......@@ -65,6 +69,7 @@ struct module_config_t
vlc_mutex_t *p_lock; /* Lock to use when modifying the config */
vlc_bool_t b_dirty; /* Dirty flag to indicate a config change */
};
/*****************************************************************************
......@@ -127,15 +132,19 @@ VLC_EXPORT( void, config_UnsetCallbacks, ( module_config_t * ) );
{ static module_config_t tmp = { CONFIG_ITEM_STRING, NULL, name, '\0', text, longtext, psz_value }; p_config[ i_config ] = tmp; p_config[ i_config ].pf_callback = p_callback; } i_config++
#define add_string_from_list( name, psz_value, ppsz_list, p_callback, text, \
longtext ) \
{ static module_config_t tmp = { CONFIG_ITEM_STRING, NULL, name, '\0', text, longtext, psz_value, 0, 0, NULL, ppsz_list }; p_config[ i_config ] = tmp; p_config[ i_config ].pf_callback = p_callback; } i_config++
{ static module_config_t tmp = { CONFIG_ITEM_STRING, NULL, name, '\0', text, longtext, psz_value, 0, 0, 0, 0, 0, 0, NULL, ppsz_list }; p_config[ i_config ] = tmp; p_config[ i_config ].pf_callback = p_callback; } i_config++
#define add_file( name, psz_value, p_callback, text, longtext ) \
{ static module_config_t tmp = { CONFIG_ITEM_FILE, NULL, name, '\0', text, longtext, psz_value, 0, 0 }; p_config[ i_config ] = tmp; p_config[ i_config ].pf_callback = p_callback; } i_config++
#define add_module( name, psz_caps, psz_value, p_callback, text, longtext ) \
{ static module_config_t tmp = { CONFIG_ITEM_MODULE, psz_caps, name, '\0', text, longtext, psz_value }; p_config[ i_config ] = tmp; p_config[ i_config ].pf_callback = p_callback; } i_config++
#define add_integer( name, i_value, p_callback, text, longtext ) \
{ static module_config_t tmp = { CONFIG_ITEM_INTEGER, NULL, name, '\0', text, longtext, NULL, i_value }; p_config[ i_config ] = tmp; p_config[ i_config ].pf_callback = p_callback; } i_config++
#define add_integer_with_range( name, i_value, i_min, i_max, p_callback, text, longtext ) \
{ static module_config_t tmp = { CONFIG_ITEM_INTEGER, NULL, name, '\0', text, longtext, NULL, i_value, 0, i_min, i_max }; p_config[ i_config ] = tmp; p_config[ i_config ].pf_callback = p_callback; } i_config++
#define add_float( name, f_value, p_callback, text, longtext ) \
{ static module_config_t tmp = { CONFIG_ITEM_FLOAT, NULL, name, '\0', text, longtext, NULL, 0, f_value }; p_config[ i_config ] = tmp; p_config[ i_config ].pf_callback = p_callback; } i_config++
#define add_float_with_range( name, f_value, f_min, f_max, p_callback, text, longtext ) \
{ static module_config_t tmp = { CONFIG_ITEM_FLOAT, NULL, name, '\0', text, longtext, NULL, 0, f_value, 0, 0, f_min, f_max }; p_config[ i_config ] = tmp; p_config[ i_config ].pf_callback = p_callback; } i_config++
#define add_bool( name, b_value, p_callback, text, longtext ) \
{ static module_config_t tmp = { CONFIG_ITEM_BOOL, NULL, name, '\0', text, longtext, NULL, b_value }; p_config[ i_config ] = tmp; p_config[ i_config ].pf_callback = p_callback; } i_config++
......
......@@ -2,7 +2,7 @@
* modules_inner.h : Macros used from within a module.
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: modules_inner.h,v 1.35 2002/12/10 12:46:35 gbazin Exp $
* $Id: modules_inner.h,v 1.36 2003/01/06 00:37:29 garf Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -114,8 +114,7 @@
} \
{ \
static module_config_t tmp = { CONFIG_HINT_END, NULL, NULL, '\0', \
NULL, NULL, NULL, 0, 0.0, NULL, \
NULL, NULL, VLC_FALSE }; \
NULL, NULL, NULL, 0, 0.0, 0, 0, 0.0, 0.0, NULL,NULL, NULL, VLC_FALSE }; \
p_config[ i_config ] = tmp; \
} \
config_Duplicate( p_module, p_config ); \
......
......@@ -2,7 +2,7 @@
* gtk_preferences.c: functions to handle the preferences dialog box.
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
* $Id: preferences.c,v 1.6 2002/12/13 01:56:29 gbazin Exp $
* $Id: preferences.c,v 1.7 2003/01/06 00:37:30 garf Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
* Loc Minier <lool@via.ecp.fr>
......@@ -62,7 +62,9 @@ static void GtkConfigDialogDestroyed ( GtkObject *, gpointer );
static void GtkStringChanged ( GtkEditable *, gpointer );
static void GtkIntChanged ( GtkEditable *, gpointer );
static void GtkIntRangedChanged ( GtkEditable *, gpointer );
static void GtkFloatChanged ( GtkEditable *, gpointer );
static void GtkFloatRangedChanged ( GtkEditable *, gpointer );
static void GtkBoolChanged ( GtkToggleButton *, gpointer );
static void GtkFreeHashTable ( GtkObject *object );
......@@ -153,7 +155,9 @@ static void GtkCreateConfigDialog( char *psz_module_name,
GtkWidget *item_combo;
GtkWidget *string_entry;
GtkWidget *integer_spinbutton;
GtkWidget *integer_slider;
GtkWidget *float_spinbutton;
GtkWidget *float_slider;
GtkObject *item_adj;
GtkWidget *bool_checkbutton;
GtkWidget *module_clist;
......@@ -457,42 +461,82 @@ static void GtkCreateConfigDialog( char *psz_module_name,
case CONFIG_ITEM_INTEGER:
/* add input box with default value */
item_adj = gtk_adjustment_new( p_item->i_value,
-1, 99999, 1, 10, 10 );
integer_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT(item_adj),
1, 0 );
/* connect signal to track changes in the spinbutton value */
gtk_object_set_data( GTK_OBJECT(integer_spinbutton),
"config_option", p_item->psz_name );
gtk_signal_connect( GTK_OBJECT(integer_spinbutton), "changed",
GTK_SIGNAL_FUNC(GtkIntChanged),
(gpointer)config_dialog );
LABEL_AND_WIDGET( p_item->psz_text,
integer_spinbutton, p_item->psz_longtext );
if (( p_item->i_max == 0) && ( p_item->i_min == 0))
{
/* add input box with default value */
item_adj = gtk_adjustment_new( p_item->i_value,
-1, 99999, 1, 10, 10 );
integer_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT(item_adj), 1, 0 );
/* connect signal to track changes in the spinbutton value */
gtk_object_set_data( GTK_OBJECT(integer_spinbutton),
"config_option", p_item->psz_name );
gtk_signal_connect( GTK_OBJECT(integer_spinbutton), "changed",
GTK_SIGNAL_FUNC(GtkIntChanged),
(gpointer)config_dialog );
LABEL_AND_WIDGET( p_item->psz_text,
integer_spinbutton, p_item->psz_longtext );
}
else /* use i_min and i_max */
{
item_adj = gtk_adjustment_new( p_item->i_value, p_item->i_min,
p_item->i_max, 1, 1, 0 );
integer_slider = gtk_hscale_new( GTK_ADJUSTMENT(item_adj));
gtk_scale_set_digits (GTK_SCALE(integer_slider), 0);
/* connect signal to track changes in the spinbutton value */
gtk_object_set_data( GTK_OBJECT(item_adj),
"config_option", p_item->psz_name );
gtk_signal_connect( GTK_OBJECT(item_adj), "value-changed",
GTK_SIGNAL_FUNC(GtkIntRangedChanged),
(gpointer)config_dialog );
LABEL_AND_WIDGET( p_item->psz_text,
integer_slider, p_item->psz_longtext );
}
break;
case CONFIG_ITEM_FLOAT:
/* add input box with default value */
item_adj = gtk_adjustment_new( p_item->f_value,
0, 99999, 0.01, 10, 10 );
float_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT(item_adj),
0.01, 2 );
/* connect signal to track changes in the spinbutton value */
gtk_object_set_data( GTK_OBJECT(float_spinbutton),
"config_option", p_item->psz_name );
gtk_signal_connect( GTK_OBJECT(float_spinbutton), "changed",
GTK_SIGNAL_FUNC(GtkFloatChanged),
(gpointer)config_dialog );
LABEL_AND_WIDGET( p_item->psz_text,
float_spinbutton, p_item->psz_longtext );
if (( p_item->f_max == 0.0) && ( p_item->f_min == 0.0))
{
/* add input box with default value */
item_adj = gtk_adjustment_new( p_item->f_value,
0, 99999, 0.01, 10, 10 );
float_spinbutton = gtk_spin_button_new( GTK_ADJUSTMENT(item_adj),
0.01, 2 );
/* connect signal to track changes in the spinbutton value */
gtk_object_set_data( GTK_OBJECT(float_spinbutton),
"config_option", p_item->psz_name );
gtk_signal_connect( GTK_OBJECT(float_spinbutton), "changed",
GTK_SIGNAL_FUNC(GtkFloatChanged),
(gpointer)config_dialog );
LABEL_AND_WIDGET( p_item->psz_text,
float_spinbutton, p_item->psz_longtext );
}
else /* use f_min and f_max */
{
item_adj = gtk_adjustment_new( p_item->f_value, p_item->f_min,
p_item->f_max, 0.01, 0.01, 0 );
float_slider = gtk_hscale_new( GTK_ADJUSTMENT(item_adj));
gtk_scale_set_digits (GTK_SCALE(float_slider), 2);
/* connect signal to track changes in the spinbutton value */
gtk_object_set_data( GTK_OBJECT(item_adj),
"config_option", p_item->psz_name );
gtk_signal_connect( GTK_OBJECT(item_adj), "value-changed",
GTK_SIGNAL_FUNC(GtkFloatRangedChanged),
(gpointer)config_dialog );
LABEL_AND_WIDGET( p_item->psz_text,
float_slider, p_item->psz_longtext );
}
break;
case CONFIG_ITEM_BOOL:
/* add check button */
......@@ -766,7 +810,6 @@ static void GtkStringChanged( GtkEditable *editable, gpointer user_data )
"apply_button" );
gtk_widget_set_sensitive( apply_button, TRUE );
}
/****************************************************************************
* GtkIntChanged: signal called when the user changes an integer value.
****************************************************************************/
......@@ -805,6 +848,43 @@ static void GtkIntChanged( GtkEditable *editable, gpointer user_data )
gtk_widget_set_sensitive( apply_button, TRUE );
}
/***************************************************************************************
* GtkIntRangedChanged: signal called when the user changes an integer with range value.
**************************************************************************************/
static void GtkIntRangedChanged( GtkEditable *editable, gpointer user_data )
{
intf_thread_t *p_intf;
module_config_t *p_config;
GHashTable *hash_table;
GtkWidget *apply_button;
p_intf = (intf_thread_t *)gtk_object_get_data( GTK_OBJECT(editable),
"p_intf" );
hash_table = (GHashTable *)gtk_object_get_data( GTK_OBJECT(user_data),
"config_hash_table" );
/* free old p_config */
p_config = (module_config_t *)g_hash_table_lookup( hash_table,
(gpointer)editable );
if( p_config ) GtkFreeHashValue( NULL, (gpointer)p_config, (void *)p_intf );
p_config = malloc( sizeof(module_config_t) );
p_config->i_type = CONFIG_ITEM_INTEGER;
p_config->i_value = ((GTK_ADJUSTMENT(editable))->value);
p_config->psz_name = (char *)gtk_object_get_data( GTK_OBJECT(editable),
"config_option" );
g_hash_table_insert( hash_table, (gpointer)editable,
(gpointer)p_config );
/* change the highlight status of the Apply button */
apply_button = (GtkWidget *)gtk_object_get_data( GTK_OBJECT(user_data),
"apply_button" );
gtk_widget_set_sensitive( apply_button, TRUE );
}
/****************************************************************************
* GtkFloatChanged: signal called when the user changes a float value.
****************************************************************************/
......@@ -843,6 +923,42 @@ static void GtkFloatChanged( GtkEditable *editable, gpointer user_data )
gtk_widget_set_sensitive( apply_button, TRUE );
}
/***************************************************************************************
* GtkIntRangedChanged: signal called when the user changes an integer with range value.
**************************************************************************************/
static void GtkFloatRangedChanged( GtkEditable *editable, gpointer user_data )
{
intf_thread_t *p_intf;
module_config_t *p_config;
GHashTable *hash_table;
GtkWidget *apply_button;
p_intf = (intf_thread_t *)gtk_object_get_data( GTK_OBJECT(editable),
"p_intf" );
hash_table = (GHashTable *)gtk_object_get_data( GTK_OBJECT(user_data),
"config_hash_table" );
/* free old p_config */
p_config = (module_config_t *)g_hash_table_lookup( hash_table,
(gpointer)editable );
if( p_config ) GtkFreeHashValue( NULL, (gpointer)p_config, (void *)p_intf );
p_config = malloc( sizeof(module_config_t) );
p_config->i_type = CONFIG_ITEM_FLOAT;
p_config->f_value = ((GTK_ADJUSTMENT(editable))->value);
p_config->psz_name = (char *)gtk_object_get_data( GTK_OBJECT(editable),
"config_option" );
g_hash_table_insert( hash_table, (gpointer)editable,
(gpointer)p_config );
/* change the highlight status of the Apply button */
apply_button = (GtkWidget *)gtk_object_get_data( GTK_OBJECT(user_data),
"apply_button" );
gtk_widget_set_sensitive( apply_button, TRUE );
}
/****************************************************************************
* GtkBoolChanged: signal called when the user changes a bool value.
****************************************************************************/
......
......@@ -2,7 +2,7 @@
* adjust.c : Contrast/Hue/Saturation/Brightness video plugin for vlc
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
* $Id: adjust.c,v 1.4 2002/12/12 10:56:24 garf Exp $
* $Id: adjust.c,v 1.5 2003/01/06 00:37:30 garf Exp $
*
* Authors: Simon Latapie <garf@via.ecp.fr>, Samuel Hocevar <sam@zoy.org>
*
......@@ -63,10 +63,10 @@ static void Render ( vout_thread_t *, picture_t * );
vlc_module_begin();
add_category_hint( N_("Miscellaneous"), NULL );
add_float( "Contrast", 1.0, NULL, CONT_TEXT, CONT_LONGTEXT );
add_float( "Brightness", 1.0, NULL, LUM_TEXT, LUM_LONGTEXT );
add_integer( "Hue", 0, NULL, HUE_TEXT, HUE_LONGTEXT );
add_float( "Saturation", 1.0, NULL, SAT_TEXT, SAT_LONGTEXT );
add_float_with_range( "Contrast", 1.0, 0.0, 2.0, NULL, CONT_TEXT, CONT_LONGTEXT );
add_float_with_range( "Brightness", 1.0, 0.0, 2.0, NULL, LUM_TEXT, LUM_LONGTEXT );
add_integer_with_range( "Hue", 0, 0, 360, NULL, HUE_TEXT, HUE_LONGTEXT );
add_float_with_range( "Saturation", 1.0, 0.0, 3.0, NULL, SAT_TEXT, SAT_LONGTEXT );
set_description( _("Contrast/Hue/Saturation/Brightness filter") );
set_capability( "video filter", 0 );
add_shortcut( "adjust" );
......
......@@ -2,7 +2,7 @@
* libvlc.h: main libvlc header
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
* $Id: libvlc.h,v 1.31 2002/12/18 17:52:23 gbazin Exp $
* $Id: libvlc.h,v 1.32 2003/01/06 00:37:30 garf Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -432,7 +432,7 @@ vlc_module_begin();
add_module_with_short( "aout", 'A', "audio output", NULL, NULL,
AOUT_TEXT, AOUT_LONGTEXT );
add_bool( "audio", 1, NULL, AUDIO_TEXT, AUDIO_LONGTEXT );
add_integer( "volume", -1, NULL, VOLUME_TEXT, VOLUME_LONGTEXT );
add_integer_with_range( "volume", 256, 0, 1024, NULL, VOLUME_TEXT, VOLUME_LONGTEXT );
add_integer( "aout-rate", -1, NULL, AOUT_RATE_TEXT, AOUT_RATE_LONGTEXT );
add_integer( "aout-channels", -1, NULL,
AOUT_CHANNELS_TEXT, AOUT_CHANNELS_LONGTEXT );
......@@ -555,19 +555,19 @@ vlc_module_end();
static module_config_t p_help_config[] =
{
{ CONFIG_ITEM_BOOL, NULL, "help", 'h', N_("print help"),
NULL, NULL, 0, 0.0, NULL, NULL, NULL, VLC_FALSE },
NULL, NULL, 0, 0.0, 0, 0, 0.0, 0.0, NULL, NULL, NULL, VLC_FALSE },
{ CONFIG_ITEM_BOOL, NULL, "longhelp", 'H', N_("print detailed help"),
NULL, NULL, 0, 0.0, NULL, NULL, NULL, VLC_FALSE },
NULL, NULL, 0, 0.0, 0, 0, 0.0, 0.0, NULL, NULL, NULL, VLC_FALSE },
{ CONFIG_ITEM_BOOL, NULL, "list", 'l',
N_("print a list of available modules"),
NULL, NULL, 0, 0.0, NULL, NULL, NULL, VLC_FALSE },
NULL, NULL, 0, 0.0, 0, 0, 0.0, 0.0, NULL, NULL, NULL, VLC_FALSE },
{ CONFIG_ITEM_STRING, NULL, "module", 'p', N_("print help on module"),
NULL, NULL, 0, 0.0, NULL, NULL, NULL, VLC_FALSE },
NULL, NULL, 0, 0.0, 0, 0, 0.0, 0.0, NULL, NULL, NULL, VLC_FALSE },
{ CONFIG_ITEM_BOOL, NULL, "version", '\0',
N_("print version information"),
NULL, NULL, 0, 0.0, NULL, NULL, NULL, VLC_FALSE },
NULL, NULL, 0, 0.0, 0, 0, 0.0, 0.0, NULL, NULL, NULL, VLC_FALSE },
{ CONFIG_HINT_END, NULL, NULL, '\0', NULL,
NULL, NULL, 0, 0.0, NULL, NULL, NULL, VLC_FALSE }
NULL, NULL, 0, 0.0, 0, 0, 0.0, 0.0, NULL, NULL, NULL, VLC_FALSE }
};
/*****************************************************************************
......
......@@ -2,7 +2,7 @@
* configuration.c management of the modules configuration
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: configuration.c,v 1.47 2002/12/13 01:56:30 gbazin Exp $
* $Id: configuration.c,v 1.48 2003/01/06 00:37:30 garf Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -222,7 +222,23 @@ void __config_PutInt( vlc_object_t *p_this, const char *psz_name, int i_value )
return;
}
p_config->i_value = i_value;
/* if i_min == i_max == 0, then do not use them */
if ((p_config->i_min == 0) && (p_config->i_max == 0))
{
p_config->i_value = i_value;
}
else if (i_value < p_config->i_min)
{
p_config->i_value = p_config->i_min;
}
else if (i_value > p_config->i_max)
{
p_config->i_value = p_config->i_max;
}
else
{
p_config->i_value = i_value;
}
if( p_config->pf_callback )
{
......@@ -255,7 +271,23 @@ void __config_PutFloat( vlc_object_t *p_this,
return;
}
p_config->f_value = f_value;
/* if f_min == f_max == 0, then do not use them */
if ((p_config->f_min == 0) && (p_config->f_max == 0))
{
p_config->f_value = f_value;
}
else if (f_value < p_config->f_min)
{
p_config->f_value = p_config->f_min;
}
else if (f_value > p_config->f_max)
{
p_config->f_value = p_config->f_max;
}
else
{
p_config->f_value = f_value;
}
if( p_config->pf_callback )
{
......@@ -353,7 +385,11 @@ void config_Duplicate( module_t *p_module, module_config_t *p_orig )
p_module->p_config[i].i_type = p_orig[i].i_type;
p_module->p_config[i].i_short = p_orig[i].i_short;
p_module->p_config[i].i_value = p_orig[i].i_value;
p_module->p_config[i].i_min = p_orig[i].i_min;
p_module->p_config[i].i_max = p_orig[i].i_max;
p_module->p_config[i].f_value = p_orig[i].f_value;
p_module->p_config[i].f_min = p_orig[i].f_min;
p_module->p_config[i].f_max = p_orig[i].f_max;
p_module->p_config[i].b_dirty = p_orig[i].b_dirty;
p_module->p_config[i].psz_type = p_orig[i].psz_type ?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment