ayatana-commits team mailing list archive
-
ayatana-commits team
-
Mailing list archive
-
Message #01063
[Merge] lp:~ted/indicator-messages/default-application-names into lp:indicator-messages
Ted Gould has proposed merging lp:~ted/indicator-messages/default-application-names into lp:indicator-messages.
Requested reviews:
Indicator Applet Developers (indicator-applet-developers)
Sets up a list of default names that are used for our default
applications in the messaging menu. Evolution is mail, Empathy is Chat
and Gwibber is Microblogging.
--
https://code.launchpad.net/~ted/indicator-messages/default-application-names/+merge/20628
Your team ayatana-commits is subscribed to branch lp:indicator-messages.
=== modified file 'po/POTFILES.in'
--- po/POTFILES.in 2009-09-15 21:13:51 +0000
+++ po/POTFILES.in 2010-03-04 07:20:29 +0000
@@ -2,6 +2,7 @@
src/messages-service-dbus.c
src/indicator-messages.c
src/messages-service.c
+src/default-applications.c
src/launcher-menu-item.c
src/im-menu-item.c
src/app-menu-item.c
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2009-09-09 14:52:36 +0000
+++ src/Makefile.am 2010-03-04 07:20:29 +0000
@@ -20,6 +20,8 @@
######################################
indicator_messages_service_SOURCES = \
+ default-applications.h \
+ default-applications.c \
messages-service.c \
messages-service-server.h \
messages-service-dbus.c \
=== modified file 'src/app-menu-item.c'
--- src/app-menu-item.c 2010-02-18 17:23:29 +0000
+++ src/app-menu-item.c 2010-03-04 07:20:29 +0000
@@ -30,6 +30,7 @@
#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 @@
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;
=== added file 'src/default-applications.c'
--- src/default-applications.c 1970-01-01 00:00:00 +0000
+++ src/default-applications.c 2010-03-04 07:20:29 +0000
@@ -0,0 +1,80 @@
+/*
+Looking for the default applications. A quick lookup.
+
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Ted Gould <ted@xxxxxxxxxxxxx>
+
+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;
+}
=== added file 'src/default-applications.h'
--- src/default-applications.h 1970-01-01 00:00:00 +0000
+++ src/default-applications.h 2010-03-04 07:20:29 +0000
@@ -0,0 +1,29 @@
+/*
+Looking for the default applications. A quick lookup.
+
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Ted Gould <ted@xxxxxxxxxxxxx>
+
+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__ */
+
=== modified file 'src/launcher-menu-item.c'
--- src/launcher-menu-item.c 2010-02-18 17:23:29 +0000
+++ src/launcher-menu-item.c 2010-03-04 07:20:29 +0000
@@ -30,6 +30,7 @@
#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 @@
/* 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);
Follow ups