Paste Code
Paste Blends
Paste Images
/* client-gtk2.c generated by valac 0.12.1, the Vala compiler
* generated from client-gtk2.vala, do not modify */


#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <gdk/gdkx.h>
#include <gdk/gdk.h>


#define TYPE_MENU (menu_get_type ())
#define MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MENU, Menu))
#define MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MENU, MenuClass))
#define IS_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MENU))
#define IS_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MENU))
#define MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MENU, MenuClass))

typedef struct _Menu Menu;
typedef struct _MenuClass MenuClass;
typedef struct _MenuPrivate MenuPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block1Data Block1Data;

#define TYPE_MANAGER (manager_get_type ())
#define MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MANAGER, Manager))
#define IS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MANAGER))
#define MANAGER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_MANAGER, ManagerIface))

typedef struct _Manager Manager;
typedef struct _ManagerIface ManagerIface;

#define TYPE_MANAGER_PROXY (manager_proxy_get_type ())
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_list_free0(var) ((var == NULL) ? NULL : (var = (g_list_free (var), NULL)))
typedef struct _Block2Data Block2Data;
typedef struct _Block3Data Block3Data;
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
typedef struct _Block4Data Block4Data;
typedef struct _Block5Data Block5Data;
typedef GDBusProxy ManagerProxy;
typedef GDBusProxyClass ManagerProxyClass;
#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))

struct _Menu {
GObject parent_instance;
MenuPrivate * priv;
};

struct _MenuClass {
GObjectClass parent_class;
};

struct _MenuPrivate {
guint64 _xwindow;
GtkMenuShell* shell;
gulong realize_handler_id;
gulong unrealize_handler_id;
};

struct _Block1Data {
int _ref_count_;
guint reg_id;
};

struct _ManagerIface {
GTypeInterface parent_iface;
void (*add) (Manager* self, const gchar* object_path, GError** error);
};

struct _Block2Data {
int _ref_count_;
Menu * self;
GtkMenuItem* cursor;
};

struct _Block3Data {
int _ref_count_;
Block2Data * _data2_;
gint loc;
gint j;
};

struct _Block4Data {
int _ref_count_;
GString* sb;
};

struct _Block5Data {
int _ref_count_;
GtkWidget* rt;
GType type;
};


static gpointer menu_parent_class = NULL;

GType menu_get_type (void) G_GNUC_CONST;
guint menu_register_object (void* object, GDBusConnection* connection, const gchar* path, GError** error);
#define MENU_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MENU, MenuPrivate))
enum {
MENU_DUMMY_PROPERTY,
MENU_XWINDOW
};
void menu_get_ui (Menu* self, const gchar* path, gchar** ui);
static GtkWidget* menu_get_widget (Menu* self, const gchar* path);
static gchar* menu_serialize (GtkWidget* widget);
void menu_emit (Menu* self, const gchar* path);
Menu* menu_new (GtkMenuShell* shell);
Menu* menu_construct (GType object_type, GtkMenuShell* shell);
static void _lambda3_ (GtkWidget* prev, Menu* self);
static void menu_attach_to_toplevel (Menu* self, GtkWidget* toplevel);
static void __lambda3__gtk_widget_hierarchy_changed (GtkWidget* _sender, GtkWidget* previous_toplevel, gpointer self);
void menu_register (GtkMenuShell* shell);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (Block1Data* _data1_);
GType manager_proxy_get_type (void) G_GNUC_CONST;
guint manager_register_object (void* object, GDBusConnection* connection, const gchar* path, GError** error);
GType manager_get_type (void) G_GNUC_CONST;
void manager_add (Manager* self, const gchar* object_path, GError** error);
static void _lambda6_ (GtkObject* shell, Block1Data* _data1_);
static void __lambda6__gtk_object_destroy (GtkObject* _sender, gpointer self);
void menu_lost (GtkMenuShell* shell);
gboolean menu_has_registered (GtkMenuShell* shell);
void menu_register_all (void);
static GtkWidget* menu_widget_by_type (GtkWidget* parent, GType type);
void menu_lost_all (void);
static void _lambda4_ (GtkWidget* obj, Menu* self);
static void menu_set_xwindow (Menu* self, guint64 value);
static void __lambda4__gtk_widget_realize (GtkWidget* _sender, gpointer self);
static void _lambda5_ (GtkWidget* obj, Menu* self);
static void __lambda5__gtk_widget_unrealize (GtkWidget* _sender, gpointer self);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (Block2Data* _data2_);
static Block3Data* block3_data_ref (Block3Data* _data3_);
static void block3_data_unref (Block3Data* _data3_);
static void _lambda0_ (GtkWidget* item, Block3Data* _data3_);
static void __lambda0__gtk_callback (GtkWidget* widget, gpointer self);
static void menu_serialize_to (GString* sb, GtkWidget* widget);
static Block4Data* block4_data_ref (Block4Data* _data4_);
static void block4_data_unref (Block4Data* _data4_);
static void _lambda1_ (GtkWidget* item, Block4Data* _data4_);
static void __lambda1__gtk_callback (GtkWidget* widget, gpointer self);
static Block5Data* block5_data_ref (Block5Data* _data5_);
static void block5_data_unref (Block5Data* _data5_);
static void _lambda2_ (GtkWidget* widget, Block5Data* _data5_);
static void __lambda2__gtk_callback (GtkWidget* widget, gpointer self);
guint64 menu_get_xwindow (Menu* self);
static void menu_finalize (GObject* obj);
static void _vala_menu_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_menu_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
static void _dbus_menu_get_ui (Menu* self, GVariant* parameters, GDBusMethodInvocation* invocation);
static void _dbus_menu_emit (Menu* self, GVariant* parameters, GDBusMethodInvocation* invocation);
static void menu_dbus_interface_method_call (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* method_name, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer user_data);
static GVariant* menu_dbus_interface_get_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GError** error, gpointer user_data);
static GVariant* _dbus_menu_get_xwindow (Menu* self);
static gboolean menu_dbus_interface_set_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GVariant* value, GError** error, gpointer user_data);
static void _dbus_menu_set_xwindow (Menu* self, GVariant* _value);
static void _menu_unregister_object (gpointer user_data);
static void manager_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters);
static void manager_proxy_add (Manager* self, const gchar* object_path, GError** error);
static void manager_proxy_manager_interface_init (ManagerIface* iface);
static void _dbus_manager_add (Manager* self, GVariant* parameters, GDBusMethodInvocation* invocation);
static void manager_dbus_interface_method_call (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* method_name, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer user_data);
static GVariant* manager_dbus_interface_get_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GError** error, gpointer user_data);
static gboolean manager_dbus_interface_set_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GVariant* value, GError** error, gpointer user_data);
static void _manager_unregister_object (gpointer user_data);
void callback (GtkAction* action);
void _vala_main (gchar** args, int args_length1);
static void _callback_gtk_action_callback (GtkAction* action, gpointer self);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
static gint _vala_array_length (gpointer array);

static const GDBusArgInfo _menu_dbus_arg_info_get_ui_path = {-1, "path", "s"};
static const GDBusArgInfo _menu_dbus_arg_info_get_ui_ui = {-1, "ui", "s"};
static const GDBusArgInfo * const _menu_dbus_arg_info_get_ui_in[] = {&_menu_dbus_arg_info_get_ui_path, NULL};
static const GDBusArgInfo * const _menu_dbus_arg_info_get_ui_out[] = {&_menu_dbus_arg_info_get_ui_ui, NULL};
static const GDBusMethodInfo _menu_dbus_method_info_get_ui = {-1, "GetUi", (GDBusArgInfo **) (&_menu_dbus_arg_info_get_ui_in), (GDBusArgInfo **) (&_menu_dbus_arg_info_get_ui_out)};
static const GDBusArgInfo _menu_dbus_arg_info_emit_path = {-1, "path", "s"};
static const GDBusArgInfo * const _menu_dbus_arg_info_emit_in[] = {&_menu_dbus_arg_info_emit_path, NULL};
static const GDBusArgInfo * const _menu_dbus_arg_info_emit_out[] = {NULL};
static const GDBusMethodInfo _menu_dbus_method_info_emit = {-1, "Emit", (GDBusArgInfo **) (&_menu_dbus_arg_info_emit_in), (GDBusArgInfo **) (&_menu_dbus_arg_info_emit_out)};
static const GDBusMethodInfo * const _menu_dbus_method_info[] = {&_menu_dbus_method_info_get_ui, &_menu_dbus_method_info_emit, NULL};
static const GDBusSignalInfo * const _menu_dbus_signal_info[] = {NULL};
static const GDBusPropertyInfo _menu_dbus_property_info_xwindow = {-1, "Xwindow", "t", G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE};
static const GDBusPropertyInfo * const _menu_dbus_property_info[] = {&_menu_dbus_property_info_xwindow, NULL};
static const GDBusInterfaceInfo _menu_dbus_interface_info = {-1, "org.globalmenu.menu", (GDBusMethodInfo **) (&_menu_dbus_method_info), (GDBusSignalInfo **) (&_menu_dbus_signal_info), (GDBusPropertyInfo **) (&_menu_dbus_property_info)};
static const GDBusInterfaceVTable _menu_dbus_interface_vtable = {menu_dbus_interface_method_call, menu_dbus_interface_get_property, menu_dbus_interface_set_property};
static const GDBusArgInfo _manager_dbus_arg_info_add_object_path = {-1, "object_path", "s"};
static const GDBusArgInfo * const _manager_dbus_arg_info_add_in[] = {&_manager_dbus_arg_info_add_object_path, NULL};
static const GDBusArgInfo * const _manager_dbus_arg_info_add_out[] = {NULL};
static const GDBusMethodInfo _manager_dbus_method_info_add = {-1, "Add", (GDBusArgInfo **) (&_manager_dbus_arg_info_add_in), (GDBusArgInfo **) (&_manager_dbus_arg_info_add_out)};
static const GDBusMethodInfo * const _manager_dbus_method_info[] = {&_manager_dbus_method_info_add, NULL};
static const GDBusSignalInfo * const _manager_dbus_signal_info[] = {NULL};
static const GDBusPropertyInfo * const _manager_dbus_property_info[] = {NULL};
static const GDBusInterfaceInfo _manager_dbus_interface_info = {-1, "org.globalmenu.manager", (GDBusMethodInfo **) (&_manager_dbus_method_info), (GDBusSignalInfo **) (&_manager_dbus_signal_info), (GDBusPropertyInfo **) (&_manager_dbus_property_info)};
static const GDBusInterfaceVTable _manager_dbus_interface_vtable = {manager_dbus_interface_method_call, manager_dbus_interface_get_property, manager_dbus_interface_set_property};

static gchar* string_slice (const gchar* self, glong start, glong end) {
gchar* result = NULL;
gint _tmp0_;
glong string_length;
gboolean _tmp1_ = FALSE;
gboolean _tmp2_ = FALSE;
gchar* _tmp3_ = NULL;
g_return_val_if_fail (self != NULL, NULL);
_tmp0_ = strlen (self);
string_length = (glong) _tmp0_;
if (start < 0) {
start = string_length + start;
}
if (end < 0) {
end = string_length + end;
}
if (start >= 0) {
_tmp1_ = start <= string_length;
} else {
_tmp1_ = FALSE;
}
g_return_val_if_fail (_tmp1_, NULL);
if (end >= 0) {
_tmp2_ = end <= string_length;
} else {
_tmp2_ = FALSE;
}
g_return_val_if_fail (_tmp2_, NULL);
g_return_val_if_fail (start <= end, NULL);
_tmp3_ = g_strndup (((gchar*) self) + start, (gsize) (end - start));
result = _tmp3_;
return result;
}


void menu_get_ui (Menu* self, const gchar* path, gchar** ui) {
gchar* _ui = NULL;
GtkWidget* _tmp0_ = NULL;
GtkWidget* widget;
g_return_if_fail (self != NULL);
g_return_if_fail (path != NULL);
_tmp0_ = menu_get_widget (self, path);
widget = _tmp0_;
if (GTK_IS_MENU_SHELL (widget)) {
gchar* _tmp1_ = NULL;
gchar* _tmp2_;
GtkWidget* _tmp3_ = NULL;
GtkWidget* _tmp4_;
GtkMenuItem* _tmp5_;
GtkMenuItem* item;
GtkWidget* _tmp8_;
gchar* _tmp9_ = NULL;
_tmp1_ = string_slice (path, (glong) 0, (glong) (-1));
_tmp2_ = _tmp1_;
_tmp3_ = menu_get_widget (self, _tmp2_);
_tmp4_ = _tmp3_;
_tmp5_ = GTK_IS_MENU_ITEM (_tmp4_) ? ((GtkMenuItem*) _tmp4_) : NULL;
_g_free0 (_tmp2_);
item = _tmp5_;
if (item != NULL) {
gchar* _tmp6_ = NULL;
gchar* _tmp7_;
_tmp6_ = string_slice (path, (glong) 0, (glong) (-1));
_tmp7_ = _tmp6_;
g_print ("path = %s, item is %p\n", _tmp7_, item);
_g_free0 (_tmp7_);
gtk_menu_item_activate (item);
gtk_item_select ((GtkItem*) item);
}
gtk_widget_show (widget);
_tmp8_ = widget;
_tmp9_ = menu_serialize ((GtkWidget*) (GTK_IS_MENU_SHELL (_tmp8_) ? ((GtkMenuShell*) _tmp8_) : NULL));
_g_free0 (_ui);
_ui = _tmp9_;
_g_object_unref0 (item);
} else {
gchar* _tmp10_;
_tmp10_ = g_strdup ("<empty/>");
_g_free0 (_ui);
_ui = _tmp10_;
}
_g_object_unref0 (widget);
if (ui) {
*ui = _ui;
} else {
_g_free0 (_ui);
}
}


void menu_emit (Menu* self, const gchar* path) {
GtkWidget* _tmp0_ = NULL;
GtkWidget* widget;
g_return_if_fail (self != NULL);
g_return_if_fail (path != NULL);
_tmp0_ = menu_get_widget (self, path);
widget = _tmp0_;
if (GTK_IS_TEAROFF_MENU_ITEM (widget)) {
_g_object_unref0 (widget);
return;
}
if (GTK_IS_SEPARATOR_MENU_ITEM (widget)) {
_g_object_unref0 (widget);
return;
}
if (GTK_IS_MENU_ITEM (widget)) {
GtkWidget* _tmp1_;
_tmp1_ = widget;
gtk_menu_item_activate (GTK_IS_MENU_ITEM (_tmp1_) ? ((GtkMenuItem*) _tmp1_) : NULL);
}
_g_object_unref0 (widget);
}


static gpointer _g_object_ref0 (gpointer self) {
return self ? g_object_ref (self) : NULL;
}


static void _lambda3_ (GtkWidget* prev, Menu* self) {
GtkWidget* _tmp0_ = NULL;
GtkWidget* _tmp1_;
GtkWidget* next;
if (GTK_IS_WINDOW (prev)) {
g_signal_handler_disconnect ((GObject*) prev, self->priv->realize_handler_id);
}
g_signal_handler_disconnect ((GObject*) prev, self->priv->unrealize_handler_id);
_tmp0_ = gtk_widget_get_toplevel ((GtkWidget*) self->priv->shell);
_tmp1_ = _g_object_ref0 (_tmp0_);
next = _tmp1_;
if (GTK_IS_WINDOW (next)) {
menu_attach_to_toplevel (self, next);
}
_g_object_unref0 (next);
}


static void __lambda3__gtk_widget_hierarchy_changed (GtkWidget* _sender, GtkWidget* previous_toplevel, gpointer self) {
_lambda3_ (previous_toplevel, self);
}


Menu* menu_construct (GType object_type, GtkMenuShell* shell) {
Menu * self = NULL;
GtkMenuShell* _tmp0_;
GtkWidget* _tmp1_ = NULL;
GtkWidget* _tmp2_;
GtkWidget* toplevel;
g_return_val_if_fail (shell != NULL, NULL);
self = (Menu*) g_object_new (object_type, NULL);
_tmp0_ = _g_object_ref0 (shell);
_g_object_unref0 (self->priv->shell);
self->priv->shell = _tmp0_;
g_signal_connect_object ((GtkWidget*) self->priv->shell, "hierarchy-changed", (GCallback) __lambda3__gtk_widget_hierarchy_changed, self, 0);
_tmp1_ = gtk_widget_get_toplevel ((GtkWidget*) self->priv->shell);
_tmp2_ = _g_object_ref0 (_tmp1_);
toplevel = _tmp2_;
if (GTK_IS_WINDOW (toplevel)) {
menu_attach_to_toplevel (self, toplevel);
}
_g_object_unref0 (toplevel);
return self;
}


Menu* menu_new (GtkMenuShell* shell) {
return menu_construct (TYPE_MENU, shell);
}


static Block1Data* block1_data_ref (Block1Data* _data1_) {
g_atomic_int_inc (&_data1_->_ref_count_);
return _data1_;
}


static void block1_data_unref (Block1Data* _data1_) {
if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
g_slice_free (Block1Data, _data1_);
}
}


