Use computed offset instead of hand-built array for access to struct swb_config members To access an arbitrary member of struct swb_config, we currently use the entries array in the struct, which contains pointers to the members of the struct in order. This has several disadvantages: * the entries array must be filled by hand for each instance; * structure instances cannot be copied in the normal way; * the swb_config_options array describing the possible config options must be kept in the same order as the members of the struct. A much better solution is to let the compiler compute the offset of structure members using the offsetof() macro and stick the results in the swb_config_options array; we can then access the member by adding the offset to the address of the structure instance. This also allows us to get rid of the entries array in struct swb_config and the swb_config_copy() function.
Fremantle: Prestart MicroB if appropriate when reconfiguring browser-switchboard If, in changing the browser-switchboard configuration, we go from a configuration where MicroB is not left running to one where it is, we should start MicroB in the background in order to make sure that the MicroB browser window comes up quickly when requested. Make a best-effort attempt at this in both the command-line utility and the GUI, refactoring to give a swb_reconfig() function that can be shared between the two along the way. Ideally, we'd also kill MicroB when making a config change in the other direction, but we don't have an easy way of knowing whether MicroB is actually in use and we don't want to kill MicroB if it's in use at the time.
Command-line utility: check that browser is installed before reporting it as the default When reporting the configured default browser (-b), check to see that it's installed. If the configured default browser isn't installed, report the default default browser instead, since that's what browser-switchboard will actually use.
Config UI: Only offer the user browsers that are installed Check to see which of the known browsers is installed, and only offer the user choices for the ones that are. If the currently configured default browser is not installed (e.g. if the user uninstalled the browser without changing the default), use the default default browser like browser-switchboard does. This fixes Browser Switchboard bug 5469: https://garage.maemo.org/tracker/index.php?func=detail&aid=5469&group_id=1159&atid=4348
Config UI: leave other_browser_cmd unset instead of configuring an empty value It used to be that when the user cleared the value of other_browser_cmd in the UI, the setting would be removed from the config file instead of writing an empty value. Restore this behavior.
Describe MicroB slightly more verbosely in the UI Emanuele Cassioli pointed out that users could potentially be unfamiliar with the name "MicroB", since it's not used in normally user-visible places. Rename the entry "MicroB (stock browser)" to hopefully help these users; better suggestions welcome.
Introduce command-line config utility Add a simple command-line configuration utility, browser-switchboard-config, which can be used to query or set browser-switchboard config settings. The primary purpose of this tool is to allow browser vendors to provide an option in their browsers to set themselves as the default browser, via something like this (shell-like pseudocode): if [ -x /usr/bin/browser-switchboard-config ]; then if [ `browser-switchboard-config -b` = "mybrowser" ]; then display "MyBrowser is the default browser." else button "Make MyBrowser the default browser" action "browser-switchboard-config -s -b mybrowser" fi else display "Install Browser Switchboard to make MyBrowser the default browser" fi Browser vendors: setting yourself as the default browser without prompting the user first (via package maintainer scripts, for example) is strongly discouraged.
Clean up configuration again Commit ec8b58af... ("Refactor configuration") still has too much boilerplate code and leaves too many places that have to be modified to add a new config option. To fix this, add a new array of config options with name and type of information stored, and then add an array of pointers to the elements of struct swb_config with indices matching the list of config options to struct swb_config. This consolidates all the work needed to add new config options to config.h and config.c, and allows us to replace the boilerplate code with loops over the array of config options.
Refactor configuration Most of the code for loading configuration from the config file was being duplicated between the UI and the main browser-switchboard code; also, the forthcoming command-line configuration tool should share the code for loading and saving configuration with the UI. Therefore, move code for loading and saving configuration information into functions generic enough to be shared between the UIs and browser-switchboard.
Add preliminary support for Opera Mobile We do this the lazy way, using use_other_browser_cmd("opera %s"). The Opera Labs post announcing Opera Mobile for Maemo (http://labs.opera.com/news/2010/05/11/) says that "an extra empty tab will get opened every time you open a link from an external application", so I suspect we may need a different method of opening links in an already open browser.
Link binaries with -Wl,--as-needed to reduce library dependencies Using pkg-config --libs to get library link lines has the disadvantage of bringing in many more library dependencies than actually necessary, since that assumes that dependencies of libraries need to be specified explicitly at link time (even when the library is itself linked against those dependencies). Using GNU ld's --as-needed option causes these unnecessary dependencies to be omitted from the binary. --as-needed needs to be specified after all the objects to be linked into the binary and before the libraries, so some reordering of the link command line is needed.