diff --git a/src/Autocompletion.vala b/src/Autocompletion.vala index d952ec9..b1c5ecf 100644 --- a/src/Autocompletion.vala +++ b/src/Autocompletion.vala @@ -45,6 +45,8 @@ public class Autocompletion : Object { tree_view.set_filter_function(filter_function); tree_view.set_sort_function(sort_function); + + tree_view.item_activated.connect((item) => item_activated(((AutocompletionEntry)item).text)); } public void save_entries_to_file(string filename) { @@ -191,6 +193,8 @@ public class Autocompletion : Object { return popup_window.visible; } + public signal void item_activated(string item); + private class AutocompletionEntry : Object { public string text { get; set; } diff --git a/src/FinalTerm.vala b/src/FinalTerm.vala index 3018d07..f590497 100644 --- a/src/FinalTerm.vala +++ b/src/FinalTerm.vala @@ -117,6 +117,8 @@ public class FinalTerm : Gtk.Application { string autocompletion_filename = data_dir.get_path() + "/commands.ftcompletion"; autocompletion = new Autocompletion(); + autocompletion.item_activated.connect((command) => + active_terminal_widget.set_shell_command(command)); if (File.new_for_path(autocompletion_filename).query_exists()) autocompletion.load_entries_from_file(autocompletion_filename); diff --git a/src/ScrollableTreeView.vala b/src/ScrollableTreeView.vala index 79baf7e..3eb7b2f 100644 --- a/src/ScrollableTreeView.vala +++ b/src/ScrollableTreeView.vala @@ -59,6 +59,14 @@ public class ScrollableTreeView : ScrolledWindow { filter = new TreeModelFilter (model, null); list = new TreeView.with_model (filter); list.headers_visible = false; + list.activate_on_single_click = true; + list.row_activated.connect ((path, column) => { + TreeIter iter; + Object val; + filter.get_iter (out iter, path); + filter.get(iter, 0, out val, -1); + item_activated(val); + }); add (list); list.insert_column_with_attributes (0, "Command", view, "data", 0); @@ -160,4 +168,6 @@ public class ScrollableTreeView : ScrolledWindow { return val; } + + public signal void item_activated (T item); } \ No newline at end of file