From fa46c00e22120fe050ff0ad55ce440db73785334 Mon Sep 17 00:00:00 2001 From: eidheim Date: Fri, 15 Jan 2016 17:31:07 +0100 Subject: [PATCH] Completiondialog cleanup, and now updates tooltip when a row is selected with mouse --- src/selectiondialog.cc | 64 ++++++++++-------------------------------- 1 file changed, 15 insertions(+), 49 deletions(-) diff --git a/src/selectiondialog.cc b/src/selectiondialog.cc index 8acafd1..8ef0754 100644 --- a/src/selectiondialog.cc +++ b/src/selectiondialog.cc @@ -59,6 +59,17 @@ list_view_text(use_markup), start_mark(start_mark), show_search_entry(show_searc resize(); }); + list_view_text.signal_event_after().connect([this](GdkEvent* event){ + if(event->type==GDK_KEY_PRESS || event->type==GDK_BUTTON_PRESS) + cursor_changed(); + }); + if(show_search_entry) { + search_entry.signal_event_after().connect([this](GdkEvent* event){ + if(event->type==GDK_KEY_PRESS || event->type==GDK_BUTTON_PRESS) + cursor_changed(); + }); + } + scrolled_window.add(list_view_text); if(!show_search_entry) window->add(scrolled_window); @@ -185,7 +196,6 @@ SelectionDialog::SelectionDialog(Gtk::TextView& text_view, Glib::RefPtrchildren().size()>0) list_view_text.set_cursor(list_view_text.get_model()->get_path(list_view_text.get_model()->children().begin())); } - cursor_changed(); }); search_entry.signal_event().connect([this](GdkEvent* event) { @@ -195,14 +205,8 @@ SelectionDialog::SelectionDialog(Gtk::TextView& text_view, Glib::RefPtrget_selected(); if(it) { it++; - if(it) { + if(it) list_view_text.set_cursor(list_view_text.get_model()->get_path(it)); - cursor_changed(); - } - } - else { - list_view_text.set_cursor(list_view_text.get_model()->get_path(list_view_text.get_model()->children().begin())); - cursor_changed(); } return true; } @@ -210,18 +214,8 @@ SelectionDialog::SelectionDialog(Gtk::TextView& text_view, Glib::RefPtrget_selected(); if(it) { it--; - if(it) { + if(it) list_view_text.set_cursor(list_view_text.get_model()->get_path(it)); - cursor_changed(); - } - } - else { - auto last_it=list_view_text.get_model()->children().end(); - last_it--; - if(last_it) { - list_view_text.set_cursor(list_view_text.get_model()->get_path(last_it)); - cursor_changed(); - } } return true; } @@ -256,14 +250,8 @@ bool SelectionDialog::on_key_press(GdkEventKey* key) { auto it=list_view_text.get_selection()->get_selected(); if(it) { it++; - if(it) { + if(it) list_view_text.set_cursor(list_view_text.get_model()->get_path(it)); - cursor_changed(); - } - } - else { - list_view_text.set_cursor(list_view_text.get_model()->get_path(list_view_text.get_model()->children().begin())); - cursor_changed(); } return true; } @@ -271,18 +259,8 @@ bool SelectionDialog::on_key_press(GdkEventKey* key) { auto it=list_view_text.get_selection()->get_selected(); if(it) { it--; - if(it) { + if(it) list_view_text.set_cursor(list_view_text.get_model()->get_path(it)); - cursor_changed(); - } - } - else { - auto last_it=list_view_text.get_model()->children().end(); - last_it--; - if(last_it) { - list_view_text.set_cursor(list_view_text.get_model()->get_path(last_it)); - cursor_changed(); - } } return true; } @@ -402,10 +380,6 @@ bool CompletionDialog::on_key_press(GdkEventKey* key) { cursor_changed(); } } - else { - list_view_text.set_cursor(list_view_text.get_model()->get_path(list_view_text.get_model()->children().begin())); - cursor_changed(); - } select(false); return true; } @@ -418,14 +392,6 @@ bool CompletionDialog::on_key_press(GdkEventKey* key) { cursor_changed(); } } - else { - auto last_it=list_view_text.get_model()->children().end(); - last_it--; - if(last_it) { - list_view_text.set_cursor(list_view_text.get_model()->get_path(last_it)); - cursor_changed(); - } - } select(false); return true; }