aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-08-27 10:10:18 -0500
committerTed Gould <ted@canonical.com>2009-08-27 10:10:18 -0500
commit3f3da424ad9598486672ac43a531bd7565d765a8 (patch)
tree84cfbeb206edaf98c56e90f27eb9931e5a7fd1ee
parentec04bfc2ba1caed976374344ae7bf7fb71cad38c (diff)
parent86cab293762c8b864a58f3e297c057cc05794daf (diff)
downloadayatana-indicator-messages-3f3da424ad9598486672ac43a531bd7565d765a8.tar.gz
ayatana-indicator-messages-3f3da424ad9598486672ac43a531bd7565d765a8.tar.bz2
ayatana-indicator-messages-3f3da424ad9598486672ac43a531bd7565d765a8.zip
Merging in a branch that updates to the new dbusmenu but also uses it to add a custom launcher item.
-rw-r--r--configure.ac2
-rw-r--r--src/app-menu-item.c4
-rw-r--r--src/dbus-data.h4
-rw-r--r--src/im-menu-item.c2
-rw-r--r--src/indicator-messages.c41
-rw-r--r--src/launcher-menu-item.c32
-rw-r--r--src/launcher-menu-item.h1
-rw-r--r--src/messages-service.c2
8 files changed, 67 insertions, 21 deletions
diff --git a/configure.ac b/configure.ac
index 19a549c..d9962a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,7 +28,7 @@ GIO_UNIX_REQUIRED_VERSION=2.18
PANEL_REQUIRED_VERSION=2.0.0
INDICATE_REQUIRED_VERSION=0.2.0
INDICATOR_REQUIRED_VERSION=0.2.0
-DBUSMENUGTK_REQUIRED_VERSION=0.0.0
+DBUSMENUGTK_REQUIRED_VERSION=0.0.2
PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION
gio-unix-2.0 >= $GIO_UNIX_REQUIRED_VERSION
diff --git a/src/app-menu-item.c b/src/app-menu-item.c
index 3a2c795..feb780d 100644
--- a/src/app-menu-item.c
+++ b/src/app-menu-item.c
@@ -218,10 +218,10 @@ update_label (AppMenuItem * self)
/* 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);
- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "label", label);
+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_LABEL, label);
g_free(label);
} else {
- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "label", app_menu_item_get_name(self));
+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_LABEL, app_menu_item_get_name(self));
}
return;
diff --git a/src/dbus-data.h b/src/dbus-data.h
index e7d4d26..db59003 100644
--- a/src/dbus-data.h
+++ b/src/dbus-data.h
@@ -8,4 +8,8 @@
#define INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT "/org/ayatana/indicator/messages/service"
#define INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE "org.ayatana.indicator.messages.service"
+#define LAUNCHER_MENUITEM_TYPE "launcher-item"
+#define LAUNCHER_MENUITEM_PROP_APP_NAME "application-name"
+#define LAUNCHER_MENUITEM_PROP_APP_DESC "application-description"
+
#endif /* __DBUS_DATA_H__ */
diff --git a/src/im-menu-item.c b/src/im-menu-item.c
index d35684e..008e33f 100644
--- a/src/im-menu-item.c
+++ b/src/im-menu-item.c
@@ -253,7 +253,7 @@ sender_cb (IndicateListener * listener, IndicateListenerServer * server, Indicat
return;
}
- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "label", propertydata);
+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_LABEL, propertydata);
return;
}
diff --git a/src/indicator-messages.c b/src/indicator-messages.c
index 0d2854b..c410ef7 100644
--- a/src/indicator-messages.c
+++ b/src/indicator-messages.c
@@ -21,6 +21,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
+#include <glib.h>
#include <gtk/gtk.h>
#include <libdbusmenu-gtk/menu.h>
#include <dbus/dbus-glib.h>
@@ -136,6 +137,39 @@ setup_icon_proxy (gpointer userdata)
return FALSE;
}
+static gboolean
+new_launcher_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
+{
+ g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
+ g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
+ /* Note: not checking parent, it's reasonable for it to be NULL */
+
+ GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new());
+
+ GtkWidget * vbox = gtk_vbox_new(TRUE, 2);
+
+ GtkWidget * app_label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, LAUNCHER_MENUITEM_PROP_APP_NAME));
+ gtk_misc_set_alignment(GTK_MISC(app_label), 0.0, 0.5);
+ GtkWidget * dsc_label = gtk_label_new("");
+ gtk_misc_set_alignment(GTK_MISC(dsc_label), 0.05, 0.5);
+ gtk_label_set_ellipsize(GTK_LABEL(dsc_label), PANGO_ELLIPSIZE_END);
+ gchar * markup = g_markup_printf_escaped("<span font-size=\"smaller\">%s</span>", dbusmenu_menuitem_property_get(newitem, LAUNCHER_MENUITEM_PROP_APP_DESC));
+ gtk_label_set_markup(GTK_LABEL(dsc_label), markup);
+ g_free(markup);
+
+ gtk_box_pack_start(GTK_BOX(vbox), app_label, FALSE, FALSE, 0);
+ gtk_widget_show(app_label);
+ gtk_box_pack_start(GTK_BOX(vbox), dsc_label, FALSE, FALSE, 0);
+ gtk_widget_show(dsc_label);
+
+ gtk_container_add(GTK_CONTAINER(gmi), GTK_WIDGET(vbox));
+ gtk_widget_show(GTK_WIDGET(vbox));
+
+ dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent);
+
+ return TRUE;
+}
+
GtkLabel *
get_label (void)
{
@@ -175,6 +209,11 @@ get_menu (void)
g_idle_add(setup_icon_proxy, NULL);
- return GTK_MENU(dbusmenu_gtkmenu_new(INDICATOR_MESSAGES_DBUS_NAME, INDICATOR_MESSAGES_DBUS_OBJECT));
+ DbusmenuGtkMenu * menu = dbusmenu_gtkmenu_new(INDICATOR_MESSAGES_DBUS_NAME, INDICATOR_MESSAGES_DBUS_OBJECT);
+ DbusmenuGtkClient * client = dbusmenu_gtkmenu_get_client(menu);
+
+ dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), LAUNCHER_MENUITEM_TYPE, new_launcher_item);
+
+ return GTK_MENU(menu);
}
diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c
index 802575f..822196b 100644
--- a/src/launcher-menu-item.c
+++ b/src/launcher-menu-item.c
@@ -28,6 +28,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <glib/gi18n.h>
#include <gio/gdesktopappinfo.h>
#include "launcher-menu-item.h"
+#include "dbus-data.h"
enum {
NAME_CHANGED,
@@ -130,7 +131,9 @@ launcher_menu_item_new (const gchar * 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));
+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "type", LAUNCHER_MENUITEM_TYPE);
+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), LAUNCHER_MENUITEM_PROP_APP_NAME, launcher_menu_item_get_name(self));
+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), LAUNCHER_MENUITEM_PROP_APP_DESC, launcher_menu_item_get_description(self));
g_signal_connect(G_OBJECT(self), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), NULL);
@@ -157,23 +160,12 @@ activate_cb (LauncherMenuItem * self, gpointer data)
LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(self);
g_return_if_fail(priv->appinfo != NULL);
- /* This should manage the X stuff for us */
- GdkAppLaunchContext * context = gdk_app_launch_context_new();
-
- /* Using the current time as we don't have the event
- time as that's not sent across the bus */
- GTimeVal time;
- g_get_current_time(&time);
- gdk_app_launch_context_set_timestamp(context, time.tv_usec / 1000);
-
GError * error = NULL;
- if (!g_app_info_launch(priv->appinfo, NULL, G_APP_LAUNCH_CONTEXT(context), &error)) {
+ if (!g_app_info_launch(priv->appinfo, NULL, NULL, &error)) {
g_warning("Application failed to launch '%s' because: %s", launcher_menu_item_get_name(self), error->message);
g_error_free(error);
}
- g_object_unref(G_OBJECT(context));
-
return;
}
@@ -185,20 +177,30 @@ launcher_menu_item_get_desktop (LauncherMenuItem * launchitem)
return priv->desktop;
}
+/* Gets the decription for the item that should
+ go in the messaging menu */
+const gchar *
+launcher_menu_item_get_description (LauncherMenuItem * li)
+{
+ g_return_val_if_fail(IS_LAUNCHER_MENU_ITEM(li), NULL);
+ LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(li);
+ return g_app_info_get_description(priv->appinfo);
+}
+
/* Hides the menu item based on whether it is eclipsed
or not. */
void
launcher_menu_item_set_eclipsed (LauncherMenuItem * li, gboolean eclipsed)
{
g_debug("Laucher '%s' is %s", launcher_menu_item_get_name(li), eclipsed ? "now eclipsed" : "shown again");
- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li), "show", eclipsed ? "false" : "true");
+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li), DBUSMENU_MENUITEM_PROP_VISIBLE, eclipsed ? "false" : "true");
return;
}
gboolean
launcher_menu_item_get_eclipsed (LauncherMenuItem * li)
{
- const gchar * show = dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(li), "show");
+ const gchar * show = dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(li), DBUSMENU_MENUITEM_PROP_VISIBLE);
if (show == NULL) {
return FALSE;
}
diff --git a/src/launcher-menu-item.h b/src/launcher-menu-item.h
index 920194e..3e031d5 100644
--- a/src/launcher-menu-item.h
+++ b/src/launcher-menu-item.h
@@ -56,6 +56,7 @@ 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);
+const gchar * launcher_menu_item_get_description (LauncherMenuItem * li);
void launcher_menu_item_set_eclipsed (LauncherMenuItem * li, gboolean eclipsed);
gboolean launcher_menu_item_get_eclipsed (LauncherMenuItem * li);
diff --git a/src/messages-service.c b/src/messages-service.c
index a5af895..093ebfd 100644
--- a/src/messages-service.c
+++ b/src/messages-service.c
@@ -908,7 +908,7 @@ destroy_launcher (gpointer data)
g_list_free(li->appdiritems);
if (li->menuitem != NULL) {
- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li->menuitem), "visible", "false");
+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li->menuitem), DBUSMENU_MENUITEM_PROP_VISIBLE, "false");
dbusmenu_menuitem_child_delete(root_menuitem, DBUSMENU_MENUITEM(li->menuitem));
g_object_unref(G_OBJECT(li->menuitem));
li->menuitem = NULL;