From de1ea7a175f0913b5a5421e666dd2d38d864fe47 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 8 Nov 2010 11:19:19 -0500 Subject: Adding an API function to build the menu from a desktop file --- src/app-indicator.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 4f7daa8..4734b80 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -2106,3 +2106,18 @@ app_indicator_get_ordering_index (AppIndicator *self) } } +/** + app_indicator_build_menu_from_desktop: + @self: The #AppIndicator object to use + @desktop_file: A path to the desktop file to build the menu from + + This function allows for building the Application Indicator menu + from a static desktop file. +*/ +void +app_indicator_build_menu_from_desktop (AppIndicator * self, const gchar * desktop_file) +{ + + + +} -- cgit v1.2.3 From d2427bba3a731af3db25878f7e63fd2a83a3243e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 8 Nov 2010 11:25:40 -0500 Subject: Adding the profile in there --- src/app-indicator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 4734b80..1805bd5 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -2115,7 +2115,7 @@ app_indicator_get_ordering_index (AppIndicator *self) from a static desktop file. */ void -app_indicator_build_menu_from_desktop (AppIndicator * self, const gchar * desktop_file) +app_indicator_build_menu_from_desktop (AppIndicator * self, const gchar * desktop_file, const gchar * desktop_profile) { -- cgit v1.2.3 From 9f0ec1f915156311d8de7a629782252a4bce6e41 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 16:57:22 -0600 Subject: Start to flesh out the nicks side of building the menu items --- src/app-indicator.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 1805bd5..dc88e9b 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -37,6 +37,8 @@ License version 3 and version 2.1 along with this program. If not, see #include #include +#include + #include "app-indicator.h" #include "app-indicator-enum-types.h" #include "application-service-marshal.h" @@ -2106,6 +2108,18 @@ app_indicator_get_ordering_index (AppIndicator *self) } } +#define APP_INDICATOR_SHORTY_NICK "app-indicator-shorty-nick" + +/* Callback when an item from the desktop shortcuts gets + called. */ +static void +shorty_activated_cb (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) +{ + + + return; +} + /** app_indicator_build_menu_from_desktop: @self: The #AppIndicator object to use @@ -2118,6 +2132,30 @@ void app_indicator_build_menu_from_desktop (AppIndicator * self, const gchar * desktop_file, const gchar * desktop_profile) { + /* Build a new shortcuts object */ + IndicatorDesktopShortcuts * shorties = indicator_desktop_shortcuts_new(desktop_file, desktop_profile); + g_return_if_fail(shorties != NULL); + const gchar ** nicks = indicator_desktop_shortcuts_get_nicks(shorties); + int nick_num; + /* Place the items on a dbusmenu */ + DbusmenuMenuitem * root = dbusmenu_menuitem_new(); + + for (nick_num = 0; nicks[nick_num] != NULL; nick_num++) { + DbusmenuMenuitem * item = dbusmenu_menuitem_new(); + g_object_set_data(G_OBJECT(item), APP_INDICATOR_SHORTY_NICK, (gpointer)nicks[nick_num]); + + gchar * name = indicator_desktop_shortcuts_nick_get_name(shorties, nicks[nick_num]); + dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_LABEL, name); + g_free(name); + + g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(shorty_activated_cb), self); + + dbusmenu_menuitem_child_append(root, item); + } + + /* Swap it if needed */ + + return; } -- cgit v1.2.3 From 1ec2b70ac16b031a4c7cc5398e9fb7a17bef4e4c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 20:10:54 -0600 Subject: Create a property for the dbusmenu server --- src/app-indicator.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 4f7daa8..25599a7 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -34,6 +34,7 @@ License version 3 and version 2.1 along with this program. If not, see #include #include +#include #include #include @@ -121,7 +122,8 @@ enum { PROP_X_LABEL, PROP_X_LABEL_GUIDE, PROP_ORDERING_INDEX, - PROP_X_ORDERING_INDEX + PROP_X_ORDERING_INDEX, + PROP_DBUS_MENU_SERVER }; /* The strings so that they can be slowly looked up. */ @@ -139,6 +141,7 @@ enum { #define PROP_X_LABEL_GUIDE_S ("x-ayatana-" PROP_LABEL_GUIDE_S) #define PROP_ORDERING_INDEX_S "ordering-index" #define PROP_X_ORDERING_INDEX_S ("x-ayatana-" PROP_ORDERING_INDEX_S) +#define PROP_DBUS_MENU_SERVER_S "dbus-menu-server" /* Private macro, shhhh! */ #define APP_INDICATOR_GET_PRIVATE(o) \ @@ -406,6 +409,19 @@ app_indicator_class_init (AppIndicatorClass *klass) "A wrapper, please don't use.", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** + AppIndicator:dbus-menu-server: + + A way to get the internal dbusmenu server if it is available. + This should only be used for testing. + */ + g_object_class_install_property(object_class, + PROP_DBUS_MENU_SERVER, + g_param_spec_object (PROP_DBUS_MENU_SERVER_S, + "The internal DBusmenu Server", + "DBusmenu server which is available for testing the application indicators.", + DBUSMENU_TYPE_MENUITEM, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /* Signals */ -- cgit v1.2.3 From 00758f364ae486352c0e2aa076710ae74e3ce190 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 20:17:51 -0600 Subject: Set and Get for the dbusmenu server property --- src/app-indicator.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 25599a7..fd035ac 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -810,6 +810,14 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu priv->ordering_index = g_value_get_uint(value); break; + case PROP_DBUS_MENU_SERVER: + if (priv->menuservice != NULL) { + g_object_unref (priv->menuservice); + } + gpointer val = g_value_dup_object(value); + priv->menuservice = DBUSMENU_SERVER(val); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -882,6 +890,10 @@ app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GPa g_value_set_uint(value, priv->ordering_index); break; + case PROP_DBUS_MENU_SERVER: + g_value_set_object(value, priv->menuservice); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; -- cgit v1.2.3 From 8b57d12c54ec1befb09711439e40eac7ed93dbcd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 21:05:39 -0600 Subject: Set the property type correctly. --- src/app-indicator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index fd035ac..78d784a 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -420,7 +420,7 @@ app_indicator_class_init (AppIndicatorClass *klass) g_param_spec_object (PROP_DBUS_MENU_SERVER_S, "The internal DBusmenu Server", "DBusmenu server which is available for testing the application indicators.", - DBUSMENU_TYPE_MENUITEM, + DBUSMENU_TYPE_SERVER, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /* Signals */ -- cgit v1.2.3 From 1d3ca65fb6f35c8b25f373d988d777fd6f8ce6f0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 21:32:01 -0600 Subject: Adding shorties as a private variable --- src/app-indicator.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 318a056..138498c 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -91,6 +91,9 @@ struct _AppIndicatorPrivate { DBusGProxy *watcher_proxy; DBusGConnection *connection; DBusGProxy * dbus_proxy; + + /* Might be used */ + IndicatorDesktopShortcuts * shorties; }; /* Signals Stuff */ @@ -568,6 +571,8 @@ app_indicator_init (AppIndicator *self) priv->status_icon = NULL; priv->fallback_timer = 0; + priv->shorties = NULL; + /* Put the object on DBus */ GError * error = NULL; priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); @@ -594,6 +599,11 @@ app_indicator_dispose (GObject *object) AppIndicator *self = APP_INDICATOR (object); AppIndicatorPrivate *priv = self->priv; + if (priv->shorties != NULL) { + g_object_unref(G_OBJECT(priv->shorties)); + priv->shorties = NULL; + } + if (priv->status != APP_INDICATOR_STATUS_PASSIVE) { app_indicator_set_status(self, APP_INDICATOR_STATUS_PASSIVE); } -- cgit v1.2.3 From 5c687d9de8dd774742a6a0e06ea443042fe91541 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 21:37:18 -0600 Subject: Switching to use the private variable for the shorties --- src/app-indicator.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 138498c..4643931 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -2169,12 +2169,18 @@ shorty_activated_cb (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) void app_indicator_build_menu_from_desktop (AppIndicator * self, const gchar * desktop_file, const gchar * desktop_profile) { + g_return_if_fail(IS_APP_INDICATOR(self)); + AppIndicatorPrivate *priv = self->priv; /* Build a new shortcuts object */ - IndicatorDesktopShortcuts * shorties = indicator_desktop_shortcuts_new(desktop_file, desktop_profile); - g_return_if_fail(shorties != NULL); + if (priv->shorties != NULL) { + g_object_unref(priv->shorties); + priv->shorties = NULL; + } + priv->shorties = indicator_desktop_shortcuts_new(desktop_file, desktop_profile); + g_return_if_fail(priv->shorties != NULL); - const gchar ** nicks = indicator_desktop_shortcuts_get_nicks(shorties); + const gchar ** nicks = indicator_desktop_shortcuts_get_nicks(priv->shorties); int nick_num; /* Place the items on a dbusmenu */ @@ -2184,7 +2190,7 @@ app_indicator_build_menu_from_desktop (AppIndicator * self, const gchar * deskto DbusmenuMenuitem * item = dbusmenu_menuitem_new(); g_object_set_data(G_OBJECT(item), APP_INDICATOR_SHORTY_NICK, (gpointer)nicks[nick_num]); - gchar * name = indicator_desktop_shortcuts_nick_get_name(shorties, nicks[nick_num]); + gchar * name = indicator_desktop_shortcuts_nick_get_name(priv->shorties, nicks[nick_num]); dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_LABEL, name); g_free(name); -- cgit v1.2.3 From 2d87c7a295d0eb4681ed65a709c77ef47a421bf7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 21:48:35 -0600 Subject: Setup the menu as a dbusmenu if we build it --- src/app-indicator.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 4643931..ee18cad 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -2200,6 +2200,18 @@ app_indicator_build_menu_from_desktop (AppIndicator * self, const gchar * deskto } /* Swap it if needed */ + if (priv->menuservice == NULL) { + gchar * path = g_strdup_printf(DEFAULT_ITEM_PATH "/%s/Menu", priv->clean_id); + priv->menuservice = dbusmenu_server_new (path); + g_free(path); + } + + dbusmenu_server_set_root (priv->menuservice, root); + + if (priv->menu != NULL) { + g_object_unref(G_OBJECT(priv->menu)); + priv->menu = NULL; + } return; } -- cgit v1.2.3 From 9bde70f2f1b96fe335dc11c941f64784c8f258f0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 21:52:59 -0600 Subject: Filling out the activate function. --- src/app-indicator.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index ee18cad..199e256 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -2153,7 +2153,16 @@ app_indicator_get_ordering_index (AppIndicator *self) static void shorty_activated_cb (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) { + gchar * nick = g_object_get_data(G_OBJECT(mi), APP_INDICATOR_SHORTY_NICK); + g_return_if_fail(nick != NULL); + g_return_if_fail(IS_APP_INDICATOR(user_data)); + AppIndicator * self = APP_INDICATOR(user_data); + AppIndicatorPrivate *priv = self->priv; + + g_return_if_fail(priv->shorties != NULL); + + indicator_desktop_shortcuts_nick_exec(priv->shorties, nick); return; } -- cgit v1.2.3 From c2e08e008bd9ea4f43a15390e6e4116cc714521a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Nov 2010 22:29:42 -0600 Subject: Documentation fixes for distcheck --- src/app-indicator.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 199e256..146bee2 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -2171,6 +2171,7 @@ shorty_activated_cb (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) app_indicator_build_menu_from_desktop: @self: The #AppIndicator object to use @desktop_file: A path to the desktop file to build the menu from + @desktop_profile: Which entries should be used from the desktop file This function allows for building the Application Indicator menu from a static desktop file. -- cgit v1.2.3 From 9287e2084f137024fc5d519a241f83ade387f3b0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 6 Dec 2010 11:13:54 -0600 Subject: Building up the base inforation for the dbus interfaces as static globals --- src/app-indicator.c | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 4886605..6403a9b 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -48,8 +48,8 @@ License version 3 and version 2.1 along with this program. If not, see #include "app-indicator-enum-types.h" #include "application-service-marshal.h" -#include "notification-item-server.h" -#include "notification-watcher-client.h" +#include "notification-watcher.xml.h" +#include "notification-item.xml.h" #include "dbus-shared.h" #include "generate-id.h" @@ -165,6 +165,12 @@ enum { /* More constants */ #define DEFAULT_FALLBACK_TIMER 100 /* in milliseconds */ +/* Globals */ +static GDBusNodeInfo * item_node_info = NULL; +static GDBusInterfaceInfo * item_interface_info = NULL; +static GDBusNodeInfo * watcher_node_info = NULL; +static GDBusInterfaceInfo * watcher_interface_info = NULL; + /* Boiler plate */ static void app_indicator_class_init (AppIndicatorClass *klass); static void app_indicator_init (AppIndicator *self); @@ -542,6 +548,43 @@ app_indicator_class_init (AppIndicatorClass *klass) g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); + /* DBus interfaces */ + if (item_node_info == NULL) { + GError * error = NULL; + + item_node_info = g_dbus_node_info_new_for_xml(notification_item_xml, &error); + if (error != NULL) { + g_error("Unable to parse Notification Item DBus interface: %s", error->message); + g_error_free(error); + } + } + + if (item_interface_info == NULL && item_node_info != NULL) { + item_interface_info = g_dbus_node_info_lookup_interface(item_node_info, NOTIFICATION_ITEM_DBUS_IFACE); + + if (item_interface_info == NULL) { + g_error("Unable to find interface '" NOTIFICATION_ITEM_DBUS_IFACE "'"); + } + } + + if (watcher_node_info == NULL) { + GError * error = NULL; + + watcher_node_info = g_dbus_node_info_new_for_xml(notification_watcher_xml, &error); + if (error != NULL) { + g_error("Unable to parse Notification Item DBus interface: %s", error->message); + g_error_free(error); + } + } + + if (watcher_interface_info == NULL && watcher_node_info != NULL) { + watcher_interface_info = g_dbus_node_info_lookup_interface(watcher_node_info, NOTIFICATION_WATCHER_DBUS_IFACE); + + if (watcher_interface_info == NULL) { + g_error("Unable to find interface '" NOTIFICATION_WATCHER_DBUS_IFACE "'"); + } + } + /* Initialize the object as a DBus type */ dbus_g_object_type_install_info(APP_INDICATOR_TYPE, &dbus_glib__notification_item_server_object_info); -- cgit v1.2.3 From 589bebb75b236729cdce2e139f4aa2da2317c495 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 6 Dec 2010 11:21:26 -0600 Subject: Dropping the registration of the type of the object in the dbus-glib way --- src/app-indicator.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 6403a9b..76b5dd1 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -585,10 +585,6 @@ app_indicator_class_init (AppIndicatorClass *klass) } } - /* Initialize the object as a DBus type */ - dbus_g_object_type_install_info(APP_INDICATOR_TYPE, - &dbus_glib__notification_item_server_object_info); - return; } -- cgit v1.2.3 From c1f18c7a8731c9381075a4ddf1645a6feb591ad1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 6 Dec 2010 11:45:27 -0600 Subject: Switching the dbus object registration to us GDBus --- src/app-indicator.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 76b5dd1..b18ac36 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -95,6 +95,7 @@ struct _AppIndicatorPrivate { DBusGProxy *watcher_proxy; DBusGConnection *connection; DBusGProxy * dbus_proxy; + guint dbus_registration; /* Might be used */ IndicatorDesktopShortcuts * shorties; @@ -194,8 +195,14 @@ static gchar * append_panel_icon_suffix (const gchar * icon_name); static void watcher_proxy_destroyed (GObject * object, gpointer data); static void client_menu_changed (GtkWidget *widget, GtkWidget *child, AppIndicator *indicator); static void submenu_changed (GtkWidget *widget, GtkWidget *child, gpointer data); - static void theme_changed_cb (GtkIconTheme * theme, gpointer user_data); +static GVariant * bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * property, GError ** error, gpointer user_data); + +static const GDBusInterfaceVTable item_interface_table = { + method_call: NULL, /* No methods on this object */ + get_property: bus_get_prop, + set_property: NULL /* No properties that can be set */ +}; /* GObject type */ G_DEFINE_TYPE (AppIndicator, app_indicator, G_TYPE_OBJECT); @@ -610,6 +617,7 @@ app_indicator_init (AppIndicator *self) priv->watcher_proxy = NULL; priv->connection = NULL; priv->dbus_proxy = NULL; + priv->dbus_registration = 0; priv->status_icon = NULL; priv->fallback_timer = 0; @@ -642,6 +650,11 @@ app_indicator_dispose (GObject *object) AppIndicator *self = APP_INDICATOR (object); AppIndicatorPrivate *priv = self->priv; + if (priv->dbus_registration != 0) { + g_dbus_connection_unregister_object(priv->connection, priv->dbus_registration); + priv->dbus_registration = 0; + } + if (priv->shorties != NULL) { g_object_unref(G_OBJECT(priv->shorties)); priv->shorties = NULL; @@ -1012,11 +1025,21 @@ check_connect (AppIndicator *self) gchar * path = g_strdup_printf(DEFAULT_ITEM_PATH "/%s", priv->clean_id); - dbus_g_connection_register_g_object(priv->connection, - path, - G_OBJECT(self)); - GError * error = NULL; + priv->dbus_registration = g_dbus_connection_register_object(priv->connection, + path, + item_interface_info, + &item_interface_table, + self, + NULL, + &error); + if (error != NULL) { + g_warning("Unable to register object on path '%s': %s", path, error->message); + g_error_free(error); + g_free(path); + return; + } + priv->watcher_proxy = dbus_g_proxy_new_for_name_owner(priv->connection, NOTIFICATION_WATCHER_DBUS_ADDR, NOTIFICATION_WATCHER_DBUS_OBJ, -- cgit v1.2.3 From 6a4266ba2927f856235b3788938333e9377c0e89 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 6 Dec 2010 12:25:07 -0600 Subject: Changing the connection to be a GDBus connection and making aquiring it async --- src/app-indicator.c | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index b18ac36..9715817 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -93,7 +93,7 @@ struct _AppIndicatorPrivate { /* Fun stuff */ DBusGProxy *watcher_proxy; - DBusGConnection *connection; + GDBusConnection *connection; DBusGProxy * dbus_proxy; guint dbus_registration; @@ -197,6 +197,7 @@ static void client_menu_changed (GtkWidget *widget, GtkWidget *child, AppIndicat static void submenu_changed (GtkWidget *widget, GtkWidget *child, gpointer data); static void theme_changed_cb (GtkIconTheme * theme, gpointer user_data); static GVariant * bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * property, GError ** error, gpointer user_data); +static void bus_creation (GObject * obj, GAsyncResult * res, gpointer user_data); static const GDBusInterfaceVTable item_interface_table = { method_call: NULL, /* No methods on this object */ @@ -624,15 +625,8 @@ app_indicator_init (AppIndicator *self) priv->shorties = NULL; - /* Put the object on DBus */ - GError * error = NULL; - priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); - if (error != NULL) { - g_error("Unable to connect to the session bus when creating application indicator: %s", error->message); - g_error_free(error); - return; - } - dbus_g_connection_ref(priv->connection); + /* Start getting the session bus */ + g_bus_get(G_BUS_TYPE_SESSION, NULL, bus_creation, self); g_signal_connect(G_OBJECT(gtk_icon_theme_get_default()), "changed", G_CALLBACK(theme_changed_cb), self); @@ -765,6 +759,11 @@ app_indicator_finalize (GObject *object) priv->label_guide = NULL; } + if (priv->connection != NULL) { + g_object_unref(G_OBJECT(priv->connection)); + priv->connection = NULL; + } + G_OBJECT_CLASS (app_indicator_parent_class)->finalize (object); return; } @@ -970,6 +969,29 @@ app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GPa return; } +/* DBus bus has been created, well maybe, but we got a call + back about it so we need to check into it. */ +static void +bus_creation (GObject * obj, GAsyncResult * res, gpointer user_data) +{ + GError * error = NULL; + + GDBusConnection * connection = g_bus_get_finish(res, &error); + if (error != NULL) { + g_warning("Unable to get the session bus: %s", error->message); + g_error_free(error); + return; + } + + AppIndicator * app = APP_INDICATOR(user_data); + app->priv->connection = connection; + + /* If the connection was blocking the exporting of the + object this function will export everything. */ + check_connect(app); + return; +} + /* Sends the label changed signal and resets the source ID */ static gboolean signal_label_change_idle (gpointer user_data) @@ -1015,6 +1037,9 @@ check_connect (AppIndicator *self) { AppIndicatorPrivate *priv = self->priv; + /* Do we have a connection? */ + if (priv->connection == NULL) return; + /* We're alreadying connecting or trying to connect. */ if (priv->watcher_proxy != NULL) return; -- cgit v1.2.3 From 6e078ce032712912c87fafa641051248c8b43d57 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 6 Dec 2010 14:36:57 -0600 Subject: Readjusting how the proxy is setup, called back, and the registration occurs. --- src/app-indicator.c | 151 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 113 insertions(+), 38 deletions(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 9715817..2a8eb2f 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -92,10 +92,11 @@ struct _AppIndicatorPrivate { gint fallback_timer; /* Fun stuff */ - DBusGProxy *watcher_proxy; + GDBusProxy *watcher_proxy; GDBusConnection *connection; DBusGProxy * dbus_proxy; guint dbus_registration; + gchar * path; /* Might be used */ IndicatorDesktopShortcuts * shorties; @@ -198,6 +199,7 @@ static void submenu_changed (GtkWidget *widget, GtkWidget *child, gpointer data) static void theme_changed_cb (GtkIconTheme * theme, gpointer user_data); static GVariant * bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * property, GError ** error, gpointer user_data); static void bus_creation (GObject * obj, GAsyncResult * res, gpointer user_data); +static void bus_watcher_ready (GObject * obj, GAsyncResult * res, gpointer user_data); static const GDBusInterfaceVTable item_interface_table = { method_call: NULL, /* No methods on this object */ @@ -619,6 +621,7 @@ app_indicator_init (AppIndicator *self) priv->connection = NULL; priv->dbus_proxy = NULL; priv->dbus_registration = 0; + priv->path = NULL; priv->status_icon = NULL; priv->fallback_timer = 0; @@ -694,7 +697,6 @@ app_indicator_dispose (GObject *object) } if (priv->watcher_proxy != NULL) { - dbus_g_connection_flush(priv->connection); g_signal_handlers_disconnect_by_func(G_OBJECT(priv->watcher_proxy), watcher_proxy_destroyed, self); g_object_unref(G_OBJECT(priv->watcher_proxy)); priv->watcher_proxy = NULL; @@ -704,7 +706,7 @@ app_indicator_dispose (GObject *object) } if (priv->connection != NULL) { - dbus_g_connection_unref(priv->connection); + g_object_unref(G_OBJECT(priv->connection)); priv->connection = NULL; } @@ -717,8 +719,8 @@ app_indicator_dispose (GObject *object) static void app_indicator_finalize (GObject *object) { - AppIndicator * self = APP_INDICATOR(object); - AppIndicatorPrivate *priv = self->priv; + AppIndicator * self = APP_INDICATOR(object); + AppIndicatorPrivate *priv = self->priv; if (priv->status != APP_INDICATOR_STATUS_PASSIVE) { g_warning("Finalizing Application Status with the status set to: %d", priv->status); @@ -759,9 +761,9 @@ app_indicator_finalize (GObject *object) priv->label_guide = NULL; } - if (priv->connection != NULL) { - g_object_unref(G_OBJECT(priv->connection)); - priv->connection = NULL; + if (priv->path != NULL) { + g_free(priv->path); + priv->path = NULL; } G_OBJECT_CLASS (app_indicator_parent_class)->finalize (object); @@ -938,9 +940,20 @@ app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GPa } break; - case PROP_CONNECTED: - g_value_set_boolean (value, priv->watcher_proxy != NULL ? TRUE : FALSE); - break; + case PROP_CONNECTED: { + gboolean connected = FALSE; + + if (priv->watcher_proxy != NULL) { + gchar * name = g_dbus_proxy_get_name_owner(priv->watcher_proxy); + if (name != NULL) { + connected = TRUE; + g_free(name); + } + } + + g_value_set_boolean (value, connected); + break; + } case PROP_X_LABEL: case PROP_LABEL: @@ -1043,50 +1056,109 @@ check_connect (AppIndicator *self) /* We're alreadying connecting or trying to connect. */ if (priv->watcher_proxy != NULL) return; + gchar * name = g_dbus_proxy_get_name_owner(priv->watcher_proxy); + if (name == NULL) { + return; + } + g_free(name); + /* Do we have enough information? */ if (priv->menu == NULL) return; if (priv->icon_name == NULL) return; if (priv->id == NULL) return; - gchar * path = g_strdup_printf(DEFAULT_ITEM_PATH "/%s", priv->clean_id); + if (priv->path == NULL) { + priv->path = g_strdup_printf(DEFAULT_ITEM_PATH "/%s", priv->clean_id); + } + if (priv->dbus_registration == 0) { + GError * error = NULL; + priv->dbus_registration = g_dbus_connection_register_object(priv->connection, + priv->path, + item_interface_info, + &item_interface_table, + self, + NULL, + &error); + if (error != NULL) { + g_warning("Unable to register object on path '%s': %s", priv->path, error->message); + g_error_free(error); + return; + } + } + + /* NOTE: It's really important the order here. We make sure to *publish* + the object on the bus and *then* get the proxy. The reason is that we + want to ensure all the filters are setup before talking to the watcher + and that's where the order is important. */ + + if (priv->watcher_proxy == NULL) { + /* Build Watcher Proxy */ + g_dbus_proxy_new(priv->connection, + G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS, /* We don't use these, don't bother with them */ + watcher_interface_info, + NOTIFICATION_WATCHER_DBUS_ADDR, + NOTIFICATION_WATCHER_DBUS_OBJ, + NOTIFICATION_WATCHER_DBUS_IFACE, + NULL, /* cancellable */ + bus_watcher_ready, + self); + } else { + bus_watcher_ready(NULL, NULL, self); + } + + return; +} + +/* Callback for when the watcher proxy has been created, or not + but we got called none-the-less. */ +static void +bus_watcher_ready (GObject * obj, GAsyncResult * res, gpointer user_data) +{ GError * error = NULL; - priv->dbus_registration = g_dbus_connection_register_object(priv->connection, - path, - item_interface_info, - &item_interface_table, - self, - NULL, - &error); - if (error != NULL) { - g_warning("Unable to register object on path '%s': %s", path, error->message); - g_error_free(error); - g_free(path); - return; + + GDBusProxy * proxy = NULL; + if (res != NULL) { + proxy = g_dbus_proxy_new_finish(res, &error); } - priv->watcher_proxy = dbus_g_proxy_new_for_name_owner(priv->connection, - NOTIFICATION_WATCHER_DBUS_ADDR, - NOTIFICATION_WATCHER_DBUS_OBJ, - NOTIFICATION_WATCHER_DBUS_IFACE, - &error); if (error != NULL) { /* Unable to get proxy, but we're handling that now so it's not a warning anymore. */ g_error_free(error); - dbus_g_connection_unregister_g_object(priv->connection, - G_OBJECT(self)); - start_fallback_timer(self, FALSE); - g_free(path); + + if (IS_APP_INDICATOR(user_data)) { + start_fallback_timer(APP_INDICATOR(user_data), FALSE); + } return; } - g_signal_connect(G_OBJECT(priv->watcher_proxy), "destroy", G_CALLBACK(watcher_proxy_destroyed), self); - org_kde_StatusNotifierWatcher_register_status_notifier_item_async(priv->watcher_proxy, path, register_service_cb, self); - g_free(path); + AppIndicator * app = APP_INDICATOR(user_data); - /* Emit the AppIndicator::connection-changed signal*/ - g_signal_emit (self, signals[CONNECTION_CHANGED], 0, TRUE); + if (res != NULL) { + app->priv->watcher_proxy = proxy; + + /* Setting up a signal to watch when the unique name + changes */ + g_signal_connect(G_OBJECT(app->priv->watcher_proxy), "destroy", G_CALLBACK(watcher_proxy_destroyed), user_data); + } + + /* Let's insure that someone is on the other side, else we're + still in a fallback scenario. */ + gchar * name = g_dbus_proxy_get_name_owner(app->priv->watcher_proxy); + if (name == NULL) { + start_fallback_timer(APP_INDICATOR(user_data), FALSE); + return; + } + + g_dbus_proxy_call(app->priv->watcher_proxy, + "RegisterStatusNotifierItem", + g_variant_new("(s)", app->priv->path), + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, /* cancelable */ + register_service_cb, + user_data); return; } @@ -1129,6 +1201,9 @@ register_service_cb (DBusGProxy * proxy, GError * error, gpointer data) start_fallback_timer(APP_INDICATOR(data), TRUE); } + /* Emit the AppIndicator::connection-changed signal*/ + g_signal_emit (self, signals[CONNECTION_CHANGED], 0, TRUE); + if (priv->status_icon) { AppIndicatorClass * class = APP_INDICATOR_GET_CLASS(data); if (class->unfallback != NULL) { -- cgit v1.2.3 From 884367e5f739a56355d56a707ff0d741934190ec Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 6 Dec 2010 15:57:14 -0600 Subject: Switch from using the DBus proxy to using the owner change signal on the watcher proxy. --- src/app-indicator.c | 167 ++++++++++++++-------------------------------------- 1 file changed, 44 insertions(+), 123 deletions(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 2a8eb2f..94cf624 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -94,7 +94,6 @@ struct _AppIndicatorPrivate { /* Fun stuff */ GDBusProxy *watcher_proxy; GDBusConnection *connection; - DBusGProxy * dbus_proxy; guint dbus_registration; gchar * path; @@ -184,7 +183,7 @@ static void app_indicator_get_property (GObject * object, guint prop_id, GValue /* Other stuff */ static void signal_label_change (AppIndicator * self); static void check_connect (AppIndicator * self); -static void register_service_cb (DBusGProxy * proxy, GError * error, gpointer data); +static void register_service_cb (GObject * obj, GAsyncResult * res, gpointer user_data); static void start_fallback_timer (AppIndicator * self, gboolean disable_timeout); static gboolean fallback_timer_expire (gpointer data); static GtkStatusIcon * fallback (AppIndicator * self); @@ -193,7 +192,7 @@ static void status_icon_changes (AppIndicator * self, gpointer data); static void status_icon_activate (GtkStatusIcon * icon, gpointer data); static void unfallback (AppIndicator * self, GtkStatusIcon * status_icon); static gchar * append_panel_icon_suffix (const gchar * icon_name); -static void watcher_proxy_destroyed (GObject * object, gpointer data); +static void watcher_owner_changed (GObject * obj, GParamSpec * pspec, gpointer user_data); static void client_menu_changed (GtkWidget *widget, GtkWidget *child, AppIndicator *indicator); static void submenu_changed (GtkWidget *widget, GtkWidget *child, gpointer data); static void theme_changed_cb (GtkIconTheme * theme, gpointer user_data); @@ -619,7 +618,6 @@ app_indicator_init (AppIndicator *self) priv->watcher_proxy = NULL; priv->connection = NULL; - priv->dbus_proxy = NULL; priv->dbus_registration = 0; priv->path = NULL; @@ -687,17 +685,12 @@ app_indicator_dispose (GObject *object) priv->menu = NULL; } - if (priv->menuservice != NULL) { - g_object_unref (priv->menuservice); - } - - if (priv->dbus_proxy != NULL) { - g_object_unref(G_OBJECT(priv->dbus_proxy)); - priv->dbus_proxy = NULL; + if (priv->menuservice != NULL) { + g_object_unref (priv->menuservice); } if (priv->watcher_proxy != NULL) { - g_signal_handlers_disconnect_by_func(G_OBJECT(priv->watcher_proxy), watcher_proxy_destroyed, self); + g_signal_handlers_disconnect_by_func(G_OBJECT(priv->watcher_proxy), watcher_owner_changed, self); g_object_unref(G_OBJECT(priv->watcher_proxy)); priv->watcher_proxy = NULL; @@ -1140,7 +1133,7 @@ bus_watcher_ready (GObject * obj, GAsyncResult * res, gpointer user_data) /* Setting up a signal to watch when the unique name changes */ - g_signal_connect(G_OBJECT(app->priv->watcher_proxy), "destroy", G_CALLBACK(watcher_proxy_destroyed), user_data); + g_signal_connect(G_OBJECT(app->priv->watcher_proxy), "notify::g-name-owner", G_CALLBACK(watcher_owner_changed), user_data); } /* Let's insure that someone is on the other side, else we're @@ -1163,51 +1156,67 @@ bus_watcher_ready (GObject * obj, GAsyncResult * res, gpointer user_data) return; } -/* A function that gets called when the watcher dies. Like - dies dies. Not our friend anymore. */ +/* Watching for when the name owner changes on the interface + to know whether we should be connected or not. */ static void -watcher_proxy_destroyed (GObject * object, gpointer data) +watcher_owner_changed (GObject * obj, GParamSpec * pspec, gpointer user_data) { - AppIndicator * self = APP_INDICATOR(data); + AppIndicator * self = APP_INDICATOR(user_data); g_return_if_fail(self != NULL); + g_return_if_fail(self->priv->watcher_proxy != NULL); - dbus_g_connection_unregister_g_object(self->priv->connection, - G_OBJECT(self)); - self->priv->watcher_proxy = NULL; + gchar * name = g_dbus_proxy_get_name_owner(self->priv->watcher_proxy); + + if (name == NULL) { + /* Emit the AppIndicator::connection-changed signal*/ + g_signal_emit (self, signals[CONNECTION_CHANGED], 0, FALSE); + + start_fallback_timer(self, FALSE); + } else { + if (self->priv->fallback_timer != 0) { + /* Stop the timer */ + g_source_remove(self->priv->fallback_timer); + self->priv->fallback_timer = 0; + } + + check_connect(self); + } - /* Emit the AppIndicator::connection-changed signal*/ - g_signal_emit (self, signals[CONNECTION_CHANGED], 0, FALSE); - - start_fallback_timer(self, FALSE); return; } /* Responce from the DBus command to register a service with a NotificationWatcher. */ static void -register_service_cb (DBusGProxy * proxy, GError * error, gpointer data) +register_service_cb (GObject * obj, GAsyncResult * res, gpointer user_data) { - g_return_if_fail(IS_APP_INDICATOR(data)); - AppIndicatorPrivate * priv = APP_INDICATOR(data)->priv; + GError * error = NULL; + GVariant * returns = g_dbus_proxy_call_finish(G_DBUS_PROXY(obj), res, &error); + + /* We don't care about any return values */ + if (returns != NULL) { + g_variant_unref(returns); + } if (error != NULL) { /* They didn't respond, ewww. Not sure what they could be doing */ g_warning("Unable to connect to the Notification Watcher: %s", error->message); - dbus_g_connection_unregister_g_object(priv->connection, - G_OBJECT(data)); - g_object_unref(G_OBJECT(priv->watcher_proxy)); - priv->watcher_proxy = NULL; - start_fallback_timer(APP_INDICATOR(data), TRUE); + start_fallback_timer(APP_INDICATOR(user_data), TRUE); + return; } + g_return_if_fail(IS_APP_INDICATOR(user_data)); + AppIndicator * app = APP_INDICATOR(user_data); + AppIndicatorPrivate * priv = app->priv; + /* Emit the AppIndicator::connection-changed signal*/ - g_signal_emit (self, signals[CONNECTION_CHANGED], 0, TRUE); + g_signal_emit (app, signals[CONNECTION_CHANGED], 0, TRUE); if (priv->status_icon) { - AppIndicatorClass * class = APP_INDICATOR_GET_CLASS(data); + AppIndicatorClass * class = APP_INDICATOR_GET_CLASS(app); if (class->unfallback != NULL) { - class->unfallback(APP_INDICATOR(data), priv->status_icon); + class->unfallback(app, priv->status_icon); priv->status_icon = NULL; } } @@ -1226,89 +1235,6 @@ category_from_enum (AppIndicatorCategory category) return value->value_nick; } -/* Watching the dbus owner change events to see if someone - we care about pops up! */ -static void -dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, gpointer data) -{ - if (new == NULL || new[0] == '\0') { - /* We only care about folks coming on the bus. Exit quickly otherwise. */ - return; - } - - if (g_strcmp0(name, NOTIFICATION_WATCHER_DBUS_ADDR)) { - /* We only care about this address, reject all others. */ - return; - } - - /* Woot, there's a new notification watcher in town. */ - - AppIndicatorPrivate * priv = APP_INDICATOR_GET_PRIVATE(data); - - if (priv->fallback_timer != 0) { - /* Stop a timer */ - g_source_remove(priv->fallback_timer); - - /* Stop listening to bus events */ - g_object_unref(G_OBJECT(priv->dbus_proxy)); - priv->dbus_proxy = NULL; - } - - /* Let's start from the very beginning */ - check_connect(APP_INDICATOR(data)); - - return; -} - -/* Checking to see if someone already has the name we're looking for */ -static void -check_owner_cb (DBusGProxy *proxy, gboolean exists, GError *error, gpointer userdata) -{ - if (error != NULL) { - g_warning("Unable to check for '" NOTIFICATION_WATCHER_DBUS_ADDR "' on DBus. No worries, but concerning."); - return; - } - - if (exists) { - g_debug("Woah, we actually has a race condition with dbus"); - dbus_owner_change(proxy, NOTIFICATION_WATCHER_DBUS_ADDR, NULL, "Non NULL", userdata); - } - - return; -} - -/* This is an idle function to create the proxy. This is mostly - because start_fallback_timer can get called in the distruction - of a proxy and thus the proxy manager gets confused when creating - a new proxy as part of destroying an old one. This function being - on idle means that we'll just do it outside of the same stack where - the previous proxy is being destroyed. */ -static gboolean -setup_name_owner_proxy (gpointer data) -{ - g_return_val_if_fail(IS_APP_INDICATOR(data), FALSE); - AppIndicatorPrivate * priv = APP_INDICATOR(data)->priv; - - if (priv->dbus_proxy == NULL) { - priv->dbus_proxy = dbus_g_proxy_new_for_name(priv->connection, - DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, - DBUS_INTERFACE_DBUS); - dbus_g_proxy_add_signal(priv->dbus_proxy, "NameOwnerChanged", - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, - G_TYPE_INVALID); - dbus_g_proxy_connect_signal(priv->dbus_proxy, "NameOwnerChanged", - G_CALLBACK(dbus_owner_change), data, NULL); - - /* Check to see if anyone has the name we're looking for - just incase we missed it changing. */ - - org_freedesktop_DBus_name_has_owner_async(priv->dbus_proxy, NOTIFICATION_WATCHER_DBUS_ADDR, check_owner_cb, data); - } - - return FALSE; -} - /* A function that will start the fallback timer if it's not already started. It sets up the DBus watcher to see if there is a change. Also, provides an override mode for cases @@ -1330,11 +1256,6 @@ start_fallback_timer (AppIndicator * self, gboolean disable_timeout) return; } - if (priv->dbus_proxy == NULL) { - /* NOTE: Read the comment on setup_name_owner_proxy */ - g_idle_add(setup_name_owner_proxy, self); - } - if (disable_timeout) { fallback_timer_expire(self); } else { -- cgit v1.2.3 From a92f87080dea6c0d16bfb55bf75e155658bfa372 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 6 Dec 2010 16:05:36 -0600 Subject: Adding in the get_prop function so that things start linking --- src/app-indicator.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 94cf624..0b31018 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -998,6 +998,16 @@ bus_creation (GObject * obj, GAsyncResult * res, gpointer user_data) return; } +/* DBus is asking for a property so we should figure out what it + wants and try and deliver. */ +static GVariant * +bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * property, GError ** error, gpointer user_data) +{ + + + return NULL; +} + /* Sends the label changed signal and resets the source ID */ static gboolean signal_label_change_idle (gpointer user_data) -- cgit v1.2.3 From 07aeca3802b2e19878b24637f1f73d971c7be101 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 6 Dec 2010 16:38:29 -0600 Subject: Switching the names of the generated files to stop automake from thinking it needs to build the XML files. --- src/app-indicator.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 0b31018..0d469ac 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -48,8 +48,8 @@ License version 3 and version 2.1 along with this program. If not, see #include "app-indicator-enum-types.h" #include "application-service-marshal.h" -#include "notification-watcher.xml.h" -#include "notification-item.xml.h" +#include "gen-notification-watcher.xml.h" +#include "gen-notification-item.xml.h" #include "dbus-shared.h" #include "generate-id.h" @@ -561,7 +561,7 @@ app_indicator_class_init (AppIndicatorClass *klass) if (item_node_info == NULL) { GError * error = NULL; - item_node_info = g_dbus_node_info_new_for_xml(notification_item_xml, &error); + item_node_info = g_dbus_node_info_new_for_xml(notification_item, &error); if (error != NULL) { g_error("Unable to parse Notification Item DBus interface: %s", error->message); g_error_free(error); @@ -579,7 +579,7 @@ app_indicator_class_init (AppIndicatorClass *klass) if (watcher_node_info == NULL) { GError * error = NULL; - watcher_node_info = g_dbus_node_info_new_for_xml(notification_watcher_xml, &error); + watcher_node_info = g_dbus_node_info_new_for_xml(notification_watcher, &error); if (error != NULL) { g_error("Unable to parse Notification Item DBus interface: %s", error->message); g_error_free(error); -- cgit v1.2.3 From 1652577abbb869f4276c03f4e10b829c515cb674 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 6 Dec 2010 17:06:10 -0600 Subject: Putting some dummy code in the bus get property function. --- src/app-indicator.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 0d469ac..a2bcaf2 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -1003,8 +1003,29 @@ bus_creation (GObject * obj, GAsyncResult * res, gpointer user_data) static GVariant * bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * property, GError ** error, gpointer user_data) { + if (g_strcmp0(property, "Id") == 0) { + return g_variant_new("s", "bob"); + } else if (g_strcmp0(property, "Category") == 0) { + return g_variant_new("s", "bob"); + } else if (g_strcmp0(property, "Status") == 0) { + return g_variant_new("s", "bob"); + } else if (g_strcmp0(property, "IconName") == 0) { + return g_variant_new("s", "bob"); + } else if (g_strcmp0(property, "AttentionIconName") == 0) { + return g_variant_new("s", "bob"); + } else if (g_strcmp0(property, "IconThemePath") == 0) { + return g_variant_new("s", "bob"); + } else if (g_strcmp0(property, "Menu") == 0) { + return g_variant_new("o", "/bob"); + } else if (g_strcmp0(property, "XAyatanaLabel") == 0) { + return g_variant_new("s", "bob"); + } else if (g_strcmp0(property, "XAyatanaLabelGuide") == 0) { + return g_variant_new("s", "bob"); + } else if (g_strcmp0(property, "XAyatanaOrderingIndex") == 0) { + return g_variant_new("u", 42); + } - + *error = g_error_new(0, 0, "Unknown property: %s", property); return NULL; } -- cgit v1.2.3 From a666e4bf6fb63a54bc8fda8f12ba8c6cdbf19669 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 6 Dec 2010 17:10:32 -0600 Subject: Dropping all the 'x' properties in the object --- src/app-indicator.c | 52 ---------------------------------------------------- 1 file changed, 52 deletions(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index a2bcaf2..a95c7c1 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -129,10 +129,7 @@ enum { PROP_CONNECTED, PROP_LABEL, PROP_LABEL_GUIDE, - PROP_X_LABEL, - PROP_X_LABEL_GUIDE, PROP_ORDERING_INDEX, - PROP_X_ORDERING_INDEX, PROP_DBUS_MENU_SERVER }; @@ -147,10 +144,7 @@ enum { #define PROP_CONNECTED_S "connected" #define PROP_LABEL_S "label" #define PROP_LABEL_GUIDE_S "label-guide" -#define PROP_X_LABEL_S ("x-ayatana-" PROP_LABEL_S) -#define PROP_X_LABEL_GUIDE_S ("x-ayatana-" PROP_LABEL_GUIDE_S) #define PROP_ORDERING_INDEX_S "ordering-index" -#define PROP_X_ORDERING_INDEX_S ("x-ayatana-" PROP_ORDERING_INDEX_S) #define PROP_DBUS_MENU_SERVER_S "dbus-menu-server" /* Private macro, shhhh! */ @@ -392,47 +386,7 @@ app_indicator_class_init (AppIndicatorClass *klass) "A way to override the default ordering of the applications by providing a very specific idea of where this entry should be placed.", 0, G_MAXUINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - /** - AppIndicator:x-ayatana-ordering-index: - - A wrapper for #AppIndicator:ordering-index so that it can match the - dbus interface currently. It will hopefully be retired, please don't - use it anywhere. - */ - g_object_class_install_property(object_class, - PROP_X_ORDERING_INDEX, - g_param_spec_uint (PROP_X_ORDERING_INDEX_S, - "A wrapper, please don't use.", - "A wrapper, please don't use.", - 0, G_MAXUINT32, 0, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - - /** - AppIndicator:x-ayatana-label: - - Wrapper for #AppIndicator:label. Please use that in all of your - code. - */ - g_object_class_install_property(object_class, - PROP_X_LABEL, - g_param_spec_string (PROP_X_LABEL_S, - "A wrapper, please don't use.", - "A wrapper, please don't use.", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - /** - AppIndicator:x-ayatana-label-guide: - Wrapper for #AppIndicator:label-guide. Please use that in all of your - code. - */ - g_object_class_install_property(object_class, - PROP_X_LABEL_GUIDE, - g_param_spec_string (PROP_X_LABEL_GUIDE_S, - "A wrapper, please don't use.", - "A wrapper, please don't use.", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /** AppIndicator:dbus-menu-server: @@ -829,7 +783,6 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu check_connect (self); break; - case PROP_X_LABEL: case PROP_LABEL: { gchar * oldlabel = priv->label; priv->label = g_value_dup_string(value); @@ -848,7 +801,6 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu } break; } - case PROP_X_LABEL_GUIDE: case PROP_LABEL_GUIDE: { gchar * oldguide = priv->label_guide; priv->label_guide = g_value_dup_string(value); @@ -867,7 +819,6 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu } break; } - case PROP_X_ORDERING_INDEX: case PROP_ORDERING_INDEX: priv->ordering_index = g_value_get_uint(value); break; @@ -948,17 +899,14 @@ app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GPa break; } - case PROP_X_LABEL: case PROP_LABEL: g_value_set_string (value, priv->label); break; - case PROP_X_LABEL_GUIDE: case PROP_LABEL_GUIDE: g_value_set_string (value, priv->label_guide); break; - case PROP_X_ORDERING_INDEX: case PROP_ORDERING_INDEX: g_value_set_uint(value, priv->ordering_index); break; -- cgit v1.2.3 From 0d80d13d380533d5bb98f9820ff1e59c5ce80938 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 6 Dec 2010 17:12:39 -0600 Subject: Killing the X signals as well --- src/app-indicator.c | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index a95c7c1..81f3754 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -107,7 +107,6 @@ enum { NEW_ATTENTION_ICON, NEW_STATUS, NEW_LABEL, - X_NEW_LABEL, CONNECTION_CHANGED, NEW_ICON_THEME_PATH, LAST_SIGNAL @@ -151,9 +150,6 @@ enum { #define APP_INDICATOR_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), APP_INDICATOR_TYPE, AppIndicatorPrivate)) -/* Signal wrapper */ -#define APP_INDICATOR_SIGNAL_X_NEW_LABEL ("x-ayatana-" APP_INDICATOR_SIGNAL_NEW_LABEL) - /* Default Path */ #define DEFAULT_ITEM_PATH "/org/ayatana/NotificationItem" @@ -464,22 +460,6 @@ app_indicator_class_init (AppIndicatorClass *klass) _application_service_marshal_VOID__STRING_STRING, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); - /** - AppIndicator::x-ayatana-new-label: - @arg0: The #AppIndicator object - @arg1: The string for the label - @arg1: The string for the guide - - Wrapper for #AppIndicator::new-label, please don't use this signal - use the other one. - */ - signals[X_NEW_LABEL] = g_signal_new (APP_INDICATOR_SIGNAL_X_NEW_LABEL, - G_TYPE_FROM_CLASS(klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (AppIndicatorClass, new_label), - NULL, NULL, - _application_service_marshal_VOID__STRING_STRING, - G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); /** AppIndicator::connection-changed: @@ -988,10 +968,6 @@ signal_label_change_idle (gpointer user_data) priv->label != NULL ? priv->label : "", priv->label_guide != NULL ? priv->label_guide : "", TRUE); - g_signal_emit(G_OBJECT(self), signals[X_NEW_LABEL], 0, - priv->label != NULL ? priv->label : "", - priv->label_guide != NULL ? priv->label_guide : "", - TRUE); priv->label_change_idle = 0; -- cgit v1.2.3 From 985854cc7dc80383d9ed365cde87a991a1304754 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 6 Dec 2010 20:07:48 -0600 Subject: Returning real values for the dbus properties --- src/app-indicator.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 81f3754..3aaf444 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -931,26 +931,43 @@ bus_creation (GObject * obj, GAsyncResult * res, gpointer user_data) static GVariant * bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * property, GError ** error, gpointer user_data) { + g_return_val_if_fail(IS_APP_INDICATOR(user_data), NULL); + AppIndicator * app = APP_INDICATOR(user_data); + AppIndicatorPrivate *priv = app->priv; + if (g_strcmp0(property, "Id") == 0) { - return g_variant_new("s", "bob"); + return g_variant_new_string(app->priv->id); } else if (g_strcmp0(property, "Category") == 0) { - return g_variant_new("s", "bob"); + GEnumValue *enum_value; + enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (APP_INDICATOR_TYPE_INDICATOR_CATEGORY), priv->category); + return g_variant_new_string(enum_value->value_nick); } else if (g_strcmp0(property, "Status") == 0) { - return g_variant_new("s", "bob"); + GEnumValue *enum_value; + enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (APP_INDICATOR_TYPE_INDICATOR_STATUS), priv->status); + return g_variant_new_string(enum_value->value_nick); } else if (g_strcmp0(property, "IconName") == 0) { - return g_variant_new("s", "bob"); + return g_variant_new_string(priv->icon_name); } else if (g_strcmp0(property, "AttentionIconName") == 0) { - return g_variant_new("s", "bob"); + return g_variant_new_string(priv->attention_icon_name); } else if (g_strcmp0(property, "IconThemePath") == 0) { - return g_variant_new("s", "bob"); + return g_variant_new_string(priv->icon_theme_path); } else if (g_strcmp0(property, "Menu") == 0) { - return g_variant_new("o", "/bob"); + if (priv->menuservice != NULL) { + GValue strval = { 0 }; + g_value_init(&strval, G_TYPE_STRING); + g_object_get_property (G_OBJECT (priv->menuservice), DBUSMENU_SERVER_PROP_DBUS_OBJECT, &strval); + GVariant * var = g_variant_new("o", g_value_get_string(&strval)); + g_value_unset(&strval); + return var; + } else { + return g_variant_new("o", "/"); + } } else if (g_strcmp0(property, "XAyatanaLabel") == 0) { - return g_variant_new("s", "bob"); + return g_variant_new_string(priv->label); } else if (g_strcmp0(property, "XAyatanaLabelGuide") == 0) { - return g_variant_new("s", "bob"); + return g_variant_new_string(priv->label_guide); } else if (g_strcmp0(property, "XAyatanaOrderingIndex") == 0) { - return g_variant_new("u", 42); + return g_variant_new_uint32(priv->ordering_index); } *error = g_error_new(0, 0, "Unknown property: %s", property); -- cgit v1.2.3 From 4b46daa3c4b95c301dc4a26112efc9a23777711e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 6 Dec 2010 20:48:55 -0600 Subject: Emitting the signals on DBus --- src/app-indicator.c | 183 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 144 insertions(+), 39 deletions(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 3aaf444..dc9fb47 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -981,10 +981,27 @@ signal_label_change_idle (gpointer user_data) AppIndicator * self = (AppIndicator *)user_data; AppIndicatorPrivate *priv = self->priv; + gchar * label = priv->label != NULL ? priv->label : ""; + gchar * guide = priv->label_guide != NULL ? priv->label_guide : ""; + g_signal_emit(G_OBJECT(self), signals[NEW_LABEL], 0, - priv->label != NULL ? priv->label : "", - priv->label_guide != NULL ? priv->label_guide : "", - TRUE); + label, guide, TRUE); + if (priv->dbus_registration != 0 && priv->connection != NULL) { + GError * error = NULL; + + g_dbus_connection_emit_signal(priv->connection, + NULL, + priv->path, + NOTIFICATION_ITEM_DBUS_IFACE, + "XAyatanaNewLabel", + g_variant_new("(ss)", label, guide), + &error); + + if (error != NULL) { + g_warning("Unable to send signal for NewIcon: %s", error->message); + g_error_free(error); + } + } priv->label_change_idle = 0; @@ -1269,6 +1286,28 @@ static void theme_changed_cb (GtkIconTheme * theme, gpointer user_data) { g_signal_emit (user_data, signals[NEW_ICON], 0, TRUE); + + AppIndicator * self = (AppIndicator *)user_data; + AppIndicatorPrivate *priv = self->priv; + + if (priv->dbus_registration != 0 && priv->connection != NULL) { + GError * error = NULL; + + g_dbus_connection_emit_signal(priv->connection, + NULL, + priv->path, + NOTIFICATION_ITEM_DBUS_IFACE, + "NewIcon", + NULL, + &error); + + if (error != NULL) { + g_warning("Unable to send signal for NewIcon: %s", error->message); + g_error_free(error); + } + } + + return; } /* Creates a StatusIcon that can be used when the application @@ -1472,15 +1511,33 @@ app_indicator_new_with_path (const gchar *id, void app_indicator_set_status (AppIndicator *self, AppIndicatorStatus status) { - g_return_if_fail (IS_APP_INDICATOR (self)); + g_return_if_fail (IS_APP_INDICATOR (self)); - if (self->priv->status != status) - { - GEnumValue *value = g_enum_get_value ((GEnumClass *) g_type_class_ref (APP_INDICATOR_TYPE_INDICATOR_STATUS), status); + if (self->priv->status != status) { + GEnumValue *value = g_enum_get_value ((GEnumClass *) g_type_class_ref (APP_INDICATOR_TYPE_INDICATOR_STATUS), status); - self->priv->status = status; - g_signal_emit (self, signals[NEW_STATUS], 0, value->value_nick); - } + self->priv->status = status; + g_signal_emit (self, signals[NEW_STATUS], 0, value->value_nick); + + if (self->priv->dbus_registration != 0 && self->priv->connection != NULL) { + GError * error = NULL; + + g_dbus_connection_emit_signal(self->priv->connection, + NULL, + self->priv->path, + NOTIFICATION_ITEM_DBUS_IFACE, + "NewStatus", + g_variant_new("(s)", value->value_nick), + &error); + + if (error != NULL) { + g_warning("Unable to send signal for NewStatus: %s", error->message); + g_error_free(error); + } + } + } + + return; } /** @@ -1493,20 +1550,36 @@ app_indicator_set_status (AppIndicator *self, AppIndicatorStatus status) void app_indicator_set_attention_icon (AppIndicator *self, const gchar *icon_name) { - g_return_if_fail (IS_APP_INDICATOR (self)); - g_return_if_fail (icon_name != NULL); + g_return_if_fail (IS_APP_INDICATOR (self)); + g_return_if_fail (icon_name != NULL); - if (g_strcmp0 (self->priv->attention_icon_name, icon_name) != 0) - { - if (self->priv->attention_icon_name) - g_free (self->priv->attention_icon_name); + if (g_strcmp0 (self->priv->attention_icon_name, icon_name) != 0) { + if (self->priv->attention_icon_name) + g_free (self->priv->attention_icon_name); - self->priv->attention_icon_name = g_strdup(icon_name); + self->priv->attention_icon_name = g_strdup(icon_name); - g_signal_emit (self, signals[NEW_ATTENTION_ICON], 0, TRUE); - } + g_signal_emit (self, signals[NEW_ATTENTION_ICON], 0, TRUE); - return; + if (self->priv->dbus_registration != 0 && self->priv->connection != NULL) { + GError * error = NULL; + + g_dbus_connection_emit_signal(self->priv->connection, + NULL, + self->priv->path, + NOTIFICATION_ITEM_DBUS_IFACE, + "NewAttentionIcon", + NULL, + &error); + + if (error != NULL) { + g_warning("Unable to send signal for NewAttentionIcon: %s", error->message); + g_error_free(error); + } + } + } + + return; } /** @@ -1522,20 +1595,36 @@ app_indicator_set_attention_icon (AppIndicator *self, const gchar *icon_name) void app_indicator_set_icon (AppIndicator *self, const gchar *icon_name) { - g_return_if_fail (IS_APP_INDICATOR (self)); - g_return_if_fail (icon_name != NULL); + g_return_if_fail (IS_APP_INDICATOR (self)); + g_return_if_fail (icon_name != NULL); - if (g_strcmp0 (self->priv->icon_name, icon_name) != 0) - { - if (self->priv->icon_name) - g_free (self->priv->icon_name); + if (g_strcmp0 (self->priv->icon_name, icon_name) != 0) { + if (self->priv->icon_name) + g_free (self->priv->icon_name); - self->priv->icon_name = g_strdup(icon_name); + self->priv->icon_name = g_strdup(icon_name); - g_signal_emit (self, signals[NEW_ICON], 0, TRUE); - } + g_signal_emit (self, signals[NEW_ICON], 0, TRUE); - return; + if (self->priv->dbus_registration != 0 && self->priv->connection != NULL) { + GError * error = NULL; + + g_dbus_connection_emit_signal(self->priv->connection, + NULL, + self->priv->path, + NOTIFICATION_ITEM_DBUS_IFACE, + "NewIcon", + NULL, + &error); + + if (error != NULL) { + g_warning("Unable to send signal for NewIcon: %s", error->message); + g_error_free(error); + } + } + } + + return; } /** @@ -1573,19 +1662,35 @@ app_indicator_set_label (AppIndicator *self, const gchar * label, const gchar * void app_indicator_set_icon_theme_path (AppIndicator *self, const gchar *icon_theme_path) { - g_return_if_fail (IS_APP_INDICATOR (self)); + g_return_if_fail (IS_APP_INDICATOR (self)); - if (g_strcmp0 (self->priv->icon_theme_path, icon_theme_path) != 0) - { - if (self->priv->icon_theme_path != NULL) - g_free(self->priv->icon_theme_path); + if (g_strcmp0 (self->priv->icon_theme_path, icon_theme_path) != 0) { + if (self->priv->icon_theme_path != NULL) + g_free(self->priv->icon_theme_path); - self->priv->icon_theme_path = g_strdup(icon_theme_path); + self->priv->icon_theme_path = g_strdup(icon_theme_path); - g_signal_emit (self, signals[NEW_ICON_THEME_PATH], 0, g_strdup(self->priv->icon_theme_path)); - } + g_signal_emit (self, signals[NEW_ICON_THEME_PATH], 0, self->priv->icon_theme_path, TRUE); - return; + if (self->priv->dbus_registration != 0 && self->priv->connection != NULL) { + GError * error = NULL; + + g_dbus_connection_emit_signal(self->priv->connection, + NULL, + self->priv->path, + NOTIFICATION_ITEM_DBUS_IFACE, + "NewIconThemePath", + g_variant_new("(s)", self->priv->icon_theme_path), + &error); + + if (error != NULL) { + g_warning("Unable to send signal for NewIconThemePath: %s", error->message); + g_error_free(error); + } + } + } + + return; } static void -- cgit v1.2.3 From 05d072b4e78d6e4f5e4c9e85d01dc0d704c70d80 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 6 Dec 2010 20:57:41 -0600 Subject: Changing what we're checking with the watcher, now that it's persistant more of the time we need to not block if it exists. --- src/app-indicator.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index dc9fb47..5260f58 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -1035,14 +1035,16 @@ check_connect (AppIndicator *self) /* Do we have a connection? */ if (priv->connection == NULL) return; - /* We're alreadying connecting or trying to connect. */ - if (priv->watcher_proxy != NULL) return; - - gchar * name = g_dbus_proxy_get_name_owner(priv->watcher_proxy); - if (name == NULL) { - return; + /* If we already have a proxy, let's see if it has someone + implementing it. If not, we can't do much more than to + do nothing. */ + if (priv->watcher_proxy != NULL) { + gchar * name = g_dbus_proxy_get_name_owner(priv->watcher_proxy); + if (name == NULL) { + return; + } + g_free(name); } - g_free(name); /* Do we have enough information? */ if (priv->menu == NULL) return; -- cgit v1.2.3 From 9530e6993889a539081131ab1bd14635062569fa Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 8 Dec 2010 09:38:31 -0600 Subject: Dropping the 'MENU' property as we don't need it. --- src/app-indicator.c | 28 ---------------------------- 1 file changed, 28 deletions(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 5260f58..3ecf9c5 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -31,9 +31,6 @@ License version 3 and version 2.1 along with this program. If not, see #include "config.h" #endif -#include -#include - #include #include #ifdef HAVE_GTK3 @@ -124,7 +121,6 @@ enum { PROP_ICON_NAME, PROP_ATTENTION_ICON_NAME, PROP_ICON_THEME_PATH, - PROP_MENU, PROP_CONNECTED, PROP_LABEL, PROP_LABEL_GUIDE, @@ -139,7 +135,6 @@ enum { #define PROP_ICON_NAME_S "icon-name" #define PROP_ATTENTION_ICON_NAME_S "attention-icon-name" #define PROP_ICON_THEME_PATH_S "icon-theme-path" -#define PROP_MENU_S "menu" #define PROP_CONNECTED_S "connected" #define PROP_LABEL_S "label" #define PROP_LABEL_GUIDE_S "label-guide" @@ -302,19 +297,6 @@ app_indicator_class_init (AppIndicatorClass *klass) NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT)); - /** - AppIndicator:menu: - - A method for getting the menu path as a string for DBus. - */ - g_object_class_install_property(object_class, - PROP_MENU, - g_param_spec_boxed (PROP_MENU_S, - "The object path of the menu on DBus.", - "A method for getting the menu path as a string for DBus.", - DBUS_TYPE_G_OBJECT_PATH, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - /** AppIndicator:connected: @@ -852,16 +834,6 @@ app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GPa case PROP_ICON_THEME_PATH: g_value_set_string (value, priv->icon_theme_path); - break; - - case PROP_MENU: - if (priv->menuservice != NULL) { - GValue strval = { 0 }; - g_value_init(&strval, G_TYPE_STRING); - g_object_get_property (G_OBJECT (priv->menuservice), DBUSMENU_SERVER_PROP_DBUS_OBJECT, &strval); - g_value_set_boxed(value, g_value_get_string(&strval)); - g_value_unset(&strval); - } break; case PROP_CONNECTED: { -- cgit v1.2.3 From b9d669083f761e75c4c62b23055ca5e103cd8a2c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 8 Dec 2010 10:03:28 -0600 Subject: Making sure to ref the object when doing the async callback. --- src/app-indicator.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 3ecf9c5..99c7fed 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -543,6 +543,7 @@ app_indicator_init (AppIndicator *self) priv->shorties = NULL; /* Start getting the session bus */ + g_object_ref(self); /* ref for the bus creation callback */ g_bus_get(G_BUS_TYPE_SESSION, NULL, bus_creation, self); g_signal_connect(G_OBJECT(gtk_icon_theme_get_default()), @@ -895,6 +896,9 @@ bus_creation (GObject * obj, GAsyncResult * res, gpointer user_data) /* If the connection was blocking the exporting of the object this function will export everything. */ check_connect(app); + + g_object_unref(G_OBJECT(app)); + return; } -- cgit v1.2.3 From 52375e6f27d268b13227b1f51b6a126e4df3a435 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 8 Dec 2010 10:05:54 -0600 Subject: Adding a ref for creating the bus proxy. --- src/app-indicator.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 99c7fed..744590b 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -1052,6 +1052,7 @@ check_connect (AppIndicator *self) want to ensure all the filters are setup before talking to the watcher and that's where the order is important. */ + g_object_ref(G_OBJECT(self)); /* Unref in watcher_ready() */ if (priv->watcher_proxy == NULL) { /* Build Watcher Proxy */ g_dbus_proxy_new(priv->connection, @@ -1120,6 +1121,8 @@ bus_watcher_ready (GObject * obj, GAsyncResult * res, gpointer user_data) register_service_cb, user_data); + g_object_unref(G_OBJECT(user_data)); + return; } -- cgit v1.2.3 From 7fae05b11eea1644bf0a0a7e773c7753a9b620d8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 8 Dec 2010 10:11:30 -0600 Subject: Making sure we have more ref's on our callbacks. --- src/app-indicator.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 744590b..2b45b85 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -887,6 +887,7 @@ bus_creation (GObject * obj, GAsyncResult * res, gpointer user_data) if (error != NULL) { g_warning("Unable to get the session bus: %s", error->message); g_error_free(error); + g_object_unref(G_OBJECT(user_data)); return; } @@ -1091,6 +1092,8 @@ bus_watcher_ready (GObject * obj, GAsyncResult * res, gpointer user_data) if (IS_APP_INDICATOR(user_data)) { start_fallback_timer(APP_INDICATOR(user_data), FALSE); } + + g_object_unref(G_OBJECT(user_data)); return; } @@ -1109,9 +1112,15 @@ bus_watcher_ready (GObject * obj, GAsyncResult * res, gpointer user_data) gchar * name = g_dbus_proxy_get_name_owner(app->priv->watcher_proxy); if (name == NULL) { start_fallback_timer(APP_INDICATOR(user_data), FALSE); + g_object_unref(G_OBJECT(user_data)); return; } + /* g_object_unref(G_OBJECT(user_data)); */ + /* Why is this commented out? Oh, wait, we don't want to + unref in this case because we need to ref again to do the + register callback. Let's not unref to ref again. */ + g_dbus_proxy_call(app->priv->watcher_proxy, "RegisterStatusNotifierItem", g_variant_new("(s)", app->priv->path), @@ -1121,8 +1130,6 @@ bus_watcher_ready (GObject * obj, GAsyncResult * res, gpointer user_data) register_service_cb, user_data); - g_object_unref(G_OBJECT(user_data)); - return; } @@ -1173,6 +1180,7 @@ register_service_cb (GObject * obj, GAsyncResult * res, gpointer user_data) be doing */ g_warning("Unable to connect to the Notification Watcher: %s", error->message); start_fallback_timer(APP_INDICATOR(user_data), TRUE); + g_object_unref(G_OBJECT(user_data)); return; } @@ -1191,6 +1199,7 @@ register_service_cb (GObject * obj, GAsyncResult * res, gpointer user_data) } } + g_object_unref(G_OBJECT(user_data)); return; } -- cgit v1.2.3 From 41edd6b1dd171d887fe6bc860a1451358b630add Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 8 Dec 2010 11:00:54 -0600 Subject: Adding in some '_' so that the symbols don't get exported in the library. --- src/app-indicator.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 2b45b85..404d69d 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -477,7 +477,7 @@ app_indicator_class_init (AppIndicatorClass *klass) if (item_node_info == NULL) { GError * error = NULL; - item_node_info = g_dbus_node_info_new_for_xml(notification_item, &error); + item_node_info = g_dbus_node_info_new_for_xml(_notification_item, &error); if (error != NULL) { g_error("Unable to parse Notification Item DBus interface: %s", error->message); g_error_free(error); @@ -495,7 +495,7 @@ app_indicator_class_init (AppIndicatorClass *klass) if (watcher_node_info == NULL) { GError * error = NULL; - watcher_node_info = g_dbus_node_info_new_for_xml(notification_watcher, &error); + watcher_node_info = g_dbus_node_info_new_for_xml(_notification_watcher, &error); if (error != NULL) { g_error("Unable to parse Notification Item DBus interface: %s", error->message); g_error_free(error); @@ -2300,7 +2300,7 @@ app_indicator_get_ordering_index (AppIndicator *self) g_return_val_if_fail (IS_APP_INDICATOR (self), 0); if (self->priv->ordering_index == 0) { - return generate_id(self->priv->category, self->priv->id); + return _generate_id(self->priv->category, self->priv->id); } else { return self->priv->ordering_index; } -- cgit v1.2.3 From 5b8d8f97aa46c2d56e7c4bbc244dafe378b60e8d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 8 Dec 2010 14:50:01 -0600 Subject: Wrong directory for the GTK 3 header. Fixed. --- src/app-indicator.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 404d69d..babdaf5 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -33,11 +33,7 @@ License version 3 and version 2.1 along with this program. If not, see #include #include -#ifdef HAVE_GTK3 -#include -#else #include -#endif #include -- cgit v1.2.3