[latexila] Structure: new item type: image (\includegraphics)
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] Structure: new item type: image (\includegraphics)
- Date: Mon, 13 Jun 2011 01:17:45 +0000 (UTC)
commit c0b09334ca8ef2fd0316588999c6a3bd52c6a7a7
Author: Sébastien Wilmet <swilmet src gnome org>
Date: Mon Jun 13 01:49:42 2011 +0200
Structure: new item type: image (\includegraphics)
TODO | 2 --
src/document_structure.vala | 7 ++++++-
src/structure.vala | 7 +++++--
src/structure_model.vala | 20 +++++++++++++++++++-
4 files changed, 30 insertions(+), 6 deletions(-)
---
diff --git a/TODO b/TODO
index 078c950..0ef6217 100644
--- a/TODO
+++ b/TODO
@@ -7,8 +7,6 @@ LaTeXila 2.2
============
- Structure (list of chapters, sections, etc. to easily navigate in a document):
- - New item type: graphic file (\includegraphics)
-
- Figure and Table env:
- items between start_mark and end_mark of the env: children
diff --git a/src/document_structure.vala b/src/document_structure.vala
index 46b8e02..d83ae67 100644
--- a/src/document_structure.vala
+++ b/src/document_structure.vala
@@ -61,7 +61,9 @@ public class DocumentStructure : GLib.Object
_comment_regex =
new Regex ("^(?P<type>TODO|FIXME)[[:space:]:]*(?P<text>.*)$");
- _command_name_regex = new Regex ("^(?P<name>[a-z]+\\*?)[[:space:]]*{");
+ // the LaTeX command can contain some optional arguments
+ _command_name_regex =
+ new Regex ("^(?P<name>[a-z]+\\*?)[[:space:]]*(\\[[^\\]]*\\][[:space:]]*)*{");
}
catch (RegexError e)
{
@@ -467,6 +469,9 @@ public class DocumentStructure : GLib.Object
case "include":
return StructType.INCLUDE;
+ case "includegraphics":
+ return StructType.IMAGE;
+
default:
return null;
}
diff --git a/src/structure.vala b/src/structure.vala
index 30ab649..bd6406b 100644
--- a/src/structure.vala
+++ b/src/structure.vala
@@ -32,6 +32,7 @@ public enum StructType
INCLUDE,
TABLE,
FIGURE,
+ IMAGE,
TODO,
FIXME,
N_TYPES
@@ -140,8 +141,8 @@ public class Structure : VBox
_("Show tables"));
hbox.pack_start (toggle_button);
- toggle_button = create_simple_list_button ({ StructType.FIGURE },
- _("Show figures"));
+ toggle_button = create_simple_list_button (
+ { StructType.FIGURE, StructType.IMAGE }, _("Show figures and images"));
hbox.pack_start (toggle_button);
toggle_button = create_simple_list_button ({ StructType.TODO, StructType.FIXME },
@@ -571,6 +572,7 @@ public class Structure : VBox
_icons[StructType.FIXME] = "tree_todo";
_icons[StructType.TABLE] = "table";
_icons[StructType.FIGURE] = "image";
+ _icons[StructType.IMAGE] = "image";
_icons[StructType.INCLUDE] = "tree_include";
}
@@ -594,6 +596,7 @@ public class Structure : VBox
_names[StructType.FIXME] = "FIXME";
_names[StructType.TABLE] = _("Table");
_names[StructType.FIGURE] = _("Figure");
+ _names[StructType.IMAGE] = _("Image");
_names[StructType.INCLUDE] = _("File included");
}
diff --git a/src/structure_model.vala b/src/structure_model.vala
index 95e1117..2f97f22 100644
--- a/src/structure_model.vala
+++ b/src/structure_model.vala
@@ -483,7 +483,24 @@ public class StructureModel : TreeModel, GLib.Object
return;
var list = get_list (item.type);
- list.add (new_node);
+
+ // if it's an append_item(), append the item to the list too
+ if (pos == -1)
+ {
+ list.add (new_node);
+ return;
+ }
+
+ // if the item is inserted in the middle, search where to insert it in the list
+ int mark_pos = get_position_from_mark (item.start_mark);
+ int i;
+ for (i = 0 ; i < list.size ; i++)
+ {
+ int cur_mark_pos = get_position_from_mark (list[i].data.start_mark);
+ if (cur_mark_pos > mark_pos)
+ break;
+ }
+ list.insert (i, new_node);
}
private static int get_position_from_mark (TextMark mark)
@@ -561,6 +578,7 @@ public class StructureModel : TreeModel, GLib.Object
return _list_tables;
case StructType.FIGURE:
+ case StructType.IMAGE:
return _list_figures;
case StructType.TODO:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]