summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2010-11-18 18:03:32 +0000
committerRex Dieter <rdieter@fedoraproject.org>2011-02-01 08:53:14 -0600
commit6f49c05ceb2a1935d07c49c2e100b5cf3cdf5f26 (patch)
tree4c8a2e1d7673e5585fb6848f5cc53d8edfb05f12
parent2baf6ae56f9b622ca51aa79ff370676aaef93908 (diff)
Port mailto and browser settings for GNOME 3.x
We use the x-scheme-handler/$protocol now, instead of GConf keys.
-rw-r--r--scripts/xdg-copy.in2
-rw-r--r--scripts/xdg-email.in30
-rw-r--r--scripts/xdg-file-dialog.in8
-rw-r--r--scripts/xdg-mime.in2
-rw-r--r--scripts/xdg-open.in2
-rw-r--r--scripts/xdg-settings.in78
-rw-r--r--scripts/xdg-su.in2
-rw-r--r--scripts/xdg-terminal.in2
-rw-r--r--scripts/xdg-utils-common.in6
9 files changed, 111 insertions, 21 deletions
diff --git a/scripts/xdg-copy.in b/scripts/xdg-copy.in
index 8387248..6838cd6 100644
--- a/scripts/xdg-copy.in
+++ b/scripts/xdg-copy.in
@@ -96,7 +96,7 @@ case "$DE" in
copy_kde "$source" "$dest"
;;
- gnome)
+ gnome*)
copy_gnome "$source" "$dest"
;;
diff --git a/scripts/xdg-email.in b/scripts/xdg-email.in
index cff0840..1066e1f 100644
--- a/scripts/xdg-email.in
+++ b/scripts/xdg-email.in
@@ -120,6 +120,32 @@ open_kde()
fi
}
+open_gnome3()
+{
+ local client
+ local desktop
+ desktop=`xdg-mime query default "x-scheme-handler/mailto"`
+ client=`desktop_file_to_binary "$browser"`
+ echo $client | grep thunderbird > /dev/null 2>&1
+ if [ $? -eq 0 ] ; then
+ run_thunderbird "$client" "$1"
+ fi
+
+ if gvfs-open --help 2>/dev/null 1>&2; then
+ DEBUG 1 "Running gvfs-open \"$1\""
+ gvfs-open "$1"
+ else
+ DEBUG 1 "Running gnome-open \"$1\""
+ gnome-open "$1"
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
open_gnome()
{
local client
@@ -360,6 +386,10 @@ case "$DE" in
open_gnome "${mailto}"
;;
+ gnome3)
+ open_gnome3 "${mailto}"
+ ;;
+
xfce)
open_xfce "${mailto}"
;;
diff --git a/scripts/xdg-file-dialog.in b/scripts/xdg-file-dialog.in
index 2a589d1..14fc102 100644
--- a/scripts/xdg-file-dialog.in
+++ b/scripts/xdg-file-dialog.in
@@ -312,7 +312,7 @@ if [ "$action" = "openfilename" ]; then
open_kde "$filename"
;;
- gnome|xfce|lxde)
+ gnome*|xfce|lxde)
open_zenity "$filename"
;;
@@ -326,7 +326,7 @@ elif [ "$action" = "openfilenamelist" ]; then
open_multi_kde "$filename"
;;
- gnome|xfce|lxde)
+ gnome*|xfce|lxde)
open_multi_zenity "$filename"
;;
@@ -340,7 +340,7 @@ elif [ "$action" = "savefilename" ]; then
save_kde "$filename"
;;
- gnome|xfce|lxde)
+ gnome*|xfce|lxde)
save_zenity "$filename"
;;
@@ -354,7 +354,7 @@ elif [ "$action" = "directory" ]; then
directory_kde "$filename"
;;
- gnome|xfce|lxde)
+ gnome*|xfce|lxde)
directory_zenity "$filename"
;;
diff --git a/scripts/xdg-mime.in b/scripts/xdg-mime.in
index bd65170..17d8581 100644
--- a/scripts/xdg-mime.in
+++ b/scripts/xdg-mime.in
@@ -422,7 +422,7 @@ if [ "$action" = "info" ]; then
info_kde "$filename"
;;
- gnome)
+ gnome*)
info_gnome "$filename"
;;
diff --git a/scripts/xdg-open.in b/scripts/xdg-open.in
index bc756d0..d48afb2 100644
--- a/scripts/xdg-open.in
+++ b/scripts/xdg-open.in
@@ -235,7 +235,7 @@ case "$DE" in
open_kde "$url"
;;
- gnome)
+ gnome*)
open_gnome "$url"
;;
diff --git a/scripts/xdg-settings.in b/scripts/xdg-settings.in
index fb621a9..d4d0da0 100644
--- a/scripts/xdg-settings.in
+++ b/scripts/xdg-settings.in
@@ -107,21 +107,26 @@ desktop_file_to_binary()
# This function is hard-coded for text/html but it could be adapted if needed.
fix_local_desktop_file()
{
+ if test -z "$2" ; then
+ MIME="text/html"
+ else
+ MIME="$2"
+ fi
apps="${XDG_DATA_HOME:-$HOME/.local/share}/applications"
# No local desktop file?
[ ! -f "$apps/$1" ] && return
- MIME="`grep "^MimeType=" "$apps/$1" | cut -d= -f 2-`"
- case "$MIME" in
- text/html\;*|*\;text/html\;*|*\;text/html\;|*\;text/html)
- # Already has text/html? Great!
+ MIMETYPES="`grep "^MimeType=" "$apps/$1" | cut -d= -f 2-`"
+ case "$MIMETYPES" in
+ $MIME\;*|*\;$MIME\;*|*\;$MIME\;|*\;$MIME)
+ # Already has the mime-type? Great!
return 0
;;
esac
- # Add text/html to the list
+ # Add the mime-type to the list
temp="`mktemp "$apps/$1.XXXXXX"`" || return
grep -v "^MimeType=" "$apps/$1" >> "$temp"
- echo "MimeType=text/html;$MIME" >> "$temp"
+ echo "MimeType=$MIME;$MIMETYPES" >> "$temp"
oldlines="`wc -l < "$apps/$1"`"
newlines="`wc -l < "$temp"`"
@@ -155,22 +160,32 @@ xdg_mime_fixup()
get_browser_mime()
{
+ if test -z "$1" ; then
+ MIME="text/html"
+ else
+ MIME="$1"
+ fi
xdg_mime_fixup
- xdg-mime query default text/html
+ xdg-mime query default "$MIME"
}
set_browser_mime()
{
xdg_mime_fixup
- orig="`get_browser_mime`"
+ if test -z "$2" ; then
+ MIME="text/html"
+ else
+ MIME="$2"
+ fi
+ orig="`get_browser_mime $MIME`"
# Fixing the local desktop file can actually change the default browser all
# by itself, so we fix it only after querying to find the current default.
- fix_local_desktop_file "$1" || return
+ fix_local_desktop_file "$1" "$MIME" || return
mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/applications"
- xdg-mime default "$1" text/html || return
+ xdg-mime default "$1" "$MIME" || return
if [ x"`get_browser_mime`" != x"$1" ]; then
# Put back the original value
- xdg-mime default "$orig" text/html
+ xdg-mime default "$orig" "$MIME"
exit_failure_operation_failed
fi
}
@@ -340,6 +355,45 @@ set_browser_gnome()
}
# }}} GNOME
+# {{{ GNOME 3.x
+
+get_browser_gnome3()
+{
+ get_browser_mime "x-scheme-handler/http"
+}
+
+check_browser_gnome3()
+{
+ desktop="$1"
+ check="`desktop_file_to_binary "$1"`"
+ if [ -z "$check" ]; then
+ echo no
+ exit_success
+ fi
+ # Check HTTP and HTTPS, but not about: and unknown:.
+ for protocol in http https; do
+ browser="`get_browser_mime "x-scheme-handler/$protocol"`"
+ if [ x"$browser" != x"$desktop" ]; then
+ echo no
+ exit_success
+ fi
+ done
+ echo yes
+ exit_success
+}
+
+set_browser_gnome3()
+{
+ binary="`desktop_file_to_binary "$1"`"
+ [ "$binary" ] || exit_failure_file_missing
+ set_browser_mime "$1" || return
+
+ # Set the default browser.
+ for protocol in http https about unknown; do
+ set_browser_mime "$1" "x-scheme-handler/$protocol" || return
+ done
+}
+# }}} GNOME 3.x
# {{{ xfce
get_browser_xfce()
@@ -549,7 +603,7 @@ fi
detectDE
case "$DE" in
- kde|gnome|xfce)
+ kde|gnome*|xfce)
dispatch_specific "$@"
;;
diff --git a/scripts/xdg-su.in b/scripts/xdg-su.in
index 0b067ee..5985e8a 100644
--- a/scripts/xdg-su.in
+++ b/scripts/xdg-su.in
@@ -146,7 +146,7 @@ case "$DE" in
su_kde
;;
- gnome|lxde)
+ gnome*|lxde)
su_gnome
;;
diff --git a/scripts/xdg-terminal.in b/scripts/xdg-terminal.in
index dbaf435..a4f2acf 100644
--- a/scripts/xdg-terminal.in
+++ b/scripts/xdg-terminal.in
@@ -166,7 +166,7 @@ case "$DE" in
terminal_kde "$command"
;;
- gnome)
+ gnome*)
terminal_gnome "$command"
;;
diff --git a/scripts/xdg-utils-common.in b/scripts/xdg-utils-common.in
index 304585a..be21161 100644
--- a/scripts/xdg-utils-common.in
+++ b/scripts/xdg-utils-common.in
@@ -200,6 +200,12 @@ detectDE()
elif [ x"$DESKTOP_SESSION" == x"LXDE" ]; then DE=lxde;
else DE=""
fi
+
+ if [ "x$DE" = "xgnome" ]; then
+ # gnome-default-applications-properties is only available in GNOME 2.x
+ # but not in GNOME 3.x
+ which gnome-default-applications-properties 2> /dev/null || DE="gnome3"
+ fi
}
#----------------------------------------------------------------------------