[latexila] MainWindow: rework sensitivity updates
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] MainWindow: rework sensitivity updates
- Date: Mon, 14 Aug 2017 18:23:05 +0000 (UTC)
commit 9fbba1b3820465a348a19f46234a5f1092a2f602
Author: Sébastien Wilmet <swilmet gnome org>
Date: Mon Aug 14 19:59:22 2017 +0200
MainWindow: rework sensitivity updates
This fixes a recent regression introduced by
commit bcff602c95208b167249cfd596d038583dbf7a1b:
For the build tools actions: empty notebook -> open a file -> the build
tools actions were still insensitive. This is now fixed. The
MainWindowBuildTools's update_sensitivity() function was called too
early, the active-tab property was still null.
So now, update sensitivity (and do other stuff) when the
notify::active-tab signal is sent by the TeplApplicationWindow, so we
are sure that the active-tab property has the new value.
src/main_window.vala | 61 +++++++++++++++++----------------------------
src/main_window_file.vala | 6 +++-
2 files changed, 28 insertions(+), 39 deletions(-)
---
diff --git a/src/main_window.vala b/src/main_window.vala
index 4b2c89e..db2ab4a 100644
--- a/src/main_window.vala
+++ b/src/main_window.vala
@@ -161,6 +161,17 @@ public class MainWindow : ApplicationWindow
tepl_window.notify["active-tab"].connect (() =>
{
+ update_file_actions_sensitivity ();
+ update_config_project_sensitivity ();
+ update_cursor_position_statusbar ();
+ my_set_title ();
+
+ if (this.active_tab == null)
+ {
+ _goto_line.hide ();
+ _search_and_replace.hide ();
+ }
+
this.notify_property ("active-tab");
});
@@ -186,7 +197,7 @@ public class MainWindow : ApplicationWindow
_main_window_tools = new MainWindowTools (this, _ui_manager);
show_images_in_menu ();
- set_file_actions_sensitivity (false);
+ update_file_actions_sensitivity ();
/* Main vertical grid */
@@ -465,40 +476,6 @@ public class MainWindow : ApplicationWindow
Gtk.Menu popup_menu = _ui_manager.get_widget ("/NotebookPopup") as Gtk.Menu;
popup_menu.popup (null, null, null, event.button, event.time);
});
-
- _documents_panel.page_added.connect (() =>
- {
- int nb_pages = _documents_panel.get_n_pages ();
-
- // actions for which there must be 1 document minimum
- if (nb_pages == 1)
- set_file_actions_sensitivity (true);
- });
-
- _documents_panel.page_removed.connect (() =>
- {
- int nb_pages = _documents_panel.get_n_pages ();
-
- if (nb_pages == 0)
- {
- _statusbar.set_cursor_position (-1, -1);
- set_file_actions_sensitivity (false);
- _goto_line.hide ();
- _search_and_replace.hide ();
- }
-
- my_set_title ();
- });
-
- _documents_panel.switch_page.connect ((pg, page_num) =>
- {
- _main_window_edit.update_sensitivity ();
- _main_window_build_tools.update_sensitivity ();
- _main_window_tools.update_sensitivity ();
- update_config_project_sensitivity ();
- my_set_title ();
- update_cursor_position_statusbar ();
- });
}
private BottomPanel get_bottom_panel ()
@@ -982,7 +959,10 @@ public class MainWindow : ApplicationWindow
private void update_cursor_position_statusbar ()
{
if (active_view == null)
+ {
+ _statusbar.set_cursor_position (-1, -1);
return;
+ }
TextIter iter;
active_document.get_iter_at_mark (out iter, active_document.get_insert ());
@@ -1049,9 +1029,13 @@ public class MainWindow : ApplicationWindow
/*************************************************************************/
// Sensitivity
- private void set_file_actions_sensitivity (bool sensitive)
+ private void update_file_actions_sensitivity ()
{
- // actions that must be insensitive if the notebook is empty
+ Tepl.ApplicationWindow tepl_window =
+ Tepl.ApplicationWindow.get_from_gtk_application_window (this);
+ bool sensitive = tepl_window.active_tab != null;
+
+ // Actions that must be insensitive if the notebook is empty.
string[] file_actions =
{
"ViewZoomIn",
@@ -1071,7 +1055,8 @@ public class MainWindow : ApplicationWindow
}
_latex_action_group.set_sensitive (sensitive);
- _main_window_file.update_sensitivity (sensitive);
+
+ _main_window_file.update_sensitivity ();
_main_window_edit.update_sensitivity ();
_main_window_build_tools.update_sensitivity ();
_main_window_tools.update_sensitivity ();
diff --git a/src/main_window_file.vala b/src/main_window_file.vala
index ade3c8e..b0a341f 100644
--- a/src/main_window_file.vala
+++ b/src/main_window_file.vala
@@ -115,8 +115,12 @@ public class MainWindowFile
/* Sensitivity */
- public void update_sensitivity (bool sensitive)
+ public void update_sensitivity ()
{
+ Tepl.ApplicationWindow tepl_window =
+ Tepl.ApplicationWindow.get_from_gtk_application_window (_main_window);
+ bool sensitive = tepl_window.active_tab != null;
+
string[] action_names =
{
"FileSave",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]