Back to index

libappindicator  12.10.0
test-libappindicator-dbus-server.c
Go to the documentation of this file.
00001 /*
00002 Tests for the libappindicator library that are over DBus.  This is
00003 the server side of those tests.
00004 
00005 Copyright 2009 Canonical Ltd.
00006 
00007 Authors:
00008     Ted Gould <ted@canonical.com>
00009 
00010 This program is free software: you can redistribute it and/or modify it
00011 under the terms of the GNU General Public License version 3, as published
00012 by the Free Software Foundation.
00013 
00014 This program is distributed in the hope that it will be useful, but
00015 WITHOUT ANY WARRANTY; without even the implied warranties of
00016 MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
00017 PURPOSE.  See the GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License along
00020 with this program.  If not, see <http://www.gnu.org/licenses/>.
00021 */
00022 
00023 
00024 #include <gtk/gtk.h>
00025 #include <app-indicator.h>
00026 #include "test-defines.h"
00027 
00028 static GMainLoop * mainloop = NULL;
00029 
00030 gboolean
00031 kill_func (gpointer userdata)
00032 {
00033        g_main_loop_quit(mainloop);
00034        return FALSE;
00035 }
00036 
00037 gint
00038 main (gint argc, gchar * argv[])
00039 {
00040        gtk_init(&argc, &argv);
00041 
00042        AppIndicator * ci = app_indicator_new (TEST_ID, TEST_ICON_NAME, TEST_CATEGORY);
00043 
00044        app_indicator_set_status (ci, TEST_STATE);
00045        app_indicator_set_attention_icon (ci, TEST_ATTENTION_ICON_NAME);
00046 
00047        GtkMenu * menu = GTK_MENU(gtk_menu_new());
00048        GtkMenuItem * item = GTK_MENU_ITEM(gtk_menu_item_new_with_label("Label"));
00049        gtk_menu_shell_append(GTK_MENU_SHELL(menu), GTK_WIDGET(item));
00050 
00051        app_indicator_set_menu(ci, menu);
00052 
00053        g_timeout_add_seconds(2, kill_func, NULL);
00054 
00055        mainloop = g_main_loop_new(NULL, FALSE);
00056        g_main_loop_run(mainloop);
00057 
00058        g_object_unref(G_OBJECT(ci));
00059        g_debug("Quiting");
00060 
00061        return 0;
00062 }