--- a/src/FluidSynth-DSSI_gtk.c
+++ b/src/FluidSynth-DSSI_gtk.c
@@ -1,6 +1,6 @@
 /* FluidSynth DSSI software synthesizer GUI
  *
- * Copyright (C) 2004-2005 Sean Bolton and others.
+ * Copyright (C) 2004-2008 Sean Bolton and others.
  *
  * Portions of this file may have come from FluidSynth, copyright
  * (C) 2003 Peter Hanappe and others.
@@ -19,8 +19,8 @@
  *
  * You should have received a copy of the GNU General Public
  * License along with this program; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307, USA.
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
  */
 
 #define _BSD_SOURCE    1
@@ -83,6 +83,7 @@
 char *     osc_midi_path;
 char *     osc_program_path;
 char *     osc_quit_path;
+char *     osc_rate_path;
 char *     osc_show_path;
 char *     osc_update_path;
 
@@ -111,6 +112,7 @@
 
 int internal_gui_update_only = 0;
 int host_requested_quit = 0;
+int gui_test_mode = 0;
 
 /* ==== OSC handling ==== */
 
@@ -176,6 +178,11 @@
         /* DEBUG_DSSI("fsd-gui osc_action_handler: received 'quit' message\n"); */
         host_requested_quit = 1;
         gtk_main_quit();
+
+    } else if (!strcmp(user_data, "sample-rate")) {
+
+        /* DEBUG_DSSI("fsd-gui osc_action_handler: received 'sample-rate' message, rate is %d\n", argv[0]->i); */
+        /* ignore it */
 
     } else {
 
@@ -337,8 +344,16 @@
 gint
 update_request_timeout_callback(gpointer data)
 {
-    /* send our update request */
-    lo_send(osc_host_address, osc_update_path, "s", osc_self_url);
+    if (!gui_test_mode) {
+
+        /* send our update request */
+        lo_send(osc_host_address, osc_update_path, "s", osc_self_url);
+
+    } else {
+
+        gtk_widget_show(main_window);
+
+    }
 
     return FALSE;  /* don't need to do this again */
 }
@@ -1145,6 +1160,7 @@
 int
 main (int argc, char *argv[])
 {
+    static char *test_argv[5] = { NULL, NULL, "-", "-", "FluidSynth-DSSI" };
     char *host, *port, *path, *tmp_url;
     lo_server osc_server;
     gint osc_server_socket_tag;
@@ -1155,8 +1171,17 @@
     gtk_set_locale ();
     gtk_init (&argc, &argv);
 
-    if (argc != 5) {
-        fprintf(stderr, "usage: %s <osc url> <plugin dllname> <plugin label> <user-friendly id>\n", argv[0]);
+    if (!strcmp(argv[1], "-test")) {
+        gui_test_mode = 1;
+        test_argv[0] = argv[0];
+        test_argv[1] = "osc.udp://localhost:9/test/mode";
+        if (argc >= 5)
+            test_argv[4] = argv[4];
+        argc = 5;
+        argv = test_argv;
+    } else if (argc != 5) {
+        fprintf(stderr, "usage: %s <osc url> <plugin dllname> <plugin label> <user-friendly id>\n"
+                        "   or: %s -test\n", argv[0], argv[0]);
         exit(1);
     }
 
@@ -1172,6 +1197,7 @@
     osc_midi_path      = osc_build_path(path, "/midi");
     osc_program_path   = osc_build_path(path, "/program");
     osc_quit_path      = osc_build_path(path, "/quit");
+    osc_rate_path      = osc_build_path(path, "/sample-rate");
     osc_show_path      = osc_build_path(path, "/show");
     osc_update_path    = osc_build_path(path, "/update");
 
@@ -1181,6 +1207,7 @@
     lo_server_add_method(osc_server, osc_hide_path, "", osc_action_handler, "hide");
     lo_server_add_method(osc_server, osc_program_path, "ii", osc_program_handler, NULL);
     lo_server_add_method(osc_server, osc_quit_path, "", osc_action_handler, "quit");
+    lo_server_add_method(osc_server, osc_rate_path, "i", osc_action_handler, "sample-rate");
     lo_server_add_method(osc_server, osc_show_path, "", osc_action_handler, "show");
     lo_server_add_method(osc_server, NULL, NULL, osc_debug_handler, NULL);
 
@@ -1243,6 +1270,7 @@
     free(osc_midi_path);
     free(osc_program_path);
     free(osc_quit_path);
+    free(osc_rate_path);
     free(osc_show_path);
     free(osc_update_path);
     free(osc_self_url);