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 glib.ConstructionException;
30 private import glib.Str;
31 private import gobject.ObjectG;
32 private import gtkc.gio;
33 public  import gtkc.giotypes;
34 
35 
36 /**
37  * #GDBusMenuModel is an implementation of #GMenuModel that can be used
38  * as a proxy for a menu model that is exported over D-Bus with
39  * g_dbus_connection_export_menu_model().
40  */
41 public class DBusMenuModel : MenuModel
42 {
43 	/** the main Gtk struct */
44 	protected GDBusMenuModel* gDBusMenuModel;
45 
46 	/** Get the main Gtk struct */
47 	public GDBusMenuModel* getDBusMenuModelStruct(bool transferOwnership = false)
48 	{
49 		if (transferOwnership)
50 			ownedRef = false;
51 		return gDBusMenuModel;
52 	}
53 
54 	/** the main Gtk struct as a void* */
55 	protected override void* getStruct()
56 	{
57 		return cast(void*)gDBusMenuModel;
58 	}
59 
60 	protected override void setStruct(GObject* obj)
61 	{
62 		gDBusMenuModel = cast(GDBusMenuModel*)obj;
63 		super.setStruct(obj);
64 	}
65 
66 	/**
67 	 * Sets our main struct and passes it to the parent class.
68 	 */
69 	public this (GDBusMenuModel* gDBusMenuModel, bool ownedRef = false)
70 	{
71 		this.gDBusMenuModel = gDBusMenuModel;
72 		super(cast(GMenuModel*)gDBusMenuModel, ownedRef);
73 	}
74 
75 	/**
76 	 * See_Also: get().
77 	 */
78 	this(DBusConnection connection, string busName, string objectPath)
79 	{
80 		auto p =  g_dbus_menu_model_get((connection is null) ? null : connection.getDBusConnectionStruct(), Str.toStringz(busName), Str.toStringz(objectPath));
81 		
82 		if(p is null)
83 		{
84 			throw new ConstructionException("null returned by g_dbus_menu_model_get");
85 		}
86 		
87 		this(cast(GDBusMenuModel*) p, true);
88 	}
89 
90 	/**
91 	 */
92 
93 	/** */
94 	public static GType getType()
95 	{
96 		return g_dbus_menu_model_get_type();
97 	}
98 
99 	/**
100 	 * Obtains a #GDBusMenuModel for the menu model which is exported
101 	 * at the given @bus_name and @object_path.
102 	 *
103 	 * The thread default main context is taken at the time of this call.
104 	 * All signals on the menu model (and any linked models) are reported
105 	 * with respect to this context.  All calls on the returned menu model
106 	 * (and linked models) must also originate from this same context, with
107 	 * the thread default main context unchanged.
108 	 *
109 	 * Params:
110 	 *     connection = a #GDBusConnection
111 	 *     busName = the bus name which exports the menu model
112 	 *     objectPath = the object path at which the menu model is exported
113 	 *
114 	 * Returns: a #GDBusMenuModel object. Free with
115 	 *     g_object_unref().
116 	 *
117 	 * Since: 2.32
118 	 */
119 	public static DBusMenuModel get(DBusConnection connection, string busName, string objectPath)
120 	{
121 		auto p = g_dbus_menu_model_get((connection is null) ? null : connection.getDBusConnectionStruct(), Str.toStringz(busName), Str.toStringz(objectPath));
122 		
123 		if(p is null)
124 		{
125 			return null;
126 		}
127 		
128 		return ObjectG.getDObject!(DBusMenuModel)(cast(GDBusMenuModel*) p, true);
129 	}
130 }