aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac3
-rw-r--r--data/icons/16x16/categories/Makefile.am2
-rw-r--r--data/icons/16x16/status/Makefile.am2
-rw-r--r--data/icons/22x22/categories/Makefile.am2
-rw-r--r--data/icons/22x22/status/Makefile.am2
-rw-r--r--data/icons/24x24/status/Makefile.am2
-rw-r--r--data/icons/32x32/categories/Makefile.am2
-rw-r--r--data/icons/32x32/status/Makefile.am2
-rw-r--r--data/icons/48x48/status/Makefile.am2
-rw-r--r--data/icons/scalable/categories/Makefile.am2
-rw-r--r--data/icons/scalable/status/Makefile.am2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/app-section.c7
-rw-r--r--src/ido-menu-item.c395
-rw-r--r--src/ido-menu-item.h54
-rw-r--r--src/im-app-menu-item.c1
-rw-r--r--src/im-source-menu-item.c2
-rw-r--r--src/indicator-messages.c3
-rw-r--r--src/messages-service.c29
19 files changed, 495 insertions, 21 deletions
diff --git a/configure.ac b/configure.ac
index d9270dd..08560c6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -106,13 +106,10 @@ AC_ARG_ENABLE(localinstall, AS_HELP_STRING([--enable-localinstall], [install all
if test "x$with_localinstall" = "xyes"; then
INDICATORDIR="${libdir}/indicators/2/"
- INDICATORICONSDIR="${datadir}/libindicate/icons/"
else
INDICATORDIR=`$PKG_CONFIG --variable=indicatordir indicator3-0.4`
- INDICATORICONSDIR=`$PKG_CONFIG --variable=iconsdir indicator3-0.4`
fi
AC_SUBST(INDICATORDIR)
-AC_SUBST(INDICATORICONSDIR)
###########################
# DBus Service Info
diff --git a/data/icons/16x16/categories/Makefile.am b/data/icons/16x16/categories/Makefile.am
index 171e2f9..2ddfa63 100644
--- a/data/icons/16x16/categories/Makefile.am
+++ b/data/icons/16x16/categories/Makefile.am
@@ -1,5 +1,5 @@
-iconsdir = $(INDICATORICONSDIR)/hicolor/16x16/categories
+iconsdir = $(datadir)/icons/hicolor/16x16/categories
icons_DATA = \
applications-email-panel.png \
diff --git a/data/icons/16x16/status/Makefile.am b/data/icons/16x16/status/Makefile.am
index e9c66f1..adafb8c 100644
--- a/data/icons/16x16/status/Makefile.am
+++ b/data/icons/16x16/status/Makefile.am
@@ -1,5 +1,5 @@
-iconsdir = $(INDICATORICONSDIR)/hicolor/16x16/status
+iconsdir = $(datadir)/icons/hicolor/16x16/status
icons_DATA = \
application-running.png \
diff --git a/data/icons/22x22/categories/Makefile.am b/data/icons/22x22/categories/Makefile.am
index 02885d3..b1ea14c 100644
--- a/data/icons/22x22/categories/Makefile.am
+++ b/data/icons/22x22/categories/Makefile.am
@@ -1,5 +1,5 @@
-iconsdir = $(INDICATORICONSDIR)/hicolor/22x22/categories
+iconsdir = $(datadir)/icons/hicolor/22x22/categories
icons_DATA = \
applications-email-panel.png
diff --git a/data/icons/22x22/status/Makefile.am b/data/icons/22x22/status/Makefile.am
index f18bbcc..470c817 100644
--- a/data/icons/22x22/status/Makefile.am
+++ b/data/icons/22x22/status/Makefile.am
@@ -1,5 +1,5 @@
-iconsdir = $(INDICATORICONSDIR)/hicolor/22x22/status
+iconsdir = $(datadir)/icons/hicolor/22x22/status
icons_DATA = \
indicator-messages.png \
diff --git a/data/icons/24x24/status/Makefile.am b/data/icons/24x24/status/Makefile.am
index 7686c0e..086c404 100644
--- a/data/icons/24x24/status/Makefile.am
+++ b/data/icons/24x24/status/Makefile.am
@@ -1,5 +1,5 @@
-iconsdir = $(INDICATORICONSDIR)/hicolor/24x24/status
+iconsdir = $(datadir)/icons/hicolor/24x24/status
icons_DATA = \
application-running.png \
diff --git a/data/icons/32x32/categories/Makefile.am b/data/icons/32x32/categories/Makefile.am
index 3a74b80..6fcfb7b 100644
--- a/data/icons/32x32/categories/Makefile.am
+++ b/data/icons/32x32/categories/Makefile.am
@@ -1,5 +1,5 @@
-iconsdir = $(INDICATORICONSDIR)/hicolor/32x32/categories
+iconsdir = $(datadir)/icons/hicolor/32x32/categories
icons_DATA = \
applications-email-panel.png \
diff --git a/data/icons/32x32/status/Makefile.am b/data/icons/32x32/status/Makefile.am
index 84d9609..00f9d53 100644
--- a/data/icons/32x32/status/Makefile.am
+++ b/data/icons/32x32/status/Makefile.am
@@ -1,5 +1,5 @@
-iconsdir = $(INDICATORICONSDIR)/hicolor/32x32/status
+iconsdir = $(datadir)/icons/hicolor/32x32/status
icons_DATA = \
application-running.png \
diff --git a/data/icons/48x48/status/Makefile.am b/data/icons/48x48/status/Makefile.am
index ee7eb74..9c560b5 100644
--- a/data/icons/48x48/status/Makefile.am
+++ b/data/icons/48x48/status/Makefile.am
@@ -1,5 +1,5 @@
-iconsdir = $(INDICATORICONSDIR)/hicolor/48x48/status
+iconsdir = $(datadir)/icons/hicolor/48x48/status
icons_DATA = \
application-running.png \
diff --git a/data/icons/scalable/categories/Makefile.am b/data/icons/scalable/categories/Makefile.am
index 64ce622..0fdbbd7 100644
--- a/data/icons/scalable/categories/Makefile.am
+++ b/data/icons/scalable/categories/Makefile.am
@@ -1,5 +1,5 @@
-iconsdir = $(INDICATORICONSDIR)/hicolor/scalable/categories
+iconsdir = $(datadir)/icons/hicolor/scalable/categories
icons_DATA = \
applications-email-panel.svg \
diff --git a/data/icons/scalable/status/Makefile.am b/data/icons/scalable/status/Makefile.am
index 060b479..59f0256 100644
--- a/data/icons/scalable/status/Makefile.am
+++ b/data/icons/scalable/status/Makefile.am
@@ -1,5 +1,5 @@
-iconsdir = $(INDICATORICONSDIR)/hicolor/scalable/status
+iconsdir = $(datadir)/icons/hicolor/scalable/status
icons_DATA = \
application-running.svg \
diff --git a/src/Makefile.am b/src/Makefile.am
index 403a289..4d86730 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -15,6 +15,8 @@ messaginglibdir = $(INDICATORDIR)
messaginglib_LTLIBRARIES = libmessaging.la
libmessaging_la_SOURCES = \
indicator-messages.c \
+ ido-menu-item.c \
+ ido-menu-item.h \
im-app-menu-item.c \
im-app-menu-item.h \
im-source-menu-item.c \
diff --git a/src/app-section.c b/src/app-section.c
index baae21f..bed1302 100644
--- a/src/app-section.c
+++ b/src/app-section.c
@@ -346,6 +346,7 @@ app_section_set_app_info (AppSection *self,
for (i = 0; nicks[i] != NULL; i++) {
gchar *name;
GSimpleAction *action;
+ GMenuItem *item;
name = indicator_desktop_shortcuts_nick_get_name(priv->ids, nicks[i]);
@@ -354,8 +355,12 @@ app_section_set_app_info (AppSection *self,
g_simple_action_group_insert (priv->static_shortcuts, G_ACTION (action));
g_object_unref (action);
- g_menu_append (priv->menu, name, nicks[i]);
+ item = g_menu_item_new (name, nicks[i]);
+ g_menu_item_set_attribute (item, "x-canonical-type", "s", "IdoMenuItem");
+ g_menu_item_set_attribute (item, "x-canonical-icon", "s", ""); /* empty to get indentation */
+ g_menu_append_item (priv->menu, item);
+ g_object_unref (item);
g_free(name);
}
diff --git a/src/ido-menu-item.c b/src/ido-menu-item.c
new file mode 100644
index 0000000..6b19d2a
--- /dev/null
+++ b/src/ido-menu-item.c
@@ -0,0 +1,395 @@
+/*
+ * Copyright 2012 Canonical Ltd.
+ *
+ * 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/>.
+ *
+ * Authors:
+ * Lars Uebernickel <lars.uebernickel@canonical.com>
+ */
+
+#include "ido-menu-item.h"
+
+struct _IdoMenuItemPrivate
+{
+ GActionGroup *action_group;
+ gchar *action;
+ GVariant *target;
+
+ GtkWidget *icon;
+ GtkWidget *label;
+
+ gboolean has_indicator;
+ gboolean in_set_active;
+};
+
+enum
+{
+ PROP_0,
+ PROP_MENU_ITEM,
+ PROP_ACTION_GROUP,
+ NUM_PROPERTIES
+};
+
+static GParamSpec *properties[NUM_PROPERTIES];
+
+G_DEFINE_TYPE (IdoMenuItem, ido_menu_item, GTK_TYPE_CHECK_MENU_ITEM);
+
+static void
+ido_menu_item_constructed (GObject *object)
+{
+ IdoMenuItemPrivate *priv = IDO_MENU_ITEM (object)->priv;
+ GtkWidget *grid;
+
+ priv->icon = g_object_ref (gtk_image_new ());
+ gtk_widget_set_margin_right (priv->icon, 6);
+
+ priv->label = g_object_ref (gtk_label_new (""));
+
+ grid = gtk_grid_new ();
+ gtk_grid_attach (GTK_GRID (grid), priv->icon, 0, 0, 1, 1);
+ gtk_grid_attach (GTK_GRID (grid), priv->label, 1, 0, 1, 1);
+
+ gtk_container_add (GTK_CONTAINER (object), grid);
+ gtk_widget_show_all (grid);
+
+ G_OBJECT_CLASS (ido_menu_item_parent_class)->constructed (object);
+}
+
+static void
+ido_menu_item_set_active (IdoMenuItem *self,
+ gboolean active)
+{
+ /* HACK gtk_check_menu_item_set_active calls gtk_menu_item_activate.
+ * Make sure our activate handler doesn't toggle the action as a
+ * result of calling this function. */
+
+ self->priv->in_set_active = TRUE;
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (self), active);
+ self->priv->in_set_active = FALSE;
+}
+
+static void
+ido_menu_item_set_has_indicator (IdoMenuItem *self,
+ gboolean has_indicator)
+{
+ if (has_indicator == self->priv->has_indicator)
+ return;
+
+ self->priv->has_indicator = has_indicator;
+
+ gtk_widget_queue_resize (GTK_WIDGET (self));
+}
+
+static void
+ido_menu_item_set_state (IdoMenuItem *self,
+ GVariant *state)
+{
+ IdoMenuItemPrivate *priv = self->priv;
+
+ if (priv->target)
+ {
+ ido_menu_item_set_has_indicator (self, TRUE);
+ gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (self), TRUE);
+ ido_menu_item_set_active (self, g_variant_equal (priv->target, state));
+ }
+ else if (g_variant_is_of_type (state, G_VARIANT_TYPE_BOOLEAN))
+ {
+ ido_menu_item_set_has_indicator (self, TRUE);
+ gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (self), FALSE);
+ ido_menu_item_set_active (self, g_variant_get_boolean (state));
+ }
+ else
+ {
+ ido_menu_item_set_has_indicator (self, FALSE);
+ }
+}
+
+static void
+ido_menu_item_set_action_name (IdoMenuItem *self,
+ const gchar *action_name)
+{
+ IdoMenuItemPrivate *priv = self->priv;
+ gboolean enabled = FALSE;
+ GVariant *state;
+ const GVariantType *param_type;
+
+ if (priv->action != NULL)
+ g_free (priv->action);
+
+ priv->action = g_strdup (action_name);
+
+ if (priv->action_group != NULL && priv->action != NULL &&
+ g_action_group_query_action (priv->action_group, priv->action,
+ &enabled, &param_type, NULL, NULL, &state))
+ {
+ gtk_widget_set_sensitive (GTK_WIDGET (self), enabled);
+
+ if (state)
+ {
+ ido_menu_item_set_state (self, state);
+ g_variant_unref (state);
+ }
+ }
+ else
+ {
+ ido_menu_item_set_active (self, FALSE);
+ gtk_widget_set_sensitive (GTK_WIDGET (self), FALSE);
+ ido_menu_item_set_has_indicator (self, FALSE);
+ }
+}
+
+static void
+ido_menu_item_action_added (GActionGroup *action_group,
+ gchar *action_name,
+ gpointer user_data)
+{
+ IdoMenuItem *self = user_data;
+
+ if (g_strcmp0 (self->priv->action, action_name) == 0)
+ ido_menu_item_set_action_name (self, action_name);
+}
+
+static void
+ido_menu_item_action_removed (GActionGroup *action_group,
+ gchar *action_name,
+ gpointer user_data)
+{
+ IdoMenuItem *self = user_data;
+
+ if (g_strcmp0 (self->priv->action, action_name) == 0)
+ {
+ gtk_widget_set_sensitive (GTK_WIDGET (self), FALSE);
+ }
+}
+
+static void
+ido_menu_item_action_enabled_changed (GActionGroup *action_group,
+ gchar *action_name,
+ gboolean enabled,
+ gpointer user_data)
+{
+ IdoMenuItem *self = user_data;
+
+ if (g_strcmp0 (self->priv->action, action_name) == 0)
+ gtk_widget_set_sensitive (GTK_WIDGET (self), enabled);
+}
+
+static void
+ido_menu_item_action_state_changed (GActionGroup *action_group,
+ gchar *action_name,
+ GVariant *value,
+ gpointer user_data)
+{
+ IdoMenuItem *self = user_data;
+
+ if (g_strcmp0 (self->priv->action, action_name) == 0)
+ ido_menu_item_set_state (self, value);
+}
+
+static void
+ido_menu_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ IdoMenuItem *self = IDO_MENU_ITEM (object);
+
+ switch (property_id)
+ {
+ case PROP_MENU_ITEM:
+ ido_menu_item_set_menu_item (self, G_MENU_ITEM (g_value_get_object (value)));
+ break;
+
+ case PROP_ACTION_GROUP:
+ ido_menu_item_set_action_group (self, G_ACTION_GROUP (g_value_get_object (value)));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+ido_menu_item_dispose (GObject *object)
+{
+ IdoMenuItem *self = IDO_MENU_ITEM (object);
+
+ if (self->priv->action_group)
+ ido_menu_item_set_action_group (self, NULL);
+
+ g_clear_object (&self->priv->icon);
+ g_clear_object (&self->priv->label);
+
+ if (self->priv->target)
+ {
+ g_variant_unref (self->priv->target);
+ self->priv->target = NULL;
+ }
+
+ G_OBJECT_CLASS (ido_menu_item_parent_class)->dispose (object);
+}
+
+static void
+ido_menu_item_finalize (GObject *object)
+{
+ IdoMenuItemPrivate *priv = IDO_MENU_ITEM (object)->priv;
+
+ g_free (priv->action);
+
+ G_OBJECT_CLASS (ido_menu_item_parent_class)->finalize (object);
+}
+
+static void
+ido_menu_item_activate (GtkMenuItem *item)
+{
+ IdoMenuItemPrivate *priv = IDO_MENU_ITEM (item)->priv;
+
+ /* see ido_menu_item_set_active */
+ if (!priv->in_set_active && priv->action && priv->action_group)
+ g_action_group_activate_action (priv->action_group, priv->action, priv->target);
+
+ GTK_MENU_ITEM_CLASS (ido_menu_item_parent_class)->activate (item);
+}
+
+static void
+ido_menu_item_draw_indicator (GtkCheckMenuItem *item,
+ cairo_t *cr)
+{
+ IdoMenuItem *self = IDO_MENU_ITEM (item);
+
+ if (self->priv->has_indicator)
+ GTK_CHECK_MENU_ITEM_CLASS (ido_menu_item_parent_class)
+ ->draw_indicator (item, cr);
+}
+
+static void
+ido_menu_item_class_init (IdoMenuItemClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkMenuItemClass *menu_item_class = GTK_MENU_ITEM_CLASS (klass);
+ GtkCheckMenuItemClass *check_class = GTK_CHECK_MENU_ITEM_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (IdoMenuItemPrivate));
+
+ object_class->constructed = ido_menu_item_constructed;
+ object_class->set_property = ido_menu_set_property;
+ object_class->dispose = ido_menu_item_dispose;
+ object_class->finalize = ido_menu_item_finalize;
+
+ menu_item_class->activate = ido_menu_item_activate;
+
+ check_class->draw_indicator = ido_menu_item_draw_indicator;
+
+ properties[PROP_MENU_ITEM] = g_param_spec_object ("menu-item",
+ "Menu item",
+ "The model GMenuItem for this menu item",
+ G_TYPE_MENU_ITEM,
+ G_PARAM_WRITABLE |
+ G_PARAM_STATIC_STRINGS);
+
+ properties[PROP_ACTION_GROUP] = g_param_spec_object ("action-group",
+ "Action group",
+ "The action group associated with this menu item",
+ G_TYPE_ACTION_GROUP,
+ G_PARAM_WRITABLE |
+ G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, NUM_PROPERTIES, properties);
+}
+
+static void
+ido_menu_item_init (IdoMenuItem *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ IDO_TYPE_MENU_ITEM,
+ IdoMenuItemPrivate);
+}
+
+void
+ido_menu_item_set_menu_item (IdoMenuItem *self,
+ GMenuItem *menuitem)
+{
+ gchar *iconstr = NULL;
+ GIcon *icon = NULL;
+ gchar *label = NULL;
+ gchar *action = NULL;
+
+ if (g_menu_item_get_attribute (menuitem, "x-canonical-icon", "s", &iconstr))
+ {
+ GError *error;
+
+ /* only indent the label if icon is set to "" */
+ if (iconstr[0] == '\0')
+ {
+ gint width;
+
+ gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, NULL);
+ gtk_widget_set_size_request (self->priv->icon, width, -1);
+ }
+ else
+ {
+ icon = g_icon_new_for_string (iconstr, &error);
+ if (icon == NULL)
+ {
+ g_warning ("unable to set icon: %s", error->message);
+ g_error_free (error);
+ }
+ }
+ g_free (iconstr);
+ }
+ gtk_image_set_from_gicon (GTK_IMAGE (self->priv->icon), icon, GTK_ICON_SIZE_MENU);
+
+ g_menu_item_get_attribute (menuitem, "label", "s", &label);
+ gtk_label_set_label (GTK_LABEL (self->priv->label), label ? label : "");
+
+ self->priv->target = g_menu_item_get_attribute_value (menuitem, "target", NULL);
+
+ g_menu_item_get_attribute (menuitem, "action", "s", &action);
+ ido_menu_item_set_action_name (self, action);
+
+ if (icon)
+ g_object_unref (icon);
+ g_free (label);
+ g_free (action);
+}
+
+void
+ido_menu_item_set_action_group (IdoMenuItem *self,
+ GActionGroup *action_group)
+{
+ IdoMenuItemPrivate *priv = self->priv;
+
+ if (priv->action_group != NULL)
+ {
+ g_signal_handlers_disconnect_by_func (priv->action_group, ido_menu_item_action_added, self);
+ g_signal_handlers_disconnect_by_func (priv->action_group, ido_menu_item_action_removed, self);
+ g_signal_handlers_disconnect_by_func (priv->action_group, ido_menu_item_action_enabled_changed, self);
+ g_signal_handlers_disconnect_by_func (priv->action_group, ido_menu_item_action_state_changed, self);
+
+ g_clear_object (&priv->action_group);
+ }
+
+ if (action_group != NULL)
+ {
+ priv->action_group = g_object_ref (action_group);
+
+ g_signal_connect (priv->action_group, "action-added",
+ G_CALLBACK (ido_menu_item_action_added), self);
+ g_signal_connect (priv->action_group, "action-removed",
+ G_CALLBACK (ido_menu_item_action_removed), self);
+ g_signal_connect (priv->action_group, "action-enabled-changed",
+ G_CALLBACK (ido_menu_item_action_enabled_changed), self);
+ g_signal_connect (priv->action_group, "action-state-changed",
+ G_CALLBACK (ido_menu_item_action_state_changed), self);
+ }
+}
diff --git a/src/ido-menu-item.h b/src/ido-menu-item.h
new file mode 100644
index 0000000..0521928
--- /dev/null
+++ b/src/ido-menu-item.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2012 Canonical Ltd.
+ *
+ * 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/>.
+ *
+ * Authors:
+ * Lars Uebernickel <lars.uebernickel@canonical.com>
+ */
+
+#ifndef __IDO_MENU_ITEM_H__
+#define __IDO_MENU_ITEM_H__
+
+#include <gtk/gtk.h>
+
+#define IDO_TYPE_MENU_ITEM (ido_menu_item_get_type ())
+#define IDO_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IDO_TYPE_MENU_ITEM, IdoMenuItem))
+#define IDO_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IDO_TYPE_MENU_ITEM, IdoMenuItemClass))
+#define IS_IDO_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IDO_TYPE_MENU_ITEM))
+#define IS_IDO_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IDO_TYPE_MENU_ITEM))
+#define IDO_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IDO_TYPE_MENU_ITEM, IdoMenuItemClass))
+
+typedef struct _IdoMenuItem IdoMenuItem;
+typedef struct _IdoMenuItemClass IdoMenuItemClass;
+typedef struct _IdoMenuItemPrivate IdoMenuItemPrivate;
+
+struct _IdoMenuItemClass
+{
+ GtkCheckMenuItemClass parent_class;
+};
+
+struct _IdoMenuItem
+{
+ GtkCheckMenuItem parent;
+ IdoMenuItemPrivate *priv;
+};
+
+GType ido_menu_item_get_type (void);
+
+void ido_menu_item_set_menu_item (IdoMenuItem *item,
+ GMenuItem *menuitem);
+void ido_menu_item_set_action_group (IdoMenuItem *self,
+ GActionGroup *action_group);
+
+#endif
diff --git a/src/im-app-menu-item.c b/src/im-app-menu-item.c
index eddf562..a204631 100644
--- a/src/im-app-menu-item.c
+++ b/src/im-app-menu-item.c
@@ -48,6 +48,7 @@ im_app_menu_item_constructed (GObject *object)
GtkWidget *grid;
priv->icon = g_object_ref (gtk_image_new ());
+ gtk_widget_set_margin_right (priv->icon, 6);
priv->label = g_object_ref (gtk_label_new (""));
diff --git a/src/im-source-menu-item.c b/src/im-source-menu-item.c
index 43c0afb..5aebb68 100644
--- a/src/im-source-menu-item.c
+++ b/src/im-source-menu-item.c
@@ -56,7 +56,7 @@ im_source_menu_item_constructed (GObject *object)
gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &icon_width, NULL);
priv->icon = g_object_ref (gtk_image_new ());
- gtk_widget_set_margin_left (priv->icon, icon_width + 2);
+ gtk_widget_set_margin_left (priv->icon, icon_width + 6);
priv->label = g_object_ref (gtk_label_new (""));
diff --git a/src/indicator-messages.c b/src/indicator-messages.c
index 4f5a012..942e46f 100644
--- a/src/indicator-messages.c
+++ b/src/indicator-messages.c
@@ -32,11 +32,11 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <libindicator/indicator.h>
#include <libindicator/indicator-object.h>
-#include <libindicator/indicator-image-helper.h>
#include <libindicator/indicator-service-manager.h>
#include "dbus-data.h"
+#include "ido-menu-item.h"
#include "im-app-menu-item.h"
#include "im-source-menu-item.h"
@@ -130,6 +130,7 @@ indicator_messages_init (IndicatorMessages *self)
/* make sure custom menu item types are registered (so that
* gtk_model_new_from_menu can pick them up */
+ ido_menu_item_get_type ();
im_app_menu_item_get_type ();
im_source_menu_item_get_type ();
}
diff --git a/src/messages-service.c b/src/messages-service.c
index 31d2a5b..15c5123 100644
--- a/src/messages-service.c
+++ b/src/messages-service.c
@@ -406,14 +406,33 @@ static GMenuModel *
create_status_section (void)
{
GMenu *menu;
+ GMenuItem *item;
+ struct status_item {
+ gchar *label;
+ gchar *action;
+ gchar *icon_name;
+ } status_items[] = {
+ { _("Available"), "status::available", "user-available" },
+ { _("Away"), "status::away", "user-away" },
+ { _("Busy"), "status::busy", "user-busy" },
+ { _("Invisible"), "status::invisible", "user-invisible" },
+ { _("Offline"), "status::offline", "user-offline" }
+ };
+ int i;
menu = g_menu_new ();
- g_menu_append_with_icon_name (menu, _("Available"), "user-available", "status::available");
- g_menu_append_with_icon_name (menu, _("Away"), "user-away", "status::away");
- g_menu_append_with_icon_name (menu, _("Busy"), "user-busy", "status::busy");
- g_menu_append_with_icon_name (menu, _("Invisible"), "user-invisible", "status::invisible");
- g_menu_append_with_icon_name (menu, _("Offline"), "user-offline", "status::offline");
+ item = g_menu_item_new (NULL, NULL);
+ g_menu_item_set_attribute (item, "x-canonical-type", "s", "IdoMenuItem");
+
+ for (i = 0; i < G_N_ELEMENTS (status_items); i++) {
+ g_menu_item_set_label (item, status_items[i].label);
+ g_menu_item_set_detailed_action (item, status_items[i].action);
+ g_menu_item_set_attribute (item, "x-canonical-icon", "s", status_items[i].icon_name);
+ g_menu_append_item (menu, item);
+ }
+
+ g_object_unref (item);
return G_MENU_MODEL (menu);
}