2
Copyright 2012 Canonical Ltd.
5
Ted Gould <ted@canonical.com>
7
This program is free software: you can redistribute it and/or modify it
8
under the terms of the GNU General Public License version 3, as published
9
by the Free Software Foundation.
11
This program is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranties of
13
MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14
PURPOSE. See the GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License along
17
with this program. If not, see <http://www.gnu.org/licenses/>.
20
#include <glib-object.h>
24
main (int argv, char ** argc)
26
if (!(argv == 3 || argv == 4)) {
27
g_print("'%s <DBus name> <Object Path> [Is Application]' is how you should use this program.\n", argc[0]);
31
#ifndef GLIB_VERSION_2_36
35
gboolean is_application = (argv == 4 && !g_strcmp0(argc[3], "TRUE"));
37
GMenu * menu = g_menu_new();
38
GMenuItem * item = NULL;
40
item = g_menu_item_new("Simple", "app.simple");
42
item = g_menu_item_new("Simple", "simple");
44
g_menu_item_set_attribute_value(item, "hud-toolbar-item", g_variant_new_string("unknown"));
45
g_menu_append_item(menu, item);
47
GSimpleActionGroup * ag = g_simple_action_group_new();
49
g_action_map_add_action(G_ACTION_MAP(ag), G_ACTION(g_simple_action_new("app.simple", G_VARIANT_TYPE_BOOLEAN)));
51
g_action_map_add_action(G_ACTION_MAP(ag), G_ACTION(g_simple_action_new("simple", G_VARIANT_TYPE_BOOLEAN)));
53
GDBusConnection * session = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
55
g_dbus_connection_export_action_group(session, argc[2], G_ACTION_GROUP(ag), NULL);
56
g_dbus_connection_export_menu_model(session, argc[2], G_MENU_MODEL(menu), NULL);
58
g_bus_own_name(G_BUS_TYPE_SESSION, argc[1], 0, NULL, NULL, NULL, NULL, NULL);
60
GMainLoop * mainloop = g_main_loop_new(NULL, FALSE);
61
g_main_loop_run(mainloop);