gmerlin
|
00001 /***************************************************************** 00002 * gmerlin - a general purpose multimedia framework and applications 00003 * 00004 * Copyright (c) 2001 - 2011 Members of the Gmerlin project 00005 * gmerlin-general@lists.sourceforge.net 00006 * http://gmerlin.sourceforge.net 00007 * 00008 * This program is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation, either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00020 * *****************************************************************/ 00021 00022 #ifndef __BG_PARAMETER_H_ 00023 #define __BG_PARAMETER_H_ 00024 00025 #include <libxml/tree.h> 00026 #include <libxml/parser.h> 00027 00028 #include <gavl/gavl.h> 00029 00044 /* Universal Parameter setting mechanism */ 00045 00053 typedef enum 00054 { 00055 BG_PARAMETER_SECTION, 00056 BG_PARAMETER_CHECKBUTTON, 00057 BG_PARAMETER_INT, 00058 BG_PARAMETER_FLOAT, 00059 BG_PARAMETER_SLIDER_INT, 00060 BG_PARAMETER_SLIDER_FLOAT, 00061 BG_PARAMETER_STRING, 00062 BG_PARAMETER_STRING_HIDDEN, 00063 BG_PARAMETER_STRINGLIST, 00064 BG_PARAMETER_COLOR_RGB, 00065 BG_PARAMETER_COLOR_RGBA, 00066 BG_PARAMETER_FONT, 00067 BG_PARAMETER_DEVICE, 00068 BG_PARAMETER_FILE, 00069 BG_PARAMETER_DIRECTORY, 00070 BG_PARAMETER_MULTI_MENU, 00071 BG_PARAMETER_MULTI_LIST, 00072 BG_PARAMETER_MULTI_CHAIN, 00073 BG_PARAMETER_TIME, 00074 BG_PARAMETER_POSITION, 00075 BG_PARAMETER_BUTTON, 00076 } bg_parameter_type_t; 00077 00082 typedef union 00083 { 00084 double val_f; 00085 int val_i; 00086 char * val_str; 00087 float val_color[4]; 00088 gavl_time_t val_time; 00089 double val_pos[2]; 00090 } bg_parameter_value_t; 00091 00092 /* Flags */ 00093 00097 #define BG_PARAMETER_SYNC (1<<0) //!< Apply the value whenever the widgets value changes 00098 00102 #define BG_PARAMETER_HIDE_DIALOG (1<<1) //!< Don't make a configuration widget (for objects, which change values themselves) 00103 00107 #define BG_PARAMETER_NO_SORT (1<<2) //!< Don't make a list sortable 00108 00112 #define BG_PARAMETER_PLUGIN (1<<3) //!< Parameter refers to a plugin 00113 00117 #define BG_PARAMETER_OWN_SECTION (1<<4) //!< For parameters of the type BG_PARAMETER_SECTION: Following parameters should be stored in an own section 00118 00123 #define BG_PARAMETER_GLOBAL_PRESET (1<<5) //!< For parameters of the type BG_PARAMETER_SECTION: There should be one preset for all following sections 00124 00125 00126 typedef struct bg_parameter_info_s bg_parameter_info_t; 00127 00134 struct bg_parameter_info_s 00135 { 00136 char * name; 00137 char * long_name; 00138 char * opt; 00139 00140 char * gettext_domain; 00141 char * gettext_directory; 00142 00143 bg_parameter_type_t type; 00144 00145 int flags; 00146 00147 bg_parameter_value_t val_default; 00148 bg_parameter_value_t val_min; 00149 bg_parameter_value_t val_max; 00150 00151 /* Names which can be passed to set_parameter (NULL terminated) */ 00152 00153 char const * const * multi_names; 00154 00155 /* Long names are optional, if they are NULL, 00156 the short names are used */ 00157 00158 char const * const * multi_labels; 00159 char const * const * multi_descriptions; 00160 00161 /* 00162 * These are parameters for each codec. 00163 * The name members of these MUST be unique with respect to the rest 00164 * of the parameters passed to the same set_parameter func 00165 */ 00166 00167 struct bg_parameter_info_s const * const * multi_parameters; 00168 00169 int num_digits; 00170 00171 char * help_string; 00172 00173 char * preset_path; 00174 00175 char ** multi_names_nc; 00176 00177 char ** multi_labels_nc; 00178 00179 char ** multi_descriptions_nc; 00180 00181 struct bg_parameter_info_s ** multi_parameters_nc; 00182 00183 }; 00184 00185 /* Prototype for setting/getting parameters */ 00186 00187 /* 00188 * NOTE: All applications MUST call a bg_set_parameter_func with 00189 * a NULL name argument to signal, that all parameters are set now 00190 */ 00191 00205 typedef void (*bg_set_parameter_func_t)(void * data, const char * name, 00206 const bg_parameter_value_t * v); 00207 00221 typedef int (*bg_get_parameter_func_t)(void * data, const char * name, 00222 bg_parameter_value_t * v); 00223 00230 void bg_parameter_info_copy(bg_parameter_info_t * dst, 00231 const bg_parameter_info_t * src); 00232 00242 bg_parameter_info_t * 00243 bg_parameter_info_copy_array(const bg_parameter_info_t * src); 00244 00253 void 00254 bg_parameter_info_set_const_ptrs(bg_parameter_info_t * info); 00255 00261 void bg_parameter_info_destroy_array(bg_parameter_info_t * info); 00262 00273 void bg_parameter_value_copy(bg_parameter_value_t * dst, 00274 const bg_parameter_value_t * src, 00275 const bg_parameter_info_t * info); 00276 00283 void bg_parameter_value_free(bg_parameter_value_t * val, 00284 bg_parameter_type_t type); 00285 00286 00294 bg_parameter_info_t * 00295 bg_parameter_info_concat_arrays(bg_parameter_info_t const ** srcs); 00296 00307 int bg_parameter_get_selected(const bg_parameter_info_t * info, 00308 const char * val); 00309 00310 00322 const bg_parameter_info_t * 00323 bg_parameter_find(const bg_parameter_info_t * info, 00324 const char * name); 00325 00326 00337 bg_parameter_info_t * bg_xml_2_parameters(xmlDocPtr xml_doc, 00338 xmlNodePtr xml_parameters); 00339 00349 void 00350 bg_parameters_2_xml(const bg_parameter_info_t * info, xmlNodePtr xml_parameters); 00351 00360 void 00361 bg_parameters_dump(const bg_parameter_info_t * info, const char * filename); 00362 00363 00364 #endif /* __BG_PARAMETER_H_ */ 00365