[Xfce4-commits] <exo:master> Squashed commit of the following:
Nick Schermer
nick at xfce.org
Sat Aug 29 21:50:01 CEST 2009
Updating branch refs/heads/master
to ce3c2d6606f856b4f0bebad286e0825d1622fc7f (commit)
from 6764461a5357e2901430ebe4e01c2f43acb3fe16 (commit)
commit ce3c2d6606f856b4f0bebad286e0825d1622fc7f
Author: Nick Schermer <nick at xfce.org>
Date: Sat Aug 29 21:46:34 2009 +0200
Squashed commit of the following:
commit c89f6932db63a37827ef5c05e06002d2eeb151ad
Author: Nick Schermer <nick at xfce.org>
Date: Thu Aug 27 20:17:00 2009 +0200
Strip the mailto: part from an uri since we work with mailto:%s in the desktop files.
commit 8d82d52e199b8dfc8ef99763d203daaa6c4ed688
Author: Nick Schermer <nick at xfce.org>
Date: Wed Aug 26 22:46:47 2009 +0200
Fix distcheck with external gio module.
commit a8c711840c69e434ea7b436cc9c84444328faadd
Author: Nick Schermer <nick at xfce.org>
Date: Wed Aug 26 22:34:04 2009 +0200
Update POTFILES.in.
commit 3167524eae1b5dfacb3c4c6dc7adfe53f5f0b2e4
Author: Nick Schermer <nick at xfce.org>
Date: Wed Aug 26 19:11:31 2009 +0200
Use -compose for thunderbird (bug #4496).
commit d72abb5d58b217a60fde7755f1102f1658747d39
Author: Nick Schermer <nick at xfce.org>
Date: Wed Aug 26 18:44:35 2009 +0200
Add gopher to the known browser URI schemes (bug #4497).
commit 41b0c2a5d33f51195f0a01d9154b099f0a9cdc61
Author: Nick Schermer <nick at xfce.org>
Date: Wed Aug 26 18:42:01 2009 +0200
Update docs.
commit d28a218994ae1b7ca3553a864a1ab28312141ab2
Author: Nick Schermer <nick at xfce.org>
Date: Wed Aug 26 18:38:26 2009 +0200
Update python bindings.
commit e09d4bcc06dcd32a135b98b2ddca98e5d2e4e079
Author: Nick Schermer <nick at xfce.org>
Date: Wed Aug 26 18:37:03 2009 +0200
Remove exo-url functions and move dialog hook to gtk extensions.
commit c07a72487229b8ab3b75326dd1a29211b9455914
Author: Nick Schermer <nick at xfce.org>
Date: Wed Aug 26 18:09:09 2009 +0200
Add FileManager support to exo-open and known URI completion.
Move some code from exo-url to exo-open to complete non-uris
when passing for example some filenames to exo-open.
commit a16361e2f7684ac84d9e80008969e3a7db5a5838
Author: Nick Schermer <nick at xfce.org>
Date: Wed Aug 26 18:08:10 2009 +0200
Iterate the mainloop so the dialog is fully destroyed before executing.
commit 4a3b8878bde0e18faae459e1a530bbd0f6c24aee
Author: Nick Schermer <nick at xfce.org>
Date: Wed Aug 26 18:05:16 2009 +0200
Add FileManager support to exo-helper (bug #4445).
Slightly modified patch provided by Christian Dywan.
commit 48e3c3f52d41cc4da1b5d85d93990e205f5b13a1
Author: Nick Schermer <nick at xfce.org>
Date: Wed Aug 26 18:02:02 2009 +0200
Add a GIO module to handle known exo helper URIs.
Makefile.am | 4 +-
configure.in.in | 24 +-
docs/reference/exo-docs.sgml | 2 -
docs/reference/exo-sections.txt | 11 +-
docs/reference/tmpl/exo-execute.sgml | 7 +-
docs/reference/tmpl/exo-gtk-extensions.sgml | 8 +
docs/reference/tmpl/exo-url.sgml | 76 ----
exo-gio-module/Makefile.am | 47 +++
exo-gio-module/exo-module.c | 181 +++++++++
exo-helper/exo-helper-chooser-dialog.c | 34 ++-
exo-helper/exo-helper-chooser.c | 6 +-
exo-helper/exo-helper-launcher-dialog.c | 2 +
exo-helper/exo-helper.c | 31 +-
exo-helper/exo-helper.h | 1 +
exo-helper/helpers/Makefile.am | 3 +
.../{midori.desktop.in.in => Thunar.desktop.in.in} | 8 +-
exo-helper/helpers/exo-compose-mail-1 | 2 +-
...midori.desktop.in.in => nautilus.desktop.in.in} | 8 +-
...{midori.desktop.in.in => pcmanfm.desktop.in.in} | 8 +-
exo-helper/main.c | 11 +-
exo-open/main.c | 110 +++++-
exo/Makefile.am | 2 -
exo/exo-execute.c | 2 +-
exo/exo-gtk-extensions.c | 89 +++++
exo/exo-gtk-extensions.h | 4 +
exo/exo-url.c | 408 --------------------
exo/exo-url.h | 62 ---
exo/exo.h | 1 -
exo/exo.symbols | 10 +-
po/POTFILES.in | 9 +-
python/exo.defs | 25 --
python/exo.override | 70 ----
python/exomodule.c | 8 +-
33 files changed, 554 insertions(+), 720 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index dc1b9f0..9500c77 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -13,6 +13,7 @@ SUBDIRS = \
exo-csource \
exo-support \
exo-desktop-item-edit \
+ exo-gio-module \
exo-hal \
exo-helper \
exo-mount \
@@ -62,6 +63,7 @@ DISTCLEANFILES = \
DISTCHECK_CONFIGURE_FLAGS = \
--enable-gtk-doc \
--enable-xml2po \
- --enable-xsltproc
+ --enable-xsltproc \
+ --with-gio-module-dir=distcheck
# vi:set ts=8 sw=8 noet ai nocindent:
diff --git a/configure.in.in b/configure.in.in
index 11545d9..0eab2fb 100644
--- a/configure.in.in
+++ b/configure.in.in
@@ -157,10 +157,28 @@ dnl *** Check for required packages ***
dnl ***********************************
XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.16.0])
XDT_CHECK_PACKAGE([GIO], [gio-2.0], [2.16.0])
+XDT_CHECK_PACKAGE([GIO_UNIX], [gio-unix-2.0], [2.16.0])
XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.14.0])
XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.16.0])
XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.2.2])
+dnl ****************************
+dnl *** GIO modules location ***
+dnl ****************************
+AC_ARG_WITH([gio-module-dir],
+ [AC_HELP_STRING([--with-gio-module-dir=PATH],
+ [Specify where to install the exo gio module (default=autodetect)])],
+ [gio_module_dir="$withval"])
+if test x"$gio_module_dir" = x""; then
+ GIOMODULEDIR="`$PKG_CONFIG gio-2.0 --variable giomoduledir`"
+elif test x"$gio_module_dir" = x"distcheck"; then
+ GIOMODULEDIR=""
+else
+ GIOMODULEDIR="$gio_module_dir"
+fi
+AC_SUBST([GIOMODULEDIR])
+AM_CONDITIONAL([HAVE_GIO_MODULEDIR], [test x"$GIOMODULEDIR" != x""])
+
dnl **************************************
dnl *** Check for libnotify (optional) ***
dnl **************************************
@@ -247,7 +265,7 @@ if test x"$enable_python" != x"no"; then
if test x"$enable_python" = x"yes"; then
AC_MSG_ERROR([Building python explicitly requested, but cannot build python bindings])
else
- AC_MSG_WARN([Couldn't find either PyGTK or the Python headers, not building Python bindings])
+ AC_MSG_WARN([Could not find either PyGTK or the Python headers, not building Python bindings])
fi
fi
fi
@@ -358,7 +376,7 @@ esac
dnl ****************************************
dnl *** Check for ELF visibility support ***
dnl ****************************************
-AC_ARG_ENABLE([visibility], AC_HELP_STRING([--disable-visibility], [Don't use ELF visibility attributes]), [], [enable_visibility=yes])
+AC_ARG_ENABLE([visibility], AC_HELP_STRING([--disable-visibility], [Do not use ELF visibility attributes]), [], [enable_visibility=yes])
have_gnuc_visibility=no
if test x"$enable_visibility" != x"no"; then
dnl Check whether the compiler supports the visibility attribute
@@ -427,6 +445,7 @@ exo/exo-1.pc
exo/exo-config.h
exo-csource/Makefile
exo-desktop-item-edit/Makefile
+exo-gio-module/Makefile
exo-hal/Makefile
exo-hal/exo-hal-1.pc
exo-helper/Makefile
@@ -458,6 +477,7 @@ echo "* HAL support: yes"
else
echo "* HAL support: no"
fi
+echo "* GIO Module Dir: $GIOMODULEDIR"
echo "* Debug Support: $enable_debug"
echo "* Python Support: $have_python"
echo
diff --git a/docs/reference/exo-docs.sgml b/docs/reference/exo-docs.sgml
index 144d735..1483285 100644
--- a/docs/reference/exo-docs.sgml
+++ b/docs/reference/exo-docs.sgml
@@ -22,7 +22,6 @@
<!ENTITY exo-execute SYSTEM "xml/exo-execute.xml">
<!ENTITY exo-mount-point SYSTEM "xml/exo-mount-point.xml">
<!ENTITY exo-string SYSTEM "xml/exo-string.xml">
-<!ENTITY exo-url SYSTEM "xml/exo-url.xml">
<!ENTITY exo-utils SYSTEM "xml/exo-utils.xml">
<!ENTITY exo-hal SYSTEM "xml/exo-hal.xml">
<!ENTITY exo-xsession-client SYSTEM "xml/exo-xsession-client.xml">
@@ -301,7 +300,6 @@
&exo-execute;
&exo-mount-point;
&exo-string;
- &exo-url;
&exo-utils;
&exo-hal;
&exo-xsession-client;
diff --git a/docs/reference/exo-sections.txt b/docs/reference/exo-sections.txt
index 4624b34..95f96d2 100644
--- a/docs/reference/exo-sections.txt
+++ b/docs/reference/exo-sections.txt
@@ -391,6 +391,7 @@ exo_g_value_transform_negate
<TITLE>Extensions to Gtk</TITLE>
exo_gtk_object_destroy_later
exo_gtk_file_chooser_add_thumbnail_preview
+exo_gtk_url_about_dialog_hook
</SECTION>
<SECTION>
@@ -458,16 +459,6 @@ I_
</SECTION>
<SECTION>
-<FILE>exo-url</FILE>
-<TITLE>Opening URLs</TITLE>
-ExoUrlError
-EXO_URL_ERROR
-exo_url_show
-exo_url_show_on_screen
-exo_url_about_dialog_hook
-</SECTION>
-
-<SECTION>
<FILE>exo-utils</FILE>
<TITLE>Miscellaneous Utility Functions</TITLE>
exo_noop
diff --git a/docs/reference/tmpl/exo-execute.sgml b/docs/reference/tmpl/exo-execute.sgml
index 41c01d6..07bc030 100644
--- a/docs/reference/tmpl/exo-execute.sgml
+++ b/docs/reference/tmpl/exo-execute.sgml
@@ -15,10 +15,9 @@ Execute preferred applications
</para>
<para>
On the other hand if you need to display an URL (i.e. you want to point
- the user to the website of your application), you should use exo_url_show()
- or exo_url_show_on_screen() from the <link
- linkend="exo-Opening-URLs">exo-url</link> module instead, as they will
- try to automatically determine the appropriate viewer for a given URL.
+ the user to the website of your application), you should use gtk_show_uri()
+ instead, as it will try to automatically determine the appropriate
+ viewer for a given URI.
</para>
<!-- ##### SECTION See_Also ##### -->
diff --git a/docs/reference/tmpl/exo-gtk-extensions.sgml b/docs/reference/tmpl/exo-gtk-extensions.sgml
index efe8e54..8ac7b30 100644
--- a/docs/reference/tmpl/exo-gtk-extensions.sgml
+++ b/docs/reference/tmpl/exo-gtk-extensions.sgml
@@ -39,3 +39,11 @@ Stable
@chooser:
+<!-- ##### FUNCTION exo_gtk_url_about_dialog_hook ##### -->
+<para>
+
+</para>
+
+ at about_dialog:
+ at link:
+ at user_data:
diff --git a/docs/reference/tmpl/exo-url.sgml b/docs/reference/tmpl/exo-url.sgml
deleted file mode 100644
index 02f91c0..0000000
--- a/docs/reference/tmpl/exo-url.sgml
+++ /dev/null
@@ -1,76 +0,0 @@
-<!-- ##### SECTION Title ##### -->
-Opening URLs
-
-<!-- ##### SECTION Short_Description ##### -->
-Display URLs using appropriate viewers
-
-<!-- ##### SECTION Long_Description ##### -->
-<para>
- Xfce users can configure which applications they wish to use for certain task,
- for example they can select their preferred web browser and mail reader from
- the <guilabel>Preferred Applications</guilabel> dialog. This module provides a
- means for applications to display an URL without having to worry about which
- viewer is going to ultimately handle the job.
-</para>
-<para>
- One of the most popular use cases for this module is to provide the ability to
- open links from a <link linkend="GtkAboutDialog">GtkAboutDialog</link>. Therefore
- a convenience hook is provided for this use case, see the documentation of
- exo_url_about_dialog_hook() for details.
-</para>
-
-<!-- ##### SECTION See_Also ##### -->
-<para>
- <link linkend="exo-Executing-Applications">Executing Applications</link>
-</para>
-
-<!-- ##### SECTION Stability_Level ##### -->
-Stable
-
-<!-- ##### ENUM ExoUrlError ##### -->
-<para>
-
-</para>
-
- at EXO_URL_ERROR_NOT_SUPPORTED:
-
-<!-- ##### MACRO EXO_URL_ERROR ##### -->
-<para>
- The domain of errors raised by this module.
-</para>
-
-
-
-<!-- ##### FUNCTION exo_url_show ##### -->
-<para>
-
-</para>
-
- at url:
- at envp:
- at error:
- at Returns:
-
-
-<!-- ##### FUNCTION exo_url_show_on_screen ##### -->
-<para>
-
-</para>
-
- at url:
- at envp:
- at screen:
- at error:
- at Returns:
-
-
-<!-- ##### FUNCTION exo_url_about_dialog_hook ##### -->
-<para>
-
-</para>
-
- at about_dialog:
- at link:
- at user_data:
-
-
diff --git a/exo-gio-module/Makefile.am b/exo-gio-module/Makefile.am
new file mode 100644
index 0000000..2101fc6
--- /dev/null
+++ b/exo-gio-module/Makefile.am
@@ -0,0 +1,47 @@
+# $Id$
+
+INCLUDES = \
+ -I$(top_srcdir) \
+ -DG_LOG_DOMAIN=\"exo-gio-module\" \
+ -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
+ -DLIBEXECDIR=\"$(libexecdir)\" \
+ -DLIBEXO_VERSION_API=\"$(LIBEXO_VERSION_API)\"
+
+if HAVE_GIO_MODULEDIR
+exomoduledir = \
+ $(GIOMODULEDIR)
+else
+exomoduledir = \
+ $(libdir)/gio/modules
+endif
+
+exomodule_LTLIBRARIES = \
+ libexo-module-1.la
+
+libexo_module_1_la_SOURCES = \
+ exo-module.c
+
+libexo_module_1_la_CFLAGS = \
+ $(GIO_CFLAGS) \
+ $(GIO_UNIX_CFLAGS) \
+ $(GTK_CFLAGS) \
+ $(LIBXFCE4UTIL_CFLAGS)
+
+libexo_module_1_la_LDFLAGS = \
+ -export_dynamic \
+ -avoid-version \
+ -module \
+ -no-undefined \
+ -export-symbols-regex '^g_io_module_(load|unload)'
+
+libexo_module_1_la_DEPENDENCIES = \
+ $(top_builddir)/exo/libexo-$(LIBEXO_VERSION_API).la
+
+libexo_module_1_la_LIBADD = \
+ $(GIO_LIBS) \
+ $(GIO_UNIX_LIBS) \
+ $(GTK_LIBS) \
+ $(LIBXFCE4UTIL_LIBS) \
+ $(top_builddir)/exo/libexo-$(LIBEXO_VERSION_API).la
+
+# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
diff --git a/exo-gio-module/exo-module.c b/exo-gio-module/exo-module.c
new file mode 100644
index 0000000..94866e4
--- /dev/null
+++ b/exo-gio-module/exo-module.c
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2009 Nick Schermer <nick at xfce.org>.
+ *
+ * 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 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <exo/exo.h>
+#include <gio/gio.h>
+#include <gio/gdesktopappinfo.h>
+
+#define EXO_HELPER_LAUNCH LIBEXECDIR "/exo-helper-" LIBEXO_VERSION_API " --launch "
+
+
+
+
+#define EXO_TYPE_GIO_MODULE (exo_gio_module_get_type ())
+#define EXO_GIO_MODULE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_GIO_MODULE, ExoGioModule))
+#define EXO_GIO_MODULE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), G_TYPE_GIO_MODULE, ExoGioModuleClass))
+#define EXO_IS_GIO_MODULE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_GIO_MODULE))
+#define EXO_IS_GIO_MODULE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_GIO_MODULE))
+
+
+
+GType exo_gio_module_get_type (void);
+static void exo_gio_module_app_info_lookup_iface_init (GDesktopAppInfoLookupIface *iface);
+static GAppInfo *exo_gio_module_get_default_for_uri_scheme (GDesktopAppInfoLookup *lookup,
+ const gchar *uri_scheme);
+
+
+
+
+typedef struct _ExoGioModuleClass ExoGioModuleClass;
+typedef struct _ExoGioModule ExoGioModule;
+typedef struct _KnownSchemes KnownSchemes;
+
+struct _ExoGioModuleClass
+{
+ GObjectClass __parent__;
+};
+
+struct _ExoGioModule
+{
+ GObject __parent__;
+};
+
+struct _KnownSchemes
+{
+ const gchar *pattern;
+ const gchar *category;
+};
+
+static KnownSchemes known_schemes[] =
+{
+ { "^(https?|ftps|gopher)$", "WebBrowser" },
+ { "^mailto$", "MailReader" },
+ { "^(file|trash)$", "FileManager" }
+};
+
+
+
+#define _G_IMPLEMENT_INTERFACE_DYNAMIC(TYPE_IFACE, iface_init) \
+{ \
+ const GInterfaceInfo g_implement_interface_info = { \
+ (GInterfaceInitFunc) iface_init, NULL, NULL \
+ }; \
+ g_type_module_add_interface (type_module, g_define_type_id, \
+ TYPE_IFACE, &g_implement_interface_info); \
+}
+
+
+
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (ExoGioModule, exo_gio_module, G_TYPE_OBJECT, 0,
+ _G_IMPLEMENT_INTERFACE_DYNAMIC (G_TYPE_DESKTOP_APP_INFO_LOOKUP,
+ exo_gio_module_app_info_lookup_iface_init))
+
+
+
+static void
+exo_gio_module_class_init (ExoGioModuleClass *klass)
+{
+}
+
+
+
+static void
+exo_gio_module_init (ExoGioModule *module)
+{
+}
+
+
+
+static void
+exo_gio_module_class_finalize (ExoGioModuleClass *klass)
+{
+}
+
+
+
+static void
+exo_gio_module_app_info_lookup_iface_init (GDesktopAppInfoLookupIface *iface)
+{
+ iface->get_default_for_uri_scheme = exo_gio_module_get_default_for_uri_scheme;
+}
+
+
+
+static GAppInfo *
+exo_gio_module_get_default_for_uri_scheme (GDesktopAppInfoLookup *lookup,
+ const gchar *uri_scheme)
+{
+ GAppInfo *info = NULL;
+ GError *error = NULL;
+ gchar *command;
+ gboolean found;
+ guint i;
+
+ /* do nothing when there is no scheme defined */
+ if (G_UNLIKELY (uri_scheme == NULL))
+ return NULL;
+
+ for (i = 0, found = FALSE; !found && i < G_N_ELEMENTS (known_schemes); i++)
+ {
+ /* see if the scheme matches */
+ found = g_regex_match_simple (known_schemes[i].pattern, uri_scheme, G_REGEX_CASELESS, 0);
+ if (found)
+ {
+ /* use the exo-helper directly here to avoid possible roundtrips with exo-open */
+ command = g_strconcat (EXO_HELPER_LAUNCH, known_schemes[i].category, NULL);
+ info = g_app_info_create_from_commandline (command, NULL, G_APP_INFO_CREATE_SUPPORTS_URIS, &error);
+ if (G_UNLIKELY (info == NULL))
+ {
+ /* show error */
+ g_critical ("Failed to create GAppInfo from \"%s\" for URI-scheme \"%s\": %s.",
+ command, uri_scheme, error->message);
+ g_error_free (error);
+ }
+
+ /* cleanup */
+ g_free (command);
+ }
+ }
+
+ /* print debug message if scheme is not recognized by exo */
+ if (!found)
+ g_debug ("Unknown URI-scheme \"%s\".", uri_scheme);
+
+ return info;
+}
+
+
+
+G_MODULE_EXPORT void
+g_io_module_load (GIOModule *module)
+{
+ exo_gio_module_register_type (G_TYPE_MODULE (module));
+ g_io_extension_point_implement (G_DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME,
+ EXO_TYPE_GIO_MODULE, "ExoGioModule", 10);
+}
+
+
+
+G_MODULE_EXPORT void
+g_io_module_unload (GIOModule *module)
+{
+}
diff --git a/exo-helper/exo-helper-chooser-dialog.c b/exo-helper/exo-helper-chooser-dialog.c
index 149efa7..b5bd0e2 100644
--- a/exo-helper/exo-helper-chooser-dialog.c
+++ b/exo-helper/exo-helper-chooser-dialog.c
@@ -95,7 +95,7 @@ exo_helper_chooser_dialog_init (ExoHelperChooserDialog *chooser_dialog)
GtkWidget *box;
/* verify category settings */
- g_assert (EXO_HELPER_N_CATEGORIES == 3);
+ g_assert (EXO_HELPER_N_CATEGORIES == 4);
gtk_dialog_add_button (GTK_DIALOG (chooser_dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
gtk_dialog_set_has_separator (GTK_DIALOG (chooser_dialog), FALSE);
@@ -210,6 +210,38 @@ exo_helper_chooser_dialog_init (ExoHelperChooserDialog *chooser_dialog)
gtk_widget_show (vbox);
/*
+ File Manager
+ */
+ frame = g_object_new (GTK_TYPE_FRAME, "border-width", 0, "shadow-type", GTK_SHADOW_NONE, NULL);
+ gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
+ gtk_widget_show (frame);
+
+ label = g_object_new (GTK_TYPE_LABEL, "attributes", attr_list_bold, "label", _("File Manager"), NULL);
+ gtk_frame_set_label_widget (GTK_FRAME (frame), label);
+ gtk_widget_show (label);
+
+ box = g_object_new (GTK_TYPE_VBOX, "border-width", 12, "spacing", 12, NULL);
+ gtk_container_add (GTK_CONTAINER (frame), box);
+ gtk_widget_show (box);
+
+ label = gtk_label_new (_("The preferred File Manager will be used to\n"
+ "browse the contents of folders."));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0f, 0.0f);
+ gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
+ gtk_widget_show (label);
+
+ chooser = exo_helper_chooser_new (EXO_HELPER_FILEMANAGER);
+ gtk_box_pack_start (GTK_BOX (box), chooser, FALSE, FALSE, 0);
+ gtk_widget_show (chooser);
+
+ /* set Atk label relation for the chooser */
+ object = gtk_widget_get_accessible (chooser);
+ relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label));
+ relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR);
+ atk_relation_set_add (relations, relation);
+ g_object_unref (G_OBJECT (relation));
+
+ /*
Terminal Emulator
*/
frame = g_object_new (GTK_TYPE_FRAME, "border-width", 0, "shadow-type", GTK_SHADOW_NONE, NULL);
diff --git a/exo-helper/exo-helper-chooser.c b/exo-helper/exo-helper-chooser.c
index 6307756..501f6c5 100644
--- a/exo-helper/exo-helper-chooser.c
+++ b/exo-helper/exo-helper-chooser.c
@@ -315,6 +315,7 @@ menu_activate (GtkWidget *item,
{
N_("Failed to set default Web Browser"),
N_("Failed to set default Mail Reader"),
+ N_("Failed to set default File Manager"),
N_("Failed to set default Terminal Emulator"),
};
@@ -500,6 +501,7 @@ menu_activate_other (GtkWidget *item,
{
N_("Choose a custom Web Browser"),
N_("Choose a custom Mail Reader"),
+ N_("Choose a custom File Manager"),
N_("Choose a custom Terminal Emulator"),
};
@@ -507,6 +509,7 @@ menu_activate_other (GtkWidget *item,
{
N_("Specify the application you want to use\nas default Web Browser for Xfce:"),
N_("Specify the application you want to use\nas default Mail Reader for Xfce:"),
+ N_("Specify the application you want to use\nas default File Manager for Xfce:"),
N_("Specify the application you want to use\nas default Terminal Emulator for Xfce:"),
};
@@ -522,7 +525,8 @@ menu_activate_other (GtkWidget *item,
GtkWidget *button;
/* sanity check the category values */
- g_assert (EXO_HELPER_N_CATEGORIES == 3);
+ g_assert (EXO_HELPER_N_CATEGORIES == G_N_ELEMENTS (BROWSE_TITLES));
+ g_assert (EXO_HELPER_N_CATEGORIES == G_N_ELEMENTS (BROWSE_MESSAGES));
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (chooser));
diff --git a/exo-helper/exo-helper-launcher-dialog.c b/exo-helper/exo-helper-launcher-dialog.c
index 480941b..df3cef4 100644
--- a/exo-helper/exo-helper-launcher-dialog.c
+++ b/exo-helper/exo-helper-launcher-dialog.c
@@ -258,6 +258,8 @@ exo_helper_launcher_dialog_set_category (ExoHelperLauncherDialog *launcher_dialo
"Browser now and click OK to proceed."),
N_("Please choose your preferred Mail Reader\n"
"now and click OK to proceed."),
+ N_("Please choose your preferred File Manager\n"
+ "now and click OK to proceed."),
N_("Please choose your preferred Terminal\n"
"Emulator now and click OK to proceed."),
};
diff --git a/exo-helper/exo-helper.c b/exo-helper/exo-helper.c
index 28ff320..9a06daa 100644
--- a/exo-helper/exo-helper.c
+++ b/exo-helper/exo-helper.c
@@ -347,17 +347,18 @@ exo_helper_execute (ExoHelper *helper,
const gchar *parameter,
GError **error)
{
- GTimeVal previous;
- GTimeVal current;
- gboolean succeed = FALSE;
- GError *err = NULL;
- gchar **commands;
- gchar **argv;
- gchar *command;
- guint n;
- gint status;
- gint result;
- gint pid;
+ GTimeVal previous;
+ GTimeVal current;
+ gboolean succeed = FALSE;
+ GError *err = NULL;
+ gchar **commands;
+ gchar **argv;
+ gchar *command;
+ guint n;
+ gint status;
+ gint result;
+ gint pid;
+ const gchar *real_parameter = parameter;
// FIXME: startup-notification
@@ -369,8 +370,12 @@ exo_helper_execute (ExoHelper *helper,
if (G_UNLIKELY (screen == NULL))
screen = gdk_screen_get_default ();
+ /* strip the mailto part if needed */
+ if (real_parameter != NULL && g_str_has_prefix (real_parameter, "mailto:"))
+ real_parameter = parameter + 7;
+
/* determine the command set to use */
- commands = (parameter != NULL) ? helper->commands_with_parameter : helper->commands;
+ commands = !exo_str_is_empty (real_parameter) ? helper->commands_with_parameter : helper->commands;
/* verify that we have atleast one command */
if (G_UNLIKELY (*commands == NULL))
@@ -386,7 +391,7 @@ exo_helper_execute (ExoHelper *helper,
g_clear_error (&err);
/* parse the command */
- command = (parameter != NULL) ? exo_str_replace (commands[n], "%s", parameter) : g_strdup (commands[n]);
+ command = !exo_str_is_empty (real_parameter) ? exo_str_replace (commands[n], "%s", real_parameter) : g_strdup (commands[n]);
succeed = g_shell_parse_argv (command, NULL, &argv, &err);
g_free (command);
diff --git a/exo-helper/exo-helper.h b/exo-helper/exo-helper.h
index 5b9da53..dbef46b 100644
--- a/exo-helper/exo-helper.h
+++ b/exo-helper/exo-helper.h
@@ -28,6 +28,7 @@ typedef enum /*< enum,prefix=EXO_HELPER >*/
{
EXO_HELPER_WEBBROWSER, /*< nick=WebBrowser >*/
EXO_HELPER_MAILREADER, /*< nick=MailReader >*/
+ EXO_HELPER_FILEMANAGER, /*< nick=FileManager >*/
EXO_HELPER_TERMINALEMULATOR, /*< nick=TerminalEmulator >*/
EXO_HELPER_N_CATEGORIES, /*< skip >*/
} ExoHelperCategory;
diff --git a/exo-helper/helpers/Makefile.am b/exo-helper/helpers/Makefile.am
index f194b48..839ef68 100644
--- a/exo-helper/helpers/Makefile.am
+++ b/exo-helper/helpers/Makefile.am
@@ -6,6 +6,7 @@ defaults_DATA = helpers.rc
desktopdir = $(datadir)/xfce4/helpers
desktop_in_in_files = \
Terminal.desktop.in.in \
+ Thunar.desktop.in.in \
aterm.desktop.in.in \
balsa.desktop.in.in \
debian-sensible-browser.desktop.in.in \
@@ -25,10 +26,12 @@ desktop_in_in_files = \
mozilla-browser.desktop.in.in \
mozilla-mailer.desktop.in.in \
mutt.desktop.in.in \
+ nautilus.desktop.in.in \
netscape-navigator.desktop.in.in \
nxterm.desktop.in.in \
opera-browser.desktop.in.in \
opera-mailer.desktop.in.in \
+ pcmanfm.desktop.in.in \
sylpheed.desktop.in.in \
sylpheed-claws.desktop.in.in \
thunderbird.desktop.in.in \
diff --git a/exo-helper/helpers/midori.desktop.in.in b/exo-helper/helpers/Thunar.desktop.in.in
similarity index 64%
copy from exo-helper/helpers/midori.desktop.in.in
copy to exo-helper/helpers/Thunar.desktop.in.in
index 0c26940..07971e3 100644
--- a/exo-helper/helpers/midori.desktop.in.in
+++ b/exo-helper/helpers/Thunar.desktop.in.in
@@ -2,11 +2,11 @@
[Desktop Entry]
Encoding=UTF-8
Version=1.0
-Icon=midori
+Icon=Thunar
Type=X-XFCE-Helper
-_Name=Midori
+_Name=Thunar
StartupNotify=true
-X-XFCE-Binaries=midori;
-X-XFCE-Category=WebBrowser
+X-XFCE-Binaries=Thunar;
+X-XFCE-Category=FileManager
X-XFCE-Commands=%B;
X-XFCE-CommandsWithParameter=%B "%s";
diff --git a/exo-helper/helpers/exo-compose-mail-1 b/exo-helper/helpers/exo-compose-mail-1
index 8ea65a9..cb41a31 100755
--- a/exo-helper/helpers/exo-compose-mail-1
+++ b/exo-helper/helpers/exo-compose-mail-1
@@ -81,7 +81,7 @@ if ($style eq 'mozilla') {
$body and $command .= ",body='$body'";
# and add the parameters to the argv
- push (@argv, '--compose');
+ push (@argv, '-compose');
push (@argv, $command);
}
elsif ($style eq 'mozilla-remote') {
diff --git a/exo-helper/helpers/midori.desktop.in.in b/exo-helper/helpers/nautilus.desktop.in.in
similarity index 62%
copy from exo-helper/helpers/midori.desktop.in.in
copy to exo-helper/helpers/nautilus.desktop.in.in
index 0c26940..f4c79c6 100644
--- a/exo-helper/helpers/midori.desktop.in.in
+++ b/exo-helper/helpers/nautilus.desktop.in.in
@@ -2,11 +2,11 @@
[Desktop Entry]
Encoding=UTF-8
Version=1.0
-Icon=midori
+Icon=nautilus
Type=X-XFCE-Helper
-_Name=Midori
+_Name=Nautilus
StartupNotify=true
-X-XFCE-Binaries=midori;
-X-XFCE-Category=WebBrowser
+X-XFCE-Binaries=nautilus;
+X-XFCE-Category=FileManager
X-XFCE-Commands=%B;
X-XFCE-CommandsWithParameter=%B "%s";
diff --git a/exo-helper/helpers/midori.desktop.in.in b/exo-helper/helpers/pcmanfm.desktop.in.in
similarity index 60%
copy from exo-helper/helpers/midori.desktop.in.in
copy to exo-helper/helpers/pcmanfm.desktop.in.in
index 0c26940..2c44a8b 100644
--- a/exo-helper/helpers/midori.desktop.in.in
+++ b/exo-helper/helpers/pcmanfm.desktop.in.in
@@ -2,11 +2,11 @@
[Desktop Entry]
Encoding=UTF-8
Version=1.0
-Icon=midori
+Icon=pcmanfm
Type=X-XFCE-Helper
-_Name=Midori
+_Name=PCMan File Manager
StartupNotify=true
-X-XFCE-Binaries=midori;
-X-XFCE-Category=WebBrowser
+X-XFCE-Binaries=pcmanfm;
+X-XFCE-Category=FileManager
X-XFCE-Commands=%B;
X-XFCE-CommandsWithParameter=%B "%s";
diff --git a/exo-helper/main.c b/exo-helper/main.c
index 1a3c992..5cbfaf7 100644
--- a/exo-helper/main.c
+++ b/exo-helper/main.c
@@ -41,6 +41,7 @@ static const gchar *CATEGORY_EXEC_ERRORS[] =
{
N_("Failed to execute default Web Browser"),
N_("Failed to execute default Mail Reader"),
+ N_("Failed to execute default File Manager"),
N_("Failed to execute default Terminal Emulator"),
};
@@ -86,13 +87,15 @@ main (int argc, char **argv)
g_option_context_add_group (opt_ctx, gtk_option_group);
g_option_context_add_main_entries (opt_ctx, option_entries, NULL);
- /* Note to Translators: Do not translate the TYPEs (WebBrowser, MailReader, TerminalEmulator),
- * since the exo-helper utility will not accept localized TYPEs.
+ /* Note to Translators: Do not translate the TYPEs (WebBrowser, MailReader,
+ * FileManager and TerminalEmulator), since the exo-helper utility will
+ * not accept localized TYPEs.
*/
g_option_context_set_description (opt_ctx,
_("The following TYPEs are supported for the --launch command:\n\n"
" WebBrowser - The preferred Web Browser.\n"
" MailReader - The preferred Mail Reader.\n"
+ " FileManager - The preferred File Manager.\n"
" TerminalEmulator - The preferred Terminal Emulator."));
if (!g_option_context_parse (opt_ctx, &argc, &argv, &error))
@@ -165,6 +168,10 @@ main (int argc, char **argv)
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
helper = exo_helper_database_get_default (database, category);
gtk_widget_destroy (dialog);
+
+ /* iterate the mainloop until the dialog is fully destroyed */
+ while (gtk_events_pending ())
+ gtk_main_iteration ();
}
/* release our reference on the database */
diff --git a/exo-open/main.c b/exo-open/main.c
index d93d197..f2585c3 100644
--- a/exo-open/main.c
+++ b/exo-open/main.c
@@ -37,8 +37,13 @@
+#define MATCH_BROWSER "^(([^:/?#]+)://)?([^/?#])([^?#]*)(\\?([^#]*))?(#(.*))?"
+#define MATCH_MAILER "^[a-z0-9][a-z0-9_.-]*@[a-z0-9][a-z0-9-]*(\\.[a-z0-9][a-z0-9-]*)+$"
+
+
+
/**
- * For testing this code the following commands should work:
+ * For testing this code, the following commands should work:
*
* exo-open --launch WebBrowser http://xfce.org (bug #5461).
* exo-open --launch WebBrowser http://xfce.org bugs.xfce.org 'http://www.google.com/search?q=what is a space' 'http://wiki.xfce.org'
@@ -51,10 +56,10 @@
-static gboolean opt_help = FALSE;
-static gboolean opt_version = FALSE;
-static gchar *opt_launch = NULL;
-static gchar *opt_working_directory = NULL;
+static gboolean opt_help = FALSE;
+static gboolean opt_version = FALSE;
+static gchar *opt_launch = NULL;
+static gchar *opt_working_directory = NULL;
static GOptionEntry entries[] =
{
@@ -91,6 +96,7 @@ usage (void)
*/
g_print ("%s\n", _(" WebBrowser - The preferred Web Browser.\n"
" MailReader - The preferred Mail Reader.\n"
+ " FileManager - The preferred File Manager.\n"
" TerminalEmulator - The preferred Terminal Emulator."));
g_print ("\n");
g_print ("%s\n", _("If you don't specify the --launch option, exo-open will open all specified\n"
@@ -103,6 +109,60 @@ usage (void)
+static gboolean
+exo_open_looks_like_an_uri (const gchar *string)
+{
+ const gchar *s = string;
+
+ /* <scheme> starts with an alpha character */
+ if (g_ascii_isalpha (*s))
+ {
+ /* <scheme> continues with (alpha | digit | "+" | "-" | ".")* */
+ for (++s; g_ascii_isalnum (*s) || *s == '+' || *s == '-' || *s == '.'; ++s);
+
+ /* <scheme> must be followed by ":" */
+ return (*s == ':');
+ }
+
+ return FALSE;
+}
+
+
+
+static const gchar *
+exo_open_find_scheme (const gchar *string)
+{
+ gboolean exists;
+ gchar *current_dir, *path;
+
+ /* is an absolute path, return file uri */
+ if (g_path_is_absolute (string))
+ return "file://";
+
+ /* treat it like a relative path */
+ current_dir = g_get_current_dir ();
+ path = g_build_filename (current_dir, string, NULL);
+ g_free (current_dir);
+
+ /* verify that a file of the given name exists */
+ exists = g_file_test (path, G_FILE_TEST_EXISTS);
+ g_free (path);
+ if (exists)
+ return "file://";
+
+ /* regular expression to check if it looks like an email address */
+ if (g_regex_match_simple (MATCH_MAILER, string, G_REGEX_CASELESS, 0))
+ return "mailto:";
+
+ /* regular expression to check if it looks like an url */
+ if (g_regex_match_simple (MATCH_BROWSER, string, G_REGEX_CASELESS, 0))
+ return "http://";
+
+ return NULL;
+}
+
+
+
int
main (int argc, char **argv)
{
@@ -113,6 +173,8 @@ main (int argc, char **argv)
gint result = EXIT_SUCCESS;
GString *join;
guint i;
+ gchar *uri;
+ const gchar *scheme;
#ifdef GETTEXT_PACKAGE
/* setup i18n support */
@@ -212,20 +274,48 @@ main (int argc, char **argv)
else if (argc > 1)
{
/* open all specified urls */
- for (argv += 1; *argv != NULL; ++argv)
+ for (argv += 1; result == EXIT_SUCCESS && *argv != NULL; ++argv)
{
- if (!exo_url_show (*argv, NULL, &err))
+ if (exo_open_looks_like_an_uri (*argv))
+ {
+ /* use the argument directly */
+ uri = g_strdup (*argv);
+ }
+ else
+ {
+ /* try to find a valid scheme */
+ scheme = exo_open_find_scheme (*argv);
+ if (G_LIKELY (scheme != NULL))
+ uri = g_strconcat (scheme, *argv, NULL);
+ else
+ uri = NULL;
+ }
+
+ if (uri == NULL)
{
/* display an error dialog */
dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
- _("Failed to open URL \"%s\"."), *argv);
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s.", err->message);
+ _("Unable to detect the URI-scheme of \"%s\"."), *argv);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
+
result = EXIT_FAILURE;
+ }
+ else if (!gtk_show_uri (NULL, uri, 0, &err))
+ {
+ /* display an error dialog */
+ dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
+ _("Failed to open URI \"%s\"."), uri);
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s.", err->message);
g_error_free (err);
- break;
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ result = EXIT_FAILURE;
}
+
+ /* cleanup */
+ g_free (uri);
}
}
else
diff --git a/exo/Makefile.am b/exo/Makefile.am
index 187788d..a823edb 100644
--- a/exo/Makefile.am
+++ b/exo/Makefile.am
@@ -31,7 +31,6 @@ libexo_headers = \
exo-toolbars-model.h \
exo-toolbars-view.h \
exo-tree-view.h \
- exo-url.h \
exo-utils.h \
exo-wrap-table.h \
exo-xsession-client.h
@@ -89,7 +88,6 @@ libexo_1_la_SOURCES = \
exo-toolbars-private.h \
exo-toolbars-view.c \
exo-tree-view.c \
- exo-url.c \
exo-utils.c \
exo-wrap-table.c \
exo-xsession-client.c
diff --git a/exo/exo-execute.c b/exo/exo-execute.c
index 7a0b85c..7965982 100644
--- a/exo/exo-execute.c
+++ b/exo/exo-execute.c
@@ -106,7 +106,7 @@ exo_execute_preferred_application_on_screen (const gchar *category,
GError **error)
{
gchar *argv[5];
- gint argc = 0;
+ gint argc = 0;
g_return_val_if_fail (category != NULL, FALSE);
g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
diff --git a/exo/exo-gtk-extensions.c b/exo/exo-gtk-extensions.c
index 805fc40..baf7e6b 100644
--- a/exo/exo-gtk-extensions.c
+++ b/exo/exo-gtk-extensions.c
@@ -24,6 +24,10 @@
#include <config.h>
#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
#include <exo/exo-gtk-extensions.h>
#include <exo/exo-private.h>
#include <exo/exo-thumbnail-preview.h>
@@ -131,5 +135,90 @@ exo_gtk_file_chooser_add_thumbnail_preview (GtkFileChooser *chooser)
+/**
+ * exo_gtk_url_about_dialog_hook:
+ * @about_dialog : the #GtkAboutDialog in which the user activated a link.
+ * @link : the link, mail or web address, to open.
+ * @user_data : user data that was passed when the function was
+ * registered with gtk_about_dialog_set_email_hook()
+ * or gtk_about_dialog_set_url_hook(). This is currently
+ * unused within the context of this function, so you
+ * can safely pass %NULL when registering this hook
+ * with #GtkAboutDialog.
+ *
+ * This is a convenience function, which can be registered with #GtkAboutDialog,
+ * to open links clicked by the user in #GtkAboutDialog<!---->s.
+ *
+ * All you need to do is to register this hook with gtk_about_dialog_set_url_hook()
+ * and gtk_about_dialog_set_email_hook(). This can be done prior to calling
+ * gtk_show_about_dialog(), for example:
+ *
+ * <informalexample><programlisting>
+ * static void show_about_dialog (void)
+ * {
+ * gtk_about_dialog_set_email_hook (exo_gtk_url_about_dialog_hook, NULL, NULL);
+ * gtk_about_dialog_set_url_hook (exo_gtk_url_about_dialog_hook, NULL, NULL);
+ * gtk_show_about_dialog (.....);
+ * }
+ * </programlisting></informalexample>
+ *
+ * This function is not needed when you use Gtk 2.18 or later, because from
+ * that version this is implemented by default.
+ *
+ * Since: 0.5.0
+ **/
+void
+exo_gtk_url_about_dialog_hook (GtkAboutDialog *about_dialog,
+ const gchar *link,
+ gpointer user_data)
+{
+ GtkWidget *message;
+ GdkScreen *screen;
+ GError *error = NULL;
+ gchar *uri, *escaped;
+
+ g_return_if_fail (GTK_IS_ABOUT_DIALOG (about_dialog));
+ g_return_if_fail (link != NULL);
+
+ /* simple check if this is an email address */
+ if (!g_str_has_prefix (link, "mailto:") && strchr (link, '@') != NULL)
+ {
+ escaped = g_uri_escape_string (link, NULL, FALSE);
+ uri = g_strdup_printf ("mailto:%s", escaped);
+ g_free (escaped);
+ }
+ else
+ {
+ uri = g_strdup (link);
+ }
+
+ /* determine the screen from the about dialog */
+ screen = gtk_widget_get_screen (GTK_WIDGET (about_dialog));
+
+ /* try to open the url on the given screen */
+ if (!gtk_show_uri (screen, uri, gtk_get_current_event_time (), &error))
+ {
+ /* make sure to initialize i18n support first,
+ * so we'll see a translated message.
+ */
+ _exo_i18n_init ();
+
+ /* display an error message to tell the user that we were unable to open the link */
+ message = gtk_message_dialog_new (GTK_WINDOW (about_dialog),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
+ _("Failed to open \"%s\"."), uri);
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message), "%s.", error->message);
+ gtk_dialog_run (GTK_DIALOG (message));
+ gtk_widget_destroy (message);
+ g_error_free (error);
+ }
+
+ /* cleanup */
+ g_free (uri);
+}
+
+
+
#define __EXO_GTK_EXTENSIONS_C__
#include <exo/exo-aliasdef.c>
diff --git a/exo/exo-gtk-extensions.h b/exo/exo-gtk-extensions.h
index 8cae715..4a2e6f2 100644
--- a/exo/exo-gtk-extensions.h
+++ b/exo/exo-gtk-extensions.h
@@ -35,6 +35,10 @@ void exo_gtk_object_destroy_later (GtkObject *object);
void exo_gtk_file_chooser_add_thumbnail_preview (GtkFileChooser *chooser);
+void exo_gtk_url_about_dialog_hook (GtkAboutDialog *about,
+ const gchar *link,
+ gpointer data);
+
G_END_DECLS
#endif /* !__EXO_GTK_EXTENSIONS_H__ */
diff --git a/exo/exo-url.c b/exo/exo-url.c
deleted file mode 100644
index 0ee56b4..0000000
--- a/exo/exo-url.c
+++ /dev/null
@@ -1,408 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2005-2006 Benedikt Meurer <benny at xfce.org>.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#ifdef HAVE_FNMATCH_H
-#include <fnmatch.h>
-#endif
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
-#ifdef HAVE_REGEX_H
-#include <regex.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-/* define FNM_CASEFOLD for systems that don't have it */
-#ifndef FNM_CASEFOLD
-#define FNM_CASEFOLD 0
-#endif
-
-#include <exo/exo-execute.h>
-#include <exo/exo-private.h>
-#include <exo/exo-url.h>
-#include <exo/exo-alias.h>
-
-
-
-/* regular expressions for exo_url_show_on_screen() */
-#define USERCHARS "-A-Za-z0-9"
-#define PASSCHARS "-A-Za-z0-9,?;.:/!%$^*&~\"#'"
-#define HOSTCHARS "-A-Za-z0-9"
-#define USER "[" USERCHARS "]+(:["PASSCHARS "]+)?"
-#define MATCH_BROWSER "^(([^:/?#]+)://)?([^/?#])([^?#]*)(\\?([^#]*))?(#(.*))?"
-#if !defined(__GLIBC__)
-#define MATCH_MAILER "^[a-z0-9][a-z0-9_.-]*@[a-z0-9][a-z0-9-]*(\\.[a-z0-9][a-z0-9-]*)+$"
-#else
-#define MATCH_MAILER "^\\<[a-z0-9][a-z0-9_.-]*@[a-z0-9][a-z0-9-]*(\\.[a-z0-9][a-z0-9-]*)+\\>$"
-#endif
-
-
-
-/**
- * exo_url_error_quark:
- *
- * Returns the #GError domain used for #ExoUrlError<!---->s
- * returned from exo_url_show() and exo_url_show_on_screen().
- *
- * Return value: the #GError domain used for #ExoUrlError<!---->s.
- *
- * Since: 0.3.1.3
- **/
-GQuark
-exo_url_error_quark (void)
-{
- static GQuark quark = 0;
-
- if (G_UNLIKELY (quark == 0))
- quark = g_quark_from_static_string ("exo-url-error-quark");
-
- return quark;
-}
-
-
-
-/**
- * exo_url_show:
- * @url : the URL that should be shown.
- * @envp : child environment for the url handler or
- * %NULL to inherit parent's environment.
- * @error : return location for errors or %NULL.
- *
- * Convenience wrapper to exo_url_show_on_screen(), which
- * shows the @url on the default #GdkScreen.
- *
- * Return value: %TRUE on success, %FALSE on error.
- *
- * Since: 0.3.1.3
- **/
-gboolean
-exo_url_show (const gchar *url,
- gchar **envp,
- GError **error)
-{
- g_return_val_if_fail (url != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- return exo_url_show_on_screen (url, envp, gdk_screen_get_default (), error);
-}
-
-
-
-static gboolean
-_exo_url_match (const gchar *pattern, const gchar *url)
-{
-#ifdef HAVE_REGEXEC
- regex_t regex;
- gint result = -1;
-
- if (regcomp (®ex, pattern, REG_EXTENDED) == 0)
- {
- result = regexec (®ex, url, 0, NULL, 0);
- regfree (®ex);
- }
-
- return (result == 0);
-#else
-#error "No POSIX regular expressions available, please report this to thunar-dev at xfce.org"
-#endif
-}
-
-
-
-static gchar*
-_exo_url_to_local_path (const gchar *url)
-{
- gchar *current_dir;
- gchar *path = NULL;
-
- if (g_str_has_prefix (url, "file://"))
- {
- /* transform a file:-URI to a local path */
- path = g_filename_from_uri (url, NULL, NULL);
- }
- else
- {
- /* check if url is an absolute path */
- if (g_path_is_absolute (url))
- {
- /* well, we got our path then */
- path = g_strdup (url);
- }
- else
- {
- /* treat it like a relative path */
- current_dir = g_get_current_dir ();
- path = g_build_filename (current_dir, url, NULL);
- g_free (current_dir);
-
- /* verify that a file of the given name exists */
- if (!g_file_test (path, G_FILE_TEST_EXISTS))
- {
- /* no local path then! */
- g_free (path);
- path = NULL;
- }
- }
- }
-
- return path;
-}
-
-
-
-/**
- * exo_url_show_on_screen:
- * @url : the URL that should be shown.
- * @envp : child environment for the url handler or
- * %NULL to inherit parent's environment.
- * @screen : the #GdkScreen on which to open the
- * URL handler for @url.
- * @error : return location for errors or %NULL.
- *
- * Tries to find a suitable handler for @url in the list of
- * preferred application categories and runs that handler
- * with @url on @screen.
- *
- * Return value: %TRUE on success, %FALSE on error.
- *
- * Since: 0.3.1.3
- **/
-gboolean
-exo_url_show_on_screen (const gchar *url,
- gchar **envp,
- GdkScreen *screen,
- GError **error)
-{
- const gchar *category = NULL;
- gboolean result = FALSE;
- gchar *display_name;
- gchar *local_path;
- gchar *command;
- gchar *uri;
- gchar *quoted_url;
- gint status;
-
- g_return_val_if_fail (url != NULL, FALSE);
- g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- /* be sure to initialize i18n support first,
- * so we get a translated error message.
- */
- _exo_i18n_init ();
-
- /* try to conver the URL into a local path */
- local_path = _exo_url_to_local_path (url);
-
- /* now, let's see what we have here */
- if (local_path != NULL)
- {
- /* determine the display name for the screen */
- display_name = gdk_screen_make_display_name (screen);
-
- /* check if we have a local HTML file here */
- if (fnmatch ("*.xhtml", local_path, FNM_CASEFOLD) == 0
- || fnmatch ("*.htm", local_path, FNM_CASEFOLD) == 0
- || fnmatch ("*.html", local_path, FNM_CASEFOLD) == 0)
- {
- /* transform the path to a file:-URI */
- uri = g_filename_to_uri (local_path, NULL, error);
- if (G_LIKELY (uri != NULL))
- {
- /* try to execute the file:-URI in a web browser */
- result = exo_execute_preferred_application_on_screen ("WebBrowser", uri, NULL, envp, screen, error);
- g_free (uri);
- }
- }
- else
- {
- /* make a shell quoted url to pass to other applications */
- quoted_url = g_shell_quote(local_path);
-
- /* but since we have a local file here, maybe the org.xfce.FileManager can open it? */
- command = g_strdup_printf ("dbus-send --print-reply --dest=org.xfce.FileManager "
- "/org/xfce/FileManager org.xfce.FileManager.Launch "
- "string:%s string:\"%s\"", quoted_url, display_name);
- result = (g_spawn_command_line_sync (command, NULL, NULL, &status, NULL) && status == 0);
- g_free (command);
-
- /* check if it's handled now */
- if (G_UNLIKELY (!result))
- {
- /* but hey, we know that Thunar can open local files, so give it a go */
- command = g_strdup_printf ("Thunar --display=\"%s\" %s", display_name, quoted_url);
- result = g_spawn_command_line_async (command, NULL);
- g_free (command);
- }
-
- /* check if it's handled now */
- if (G_UNLIKELY (!result))
- {
- /* gnome-open is also worth a try, since it uses the standard applications database */
- command = g_strdup_printf ("env DISPLAY=\"%s\" gnome-open %s", display_name, quoted_url);
- result = (g_spawn_command_line_sync (command, NULL, NULL, &status, NULL) && status == 0);
- g_free (command);
- }
-
- /* check if it's handled now */
- if (G_UNLIKELY (!result))
- {
- /* ok, we tried everything, but no luck, tell the user that we failed */
- g_set_error (error, EXO_URL_ERROR, EXO_URL_ERROR_NOT_SUPPORTED,
- _("Unable to open \"%s\""), local_path);
- }
-
- /* release the quoted_url as it is no longer needed */
- g_free(quoted_url);
- }
-
- /* release the local path and the display name */
- g_free (display_name);
- g_free (local_path);
-
- /* and we're done */
- return result;
- }
- else if (strncmp (url, "mailto:", 7) == 0 || _exo_url_match (MATCH_MAILER, url))
- {
- /* ignore mailto: prefix, as not all mailers can handle it */
- if (strncmp (url, "mailto:", 7) == 0)
- url += 7;
- category = "MailReader";
- }
- else if (_exo_url_match (MATCH_BROWSER, url))
- {
- category = "WebBrowser";
- }
- else
- {
- /* determine the display name for the screen */
- display_name = gdk_screen_make_display_name (screen);
-
- /* make a shell quoted url to pass to other applications */
- quoted_url = g_shell_quote(url);
-
- /* not a local path, and not something that we support, but maybe gnome-open knows what to do */
- command = g_strdup_printf ("env DISPLAY=\"%s\" gnome-open %s", display_name, quoted_url);
- result = (g_spawn_command_line_sync (command, NULL, NULL, &status, NULL) && status == 0);
- g_free (command);
-
- /* release the quoted_url as it is no longer needed */
- g_free(quoted_url);
-
- /* check if gnome-open handled the URL */
- if (G_UNLIKELY (!result))
- {
- /* no options left, we have to tell the user that we failed */
- g_set_error (error, EXO_URL_ERROR, EXO_URL_ERROR_NOT_SUPPORTED,
- _("The URL \"%s\" is not supported"), url);
- }
-
- /* release the display name */
- g_free (display_name);
-
- return result;
- }
-
- /* oki doki then, let's open it */
- return exo_execute_preferred_application_on_screen (category, url, NULL, envp, screen, error);
-}
-
-
-
-/**
- * exo_url_about_dialog_hook:
- * @about_dialog : the #GtkAboutDialog in which the user activated a link.
- * @link : the link, mail or web address, to open.
- * @user_data : user data that was passed when the function was
- * registered with gtk_about_dialog_set_email_hook()
- * or gtk_about_dialog_set_url_hook(). This is currently
- * unused within the context of this function, so you
- * can safely pass %NULL when registering this hook
- * with #GtkAboutDialog.
- *
- * This is a convenience function, which can be registered with #GtkAboutDialog,
- * to have the <link linkend="exo-Opening-URLs">exo-url</link> module open links
- * clicked by the user in #GtkAboutDialog<!---->s.
- *
- * All you need to do is to register this hook with gtk_about_dialog_set_url_hook()
- * and gtk_about_dialog_set_email_hook(). This can be done prior to calling
- * gtk_show_about_dialog(), for example:
- *
- * <informalexample><programlisting>
- * static void show_about_dialog (void)
- * {
- * gtk_about_dialog_set_email_hook (exo_url_about_dialog_hook, NULL, NULL);
- * gtk_about_dialog_set_url_hook (exo_url_about_dialog_hook, NULL, NULL);
- * gtk_show_about_dialog (.....);
- * }
- * </programlisting></informalexample>
- *
- * Since: 0.3.1.3
- **/
-void
-exo_url_about_dialog_hook (GtkAboutDialog *about_dialog,
- const gchar *link,
- gpointer user_data)
-{
- GtkWidget *message;
- GdkScreen *screen;
- GError *error = NULL;
-
- g_return_if_fail (GTK_IS_ABOUT_DIALOG (about_dialog));
- g_return_if_fail (link != NULL);
-
- /* determine the screen from the about dialog */
- screen = gtk_widget_get_screen (GTK_WIDGET (about_dialog));
-
- /* try to open the url on the given screen */
- if (!exo_url_show_on_screen (link, NULL, screen, &error))
- {
- /* make sure to initialize i18n support first,
- * so we'll see a translated message.
- */
- _exo_i18n_init ();
-
- /* display an error message to tell the user that we were unable to open the link */
- message = gtk_message_dialog_new (GTK_WINDOW (about_dialog),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
- _("Failed to open \"%s\"."), link);
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message), "%s.", error->message);
- gtk_dialog_run (GTK_DIALOG (message));
- gtk_widget_destroy (message);
- g_error_free (error);
- }
-}
-
-
-
-#define __EXO_URL_C__
-#include <exo/exo-aliasdef.c>
diff --git a/exo/exo-url.h b/exo/exo-url.h
deleted file mode 100644
index 3abc709..0000000
--- a/exo/exo-url.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* $Id$ */
-/*-
- * Copyright (c) 2005-2006 Benedikt Meurer <benny at xfce.org>.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#if !defined (EXO_INSIDE_EXO_H) && !defined (EXO_COMPILATION)
-#error "Only <exo/exo.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef __EXO_URL_H__
-#define __EXO_URL_H__
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-#define EXO_URL_ERROR (exo_url_error_quark ())
-GQuark exo_url_error_quark (void) G_GNUC_CONST;
-
-/**
- * ExoUrlError:
- * @EXO_URL_ERROR_NOT_SUPPORTED : a given URL is not supported.
- *
- * The errors that can be returned due to bad parameters being
- * passed to exo_url_show() or exo_url_show_on_screen().
- **/
-typedef enum /*< skip >*/
-{
- EXO_URL_ERROR_NOT_SUPPORTED,
-} ExoUrlError;
-
-gboolean exo_url_show (const gchar *url,
- gchar **envp,
- GError **error);
-
-gboolean exo_url_show_on_screen (const gchar *url,
- gchar **envp,
- GdkScreen *screen,
- GError **error);
-
-void exo_url_about_dialog_hook (GtkAboutDialog *about_dialog,
- const gchar *link,
- gpointer user_data);
-
-G_END_DECLS
-
-#endif /* !__EXO_URL_H__ */
diff --git a/exo/exo.h b/exo/exo.h
index de05b69..0084f08 100644
--- a/exo/exo.h
+++ b/exo/exo.h
@@ -56,7 +56,6 @@
#include <exo/exo-toolbars-model.h>
#include <exo/exo-toolbars-view.h>
#include <exo/exo-tree-view.h>
-#include <exo/exo-url.h>
#include <exo/exo-utils.h>
#include <exo/exo-wrap-table.h>
#include <exo/exo-xsession-client.h>
diff --git a/exo/exo.symbols b/exo/exo.symbols
index 210b72a..baeb58e 100644
--- a/exo/exo.symbols
+++ b/exo/exo.symbols
@@ -120,6 +120,7 @@ exo_g_value_transform_negate
#if IN_SOURCE(__EXO_GTK_EXTENSIONS_C__)
exo_gtk_object_destroy_later
exo_gtk_file_chooser_add_thumbnail_preview
+exo_gtk_url_about_dialog_hook
#endif
#endif
@@ -359,15 +360,6 @@ exo_tree_view_set_single_click_timeout
#endif
#endif
-#if IN_HEADER(__EXO_URL_H__)
-#if IN_SOURCE(__EXO_URL_C__)
-exo_url_error_quark G_GNUC_CONST
-exo_url_show
-exo_url_show_on_screen
-exo_url_about_dialog_hook
-#endif
-#endif
-
#if IN_HEADER(__EXO_WRAP_TABLE_H__)
#if IN_SOURCE(__EXO_WRAP_TABLE_C__)
exo_wrap_table_get_type G_GNUC_CONST
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 7bae820..bc545ca 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -2,7 +2,6 @@ exo/exo-binding.c
exo/exo-cell-renderer-ellipsized-text.c
exo/exo-cell-renderer-icon.c
exo/exo-config.c
-exo/exo-ellipsized-label.c
exo/exo-execute.c
exo/exo-gdk-pixbuf-extensions.c
exo/exo-gobject-extensions.c
@@ -11,10 +10,10 @@ exo/exo-icon-bar.c
exo/exo-icon-chooser-dialog.c
exo/exo-icon-chooser-model.c
exo/exo-icon-view.c
-exo/exo-md5.c
+exo/exo-job.c
exo/exo-mount-point.c
-exo/exo-pango-extensions.c
exo/exo-private.c
+exo/exo-simple-job.c
exo/exo-string.c
exo/exo-thumbnail-preview.c
exo/exo-thumbnail.c
@@ -24,7 +23,6 @@ exo/exo-toolbars-model.c
exo/exo-toolbars-private.c
exo/exo-toolbars-view.c
exo/exo-tree-view.c
-exo/exo-url.c
exo/exo-utils.c
exo/exo-wrap-table.c
exo/exo-xsession-client.c
@@ -47,6 +45,7 @@ exo-helper/exo-helper.c
exo-helper/exo-preferred-applications.desktop.in
exo-helper/main.c
exo-helper/helpers/Terminal.desktop.in.in
+exo-helper/helpers/Thunar.desktop.in.in
exo-helper/helpers/aterm.desktop.in.in
exo-helper/helpers/balsa.desktop.in.in
exo-helper/helpers/debian-sensible-browser.desktop.in.in
@@ -66,10 +65,12 @@ exo-helper/helpers/midori.desktop.in.in
exo-helper/helpers/mozilla-browser.desktop.in.in
exo-helper/helpers/mozilla-mailer.desktop.in.in
exo-helper/helpers/mutt.desktop.in.in
+exo-helper/helpers/nautilus.desktop.in.in
exo-helper/helpers/netscape-navigator.desktop.in.in
exo-helper/helpers/nxterm.desktop.in.in
exo-helper/helpers/opera-browser.desktop.in.in
exo-helper/helpers/opera-mailer.desktop.in.in
+exo-helper/helpers/pcmanfm.desktop.in.in
exo-helper/helpers/sylpheed-claws.desktop.in.in
exo-helper/helpers/sylpheed.desktop.in.in
exo-helper/helpers/thunderbird.desktop.in.in
diff --git a/python/exo.defs b/python/exo.defs
index a4446d7..296b090 100644
--- a/python/exo.defs
+++ b/python/exo.defs
@@ -1285,31 +1285,6 @@
-;; From ../exo/exo-url.h
-
-(define-function url_show
- (c-name "exo_url_show")
- (return-type "gboolean")
- (parameters
- '("const-gchar*" "url")
- '("gchar**" "envp")
- '("GError**" "error")
- )
-)
-
-(define-function url_show_on_screen
- (c-name "exo_url_show_on_screen")
- (return-type "gboolean")
- (parameters
- '("const-gchar*" "url")
- '("gchar**" "envp")
- '("GdkScreen*" "screen")
- '("GError**" "error")
- )
-)
-
-
-
;; From ../exo/exo-wrap-table.h
(define-function exo_wrap_table_get_type
diff --git a/python/exo.override b/python/exo.override
index 7001ac7..ddb1da9 100644
--- a/python/exo.override
+++ b/python/exo.override
@@ -66,7 +66,6 @@ ignore
exo_icon_view_selected_foreach
exo_toolbars_editor_new
exo_toolbars_view_new
- exo_url_show_on_screen
%%
override exo_execute_preferred_application kwargs
@@ -493,72 +492,3 @@ _wrap_exo_xsession_client_set_restart_command (PyGObject *self,
Py_INCREF (Py_None);
return Py_None;
}
-
-%%
-override exo_url_show kwargs
-static PyObject*
-_wrap_exo_url_show (PyObject *self,
- PyObject *args,
- PyObject *kwargs)
-{
- static gchar *kwlist[] = { "url", "environment", "screen", NULL };
- const gchar *url;
- GdkScreen *screen;
- PyObject *sequence = Py_None;
- PyObject *item = Py_None;
- GError *error = NULL;
- gchar **envp = NULL;
- gint n;
-
- if (!PyArg_ParseTupleAndKeywords (args, kwargs, "s|OO:show_url",
- kwlist, &url, &sequence, &item))
- return NULL;
-
- /* validate parameters */
- if (sequence != Py_None && !PySequence_Check (sequence))
- {
- PyErr_SetString (PyExc_TypeError, "environment must be a sequence or None");
- return NULL;
- }
- else if (item != Py_None && !pygobject_check (item, &PyGdkScreen_Type))
- {
- PyErr_SetString (PyExc_TypeError, "screen must be a gtk.gdk.Screen or None");
- return NULL;
- }
-
- /* determine the screen */
- screen = (item != Py_None) ? GDK_SCREEN (pygobject_get (item)) : gdk_screen_get_default ();
-
- if (G_UNLIKELY (sequence != Py_None))
- {
- envp = g_new0 (gchar *, PySequence_Length (sequence) + 1);
- for (n = 0; n < PySequence_Length (sequence); ++n)
- {
- item = PySequence_GetItem (sequence, n);
- Py_DECREF (item);
-
- if (!PyString_Check (item) && !PyUnicode_Check (item))
- {
- PyErr_SetString (PyExc_TypeError, "sequence item not a string or unicode object");
- g_strfreev (envp);
- return NULL;
- }
-
- envp[n] = g_strdup (PyString_AsString (item));
- }
- }
-
- /* try to open the specified URL */
- exo_url_show_on_screen (url, envp, screen, &error);
-
- /* release the environment */
- g_strfreev (envp);
-
- /* check for errors */
- if (pyg_error_check (&error))
- return NULL;
-
- Py_INCREF (Py_None);
- return Py_None;
-}
-
diff --git a/python/exomodule.c b/python/exomodule.c
index 37e9369..09a33c3 100644
--- a/python/exomodule.c
+++ b/python/exomodule.c
@@ -143,7 +143,9 @@ init_exo (void)
#undef REGISTER_TYPE
- /* use exo-url for about dialogs by default */
- gtk_about_dialog_set_email_hook (exo_url_about_dialog_hook, NULL, NULL);
- gtk_about_dialog_set_url_hook (exo_url_about_dialog_hook, NULL, NULL);
+#if GTK_CHECK_VERSION (2, 18, 0)
+ /* use exo about dialog hook by default */
+ gtk_about_dialog_set_email_hook (exo_gtk_url_about_dialog_hook, NULL, NULL);
+ gtk_about_dialog_set_url_hook (exo_gtk_url_about_dialog_hook, NULL, NULL);
+#endif
}
More information about the Xfce4-commits
mailing list