[latexila] Build tool dialog: edit and create a build tool
- From: SÃbastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] Build tool dialog: edit and create a build tool
- Date: Sun, 8 Jul 2012 04:23:08 +0000 (UTC)
commit fa0a2177d4acdd0c2ed1006f06058925317b503d
Author: SÃbastien Wilmet <swilmet src gnome org>
Date: Sun Jul 8 05:29:37 2012 +0200
Build tool dialog: edit and create a build tool
src/build_tool_dialog.vala | 68 ++++++++++++++++++++++++++++++++++++++
src/build_tools_preferences.vala | 26 ++++++++++----
2 files changed, 87 insertions(+), 7 deletions(-)
---
diff --git a/src/build_tool_dialog.vala b/src/build_tool_dialog.vala
index 13b0fd4..865e117 100644
--- a/src/build_tool_dialog.vala
+++ b/src/build_tool_dialog.vala
@@ -89,6 +89,14 @@ private class BuildToolDialog : Dialog
// Returns false if the user has clicked on cancel.
public static bool edit_build_tool (int build_tool_num)
{
+ return_val_if_fail (_instance != null, false);
+
+ BuildTools build_tools = BuildTools.get_default ();
+ BuildTool? build_tool = build_tools[build_tool_num];
+
+ return_val_if_fail (build_tool != null, false);
+
+ _instance.set_build_tool (build_tool);
return false;
}
@@ -96,6 +104,9 @@ private class BuildToolDialog : Dialog
// Returns false if the user has clicked on cancel.
public static bool create_build_tool ()
{
+ return_val_if_fail (_instance != null, false);
+
+ _instance.set_new_build_tool ();
return false;
}
@@ -368,6 +379,63 @@ private class BuildToolDialog : Dialog
}
/*************************************************************************/
+ // Run the dialog
+
+ private void set_new_build_tool ()
+ {
+ _entry_label.error = false;
+ _entry_label.text = "";
+ _entry_desc.text = "";
+ _entry_extensions.text = "";
+
+ _icons_combobox.set_active (0);
+
+ _jobs_store.clear ();
+ _jobs_view.columns_autosize ();
+ }
+
+ private void set_build_tool (BuildTool build_tool)
+ {
+ /* Text entries */
+
+ _entry_label.error = false;
+ _entry_label.text = build_tool.label;
+ _entry_desc.text = build_tool.description;
+ _entry_extensions.text = build_tool.extensions;
+
+ /* Icon */
+
+ _icons_combobox.set_active (0);
+
+ TreeIter iter;
+ bool ok = _icons_store.get_iter_first (out iter);
+ return_if_fail (ok);
+
+ TreeModel model = _icons_store as TreeModel;
+
+ do
+ {
+ string stock_id;
+ model.get (iter, IconColumn.STOCK_ID, out stock_id);
+
+ if (stock_id == build_tool.icon)
+ {
+ _icons_combobox.set_active_iter (iter);
+ break;
+ }
+ }
+ while (_icons_store.iter_next (ref iter));
+
+ /* Jobs */
+
+ _jobs_store.clear ();
+ foreach (BuildJob build_job in build_tool.jobs)
+ add_build_job (build_job);
+
+ _jobs_view.columns_autosize ();
+ }
+
+ /*************************************************************************/
// Misc utilities functions
private void add_build_job (BuildJob job)
diff --git a/src/build_tools_preferences.vala b/src/build_tools_preferences.vala
index 487799f..1e65024 100644
--- a/src/build_tools_preferences.vala
+++ b/src/build_tools_preferences.vala
@@ -147,8 +147,8 @@ public class BuildToolsPreferences : Grid
{
if (column == label_column)
{
- int num = path.get_indices ()[0];
- run_build_tool_dialog (num);
+ int build_tool_num = path.get_indices ()[0];
+ edit_build_tool (build_tool_num);
}
});
}
@@ -163,9 +163,10 @@ public class BuildToolsPreferences : Grid
properties_button.clicked.connect (() =>
{
- int num = Utils.get_selected_row (_tree_view);
- if (0 <= num)
- run_build_tool_dialog (num);
+ int build_tool_num = Utils.get_selected_row (_tree_view);
+
+ if (0 <= build_tool_num)
+ edit_build_tool (build_tool_num);
});
return properties_button;
@@ -207,7 +208,10 @@ public class BuildToolsPreferences : Grid
add_button.clicked.connect (() =>
{
- run_build_tool_dialog (-1);
+ show_build_tool_dialog ();
+
+ if (BuildToolDialog.create_build_tool ())
+ update_list_store ();
});
return add_button;
@@ -406,7 +410,7 @@ public class BuildToolsPreferences : Grid
}
}
- private void run_build_tool_dialog (int num)
+ private void show_build_tool_dialog ()
{
unowned Gtk.Window? window = Utils.get_toplevel_window (this);
return_if_fail (window != null);
@@ -414,6 +418,14 @@ public class BuildToolsPreferences : Grid
BuildToolDialog.show_me (window.get_transient_for ());
}
+ private void edit_build_tool (int build_tool_num)
+ {
+ show_build_tool_dialog ();
+
+ if (BuildToolDialog.edit_build_tool (build_tool_num))
+ update_list_store ();
+ }
+
// Set 'widget' as sensitive when there is a selection in the TreeView.
// If no elements are selected (this is the case by default),
// the widget is insensitive.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]