static void _lambda6_ (GtkObject* shell, Block1Data* _data1_) {
GDBusConnection* _tmp0_ = NULL;
GDBusConnection* _tmp1_;
GDBusConnection* _tmp2_;
GError * _inner_error_ = NULL;
g_return_if_fail (shell != NULL);
_tmp0_ = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &_inner_error_);
_tmp1_ = _tmp0_;
if (_inner_error_ != NULL) {
if (_inner_error_->domain == G_IO_ERROR) {
goto __catch1_g_io_error;
}
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return;
}
_tmp2_ = _tmp1_;
g_dbus_connection_unregister_object (_tmp2_, _data1_->reg_id);
_g_object_unref0 (_tmp2_);
goto __finally1;
__catch1_g_io_error:
{
GError * e;
e = _inner_error_;
_inner_error_ = NULL;
g_warning ("client-gtk2.vala:65: could not unregister menu %s\n", e->message);
_g_error_free0 (e);
}
__finally1:
if (_inner_error_ != NULL) {
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return;
}
}


static void __lambda6__gtk_object_destroy (GtkObject* _sender, gpointer self) {
_lambda6_ (_sender, self);
}


void menu_register (GtkMenuShell* shell) {
Block1Data* _data1_;
Menu* _tmp0_ = NULL;
Menu* menu;
Manager* _tmp1_ = NULL;
Manager* manager;
gchar* _tmp2_ = NULL;
gchar* object_path;
GDBusConnection* _tmp3_ = NULL;
GDBusConnection* _tmp4_;
GDBusConnection* _tmp5_;
guint _tmp6_;
guint _tmp7_;
gulong _tmp8_;
gulong destroy_id;
GError * _inner_error_ = NULL;
g_return_if_fail (shell != NULL);
_data1_ = g_slice_new0 (Block1Data);
_data1_->_ref_count_ = 1;
_tmp0_ = menu_new (shell);
menu = _tmp0_;
_tmp1_ = g_initable_new (TYPE_MANAGER_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", "org.globalmenu.manager", "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/globalmenu/manager", "g-interface-name", "org.globalmenu.manager", NULL);
manager = (Manager*) _tmp1_;
if (_inner_error_ != NULL) {
_g_object_unref0 (menu);
block1_data_unref (_data1_);
_data1_ = NULL;
if (_inner_error_->domain == G_IO_ERROR) {
goto __catch0_g_io_error;
}
_g_object_unref0 (menu);
block1_data_unref (_data1_);
_data1_ = NULL;
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return;
}
_tmp2_ = g_strdup_printf ("/org/globalmenu/%p", shell);
object_path = _tmp2_;
_tmp3_ = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &_inner_error_);
_tmp4_ = _tmp3_;
if (_inner_error_ != NULL) {
_g_free0 (object_path);
_g_object_unref0 (manager);
_g_object_unref0 (menu);
block1_data_unref (_data1_);
_data1_ = NULL;
if (_inner_error_->domain == G_IO_ERROR) {
goto __catch0_g_io_error;
}
_g_free0 (object_path);
_g_object_unref0 (manager);
_g_object_unref0 (menu);
block1_data_unref (_data1_);
_data1_ = NULL;
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return;
}
_tmp5_ = _tmp4_;
_tmp6_ = menu_register_object (menu, _tmp5_, object_path, &_inner_error_);
_tmp7_ = _tmp6_;
_g_object_unref0 (_tmp5_);
_data1_->reg_id = _tmp7_;
if (_inner_error_ != NULL) {
_g_free0 (object_path);
_g_object_unref0 (manager);
_g_object_unref0 (menu);
block1_data_unref (_data1_);
_data1_ = NULL;
if (_inner_error_->domain == G_IO_ERROR) {
goto __catch0_g_io_error;
}
_g_free0 (object_path);
_g_object_unref0 (manager);
_g_object_unref0 (menu);
block1_data_unref (_data1_);
_data1_ = NULL;
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return;
}
manager_add (manager, object_path, &_inner_error_);
if (_inner_error_ != NULL) {
_g_free0 (object_path);
_g_object_unref0 (manager);
_g_object_unref0 (menu);
block1_data_unref (_data1_);
_data1_ = NULL;
if (_inner_error_->domain == G_IO_ERROR) {
goto __catch0_g_io_error;
}
_g_free0 (object_path);
_g_object_unref0 (manager);
_g_object_unref0 (menu);
block1_data_unref (_data1_);
_data1_ = NULL;
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return;
}
_tmp8_ = g_signal_connect_data ((GtkObject*) shell, "destroy", (GCallback) __lambda6__gtk_object_destroy, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
destroy_id = _tmp8_;
g_object_set_data_full ((GObject*) shell, "globalmenu-reg", GUINT_TO_POINTER (_data1_->reg_id), NULL);
g_object_set_data_full ((GObject*) shell, "globalmenu-destroy", GUINT_TO_POINTER (destroy_id), NULL);
_g_free0 (object_path);
_g_object_unref0 (manager);
_g_object_unref0 (menu);
block1_data_unref (_data1_);
_data1_ = NULL;
goto __finally0;
__catch0_g_io_error:
{
GError * e;
e = _inner_error_;
_inner_error_ = NULL;
g_warning ("client-gtk2.vala:74: could not register menu %s\n", e->message);
_g_error_free0 (e);
}
__finally0:
if (_inner_error_ != NULL) {
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return;
}
}


void menu_lost (GtkMenuShell* shell) {
gconstpointer _tmp0_ = NULL;
gulong destroy_id;
gconstpointer _tmp1_ = NULL;
guint reg_id;
GDBusConnection* _tmp2_ = NULL;
GDBusConnection* _tmp3_;
GDBusConnection* _tmp4_;
GError * _inner_error_ = NULL;
g_return_if_fail (shell != NULL);
_tmp0_ = g_object_get_data ((GObject*) shell, "globalmenu-destroy");
destroy_id = GPOINTER_TO_UINT (_tmp0_);
_tmp1_ = g_object_get_data ((GObject*) shell, "globalmenu-reg");
reg_id = GPOINTER_TO_UINT (_tmp1_);
g_signal_handler_disconnect ((GObject*) shell, destroy_id);
_tmp2_ = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &_inner_error_);
_tmp3_ = _tmp2_;
if (_inner_error_ != NULL) {
if (_inner_error_->domain == G_IO_ERROR) {
goto __catch2_g_io_error;
}
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return;
}
_tmp4_ = _tmp3_;
g_dbus_connection_unregister_object (_tmp4_, reg_id);
_g_object_unref0 (_tmp4_);
goto __finally2;
__catch2_g_io_error:
{
GError * e;
e = _inner_error_;
_inner_error_ = NULL;
g_message ("client-gtk2.vala:84: can't unregister %s", e->message);
_g_error_free0 (e);
}
__finally2:
if (_inner_error_ != NULL) {
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return;
}
g_object_set_data_full ((GObject*) shell, "globalmenu-reg", GUINT_TO_POINTER ((guint) 0), NULL);
g_object_set_data_full ((GObject*) shell, "globalmenu-destroy", GUINT_TO_POINTER ((gulong) 0), NULL);
}


gboolean menu_has_registered (GtkMenuShell* shell) {
gboolean result = FALSE;
gconstpointer _tmp0_ = NULL;
g_return_val_if_fail (shell != NULL, FALSE);
_tmp0_ = g_object_get_data ((GObject*) shell, "globalmenu-reg");
result = GPOINTER_TO_UINT (_tmp0_) != 0;
return result;
}


void menu_register_all (void) {
GList* _tmp0_ = NULL;
GList* l;
_tmp0_ = gtk_window_list_toplevels ();
l = _tmp0_;
{
GList* window_collection;
GList* window_it;
window_collection = l;
for (window_it = window_collection; window_it != NULL; window_it = window_it->next) {
GtkWindow* window;
window = (GtkWindow*) window_it->data;
{
GtkWidget* _tmp1_ = NULL;
GtkWidget* _tmp2_;
GtkMenuBar* menubar;
gboolean _tmp3_ = FALSE;
_tmp1_ = menu_widget_by_type ((GtkWidget*) window, GTK_TYPE_MENU_BAR);
_tmp2_ = _tmp1_;
menubar = GTK_IS_MENU_BAR (_tmp2_) ? ((GtkMenuBar*) _tmp2_) : NULL;
if (menubar != NULL) {
gboolean _tmp4_;
_tmp4_ = menu_has_registered ((GtkMenuShell*) menubar);
_tmp3_ = !_tmp4_;
} else {
_tmp3_ = FALSE;
}
if (_tmp3_) {
menu_register ((GtkMenuShell*) menubar);
}
_g_object_unref0 (menubar);
}
}
}
_g_list_free0 (l);
}


void menu_lost_all (void) {
GList* _tmp0_ = NULL;
GList* l;
_tmp0_ = gtk_window_list_toplevels ();
l = _tmp0_;
{
GList* window_collection;
GList* window_it;
window_collection = l;
for (window_it = window_collection; window_it != NULL; window_it = window_it->next) {
GtkWindow* window;
window = (GtkWindow*) window_it->data;
{
GtkWidget* _tmp1_ = NULL;
GtkWidget* _tmp2_;
GtkMenuBar* menubar;
gboolean _tmp3_ = FALSE;
_tmp1_ = menu_widget_by_type ((GtkWidget*) window, GTK_TYPE_MENU_BAR);
_tmp2_ = _tmp1_;
menubar = GTK_IS_MENU_BAR (_tmp2_) ? ((GtkMenuBar*) _tmp2_) : NULL;
if (menubar != NULL) {
gboolean _tmp4_;
_tmp4_ = menu_has_registered ((GtkMenuShell*) menubar);
_tmp3_ = _tmp4_;
} else {
_tmp3_ = FALSE;
}
if (_tmp3_) {
menu_lost ((GtkMenuShell*) menubar);
}
_g_object_unref0 (menubar);
}
}
}
_g_list_free0 (l);
}


static void _lambda4_ (GtkWidget* obj, Menu* self) {
GdkWindow* _tmp0_ = NULL;
XID _tmp1_;
g_return_if_fail (obj != NULL);
_tmp0_ = gtk_widget_get_window (obj);
_tmp1_ = gdk_x11_drawable_get_xid ((GdkDrawable*) _tmp0_);
menu_set_xwindow (self, (guint64) _tmp1_);
}


static void __lambda4__gtk_widget_realize (GtkWidget* _sender, gpointer self) {
_lambda4_ (_sender, self);
}


static void _lambda5_ (GtkWidget* obj, Menu* self) {
g_return_if_fail (obj != NULL);
menu_set_xwindow (self, (guint64) 0);
}


static void __lambda5__gtk_widget_unrealize (GtkWidget* _sender, gpointer self) {
_lambda5_ (_sender, self);
}


static void menu_attach_to_toplevel (Menu* self, GtkWidget* toplevel) {
gulong _tmp0_;
gulong _tmp1_;
gboolean _tmp2_;
g_return_if_fail (self != NULL);
g_return_if_fail (toplevel != NULL);
_tmp0_ = g_signal_connect_object (toplevel, "realize", (GCallback) __lambda4__gtk_widget_realize, self, 0);
self->priv->realize_handler_id = _tmp0_;
_tmp1_ = g_signal_connect_object (toplevel, "unrealize", (GCallback) __lambda5__gtk_widget_unrealize, self, 0);
self->priv->unrealize_handler_id = _tmp1_;
_tmp2_ = gtk_widget_get_realized (toplevel);
if (_tmp2_) {
GdkWindow* _tmp3_ = NULL;
XID _tmp4_;
_tmp3_ = gtk_widget_get_window (toplevel);
_tmp4_ = gdk_x11_drawable_get_xid ((GdkDrawable*) _tmp3_);
menu_set_xwindow (self, (guint64) _tmp4_);
}
}


static Block2Data* block2_data_ref (Block2Data* _data2_) {
g_atomic_int_inc (&_data2_->_ref_count_);
return _data2_;
}


static void block2_data_unref (Block2Data* _data2_) {
if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
_g_object_unref0 (_data2_->self);
_g_object_unref0 (_data2_->cursor);
g_slice_free (Block2Data, _data2_);
}
}


static Block3Data* block3_data_ref (Block3Data* _data3_) {
g_atomic_int_inc (&_data3_->_ref_count_);
return _data3_;
}


static void block3_data_unref (Block3Data* _data3_) {
if (g_atomic_int_dec_and_test (&_data3_->_ref_count_)) {
block2_data_unref (_data3_->_data2_);
_data3_->_data2_ = NULL;
g_slice_free (Block3Data, _data3_);
}
}


static void _lambda0_ (GtkWidget* item, Block3Data* _data3_) {
Block2Data* _data2_;
Menu * self;
_data2_ = _data3_->_data2_;
self = _data2_->self;
g_return_if_fail (item != NULL);
if (_data3_->j == _data3_->loc) {
GtkWidget* _tmp0_;
GtkMenuItem* _tmp1_;
_tmp0_ = item;
_tmp1_ = _g_object_ref0 (GTK_IS_MENU_ITEM (_tmp0_) ? ((GtkMenuItem*) _tmp0_) : NULL);
_g_object_unref0 (_data2_->cursor);
_data2_->cursor = _tmp1_;
}
_data3_->j++;
}


static void __lambda0__gtk_callback (GtkWidget* widget, gpointer self) {
_lambda0_ (widget, self);
}


static GtkWidget* menu_get_widget (Menu* self, const gchar* path) {
GtkWidget* result = NULL;
Block2Data* _data2_;
gchar** _tmp0_;
gchar** _tmp1_ = NULL;
gchar** segs;
gint segs_length1;
gint _segs_size_;
GtkMenuShell* _tmp2_;
GtkMenuShell* shell;
gboolean _tmp8_;
GtkWidget* _tmp9_;
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (path != NULL, NULL);
_data2_ = g_slice_new0 (Block2Data);
_data2_->_ref_count_ = 1;
_data2_->self = g_object_ref (self);
_tmp1_ = _tmp0_ = g_strsplit (path, "/", 0);
segs = _tmp1_;
segs_length1 = _vala_array_length (_tmp0_);
_segs_size_ = _vala_array_length (_tmp0_);
_tmp2_ = _g_object_ref0 (self->priv->shell);
shell = _tmp2_;
_data2_->cursor = NULL;
{
gint i;
i = 0;
{
gboolean _tmp3_;
_tmp3_ = TRUE;
while (TRUE) {
Block3Data* _data3_;
gint _tmp4_;
gint _tmp5_;
GtkMenu* _tmp6_ = NULL;
GtkMenuShell* _tmp7_;
_data3_ = g_slice_new0 (Block3Data);
_data3_->_ref_count_ = 1;
_data3_->_data2_ = block2_data_ref (_data2_);
if (!_tmp3_) {
i++;
}
_tmp3_ = FALSE;
if (!(i < segs_length1)) {
block3_data_unref (_data3_);
_data3_ = NULL;
break;
}
_tmp4_ = strlen (segs[i]);
if (_tmp4_ == 0) {
block3_data_unref (_data3_);
_data3_ = NULL;
continue;
}
_tmp5_ = atoi (segs[i]);
_data3_->loc = _tmp5_;
_data3_->j = 0;
_g_object_unref0 (_data2_->cursor);
_data2_->cursor = NULL;
gtk_container_forall ((GtkContainer*) shell, __lambda0__gtk_callback, _data3_);
if (_data2_->cursor == NULL) {
result = NULL;
block3_data_unref (_data3_);
_data3_ = NULL;
_g_object_unref0 (shell);
segs = (_vala_array_free (segs, segs_length1, (GDestroyNotify) g_free), NULL);
block2_data_unref (_data2_);
_data2_ = NULL;
return result;
}
_tmp6_ = gtk_menu_item_get_submenu (_data2_->cursor);
_tmp7_ = _g_object_ref0 ((GtkMenuShell*) _tmp6_);
_g_object_unref0 (shell);
shell = _tmp7_;
block3_data_unref (_data3_);
_data3_ = NULL;
}
}
}
_tmp8_ = g_str_has_suffix (path, "/");
if (_tmp8_) {
result = (GtkWidget*) shell;
segs = (_vala_array_free (segs, segs_length1, (GDestroyNotify) g_free), NULL);
block2_data_unref (_data2_);
_data2_ = NULL;
return result;
}
_tmp9_ = _g_object_ref0 ((GtkWidget*) _data2_->cursor);
result = _tmp9_;
_g_object_unref0 (shell);
segs = (_vala_array_free (segs, segs_length1, (GDestroyNotify) g_free), NULL);
block2_data_unref (_data2_);
_data2_ = NULL;
return result;
}


static gchar* menu_serialize (GtkWidget* widget) {
gchar* result = NULL;
GString* _tmp0_ = NULL;
GString* s;
gchar* _tmp1_;
g_return_val_if_fail (widget != NULL, NULL);
_tmp0_ = g_string_new ("");
s = _tmp0_;
menu_serialize_to (s, widget);
_tmp1_ = g_strdup (s->str);
result = _tmp1_;
_g_string_free0 (s);
return result;
}


static Block4Data* block4_data_ref (Block4Data* _data4_) {
g_atomic_int_inc (&_data4_->_ref_count_);
return _data4_;
}


static void block4_data_unref (Block4Data* _data4_) {
if (g_atomic_int_dec_and_test (&_data4_->_ref_count_)) {
g_slice_free (Block4Data, _data4_);
}
}


static void _lambda1_ (GtkWidget* item, Block4Data* _data4_) {
g_return_if_fail (item != NULL);
menu_serialize_to (_data4_->sb, item);
}


static void __lambda1__gtk_callback (GtkWidget* widget, gpointer self) {
_lambda1_ (widget, self);
}


