Back to index

indicator-appmenu  12.10.0
menu-pusher.c
Go to the documentation of this file.
00001 /*
00002 A test menu pusher to the appmenu.
00003 
00004 Copyright 2010 Canonical Ltd.
00005 
00006 Authors:
00007     Ted Gould <ted@canonical.com>
00008 
00009 This program is free software: you can redistribute it and/or modify it 
00010 under the terms of the GNU General Public License version 3, as published 
00011 by the Free Software Foundation.
00012 
00013 This program is distributed in the hope that it will be useful, but 
00014 WITHOUT ANY WARRANTY; without even the implied warranties of 
00015 MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 
00016 PURPOSE.  See the GNU General Public License for more details.
00017 
00018 You should have received a copy of the GNU General Public License along 
00019 with this program.  If not, see <http://www.gnu.org/licenses/>.
00020 */
00021 
00022 #include <gtk/gtk.h>
00023 #include <gio/gio.h>
00024 #include <libdbusmenu-glib/menuitem.h>
00025 #include <libdbusmenu-glib/server.h>
00026 #include <libdbusmenu-gtk/menuitem.h>
00027 #include "../src/dbus-shared.h"
00028 
00029 int
00030 main (int argv, char ** argc)
00031 {
00032        gtk_init(&argv, &argc);
00033 
00034        DbusmenuMenuitem * root = dbusmenu_menuitem_new();
00035 
00036        DbusmenuMenuitem * firstlevel = dbusmenu_menuitem_new();
00037        dbusmenu_menuitem_property_set(firstlevel, DBUSMENU_MENUITEM_PROP_LABEL, "File");
00038        dbusmenu_menuitem_child_append(root, firstlevel);
00039 
00040        DbusmenuMenuitem * secondlevel = dbusmenu_menuitem_new();
00041        dbusmenu_menuitem_property_set(secondlevel, DBUSMENU_MENUITEM_PROP_LABEL, "Open");
00042        dbusmenu_menuitem_property_set_shortcut_string(secondlevel, "<Control>O");
00043        dbusmenu_menuitem_child_append(firstlevel, secondlevel);
00044 
00045        secondlevel = dbusmenu_menuitem_new();
00046        dbusmenu_menuitem_property_set(secondlevel, DBUSMENU_MENUITEM_PROP_LABEL, "Save");
00047        dbusmenu_menuitem_property_set_shortcut_string(secondlevel, "<Control>S");
00048        dbusmenu_menuitem_child_append(firstlevel, secondlevel);
00049 
00050        secondlevel = dbusmenu_menuitem_new();
00051        dbusmenu_menuitem_property_set(secondlevel, DBUSMENU_MENUITEM_PROP_LABEL, "Exit");
00052        dbusmenu_menuitem_child_append(firstlevel, secondlevel);
00053 
00054        firstlevel = dbusmenu_menuitem_new();
00055        dbusmenu_menuitem_property_set(firstlevel, DBUSMENU_MENUITEM_PROP_LABEL, "Edit");
00056        dbusmenu_menuitem_child_append(root, firstlevel);
00057 
00058        secondlevel = dbusmenu_menuitem_new();
00059        dbusmenu_menuitem_property_set(secondlevel, DBUSMENU_MENUITEM_PROP_LABEL, "Copy");
00060        dbusmenu_menuitem_child_append(firstlevel, secondlevel);
00061 
00062        secondlevel = dbusmenu_menuitem_new();
00063        dbusmenu_menuitem_property_set(secondlevel, DBUSMENU_MENUITEM_PROP_LABEL, "Paste");
00064        dbusmenu_menuitem_child_append(firstlevel, secondlevel);
00065 
00066        secondlevel = dbusmenu_menuitem_new();
00067        dbusmenu_menuitem_property_set(secondlevel, DBUSMENU_MENUITEM_PROP_LABEL, "Cut");
00068        dbusmenu_menuitem_child_append(firstlevel, secondlevel);
00069 
00070 
00071        DbusmenuServer * server = dbusmenu_server_new("/this/is/a/long/object/path");
00072        dbusmenu_server_set_root(server, root);
00073 
00074 
00075        GDBusProxy * proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SESSION,
00076                                                           G_DBUS_PROXY_FLAGS_NONE,
00077                                                           NULL, DBUS_NAME,
00078                                                           REG_OBJECT, REG_IFACE,
00079                                                           NULL, NULL);
00080        g_return_val_if_fail(proxy != NULL, 1);
00081 
00082        g_dbus_proxy_call_sync(proxy, "RegisterWindow",
00083                               g_variant_new("(uo)", 0, "/this/is/a/long/object/path"),
00084                               G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL);
00085 
00086        gtk_main();
00087 
00088        return 0;
00089 }