aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-08-19 22:29:40 -0500
committerTed Gould <ted@canonical.com>2009-08-19 22:29:40 -0500
commit17745461f669047872c12a6c7db7b05a9ccb0417 (patch)
tree0f3387efe54194db3be3a090192030f9cb3d6096 /src
parent99744b30f0ebf4c7054b8274c30af063ec52b248 (diff)
downloadayatana-indicator-messages-17745461f669047872c12a6c7db7b05a9ccb0417.tar.gz
ayatana-indicator-messages-17745461f669047872c12a6c7db7b05a9ccb0417.tar.bz2
ayatana-indicator-messages-17745461f669047872c12a6c7db7b05a9ccb0417.zip
Big commit. Trying to check for eclipses, but first both objects needed to track their desktop file paths. So I had to add that little nugget in as well.
Diffstat (limited to 'src')
-rw-r--r--src/app-menu-item.c27
-rw-r--r--src/app-menu-item.h1
-rw-r--r--src/launcher-menu-item.c17
-rw-r--r--src/launcher-menu-item.h1
-rw-r--r--src/messages-service.c24
5 files changed, 69 insertions, 1 deletions
diff --git a/src/app-menu-item.c b/src/app-menu-item.c
index 2212be5..3a2c795 100644
--- a/src/app-menu-item.c
+++ b/src/app-menu-item.c
@@ -45,6 +45,7 @@ struct _AppMenuItemPrivate
gchar * type;
GAppInfo * appinfo;
+ gchar * desktop;
guint unreadcount;
gboolean count_on_label;
};
@@ -105,6 +106,7 @@ app_menu_item_init (AppMenuItem *self)
priv->server = NULL;
priv->type = NULL;
priv->appinfo = NULL;
+ priv->desktop = NULL;
priv->unreadcount = 0;
priv->count_on_label = FALSE;
@@ -136,6 +138,10 @@ app_menu_item_finalize (GObject *object)
g_free(priv->type);
}
+ if (priv->desktop != NULL) {
+ g_free(priv->desktop);
+ }
+
if (priv->appinfo != NULL) {
g_object_unref(priv->appinfo);
}
@@ -229,15 +235,23 @@ desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar
if (priv->appinfo != NULL) {
g_object_unref(G_OBJECT(priv->appinfo));
+ priv->appinfo = NULL;
+ }
+
+ if (priv->desktop != NULL) {
+ g_free(priv->desktop);
+ priv->desktop = NULL;
}
if (value == NULL || value[0] == '\0') {
return;
}
-
+
priv->appinfo = G_APP_INFO(g_desktop_app_info_new_from_filename(value));
g_return_if_fail(priv->appinfo != NULL);
+ priv->desktop = g_strdup(value);
+
update_label(self);
g_signal_emit(G_OBJECT(self), signals[NAME_CHANGED], 0, app_menu_item_get_name(self), TRUE);
@@ -297,6 +311,7 @@ indicator_removed_cb (IndicateListener * listener, IndicateListenerServer * serv
guint
app_menu_item_get_count (AppMenuItem * appitem)
{
+ g_return_val_if_fail(IS_APP_MENU_ITEM(appitem), 0);
AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(appitem);
return priv->unreadcount;
@@ -304,6 +319,7 @@ app_menu_item_get_count (AppMenuItem * appitem)
IndicateListenerServer *
app_menu_item_get_server (AppMenuItem * appitem) {
+ g_return_val_if_fail(IS_APP_MENU_ITEM(appitem), NULL);
AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(appitem);
return priv->server;
@@ -312,6 +328,7 @@ app_menu_item_get_server (AppMenuItem * appitem) {
const gchar *
app_menu_item_get_name (AppMenuItem * appitem)
{
+ g_return_val_if_fail(IS_APP_MENU_ITEM(appitem), NULL);
AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(appitem);
if (priv->appinfo == NULL) {
@@ -320,3 +337,11 @@ app_menu_item_get_name (AppMenuItem * appitem)
return g_app_info_get_name(priv->appinfo);
}
}
+
+const gchar *
+app_menu_item_get_desktop (AppMenuItem * appitem)
+{
+ g_return_val_if_fail(IS_APP_MENU_ITEM(appitem), NULL);
+ AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(appitem);
+ return priv->desktop;
+}
diff --git a/src/app-menu-item.h b/src/app-menu-item.h
index dda4765..583d50d 100644
--- a/src/app-menu-item.h
+++ b/src/app-menu-item.h
@@ -59,6 +59,7 @@ AppMenuItem * app_menu_item_new (IndicateListener * listener, IndicateListenerSe
guint app_menu_item_get_count (AppMenuItem * appitem);
IndicateListenerServer * app_menu_item_get_server (AppMenuItem * appitem);
const gchar * app_menu_item_get_name (AppMenuItem * appitem);
+const gchar * app_menu_item_get_desktop (AppMenuItem * appitem);
G_END_DECLS
diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c
index b869a40..4f05ae6 100644
--- a/src/launcher-menu-item.c
+++ b/src/launcher-menu-item.c
@@ -39,6 +39,7 @@ typedef struct _LauncherMenuItemPrivate LauncherMenuItemPrivate;
struct _LauncherMenuItemPrivate
{
GAppInfo * appinfo;
+ gchar * desktop;
};
#define LAUNCHER_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), LAUNCHER_MENU_ITEM_TYPE, LauncherMenuItemPrivate))
@@ -81,6 +82,7 @@ launcher_menu_item_init (LauncherMenuItem *self)
LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(self);
priv->appinfo = NULL;
+ priv->desktop = NULL;
return;
}
@@ -102,6 +104,12 @@ launcher_menu_item_finalize (GObject *object)
if (priv->appinfo != NULL) {
g_object_unref(priv->appinfo);
+ priv->appinfo = NULL;
+ }
+
+ if (priv->desktop != NULL) {
+ g_free(priv->desktop);
+ priv->desktop = NULL;
}
G_OBJECT_CLASS (launcher_menu_item_parent_class)->finalize (object);
@@ -118,6 +126,7 @@ launcher_menu_item_new (const gchar * desktop_file)
LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(self);
priv->appinfo = G_APP_INFO(g_desktop_app_info_new_from_filename(desktop_file));
+ priv->desktop = g_strdup(desktop_file);
g_debug("\tName: %s", launcher_menu_item_get_name(self));
dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "label", launcher_menu_item_get_name(self));
@@ -156,6 +165,14 @@ activate_cb (LauncherMenuItem * self, gpointer data)
return;
}
+const gchar *
+launcher_menu_item_get_desktop (LauncherMenuItem * launchitem)
+{
+ g_return_val_if_fail(IS_LAUNCHER_MENU_ITEM(launchitem), NULL);
+ LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(launchitem);
+ return priv->desktop;
+}
+
/* Hides the menu item based on whether it is eclipsed
or not. */
void
diff --git a/src/launcher-menu-item.h b/src/launcher-menu-item.h
index f17fbad..2b39073 100644
--- a/src/launcher-menu-item.h
+++ b/src/launcher-menu-item.h
@@ -55,6 +55,7 @@ struct _LauncherMenuItem {
GType launcher_menu_item_get_type (void);
LauncherMenuItem * launcher_menu_item_new (const gchar * desktop_file);
const gchar * launcher_menu_item_get_name (LauncherMenuItem * appitem);
+const gchar * launcher_menu_item_get_desktop (LauncherMenuItem * launchitem);
void launcher_menu_item_set_eclipsed (LauncherMenuItem * li, gboolean eclipsed);
G_END_DECLS
diff --git a/src/messages-service.c b/src/messages-service.c
index c6bc5b8..f8f1aaf 100644
--- a/src/messages-service.c
+++ b/src/messages-service.c
@@ -527,7 +527,18 @@ indicator_removed (IndicateListener * listener, IndicateListenerServer * server,
static void
check_eclipses (AppMenuItem * ai)
{
+ const gchar * aidesktop = app_menu_item_get_desktop(ai);
+ if (aidesktop == NULL) return;
+ GList * llitem;
+ for (llitem = launcherList; llitem != NULL; llitem = llitem->next) {
+ const gchar * lidesktop = launcher_menu_item_get_desktop(LAUNCHER_MENU_ITEM(llitem->data));
+
+ if (!g_strcmp0(aidesktop, lidesktop)) {
+ launcher_menu_item_set_eclipsed(LAUNCHER_MENU_ITEM(llitem->data), TRUE);
+ break;
+ }
+ }
return;
}
@@ -537,7 +548,18 @@ check_eclipses (AppMenuItem * ai)
static void
remove_eclipses (AppMenuItem * ai)
{
+ const gchar * aidesktop = app_menu_item_get_desktop(ai);
+ if (aidesktop == NULL) return;
+ GList * llitem;
+ for (llitem = launcherList; llitem != NULL; llitem = llitem->next) {
+ const gchar * lidesktop = launcher_menu_item_get_desktop(LAUNCHER_MENU_ITEM(llitem->data));
+
+ if (!g_strcmp0(aidesktop, lidesktop)) {
+ launcher_menu_item_set_eclipsed(LAUNCHER_MENU_ITEM(llitem->data), FALSE);
+ break;
+ }
+ }
return;
}
@@ -609,6 +631,8 @@ build_launchers (gpointer data)
return FALSE;
}
+/* Oh, if you don't know what main() is for
+ we really shouldn't be talking. */
int
main (int argc, char ** argv)
{