aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--po/POTFILES.in3
-rw-r--r--src/Makefile.am4
-rw-r--r--src/app-menu-item.h58
-rw-r--r--src/app-section.c (renamed from src/app-menu-item.c)119
-rw-r--r--src/app-section.h58
-rw-r--r--src/messages-service.c18
-rw-r--r--test/Makefile.am4
7 files changed, 130 insertions, 134 deletions
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 051f8f3..2d93682 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -3,7 +3,4 @@ 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
src/status-items.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 2527878..1dbb514 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -42,8 +42,8 @@ indicator_messages_service_SOURCES = \
messages-service-dbus.h \
gen-messages-service.xml.h \
gen-messages-service.xml.c \
- app-menu-item.c \
- app-menu-item.h \
+ app-section.c \
+ app-section.h \
dbus-data.h \
\
status-items.c \
diff --git a/src/app-menu-item.h b/src/app-menu-item.h
deleted file mode 100644
index 1fb2762..0000000
--- a/src/app-menu-item.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-An indicator to show information that is in messaging applications
-that the user is using.
-
-Copyright 2009 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 __APP_MENU_ITEM_H__
-#define __APP_MENU_ITEM_H__
-
-#include <gio/gio.h>
-
-G_BEGIN_DECLS
-
-#define APP_MENU_ITEM_TYPE (app_menu_item_get_type ())
-#define APP_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APP_MENU_ITEM_TYPE, AppMenuItem))
-#define APP_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APP_MENU_ITEM_TYPE, AppMenuItemClass))
-#define IS_APP_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APP_MENU_ITEM_TYPE))
-#define IS_APP_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APP_MENU_ITEM_TYPE))
-#define APP_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APP_MENU_ITEM_TYPE, AppMenuItemClass))
-
-typedef struct _AppMenuItem AppMenuItem;
-typedef struct _AppMenuItemClass AppMenuItemClass;
-
-struct _AppMenuItemClass {
- GObjectClass parent_class;
-};
-
-struct _AppMenuItem {
- GObject parent;
-};
-
-GType app_menu_item_get_type (void);
-AppMenuItem * app_menu_item_new (GDesktopAppInfo *appinfo);
-guint app_menu_item_get_count (AppMenuItem * appitem);
-const gchar * app_menu_item_get_name (AppMenuItem * appitem);
-const gchar * app_menu_item_get_desktop (AppMenuItem * appitem);
-GMenuModel * app_menu_item_get_menu (AppMenuItem *appitem);
-GAppInfo * app_menu_item_get_app_info (AppMenuItem *appitem);
-
-G_END_DECLS
-
-#endif /* __APP_MENU_ITEM_H__ */
-
diff --git a/src/app-menu-item.c b/src/app-section.c
index 7638eb5..5a5e838 100644
--- a/src/app-menu-item.c
+++ b/src/app-section.c
@@ -28,12 +28,12 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <gio/gdesktopappinfo.h>
#include <gio/gio.h>
#include <libindicator/indicator-desktop-shortcuts.h>
-#include "app-menu-item.h"
+#include "app-section.h"
#include "dbus-data.h"
-typedef struct _AppMenuItemPrivate AppMenuItemPrivate;
+typedef struct _AppSectionPrivate AppSectionPrivate;
-struct _AppMenuItemPrivate
+struct _AppSectionPrivate
{
GDesktopAppInfo * appinfo;
guint unreadcount;
@@ -44,7 +44,7 @@ struct _AppMenuItemPrivate
GSimpleActionGroup *static_shortcuts;
};
-#define APP_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), APP_MENU_ITEM_TYPE, AppMenuItemPrivate))
+#define APP_SECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), APP_SECTION_TYPE, AppSectionPrivate))
enum {
PROP_0,
@@ -55,36 +55,36 @@ enum {
static GParamSpec *properties[NUM_PROPERTIES];
/* Prototypes */
-static void app_menu_item_class_init (AppMenuItemClass *klass);
-static void app_menu_item_init (AppMenuItem *self);
-static void app_menu_item_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static void app_menu_item_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void app_menu_item_dispose (GObject *object);
+static void app_section_class_init (AppSectionClass *klass);
+static void app_section_init (AppSection *self);
+static void app_section_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void app_section_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void app_section_dispose (GObject *object);
static void activate_cb (GSimpleAction *action,
GVariant *param,
gpointer userdata);
-static void app_menu_item_set_app_info (AppMenuItem *self,
- GDesktopAppInfo *appinfo);
+static void app_section_set_app_info (AppSection *self,
+ GDesktopAppInfo *appinfo);
/* GObject Boilerplate */
-G_DEFINE_TYPE (AppMenuItem, app_menu_item, G_TYPE_OBJECT);
+G_DEFINE_TYPE (AppSection, app_section, G_TYPE_OBJECT);
static void
-app_menu_item_class_init (AppMenuItemClass *klass)
+app_section_class_init (AppSectionClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (AppMenuItemPrivate));
+ g_type_class_add_private (klass, sizeof (AppSectionPrivate));
- object_class->get_property = app_menu_item_get_property;
- object_class->set_property = app_menu_item_set_property;
- object_class->dispose = app_menu_item_dispose;
+ object_class->get_property = app_section_get_property;
+ object_class->set_property = app_section_set_property;
+ object_class->dispose = app_section_dispose;
properties[PROP_APPINFO] = g_param_spec_object ("app-info",
"AppInfo",
@@ -96,10 +96,9 @@ app_menu_item_class_init (AppMenuItemClass *klass)
}
static void
-app_menu_item_init (AppMenuItem *self)
+app_section_init (AppSection *self)
{
- g_debug("Building new App Menu Item");
- AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self);
+ AppSectionPrivate * priv = APP_SECTION_GET_PRIVATE(self);
priv->appinfo = NULL;
priv->unreadcount = 0;
@@ -111,17 +110,17 @@ app_menu_item_init (AppMenuItem *self)
}
static void
-app_menu_item_get_property (GObject *object,
+app_section_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
- AppMenuItem *self = APP_MENU_ITEM (object);
+ AppSection *self = APP_SECTION (object);
switch (property_id)
{
case PROP_APPINFO:
- g_value_set_object (value, app_menu_item_get_app_info (self));
+ g_value_set_object (value, app_section_get_app_info (self));
break;
default:
@@ -130,17 +129,17 @@ app_menu_item_get_property (GObject *object,
}
static void
-app_menu_item_set_property (GObject *object,
+app_section_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
- AppMenuItem *self = APP_MENU_ITEM (object);
+ AppSection *self = APP_SECTION (object);
switch (property_id)
{
case PROP_APPINFO:
- app_menu_item_set_app_info (self, g_value_get_object (value));
+ app_section_set_app_info (self, g_value_get_object (value));
break;
default:
@@ -148,10 +147,10 @@ app_menu_item_set_property (GObject *object,
}
}
static void
-app_menu_item_dispose (GObject *object)
+app_section_dispose (GObject *object)
{
- AppMenuItem * self = APP_MENU_ITEM(object);
- AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self);
+ AppSection * self = APP_SECTION(object);
+ AppSectionPrivate * priv = APP_SECTION_GET_PRIVATE(self);
g_clear_object (&priv->menu);
g_clear_object (&priv->static_shortcuts);
@@ -166,7 +165,7 @@ app_menu_item_dispose (GObject *object)
priv->appinfo = NULL;
}
- G_OBJECT_CLASS (app_menu_item_parent_class)->dispose (object);
+ G_OBJECT_CLASS (app_section_parent_class)->dispose (object);
}
/* Respond to one of the shortcuts getting clicked on. */
@@ -176,8 +175,8 @@ nick_activate_cb (GSimpleAction *action,
gpointer userdata)
{
const gchar * nick = g_action_get_name (G_ACTION (action));
- AppMenuItem * mi = APP_MENU_ITEM (userdata);
- AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(mi);
+ AppSection * mi = APP_SECTION (userdata);
+ AppSectionPrivate * priv = APP_SECTION_GET_PRIVATE(mi);
g_return_if_fail(priv->ids != NULL);
@@ -188,10 +187,10 @@ nick_activate_cb (GSimpleAction *action,
}
static void
-app_menu_item_set_app_info (AppMenuItem *self,
+app_section_set_app_info (AppSection *self,
GDesktopAppInfo *appinfo)
{
- AppMenuItemPrivate *priv = APP_MENU_ITEM_GET_PRIVATE (self);
+ AppSectionPrivate *priv = APP_SECTION_GET_PRIVATE (self);
GSimpleAction *launch;
GMenuItem *menuitem;
GIcon *icon;
@@ -215,9 +214,9 @@ app_menu_item_set_app_info (AppMenuItem *self,
g_simple_action_group_insert (priv->static_shortcuts, G_ACTION (launch));
if (priv->unreadcount > 0)
- label = g_strdup_printf("%s (%d)", app_menu_item_get_name (self), priv->unreadcount);
+ label = g_strdup_printf("%s (%d)", app_section_get_name (self), priv->unreadcount);
else
- label = g_strdup(app_menu_item_get_name (self));
+ label = g_strdup(app_section_get_name (self));
menuitem = g_menu_item_new (label, "launch");
g_menu_item_set_attribute (menuitem, INDICATOR_MENU_ATTRIBUTE_ICON_NAME, "s", iconstr);
@@ -251,10 +250,10 @@ app_menu_item_set_app_info (AppMenuItem *self,
g_object_unref (menuitem);
}
-AppMenuItem *
-app_menu_item_new (GDesktopAppInfo *appinfo)
+AppSection *
+app_section_new (GDesktopAppInfo *appinfo)
{
- return g_object_new (APP_MENU_ITEM_TYPE,
+ return g_object_new (APP_SECTION_TYPE,
"app-info", appinfo,
NULL);
}
@@ -264,8 +263,8 @@ activate_cb (GSimpleAction *action,
GVariant *param,
gpointer userdata)
{
- AppMenuItem * mi = APP_MENU_ITEM (userdata);
- AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(mi);
+ AppSection * mi = APP_SECTION (userdata);
+ AppSectionPrivate * priv = APP_SECTION_GET_PRIVATE(mi);
GError *error = NULL;
if (!g_app_info_launch (G_APP_INFO (priv->appinfo), NULL, NULL, &error)) {
@@ -275,19 +274,19 @@ activate_cb (GSimpleAction *action,
}
guint
-app_menu_item_get_count (AppMenuItem * appitem)
+app_section_get_count (AppSection * self)
{
- g_return_val_if_fail(IS_APP_MENU_ITEM(appitem), 0);
- AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(appitem);
+ g_return_val_if_fail(IS_APP_SECTION(self), 0);
+ AppSectionPrivate * priv = APP_SECTION_GET_PRIVATE(self);
return priv->unreadcount;
}
const gchar *
-app_menu_item_get_name (AppMenuItem * appitem)
+app_section_get_name (AppSection * self)
{
- g_return_val_if_fail(IS_APP_MENU_ITEM(appitem), NULL);
- AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(appitem);
+ g_return_val_if_fail(IS_APP_SECTION(self), NULL);
+ AppSectionPrivate * priv = APP_SECTION_GET_PRIVATE(self);
if (priv->appinfo) {
return g_app_info_get_name(G_APP_INFO(priv->appinfo));
@@ -296,10 +295,10 @@ app_menu_item_get_name (AppMenuItem * appitem)
}
const gchar *
-app_menu_item_get_desktop (AppMenuItem * appitem)
+app_section_get_desktop (AppSection * self)
{
- g_return_val_if_fail(IS_APP_MENU_ITEM(appitem), NULL);
- AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(appitem);
+ g_return_val_if_fail(IS_APP_SECTION(self), NULL);
+ AppSectionPrivate * priv = APP_SECTION_GET_PRIVATE(self);
if (priv->appinfo)
return g_desktop_app_info_get_filename (priv->appinfo);
else
@@ -307,16 +306,16 @@ app_menu_item_get_desktop (AppMenuItem * appitem)
}
GMenuModel *
-app_menu_item_get_menu (AppMenuItem *appitem)
+app_section_get_menu (AppSection *self)
{
- AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(appitem);
+ AppSectionPrivate * priv = APP_SECTION_GET_PRIVATE(self);
return G_MENU_MODEL (priv->menu);
}
GAppInfo *
-app_menu_item_get_app_info (AppMenuItem *appitem)
+app_section_get_app_info (AppSection *self)
{
- AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(appitem);
+ AppSectionPrivate * priv = APP_SECTION_GET_PRIVATE(self);
return G_APP_INFO (priv->appinfo);
}
diff --git a/src/app-section.h b/src/app-section.h
new file mode 100644
index 0000000..7989824
--- /dev/null
+++ b/src/app-section.h
@@ -0,0 +1,58 @@
+/*
+An indicator to show information that is in messaging applications
+that the user is using.
+
+Copyright 2009 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 __APP_SECTION_H__
+#define __APP_SECTION_H__
+
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+#define APP_SECTION_TYPE (app_section_get_type ())
+#define APP_SECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APP_SECTION_TYPE, AppSection))
+#define APP_SECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APP_SECTION_TYPE, AppSectionClass))
+#define IS_APP_SECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APP_SECTION_TYPE))
+#define IS_APP_SECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APP_SECTION_TYPE))
+#define APP_SECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APP_SECTION_TYPE, AppSectionClass))
+
+typedef struct _AppSection AppSection;
+typedef struct _AppSectionClass AppSectionClass;
+
+struct _AppSectionClass {
+ GObjectClass parent_class;
+};
+
+struct _AppSection {
+ GObject parent;
+};
+
+GType app_section_get_type (void);
+AppSection * app_section_new (GDesktopAppInfo *appinfo);
+guint app_section_get_count (AppSection * appitem);
+const gchar * app_section_get_name (AppSection * appitem);
+const gchar * app_section_get_desktop (AppSection * appitem);
+GMenuModel * app_section_get_menu (AppSection *appitem);
+GAppInfo * app_section_get_app_info (AppSection *appitem);
+
+G_END_DECLS
+
+#endif /* __APP_SECTION_H__ */
+
diff --git a/src/messages-service.c b/src/messages-service.c
index 134c4ee..dcce1c5 100644
--- a/src/messages-service.c
+++ b/src/messages-service.c
@@ -30,7 +30,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <gio/gdesktopappinfo.h>
#include <glib/gi18n.h>
-#include "app-menu-item.h"
+#include "app-section.h"
#include "dbus-data.h"
#include "messages-service-dbus.h"
#include "status-items.h"
@@ -63,14 +63,14 @@ add_application (const gchar *desktop_id,
desktop_file = g_desktop_app_info_get_filename (appinfo);
if (!g_hash_table_lookup (applications, desktop_file)) {
- AppMenuItem *menuitem = app_menu_item_new(appinfo);
+ AppSection *section = app_section_new(appinfo);
/* TODO insert it at the right position (alphabetically by application name) */
g_menu_insert_section (menu, 2,
- app_menu_item_get_name (menuitem),
- app_menu_item_get_menu (menuitem));
+ app_section_get_name (section),
+ app_section_get_menu (section));
- g_hash_table_insert (applications, g_strdup (desktop_file), menuitem);
+ g_hash_table_insert (applications, g_strdup (desktop_file), section);
}
g_object_unref (appinfo);
@@ -101,7 +101,7 @@ remove_application (const char *desktop_id)
{
GDesktopAppInfo *appinfo;
const gchar *desktop_file;
- AppMenuItem *menuitem;
+ AppSection *section;
appinfo = g_desktop_app_info_new (desktop_id);
if (!appinfo) {
@@ -111,9 +111,9 @@ remove_application (const char *desktop_id)
desktop_file = g_desktop_app_info_get_filename (appinfo);
- menuitem = g_hash_table_lookup (applications, desktop_file);
- if (menuitem) {
- int pos = g_menu_find_section (menu, app_menu_item_get_menu (menuitem));
+ section = g_hash_table_lookup (applications, desktop_file);
+ if (section) {
+ int pos = g_menu_find_section (menu, app_section_get_menu (section));
if (pos >= 0)
g_menu_remove (menu, pos);
}
diff --git a/test/Makefile.am b/test/Makefile.am
index 847d857..2b0f67e 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -40,7 +40,7 @@ lib_LTLIBRARIES = \
libindicator_messages_service_la_HEADERS = \
$(top_srcdir)/src/gen-messages-service.xml.h \
- $(top_srcdir)/src/app-menu-item.h \
+ $(top_srcdir)/src/app-section.h \
$(top_srcdir)/src/dbus-data.h \
$(top_srcdir)/src/status-items.h
@@ -48,7 +48,7 @@ libindicator_messages_service_la_SOURCES = \
$(top_srcdir)/src/messages-service.c \
$(top_srcdir)/src/messages-service-dbus.c \
$(top_srcdir)/src/gen-messages-service.xml.c \
- $(top_srcdir)/src/app-menu-item.c \
+ $(top_srcdir)/src/app-section.c \
$(top_srcdir)/src/status-items.c
libindicator_messages_service_ladir = \