static gchar* bool_to_string (gboolean self) {
gchar* result = NULL;
if (self) {
gchar* _tmp0_;
_tmp0_ = g_strdup ("true");
result = _tmp0_;
return result;
} else {
gchar* _tmp1_;
_tmp1_ = g_strdup ("false");
result = _tmp1_;
return result;
}
}


static void menu_serialize_to (GString* sb, GtkWidget* widget) {
Block4Data* _data4_;
gboolean _tmp20_;
gboolean visible;
gboolean _tmp21_;
gboolean sensitive;
g_return_if_fail (widget != NULL);
_data4_ = g_slice_new0 (Block4Data);
_data4_->_ref_count_ = 1;
_data4_->sb = sb;
if (GTK_IS_MENU_SHELL (widget)) {
GtkWidget* _tmp0_;
_tmp0_ = widget;
gtk_container_forall ((GtkContainer*) (GTK_IS_MENU_SHELL (_tmp0_) ? ((GtkMenuShell*) _tmp0_) : NULL), __lambda1__gtk_callback, _data4_);
block4_data_unref (_data4_);
_data4_ = NULL;
return;
}
if (GTK_IS_SEPARATOR_MENU_ITEM (widget)) {
g_string_append_printf (_data4_->sb, "<separator");
} else {
if (GTK_IS_TEAROFF_MENU_ITEM (widget)) {
g_string_append_printf (_data4_->sb, "<tearoff");
} else {
if (GTK_IS_RADIO_MENU_ITEM (widget)) {
g_string_append_printf (_data4_->sb, "<radio");
} else {
if (GTK_IS_CHECK_MENU_ITEM (widget)) {
g_string_append_printf (_data4_->sb, "<check");
} else {
if (GTK_IS_MENU_ITEM (widget)) {
g_string_append_printf (_data4_->sb, "<item");
} else {
g_string_append_printf (_data4_->sb, "<unknown");
}
}
}
}
}
if (GTK_IS_MENU_ITEM (widget)) {
GtkWidget* _tmp1_ = NULL;
GtkWidget* _tmp2_;
GtkLabel* label;
const gchar* _tmp3_ = NULL;
GtkWidget* _tmp5_;
GtkWidget* _tmp6_ = NULL;
gboolean has_submenu;
GtkWidget* _tmp9_;
GtkAction* _tmp10_ = NULL;
GtkAction* _tmp11_;
GtkAction* action;
_tmp1_ = menu_widget_by_type (widget, GTK_TYPE_LABEL);
_tmp2_ = _tmp1_;
label = GTK_IS_LABEL (_tmp2_) ? ((GtkLabel*) _tmp2_) : NULL;
if (label == NULL) {
_tmp3_ = "___";
} else {
const gchar* _tmp4_ = NULL;
_tmp4_ = gtk_label_get_text (label);
_tmp3_ = _tmp4_;
}
g_string_append_printf (_data4_->sb, " label=\"%s\"", _tmp3_);
_tmp5_ = widget;
_tmp6_ = gtk_menu_item_get_submenu (GTK_IS_MENU_ITEM (_tmp5_) ? ((GtkMenuItem*) _tmp5_) : NULL);
has_submenu = _tmp6_ != NULL;
if (has_submenu) {
gchar* _tmp7_ = NULL;
gchar* _tmp8_;
_tmp7_ = bool_to_string (has_submenu);
_tmp8_ = _tmp7_;
g_string_append_printf (_data4_->sb, " submenu=\"%s\"", _tmp8_);
_g_free0 (_tmp8_);
}
_tmp9_ = widget;
_tmp10_ = gtk_activatable_get_related_action ((GtkActivatable*) (GTK_IS_MENU_ITEM (_tmp9_) ? ((GtkMenuItem*) _tmp9_) : NULL));
_tmp11_ = _g_object_ref0 (_tmp10_);
action = _tmp11_;
if (action != NULL) {
const gchar* _tmp12_ = NULL;
gchar* _tmp13_;
gchar* tooltip;
_tmp12_ = gtk_action_get_tooltip (action);
_tmp13_ = g_strdup (_tmp12_);
tooltip = _tmp13_;
if (tooltip != NULL) {
g_string_append_printf (_data4_->sb, " tooltip=\"%s\"", tooltip);
}
_g_free0 (tooltip);
}
_g_object_unref0 (action);
_g_object_unref0 (label);
}
if (GTK_IS_RADIO_MENU_ITEM (widget)) {
GtkWidget* _tmp14_;
GSList* _tmp15_ = NULL;
void* group;
_tmp14_ = widget;
_tmp15_ = gtk_radio_menu_item_get_group (GTK_IS_RADIO_MENU_ITEM (_tmp14_) ? ((GtkRadioMenuItem*) _tmp14_) : NULL);
group = (void*) _tmp15_;
g_string_append_printf (_data4_->sb, " group=\"%P\"", group);
}
if (GTK_IS_CHECK_MENU_ITEM (widget)) {
GtkWidget* _tmp16_;
gboolean _tmp17_;
gboolean active;
gchar* _tmp18_ = NULL;
gchar* _tmp19_;
_tmp16_ = widget;
_tmp17_ = gtk_check_menu_item_get_active (GTK_IS_CHECK_MENU_ITEM (_tmp16_) ? ((GtkCheckMenuItem*) _tmp16_) : NULL);
active = _tmp17_;
_tmp18_ = bool_to_string (active);
_tmp19_ = _tmp18_;
g_string_append_printf (_data4_->sb, " active=\"%s\"", _tmp19_);
_g_free0 (_tmp19_);
}
_tmp20_ = gtk_widget_get_visible (widget);
visible = _tmp20_;
_tmp21_ = gtk_widget_get_sensitive (widget);
sensitive = _tmp21_;
if (!visible) {
gchar* _tmp22_ = NULL;
gchar* _tmp23_;
_tmp22_ = bool_to_string (visible);
_tmp23_ = _tmp22_;
g_string_append_printf (_data4_->sb, " visible=\"%s\"", _tmp23_);
_g_free0 (_tmp23_);
}
if (!sensitive) {
gchar* _tmp24_ = NULL;
gchar* _tmp25_;
_tmp24_ = bool_to_string (sensitive);
_tmp25_ = _tmp24_;
g_string_append_printf (_data4_->sb, " sensitive=\"%s\"", _tmp25_);
_g_free0 (_tmp25_);
}
g_string_append_printf (_data4_->sb, "/>");
block4_data_unref (_data4_);
_data4_ = NULL;
}


static Block5Data* block5_data_ref (Block5Data* _data5_) {
g_atomic_int_inc (&_data5_->_ref_count_);
return _data5_;
}


static void block5_data_unref (Block5Data* _data5_) {
if (g_atomic_int_dec_and_test (&_data5_->_ref_count_)) {
_g_object_unref0 (_data5_->rt);
g_slice_free (Block5Data, _data5_);
}
}


static void _lambda2_ (GtkWidget* widget, Block5Data* _data5_) {
GType _tmp0_;
gboolean _tmp1_;
g_return_if_fail (widget != NULL);
if (_data5_->rt != NULL) {
return;
}
_tmp0_ = G_TYPE_FROM_INSTANCE ((GObject*) widget);
_tmp1_ = g_type_is_a (_tmp0_, _data5_->type);
if (_tmp1_) {
GtkWidget* _tmp2_;
_tmp2_ = _g_object_ref0 (widget);
_g_object_unref0 (_data5_->rt);
_data5_->rt = _tmp2_;
} else {
if (GTK_IS_CONTAINER (widget)) {
GtkWidget* _tmp3_ = NULL;
_tmp3_ = menu_widget_by_type (widget, _data5_->type);
_g_object_unref0 (_data5_->rt);
_data5_->rt = _tmp3_;
}
}
}


static void __lambda2__gtk_callback (GtkWidget* widget, gpointer self) {
_lambda2_ (widget, self);
}


static GtkWidget* menu_widget_by_type (GtkWidget* parent, GType type) {
GtkWidget* result = NULL;
Block5Data* _data5_;
GtkWidget* _tmp0_;
GtkWidget* _tmp1_;
g_return_val_if_fail (parent != NULL, NULL);
_data5_ = g_slice_new0 (Block5Data);
_data5_->_ref_count_ = 1;
_data5_->type = type;
_data5_->rt = NULL;
_tmp0_ = parent;
gtk_container_forall (GTK_IS_CONTAINER (_tmp0_) ? ((GtkContainer*) _tmp0_) : NULL, __lambda2__gtk_callback, _data5_);
_tmp1_ = _g_object_ref0 (_data5_->rt);
result = _tmp1_;
block5_data_unref (_data5_);
_data5_ = NULL;
return result;
}


guint64 menu_get_xwindow (Menu* self) {
guint64 result;
g_return_val_if_fail (self != NULL, 0ULL);
result = self->priv->_xwindow;
return result;
}


static void menu_set_xwindow (Menu* self, guint64 value) {
g_return_if_fail (self != NULL);
self->priv->_xwindow = value;
g_object_notify ((GObject *) self, "xwindow");
}


static void menu_class_init (MenuClass * klass) {
menu_parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (MenuPrivate));
G_OBJECT_CLASS (klass)->get_property = _vala_menu_get_property;
G_OBJECT_CLASS (klass)->set_property = _vala_menu_set_property;
G_OBJECT_CLASS (klass)->finalize = menu_finalize;
g_object_class_install_property (G_OBJECT_CLASS (klass), MENU_XWINDOW, g_param_spec_uint64 ("xwindow", "xwindow", "xwindow", 0, G_MAXUINT64, 0U, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
}


static void menu_instance_init (Menu * self) {
self->priv = MENU_GET_PRIVATE (self);
self->priv->realize_handler_id = (gulong) 0;
self->priv->unrealize_handler_id = (gulong) 0;
}


static void menu_finalize (GObject* obj) {
Menu * self;
self = MENU (obj);
_g_object_unref0 (self->priv->shell);
G_OBJECT_CLASS (menu_parent_class)->finalize (obj);
}


GType menu_get_type (void) {
static volatile gsize menu_type_id__volatile = 0;
if (g_once_init_enter (&menu_type_id__volatile)) {
static const GTypeInfo g_define_type_info = { sizeof (MenuClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) menu_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Menu), 0, (GInstanceInitFunc) menu_instance_init, NULL };
GType menu_type_id;
menu_type_id = g_type_register_static (G_TYPE_OBJECT, "Menu", &g_define_type_info, 0);
g_type_set_qdata (menu_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) menu_register_object);
g_once_init_leave (&menu_type_id__volatile, menu_type_id);
}
return menu_type_id__volatile;
}


static void _vala_menu_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
Menu * self;
self = MENU (object);
switch (property_id) {
case MENU_XWINDOW:
g_value_set_uint64 (value, menu_get_xwindow (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}


static void _vala_menu_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
Menu * self;
self = MENU (object);
switch (property_id) {
case MENU_XWINDOW:
menu_set_xwindow (self, g_value_get_uint64 (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}


static void _dbus_menu_get_ui (Menu* self, GVariant* parameters, GDBusMethodInvocation* invocation) {
GError* error = NULL;
GVariantIter _arguments_iter;
gchar* path = NULL;
GVariant* _tmp0_;
GDBusMessage* _reply_message;
GVariant* _reply;
GVariantBuilder _reply_builder;
gchar* ui = NULL;
g_variant_iter_init (&_arguments_iter, parameters);
_tmp0_ = g_variant_iter_next_value (&_arguments_iter);
path = g_variant_dup_string (_tmp0_, NULL);
g_variant_unref (_tmp0_);
menu_get_ui (self, path, &ui);
_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
g_variant_builder_add_value (&_reply_builder, g_variant_new_string (ui));
_reply = g_variant_builder_end (&_reply_builder);
g_dbus_message_set_body (_reply_message, _reply);
_g_free0 (path);
_g_free0 (ui);
g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
g_object_unref (invocation);
g_object_unref (_reply_message);
}


static void _dbus_menu_emit (Menu* self, GVariant* parameters, GDBusMethodInvocation* invocation) {
GError* error = NULL;
GVariantIter _arguments_iter;
gchar* path = NULL;
GVariant* _tmp1_;
GDBusMessage* _reply_message;
GVariant* _reply;
GVariantBuilder _reply_builder;
g_variant_iter_init (&_arguments_iter, parameters);
_tmp1_ = g_variant_iter_next_value (&_arguments_iter);
path = g_variant_dup_string (_tmp1_, NULL);
g_variant_unref (_tmp1_);
menu_emit (self, path);
_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
_reply = g_variant_builder_end (&_reply_builder);
g_dbus_message_set_body (_reply_message, _reply);
_g_free0 (path);
g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
g_object_unref (invocation);
g_object_unref (_reply_message);
}


static void menu_dbus_interface_method_call (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* method_name, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer user_data) {
gpointer* data;
gpointer object;
data = user_data;
object = data[0];
if (strcmp (method_name, "GetUi") == 0) {
_dbus_menu_get_ui (object, parameters, invocation);
} else if (strcmp (method_name, "Emit") == 0) {
_dbus_menu_emit (object, parameters, invocation);
} else {
g_object_unref (invocation);
}
}


static GVariant* _dbus_menu_get_xwindow (Menu* self) {
guint64 result;
GVariant* _reply;
result = menu_get_xwindow (self);
_reply = g_variant_new_uint64 (result);
return _reply;
}


static GVariant* menu_dbus_interface_get_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GError** error, gpointer user_data) {
gpointer* data;
gpointer object;
data = user_data;
object = data[0];
if (strcmp (property_name, "Xwindow") == 0) {
return _dbus_menu_get_xwindow (object);
}
return NULL;
}


static void _dbus_menu_set_xwindow (Menu* self, GVariant* _value) {
guint64 value = 0ULL;
value = g_variant_get_uint64 (_value);
menu_set_xwindow (self, value);
}


static gboolean menu_dbus_interface_set_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GVariant* value, GError** error, gpointer user_data) {
gpointer* data;
gpointer object;
data = user_data;
object = data[0];
if (strcmp (property_name, "Xwindow") == 0) {
_dbus_menu_set_xwindow (object, value);
return TRUE;
}
return FALSE;
}


guint menu_register_object (gpointer object, GDBusConnection* connection, const gchar* path, GError** error) {
guint result;
gpointer *data;
data = g_new (gpointer, 3);
data[0] = g_object_ref (object);
data[1] = g_object_ref (connection);
data[2] = g_strdup (path);
result = g_dbus_connection_register_object (connection, path, (GDBusInterfaceInfo *) (&_menu_dbus_interface_info), &_menu_dbus_interface_vtable, data, _menu_unregister_object, error);
if (!result) {
return 0;
}
return result;
}


static void _menu_unregister_object (gpointer user_data) {
gpointer* data;
data = user_data;
g_object_unref (data[0]);
g_object_unref (data[1]);
g_free (data[2]);
g_free (data);
}


void manager_add (Manager* self, const gchar* object_path, GError** error) {
MANAGER_GET_INTERFACE (self)->add (self, object_path, error);
}


static void manager_base_init (ManagerIface * iface) {
static gboolean initialized = FALSE;
if (!initialized) {
initialized = TRUE;
}
}


GType manager_get_type (void) {
static volatile gsize manager_type_id__volatile = 0;
if (g_once_init_enter (&manager_type_id__volatile)) {
static const GTypeInfo g_define_type_info = { sizeof (ManagerIface), (GBaseInitFunc) manager_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
GType manager_type_id;
manager_type_id = g_type_register_static (G_TYPE_INTERFACE, "Manager", &g_define_type_info, 0);
g_type_interface_add_prerequisite (manager_type_id, G_TYPE_OBJECT);
g_type_set_qdata (manager_type_id, g_quark_from_static_string ("vala-dbus-proxy-type"), (void*) manager_proxy_get_type);
g_type_set_qdata (manager_type_id, g_quark_from_static_string ("vala-dbus-interface-name"), "org.globalmenu.manager");
g_type_set_qdata (manager_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) manager_register_object);
g_once_init_leave (&manager_type_id__volatile, manager_type_id);
}
return manager_type_id__volatile;
}


G_DEFINE_TYPE_EXTENDED (ManagerProxy, manager_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT_INTERFACE (TYPE_MANAGER, manager_proxy_manager_interface_init) )
static void manager_proxy_class_init (ManagerProxyClass* klass) {
G_DBUS_PROXY_CLASS (klass)->g_signal = manager_proxy_g_signal;
}


static void manager_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters) {
}


static void manager_proxy_init (ManagerProxy* self) {
}


static void manager_proxy_add (Manager* self, const gchar* object_path, GError** error) {
GDBusMessage *_message;
GVariant *_arguments;
GVariantBuilder _arguments_builder;
GDBusMessage *_reply_message;
G_IO_ERROR;
_message = g_dbus_message_new_method_call (g_dbus_proxy_get_name ((GDBusProxy *) self), g_dbus_proxy_get_object_path ((GDBusProxy *) self), "org.globalmenu.manager", "Add");
g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE);
g_variant_builder_add_value (&_arguments_builder, g_variant_new_string (object_path));
_arguments = g_variant_builder_end (&_arguments_builder);
g_dbus_message_set_body (_message, _arguments);
_reply_message = g_dbus_connection_send_message_with_reply_sync (g_dbus_proxy_get_connection ((GDBusProxy *) self), _message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, g_dbus_proxy_get_default_timeout ((GDBusProxy *) self), NULL, NULL, error);
g_object_unref (_message);
if (!_reply_message) {
return;
}
if (g_dbus_message_to_gerror (_reply_message, error)) {
g_object_unref (_reply_message);
return;
}
g_object_unref (_reply_message);
}


