[latexila/wip/build-tools-revamp] Port BuildToolDialog to the build tools written in C
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila/wip/build-tools-revamp] Port BuildToolDialog to the build tools written in C
- Date: Wed, 7 May 2014 13:03:24 +0000 (UTC)
commit bb6a17368e44fb81ac19b1790f16e83fc268cdd2
Author: Sébastien Wilmet <swilmet gnome org>
Date: Wed May 7 14:48:20 2014 +0200
Port BuildToolDialog to the build tools written in C
src/build_tool_dialog.vala | 48 ++++++++++++++++++--------------
src/liblatexila/latexila-build-tools.c | 21 ++++++++++++++
src/liblatexila/latexila-build-tools.h | 3 ++
3 files changed, 51 insertions(+), 21 deletions(-)
---
diff --git a/src/build_tool_dialog.vala b/src/build_tool_dialog.vala
index 28ebc21..49c265e 100644
--- a/src/build_tool_dialog.vala
+++ b/src/build_tool_dialog.vala
@@ -1,7 +1,7 @@
/*
* This file is part of LaTeXila.
*
- * Copyright © 2010-2012 Sébastien Wilmet
+ * Copyright © 2010-2012, 2014 Sébastien Wilmet
*
* LaTeXila is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -89,12 +89,12 @@ public class BuildToolDialog : GLib.Object
}
// Returns true if the build tool is edited.
- public bool open_build_tool (BuildTools build_tools, int build_tool_num)
+ public bool open_build_tool (Latexila.BuildTools build_tools, int build_tool_num)
{
- BuildTool? build_tool = build_tools.get_build_tool (build_tool_num);
+ Latexila.BuildTool? build_tool = build_tools.nth (build_tool_num);
return_val_if_fail (build_tool != null, false);
- if (build_tools is DefaultBuildTools)
+ if (build_tools is Latexila.BuildToolsDefault)
set_read_only ();
else
set_editable ();
@@ -105,11 +105,12 @@ public class BuildToolDialog : GLib.Object
if (ok)
{
- BuildTool new_build_tool = retrieve_build_tool ();
+ Latexila.BuildTool new_build_tool = retrieve_build_tool ();
new_build_tool.enabled = build_tool.enabled;
- PersonalBuildTools personal_build_tools = build_tools as PersonalBuildTools;
- personal_build_tools.update (build_tool_num, new_build_tool);
+ Latexila.BuildToolsPersonal personal_build_tools =
+ build_tools as Latexila.BuildToolsPersonal;
+ personal_build_tools.replace (new_build_tool, build_tool_num);
}
_dialog.destroy ();
@@ -127,10 +128,11 @@ public class BuildToolDialog : GLib.Object
if (ok)
{
- BuildTool new_build_tool = retrieve_build_tool ();
+ Latexila.BuildTool new_build_tool = retrieve_build_tool ();
new_build_tool.enabled = true;
- PersonalBuildTools build_tools = PersonalBuildTools.get_default ();
+ Latexila.BuildToolsPersonal build_tools =
+ Latexila.BuildToolsPersonal.get_instance ();
build_tools.add (new_build_tool);
}
@@ -426,7 +428,7 @@ public class BuildToolDialog : GLib.Object
_jobs_view.columns_autosize ();
}
- private void set_build_tool (BuildTool build_tool)
+ private void set_build_tool (Latexila.BuildTool build_tool)
{
/* Text entries */
@@ -461,21 +463,21 @@ public class BuildToolDialog : GLib.Object
/* Jobs */
_jobs_store.clear ();
- foreach (BuildJob build_job in build_tool.jobs)
+ foreach (Latexila.BuildJob build_job in build_tool.get_jobs ())
add_build_job (build_job);
_jobs_view.columns_autosize ();
}
// Retrieve the build tool from the data stored in the main widgets of the dialog.
- private BuildTool retrieve_build_tool ()
+ private Latexila.BuildTool retrieve_build_tool ()
{
- BuildTool tool = BuildTool ();
+ Latexila.BuildTool tool = new Latexila.BuildTool ();
/* Text entries */
tool.label = _entry_label.text.strip ();
- tool.set_description (_entry_desc.text.strip ());
+ tool.description = _entry_desc.text.strip ();
tool.extensions = _entry_extensions.text.strip ();
tool.files_to_open = _entry_files_to_open.text.strip ();
@@ -484,7 +486,9 @@ public class BuildToolDialog : GLib.Object
TreeIter iter;
_icons_combobox.get_active_iter (out iter);
TreeModel model = _icons_store as TreeModel;
- model.get (iter, IconColumn.STOCK_ID, out tool.icon);
+ string icon;
+ model.get (iter, IconColumn.STOCK_ID, out icon);
+ tool.icon = icon;
/* Jobs */
@@ -493,7 +497,7 @@ public class BuildToolDialog : GLib.Object
while (valid)
{
- BuildJob job = BuildJob ();
+ Latexila.BuildJob job = new Latexila.BuildJob ();
string command;
string post_processor_name;
@@ -503,10 +507,12 @@ public class BuildToolDialog : GLib.Object
);
job.command = command.strip ();
- job.post_processor = BuildTools.get_post_processor_type_from_name (
- post_processor_name);
- tool.jobs.add (job);
+ Latexila.PostProcessorType type;
+ if (Latexila.PostProcessor.get_type_from_name (post_processor_name, out type))
+ job.post_processor_type = type;
+
+ tool.add_job (job);
valid = _jobs_store.iter_next (ref iter);
}
@@ -517,10 +523,10 @@ public class BuildToolDialog : GLib.Object
/*************************************************************************/
// Misc utilities functions
- private void add_build_job (BuildJob job)
+ private void add_build_job (Latexila.BuildJob job)
{
string post_processor_name =
- BuildTools.get_post_processor_name_from_type (job.post_processor);
+ Latexila.PostProcessor.get_name_from_type (job.post_processor_type);
TreeIter iter;
_jobs_store.append (out iter);
diff --git a/src/liblatexila/latexila-build-tools.c b/src/liblatexila/latexila-build-tools.c
index 3e02f20..4daa0d6 100644
--- a/src/liblatexila/latexila-build-tools.c
+++ b/src/liblatexila/latexila-build-tools.c
@@ -405,6 +405,27 @@ latexila_build_tools_load (LatexilaBuildTools *build_tools,
}
/**
+ * latexila_build_tools_nth:
+ * @build_tools: a #LatexilaBuildTools object.
+ * @tool_num: the build tool position in the list.
+ *
+ * Returns: (transfer none): the #LatexilaBuildTool located at @tool_num.
+ */
+LatexilaBuildTool *
+latexila_build_tools_nth (LatexilaBuildTools *build_tools,
+ guint tool_num)
+{
+ LatexilaBuildTool *build_tool;
+
+ g_return_val_if_fail (LATEXILA_IS_BUILD_TOOLS (build_tools), NULL);
+
+ build_tool = g_list_nth_data (build_tools->build_tools, tool_num);
+ g_return_val_if_fail (build_tool != NULL, NULL);
+
+ return build_tool;
+}
+
+/**
* latexila_build_tools_set_enabled:
* @build_tools: a #LatexilaBuildTools object.
* @tool_num: the build tool position in the list.
diff --git a/src/liblatexila/latexila-build-tools.h b/src/liblatexila/latexila-build-tools.h
index 0a9c7be..b5e632a 100644
--- a/src/liblatexila/latexila-build-tools.h
+++ b/src/liblatexila/latexila-build-tools.h
@@ -62,6 +62,9 @@ GType latexila_build_tools_get_type (void) G_GNU
void latexila_build_tools_load (LatexilaBuildTools *build_tools,
GFile *xml_file);
+LatexilaBuildTool * latexila_build_tools_nth (LatexilaBuildTools *build_tools,
+ guint tool_num);
+
void latexila_build_tools_set_enabled (LatexilaBuildTools *build_tools,
guint tool_num,
gboolean enabled);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]