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.PreferencesT; 20 21 public import dazzle.c.functions; 22 public import dazzle.c.types; 23 public import glib.HashTable; 24 public import glib.Str; 25 public import gobject.ObjectG; 26 public import gtk.Widget; 27 28 29 /** */ 30 public template PreferencesT(TStruct) 31 { 32 /** Get the main Gtk struct */ 33 public DzlPreferences* getPreferencesStruct(bool transferOwnership = false) 34 { 35 if (transferOwnership) 36 ownedRef = false; 37 return cast(DzlPreferences*)getStruct(); 38 } 39 40 41 /** */ 42 public uint addCustom(string pageName, string groupName, Widget widget, string keywords, int priority) 43 { 44 return dzl_preferences_add_custom(getPreferencesStruct(), Str.toStringz(pageName), Str.toStringz(groupName), (widget is null) ? null : widget.getWidgetStruct(), Str.toStringz(keywords), priority); 45 } 46 47 /** */ 48 public uint addFileChooser(string pageName, string groupName, string schemaId, string key, string path, string title, string subtitle, GtkFileChooserAction action, string keywords, int priority) 49 { 50 return dzl_preferences_add_file_chooser(getPreferencesStruct(), Str.toStringz(pageName), Str.toStringz(groupName), Str.toStringz(schemaId), Str.toStringz(key), Str.toStringz(path), Str.toStringz(title), Str.toStringz(subtitle), action, Str.toStringz(keywords), priority); 51 } 52 53 /** */ 54 public uint addFontButton(string pageName, string groupName, string schemaId, string key, string title, string keywords, int priority) 55 { 56 return dzl_preferences_add_font_button(getPreferencesStruct(), Str.toStringz(pageName), Str.toStringz(groupName), Str.toStringz(schemaId), Str.toStringz(key), Str.toStringz(title), Str.toStringz(keywords), priority); 57 } 58 59 /** */ 60 public void addGroup(string pageName, string groupName, string title, int priority) 61 { 62 dzl_preferences_add_group(getPreferencesStruct(), Str.toStringz(pageName), Str.toStringz(groupName), Str.toStringz(title), priority); 63 } 64 65 /** */ 66 public void addListGroup(string pageName, string groupName, string title, GtkSelectionMode mode, int priority) 67 { 68 dzl_preferences_add_list_group(getPreferencesStruct(), Str.toStringz(pageName), Str.toStringz(groupName), Str.toStringz(title), mode, priority); 69 } 70 71 /** */ 72 public void addPage(string pageName, string title, int priority) 73 { 74 dzl_preferences_add_page(getPreferencesStruct(), Str.toStringz(pageName), Str.toStringz(title), priority); 75 } 76 77 /** */ 78 public uint addRadio(string pageName, string groupName, string schemaId, string key, string path, string variantString, string title, string subtitle, string keywords, int priority) 79 { 80 return dzl_preferences_add_radio(getPreferencesStruct(), Str.toStringz(pageName), Str.toStringz(groupName), Str.toStringz(schemaId), Str.toStringz(key), Str.toStringz(path), Str.toStringz(variantString), Str.toStringz(title), Str.toStringz(subtitle), Str.toStringz(keywords), priority); 81 } 82 83 /** */ 84 public uint addSpinButton(string pageName, string groupName, string schemaId, string key, string path, string title, string subtitle, string keywords, int priority) 85 { 86 return dzl_preferences_add_spin_button(getPreferencesStruct(), Str.toStringz(pageName), Str.toStringz(groupName), Str.toStringz(schemaId), Str.toStringz(key), Str.toStringz(path), Str.toStringz(title), Str.toStringz(subtitle), Str.toStringz(keywords), priority); 87 } 88 89 /** */ 90 public uint addSwitch(string pageName, string groupName, string schemaId, string key, string path, string variantString, string title, string subtitle, string keywords, int priority) 91 { 92 return dzl_preferences_add_switch(getPreferencesStruct(), Str.toStringz(pageName), Str.toStringz(groupName), Str.toStringz(schemaId), Str.toStringz(key), Str.toStringz(path), Str.toStringz(variantString), Str.toStringz(title), Str.toStringz(subtitle), Str.toStringz(keywords), priority); 93 } 94 95 /** 96 * Returns: A #GtkWidget or %NULL. 97 */ 98 public Widget getWidget(uint widgetId) 99 { 100 auto p = dzl_preferences_get_widget(getPreferencesStruct(), widgetId); 101 102 if(p is null) 103 { 104 return null; 105 } 106 107 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 108 } 109 110 /** */ 111 public bool removeId(uint widgetId) 112 { 113 return dzl_preferences_remove_id(getPreferencesStruct(), widgetId) != 0; 114 } 115 116 /** */ 117 public void setPage(string pageName, HashTable map) 118 { 119 dzl_preferences_set_page(getPreferencesStruct(), Str.toStringz(pageName), (map is null) ? null : map.getHashTableStruct()); 120 } 121 }