From: <li...@yo...> - 2007-07-12 21:51:10
|
# HG changeset patch # User Darren Salt <li...@yo...> # Date 1184277063 -3600 # Node ID 17426240430020c26be94e40b08034940091fbe8 # Parent 24c85a7d2f86edef77b2fbd4896150673d44e419 Add "--configure KEY=VALUE" (set config item(s) at startup). diff -r 17426240430020c26be94e40b08034940091fbe8 -r 24c85a7d2f86edef77b2fbd4896150673d44e419 ChangeLog --- a/ChangeLog Thu Jul 12 22:51:03 2007 +0100 +++ b/ChangeLog Mon Jul 09 22:03:04 2007 +0100 @@ -89,6 +89,7 @@ 0.5.900:2007/??/?? * Treat .ra and .rm as binary. * Fixed two install-debug failures. * Added a compatibility fix for glib 2.13 and later. + * New option --configure for setting configuration items. 0.5.11: 2007/02/01 [dsalt] diff -r 17426240430020c26be94e40b08034940091fbe8 -r 24c85a7d2f86edef77b2fbd4896150673d44e419 TODO --- a/TODO Thu Jul 12 22:51:03 2007 +0100 +++ b/TODO Mon Jul 09 22:03:04 2007 +0100 @@ -46,9 +46,6 @@ ideas / feature requests - frame single-stepping [roguebug on #xine] -- configuration alteration switch (command line) - [Ingo Saitz (Salz) on #xine] - unsorted stuff ============== diff -r 17426240430020c26be94e40b08034940091fbe8 -r 24c85a7d2f86edef77b2fbd4896150673d44e419 doc/man/en/gxine.1 --- a/doc/man/en/gxine.1 Thu Jul 12 22:51:03 2007 +0100 +++ b/doc/man/en/gxine.1 Mon Jul 09 22:03:04 2007 +0100 @@ -79,6 +79,13 @@ Javascript command(s) to be executed imm Javascript command(s) to be executed immediately after starting up. .RE .PP +.BI \-C \ KEY=VALUE +.br +.BI \-\-configure \ KEY=VALUE +.RS +Set configuration item KEY to VALUE, e.g. "-c gui.window_size=100%". +.RE +.PP .B \-v .br .B \-\-verbose diff -r 17426240430020c26be94e40b08034940091fbe8 -r 24c85a7d2f86edef77b2fbd4896150673d44e419 src/main.c --- a/src/main.c Thu Jul 12 22:51:03 2007 +0100 +++ b/src/main.c Mon Jul 09 22:03:04 2007 +0100 @@ -297,6 +297,57 @@ list_plugins (const char *msg, typeof (x g_print ("\n"); } +static void config_change (gpointer data, gpointer user) +{ + xine_cfg_entry_t entry; + int i; + char *text = data; + char *equals = strchr (text, '='); + *equals = 0; + + if (xine_config_lookup_entry (xine, text, &entry)) + switch (entry.type) + { + case XINE_CONFIG_TYPE_RANGE: + i = atoi (equals + 1); + entry.num_value = MIN (entry.range_max, MAX (entry.range_min, i)); + xine_config_update_entry (xine, &entry); + break; + + case XINE_CONFIG_TYPE_NUM: + entry.num_value = atoi (equals + 1); + xine_config_update_entry (xine, &entry); + break; + + case XINE_CONFIG_TYPE_BOOL: + entry.num_value = !!atoi (equals + 1); + xine_config_update_entry (xine, &entry); + break; + + case XINE_CONFIG_TYPE_STRING: + entry.str_value = equals + 1; + xine_config_update_entry (xine, &entry); + break; + + case XINE_CONFIG_TYPE_ENUM: + for (i = 0; entry.enum_values[i]; ++i) + if (!strcmp (equals + 1, entry.enum_values[i])) + break; + if (entry.enum_values[i]) + { + entry.num_value = i; + xine_config_update_entry (xine, &entry); + } + else /* given value isn't in the list of valid values */ + g_printerr (_("gxine: warning: bad value for config item '%s'\n"), text); + break; + } + else + g_printerr (_("gxine: warning: config item '%s' not found\n"), text); + + *equals = '='; +} + int main(int argc, char* argv[]) { gboolean enqueue, autoplay, fullscreen; @@ -306,6 +357,7 @@ int main(int argc, char* argv[]) const char *cmd = NULL; char *geometry = NULL; xine_cfg_entry_t entry; + GPtrArray *cfg_changes; gboolean migrated_config_dir = FALSE; g_thread_init (NULL); /* done early for glib >= 2.13 */ @@ -390,9 +442,10 @@ int main(int argc, char* argv[]) fullscreen = FALSE; no_connect = FALSE; optstate = 0; + cfg_changes = g_ptr_array_new (); for (;;) { -#define OPTS "hvaefV:A:sSc:n" +#define OPTS "hvaefV:A:sSc:C:n" #ifdef HAVE_GETOPT_LONG static struct option longopts[] = { { "help", no_argument, NULL, 'h' }, @@ -406,6 +459,7 @@ int main(int argc, char* argv[]) { "splash", no_argument, NULL, 's' }, { "no-splash", no_argument, NULL, 'S' }, { "command", required_argument, NULL, 'c' }, + { "configure", required_argument, NULL, 'C' }, { "geometry", required_argument, NULL, 2 }, { NULL } }; @@ -459,6 +513,12 @@ int main(int argc, char* argv[]) break; case 'n': no_connect = TRUE; + break; + case 'C': + if (strchr (optarg, '=')) + g_ptr_array_add (cfg_changes, optarg); + else + g_printerr (_("gxine: warning: bad parameter for --configure: '%s'\n"), optarg); break; default: optstate |= 2; @@ -481,6 +541,8 @@ options:\n\ -e, --enqueue don't clear the playlist, don't play the new items\n\ -f, --full-screen start in full-screen mode\n\ -v, --verbose be more verbose\n\ + -C, --configure KEY=VALUE\n\ + alter a configuration item\n\ \n"), VERSION, VENDOR_PKG_VERSION CSET_ID, argv[0]); list_plugins (_("Available video drivers:"), xine_list_video_output_plugins); list_plugins (_("Available audio drivers:"), xine_list_audio_output_plugins); @@ -675,6 +737,8 @@ to the extent permitted by law.\n"), stream_info_init (); wizards_init (); + g_ptr_array_foreach (cfg_changes, config_change, NULL); + engine_startup_script (); /* |