1 /* 2 A library to take the object model made consistent by libdbusmenu-glib 3 and visualize it in GTK. 4 5 Copyright 2009 Canonical Ltd. 6 7 Authors: 8 Ted Gould <ted@canonical.com> 9 10 This program is free software: you can redistribute it and/or modify it 11 under the terms of either or both of the following licenses: 12 13 1) the GNU Lesser General Public License version 3, as published by the 14 Free Software Foundation; and/or 15 2) the GNU Lesser General Public License version 2.1, as published by 16 the Free Software Foundation. 17 18 This program is distributed in the hope that it will be useful, but 19 WITHOUT ANY WARRANTY; without even the implied warranties of 20 MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR 21 PURPOSE. See the applicable version of the GNU Lesser General Public 22 License for more details. 23 24 You should have received a copy of both the GNU Lesser General Public 25 License version 3 and version 2.1 along with this program. If not, see 26 <http://www.gnu.org/licenses/> 27 */ 28 29 #ifndef __DBUSMENU_GTKCLIENT_H__ 30 #define __DBUSMENU_GTKCLIENT_H__ 31 32 #include <gtk/gtk.h> 33 #include <libdbusmenu-glib/client.h> 34 35 G_BEGIN_DECLS 36 37 #define DBUSMENU_GTKCLIENT_TYPE (dbusmenu_gtkclient_get_type ()) 38 #define DBUSMENU_GTKCLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DBUSMENU_GTKCLIENT_TYPE, DbusmenuGtkClient)) 39 #define DBUSMENU_GTKCLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DBUSMENU_GTKCLIENT_TYPE, DbusmenuGtkClientClass)) 40 #define DBUSMENU_IS_GTKCLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DBUSMENU_GTKCLIENT_TYPE)) 41 #define DBUSMENU_IS_GTKCLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUSMENU_GTKCLIENT_TYPE)) 42 #define DBUSMENU_GTKCLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUSMENU_GTKCLIENT_TYPE, DbusmenuGtkClientClass)) 43 44 /** 45 * DBUSMENU_GTKCLIENT_SIGNAL_ROOT_CHANGED: 46 * 47 * String to attach to signal #DbusmenuClient::root-changed 48 */ 49 #define DBUSMENU_GTKCLIENT_SIGNAL_ROOT_CHANGED DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED 50 51 typedef struct _DbusmenuGtkClientPrivate DbusmenuGtkClientPrivate; 52 53 /** 54 * DbusmenuGtkClientClass: 55 * @parent_class: #GtkMenuClass 56 * @root_changed: Slot for signal #DbusmenuGtkClient::root-changed 57 * @reserved1: Reserved for future use. 58 * @reserved2: Reserved for future use. 59 * @reserved3: Reserved for future use. 60 * @reserved4: Reserved for future use. 61 * @reserved5: Reserved for future use. 62 * @reserved6: Reserved for future use. 63 * 64 * Functions and signal slots for using a #DbusmenuGtkClient 65 */ 66 typedef struct _DbusmenuGtkClientClass DbusmenuGtkClientClass; 67 struct _DbusmenuGtkClientClass { 68 DbusmenuClientClass parent_class; 69 70 /* Signals */ 71 void (*root_changed) (DbusmenuMenuitem * newroot); 72 73 /*< Private >*/ 74 void (*reserved1) (void); 75 void (*reserved2) (void); 76 void (*reserved3) (void); 77 void (*reserved4) (void); 78 void (*reserved5) (void); 79 void (*reserved6) (void); 80 }; 81 82 /** 83 * DbusmenuGtkClient: 84 * 85 * A subclass of #DbusmenuClient to add functionality with regarding 86 * building GTK items out of the abstract tree. 87 */ 88 typedef struct _DbusmenuGtkClient DbusmenuGtkClient; 89 struct _DbusmenuGtkClient { 90 /*< private >*/ 91 DbusmenuClient parent; 92 93 /*< Private >*/ 94 DbusmenuGtkClientPrivate * priv; 95 }; 96 97 GType dbusmenu_gtkclient_get_type (void); 98 DbusmenuGtkClient * dbusmenu_gtkclient_new (gchar * dbus_name, gchar * dbus_object); 99 GtkMenuItem * dbusmenu_gtkclient_menuitem_get (DbusmenuGtkClient * client, DbusmenuMenuitem * item); 100 GtkMenu * dbusmenu_gtkclient_menuitem_get_submenu (DbusmenuGtkClient * client, DbusmenuMenuitem * item); 101 102 void dbusmenu_gtkclient_set_accel_group (DbusmenuGtkClient * client, GtkAccelGroup * agroup); 103 GtkAccelGroup * dbusmenu_gtkclient_get_accel_group (DbusmenuGtkClient * client); 104 105 void dbusmenu_gtkclient_newitem_base (DbusmenuGtkClient * client, DbusmenuMenuitem * item, GtkMenuItem * gmi, DbusmenuMenuitem * parent); 106 107 /** 108 SECTION:client 109 @short_description: A subclass of #DbusmenuClient adding GTK level features 110 @stability: Unstable 111 @include: libdbusmenu-gtk/client.h 112 113 In general, this is just a #GtkMenu, why else would you care? Oh, 114 because this menu is created by someone else on a server that exists 115 on the other side of DBus. You need a #DbusmenuServer to be able 116 push the data into this menu. 117 118 The first thing you need to know is how to find that #DbusmenuServer 119 on DBus. This involves both the DBus name and the DBus object that 120 the menu interface can be found on. Those two value should be set 121 when creating the object using dbusmenu_gtkmenu_new(). They are then 122 stored on two properties #DbusmenuGtkClient:dbus-name and #DbusmenuGtkClient:dbus-object. 123 124 After creation the #DbusmenuGtkClient it will continue to keep in 125 synchronization with the #DbusmenuServer object across Dbus. If the 126 number of entries change, the menus change, if they change thier 127 properties change, they update in the items. All of this should 128 be handled transparently to the user of this object. 129 */ 130 G_END_DECLS 131 132 #endif 133