Browse Source

Minor cleanup of selectiondialog.*

merge-requests/365/head
eidheim 10 years ago
parent
commit
6aee69b398
  1. 13
      src/selectiondialog.cc
  2. 1
      src/selectiondialog.h
  3. 18
      src/source.cc

13
src/selectiondialog.cc

@ -31,6 +31,10 @@ ListViewText::ListViewText(bool use_markup) : Gtk::TreeView(), use_markup(use_ma
set_activate_on_single_click(true); set_activate_on_single_click(true);
set_hover_selection(false); set_hover_selection(false);
set_rules_hint(true); set_rules_hint(true);
signal_hide().connect([this]() {
list_store->clear();
});
} }
void ListViewText::append(const std::string& value) { void ListViewText::append(const std::string& value) {
@ -38,11 +42,6 @@ void ListViewText::append(const std::string& value) {
new_row->set_value(column_record.text, value); new_row->set_value(column_record.text, value);
} }
void ListViewText::hide() {
Gtk::TreeView::hide();
list_store->clear();
}
SelectionDialogBase::SelectionDialogBase(Gtk::TextView& text_view, Glib::RefPtr<Gtk::TextBuffer::Mark> start_mark, bool show_search_entry, bool use_markup): text_view(text_view), SelectionDialogBase::SelectionDialogBase(Gtk::TextView& text_view, Glib::RefPtr<Gtk::TextBuffer::Mark> start_mark, bool show_search_entry, bool use_markup): text_view(text_view),
list_view_text(use_markup), start_mark(start_mark), show_search_entry(show_search_entry) { list_view_text(use_markup), start_mark(start_mark), show_search_entry(show_search_entry) {
if(!show_search_entry) if(!show_search_entry)
@ -101,10 +100,12 @@ void SelectionDialogBase::show() {
} }
void SelectionDialogBase::hide() { void SelectionDialogBase::hide() {
if(!shown)
return;
window->hide(); window->hide();
if(tooltips) if(tooltips)
tooltips->hide(); tooltips->hide();
if(on_hide && shown) if(on_hide)
on_hide(); on_hide();
shown=false; shown=false;
} }

1
src/selectiondialog.h

@ -18,7 +18,6 @@ public:
bool use_markup; bool use_markup;
ListViewText(bool use_markup); ListViewText(bool use_markup);
void append(const std::string& value); void append(const std::string& value);
void hide();
private: private:
Glib::RefPtr<Gtk::ListStore> list_store; Glib::RefPtr<Gtk::ListStore> list_store;
ColumnRecord column_record; ColumnRecord column_record;

18
src/source.cc

@ -217,7 +217,7 @@ Source::View::View(const boost::filesystem::path &file_path, const boost::filesy
return; return;
if(mark->get_name()=="insert") { if(mark->get_name()=="insert") {
if(spellcheck_suggestions_dialog && spellcheck_suggestions_dialog->shown) if(spellcheck_suggestions_dialog)
spellcheck_suggestions_dialog->hide(); spellcheck_suggestions_dialog->hide();
delayed_spellcheck_suggestions_connection.disconnect(); delayed_spellcheck_suggestions_connection.disconnect();
delayed_spellcheck_suggestions_connection=Glib::signal_timeout().connect([this]() { delayed_spellcheck_suggestions_connection=Glib::signal_timeout().connect([this]() {
@ -429,11 +429,11 @@ void Source::View::set_tooltip_and_dialog_events() {
type_tooltips.hide(); type_tooltips.hide();
diagnostic_tooltips.hide(); diagnostic_tooltips.hide();
if(spellcheck_suggestions_dialog && spellcheck_suggestions_dialog->shown) if(spellcheck_suggestions_dialog)
spellcheck_suggestions_dialog->hide(); spellcheck_suggestions_dialog->hide();
if(autocomplete_dialog && autocomplete_dialog->shown) if(autocomplete_dialog)
autocomplete_dialog->hide(); autocomplete_dialog->hide();
if(selection_dialog && selection_dialog->shown) if(selection_dialog)
selection_dialog->hide(); selection_dialog->hide();
set_info(info); set_info(info);
@ -445,11 +445,11 @@ void Source::View::set_tooltip_and_dialog_events() {
type_tooltips.hide(); type_tooltips.hide();
diagnostic_tooltips.hide(); diagnostic_tooltips.hide();
delayed_spellcheck_suggestions_connection.disconnect(); delayed_spellcheck_suggestions_connection.disconnect();
if(spellcheck_suggestions_dialog && spellcheck_suggestions_dialog->shown) if(spellcheck_suggestions_dialog)
spellcheck_suggestions_dialog->hide(); spellcheck_suggestions_dialog->hide();
if(autocomplete_dialog && autocomplete_dialog->shown) if(autocomplete_dialog)
autocomplete_dialog->hide(); autocomplete_dialog->hide();
if(selection_dialog && selection_dialog->shown) if(selection_dialog)
selection_dialog->hide(); selection_dialog->hide();
return false; return false;
}); });
@ -459,9 +459,9 @@ void Source::View::set_tooltip_and_dialog_events() {
type_tooltips.hide(); type_tooltips.hide();
diagnostic_tooltips.hide(); diagnostic_tooltips.hide();
delayed_spellcheck_suggestions_connection.disconnect(); delayed_spellcheck_suggestions_connection.disconnect();
if(spellcheck_suggestions_dialog && spellcheck_suggestions_dialog->shown) if(spellcheck_suggestions_dialog)
spellcheck_suggestions_dialog->hide(); spellcheck_suggestions_dialog->hide();
if(autocomplete_dialog && autocomplete_dialog->shown) if(autocomplete_dialog)
autocomplete_dialog->hide(); autocomplete_dialog->hide();
return false; return false;
}); });

Loading…
Cancel
Save