aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2012-05-18 23:26:54 +0200
committerLars Uebernickel <lars.uebernickel@canonical.com>2012-05-18 23:26:54 +0200
commit583033cb8dbf95d224bc9cc4bf4d4d097b7950f3 (patch)
tree073987a4df486ac56dba3c63b6b83f8f6d52c496 /src
parente7376b8e516039cc9da5e57b1b21e4c98c69d437 (diff)
downloadayatana-indicator-messages-583033cb8dbf95d224bc9cc4bf4d4d097b7950f3.tar.gz
ayatana-indicator-messages-583033cb8dbf95d224bc9cc4bf4d4d097b7950f3.tar.bz2
ayatana-indicator-messages-583033cb8dbf95d224bc9cc4bf4d4d097b7950f3.zip
Remove default applications
This gets rid of the "Set Up <app>" sections for Email, Chat, and Broadcast. Also, default apps don't get to override the icon and names anymore. Every app gets its real name and icon displayed. Overriding the icon with X-Ayatana-Messaging-Menu-Icon is still possible.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/app-menu-item.c48
-rw-r--r--src/dbus-data.h4
-rw-r--r--src/default-applications.c116
-rw-r--r--src/default-applications.h34
-rw-r--r--src/launcher-menu-item.c36
6 files changed, 26 insertions, 214 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 6617b49..0f923c7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -37,8 +37,6 @@ libmessaging_la_LDFLAGS = \
######################################
indicator_messages_service_SOURCES = \
- default-applications.h \
- default-applications.c \
messages-service.c \
messages-service-dbus.c \
messages-service-dbus.h \
diff --git a/src/app-menu-item.c b/src/app-menu-item.c
index ef3fbc0..3fb3ab8 100644
--- a/src/app-menu-item.c
+++ b/src/app-menu-item.c
@@ -30,7 +30,6 @@ 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"
#include "seen-db.h"
enum {
@@ -257,11 +256,7 @@ 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);
- }
+ const gchar * 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
@@ -345,36 +340,31 @@ desktop_cb (IndicateListener * listener, IndicateListenerServer * server, const
update_label(self);
- const gchar * def_icon = get_default_icon(priv->desktop);
- if (def_icon == NULL) {
- gchar * iconstr = NULL;
+ gchar * iconstr = NULL;
- /* Check for the over ride key and see if we should be using that
- icon. If we can't get it, then go back to the app info */
- if (g_key_file_has_key(priv->keyfile, G_KEY_FILE_DESKTOP_GROUP, ICON_KEY, NULL) && iconstr == NULL) {
- GError * error = NULL;
+ /* Check for the over ride key and see if we should be using that
+ icon. If we can't get it, then go back to the app info */
+ if (g_key_file_has_key(priv->keyfile, G_KEY_FILE_DESKTOP_GROUP, ICON_KEY, NULL) && iconstr == NULL) {
+ GError * error = NULL;
- iconstr = g_key_file_get_string(priv->keyfile, G_KEY_FILE_DESKTOP_GROUP, ICON_KEY, &error);
-
- if (error != NULL) {
- /* Can't figure out why this would happen, but sure, let's print something */
- g_warning("Error getting '" ICON_KEY "' from desktop file: %s", error->message);
- g_error_free(error);
- }
- }
+ iconstr = g_key_file_get_string(priv->keyfile, G_KEY_FILE_DESKTOP_GROUP, ICON_KEY, &error);
- /* For some reason that didn't work, let's try the app info */
- if (iconstr == NULL) {
- GIcon * icon = g_app_info_get_icon(priv->appinfo);
- iconstr = g_icon_to_string(icon);
+ if (error != NULL) {
+ /* Can't figure out why this would happen, but sure, let's print something */
+ g_warning("Error getting '" ICON_KEY "' from desktop file: %s", error->message);
+ g_error_free(error);
}
+ }
- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), APPLICATION_MENUITEM_PROP_ICON, iconstr);
- g_free(iconstr);
- } else {
- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), APPLICATION_MENUITEM_PROP_ICON, def_icon);
+ /* For some reason that didn't work, let's try the app info */
+ if (iconstr == NULL) {
+ GIcon * icon = g_app_info_get_icon(priv->appinfo);
+ iconstr = g_icon_to_string(icon);
}
+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), APPLICATION_MENUITEM_PROP_ICON, iconstr);
+ g_free(iconstr);
+
g_signal_emit(G_OBJECT(self), signals[NAME_CHANGED], 0, app_menu_item_get_name(self), TRUE);
return;
diff --git a/src/dbus-data.h b/src/dbus-data.h
index fac732e..1e82ded 100644
--- a/src/dbus-data.h
+++ b/src/dbus-data.h
@@ -21,4 +21,8 @@
#define MAX_NUMBER_OF_INDICATORS 7
+/* Used for override icons in the normal case, but didn't
+ have a better place to put it. */
+#define ICON_KEY "X-Ayatana-Messaging-Menu-Icon"
+
#endif /* __DBUS_DATA_H__ */
diff --git a/src/default-applications.c b/src/default-applications.c
deleted file mode 100644
index 0382e4d..0000000
--- a/src/default-applications.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
-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 <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[] = {
- {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 *
-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);
-
- gboolean found = FALSE;
- gint i;
- gint length = G_N_ELEMENTS(default_db);
- for (i = 0; i < length && !found; i++) {
- if (default_db[i].desktop_file) {
- if (g_strcmp0(default_db[i].desktop_file, basename) == 0) {
- found = TRUE;
- }
- } 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);
- }
- }
-
- g_free(basename);
-
- if (found) {
- return &default_db[i - 1];
- }
-
- 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;
-}
-
-const gchar *
-get_default_icon (const gchar * desktop_path)
-{
- struct default_db_t * db = get_default_helper(desktop_path);
-
- if (db == NULL)
- return NULL;
- return db->icon;
-}
diff --git a/src/default-applications.h b/src/default-applications.h
deleted file mode 100644
index df52b38..0000000
--- a/src/default-applications.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
-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
-
-/* Used for override icons in the normal case, but didn't
- have a better place to put it. */
-#define ICON_KEY "X-Ayatana-Messaging-Menu-Icon"
-
-const gchar * get_default_name (const gchar * desktop_path);
-const gchar * get_default_setup (const gchar * desktop_path);
-const gchar * get_default_icon (const gchar * desktop_path);
-
-#endif /* DEFAULT_APPLICATIONS_H__ */
-
diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c
index 91cbbb8..5e10da4 100644
--- a/src/launcher-menu-item.c
+++ b/src/launcher-menu-item.c
@@ -30,7 +30,6 @@ 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"
#include "seen-db.h"
enum {
@@ -175,26 +174,9 @@ launcher_menu_item_new (const gchar * desktop_file)
app info that we've parsed */
g_debug("\tName: %s", launcher_menu_item_get_name(self));
- const gchar * default_name = NULL;
-
- if (seen_db_seen(desktop_file)) {
- default_name = get_default_name(desktop_file);
- } else {
- default_name = get_default_setup(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));
- }
+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_LABEL, launcher_menu_item_get_name(self));
- gchar * iconstr;
- if (default_name == NULL) {
- iconstr = launcher_menu_item_get_icon(self);
- } else {
- iconstr = g_strdup(get_default_icon(desktop_file));
- }
+ gchar * iconstr = launcher_menu_item_get_icon(self);
dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_ICON_NAME, iconstr);
g_free(iconstr);
dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
@@ -357,19 +339,7 @@ launcher_menu_item_set_eclipsed (LauncherMenuItem * li, gboolean eclipsed)
/* If we're being reshown let's re-evaluate how we should be
showing the label */
if (!eclipsed) {
- const gchar * default_name = NULL;
-
- if (seen_db_seen(priv->desktop)) {
- default_name = get_default_name(priv->desktop);
- } else {
- default_name = get_default_setup(priv->desktop);
- }
-
- if (default_name == NULL) {
- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li), DBUSMENU_MENUITEM_PROP_LABEL, launcher_menu_item_get_name(li));
- } else {
- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li), DBUSMENU_MENUITEM_PROP_LABEL, _(default_name));
- }
+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li), DBUSMENU_MENUITEM_PROP_LABEL, launcher_menu_item_get_name(li));
}
return;