Back to index

indicator-appmenu  12.10.0
Functions
menu-pusher.c File Reference
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <libdbusmenu-glib/menuitem.h>
#include <libdbusmenu-glib/server.h>
#include <libdbusmenu-gtk/menuitem.h>
#include "../src/dbus-shared.h"

Go to the source code of this file.

Functions

int main (int argv, char **argc)

Function Documentation

int main ( int  argv,
char **  argc 
)

Definition at line 30 of file menu-pusher.c.

{
       gtk_init(&argv, &argc);

       DbusmenuMenuitem * root = dbusmenu_menuitem_new();

       DbusmenuMenuitem * firstlevel = dbusmenu_menuitem_new();
       dbusmenu_menuitem_property_set(firstlevel, DBUSMENU_MENUITEM_PROP_LABEL, "File");
       dbusmenu_menuitem_child_append(root, firstlevel);

       DbusmenuMenuitem * secondlevel = dbusmenu_menuitem_new();
       dbusmenu_menuitem_property_set(secondlevel, DBUSMENU_MENUITEM_PROP_LABEL, "Open");
       dbusmenu_menuitem_property_set_shortcut_string(secondlevel, "<Control>O");
       dbusmenu_menuitem_child_append(firstlevel, secondlevel);

       secondlevel = dbusmenu_menuitem_new();
       dbusmenu_menuitem_property_set(secondlevel, DBUSMENU_MENUITEM_PROP_LABEL, "Save");
       dbusmenu_menuitem_property_set_shortcut_string(secondlevel, "<Control>S");
       dbusmenu_menuitem_child_append(firstlevel, secondlevel);

       secondlevel = dbusmenu_menuitem_new();
       dbusmenu_menuitem_property_set(secondlevel, DBUSMENU_MENUITEM_PROP_LABEL, "Exit");
       dbusmenu_menuitem_child_append(firstlevel, secondlevel);

       firstlevel = dbusmenu_menuitem_new();
       dbusmenu_menuitem_property_set(firstlevel, DBUSMENU_MENUITEM_PROP_LABEL, "Edit");
       dbusmenu_menuitem_child_append(root, firstlevel);

       secondlevel = dbusmenu_menuitem_new();
       dbusmenu_menuitem_property_set(secondlevel, DBUSMENU_MENUITEM_PROP_LABEL, "Copy");
       dbusmenu_menuitem_child_append(firstlevel, secondlevel);

       secondlevel = dbusmenu_menuitem_new();
       dbusmenu_menuitem_property_set(secondlevel, DBUSMENU_MENUITEM_PROP_LABEL, "Paste");
       dbusmenu_menuitem_child_append(firstlevel, secondlevel);

       secondlevel = dbusmenu_menuitem_new();
       dbusmenu_menuitem_property_set(secondlevel, DBUSMENU_MENUITEM_PROP_LABEL, "Cut");
       dbusmenu_menuitem_child_append(firstlevel, secondlevel);


       DbusmenuServer * server = dbusmenu_server_new("/this/is/a/long/object/path");
       dbusmenu_server_set_root(server, root);


       GDBusProxy * proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SESSION,
                                                          G_DBUS_PROXY_FLAGS_NONE,
                                                          NULL, DBUS_NAME,
                                                          REG_OBJECT, REG_IFACE,
                                                          NULL, NULL);
       g_return_val_if_fail(proxy != NULL, 1);

       g_dbus_proxy_call_sync(proxy, "RegisterWindow",
                              g_variant_new("(uo)", 0, "/this/is/a/long/object/path"),
                              G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL);

       gtk_main();

       return 0;
}