Fremantle: Prestart MicroB if appropriate when reconfiguring browser-switchboard
[browser-switch] / config-ui / browser-switchboard-cp.c
index 93f8e0a..02a4a07 100644 (file)
@@ -1,14 +1,14 @@
 /*
  * browser-switchboard-cp.c -- a hildon-control-panel applet for
  * selecting the default browser for Browser Switchboard
- * 
+ *
  * Copyright (C) 2009-2010 Steven Luo
  * Copyright (C) 2009-2010 Faheem Pervez
- * 
+ *
  * Derived from services-cp.c from maemo-control-services
  * Copyright (c) 2008 Janne Kataja <janne.kataja@iki.fi>
  * Copyright (c) 2008 Nokia Corporation
- * 
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2, or (at your option)
@@ -52,6 +52,7 @@
 #endif /* HILDON */
 
 #include "config.h"
+#include "save-config.h"
 #include "browsers.h"
 
 #define CONTINUOUS_MODE_DEFAULT 0
@@ -148,7 +149,7 @@ static inline void set_other_browser_cmd(char *cmd) {
 
 static void load_config(void) {
        swb_config_init(&orig_cfg);
-       
+
        swb_config_load(&orig_cfg);
 
 #ifndef FREMANTLE
@@ -185,15 +186,9 @@ static void save_config(void) {
        }
 
        swb_config_save(&new_cfg);
-}
-
-static void do_reconfig(void) {
-       save_config();
 
-       /* Try to send SIGHUP to any running browser-switchboard process
-          This causes it to reread config files if in continuous_mode, or
-          die so that the config will be reloaded on next start otherwise */
-       system("kill -HUP `pidof browser-switchboard` > /dev/null 2>&1");
+       /* Reconfigure a running browser-switchboard, if present */
+       swb_reconfig(&orig_cfg, &new_cfg);
 }
 
 
@@ -422,7 +417,7 @@ osso_return_t execute(osso_context_t *osso,
 
        response = gtk_dialog_run(dialog);
        if (response == GTK_RESPONSE_OK)
-               do_reconfig();
+               save_config();
 
        gtk_widget_destroy(GTK_WIDGET(dialog));
 
@@ -451,7 +446,7 @@ int main(int argc, char *argv[]) {
 
        response = gtk_dialog_run(dialog);
        if (response == GTK_RESPONSE_OK)
-               do_reconfig();
+               save_config();
 
        gtk_widget_destroy(GTK_WIDGET(dialog));