Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide command line options for WebKitSettings properties #29

Merged
merged 2 commits into from
Jun 11, 2018

Conversation

aperezdc
Copy link
Member

This adds code to introspect properties of a given GObjectClass and obtain a set of GOptionEntry instances which, when added to a GOptionGroup, will set the values of the properties from the parsed command line options.

Then, the above utility code is used to expose the properties from WebKitSettings in a generic way, instead of having to manually add a GOptionEntry and handling for each settings.

The following CLI options are replaced by the new functionality, which covers the corresponding settings:

Old New
--webgl --enable-webgl=1
-D
--dev-tools
--enable-developer-extras=1
-v
--log-console
--enable-write-console-messages-to-stdout=1

Closes #27

@aperezdc aperezdc requested review from philn and elima June 11, 2018 15:07
Copy link
Member

@philn philn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a nitpick.

core/cog-utils.c Outdated
const gboolean prop_value = !(value &&
g_ascii_strcasecmp (value, "true") &&
strcmp (value, "1"));
g_printerr ("set %s=%s\n", option, prop_value ? "true" : "false");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a stray debug statement?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, good catch! Let's remove this before merging 👍

This adds code to introspect properties of a given GObjectClass
and obtain a set of GOptionEntry instances which, when added to
a GOptionGroup, will set the values of the properties from the
parsed command line options.

Then, the above utility code is used to expose the properties from
WebKitSettings in a generic way, instead of having to manually add
a GOptionEntry and handling for each settings.

The following CLI options are replaced by the new functionality,
which covers the corresponding settings:

  --webgl          becomes --enable-webgl=1
  -D/--dev-tools   becomes --enable-developer-extras=1
  -v/--log-console becomes --enable-write-console-messages-to-stdout=1

Closes #27
Instead of directly using the type names provided by GType, use
uppercase strings for the value placeholders in help texts, which
makes the output from --help-websettings more easily readable and
provide a few lines with explanations for the available input
formats.
@aperezdc
Copy link
Member Author

I've added a small commit on top to provide a nicer formatting of the help output when using --help-websettings, which now looks like this:

Usage:                                                                                                          
  cog [OPTION?] [URL]                                                                                           
                                                                                               
WebKitSettings options can be used to configure features exposed to the loaded Web content.          
                                                                                                                
  BOOL values are either 'true', '1', 'false', or '0'. Ommitting the value implies '1'.                        
  INTEGER values can be decimal, octal (prefix '0'), or hexadecimal (prefix '0x').                        
  UNSIGNED values behave like INTEGER, but negative values are not accepted.                
  FLOAT values may optionally use decimal separators and scientific notation.                                  
  STRING values may need quoting when passed from the shell.                                              
                                                                                                              
  --enable-javascript=BOOL                             Enable JavaScript.                              
  --auto-load-images=BOOL                              Load images automatically.                    
  --load-icons-ignoring-image-load-setting=BOOL        Whether to load site icons ignoring image load setting.
  ...

@philn philn merged commit 1c63839 into master Jun 11, 2018
@aperezdc aperezdc deleted the cog-websettings-cli branch June 11, 2018 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants