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 peas.PluginManagerView; 26 27 private import glib.ConstructionException; 28 private import gobject.ObjectG; 29 private import gobject.Signals; 30 private import gtk.BuildableIF; 31 private import gtk.BuildableT; 32 private import gtk.Menu; 33 private import gtk.ScrollableIF; 34 private import gtk.ScrollableT; 35 private import gtk.TreeView; 36 private import gtk.Widget; 37 private import peas.Engine; 38 private import peas.PluginInfo; 39 private import peasc.peas; 40 public import peasc.peastypes; 41 private import std.algorithm; 42 43 44 /** 45 * The #PeasGtkPluginManagerView structure contains only private data 46 * and should only be accessed using the provided API. 47 */ 48 public class PluginManagerView : TreeView 49 { 50 /** the main Gtk struct */ 51 protected PeasGtkPluginManagerView* peasGtkPluginManagerView; 52 53 /** Get the main Gtk struct */ 54 public PeasGtkPluginManagerView* getPluginManagerViewStruct() 55 { 56 return peasGtkPluginManagerView; 57 } 58 59 /** the main Gtk struct as a void* */ 60 protected override void* getStruct() 61 { 62 return cast(void*)peasGtkPluginManagerView; 63 } 64 65 protected override void setStruct(GObject* obj) 66 { 67 peasGtkPluginManagerView = cast(PeasGtkPluginManagerView*)obj; 68 super.setStruct(obj); 69 } 70 71 /** 72 * Sets our main struct and passes it to the parent class. 73 */ 74 public this (PeasGtkPluginManagerView* peasGtkPluginManagerView, bool ownedRef = false) 75 { 76 this.peasGtkPluginManagerView = peasGtkPluginManagerView; 77 super(cast(GtkTreeView*)peasGtkPluginManagerView, ownedRef); 78 } 79 80 81 /** */ 82 public static GType getType() 83 { 84 return peas_gtk_plugin_manager_view_get_type(); 85 } 86 87 /** 88 * Creates a new plugin manager view for the given #PeasEngine. 89 * 90 * If @engine is %NULL, then the default engine will be used. 91 * 92 * Params: 93 * engine = A #PeasEngine, or %NULL. 94 * 95 * Returns: the new #PeasGtkPluginManagerView. 96 * 97 * Throws: ConstructionException GTK+ fails to create the object. 98 */ 99 public this(Engine engine) 100 { 101 auto p = peas_gtk_plugin_manager_view_new((engine is null) ? null : engine.getEngineStruct()); 102 103 if(p is null) 104 { 105 throw new ConstructionException("null returned by new"); 106 } 107 108 this(cast(PeasGtkPluginManagerView*) p); 109 } 110 111 /** 112 * Returns the currently selected plugin, or %NULL if a plugin is not selected. 113 * 114 * Returns: the selected plugin. 115 */ 116 public PluginInfo getSelectedPlugin() 117 { 118 auto p = peas_gtk_plugin_manager_view_get_selected_plugin(peasGtkPluginManagerView); 119 120 if(p is null) 121 { 122 return null; 123 } 124 125 return ObjectG.getDObject!(PluginInfo)(cast(PeasPluginInfo*) p); 126 } 127 128 /** 129 * Returns if builtin plugins should be shown. 130 * 131 * Deprecated: Use hidden plugins instead. 132 * 133 * Returns: if builtin plugins should be shown. 134 */ 135 public bool getShowBuiltin() 136 { 137 return peas_gtk_plugin_manager_view_get_show_builtin(peasGtkPluginManagerView) != 0; 138 } 139 140 /** 141 * Selects the given plugin. 142 * 143 * Params: 144 * info = A #PeasPluginInfo. 145 */ 146 public void setSelectedPlugin(PluginInfo info) 147 { 148 peas_gtk_plugin_manager_view_set_selected_plugin(peasGtkPluginManagerView, (info is null) ? null : info.getPluginInfoStruct()); 149 } 150 151 /** 152 * Sets if builtin plugins should be shown. 153 * 154 * Deprecated: Use hidden plugins instead. 155 * 156 * Params: 157 * showBuiltin = If builtin plugins should be shown. 158 */ 159 public void setShowBuiltin(bool showBuiltin) 160 { 161 peas_gtk_plugin_manager_view_set_show_builtin(peasGtkPluginManagerView, showBuiltin); 162 } 163 164 protected class OnPopulatePopupDelegateWrapper 165 { 166 static OnPopulatePopupDelegateWrapper[] listeners; 167 void delegate(Menu, PluginManagerView) dlg; 168 gulong handlerId; 169 170 this(void delegate(Menu, PluginManagerView) dlg) 171 { 172 this.dlg = dlg; 173 this.listeners ~= this; 174 } 175 176 void remove(OnPopulatePopupDelegateWrapper source) 177 { 178 foreach(index, wrapper; listeners) 179 { 180 if (wrapper.handlerId == source.handlerId) 181 { 182 listeners[index] = null; 183 listeners = std.algorithm.remove(listeners, index); 184 break; 185 } 186 } 187 } 188 } 189 190 /** 191 * The ::populate-popup signal is emitted before showing the context 192 * menu of the view. If you need to add items to the context menu, 193 * connect to this signal and add your menuitems to the @menu. 194 * 195 * Params: 196 * menu = A #GtkMenu. 197 */ 198 gulong addOnPopulatePopup(void delegate(Menu, PluginManagerView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 199 { 200 auto wrapper = new OnPopulatePopupDelegateWrapper(dlg); 201 wrapper.handlerId = Signals.connectData( 202 this, 203 "populate-popup", 204 cast(GCallback)&callBackPopulatePopup, 205 cast(void*)wrapper, 206 cast(GClosureNotify)&callBackPopulatePopupDestroy, 207 connectFlags); 208 return wrapper.handlerId; 209 } 210 211 extern(C) static void callBackPopulatePopup(PeasGtkPluginManagerView* pluginmanagerviewStruct, GtkMenu* menu, OnPopulatePopupDelegateWrapper wrapper) 212 { 213 wrapper.dlg(ObjectG.getDObject!(Menu)(menu), wrapper.outer); 214 } 215 216 extern(C) static void callBackPopulatePopupDestroy(OnPopulatePopupDelegateWrapper wrapper, GClosure* closure) 217 { 218 wrapper.remove(wrapper); 219 } 220 }