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 gio.FilenameCompleter;
26 
27 private import gio.c.functions;
28 public  import gio.c.types;
29 private import glib.ConstructionException;
30 private import glib.Str;
31 private import gobject.ObjectG;
32 private import gobject.Signals;
33 public  import gtkc.giotypes;
34 private import std.algorithm;
35 
36 
37 /**
38  * Completes partial file and directory names given a partial string by
39  * looking in the file system for clues. Can return a list of possible
40  * completion strings for widget implementations.
41  */
42 public class FilenameCompleter : ObjectG
43 {
44 	/** the main Gtk struct */
45 	protected GFilenameCompleter* gFilenameCompleter;
46 
47 	/** Get the main Gtk struct */
48 	public GFilenameCompleter* getFilenameCompleterStruct(bool transferOwnership = false)
49 	{
50 		if (transferOwnership)
51 			ownedRef = false;
52 		return gFilenameCompleter;
53 	}
54 
55 	/** the main Gtk struct as a void* */
56 	protected override void* getStruct()
57 	{
58 		return cast(void*)gFilenameCompleter;
59 	}
60 
61 	/**
62 	 * Sets our main struct and passes it to the parent class.
63 	 */
64 	public this (GFilenameCompleter* gFilenameCompleter, bool ownedRef = false)
65 	{
66 		this.gFilenameCompleter = gFilenameCompleter;
67 		super(cast(GObject*)gFilenameCompleter, ownedRef);
68 	}
69 
70 
71 	/** */
72 	public static GType getType()
73 	{
74 		return g_filename_completer_get_type();
75 	}
76 
77 	/**
78 	 * Creates a new filename completer.
79 	 *
80 	 * Returns: a #GFilenameCompleter.
81 	 *
82 	 * Throws: ConstructionException GTK+ fails to create the object.
83 	 */
84 	public this()
85 	{
86 		auto __p = g_filename_completer_new();
87 
88 		if(__p is null)
89 		{
90 			throw new ConstructionException("null returned by new");
91 		}
92 
93 		this(cast(GFilenameCompleter*) __p, true);
94 	}
95 
96 	/**
97 	 * Obtains a completion for @initial_text from @completer.
98 	 *
99 	 * Params:
100 	 *     initialText = text to be completed.
101 	 *
102 	 * Returns: a completed string, or %NULL if no completion exists.
103 	 *     This string is not owned by GIO, so remember to g_free() it
104 	 *     when finished.
105 	 */
106 	public string getCompletionSuffix(string initialText)
107 	{
108 		auto retStr = g_filename_completer_get_completion_suffix(gFilenameCompleter, Str.toStringz(initialText));
109 
110 		scope(exit) Str.freeString(retStr);
111 		return Str.toString(retStr);
112 	}
113 
114 	/**
115 	 * Gets an array of completion strings for a given initial text.
116 	 *
117 	 * Params:
118 	 *     initialText = text to be completed.
119 	 *
120 	 * Returns: array of strings with possible completions for @initial_text.
121 	 *     This array must be freed by g_strfreev() when finished.
122 	 */
123 	public string[] getCompletions(string initialText)
124 	{
125 		auto retStr = g_filename_completer_get_completions(gFilenameCompleter, Str.toStringz(initialText));
126 
127 		scope(exit) Str.freeStringArray(retStr);
128 		return Str.toStringArray(retStr);
129 	}
130 
131 	/**
132 	 * If @dirs_only is %TRUE, @completer will only
133 	 * complete directory names, and not file names.
134 	 *
135 	 * Params:
136 	 *     dirsOnly = a #gboolean.
137 	 */
138 	public void setDirsOnly(bool dirsOnly)
139 	{
140 		g_filename_completer_set_dirs_only(gFilenameCompleter, dirsOnly);
141 	}
142 
143 	/**
144 	 * Emitted when the file name completion information comes available.
145 	 */
146 	gulong addOnGotCompletionData(void delegate(FilenameCompleter) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
147 	{
148 		return Signals.connect(this, "got-completion-data", dlg, connectFlags ^ ConnectFlags.SWAPPED);
149 	}
150 }