static void manager_proxy_manager_interface_init (ManagerIface* iface) {
iface->add = manager_proxy_add;
}


static void _dbus_manager_add (Manager* self, GVariant* parameters, GDBusMethodInvocation* invocation) {
GError* error = NULL;
GVariantIter _arguments_iter;
gchar* object_path = NULL;
GVariant* _tmp2_;
GDBusMessage* _reply_message;
GVariant* _reply;
GVariantBuilder _reply_builder;
g_variant_iter_init (&_arguments_iter, parameters);
_tmp2_ = g_variant_iter_next_value (&_arguments_iter);
object_path = g_variant_dup_string (_tmp2_, NULL);
g_variant_unref (_tmp2_);
manager_add (self, object_path, &error);
if (error) {
g_dbus_method_invocation_return_gerror (invocation, error);
return;
}
_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
_reply = g_variant_builder_end (&_reply_builder);
g_dbus_message_set_body (_reply_message, _reply);
_g_free0 (object_path);
g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
g_object_unref (invocation);
g_object_unref (_reply_message);
}


static void manager_dbus_interface_method_call (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* method_name, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer user_data) {
gpointer* data;
gpointer object;
data = user_data;
object = data[0];
if (strcmp (method_name, "Add") == 0) {
_dbus_manager_add (object, parameters, invocation);
} else {
g_object_unref (invocation);
}
}


static GVariant* manager_dbus_interface_get_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GError** error, gpointer user_data) {
gpointer* data;
gpointer object;
data = user_data;
object = data[0];
return NULL;
}


static gboolean manager_dbus_interface_set_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GVariant* value, GError** error, gpointer user_data) {
gpointer* data;
gpointer object;
data = user_data;
object = data[0];
return FALSE;
}


guint manager_register_object (gpointer object, GDBusConnection* connection, const gchar* path, GError** error) {
guint result;
gpointer *data;
data = g_new (gpointer, 3);
data[0] = g_object_ref (object);
data[1] = g_object_ref (connection);
data[2] = g_strdup (path);
result = g_dbus_connection_register_object (connection, path, (GDBusInterfaceInfo *) (&_manager_dbus_interface_info), &_manager_dbus_interface_vtable, data, _manager_unregister_object, error);
if (!result) {
return 0;
}
return result;
}


static void _manager_unregister_object (gpointer user_data) {
gpointer* data;
data = user_data;
g_object_unref (data[0]);
g_object_unref (data[1]);
g_free (data[2]);
g_free (data);
}


void callback (GtkAction* action) {
const gchar* _tmp0_ = NULL;
g_return_if_fail (action != NULL);
_tmp0_ = gtk_buildable_get_name ((GtkBuildable*) action);
g_print ("widget %s called", _tmp0_);
}


static void _callback_gtk_action_callback (GtkAction* action, gpointer self) {
callback (action);
}


void _vala_main (gchar** args, int args_length1) {
static const char uidef[] = "\n" \
"<ui>\n" \
" <menubar>\n" \
" <menu name=\"FileMenu\" action=\"FileMenu\">\n" \
" <menuitem name=\"New\" action=\"New\"/>\n" \
" <placeholder name=\"name\" />\n" \
" </menu>\n" \
" <menu name=\"JustifyMenu\" action=\"JustifyMenu\">\n" \
" <menuitem name=\"Left\" action=\"Left\"/>\n" \
" <menuitem name=\"Centre\" action=\"Centre\"/>\n" \
" <menuitem name=\"Right\" action=\"Right\"/>\n" \
" <menuitem name=\"Fill\" action=\"Fill\"/>\n" \
" </menu>\n" \
" </menubar>\n" \
"</ui>\n" \
" ";
static const GtkActionEntry ae[] = {{"FileMenu", NULL, "File", NULL, NULL, (GCallback) _callback_gtk_action_callback}, {"JustifyMenu", NULL, "Justify", NULL, NULL, (GCallback) _callback_gtk_action_callback}, {"New", NULL, "New", NULL, NULL, (GCallback) _callback_gtk_action_callback}, {"Left", NULL, "Left", NULL, NULL, (GCallback) _callback_gtk_action_callback}, {"Centre", NULL, "Centre", NULL, NULL, (GCallback) _callback_gtk_action_callback}, {"Right", NULL, "Right", NULL, NULL, (GCallback) _callback_gtk_action_callback}, {"Fill", NULL, "Fill", NULL, NULL, (GCallback) _callback_gtk_action_callback}};
GtkActionGroup* _tmp0_ = NULL;
GtkActionGroup* ag;
GtkUIManager* _tmp1_ = NULL;
GtkUIManager* uiman;
gint _tmp2_;
GtkWidget* _tmp3_ = NULL;
GtkWidget* _tmp4_;
GtkMenuBar* _tmp5_;
GtkMenuBar* shell;
GMainLoop* _tmp6_ = NULL;
GMainLoop* _tmp7_;
GError * _inner_error_ = NULL;
gtk_init (&args_length1, &args);
_tmp0_ = gtk_action_group_new ("default");
ag = _tmp0_;
gtk_action_group_add_actions (ag, ae, G_N_ELEMENTS (ae), NULL);
_tmp1_ = gtk_ui_manager_new ();
uiman = _tmp1_;
gtk_ui_manager_insert_action_group (uiman, ag, 0);
_tmp2_ = strlen (uidef);
gtk_ui_manager_add_ui_from_string (uiman, uidef, (gssize) _tmp2_, &_inner_error_);
if (_inner_error_ != NULL) {
_g_object_unref0 (uiman);
_g_object_unref0 (ag);
if (_inner_error_->domain == G_IO_ERROR) {
goto __catch3_g_io_error;
}
goto __finally3;
}
_tmp3_ = gtk_ui_manager_get_widget (uiman, "/menubar");
_tmp4_ = _tmp3_;
_tmp5_ = _g_object_ref0 (GTK_IS_MENU_BAR (_tmp4_) ? ((GtkMenuBar*) _tmp4_) : NULL);
shell = _tmp5_;
menu_register ((GtkMenuShell*) shell);
_g_object_unref0 (shell);
_g_object_unref0 (uiman);
_g_object_unref0 (ag);
goto __finally3;
__catch3_g_io_error:
{
GError * e;
e = _inner_error_;
_inner_error_ = NULL;
g_critical ("client-gtk2.vala:284: %s\n", e->message);
_g_error_free0 (e);
}
__finally3:
if (_inner_error_ != NULL) {
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return;
}
_tmp6_ = g_main_loop_new (NULL, FALSE);
_tmp7_ = _tmp6_;
g_main_loop_run (_tmp7_);
_g_main_loop_unref0 (_tmp7_);
}


int main (int argc, char ** argv) {
g_type_init ();
_vala_main (argv, argc);
return 0;
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
if ((array != NULL) && (destroy_func != NULL)) {
int i;
for (i = 0; i < array_length; i = i + 1) {
if (((gpointer*) array)[i] != NULL) {
destroy_func (((gpointer*) array)[i]);
}
}
}
}


static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
_vala_array_destroy (array, array_length, destroy_func);
g_free (array);
}


