Skip to content

Commit

Permalink
Fixes p-e-w#381.
Browse files Browse the repository at this point in the history
  • Loading branch information
RedHatter committed Nov 15, 2015
1 parent 1a78519 commit 8cd6166
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Autocompletion.vala
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class Autocompletion : Object {

tree_view.set_filter_function<AutocompletionEntry>(filter_function);
tree_view.set_sort_function<AutocompletionEntry>(sort_function);

tree_view.item_activated.connect((item) => item_activated(((AutocompletionEntry)item).text));
}

public void save_entries_to_file(string filename) {
Expand Down Expand Up @@ -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; }
Expand Down
2 changes: 2 additions & 0 deletions src/FinalTerm.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions src/ScrollableTreeView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ public class ScrollableTreeView<T> : 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);

Expand Down Expand Up @@ -160,4 +168,6 @@ public class ScrollableTreeView<T> : ScrolledWindow {

return val;
}

public signal void item_activated (T item);
}

0 comments on commit 8cd6166

Please sign in to comment.