Make "Web" menu entry and /usr/bin/browser open the default browser
authorSteven Luo <steven+maemo@steven676.net>
Sun, 21 Feb 2010 05:47:48 +0000 (21:47 -0800)
committerSteven Luo <steven+maemo@steven676.net>
Sun, 21 Feb 2010 05:47:48 +0000 (21:47 -0800)
Currently, no matter what the default browser is set to, the "Web" menu
entry opens MicroB, and running /usr/bin/browser does the same. This is
done to make sure that there's always a way of opening MicroB regardless
of the default browser setting.

However, this behavior would seem to be less than intuitive (why does
the entry marked "Web" not open the default browser? on Diablo, why do
the Web sidebar panel and Web menu entry do completely different
things?).  Therefore, do the following:

* Make the top_application method in the D-Bus interface open the
  default browser, not MicroB, and therefore make the "Web" menu entry
  open the default browser.
* Ship a new microb.desktop file which provides a MicroB menu entry that
  launches MicroB.
* Rename the existing /usr/bin/browser script to /usr/bin/microb.
* Ship a new /usr/bin/browser script which launches the default browser.

This has one primary disadvantage: none of the standard methods of
launching a browser on Maemo can be guaranteed to bring up MicroB (with
the old behavior, invoking /usr/bin/browser was guaranteed to bring up
MicroB, just as if Browser Switchboard weren't installed).

Makefile
browser
dbus-server-bindings.c
microb [new file with mode: 0755]
microb.desktop [new file with mode: 0644]

index 4def31b..8442de4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -22,9 +22,12 @@ strip: $(APP)
 install: all
        mkdir -p $(DESTDIR)$(PREFIX)/bin
        mkdir -p $(DESTDIR)$(PREFIX)/share/dbus-1/services
 install: all
        mkdir -p $(DESTDIR)$(PREFIX)/bin
        mkdir -p $(DESTDIR)$(PREFIX)/share/dbus-1/services
+       mkdir -p $(DESTDIR)$(PREFIX)/share/applications/hildon
        install -c -m 0755 browser-switchboard $(DESTDIR)$(PREFIX)/bin
        install -c -m 0644 com.nokia.osso_browser.service $(DESTDIR)$(PREFIX)/share/dbus-1/services
        install -c -m 0755 browser $(DESTDIR)$(PREFIX)/bin
        install -c -m 0755 browser-switchboard $(DESTDIR)$(PREFIX)/bin
        install -c -m 0644 com.nokia.osso_browser.service $(DESTDIR)$(PREFIX)/share/dbus-1/services
        install -c -m 0755 browser $(DESTDIR)$(PREFIX)/bin
+       install -c -m 0755 microb $(DESTDIR)$(PREFIX)/bin
+       install -c -m 0644 microb.desktop $(DESTDIR)$(PREFIX)/share/applications/hildon
 
 clean:
        rm -f $(APP) *.o dbus-server-glue.h
 
 clean:
        rm -f $(APP) *.o dbus-server-glue.h
diff --git a/browser b/browser
index 334523f..a94b7cd 100755 (executable)
--- a/browser
+++ b/browser
@@ -9,11 +9,5 @@ case "$1" in
                ;;
 esac
 
                ;;
 esac
 
-if pidof browser > /dev/null 2>&1; then
-       method=open_new_window
-else
-       method=switchboard_launch_microb
-fi
-
-dbus-send --session --type=method_call --print-reply --dest="com.nokia.osso_browser" /com/nokia/osso_browser/request com.nokia.osso_browser.$method string:${url:-"new_window"} > /dev/null 2>&1
+dbus-send --session --type=method_call --print-reply --dest="com.nokia.osso_browser" /com/nokia/osso_browser/request com.nokia.osso_browser.open_new_window string:${url:-"new_window"} > /dev/null 2>&1
 exit 0
 exit 0
index 9c4d6cd..f20a690 100644 (file)
@@ -127,12 +127,12 @@ gboolean osso_browser_top_application(OssoBrowser *obj,
                GError **error) {
        if (!ctx.continuous_mode)
                ignore_reconfig_requests();
                GError **error) {
        if (!ctx.continuous_mode)
                ignore_reconfig_requests();
-       launch_microb(&ctx, "new_window");
+       launch_browser(&ctx, "new_window");
        return TRUE;
 }
 
 /* This is a "undocumented", non-standard extension to the API, ONLY
        return TRUE;
 }
 
 /* This is a "undocumented", non-standard extension to the API, ONLY
-   for use by /usr/bin/browser wrapper to implement --url */
+   for use by /usr/bin/microb wrapper */
 gboolean osso_browser_switchboard_launch_microb(OssoBrowser *obj,
                const char *uri, GError **error) {
        if (!ctx.continuous_mode)
 gboolean osso_browser_switchboard_launch_microb(OssoBrowser *obj,
                const char *uri, GError **error) {
        if (!ctx.continuous_mode)
diff --git a/microb b/microb
new file mode 100755 (executable)
index 0000000..334523f
--- /dev/null
+++ b/microb
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+case "$1" in
+       --url=* )
+               url="${1#--url=}"
+               ;;
+       --url )
+               url="$2"
+               ;;
+esac
+
+if pidof browser > /dev/null 2>&1; then
+       method=open_new_window
+else
+       method=switchboard_launch_microb
+fi
+
+dbus-send --session --type=method_call --print-reply --dest="com.nokia.osso_browser" /com/nokia/osso_browser/request com.nokia.osso_browser.$method string:${url:-"new_window"} > /dev/null 2>&1
+exit 0
diff --git a/microb.desktop b/microb.desktop
new file mode 100644 (file)
index 0000000..ecaae47
--- /dev/null
@@ -0,0 +1,13 @@
+[Desktop Entry]
+Encoding=UTF-8
+Version=1.0
+Name=MicroB
+GenericName=Browser
+Comment=weba_ap_web_browser_thumb
+Exec=/usr/bin/microb
+Icon=qgn_list_browser
+Terminal=false
+Type=Application
+Categories=Application;Internet;
+X-HildonDesk-ShowInToolbar=true
+X-Osso-Type=application/x-executable