static gint _vala_array_length (gpointer array) {
int length;
length = 0;
if (array) {
while (((gpointer*) array)[length]) {
length++;
}
}
return length;
}



  1. /* client-gtk2.c generated by valac 0.12.1, the Vala compiler
  2.  * generated from client-gtk2.vala, do not modify */
  3.  
  4.  
  5. #include <glib.h>
  6. #include <glib-object.h>
  7. #include <gtk/gtk.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include <gio/gio.h>
  11. #include <gdk/gdkx.h>
  12. #include <gdk/gdk.h>
  13.  
  14.  
  15. #define TYPE_MENU (menu_get_type ())
  16. #define MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MENU, Menu))
  17. #define MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MENU, MenuClass))
  18. #define IS_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MENU))
  19. #define IS_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MENU))
  20. #define MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MENU, MenuClass))
  21.  
  22. typedef struct _Menu Menu;
  23. typedef struct _MenuClass MenuClass;
  24. typedef struct _MenuPrivate MenuPrivate;
  25. #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
  26. #define _g_free0(var) (var = (g_free (var), NULL))
  27. typedef struct _Block1Data Block1Data;
  28.  
  29. #define TYPE_MANAGER (manager_get_type ())
  30. #define MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MANAGER, Manager))
  31. #define IS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MANAGER))
  32. #define MANAGER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_MANAGER, ManagerIface))
  33.  
  34. typedef struct _Manager Manager;
  35. typedef struct _ManagerIface ManagerIface;
  36.  
  37. #define TYPE_MANAGER_PROXY (manager_proxy_get_type ())
  38. #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
  39. #define _g_list_free0(var) ((var == NULL) ? NULL : (var = (g_list_free (var), NULL)))
  40. typedef struct _Block2Data Block2Data;
  41. typedef struct _Block3Data Block3Data;
  42. #define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
  43. typedef struct _Block4Data Block4Data;
  44. typedef struct _Block5Data Block5Data;
  45. typedef GDBusProxy ManagerProxy;
  46. typedef GDBusProxyClass ManagerProxyClass;
  47. #define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))
  48.  
  49. struct _Menu {
  50.         GObject parent_instance;
  51.         MenuPrivate * priv;
  52. };
  53.  
  54. struct _MenuClass {
  55.         GObjectClass parent_class;
  56. };
  57.  
  58. struct _MenuPrivate {
  59.         guint64 _xwindow;
  60.         GtkMenuShell* shell;
  61.         gulong realize_handler_id;
  62.         gulong unrealize_handler_id;
  63. };
  64.  
  65. struct _Block1Data {
  66.         int _ref_count_;
  67.         guint reg_id;
  68. };
  69.  
  70. struct _ManagerIface {
  71.         GTypeInterface parent_iface;
  72.         void (*add) (Manager* self, const gchar* object_path, GError** error);
  73. };
  74.  
  75. struct _Block2Data {
  76.         int _ref_count_;
  77.         Menu * self;
  78.         GtkMenuItem* cursor;
  79. };
  80.  
  81. struct _Block3Data {
  82.         int _ref_count_;
  83.         Block2Data * _data2_;
  84.         gint loc;
  85.         gint j;
  86. };
  87.  
  88. struct _Block4Data {
  89.         int _ref_count_;
  90.         GString* sb;
  91. };
  92.  
  93. struct _Block5Data {
  94.         int _ref_count_;
  95.         GtkWidget* rt;
  96.         GType type;
  97. };
  98.  
  99.  
  100. static gpointer menu_parent_class = NULL;
  101.  
  102. GType menu_get_type (void) G_GNUC_CONST;
  103. guint menu_register_object (void* object, GDBusConnection* connection, const gchar* path, GError** error);
  104. #define MENU_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MENU, MenuPrivate))
  105. enum  {
  106.         MENU_DUMMY_PROPERTY,
  107.         MENU_XWINDOW
  108. };
  109. void menu_get_ui (Menu* self, const gchar* path, gchar** ui);
  110. static GtkWidget* menu_get_widget (Menu* self, const gchar* path);
  111. static gchar* menu_serialize (GtkWidget* widget);
  112. void menu_emit (Menu* self, const gchar* path);
  113. Menu* menu_new (GtkMenuShell* shell);
  114. Menu* menu_construct (GType object_type, GtkMenuShell* shell);
  115. static void _lambda3_ (GtkWidget* prev, Menu* self);
  116. static void menu_attach_to_toplevel (Menu* self, GtkWidget* toplevel);
  117. static void __lambda3__gtk_widget_hierarchy_changed (GtkWidget* _sender, GtkWidget* previous_toplevel, gpointer self);
  118. void menu_register (GtkMenuShell* shell);
  119. static Block1Data* block1_data_ref (Block1Data* _data1_);
  120. static void block1_data_unref (Block1Data* _data1_);
  121. GType manager_proxy_get_type (void) G_GNUC_CONST;
  122. guint manager_register_object (void* object, GDBusConnection* connection, const gchar* path, GError** error);
  123. GType manager_get_type (void) G_GNUC_CONST;
  124. void manager_add (Manager* self, const gchar* object_path, GError** error);
  125. static void _lambda6_ (GtkObject* shell, Block1Data* _data1_);
  126. static void __lambda6__gtk_object_destroy (GtkObject* _sender, gpointer self);
  127. void menu_lost (GtkMenuShell* shell);
  128. gboolean menu_has_registered (GtkMenuShell* shell);
  129. void menu_register_all (void);
  130. static GtkWidget* menu_widget_by_type (GtkWidget* parent, GType type);
  131. void menu_lost_all (void);
  132. static void _lambda4_ (GtkWidget* obj, Menu* self);
  133. static void menu_set_xwindow (Menu* self, guint64 value);
  134. static void __lambda4__gtk_widget_realize (GtkWidget* _sender, gpointer self);
  135. static void _lambda5_ (GtkWidget* obj, Menu* self);
  136. static void __lambda5__gtk_widget_unrealize (GtkWidget* _sender, gpointer self);
  137. static Block2Data* block2_data_ref (Block2Data* _data2_);
  138. static void block2_data_unref (Block2Data* _data2_);
  139. static Block3Data* block3_data_ref (Block3Data* _data3_);
  140. static void block3_data_unref (Block3Data* _data3_);
  141. static void _lambda0_ (GtkWidget* item, Block3Data* _data3_);
  142. static void __lambda0__gtk_callback (GtkWidget* widget, gpointer self);
  143. static void menu_serialize_to (GString* sb, GtkWidget* widget);
  144. static Block4Data* block4_data_ref (Block4Data* _data4_);
  145. static void block4_data_unref (Block4Data* _data4_);
  146. static void _lambda1_ (GtkWidget* item, Block4Data* _data4_);
  147. static void __lambda1__gtk_callback (GtkWidget* widget, gpointer self);
  148. static Block5Data* block5_data_ref (Block5Data* _data5_);
  149. static void block5_data_unref (Block5Data* _data5_);
  150. static void _lambda2_ (GtkWidget* widget, Block5Data* _data5_);
  151. static void __lambda2__gtk_callback (GtkWidget* widget, gpointer self);
  152. guint64 menu_get_xwindow (Menu* self);
  153. static void menu_finalize (GObject* obj);
  154. static void _vala_menu_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
  155. static void _vala_menu_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
  156. static void _dbus_menu_get_ui (Menu* self, GVariant* parameters, GDBusMethodInvocation* invocation);
  157. static void _dbus_menu_emit (Menu* self, GVariant* parameters, GDBusMethodInvocation* invocation);
  158. static void menu_dbus_interface_method_call (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* method_name, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer user_data);
  159. static GVariant* menu_dbus_interface_get_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GError** error, gpointer user_data);
  160. static GVariant* _dbus_menu_get_xwindow (Menu* self);
  161. static gboolean menu_dbus_interface_set_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GVariant* value, GError** error, gpointer user_data);
  162. static void _dbus_menu_set_xwindow (Menu* self, GVariant* _value);
  163. static void _menu_unregister_object (gpointer user_data);
  164. static void manager_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters);
  165. static void manager_proxy_add (Manager* self, const gchar* object_path, GError** error);
  166. static void manager_proxy_manager_interface_init (ManagerIface* iface);
  167. static void _dbus_manager_add (Manager* self, GVariant* parameters, GDBusMethodInvocation* invocation);
  168. static void manager_dbus_interface_method_call (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* method_name, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer user_data);
  169. static GVariant* manager_dbus_interface_get_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GError** error, gpointer user_data);
  170. static gboolean manager_dbus_interface_set_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GVariant* value, GError** error, gpointer user_data);
  171. static void _manager_unregister_object (gpointer user_data);
  172. void callback (GtkAction* action);
  173. void _vala_main (gchar** args, int args_length1);
  174. static void _callback_gtk_action_callback (GtkAction* action, gpointer self);
  175. static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
  176. static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
  177. static gint _vala_array_length (gpointer array);
  178.  
  179. static const GDBusArgInfo _menu_dbus_arg_info_get_ui_path = {-1, "path", "s"};
  180. static const GDBusArgInfo _menu_dbus_arg_info_get_ui_ui = {-1, "ui", "s"};
  181. static const GDBusArgInfo * const _menu_dbus_arg_info_get_ui_in[] = {&_menu_dbus_arg_info_get_ui_path, NULL};
  182. static const GDBusArgInfo * const _menu_dbus_arg_info_get_ui_out[] = {&_menu_dbus_arg_info_get_ui_ui, NULL};
  183. static const GDBusMethodInfo _menu_dbus_method_info_get_ui = {-1, "GetUi", (GDBusArgInfo **) (&_menu_dbus_arg_info_get_ui_in), (GDBusArgInfo **) (&_menu_dbus_arg_info_get_ui_out)};
  184. static const GDBusArgInfo _menu_dbus_arg_info_emit_path = {-1, "path", "s"};
  185. static const GDBusArgInfo * const _menu_dbus_arg_info_emit_in[] = {&_menu_dbus_arg_info_emit_path, NULL};
  186. static const GDBusArgInfo * const _menu_dbus_arg_info_emit_out[] = {NULL};
  187. static const GDBusMethodInfo _menu_dbus_method_info_emit = {-1, "Emit", (GDBusArgInfo **) (&_menu_dbus_arg_info_emit_in), (GDBusArgInfo **) (&_menu_dbus_arg_info_emit_out)};
  188. static const GDBusMethodInfo * const _menu_dbus_method_info[] = {&_menu_dbus_method_info_get_ui, &_menu_dbus_method_info_emit, NULL};
  189. static const GDBusSignalInfo * const _menu_dbus_signal_info[] = {NULL};
  190. static const GDBusPropertyInfo _menu_dbus_property_info_xwindow = {-1, "Xwindow", "t", G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE};
  191. static const GDBusPropertyInfo * const _menu_dbus_property_info[] = {&_menu_dbus_property_info_xwindow, NULL};
  192. static const GDBusInterfaceInfo _menu_dbus_interface_info = {-1, "org.globalmenu.menu", (GDBusMethodInfo **) (&_menu_dbus_method_info), (GDBusSignalInfo **) (&_menu_dbus_signal_info), (GDBusPropertyInfo **) (&_menu_dbus_property_info)};
  193. static const GDBusInterfaceVTable _menu_dbus_interface_vtable = {menu_dbus_interface_method_call, menu_dbus_interface_get_property, menu_dbus_interface_set_property};
  194. static const GDBusArgInfo _manager_dbus_arg_info_add_object_path = {-1, "object_path", "s"};
  195. static const GDBusArgInfo * const _manager_dbus_arg_info_add_in[] = {&_manager_dbus_arg_info_add_object_path, NULL};
  196. static const GDBusArgInfo * const _manager_dbus_arg_info_add_out[] = {NULL};
  197. static const GDBusMethodInfo _manager_dbus_method_info_add = {-1, "Add", (GDBusArgInfo **) (&_manager_dbus_arg_info_add_in), (GDBusArgInfo **) (&_manager_dbus_arg_info_add_out)};
  198. static const GDBusMethodInfo * const _manager_dbus_method_info[] = {&_manager_dbus_method_info_add, NULL};
  199. static const GDBusSignalInfo * const _manager_dbus_signal_info[] = {NULL};
  200. static const GDBusPropertyInfo * const _manager_dbus_property_info[] = {NULL};
  201. static const GDBusInterfaceInfo _manager_dbus_interface_info = {-1, "org.globalmenu.manager", (GDBusMethodInfo **) (&_manager_dbus_method_info), (GDBusSignalInfo **) (&_manager_dbus_signal_info), (GDBusPropertyInfo **) (&_manager_dbus_property_info)};
  202. static const GDBusInterfaceVTable _manager_dbus_interface_vtable = {manager_dbus_interface_method_call, manager_dbus_interface_get_property, manager_dbus_interface_set_property};
  203.  
  204. static gchar* string_slice (const gchar* self, glong start, glong end) {
  205.         gchar* result = NULL;
  206.         gint _tmp0_;
  207.         glong string_length;
  208.         gboolean _tmp1_ = FALSE;
  209.         gboolean _tmp2_ = FALSE;
  210.         gchar* _tmp3_ = NULL;
  211.         g_return_val_if_fail (self != NULL, NULL);
  212.         _tmp0_ = strlen (self);
  213.         string_length = (glong) _tmp0_;
  214.         if (start < 0) {
  215.                 start = string_length + start;
  216.         }
  217.         if (end < 0) {
  218.                 end = string_length + end;
  219.         }
  220.         if (start >= 0) {
  221.                 _tmp1_ = start <= string_length;
  222.         } else {
  223.                 _tmp1_ = FALSE;
  224.         }
  225.         g_return_val_if_fail (_tmp1_, NULL);
  226.         if (end >= 0) {
  227.                 _tmp2_ = end <= string_length;
  228.         } else {
  229.                 _tmp2_ = FALSE;
  230.         }
  231.         g_return_val_if_fail (_tmp2_, NULL);
  232.         g_return_val_if_fail (start <= end, NULL);
  233.         _tmp3_ = g_strndup (((gchar*) self) + start, (gsize) (end - start));
  234.         result = _tmp3_;
  235.         return result;
  236. }
  237.  
  238.  
  239. void menu_get_ui (Menu* self, const gchar* path, gchar** ui) {
  240.         gchar* _ui = NULL;
  241.         GtkWidget* _tmp0_ = NULL;
  242.         GtkWidget* widget;
  243.         g_return_if_fail (self != NULL);
  244.         g_return_if_fail (path != NULL);
  245.         _tmp0_ = menu_get_widget (self, path);
  246.         widget = _tmp0_;
  247.         if (GTK_IS_MENU_SHELL (widget)) {
  248.                 gchar* _tmp1_ = NULL;
  249.                 gchar* _tmp2_;
  250.                 GtkWidget* _tmp3_ = NULL;
  251.                 GtkWidget* _tmp4_;
  252.                 GtkMenuItem* _tmp5_;
  253.                 GtkMenuItem* item;
  254.                 GtkWidget* _tmp8_;
  255.                 gchar* _tmp9_ = NULL;
  256.                 _tmp1_ = string_slice (path, (glong) 0, (glong) (-1));
  257.                 _tmp2_ = _tmp1_;
  258.                 _tmp3_ = menu_get_widget (self, _tmp2_);
  259.                 _tmp4_ = _tmp3_;
  260.                 _tmp5_ = GTK_IS_MENU_ITEM (_tmp4_) ? ((GtkMenuItem*) _tmp4_) : NULL;
  261.                 _g_free0 (_tmp2_);
  262.                 item = _tmp5_;
  263.                 if (item != NULL) {
  264.                         gchar* _tmp6_ = NULL;
  265.                         gchar* _tmp7_;
  266.                         _tmp6_ = string_slice (path, (glong) 0, (glong) (-1));
  267.                         _tmp7_ = _tmp6_;
  268.                         g_print ("path = %s, item is %p\n", _tmp7_, item);
  269.                         _g_free0 (_tmp7_);
  270.                         gtk_menu_item_activate (item);
  271.                         gtk_item_select ((GtkItem*) item);
  272.                 }
  273.                 gtk_widget_show (widget);
  274.                 _tmp8_ = widget;
  275.                 _tmp9_ = menu_serialize ((GtkWidget*) (GTK_IS_MENU_SHELL (_tmp8_) ? ((GtkMenuShell*) _tmp8_) : NULL));
  276.                 _g_free0 (_ui);
  277.                 _ui = _tmp9_;
  278.                 _g_object_unref0 (item);
  279.         } else {
  280.                 gchar* _tmp10_;
  281.                 _tmp10_ = g_strdup ("<empty/>");
  282.                 _g_free0 (_ui);
  283.                 _ui = _tmp10_;
  284.         }
  285.         _g_object_unref0 (widget);
  286.         if (ui) {
  287.                 *ui = _ui;
  288.         } else {
  289.                 _g_free0 (_ui);
  290.         }
  291. }
  292.  
  293.  
  294. void menu_emit (Menu* self, const gchar* path) {
  295.         GtkWidget* _tmp0_ = NULL;
  296.         GtkWidget* widget;
  297.         g_return_if_fail (self != NULL);
  298.         g_return_if_fail (path != NULL);
  299.         _tmp0_ = menu_get_widget (self, path);
  300.         widget = _tmp0_;
  301.         if (GTK_IS_TEAROFF_MENU_ITEM (widget)) {
  302.                 _g_object_unref0 (widget);
  303.                 return;
  304.         }
  305.         if (GTK_IS_SEPARATOR_MENU_ITEM (widget)) {
  306.                 _g_object_unref0 (widget);
  307.                 return;
  308.         }
  309.         if (GTK_IS_MENU_ITEM (widget)) {
  310.                 GtkWidget* _tmp1_;
  311.                 _tmp1_ = widget;
  312.                 gtk_menu_item_activate (GTK_IS_MENU_ITEM (_tmp1_) ? ((GtkMenuItem*) _tmp1_) : NULL);
  313.         }
  314.         _g_object_unref0 (widget);
  315. }
  316.  
  317.  
  318. static gpointer _g_object_ref0 (gpointer self) {
  319.         return self ? g_object_ref (self) : NULL;
  320. }
  321.  
  322.  
  323. static void _lambda3_ (GtkWidget* prev, Menu* self) {
  324.         GtkWidget* _tmp0_ = NULL;
  325.         GtkWidget* _tmp1_;
  326.         GtkWidget* next;
  327.         if (GTK_IS_WINDOW (prev)) {
  328.                 g_signal_handler_disconnect ((GObject*) prev, self->priv->realize_handler_id);
  329.         }
  330.         g_signal_handler_disconnect ((GObject*) prev, self->priv->unrealize_handler_id);
  331.         _tmp0_ = gtk_widget_get_toplevel ((GtkWidget*) self->priv->shell);
  332.         _tmp1_ = _g_object_ref0 (_tmp0_);
  333.         next = _tmp1_;
  334.         if (GTK_IS_WINDOW (next)) {
  335.                 menu_attach_to_toplevel (self, next);
  336.         }
  337.         _g_object_unref0 (next);
  338. }
  339.  
  340.  
  341. static void __lambda3__gtk_widget_hierarchy_changed (GtkWidget* _sender, GtkWidget* previous_toplevel, gpointer self) {
  342.         _lambda3_ (previous_toplevel, self);
  343. }
  344.  
  345.  
  346. Menu* menu_construct (GType object_type, GtkMenuShell* shell) {
  347.         Menu * self = NULL;
  348.         GtkMenuShell* _tmp0_;
  349.         GtkWidget* _tmp1_ = NULL;
  350.         GtkWidget* _tmp2_;
  351.         GtkWidget* toplevel;
  352.         g_return_val_if_fail (shell != NULL, NULL);
  353.         self = (Menu*) g_object_new (object_type, NULL);
  354.         _tmp0_ = _g_object_ref0 (shell);
  355.         _g_object_unref0 (self->priv->shell);
  356.         self->priv->shell = _tmp0_;
  357.         g_signal_connect_object ((GtkWidget*) self->priv->shell, "hierarchy-changed", (GCallback) __lambda3__gtk_widget_hierarchy_changed, self, 0);
  358.         _tmp1_ = gtk_widget_get_toplevel ((GtkWidget*) self->priv->shell);
  359.         _tmp2_ = _g_object_ref0 (_tmp1_);
  360.         toplevel = _tmp2_;
  361.         if (GTK_IS_WINDOW (toplevel)) {
  362.                 menu_attach_to_toplevel (self, toplevel);
  363.         }
  364.         _g_object_unref0 (toplevel);
  365.         return self;
  366. }
  367.  
  368.  
  369. Menu* menu_new (GtkMenuShell* shell) {
  370.         return menu_construct (TYPE_MENU, shell);
  371. }
  372.  
  373.  
  374. static Block1Data* block1_data_ref (Block1Data* _data1_) {
  375.         g_atomic_int_inc (&_data1_->_ref_count_);
  376.         return _data1_;
  377. }
  378.  
  379.  
  380. static void block1_data_unref (Block1Data* _data1_) {
  381.         if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
  382.                 g_slice_free (Block1Data, _data1_);
  383.         }
  384. }
  385.  
  386.  
  387. static void _lambda6_ (GtkObject* shell, Block1Data* _data1_) {
  388.         GDBusConnection* _tmp0_ = NULL;
  389.         GDBusConnection* _tmp1_;
  390.         GDBusConnection* _tmp2_;
  391.         GError * _inner_error_ = NULL;
  392.         g_return_if_fail (shell != NULL);
  393.         _tmp0_ = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &_inner_error_);
  394.         _tmp1_ = _tmp0_;
  395.         if (_inner_error_ != NULL) {
  396.                 if (_inner_error_->domain == G_IO_ERROR) {
  397.                         goto __catch1_g_io_error;
  398.                 }
  399.                 g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
  400.                 g_clear_error (&_inner_error_);
  401.                 return;
  402.         }
  403.         _tmp2_ = _tmp1_;
  404.         g_dbus_connection_unregister_object (_tmp2_, _data1_->reg_id);
  405.         _g_object_unref0 (_tmp2_);
  406.         goto __finally1;
  407.         __catch1_g_io_error:
  408.         {
  409.                 GError * e;
  410.                 e = _inner_error_;
  411.                 _inner_error_ = NULL;
  412.                 g_warning ("client-gtk2.vala:65: could not unregister menu %s\n", e->message);
  413.                 _g_error_free0 (e);
  414.         }
  415.         __finally1:
  416.         if (_inner_error_ != NULL) {
  417.                 g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
  418.                 g_clear_error (&_inner_error_);
  419.                 return;
  420.         }
  421. }
  422.  
  423.  
  424. static void __lambda6__gtk_object_destroy (GtkObject* _sender, gpointer self) {
  425.         _lambda6_ (_sender, self);
  426. }
  427.  
  428.  
  429. void menu_register (GtkMenuShell* shell) {
  430.         Block1Data* _data1_;
  431.         Menu* _tmp0_ = NULL;
  432.         Menu* menu;
  433.         Manager* _tmp1_ = NULL;
  434.         Manager* manager;
  435.         gchar* _tmp2_ = NULL;
  436.         gchar* object_path;
  437.         GDBusConnection* _tmp3_ = NULL;
  438.         GDBusConnection* _tmp4_;
  439.         GDBusConnection* _tmp5_;
  440.         guint _tmp6_;
  441.         guint _tmp7_;
  442.         gulong _tmp8_;
  443.         gulong destroy_id;
  444.         GError * _inner_error_ = NULL;
  445.         g_return_if_fail (shell != NULL);
  446.         _data1_ = g_slice_new0 (Block1Data);
  447.         _data1_->_ref_count_ = 1;
  448.         _tmp0_ = menu_new (shell);
  449.         menu = _tmp0_;
  450.         _tmp1_ = g_initable_new (TYPE_MANAGER_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", "org.globalmenu.manager", "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/globalmenu/manager", "g-interface-name", "org.globalmenu.manager", NULL);
  451.         manager = (Manager*) _tmp1_;
  452.         if (_inner_error_ != NULL) {
  453.                 _g_object_unref0 (menu);
  454.                 block1_data_unref (_data1_);
  455.                 _data1_ = NULL;
  456.                 if (_inner_error_->domain == G_IO_ERROR) {
  457.                         goto __catch0_g_io_error;
  458.                 }
  459.                 _g_object_unref0 (menu);
  460.                 block1_data_unref (_data1_);
  461.                 _data1_ = NULL;
  462.                 g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
  463.                 g_clear_error (&_inner_error_);
  464.                 return;
  465.         }
  466.         _tmp2_ = g_strdup_printf ("/org/globalmenu/%p", shell);
  467.         object_path = _tmp2_;
  468.         _tmp3_ = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &_inner_error_);
  469.         _tmp4_ = _tmp3_;
  470.         if (_inner_error_ != NULL) {
  471.                 _g_free0 (object_path);
  472.                 _g_object_unref0 (manager);
  473.                 _g_object_unref0 (menu);
  474.                 block1_data_unref (_data1_);
  475.                 _data1_ = NULL;
  476.                 if (_inner_error_->domain == G_IO_ERROR) {
  477.                         goto __catch0_g_io_error;
  478.                 }
  479.                 _g_free0 (object_path);
  480.                 _g_object_unref0 (manager);
  481.                 _g_object_unref0 (menu);
  482.                 block1_data_unref (_data1_);
  483.                 _data1_ = NULL;
  484.                 g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
  485.                 g_clear_error (&_inner_error_);
  486.                 return;
  487.         }
  488.         _tmp5_ = _tmp4_;
  489.         _tmp6_ = menu_register_object (menu, _tmp5_, object_path, &_inner_error_);
  490.         _tmp7_ = _tmp6_;
  491.         _g_object_unref0 (_tmp5_);
  492.         _data1_->reg_id = _tmp7_;
  493.         if (_inner_error_ != NULL) {
  494.                 _g_free0 (object_path);
  495.                 _g_object_unref0 (manager);
  496.                 _g_object_unref0 (menu);
  497.                 block1_data_unref (_data1_);
  498.                 _data1_ = NULL;
  499.                 if (_inner_error_->domain == G_IO_ERROR) {
  500.                         goto __catch0_g_io_error;
  501.                 }
  502.                 _g_free0 (object_path);
  503.                 _g_object_unref0 (manager);
  504.                 _g_object_unref0 (menu);
  505.                 block1_data_unref (_data1_);
  506.                 _data1_ = NULL;
  507.                 g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
  508.                 g_clear_error (&_inner_error_);
  509.                 return;
  510.         }
  511.         manager_add (manager, object_path, &_inner_error_);
  512.         if (_inner_error_ != NULL) {
  513.                 _g_free0 (object_path);
  514.                 _g_object_unref0 (manager);
  515.                 _g_object_unref0 (menu);
  516.                 block1_data_unref (_data1_);
  517.                 _data1_ = NULL;
  518.                 if (_inner_error_->domain == G_IO_ERROR) {
  519.                         goto __catch0_g_io_error;
  520.                 }
  521.                 _g_free0 (object_path);
  522.                 _g_object_unref0 (manager);
  523.                 _g_object_unref0 (menu);
  524.                 block1_data_unref (_data1_);
  525.                 _data1_ = NULL;
  526.                 g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
  527.                 g_clear_error (&_inner_error_);
  528.                 return;
  529.         }
  530.         _tmp8_ = g_signal_connect_data ((GtkObject*) shell, "destroy", (GCallback) __lambda6__gtk_object_destroy, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
  531.         destroy_id = _tmp8_;
  532.         g_object_set_data_full ((GObject*) shell, "globalmenu-reg", GUINT_TO_POINTER (_data1_->reg_id), NULL);
  533.         g_object_set_data_full ((GObject*) shell, "globalmenu-destroy", GUINT_TO_POINTER (destroy_id), NULL);
  534.         _g_free0 (object_path);
  535.         _g_object_unref0 (manager);
  536.         _g_object_unref0 (menu);
  537.         block1_data_unref (_data1_);
  538.         _data1_ = NULL;
  539.         goto __finally0;
  540.         __catch0_g_io_error:
  541.         {
  542.                 GError * e;
  543.                 e = _inner_error_;
  544.                 _inner_error_ = NULL;
  545.                 g_warning ("client-gtk2.vala:74: could not register menu %s\n", e->message);
  546.                 _g_error_free0 (e);
  547.         }
  548.         __finally0:
  549.         if (_inner_error_ != NULL) {
  550.                 g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
  551.                 g_clear_error (&_inner_error_);
  552.                 return;
  553.         }
  554. }
  555.  
  556.  
  557. void menu_lost (GtkMenuShell* shell) {
  558.         gconstpointer _tmp0_ = NULL;
  559.         gulong destroy_id;
  560.         gconstpointer _tmp1_ = NULL;
  561.         guint reg_id;
  562.         GDBusConnection* _tmp2_ = NULL;
  563.         GDBusConnection* _tmp3_;
  564.         GDBusConnection* _tmp4_;
  565.         GError * _inner_error_ = NULL;
  566.         g_return_if_fail (shell != NULL);
  567.         _tmp0_ = g_object_get_data ((GObject*) shell, "globalmenu-destroy");
  568.         destroy_id = GPOINTER_TO_UINT (_tmp0_);
  569.         _tmp1_ = g_object_get_data ((GObject*) shell, "globalmenu-reg");
  570.         reg_id = GPOINTER_TO_UINT (_tmp1_);
  571.         g_signal_handler_disconnect ((GObject*) shell, destroy_id);
  572.         _tmp2_ = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &_inner_error_);
  573.         _tmp3_ = _tmp2_;
  574.         if (_inner_error_ != NULL) {
  575.                 if (_inner_error_->domain == G_IO_ERROR) {
  576.                         goto __catch2_g_io_error;
  577.                 }
  578.                 g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
  579.                 g_clear_error (&_inner_error_);
  580.                 return;
  581.         }
  582.         _tmp4_ = _tmp3_;
  583.         g_dbus_connection_unregister_object (_tmp4_, reg_id);
  584.         _g_object_unref0 (_tmp4_);
  585.         goto __finally2;
  586.         __catch2_g_io_error:
  587.         {
  588.                 GError * e;
  589.                 e = _inner_error_;
  590.                 _inner_error_ = NULL;
  591.                 g_message ("client-gtk2.vala:84: can't unregister %s", e->message);
  592.                 _g_error_free0 (e);
  593.         }
  594.         __finally2:
  595.         if (_inner_error_ != NULL) {
  596.                 g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
  597.                 g_clear_error (&_inner_error_);
  598.                 return;
  599.         }
  600.         g_object_set_data_full ((GObject*) shell, "globalmenu-reg", GUINT_TO_POINTER ((guint) 0), NULL);
  601.         g_object_set_data_full ((GObject*) shell, "globalmenu-destroy", GUINT_TO_POINTER ((gulong) 0), NULL);
  602. }
  603.  
  604.  
  605. gboolean menu_has_registered (GtkMenuShell* shell) {
  606.         gboolean result = FALSE;
  607.         gconstpointer _tmp0_ = NULL;
  608.         g_return_val_if_fail (shell != NULL, FALSE);
  609.         _tmp0_ = g_object_get_data ((GObject*) shell, "globalmenu-reg");
  610.         result = GPOINTER_TO_UINT (_tmp0_) != 0;
  611.         return result;
  612. }
  613.  
  614.  
  615. void menu_register_all (void) {
  616.         GList* _tmp0_ = NULL;
  617.         GList* l;
  618.         _tmp0_ = gtk_window_list_toplevels ();
  619.         l = _tmp0_;
  620.         {
  621.                 GList* window_collection;
  622.                 GList* window_it;
  623.                 window_collection = l;
  624.                 for (window_it = window_collection; window_it != NULL; window_it = window_it->next) {
  625.                         GtkWindow* window;
  626.                         window = (GtkWindow*) window_it->data;
  627.                         {
  628.                                 GtkWidget* _tmp1_ = NULL;
  629.                                 GtkWidget* _tmp2_;
  630.                                 GtkMenuBar* menubar;
  631.                                 gboolean _tmp3_ = FALSE;
  632.                                 _tmp1_ = menu_widget_by_type ((GtkWidget*) window, GTK_TYPE_MENU_BAR);
  633.                                 _tmp2_ = _tmp1_;
  634.                                 menubar = GTK_IS_MENU_BAR (_tmp2_) ? ((GtkMenuBar*) _tmp2_) : NULL;
  635.                                 if (menubar != NULL) {
  636.                                         gboolean _tmp4_;
  637.                                         _tmp4_ = menu_has_registered ((GtkMenuShell*) menubar);
  638.                                         _tmp3_ = !_tmp4_;
  639.                                 } else {
  640.                                         _tmp3_ = FALSE;
  641.                                 }
  642.                                 if (_tmp3_) {
  643.                                         menu_register ((GtkMenuShell*) menubar);
  644.                                 }
  645.                                 _g_object_unref0 (menubar);
  646.                         }
  647.                 }
  648.         }
  649.         _g_list_free0 (l);
  650. }
  651.  
  652.  
  653. void menu_lost_all (void) {
  654.         GList* _tmp0_ = NULL;
  655.         GList* l;
  656.         _tmp0_ = gtk_window_list_toplevels ();
  657.         l = _tmp0_;
  658.         {
  659.                 GList* window_collection;
  660.                 GList* window_it;
  661.                 window_collection = l;
  662.                 for (window_it = window_collection; window_it != NULL; window_it = window_it->next) {
  663.                         GtkWindow* window;
  664.                         window = (GtkWindow*) window_it->data;
  665.                         {
  666.                                 GtkWidget* _tmp1_ = NULL;
  667.                                 GtkWidget* _tmp2_;
  668.                                 GtkMenuBar* menubar;
  669.                                 gboolean _tmp3_ = FALSE;
  670.                                 _tmp1_ = menu_widget_by_type ((GtkWidget*) window, GTK_TYPE_MENU_BAR);
  671.                                 _tmp2_ = _tmp1_;
  672.                                 menubar = GTK_IS_MENU_BAR (_tmp2_) ? ((GtkMenuBar*) _tmp2_) : NULL;
  673.                                 if (menubar != NULL) {
  674.                                         gboolean _tmp4_;
  675.                                         _tmp4_ = menu_has_registered ((GtkMenuShell*) menubar);
  676.                                         _tmp3_ = _tmp4_;
  677.                                 } else {
  678.                                         _tmp3_ = FALSE;
  679.                                 }
  680.                                 if (_tmp3_) {
  681.                                         menu_lost ((GtkMenuShell*) menubar);
  682.                                 }
  683.                                 _g_object_unref0 (menubar);
  684.                         }
  685.                 }
  686.         }
  687.         _g_list_free0 (l);
  688. }
  689.  
  690.  
  691. static void _lambda4_ (GtkWidget* obj, Menu* self) {
  692.         GdkWindow* _tmp0_ = NULL;
  693.         XID _tmp1_;
  694.         g_return_if_fail (obj != NULL);
  695.         _tmp0_ = gtk_widget_get_window (obj);
  696.         _tmp1_ = gdk_x11_drawable_get_xid ((GdkDrawable*) _tmp0_);
  697.         menu_set_xwindow (self, (guint64) _tmp1_);
  698. }
  699.  
  700.  
  701. static void __lambda4__gtk_widget_realize (GtkWidget* _sender, gpointer self) {
  702.         _lambda4_ (_sender, self);
  703. }
  704.  
  705.  
  706. static void _lambda5_ (GtkWidget* obj, Menu* self) {
  707.         g_return_if_fail (obj != NULL);
  708.         menu_set_xwindow (self, (guint64) 0);
  709. }
  710.  
  711.  
  712. static void __lambda5__gtk_widget_unrealize (GtkWidget* _sender, gpointer self) {
  713.         _lambda5_ (_sender, self);
  714. }
  715.  
  716.  
  717. static void menu_attach_to_toplevel (Menu* self, GtkWidget* toplevel) {
  718.         gulong _tmp0_;
  719.         gulong _tmp1_;
  720.         gboolean _tmp2_;
  721.         g_return_if_fail (self != NULL);
  722.         g_return_if_fail (toplevel != NULL);
  723.         _tmp0_ = g_signal_connect_object (toplevel, "realize", (GCallback) __lambda4__gtk_widget_realize, self, 0);
  724.         self->priv->realize_handler_id = _tmp0_;
  725.         _tmp1_ = g_signal_connect_object (toplevel, "unrealize", (GCallback) __lambda5__gtk_widget_unrealize, self, 0);
  726.         self->priv->unrealize_handler_id = _tmp1_;
  727.         _tmp2_ = gtk_widget_get_realized (toplevel);
  728.         if (_tmp2_) {
  729.                 GdkWindow* _tmp3_ = NULL;
  730.                 XID _tmp4_;
  731.                 _tmp3_ = gtk_widget_get_window (toplevel);
  732.                 _tmp4_ = gdk_x11_drawable_get_xid ((GdkDrawable*) _tmp3_);
  733.                 menu_set_xwindow (self, (guint64) _tmp4_);
  734.         }
  735. }
  736.  
  737.  
  738. static Block2Data* block2_data_ref (Block2Data* _data2_) {
  739.         g_atomic_int_inc (&_data2_->_ref_count_);
  740.         return _data2_;
  741. }
  742.  
  743.  
  744. static void block2_data_unref (Block2Data* _data2_) {
  745.         if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
  746.                 _g_object_unref0 (_data2_->self);
  747.                 _g_object_unref0 (_data2_->cursor);
  748.                 g_slice_free (Block2Data, _data2_);
  749.         }
  750. }
  751.  
  752.  
  753. static Block3Data* block3_data_ref (Block3Data* _data3_) {
  754.         g_atomic_int_inc (&_data3_->_ref_count_);
  755.         return _data3_;
  756. }
  757.  
  758.  
  759. static void block3_data_unref (Block3Data* _data3_) {
  760.         if (g_atomic_int_dec_and_test (&_data3_->_ref_count_)) {
  761.                 block2_data_unref (_data3_->_data2_);
  762.                 _data3_->_data2_ = NULL;
  763.                 g_slice_free (Block3Data, _data3_);
  764.         }
  765. }
  766.  
  767.  
  768. static void _lambda0_ (GtkWidget* item, Block3Data* _data3_) {
  769.         Block2Data* _data2_;
  770.         Menu * self;
  771.         _data2_ = _data3_->_data2_;
  772.         self = _data2_->self;
  773.         g_return_if_fail (item != NULL);
  774.         if (_data3_->j == _data3_->loc) {
  775.                 GtkWidget* _tmp0_;
  776.                 GtkMenuItem* _tmp1_;
  777.                 _tmp0_ = item;
  778.                 _tmp1_ = _g_object_ref0 (GTK_IS_MENU_ITEM (_tmp0_) ? ((GtkMenuItem*) _tmp0_) : NULL);
  779.                 _g_object_unref0 (_data2_->cursor);
  780.                 _data2_->cursor = _tmp1_;
  781.         }
  782.         _data3_->j++;
  783. }
  784.  
  785.  
  786. static void __lambda0__gtk_callback (GtkWidget* widget, gpointer self) {
  787.         _lambda0_ (widget, self);
  788. }
  789.  
  790.  
  791. static GtkWidget* menu_get_widget (Menu* self, const gchar* path) {
  792.         GtkWidget* result = NULL;
  793.         Block2Data* _data2_;
  794.         gchar** _tmp0_;
  795.         gchar** _tmp1_ = NULL;
  796.         gchar** segs;
  797.         gint segs_length1;
  798.         gint _segs_size_;
  799.         GtkMenuShell* _tmp2_;
  800.         GtkMenuShell* shell;
  801.         gboolean _tmp8_;
  802.         GtkWidget* _tmp9_;
  803.         g_return_val_if_fail (self != NULL, NULL);
  804.         g_return_val_if_fail (path != NULL, NULL);
  805.         _data2_ = g_slice_new0 (Block2Data);
  806.         _data2_->_ref_count_ = 1;
  807.         _data2_->self = g_object_ref (self);
  808.         _tmp1_ = _tmp0_ = g_strsplit (path, "/", 0);
  809.         segs = _tmp1_;
  810.         segs_length1 = _vala_array_length (_tmp0_);
  811.         _segs_size_ = _vala_array_length (_tmp0_);
  812.         _tmp2_ = _g_object_ref0 (self->priv->shell);
  813.         shell = _tmp2_;
  814.         _data2_->cursor = NULL;
  815.         {
  816.                 gint i;
  817.                 i = 0;
  818.                 {
  819.                         gboolean _tmp3_;
  820.                         _tmp3_ = TRUE;
  821.                         while (TRUE) {
  822.                                 Block3Data* _data3_;
  823.                                 gint _tmp4_;
  824.                                 gint _tmp5_;
  825.                                 GtkMenu* _tmp6_ = NULL;
  826.                                 GtkMenuShell* _tmp7_;
  827.                                 _data3_ = g_slice_new0 (Block3Data);
  828.                                 _data3_->_ref_count_ = 1;
  829.                                 _data3_->_data2_ = block2_data_ref (_data2_);
  830.                                 if (!_tmp3_) {
  831.                                         i++;
  832.                                 }
  833.                                 _tmp3_ = FALSE;
  834.                                 if (!(i < segs_length1)) {
  835.                                         block3_data_unref (_data3_);
  836.                                         _data3_ = NULL;
  837.                                         break;
  838.                                 }
  839.                                 _tmp4_ = strlen (segs[i]);
  840.                                 if (_tmp4_ == 0) {
  841.                                         block3_data_unref (_data3_);
  842.                                         _data3_ = NULL;
  843.                                         continue;
  844.                                 }
  845.                                 _tmp5_ = atoi (segs[i]);
  846.                                 _data3_->loc = _tmp5_;
  847.                                 _data3_->j = 0;
  848.                                 _g_object_unref0 (_data2_->cursor);
  849.                                 _data2_->cursor = NULL;
  850.                                 gtk_container_forall ((GtkContainer*) shell, __lambda0__gtk_callback, _data3_);
  851.                                 if (_data2_->cursor == NULL) {
  852.                                         result = NULL;
  853.                                         block3_data_unref (_data3_);
  854.                                         _data3_ = NULL;
  855.                                         _g_object_unref0 (shell);
  856.                                         segs = (_vala_array_free (segs, segs_length1, (GDestroyNotify) g_free), NULL);
  857.                                         block2_data_unref (_data2_);
  858.                                         _data2_ = NULL;
  859.                                         return result;
  860.                                 }
  861.                                 _tmp6_ = gtk_menu_item_get_submenu (_data2_->cursor);
  862.                                 _tmp7_ = _g_object_ref0 ((GtkMenuShell*) _tmp6_);
  863.                                 _g_object_unref0 (shell);
  864.                                 shell = _tmp7_;
  865.                                 block3_data_unref (_data3_);
  866.                                 _data3_ = NULL;
  867.                         }
  868.                 }
  869.         }
  870.         _tmp8_ = g_str_has_suffix (path, "/");
  871.         if (_tmp8_) {
  872.                 result = (GtkWidget*) shell;
  873.                 segs = (_vala_array_free (segs, segs_length1, (GDestroyNotify) g_free), NULL);
  874.                 block2_data_unref (_data2_);
  875.                 _data2_ = NULL;
  876.                 return result;
  877.         }
  878.         _tmp9_ = _g_object_ref0 ((GtkWidget*) _data2_->cursor);
  879.         result = _tmp9_;
  880.         _g_object_unref0 (shell);
  881.         segs = (_vala_array_free (segs, segs_length1, (GDestroyNotify) g_free), NULL);
  882.         block2_data_unref (_data2_);
  883.         _data2_ = NULL;
  884.         return result;
  885. }
  886.  
  887.  
  888. static gchar* menu_serialize (GtkWidget* widget) {
  889.         gchar* result = NULL;
  890.         GString* _tmp0_ = NULL;
  891.         GString* s;
  892.         gchar* _tmp1_;
  893.         g_return_val_if_fail (widget != NULL, NULL);
  894.         _tmp0_ = g_string_new ("");
  895.         s = _tmp0_;
  896.         menu_serialize_to (s, widget);
  897.         _tmp1_ = g_strdup (s->str);
  898.         result = _tmp1_;
  899.         _g_string_free0 (s);
  900.         return result;
  901. }
  902.  
  903.  
  904. static Block4Data* block4_data_ref (Block4Data* _data4_) {
  905.         g_atomic_int_inc (&_data4_->_ref_count_);
  906.         return _data4_;
  907. }
  908.  
  909.  
  910. static void block4_data_unref (Block4Data* _data4_) {
  911.         if (g_atomic_int_dec_and_test (&_data4_->_ref_count_)) {
  912.                 g_slice_free (Block4Data, _data4_);
  913.         }
  914. }
  915.  
  916.  
  917. static void _lambda1_ (GtkWidget* item, Block4Data* _data4_) {
  918.         g_return_if_fail (item != NULL);
  919.         menu_serialize_to (_data4_->sb, item);
  920. }
  921.  
  922.  
  923. static void __lambda1__gtk_callback (GtkWidget* widget, gpointer self) {
  924.         _lambda1_ (widget, self);
  925. }
  926.  
  927.  
  928. static gchar* bool_to_string (gboolean self) {
  929.         gchar* result = NULL;
  930.         if (self) {
  931.                 gchar* _tmp0_;
  932.                 _tmp0_ = g_strdup ("true");
  933.                 result = _tmp0_;
  934.                 return result;
  935.         } else {
  936.                 gchar* _tmp1_;
  937.                 _tmp1_ = g_strdup ("false");
  938.                 result = _tmp1_;
  939.                 return result;
  940.         }
  941. }
  942.  
  943.  
  944. static void menu_serialize_to (GString* sb, GtkWidget* widget) {
  945.         Block4Data* _data4_;
  946.         gboolean _tmp20_;
  947.         gboolean visible;
  948.         gboolean _tmp21_;
  949.         gboolean sensitive;
  950.         g_return_if_fail (widget != NULL);
  951.         _data4_ = g_slice_new0 (Block4Data);
  952.         _data4_->_ref_count_ = 1;
  953.         _data4_->sb = sb;
  954.         if (GTK_IS_MENU_SHELL (widget)) {
  955.                 GtkWidget* _tmp0_;
  956.                 _tmp0_ = widget;
  957.                 gtk_container_forall ((GtkContainer*) (GTK_IS_MENU_SHELL (_tmp0_) ? ((GtkMenuShell*) _tmp0_) : NULL), __lambda1__gtk_callback, _data4_);
  958.                 block4_data_unref (_data4_);
  959.                 _data4_ = NULL;
  960.                 return;
  961.         }
  962.         if (GTK_IS_SEPARATOR_MENU_ITEM (widget)) {
  963.                 g_string_append_printf (_data4_->sb, "<separator");
  964.         } else {
  965.                 if (GTK_IS_TEAROFF_MENU_ITEM (widget)) {
  966.                         g_string_append_printf (_data4_->sb, "<tearoff");
  967.                 } else {
  968.                         if (GTK_IS_RADIO_MENU_ITEM (widget)) {
  969.                                 g_string_append_printf (_data4_->sb, "<radio");
  970.                         } else {
  971.                                 if (GTK_IS_CHECK_MENU_ITEM (widget)) {
  972.                                         g_string_append_printf (_data4_->sb, "<check");
  973.                                 } else {
  974.                                         if (GTK_IS_MENU_ITEM (widget)) {
  975.                                                 g_string_append_printf (_data4_->sb, "<item");
  976.                                         } else {
  977.                                                 g_string_append_printf (_data4_->sb, "<unknown");
  978.                                         }
  979.                                 }
  980.                         }
  981.                 }
  982.         }
  983.         if (GTK_IS_MENU_ITEM (widget)) {
  984.                 GtkWidget* _tmp1_ = NULL;
  985.                 GtkWidget* _tmp2_;
  986.                 GtkLabel* label;
  987.                 const gchar* _tmp3_ = NULL;
  988.                 GtkWidget* _tmp5_;
  989.                 GtkWidget* _tmp6_ = NULL;
  990.                 gboolean has_submenu;
  991.                 GtkWidget* _tmp9_;
  992.                 GtkAction* _tmp10_ = NULL;
  993.                 GtkAction* _tmp11_;
  994.                 GtkAction* action;
  995.                 _tmp1_ = menu_widget_by_type (widget, GTK_TYPE_LABEL);
  996.                 _tmp2_ = _tmp1_;
  997.                 label = GTK_IS_LABEL (_tmp2_) ? ((GtkLabel*) _tmp2_) : NULL;
  998.                 if (label == NULL) {
  999.                         _tmp3_ = "___";
  1000.                 } else {
  1001.                         const gchar* _tmp4_ = NULL;
  1002.                         _tmp4_ = gtk_label_get_text (label);
  1003.                         _tmp3_ = _tmp4_;
  1004.                 }
  1005.                 g_string_append_printf (_data4_->sb, " label=\"%s\"", _tmp3_);
  1006.                 _tmp5_ = widget;
  1007.                 _tmp6_ = gtk_menu_item_get_submenu (GTK_IS_MENU_ITEM (_tmp5_) ? ((GtkMenuItem*) _tmp5_) : NULL);
  1008.                 has_submenu = _tmp6_ != NULL;
  1009.                 if (has_submenu) {
  1010.                         gchar* _tmp7_ = NULL;
  1011.                         gchar* _tmp8_;
  1012.                         _tmp7_ = bool_to_string (has_submenu);
  1013.                         _tmp8_ = _tmp7_;
  1014.                         g_string_append_printf (_data4_->sb, " submenu=\"%s\"", _tmp8_);
  1015.                         _g_free0 (_tmp8_);
  1016.                 }
  1017.                 _tmp9_ = widget;
  1018.                 _tmp10_ = gtk_activatable_get_related_action ((GtkActivatable*) (GTK_IS_MENU_ITEM (_tmp9_) ? ((GtkMenuItem*) _tmp9_) : NULL));
  1019.                 _tmp11_ = _g_object_ref0 (_tmp10_);
  1020.                 action = _tmp11_;
  1021.                 if (action != NULL) {
  1022.                         const gchar* _tmp12_ = NULL;
  1023.                         gchar* _tmp13_;
  1024.                         gchar* tooltip;
  1025.                         _tmp12_ = gtk_action_get_tooltip (action);
  1026.                         _tmp13_ = g_strdup (_tmp12_);
  1027.                         tooltip = _tmp13_;
  1028.                         if (tooltip != NULL) {
  1029.                                 g_string_append_printf (_data4_->sb, " tooltip=\"%s\"", tooltip);
  1030.                         }
  1031.                         _g_free0 (tooltip);
  1032.                 }
  1033.                 _g_object_unref0 (action);
  1034.                 _g_object_unref0 (label);
  1035.         }
  1036.         if (GTK_IS_RADIO_MENU_ITEM (widget)) {
  1037.                 GtkWidget* _tmp14_;
  1038.                 GSList* _tmp15_ = NULL;
  1039.                 void* group;
  1040.                 _tmp14_ = widget;
  1041.                 _tmp15_ = gtk_radio_menu_item_get_group (GTK_IS_RADIO_MENU_ITEM (_tmp14_) ? ((GtkRadioMenuItem*) _tmp14_) : NULL);
  1042.                 group = (void*) _tmp15_;
  1043.                 g_string_append_printf (_data4_->sb, " group=\"%P\"", group);
  1044.         }
  1045.         if (GTK_IS_CHECK_MENU_ITEM (widget)) {
  1046.                 GtkWidget* _tmp16_;
  1047.                 gboolean _tmp17_;
  1048.                 gboolean active;
  1049.                 gchar* _tmp18_ = NULL;
  1050.                 gchar* _tmp19_;
  1051.                 _tmp16_ = widget;
  1052.                 _tmp17_ = gtk_check_menu_item_get_active (GTK_IS_CHECK_MENU_ITEM (_tmp16_) ? ((GtkCheckMenuItem*) _tmp16_) : NULL);
  1053.                 active = _tmp17_;
  1054.                 _tmp18_ = bool_to_string (active);
  1055.                 _tmp19_ = _tmp18_;
  1056.                 g_string_append_printf (_data4_->sb, " active=\"%s\"", _tmp19_);
  1057.                 _g_free0 (_tmp19_);
  1058.         }
  1059.         _tmp20_ = gtk_widget_get_visible (widget);
  1060.         visible = _tmp20_;
  1061.         _tmp21_ = gtk_widget_get_sensitive (widget);
  1062.         sensitive = _tmp21_;
  1063.         if (!visible) {
  1064.                 gchar* _tmp22_ = NULL;
  1065.                 gchar* _tmp23_;
  1066.                 _tmp22_ = bool_to_string (visible);
  1067.                 _tmp23_ = _tmp22_;
  1068.                 g_string_append_printf (_data4_->sb, " visible=\"%s\"", _tmp23_);
  1069.                 _g_free0 (_tmp23_);
  1070.         }
  1071.         if (!sensitive) {
  1072.                 gchar* _tmp24_ = NULL;
  1073.                 gchar* _tmp25_;
  1074.                 _tmp24_ = bool_to_string (sensitive);
  1075.                 _tmp25_ = _tmp24_;
  1076.                 g_string_append_printf (_data4_->sb, " sensitive=\"%s\"", _tmp25_);
  1077.                 _g_free0 (_tmp25_);
  1078.         }
  1079.         g_string_append_printf (_data4_->sb, "/>");
  1080.         block4_data_unref (_data4_);
  1081.         _data4_ = NULL;
  1082. }
  1083.  
  1084.  
  1085. static Block5Data* block5_data_ref (Block5Data* _data5_) {
  1086.         g_atomic_int_inc (&_data5_->_ref_count_);
  1087.         return _data5_;
  1088. }
  1089.  
  1090.  
  1091. static void block5_data_unref (Block5Data* _data5_) {
  1092.         if (g_atomic_int_dec_and_test (&_data5_->_ref_count_)) {
  1093.                 _g_object_unref0 (_data5_->rt);
  1094.                 g_slice_free (Block5Data, _data5_);
  1095.         }
  1096. }
  1097.  
  1098.  
  1099. static void _lambda2_ (GtkWidget* widget, Block5Data* _data5_) {
  1100.         GType _tmp0_;
  1101.         gboolean _tmp1_;
  1102.         g_return_if_fail (widget != NULL);
  1103.         if (_data5_->rt != NULL) {
  1104.                 return;
  1105.         }
  1106.         _tmp0_ = G_TYPE_FROM_INSTANCE ((GObject*) widget);
  1107.         _tmp1_ = g_type_is_a (_tmp0_, _data5_->type);
  1108.         if (_tmp1_) {
  1109.                 GtkWidget* _tmp2_;
  1110.                 _tmp2_ = _g_object_ref0 (widget);
  1111.                 _g_object_unref0 (_data5_->rt);
  1112.                 _data5_->rt = _tmp2_;
  1113.         } else {
  1114.                 if (GTK_IS_CONTAINER (widget)) {
  1115.                         GtkWidget* _tmp3_ = NULL;
  1116.                         _tmp3_ = menu_widget_by_type (widget, _data5_->type);
  1117.                         _g_object_unref0 (_data5_->rt);
  1118.                         _data5_->rt = _tmp3_;
  1119.                 }
  1120.         }
  1121. }
  1122.  
  1123.  
  1124. static void __lambda2__gtk_callback (GtkWidget* widget, gpointer self) {
  1125.         _lambda2_ (widget, self);
  1126. }
  1127.  
  1128.  
  1129. static GtkWidget* menu_widget_by_type (GtkWidget* parent, GType type) {
  1130.         GtkWidget* result = NULL;
  1131.         Block5Data* _data5_;
  1132.         GtkWidget* _tmp0_;
  1133.         GtkWidget* _tmp1_;
  1134.         g_return_val_if_fail (parent != NULL, NULL);
  1135.         _data5_ = g_slice_new0 (Block5Data);
  1136.         _data5_->_ref_count_ = 1;
  1137.         _data5_->type = type;
  1138.         _data5_->rt = NULL;
  1139.         _tmp0_ = parent;
  1140.         gtk_container_forall (GTK_IS_CONTAINER (_tmp0_) ? ((GtkContainer*) _tmp0_) : NULL, __lambda2__gtk_callback, _data5_);
  1141.         _tmp1_ = _g_object_ref0 (_data5_->rt);
  1142.         result = _tmp1_;
  1143.         block5_data_unref (_data5_);
  1144.         _data5_ = NULL;
  1145.         return result;
  1146. }
  1147.  
  1148.  
  1149. guint64 menu_get_xwindow (Menu* self) {
  1150.         guint64 result;
  1151.         g_return_val_if_fail (self != NULL, 0ULL);
  1152.         result = self->priv->_xwindow;
  1153.         return result;
  1154. }
  1155.  
  1156.  
  1157. static void menu_set_xwindow (Menu* self, guint64 value) {
  1158.         g_return_if_fail (self != NULL);
  1159.         self->priv->_xwindow = value;
  1160.         g_object_notify ((GObject *) self, "xwindow");
  1161. }
  1162.  
  1163.  
  1164. static void menu_class_init (MenuClass * klass) {
  1165.         menu_parent_class = g_type_class_peek_parent (klass);
  1166.         g_type_class_add_private (klass, sizeof (MenuPrivate));
  1167.         G_OBJECT_CLASS (klass)->get_property = _vala_menu_get_property;
  1168.         G_OBJECT_CLASS (klass)->set_property = _vala_menu_set_property;
  1169.         G_OBJECT_CLASS (klass)->finalize = menu_finalize;
  1170.         g_object_class_install_property (G_OBJECT_CLASS (klass), MENU_XWINDOW, g_param_spec_uint64 ("xwindow", "xwindow", "xwindow", 0, G_MAXUINT64, 0U, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
  1171. }
  1172.  
  1173.  
  1174. static void menu_instance_init (Menu * self) {
  1175.         self->priv = MENU_GET_PRIVATE (self);
  1176.         self->priv->realize_handler_id = (gulong) 0;
  1177.         self->priv->unrealize_handler_id = (gulong) 0;
  1178. }
  1179.  
  1180.  
  1181. static void menu_finalize (GObject* obj) {
  1182.         Menu * self;
  1183.         self = MENU (obj);
  1184.         _g_object_unref0 (self->priv->shell);
  1185.         G_OBJECT_CLASS (menu_parent_class)->finalize (obj);
  1186. }
  1187.  
  1188.  
  1189. GType menu_get_type (void) {
  1190.         static volatile gsize menu_type_id__volatile = 0;
  1191.         if (g_once_init_enter (&menu_type_id__volatile)) {
  1192.                 static const GTypeInfo g_define_type_info = { sizeof (MenuClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) menu_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Menu), 0, (GInstanceInitFunc) menu_instance_init, NULL };
  1193.                 GType menu_type_id;
  1194.                 menu_type_id = g_type_register_static (G_TYPE_OBJECT, "Menu", &g_define_type_info, 0);
  1195.                 g_type_set_qdata (menu_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) menu_register_object);
  1196.                 g_once_init_leave (&menu_type_id__volatile, menu_type_id);
  1197.         }
  1198.         return menu_type_id__volatile;
  1199. }
  1200.  
  1201.  
  1202. static void _vala_menu_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
  1203.         Menu * self;
  1204.         self = MENU (object);
  1205.         switch (property_id) {
  1206.                 case MENU_XWINDOW:
  1207.                 g_value_set_uint64 (value, menu_get_xwindow (self));
  1208.                 break;
  1209.                 default:
  1210.                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
  1211.                 break;
  1212.         }
  1213. }
  1214.  
  1215.  
  1216. static void _vala_menu_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
  1217.         Menu * self;
  1218.         self = MENU (object);
  1219.         switch (property_id) {
  1220.                 case MENU_XWINDOW:
  1221.                 menu_set_xwindow (self, g_value_get_uint64 (value));
  1222.                 break;
  1223.                 default:
  1224.                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
  1225.                 break;
  1226.         }
  1227. }
  1228.  
  1229.  
  1230. static void _dbus_menu_get_ui (Menu* self, GVariant* parameters, GDBusMethodInvocation* invocation) {
  1231.         GError* error = NULL;
  1232.         GVariantIter _arguments_iter;
  1233.         gchar* path = NULL;
  1234.         GVariant* _tmp0_;
  1235.         GDBusMessage* _reply_message;
  1236.         GVariant* _reply;
  1237.         GVariantBuilder _reply_builder;
  1238.         gchar* ui = NULL;
  1239.         g_variant_iter_init (&_arguments_iter, parameters);
  1240.         _tmp0_ = g_variant_iter_next_value (&_arguments_iter);
  1241.         path = g_variant_dup_string (_tmp0_, NULL);
  1242.         g_variant_unref (_tmp0_);
  1243.         menu_get_ui (self, path, &ui);
  1244.         _reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
  1245.         g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
  1246.         g_variant_builder_add_value (&_reply_builder, g_variant_new_string (ui));
  1247.         _reply = g_variant_builder_end (&_reply_builder);
  1248.         g_dbus_message_set_body (_reply_message, _reply);
  1249.         _g_free0 (path);
  1250.         _g_free0 (ui);
  1251.         g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
  1252.         g_object_unref (invocation);
  1253.         g_object_unref (_reply_message);
  1254. }
  1255.  
  1256.  
  1257. static void _dbus_menu_emit (Menu* self, GVariant* parameters, GDBusMethodInvocation* invocation) {
  1258.         GError* error = NULL;
  1259.         GVariantIter _arguments_iter;
  1260.         gchar* path = NULL;
  1261.         GVariant* _tmp1_;
  1262.         GDBusMessage* _reply_message;
  1263.         GVariant* _reply;
  1264.         GVariantBuilder _reply_builder;
  1265.         g_variant_iter_init (&_arguments_iter, parameters);
  1266.         _tmp1_ = g_variant_iter_next_value (&_arguments_iter);
  1267.         path = g_variant_dup_string (_tmp1_, NULL);
  1268.         g_variant_unref (_tmp1_);
  1269.         menu_emit (self, path);
  1270.         _reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
  1271.         g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
  1272.         _reply = g_variant_builder_end (&_reply_builder);
  1273.         g_dbus_message_set_body (_reply_message, _reply);
  1274.         _g_free0 (path);
  1275.         g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
  1276.         g_object_unref (invocation);
  1277.         g_object_unref (_reply_message);
  1278. }
  1279.  
  1280.  
  1281. static void menu_dbus_interface_method_call (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* method_name, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer user_data) {
  1282.         gpointer* data;
  1283.         gpointer object;
  1284.         data = user_data;
  1285.         object = data[0];
  1286.         if (strcmp (method_name, "GetUi") == 0) {
  1287.                 _dbus_menu_get_ui (object, parameters, invocation);
  1288.         } else if (strcmp (method_name, "Emit") == 0) {
  1289.                 _dbus_menu_emit (object, parameters, invocation);
  1290.         } else {
  1291.                 g_object_unref (invocation);
  1292.         }
  1293. }
  1294.  
  1295.  
  1296. static GVariant* _dbus_menu_get_xwindow (Menu* self) {
  1297.         guint64 result;
  1298.         GVariant* _reply;
  1299.         result = menu_get_xwindow (self);
  1300.         _reply = g_variant_new_uint64 (result);
  1301.         return _reply;
  1302. }
  1303.  
  1304.  
  1305. static GVariant* menu_dbus_interface_get_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GError** error, gpointer user_data) {
  1306.         gpointer* data;
  1307.         gpointer object;
  1308.         data = user_data;
  1309.         object = data[0];
  1310.         if (strcmp (property_name, "Xwindow") == 0) {
  1311.                 return _dbus_menu_get_xwindow (object);
  1312.         }
  1313.         return NULL;
  1314. }
  1315.  
  1316.  
  1317. static void _dbus_menu_set_xwindow (Menu* self, GVariant* _value) {
  1318.         guint64 value = 0ULL;
  1319.         value = g_variant_get_uint64 (_value);
  1320.         menu_set_xwindow (self, value);
  1321. }
  1322.  
  1323.  
  1324. static gboolean menu_dbus_interface_set_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GVariant* value, GError** error, gpointer user_data) {
  1325.         gpointer* data;
  1326.         gpointer object;
  1327.         data = user_data;
  1328.         object = data[0];
  1329.         if (strcmp (property_name, "Xwindow") == 0) {
  1330.                 _dbus_menu_set_xwindow (object, value);
  1331.                 return TRUE;
  1332.         }
  1333.         return FALSE;
  1334. }
  1335.  
  1336.  
  1337. guint menu_register_object (gpointer object, GDBusConnection* connection, const gchar* path, GError** error) {
  1338.         guint result;
  1339.         gpointer *data;
  1340.         data = g_new (gpointer, 3);
  1341.         data[0] = g_object_ref (object);
  1342.         data[1] = g_object_ref (connection);
  1343.         data[2] = g_strdup (path);
  1344.         result = g_dbus_connection_register_object (connection, path, (GDBusInterfaceInfo *) (&_menu_dbus_interface_info), &_menu_dbus_interface_vtable, data, _menu_unregister_object, error);
  1345.         if (!result) {
  1346.                 return 0;
  1347.         }
  1348.         return result;
  1349. }
  1350.  
  1351.  
  1352. static void _menu_unregister_object (gpointer user_data) {
  1353.         gpointer* data;
  1354.         data = user_data;
  1355.         g_object_unref (data[0]);
  1356.         g_object_unref (data[1]);
  1357.         g_free (data[2]);
  1358.         g_free (data);
  1359. }
  1360.  
  1361.  
  1362. void manager_add (Manager* self, const gchar* object_path, GError** error) {
  1363.         MANAGER_GET_INTERFACE (self)->add (self, object_path, error);
  1364. }
  1365.  
  1366.  
  1367. static void manager_base_init (ManagerIface * iface) {
  1368.         static gboolean initialized = FALSE;
  1369.         if (!initialized) {
  1370.                 initialized = TRUE;
  1371.         }
  1372. }
  1373.  
  1374.  
  1375. GType manager_get_type (void) {
  1376.         static volatile gsize manager_type_id__volatile = 0;
  1377.         if (g_once_init_enter (&manager_type_id__volatile)) {
  1378.                 static const GTypeInfo g_define_type_info = { sizeof (ManagerIface), (GBaseInitFunc) manager_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
  1379.                 GType manager_type_id;
  1380.                 manager_type_id = g_type_register_static (G_TYPE_INTERFACE, "Manager", &g_define_type_info, 0);
  1381.                 g_type_interface_add_prerequisite (manager_type_id, G_TYPE_OBJECT);
  1382.                 g_type_set_qdata (manager_type_id, g_quark_from_static_string ("vala-dbus-proxy-type"), (void*) manager_proxy_get_type);
  1383.                 g_type_set_qdata (manager_type_id, g_quark_from_static_string ("vala-dbus-interface-name"), "org.globalmenu.manager");
  1384.                 g_type_set_qdata (manager_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) manager_register_object);
  1385.                 g_once_init_leave (&manager_type_id__volatile, manager_type_id);
  1386.         }
  1387.         return manager_type_id__volatile;
  1388. }
  1389.  
  1390.  
  1391. G_DEFINE_TYPE_EXTENDED (ManagerProxy, manager_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT_INTERFACE (TYPE_MANAGER, manager_proxy_manager_interface_init) )
  1392. static void manager_proxy_class_init (ManagerProxyClass* klass) {
  1393.         G_DBUS_PROXY_CLASS (klass)->g_signal = manager_proxy_g_signal;
  1394. }
  1395.  
  1396.  
  1397. static void manager_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters) {
  1398. }
  1399.  
  1400.  
  1401. static void manager_proxy_init (ManagerProxy* self) {
  1402. }
  1403.  
  1404.  
  1405. static void manager_proxy_add (Manager* self, const gchar* object_path, GError** error) {
  1406.         GDBusMessage *_message;
  1407.         GVariant *_arguments;
  1408.         GVariantBuilder _arguments_builder;
  1409.         GDBusMessage *_reply_message;
  1410.         G_IO_ERROR;
  1411.         _message = g_dbus_message_new_method_call (g_dbus_proxy_get_name ((GDBusProxy *) self), g_dbus_proxy_get_object_path ((GDBusProxy *) self), "org.globalmenu.manager", "Add");
  1412.         g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE);
  1413.         g_variant_builder_add_value (&_arguments_builder, g_variant_new_string (object_path));
  1414.         _arguments = g_variant_builder_end (&_arguments_builder);
  1415.         g_dbus_message_set_body (_message, _arguments);
  1416.         _reply_message = g_dbus_connection_send_message_with_reply_sync (g_dbus_proxy_get_connection ((GDBusProxy *) self), _message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, g_dbus_proxy_get_default_timeout ((GDBusProxy *) self), NULL, NULL, error);
  1417.         g_object_unref (_message);
  1418.         if (!_reply_message) {
  1419.                 return;
  1420.         }
  1421.         if (g_dbus_message_to_gerror (_reply_message, error)) {
  1422.                 g_object_unref (_reply_message);
  1423.                 return;
  1424.         }
  1425.         g_object_unref (_reply_message);
  1426. }
  1427.  
  1428.  
  1429. static void manager_proxy_manager_interface_init (ManagerIface* iface) {
  1430.         iface->add = manager_proxy_add;
  1431. }
  1432.  
  1433.  
  1434. static void _dbus_manager_add (Manager* self, GVariant* parameters, GDBusMethodInvocation* invocation) {
  1435.         GError* error = NULL;
  1436.         GVariantIter _arguments_iter;
  1437.         gchar* object_path = NULL;
  1438.         GVariant* _tmp2_;
  1439.         GDBusMessage* _reply_message;
  1440.         GVariant* _reply;
  1441.         GVariantBuilder _reply_builder;
  1442.         g_variant_iter_init (&_arguments_iter, parameters);
  1443.         _tmp2_ = g_variant_iter_next_value (&_arguments_iter);
  1444.         object_path = g_variant_dup_string (_tmp2_, NULL);
  1445.         g_variant_unref (_tmp2_);
  1446.         manager_add (self, object_path, &error);
  1447.         if (error) {
  1448.                 g_dbus_method_invocation_return_gerror (invocation, error);
  1449.                 return;
  1450.         }
  1451.         _reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
  1452.         g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
  1453.         _reply = g_variant_builder_end (&_reply_builder);
  1454.         g_dbus_message_set_body (_reply_message, _reply);
  1455.         _g_free0 (object_path);
  1456.         g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
  1457.         g_object_unref (invocation);
  1458.         g_object_unref (_reply_message);
  1459. }
  1460.  
  1461.  
  1462. static void manager_dbus_interface_method_call (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* method_name, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer user_data) {
  1463.         gpointer* data;
  1464.         gpointer object;
  1465.         data = user_data;
  1466.         object = data[0];
  1467.         if (strcmp (method_name, "Add") == 0) {
  1468.                 _dbus_manager_add (object, parameters, invocation);
  1469.         } else {
  1470.                 g_object_unref (invocation);
  1471.         }
  1472. }
  1473.  
  1474.  
  1475. static GVariant* manager_dbus_interface_get_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GError** error, gpointer user_data) {
  1476.         gpointer* data;
  1477.         gpointer object;
  1478.         data = user_data;
  1479.         object = data[0];
  1480.         return NULL;
  1481. }
  1482.  
  1483.  
  1484. static gboolean manager_dbus_interface_set_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GVariant* value, GError** error, gpointer user_data) {
  1485.         gpointer* data;
  1486.         gpointer object;
  1487.         data = user_data;
  1488.         object = data[0];
  1489.         return FALSE;
  1490. }
  1491.  
  1492.  
  1493. guint manager_register_object (gpointer object, GDBusConnection* connection, const gchar* path, GError** error) {
  1494.         guint result;
  1495.         gpointer *data;
  1496.         data = g_new (gpointer, 3);
  1497.         data[0] = g_object_ref (object);
  1498.         data[1] = g_object_ref (connection);
  1499.         data[2] = g_strdup (path);
  1500.         result = g_dbus_connection_register_object (connection, path, (GDBusInterfaceInfo *) (&_manager_dbus_interface_info), &_manager_dbus_interface_vtable, data, _manager_unregister_object, error);
  1501.         if (!result) {
  1502.                 return 0;
  1503.         }
  1504.         return result;
  1505. }
  1506.  
  1507.  
  1508. static void _manager_unregister_object (gpointer user_data) {
  1509.         gpointer* data;
  1510.         data = user_data;
  1511.         g_object_unref (data[0]);
  1512.         g_object_unref (data[1]);
  1513.         g_free (data[2]);
  1514.         g_free (data);
  1515. }
  1516.  
  1517.  
  1518. void callback (GtkAction* action) {
  1519.         const gchar* _tmp0_ = NULL;
  1520.         g_return_if_fail (action != NULL);
  1521.         _tmp0_ = gtk_buildable_get_name ((GtkBuildable*) action);
  1522.         g_print ("widget %s called", _tmp0_);
  1523. }
  1524.  
  1525.  
  1526. static void _callback_gtk_action_callback (GtkAction* action, gpointer self) {
  1527.         callback (action);
  1528. }
  1529.  
  1530.  
  1531. void _vala_main (gchar** args, int args_length1) {
  1532.         static const char uidef[] = "\n" \
  1533. "<ui>\n" \
  1534. "  <menubar>\n" \
  1535. "    <menu name=\"FileMenu\" action=\"FileMenu\">\n" \
  1536. "      <menuitem name=\"New\" action=\"New\"/>\n" \
  1537. "      <placeholder name=\"name\" />\n" \
  1538. "    </menu>\n" \
  1539. "    <menu name=\"JustifyMenu\" action=\"JustifyMenu\">\n" \
  1540. "      <menuitem name=\"Left\" action=\"Left\"/>\n" \
  1541. "      <menuitem name=\"Centre\" action=\"Centre\"/>\n" \
  1542. "      <menuitem name=\"Right\" action=\"Right\"/>\n" \
  1543. "      <menuitem name=\"Fill\" action=\"Fill\"/>\n" \
  1544. "    </menu>\n" \
  1545. "  </menubar>\n" \
  1546. "</ui>\n" \
  1547. " ";
  1548.         static const GtkActionEntry ae[] = {{"FileMenu", NULL, "File", NULL, NULL, (GCallback) _callback_gtk_action_callback}, {"JustifyMenu", NULL, "Justify", NULL, NULL, (GCallback) _callback_gtk_action_callback}, {"New", NULL, "New", NULL, NULL, (GCallback) _callback_gtk_action_callback}, {"Left", NULL, "Left", NULL, NULL, (GCallback) _callback_gtk_action_callback}, {"Centre", NULL, "Centre", NULL, NULL, (GCallback) _callback_gtk_action_callback}, {"Right", NULL, "Right", NULL, NULL, (GCallback) _callback_gtk_action_callback}, {"Fill", NULL, "Fill", NULL, NULL, (GCallback) _callback_gtk_action_callback}};
  1549.         GtkActionGroup* _tmp0_ = NULL;
  1550.         GtkActionGroup* ag;
  1551.         GtkUIManager* _tmp1_ = NULL;
  1552.         GtkUIManager* uiman;
  1553.         gint _tmp2_;
  1554.         GtkWidget* _tmp3_ = NULL;
  1555.         GtkWidget* _tmp4_;
  1556.         GtkMenuBar* _tmp5_;
  1557.         GtkMenuBar* shell;
  1558.         GMainLoop* _tmp6_ = NULL;
  1559.         GMainLoop* _tmp7_;
  1560.         GError * _inner_error_ = NULL;
  1561.         gtk_init (&args_length1, &args);
  1562.         _tmp0_ = gtk_action_group_new ("default");
  1563.         ag = _tmp0_;
  1564.         gtk_action_group_add_actions (ag, ae, G_N_ELEMENTS (ae), NULL);
  1565.         _tmp1_ = gtk_ui_manager_new ();
  1566.         uiman = _tmp1_;
  1567.         gtk_ui_manager_insert_action_group (uiman, ag, 0);
  1568.         _tmp2_ = strlen (uidef);
  1569.         gtk_ui_manager_add_ui_from_string (uiman, uidef, (gssize) _tmp2_, &_inner_error_);
  1570.         if (_inner_error_ != NULL) {
  1571.                 _g_object_unref0 (uiman);
  1572.                 _g_object_unref0 (ag);
  1573.                 if (_inner_error_->domain == G_IO_ERROR) {
  1574.                         goto __catch3_g_io_error;
  1575.                 }
  1576.                 goto __finally3;
  1577.         }
  1578.         _tmp3_ = gtk_ui_manager_get_widget (uiman, "/menubar");
  1579.         _tmp4_ = _tmp3_;
  1580.         _tmp5_ = _g_object_ref0 (GTK_IS_MENU_BAR (_tmp4_) ? ((GtkMenuBar*) _tmp4_) : NULL);
  1581.         shell = _tmp5_;
  1582.         menu_register ((GtkMenuShell*) shell);
  1583.         _g_object_unref0 (shell);
  1584.         _g_object_unref0 (uiman);
  1585.         _g_object_unref0 (ag);
  1586.         goto __finally3;
  1587.         __catch3_g_io_error:
  1588.         {
  1589.                 GError * e;
  1590.                 e = _inner_error_;
  1591.                 _inner_error_ = NULL;
  1592.                 g_critical ("client-gtk2.vala:284: %s\n", e->message);
  1593.                 _g_error_free0 (e);
  1594.         }
  1595.         __finally3:
  1596.         if (_inner_error_ != NULL) {
  1597.                 g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
  1598.                 g_clear_error (&_inner_error_);
  1599.                 return;
  1600.         }
  1601.         _tmp6_ = g_main_loop_new (NULL, FALSE);
  1602.         _tmp7_ = _tmp6_;
  1603.         g_main_loop_run (_tmp7_);
  1604.         _g_main_loop_unref0 (_tmp7_);
  1605. }
  1606.  
  1607.  
  1608. int main (int argc, char ** argv) {
  1609.         g_type_init ();
  1610.         _vala_main (argv, argc);
  1611.         return 0;
  1612. }
  1613.  
  1614.  
  1615. static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
  1616.         if ((array != NULL) && (destroy_func != NULL)) {
  1617.                 int i;
  1618.                 for (i = 0; i < array_length; i = i + 1) {
  1619.                         if (((gpointer*) array)[i] != NULL) {
  1620.                                 destroy_func (((gpointer*) array)[i]);
  1621.                         }
  1622.                 }
  1623.         }
  1624. }
  1625.  
  1626.  
  1627. static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
  1628.         _vala_array_destroy (array, array_length, destroy_func);
  1629.         g_free (array);
  1630. }
  1631.  
  1632.  
  1633. static gint _vala_array_length (gpointer array) {
  1634.         int length;
  1635.         length = 0;
  1636.         if (array) {
  1637.                 while (((gpointer*) array)[length]) {
  1638.                         length++;
  1639.                 }
  1640.         }
  1641.         return length;
  1642. }
  1643.  
  1644.  
  1645.  
  1646.  
go to heaven