aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/im-client.c46
-rw-r--r--tests/listen-and-print.c53
2 files changed, 92 insertions, 7 deletions
diff --git a/tests/im-client.c b/tests/im-client.c
index db04b8e..3419a9d 100644
--- a/tests/im-client.c
+++ b/tests/im-client.c
@@ -23,6 +23,36 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "libindicate/server.h"
#include "libindicate/indicator-message.h"
+gchar * patha = "/usr/share/icons/hicolor/16x16/apps/empathy.png";
+gchar * pathb = "/usr/share/icons/hicolor/22x22/apps/empathy.png";
+gchar * lastpath = NULL;
+
+static gboolean
+timeout_cb (gpointer data)
+{
+ g_debug("Modifying properties");
+
+ IndicateIndicator * indicator = INDICATE_INDICATOR(data);
+
+ GTimeVal time;
+ g_get_current_time(&time);
+ indicate_indicator_set_property_time(INDICATE_INDICATOR(indicator), "time", &time);
+
+ if (lastpath == patha) {
+ lastpath = pathb;
+ } else {
+ lastpath = patha;
+ }
+
+ GdkPixbuf * pixbuf = gdk_pixbuf_new_from_file(lastpath, NULL);
+ g_return_val_if_fail(pixbuf != NULL, TRUE);
+
+ indicate_indicator_set_property_icon(INDICATE_INDICATOR(indicator), "icon", pixbuf);
+ g_object_unref(G_OBJECT(pixbuf));
+
+ return TRUE;
+}
+
static void
display (IndicateIndicator * indicator, gpointer data)
{
@@ -35,23 +65,25 @@ main (int argc, char ** argv)
g_type_init();
IndicateServer * server = indicate_server_ref_default();
- GValue value = {0};
- g_value_init(&value, G_TYPE_STRING);
- g_value_set_static_string(&value, "message.im");
- g_object_set_property(G_OBJECT(server), "type", &value);
+ indicate_server_set_type(server, "message.im");
+ indicate_server_set_desktop_file(server, "/usr/share/applications/empathy.desktop");
IndicateIndicatorMessage * indicator;
indicator = indicate_indicator_message_new();
indicate_indicator_set_property(INDICATE_INDICATOR(indicator), "subtype", "im");
- indicate_indicator_set_property(INDICATE_INDICATOR(indicator), "sender", "Ted Gould");
- indicate_indicator_set_property(INDICATE_INDICATOR(indicator), "time", "11:11");
+ indicate_indicator_set_property(INDICATE_INDICATOR(indicator), "sender", "IM Client Test");
+ GTimeVal time; g_get_current_time(&time);
+ indicate_indicator_set_property_time(INDICATE_INDICATOR(indicator), "time", &time);
indicate_indicator_show(INDICATE_INDICATOR(indicator));
- indicate_indicator_set_property(INDICATE_INDICATOR(indicator), "time", "11:12");
+ g_get_current_time(&time);
+ indicate_indicator_set_property_time(INDICATE_INDICATOR(indicator), "time", &time);
g_signal_connect(G_OBJECT(indicator), INDICATE_INDICATOR_SIGNAL_DISPLAY, G_CALLBACK(display), NULL);
+ g_timeout_add_seconds(180, timeout_cb, indicator);
+
g_main_loop_run(g_main_loop_new(NULL, FALSE));
return 0;
diff --git a/tests/listen-and-print.c b/tests/listen-and-print.c
index 6e1104d..a4c8c25 100644
--- a/tests/listen-and-print.c
+++ b/tests/listen-and-print.c
@@ -23,9 +23,61 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "libindicate/listener.h"
static void
+show_property_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, gchar * propertydata, gpointer data)
+{
+ g_debug("Indicator Property: %s %d %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), INDICATE_LISTENER_INDICATOR_ID(indicator), property, propertydata);
+ return;
+}
+
+static void
+show_property_time_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GTimeVal * propertydata, gpointer data)
+{
+ time_t timet;
+ struct tm * structtm;
+
+ timet = propertydata->tv_sec;
+ structtm = localtime(&timet);
+
+ gchar timestring[80];
+ strftime(timestring, 80, "%I:%M", structtm);
+
+ g_debug("Indicator Property: %s %d %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), INDICATE_LISTENER_INDICATOR_ID(indicator), property, timestring);
+ return;
+}
+
+static void
+show_property_icon_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GdkPixbuf * propertydata, gpointer data)
+{
+ g_debug("Indicator Property: %s %d %s %dx%d", INDICATE_LISTENER_SERVER_DBUS_NAME(server), INDICATE_LISTENER_INDICATOR_ID(indicator), property, gdk_pixbuf_get_width(propertydata), gdk_pixbuf_get_height(propertydata));
+ g_object_unref(G_OBJECT(propertydata));
+ return;
+}
+
+static void
+show_property (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property)
+{
+ if (!strcmp(property, "icon")) {
+ indicate_listener_get_property_icon(listener, server, indicator, property, show_property_icon_cb, NULL);
+ } else if (!strcmp(property, "time")) {
+ indicate_listener_get_property_time(listener, server, indicator, property, show_property_time_cb, NULL);
+ } else {
+ indicate_listener_get_property(listener, server, indicator, property, show_property_cb, NULL);
+ }
+
+ return;
+}
+
+static void
+get_properties (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator)
+{
+ //TODO: Not in API yet.
+}
+
+static void
indicator_added (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gpointer data)
{
g_debug("Indicator Added: %s %d %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), INDICATE_LISTENER_INDICATOR_ID(indicator), type);
+ get_properties(listener, server, indicator);
}
static void
@@ -38,6 +90,7 @@ static void
indicator_modified (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gchar * property, gpointer data)
{
g_debug("Indicator Modified: %s %d %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), INDICATE_LISTENER_INDICATOR_ID(indicator), type, property);
+ show_property(listener, server, indicator, property);
}
static void