aboutsummaryrefslogtreecommitdiff
path: root/src/default-applications.c
blob: f924702c2cb0e26a3768d920ef867bfb49cb41e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

#include <glib.h>
#include <glib/gi18n.h>
#include "default-applications.h"

struct default_db_t {
	const gchar * desktop_file;
	const gchar * name;
	const gchar * setupname;
};

struct default_db_t default_db[] = {
	{"evolution.desktop", N_("Mail"),           N_("Set Up Mail...")},
	{"empathy.desktop",   N_("Chat"),           N_("Set Up Chat...")},
	{"gwibber.desktop",   N_("Microblogging"),  N_("Set Up Microblogging...")},
	{NULL, NULL}
};

static struct default_db_t *
get_default_helper (gchar * desktop_path)
{
	g_return_val_if_fail(desktop_path != NULL, NULL);
	gchar * basename = g_path_get_basename(desktop_path);
	g_return_val_if_fail(basename != NULL, NULL);

	gint i;
	for (i = 0; default_db[i].desktop_file != NULL; i++) {
		if (g_strcmp0(default_db[i].desktop_file, basename) == 0) {
			break;
		}
	}

	g_free(basename);

	if (default_db[i].desktop_file != NULL) {
		return &default_db[i];
	}

	return NULL;
}

const gchar *
get_default_name (gchar * desktop_path)
{
	struct default_db_t * db = get_default_helper(desktop_path);

	if (db == NULL)
		return NULL;
	return db->name;
}

const gchar *
get_default_setup (gchar * desktop_path)
{
	struct default_db_t * db = get_default_helper(desktop_path);

	if (db == NULL)
		return NULL;
	return db->setupname;
}