~ubuntu-branches/ubuntu/trusty/hud/trusty-updates

« back to all changes in this revision

Viewing changes to tests/menus/test-menu-input-model-toolbar-unknown.c

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2014-01-20 19:43:59 UTC
  • mfrom: (1.1.26)
  • Revision ID: package-import@ubuntu.com-20140120194359-jxxxqtd4ql9elvpf
Tags: 13.10.1+14.04.20140120-0ubuntu1
* New rebuild forced
* Automatic snapshot from revision 362

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright 2012 Canonical Ltd.
 
3
 
 
4
Authors:
 
5
    Ted Gould <ted@canonical.com>
 
6
 
 
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.
 
10
 
 
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.
 
15
 
 
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/>.
 
18
*/
 
19
 
 
20
#include <glib-object.h>
 
21
#include <gio/gio.h>
 
22
 
 
23
int
 
24
main (int argv, char ** argc)
 
25
{
 
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]);
 
28
                return 1;
 
29
        }
 
30
 
 
31
#ifndef GLIB_VERSION_2_36
 
32
        g_type_init ();
 
33
#endif
 
34
 
 
35
        gboolean is_application = (argv == 4 && !g_strcmp0(argc[3], "TRUE"));
 
36
 
 
37
        GMenu * menu = g_menu_new();
 
38
        GMenuItem * item = NULL;
 
39
        if (is_application)
 
40
          item = g_menu_item_new("Simple", "app.simple");
 
41
        else
 
42
          item = g_menu_item_new("Simple", "simple");
 
43
 
 
44
        g_menu_item_set_attribute_value(item, "hud-toolbar-item", g_variant_new_string("unknown"));
 
45
        g_menu_append_item(menu, item);
 
46
 
 
47
        GSimpleActionGroup * ag = g_simple_action_group_new();
 
48
        if (is_application)
 
49
          g_action_map_add_action(G_ACTION_MAP(ag), G_ACTION(g_simple_action_new("app.simple", G_VARIANT_TYPE_BOOLEAN)));
 
50
        else
 
51
          g_action_map_add_action(G_ACTION_MAP(ag), G_ACTION(g_simple_action_new("simple", G_VARIANT_TYPE_BOOLEAN)));
 
52
 
 
53
        GDBusConnection * session = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
 
54
 
 
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);
 
57
 
 
58
        g_bus_own_name(G_BUS_TYPE_SESSION, argc[1], 0, NULL, NULL, NULL, NULL, NULL);
 
59
 
 
60
        GMainLoop * mainloop = g_main_loop_new(NULL, FALSE);
 
61
        g_main_loop_run(mainloop);
 
62
 
 
63
        return 0;
 
64
}