[gnote] Set initial focus without causing criticals



commit 74609f5b49a81921c0f45e73961b465032eca9a6
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Mon Jan 4 22:49:55 2021 +0200

    Set initial focus without causing criticals

 src/searchnoteswidget.cpp | 9 ++++++++-
 src/searchnoteswidget.hpp | 3 ++-
 2 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/src/searchnoteswidget.cpp b/src/searchnoteswidget.cpp
index fc1c302d..c6477b74 100644
--- a/src/searchnoteswidget.cpp
+++ b/src/searchnoteswidget.cpp
@@ -1398,7 +1398,6 @@ void SearchNotesWidget::foreground()
   }
 
   win->add_accel_group(m_accel_group);
-  win->set_focus(*m_tree);
   auto & manager(m_gnote.action_manager());
   register_callbacks();
   m_callback_changed_cid = manager.signal_main_window_search_actions_changed
@@ -1433,6 +1432,14 @@ void SearchNotesWidget::size_internals()
   }
 }
 
+void SearchNotesWidget::set_initial_focus()
+{
+  Gtk::Window *win = dynamic_cast<Gtk::Window*>(host());
+  if(win) {
+    win->set_focus(*m_tree);
+  }
+}
+
 std::vector<PopoverWidget> SearchNotesWidget::get_popover_widgets()
 {
   std::vector<PopoverWidget> popover_widgets;
diff --git a/src/searchnoteswidget.hpp b/src/searchnoteswidget.hpp
index 6437de01..9d44b93a 100644
--- a/src/searchnoteswidget.hpp
+++ b/src/searchnoteswidget.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2010-2015,2017,2019-2020 Aurimas Cernius
+ * Copyright (C) 2010-2015,2017,2019-2021 Aurimas Cernius
  * Copyright (C) 2010 Debarshi Ray
  * Copyright (C) 2009 Hubert Figuiere
  *
@@ -52,6 +52,7 @@ public:
   virtual void background() override;
   virtual void hint_size(int & width, int & height) override;
   virtual void size_internals() override;
+  virtual void set_initial_focus() override;
   virtual void perform_search(const Glib::ustring & search_text) override;
   virtual std::vector<PopoverWidget> get_popover_widgets() override;
   virtual std::vector<MainWindowAction::Ptr> get_widget_actions() override;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]