Back to index

libindicate  12.10.0
test-icon-theme-server.c
Go to the documentation of this file.
00001 
00002 #include <glib.h>
00003 #include "libindicate/listener.h"
00004 
00005 static gboolean passed = TRUE;
00006 static GMainLoop * mainloop = NULL;
00007 
00008 void
00009 cb (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data)
00010 {
00011        g_debug("Got Icon Theme: %s", value);
00012        if (g_strcmp0(value, "test-theme") != 0) {
00013               passed = FALSE;
00014        }
00015        g_main_loop_quit(mainloop);
00016        return;
00017 }
00018 
00019 static void
00020 server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
00021 {
00022        g_debug("Indicator Server Added:   %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type);
00023        g_debug("\tLooking for theme...");
00024        indicate_listener_server_get_icon_theme(listener, server, cb, NULL);
00025        return;
00026 }
00027 
00028 static gboolean
00029 failed_cb (gpointer data)
00030 {
00031        g_debug("Failed to get a server in 5 seconds.");
00032        passed = FALSE;
00033        g_main_loop_quit(mainloop);
00034        return FALSE;
00035 }
00036 
00037 int
00038 main (int argc, char * argv)
00039 {
00040        g_type_init();
00041 
00042        IndicateListener * listener = indicate_listener_ref_default();
00043 
00044        g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), NULL);
00045 
00046        g_timeout_add_seconds(5, failed_cb, NULL);
00047 
00048        mainloop = g_main_loop_new(NULL, FALSE);
00049        g_main_loop_run(mainloop);
00050 
00051        return !passed;
00052 }