1 /* 2 * This file is part of d-dazzle. 3 * 4 * d-dazzle 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 * d-dazzle 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 d-dazzle; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 module dazzle.ShortcutModel; 20 21 private import dazzle.ShortcutChord; 22 private import dazzle.ShortcutManager; 23 private import dazzle.ShortcutTheme; 24 private import dazzle.c.functions; 25 public import dazzle.c.types; 26 private import glib.ConstructionException; 27 private import gobject.ObjectG; 28 private import gtk.BuildableIF; 29 private import gtk.BuildableT; 30 private import gtk.TreeDragDestIF; 31 private import gtk.TreeDragDestT; 32 private import gtk.TreeDragSourceIF; 33 private import gtk.TreeDragSourceT; 34 private import gtk.TreeIter; 35 private import gtk.TreeModelIF; 36 private import gtk.TreeModelT; 37 private import gtk.TreeSortableIF; 38 private import gtk.TreeSortableT; 39 private import gtk.TreeStore; 40 41 42 /** */ 43 public class ShortcutModel : TreeStore 44 { 45 /** the main Gtk struct */ 46 protected DzlShortcutModel* dzlShortcutModel; 47 48 /** Get the main Gtk struct */ 49 public DzlShortcutModel* getShortcutModelStruct(bool transferOwnership = false) 50 { 51 if (transferOwnership) 52 ownedRef = false; 53 return dzlShortcutModel; 54 } 55 56 /** the main Gtk struct as a void* */ 57 protected override void* getStruct() 58 { 59 return cast(void*)dzlShortcutModel; 60 } 61 62 /** 63 * Sets our main struct and passes it to the parent class. 64 */ 65 public this (DzlShortcutModel* dzlShortcutModel, bool ownedRef = false) 66 { 67 this.dzlShortcutModel = dzlShortcutModel; 68 super(cast(GtkTreeStore*)dzlShortcutModel, ownedRef); 69 } 70 71 72 /** */ 73 public static GType getType() 74 { 75 return dzl_shortcut_model_get_type(); 76 } 77 78 /** 79 * Returns: A #GtkTreeModel 80 * 81 * Throws: ConstructionException GTK+ fails to create the object. 82 */ 83 public this() 84 { 85 auto p = dzl_shortcut_model_new(); 86 87 if(p is null) 88 { 89 throw new ConstructionException("null returned by new"); 90 } 91 92 this(cast(DzlShortcutModel*) p, true); 93 } 94 95 /** 96 * Gets the manager to be edited. 97 * 98 * Returns: A #DzlShortcutManager 99 */ 100 public ShortcutManager getManager() 101 { 102 auto p = dzl_shortcut_model_get_manager(dzlShortcutModel); 103 104 if(p is null) 105 { 106 return null; 107 } 108 109 return ObjectG.getDObject!(ShortcutManager)(cast(DzlShortcutManager*) p); 110 } 111 112 /** 113 * Get the theme to be edited. 114 * 115 * Returns: A #DzlShortcutTheme 116 */ 117 public ShortcutTheme getTheme() 118 { 119 auto p = dzl_shortcut_model_get_theme(dzlShortcutModel); 120 121 if(p is null) 122 { 123 return null; 124 } 125 126 return ObjectG.getDObject!(ShortcutTheme)(cast(DzlShortcutTheme*) p); 127 } 128 129 /** */ 130 public void rebuild() 131 { 132 dzl_shortcut_model_rebuild(dzlShortcutModel); 133 } 134 135 /** */ 136 public void setChord(TreeIter iter, ShortcutChord chord) 137 { 138 dzl_shortcut_model_set_chord(dzlShortcutModel, (iter is null) ? null : iter.getTreeIterStruct(), (chord is null) ? null : chord.getShortcutChordStruct()); 139 } 140 141 /** */ 142 public void setManager(ShortcutManager manager) 143 { 144 dzl_shortcut_model_set_manager(dzlShortcutModel, (manager is null) ? null : manager.getShortcutManagerStruct()); 145 } 146 147 /** */ 148 public void setTheme(ShortcutTheme theme) 149 { 150 dzl_shortcut_model_set_theme(dzlShortcutModel, (theme is null) ? null : theme.getShortcutThemeStruct()); 151 } 152 }