Commit e4d3dac9 authored by Aurimas Černius's avatar Aurimas Černius

Make --search always show main window in search mode

Fixes Bug 769906.
parent 4e202fc3
/*
* gnote
*
* Copyright (C) 2011-2014 Aurimas Cernius
* Copyright (C) 2011-2014,2016 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
......@@ -137,7 +137,7 @@ namespace gnote {
void RemoteControl::DisplaySearch()
{
IGnote::obj().open_search_all();
IGnote::obj().open_search_all().present();
}
......
......@@ -380,11 +380,46 @@ namespace gnote {
return new_main_window();
}
void Gnote::open_search_all()
MainWindow & Gnote::open_search_all()
{
MainWindow & main_window = get_main_window();
main_window.present_search();
main_window.present();
// if active window is search, just show it
MainWindow *rc = get_active_window();
if(rc) {
if(rc->is_search()) {
return *rc;
}
}
// present already open search window, if there is one
std::vector<Gtk::Window*> windows = Gtk::Window::list_toplevels();
int main_windows = 0;
for(std::vector<Gtk::Window*>::iterator iter = windows.begin();
iter != windows.end(); ++iter) {
auto win = dynamic_cast<MainWindow*>(*iter);
if(win) {
++main_windows;
if(win->is_search()) {
return *win;
}
else if(rc == NULL) {
rc = win;
}
}
}
// if notes are opened in new window by default, then open new window for search
// otherwise switch the only window to search
// if there is more than one window open, open new for search, since we can't decide which one to switch
bool new_window = Preferences::obj()
.get_schema_settings(Preferences::SCHEMA_GNOTE)->get_boolean(Preferences::OPEN_NOTES_IN_NEW_WINDOW);
if(main_windows > 1 || new_window) {
MainWindow & main_window = new_main_window();
main_window.present_search();
return main_window;
}
rc->present_search();
return *rc;
}
void Gnote::open_note_sync_window(const Glib::VariantBase&)
......
......@@ -126,7 +126,7 @@ public:
virtual MainWindow & new_main_window() override;
virtual MainWindow & get_main_window() override;
virtual MainWindow & get_window_for_note() override;
virtual void open_search_all() override;
virtual MainWindow & open_search_all() override;
void open_note_sync_window(const Glib::VariantBase&);
bool is_background() const
......
/*
* gnote
*
* Copyright (C) 2013 Aurimas Cernius
* Copyright (C) 2013,2016 Aurimas Cernius
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -39,7 +39,7 @@ public:
virtual MainWindow & get_window_for_note() = 0;
virtual MainWindow & new_main_window() = 0;
virtual void open_note(const Note::Ptr & note) = 0;
virtual void open_search_all() = 0;
virtual MainWindow & open_search_all() = 0;
sigc::signal<void> signal_quit;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment