aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Coulson <chrisccoulson@ubuntu.com>2011-07-21 21:03:22 +0100
committerChris Coulson <chrisccoulson@ubuntu.com>2011-07-21 21:03:22 +0100
commitcb66d5b60dfef96523a90cfec42ff679b2c60065 (patch)
tree629bb0fe1a8d275be49d4e06693e4411006bff4a /src
parentacbcc6281bd71cc487c22f6a4565827563631661 (diff)
downloadayatana-indicator-messages-cb66d5b60dfef96523a90cfec42ff679b2c60065.tar.gz
ayatana-indicator-messages-cb66d5b60dfef96523a90cfec42ff679b2c60065.tar.bz2
ayatana-indicator-messages-cb66d5b60dfef96523a90cfec42ff679b2c60065.zip
Honour the default mail client rather than hardcoding the Mail entry to point to Evolution
Diffstat (limited to 'src')
-rw-r--r--src/default-applications.c44
1 files changed, 36 insertions, 8 deletions
diff --git a/src/default-applications.c b/src/default-applications.c
index afb5025..3a8df60 100644
--- a/src/default-applications.c
+++ b/src/default-applications.c
@@ -21,20 +21,22 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <glib.h>
#include <glib/gi18n.h>
+#include <gio/gio.h>
+#include <gio/gdesktopappinfo.h>
#include "default-applications.h"
struct default_db_t {
const gchar * desktop_file;
+ const gchar * uri_scheme;
const gchar * name;
const gchar * setupname;
const gchar * icon;
};
struct default_db_t default_db[] = {
- {"evolution.desktop", N_("Mail"), N_("Set Up Mail..."), "applications-email-panel"},
- {"empathy.desktop", N_("Chat"), N_("Set Up Chat..."), "applications-chat-panel"},
- {"gwibber.desktop", N_("Broadcast"), N_("Set Up Broadcast Account..."), "applications-microblogging-panel"},
- {NULL, NULL}
+ {NULL, "mailto", N_("Mail"), N_("Set Up Mail..."), "applications-email-panel"},
+ {"empathy.desktop", NULL, N_("Chat"), N_("Set Up Chat..."), "applications-chat-panel"},
+ {"gwibber.desktop", NULL, N_("Broadcast"), N_("Set Up Broadcast Account..."), "applications-microblogging-panel"},
};
static struct default_db_t *
@@ -44,16 +46,42 @@ get_default_helper (const gchar * desktop_path)
gchar * basename = g_path_get_basename(desktop_path);
g_return_val_if_fail(basename != NULL, NULL);
+ gboolean found = FALSE;
gint i;
- for (i = 0; default_db[i].desktop_file != NULL; i++) {
- if (g_strcmp0(default_db[i].desktop_file, basename) == 0) {
- break;
+ gint length = sizeof(default_db)/sizeof(default_db[0]);
+ for (i = 0; i < length; i++) {
+ if (default_db[i].desktop_file) {
+ if (g_strcmp0(default_db[i].desktop_file, basename) == 0) {
+ found = TRUE;
+ break;
+ }
+ } else if (default_db[i].uri_scheme) {
+ GAppInfo *info = g_app_info_get_default_for_uri_scheme(default_db[i].uri_scheme);
+ if (!info) {
+ continue;
+ }
+
+ const gchar * filename = g_desktop_app_info_get_filename(G_DESKTOP_APP_INFO(info));
+ if (!filename) {
+ g_object_unref(info);
+ continue;
+ }
+
+ gchar * default_basename = g_path_get_basename(filename);
+ g_object_unref(info);
+ if (g_strcmp0(default_basename, basename) == 0) {
+ found = TRUE;
+ g_free(default_basename);
+ break;
+ }
+
+ g_free(default_basename);
}
}
g_free(basename);
- if (default_db[i].desktop_file != NULL) {
+ if (found) {
return &default_db[i];
}