From 21caab3ed3cbb70ec0f2929dd69d9f348162e975 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 13:32:34 -0500 Subject: Adding a get_description function --- src/launcher-menu-item.c | 10 ++++++++++ src/launcher-menu-item.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 6c79adb..6f005e9 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -185,6 +185,16 @@ 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 diff --git a/src/launcher-menu-item.h b/src/launcher-menu-item.h index 2b39073..9a46824 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); G_END_DECLS -- cgit v1.2.3 From 8078204a3c807df06e10be50376536ac102b3dd9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 16:06:20 -0500 Subject: show -> visible --- src/launcher-menu-item.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 802575f..100dd67 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -191,14 +191,14 @@ 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), "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), "visible"); if (show == NULL) { return FALSE; } -- cgit v1.2.3 From 482016974e086dbd2da6d5b093b4b80322cab4c8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 16:43:14 -0500 Subject: Locking to version 0.0.2 to use some of the new nicities --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v1.2.3 From 9449d49b38b2dfe2f9a0d90378877a801b6def03 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 16:47:55 -0500 Subject: Replacing the prop strings with defines --- src/app-menu-item.c | 4 ++-- src/im-menu-item.c | 2 +- src/launcher-menu-item.c | 6 +++--- src/messages-service.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) 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/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/launcher-menu-item.c b/src/launcher-menu-item.c index 100dd67..eb32e59 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -130,7 +130,7 @@ 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), DBUSMENU_MENUITEM_PROP_LABEL, launcher_menu_item_get_name(self)); g_signal_connect(G_OBJECT(self), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), NULL); @@ -191,14 +191,14 @@ 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), "visible", 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), "visible"); + const gchar * show = dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(li), DBUSMENU_MENUITEM_PROP_VISIBLE); if (show == NULL) { return FALSE; } 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; -- cgit v1.2.3 From 983f83536606972bd90e9f95377a8d1ced282720 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 17:27:39 -0500 Subject: Making ourselves a variable in the middle of everything. --- src/indicator-messages.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 0d2854b..80ab535 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -175,6 +175,8 @@ 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); + + return GTK_MENU(menu); } -- cgit v1.2.3 From bb8dfce7d1a137eeff3792862b3f9a27416f3836 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 17:29:53 -0500 Subject: Injecting in a type for the launchers. --- src/indicator-messages.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 80ab535..2aec8e9 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -136,6 +136,13 @@ setup_icon_proxy (gpointer userdata) return FALSE; } +static gboolean +new_launcher_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) +{ + + return TRUE; +} + GtkLabel * get_label (void) { @@ -176,6 +183,9 @@ get_menu (void) g_idle_add(setup_icon_proxy, NULL); 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-item", new_launcher_item); return GTK_MENU(menu); } -- cgit v1.2.3 From 96d5cadae1492a0d4db6e38f606be309e76ab0aa Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 20:06:09 -0500 Subject: Pulling the type and the properties into the shared DBus header. --- src/dbus-data.h | 4 ++++ src/indicator-messages.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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/indicator-messages.c b/src/indicator-messages.c index 2aec8e9..8762593 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -185,7 +185,7 @@ get_menu (void) 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-item", new_launcher_item); + dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), LAUNCHER_MENUITEM_TYPE, new_launcher_item); return GTK_MENU(menu); } -- cgit v1.2.3 From bab6bd250e02bb8a139ea4ad36fdee2b7b250544 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 20:20:02 -0500 Subject: Filling in the new launcher menu item --- src/indicator-messages.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 8762593..8838313 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -139,6 +139,22 @@ setup_icon_proxy (gpointer userdata) static gboolean new_launcher_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { + 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)); + GtkWidget * dsc_label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, LAUNCHER_MENUITEM_PROP_APP_DESC)); + + 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; } -- cgit v1.2.3 From 2273a4d1f95cf44edb1aad21849eda6fca358deb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 20:24:07 -0500 Subject: Setting the type of the item and app name --- src/launcher-menu-item.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index eb32e59..9c2dbeb 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -28,6 +28,7 @@ with this program. If not, see . #include #include #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), DBUSMENU_MENUITEM_PROP_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_name(self)); g_signal_connect(G_OBJECT(self), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), NULL); -- cgit v1.2.3 From d08632f2c21df15c8edf292910d63f144bb4a7a3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 20:26:13 -0500 Subject: Use that handy get_description function that we just merged in. Heh, wonder why we did that... --- src/launcher-menu-item.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 07598d7..6678cc5 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -133,7 +133,7 @@ launcher_menu_item_new (const gchar * desktop_file) g_debug("\tName: %s", 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_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); -- cgit v1.2.3 From 1077ceea42e73c4c9ef0f368913f18a9a3b092f8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 20:46:43 -0500 Subject: Adding a little style to our labels. Hopefully making them look a little nicer. --- src/indicator-messages.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 8838313..0a1002d 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -21,6 +21,7 @@ with this program. If not, see . */ #include +#include #include #include #include @@ -144,7 +145,13 @@ new_launcher_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusme GtkWidget * vbox = gtk_vbox_new(TRUE, 2); GtkWidget * app_label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, LAUNCHER_MENUITEM_PROP_APP_NAME)); - GtkWidget * dsc_label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, LAUNCHER_MENUITEM_PROP_APP_DESC)); + 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("%s", 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); -- cgit v1.2.3 From 6af9df41572d52b6115980ac2a1a98a74a71f9f1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 20:53:29 -0500 Subject: This stuff is crashing big time now. Not sure why it worked before, but not going to look into it now. --- src/launcher-menu-item.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 6678cc5..822196b 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -160,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; } -- cgit v1.2.3 -- cgit v1.2.3 From 86cab293762c8b864a58f3e297c057cc05794daf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 27 Aug 2009 09:31:43 -0500 Subject: Checking args from libdbusmenu, stealing code from there. Comments by Neil. --- src/indicator-messages.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 0a1002d..c410ef7 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -140,6 +140,10 @@ setup_icon_proxy (gpointer userdata) 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); -- cgit v1.2.3