1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gio.DBusMenuModel;
26 
27 private import gio.DBusConnection;
28 private import gio.MenuModel;
29 private import gio.c.functions;
30 public  import gio.c.types;
31 private import glib.ConstructionException;
32 private import glib.Str;
33 private import gobject.ObjectG;
34 public  import gtkc.giotypes;
35 
36 
37 /**
38  * #GDBusMenuModel is an implementation of #GMenuModel that can be used
39  * as a proxy for a menu model that is exported over D-Bus with
40  * g_dbus_connection_export_menu_model().
41  */
42 public class DBusMenuModel : MenuModel
43 {
44 	/** the main Gtk struct */
45 	protected GDBusMenuModel* gDBusMenuModel;
46 
47 	/** Get the main Gtk struct */
48 	public GDBusMenuModel* getDBusMenuModelStruct(bool transferOwnership = false)
49 	{
50 		if (transferOwnership)
51 			ownedRef = false;
52 		return gDBusMenuModel;
53 	}
54 
55 	/** the main Gtk struct as a void* */
56 	protected override void* getStruct()
57 	{
58 		return cast(void*)gDBusMenuModel;
59 	}
60 
61 	protected override void setStruct(GObject* obj)
62 	{
63 		gDBusMenuModel = cast(GDBusMenuModel*)obj;
64 		super.setStruct(obj);
65 	}
66 
67 	/**
68 	 * Sets our main struct and passes it to the parent class.
69 	 */
70 	public this (GDBusMenuModel* gDBusMenuModel, bool ownedRef = false)
71 	{
72 		this.gDBusMenuModel = gDBusMenuModel;
73 		super(cast(GMenuModel*)gDBusMenuModel, ownedRef);
74 	}
75 
76 	/**
77 	 * See_Also: get().
78 	 */
79 	this(DBusConnection connection, string busName, string objectPath)
80 	{
81 		auto p =  g_dbus_menu_model_get((connection is null) ? null : connection.getDBusConnectionStruct(), Str.toStringz(busName), Str.toStringz(objectPath));
82 
83 		if(p is null)
84 		{
85 			throw new ConstructionException("null returned by g_dbus_menu_model_get");
86 		}
87 
88 		this(cast(GDBusMenuModel*) p, true);
89 	}
90 
91 	/**
92 	 */
93 
94 	/** */
95 	public static GType getType()
96 	{
97 		return g_dbus_menu_model_get_type();
98 	}
99 
100 	/**
101 	 * Obtains a #GDBusMenuModel for the menu model which is exported
102 	 * at the given @bus_name and @object_path.
103 	 *
104 	 * The thread default main context is taken at the time of this call.
105 	 * All signals on the menu model (and any linked models) are reported
106 	 * with respect to this context.  All calls on the returned menu model
107 	 * (and linked models) must also originate from this same context, with
108 	 * the thread default main context unchanged.
109 	 *
110 	 * Params:
111 	 *     connection = a #GDBusConnection
112 	 *     busName = the bus name which exports the menu model
113 	 *     objectPath = the object path at which the menu model is exported
114 	 *
115 	 * Returns: a #GDBusMenuModel object. Free with
116 	 *     g_object_unref().
117 	 *
118 	 * Since: 2.32
119 	 */
120 	public static DBusMenuModel get(DBusConnection connection, string busName, string objectPath)
121 	{
122 		auto p = g_dbus_menu_model_get((connection is null) ? null : connection.getDBusConnectionStruct(), Str.toStringz(busName), Str.toStringz(objectPath));
123 
124 		if(p is null)
125 		{
126 			return null;
127 		}
128 
129 		return ObjectG.getDObject!(DBusMenuModel)(cast(GDBusMenuModel*) p, true);
130 	}
131 }