[latexila] Build Tools: 'modified' signal
- From: SÃbastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] Build Tools: 'modified' signal
- Date: Sun, 8 Jul 2012 22:15:30 +0000 (UTC)
commit ce0b74d1694946ebfe6ee1f96f605a579117c1b2
Author: SÃbastien Wilmet <swilmet src gnome org>
Date: Mon Jul 9 00:14:41 2012 +0200
Build Tools: 'modified' signal
src/build_tools.vala | 25 +++++++++----------------
src/main_window.vala | 3 +++
2 files changed, 12 insertions(+), 16 deletions(-)
---
diff --git a/src/build_tools.vala b/src/build_tools.vala
index 1cc7e27..8d12acd 100644
--- a/src/build_tools.vala
+++ b/src/build_tools.vala
@@ -67,12 +67,16 @@ public class BuildTools : GLib.Object
private BuildTool _cur_tool;
private BuildJob _cur_job;
+ public signal void modified ();
+
// Singleton
private BuildTools ()
{
int nb_post_processors = PostProcessorType.N_POST_PROCESSORS;
return_if_fail (_post_processor_names.length == nb_post_processors);
+ modified.connect (() => _modified = true);
+
load ();
}
@@ -118,7 +122,7 @@ public class BuildTools : GLib.Object
BuildTool tool = _build_tools[num1];
_build_tools.remove_at (num1);
_build_tools.insert (num2, tool);
- update_all_menus ();
+ modified ();
}
public void delete (int num)
@@ -126,7 +130,7 @@ public class BuildTools : GLib.Object
return_if_fail (0 <= num && num < _build_tools.size);
_build_tools.remove_at (num);
- update_all_menus ();
+ modified ();
}
public void add (BuildTool tool)
@@ -140,7 +144,7 @@ public class BuildTools : GLib.Object
tool.compilation = is_compilation (tool.icon);
_build_tools.insert (pos, tool);
- update_all_menus ();
+ modified ();
}
public void update (int num, BuildTool tool)
@@ -154,7 +158,7 @@ public class BuildTools : GLib.Object
tool.compilation = is_compilation (tool.icon);
_build_tools.remove_at (num);
_build_tools.insert (num, tool);
- update_all_menus ();
+ modified ();
}
}
@@ -165,7 +169,7 @@ public class BuildTools : GLib.Object
Utils.delete_file (file);
load ();
- update_all_menus ();
+ modified ();
}
private bool is_equal (BuildTool tool1, BuildTool tool2)
@@ -195,17 +199,6 @@ public class BuildTools : GLib.Object
return true;
}
- // TODO emit a signal instead
- private void update_all_menus ()
- {
- _modified = true;
- foreach (Gtk.Window window in Latexila.get_instance ().get_windows ())
- {
- MainWindow main_window = window as MainWindow;
- main_window.update_build_tools_menu ();
- }
- }
-
// TODO rewrite this, based on the job's commands.
// Or simply assume that all the _build_ tools are compilation, since gtk_show_uri()
// will be used for the other tools, anyway.
diff --git a/src/main_window.vala b/src/main_window.vala
index 43e006f..51106dd 100644
--- a/src/main_window.vala
+++ b/src/main_window.vala
@@ -618,6 +618,9 @@ public class MainWindow : Window
build_tools_action_group = new Gtk.ActionGroup ("BuildToolsActions");
ui_manager.insert_action_group (build_tools_action_group, 0);
update_build_tools_menu ();
+
+ BuildTools build_tools = BuildTools.get_default ();
+ build_tools.modified.connect (() => update_build_tools_menu ());
}
private void on_menu_item_select (Gtk.MenuItem proxy)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]