1 module webkit2.BackForwardList; 2 3 private import glib.ListG; 4 private import gobject.ObjectG; 5 private import gobject.Signals; 6 private import std.algorithm; 7 private import webkit2.BackForwardListItem; 8 private import webkit2.c.functions; 9 public import webkit2.c.types; 10 11 12 /** 13 * WebKitBackForwardList maintains a list of visited pages used to 14 * navigate to recent pages. Items are inserted in the list in the 15 * order they are visited. 16 * 17 * WebKitBackForwardList also maintains the notion of the current item 18 * (which is always at index 0), the preceding item (which is at index -1), 19 * and the following item (which is at index 1). 20 * Methods webkit_web_view_go_back() and webkit_web_view_go_forward() move 21 * the current item backward or forward by one. Method 22 * webkit_web_view_go_to_back_forward_list_item() sets the current item to the 23 * specified item. All other methods returning #WebKitBackForwardListItem<!-- -->s 24 * do not change the value of the current item, they just return the requested 25 * item or items. 26 */ 27 public class BackForwardList : ObjectG 28 { 29 /** the main Gtk struct */ 30 protected WebKitBackForwardList* webKitBackForwardList; 31 32 /** Get the main Gtk struct */ 33 public WebKitBackForwardList* getBackForwardListStruct(bool transferOwnership = false) 34 { 35 if (transferOwnership) 36 ownedRef = false; 37 return webKitBackForwardList; 38 } 39 40 /** the main Gtk struct as a void* */ 41 protected override void* getStruct() 42 { 43 return cast(void*)webKitBackForwardList; 44 } 45 46 /** 47 * Sets our main struct and passes it to the parent class. 48 */ 49 public this (WebKitBackForwardList* webKitBackForwardList, bool ownedRef = false) 50 { 51 this.webKitBackForwardList = webKitBackForwardList; 52 super(cast(GObject*)webKitBackForwardList, ownedRef); 53 } 54 55 56 /** */ 57 public static GType getType() 58 { 59 return webkit_back_forward_list_get_type(); 60 } 61 62 /** 63 * Returns the item that precedes the current item. 64 * 65 * Returns: the #WebKitBackForwardListItem 66 * preceding the current item or %NULL. 67 */ 68 public BackForwardListItem getBackItem() 69 { 70 auto __p = webkit_back_forward_list_get_back_item(webKitBackForwardList); 71 72 if(__p is null) 73 { 74 return null; 75 } 76 77 return ObjectG.getDObject!(BackForwardListItem)(cast(WebKitBackForwardListItem*) __p); 78 } 79 80 /** 81 * Returns: a #GList of 82 * items preceding the current item. 83 */ 84 public ListG getBackList() 85 { 86 auto __p = webkit_back_forward_list_get_back_list(webKitBackForwardList); 87 88 if(__p is null) 89 { 90 return null; 91 } 92 93 return new ListG(cast(GList*) __p); 94 } 95 96 /** 97 * 98 * Params: 99 * limit = the number of items to retrieve 100 * Returns: a #GList of 101 * items preceding the current item limited by @limit. 102 */ 103 public ListG getBackListWithLimit(uint limit) 104 { 105 auto __p = webkit_back_forward_list_get_back_list_with_limit(webKitBackForwardList, limit); 106 107 if(__p is null) 108 { 109 return null; 110 } 111 112 return new ListG(cast(GList*) __p); 113 } 114 115 /** 116 * Returns the current item in @back_forward_list. 117 * 118 * Returns: a #WebKitBackForwardListItem 119 * or %NULL if @back_forward_list is empty. 120 */ 121 public BackForwardListItem getCurrentItem() 122 { 123 auto __p = webkit_back_forward_list_get_current_item(webKitBackForwardList); 124 125 if(__p is null) 126 { 127 return null; 128 } 129 130 return ObjectG.getDObject!(BackForwardListItem)(cast(WebKitBackForwardListItem*) __p); 131 } 132 133 /** 134 * Returns the item that follows the current item. 135 * 136 * Returns: the #WebKitBackForwardListItem 137 * following the current item or %NULL. 138 */ 139 public BackForwardListItem getForwardItem() 140 { 141 auto __p = webkit_back_forward_list_get_forward_item(webKitBackForwardList); 142 143 if(__p is null) 144 { 145 return null; 146 } 147 148 return ObjectG.getDObject!(BackForwardListItem)(cast(WebKitBackForwardListItem*) __p); 149 } 150 151 /** 152 * Returns: a #GList of 153 * items following the current item. 154 */ 155 public ListG getForwardList() 156 { 157 auto __p = webkit_back_forward_list_get_forward_list(webKitBackForwardList); 158 159 if(__p is null) 160 { 161 return null; 162 } 163 164 return new ListG(cast(GList*) __p); 165 } 166 167 /** 168 * 169 * Params: 170 * limit = the number of items to retrieve 171 * Returns: a #GList of 172 * items following the current item limited by @limit. 173 */ 174 public ListG getForwardListWithLimit(uint limit) 175 { 176 auto __p = webkit_back_forward_list_get_forward_list_with_limit(webKitBackForwardList, limit); 177 178 if(__p is null) 179 { 180 return null; 181 } 182 183 return new ListG(cast(GList*) __p); 184 } 185 186 /** 187 * Returns: the length of @back_forward_list. 188 */ 189 public uint getLength() 190 { 191 return webkit_back_forward_list_get_length(webKitBackForwardList); 192 } 193 194 /** 195 * Returns the item at a given index relative to the current item. 196 * 197 * Params: 198 * index = the index of the item 199 * 200 * Returns: the #WebKitBackForwardListItem 201 * located at the specified index relative to the current item or %NULL. 202 */ 203 public BackForwardListItem getNthItem(int index) 204 { 205 auto __p = webkit_back_forward_list_get_nth_item(webKitBackForwardList, index); 206 207 if(__p is null) 208 { 209 return null; 210 } 211 212 return ObjectG.getDObject!(BackForwardListItem)(cast(WebKitBackForwardListItem*) __p); 213 } 214 215 /** 216 * This signal is emitted when @back_forward_list changes. This happens 217 * when the current item is updated, a new item is added or one or more 218 * items are removed. Note that both @item_added and @items_removed can 219 * %NULL when only the current item is updated. Items are only removed 220 * when the list is cleared or the maximum items limit is reached. 221 * 222 * Params: 223 * itemAdded = the #WebKitBackForwardListItem added or %NULL 224 * itemsRemoved = a #GList of #WebKitBackForwardListItem<!-- -->s 225 */ 226 gulong addOnChanged(void delegate(BackForwardListItem, void*, BackForwardList) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 227 { 228 return Signals.connect(this, "changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 229 } 230 }