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.SearchBar; 20 21 private import dazzle.c.functions; 22 public import dazzle.c.types; 23 private import glib.ConstructionException; 24 private import gobject.ObjectG; 25 private import gobject.Signals; 26 private import gtk.Bin; 27 private import gtk.BuildableIF; 28 private import gtk.BuildableT; 29 private import gtk.SearchEntry; 30 private import gtk.Widget; 31 private import std.algorithm; 32 33 34 /** */ 35 public class SearchBar : Bin 36 { 37 /** the main Gtk struct */ 38 protected DzlSearchBar* dzlSearchBar; 39 40 /** Get the main Gtk struct */ 41 public DzlSearchBar* getSearchBarStruct(bool transferOwnership = false) 42 { 43 if (transferOwnership) 44 ownedRef = false; 45 return dzlSearchBar; 46 } 47 48 /** the main Gtk struct as a void* */ 49 protected override void* getStruct() 50 { 51 return cast(void*)dzlSearchBar; 52 } 53 54 /** 55 * Sets our main struct and passes it to the parent class. 56 */ 57 public this (DzlSearchBar* dzlSearchBar, bool ownedRef = false) 58 { 59 this.dzlSearchBar = dzlSearchBar; 60 super(cast(GtkBin*)dzlSearchBar, ownedRef); 61 } 62 63 64 /** */ 65 public static GType getType() 66 { 67 return dzl_search_bar_get_type(); 68 } 69 70 /** */ 71 public this() 72 { 73 auto p = dzl_search_bar_new(); 74 75 if(p is null) 76 { 77 throw new ConstructionException("null returned by new"); 78 } 79 80 this(cast(DzlSearchBar*) p); 81 } 82 83 /** 84 * Returns: A #GtkSearchEntry. 85 */ 86 public SearchEntry getEntry() 87 { 88 auto p = dzl_search_bar_get_entry(dzlSearchBar); 89 90 if(p is null) 91 { 92 return null; 93 } 94 95 return ObjectG.getDObject!(SearchEntry)(cast(GtkSearchEntry*) p); 96 } 97 98 /** */ 99 public bool getSearchModeEnabled() 100 { 101 return dzl_search_bar_get_search_mode_enabled(dzlSearchBar) != 0; 102 } 103 104 /** */ 105 public bool getShowCloseButton() 106 { 107 return dzl_search_bar_get_show_close_button(dzlSearchBar) != 0; 108 } 109 110 /** */ 111 public void setSearchModeEnabled(bool searchModeEnabled) 112 { 113 dzl_search_bar_set_search_mode_enabled(dzlSearchBar, searchModeEnabled); 114 } 115 116 /** */ 117 public void setShowCloseButton(bool showCloseButton) 118 { 119 dzl_search_bar_set_show_close_button(dzlSearchBar, showCloseButton); 120 } 121 122 /** */ 123 gulong addOnActivate(void delegate(SearchBar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 124 { 125 return Signals.connect(this, "activate", dlg, connectFlags ^ ConnectFlags.SWAPPED); 126 } 127 128 /** */ 129 gulong addOnReveal(void delegate(SearchBar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 130 { 131 return Signals.connect(this, "reveal", dlg, connectFlags ^ ConnectFlags.SWAPPED); 132 } 133 }