aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-03-04 13:06:47 -0600
committerTed Gould <ted@gould.cx>2010-03-04 13:06:47 -0600
commit1cc1da9e68b7899074c90b3a17ead21281b3f4f5 (patch)
treed51b98a7e7d325f5d8fd653f29566aac9203d13e /src
parentb9713df6cd2898e5f86d8dcf1f39634bc1cc6736 (diff)
parent586e053b9e3c862c8e0561c2679cd4e146d76f84 (diff)
downloadayatana-indicator-messages-1cc1da9e68b7899074c90b3a17ead21281b3f4f5.tar.gz
ayatana-indicator-messages-1cc1da9e68b7899074c90b3a17ead21281b3f4f5.tar.bz2
ayatana-indicator-messages-1cc1da9e68b7899074c90b3a17ead21281b3f4f5.zip
Setting up default application names in the menu.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/app-menu-item.c10
-rw-r--r--src/default-applications.c80
-rw-r--r--src/default-applications.h29
-rw-r--r--src/launcher-menu-item.c10
5 files changed, 128 insertions, 3 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 01741d0..c96ef2d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -20,6 +20,8 @@ libmessaging_la_LDFLAGS = -module -avoid-version
######################################
indicator_messages_service_SOURCES = \
+ default-applications.h \
+ default-applications.c \
messages-service.c \
messages-service-server.h \
messages-service-dbus.c \
diff --git a/src/app-menu-item.c b/src/app-menu-item.c
index a37daf4..f792128 100644
--- a/src/app-menu-item.c
+++ b/src/app-menu-item.c
@@ -30,6 +30,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <libdbusmenu-glib/menuitem-proxy.h>
#include "app-menu-item.h"
#include "dbus-data.h"
+#include "default-applications.h"
enum {
COUNT_CHANGED,
@@ -233,15 +234,20 @@ static void
update_label (AppMenuItem * self)
{
AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self);
+ const gchar * name = get_default_name(priv->desktop);
+
+ if (name == NULL) {
+ name = app_menu_item_get_name(self);
+ }
if (priv->unreadcount > 0) {
/* TRANSLATORS: This is the name of the program and the number of indicators. So it
would read something like "Mail Client (5)" */
- gchar * label = g_strdup_printf(_("%s (%d)"), app_menu_item_get_name(self), priv->unreadcount);
+ gchar * label = g_strdup_printf(_("%s (%d)"), _(name), priv->unreadcount);
dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_LABEL, label);
g_free(label);
} else {
- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_LABEL, app_menu_item_get_name(self));
+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_LABEL, _(name));
}
return;
diff --git a/src/default-applications.c b/src/default-applications.c
new file mode 100644
index 0000000..5fd6612
--- /dev/null
+++ b/src/default-applications.c
@@ -0,0 +1,80 @@
+/*
+Looking for the default applications. A quick lookup.
+
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Ted Gould <ted@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#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 (const 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 (const 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 (const gchar * desktop_path)
+{
+ struct default_db_t * db = get_default_helper(desktop_path);
+
+ if (db == NULL)
+ return NULL;
+ return db->setupname;
+}
diff --git a/src/default-applications.h b/src/default-applications.h
new file mode 100644
index 0000000..13cc904
--- /dev/null
+++ b/src/default-applications.h
@@ -0,0 +1,29 @@
+/*
+Looking for the default applications. A quick lookup.
+
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Ted Gould <ted@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef DEFAULT_APPLICATIONS_H__
+#define DEFAULT_APPLICATIONS_H__ 1
+
+const gchar * get_default_name (const gchar * desktop_path);
+const gchar * get_default_setup (const gchar * desktop_path);
+
+#endif /* DEFAULT_APPLICATIONS_H__ */
+
diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c
index 07b0546..5cc7cfe 100644
--- a/src/launcher-menu-item.c
+++ b/src/launcher-menu-item.c
@@ -30,6 +30,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <libindicator/indicator-desktop-shortcuts.h>
#include "launcher-menu-item.h"
#include "dbus-data.h"
+#include "default-applications.h"
enum {
NAME_CHANGED,
@@ -161,7 +162,14 @@ launcher_menu_item_new (const gchar * desktop_file)
/* Set the appropriate values on this menu item based on the
app info that we've parsed */
g_debug("\tName: %s", launcher_menu_item_get_name(self));
- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_LABEL, launcher_menu_item_get_name(self));
+
+ const gchar * default_name = get_default_name(desktop_file);
+ if (default_name == NULL) {
+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_LABEL, launcher_menu_item_get_name(self));
+ } else {
+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_LABEL, default_name);
+ }
+
gchar * iconstr = launcher_menu_item_get_icon(self);
dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_ICON_NAME, iconstr);
g_free(iconstr);