[latexila] Structure: remove min level and show/hide item types
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] Structure: remove min level and show/hide item types
- Date: Fri, 10 Jun 2011 19:44:06 +0000 (UTC)
commit 2d1c3315b956bb904dd64e2e37e4071b9d80fb30
Author: Sébastien Wilmet <sebastien wilmet gmail com>
Date: Wed Jun 8 16:24:11 2011 +0200
Structure: remove min level and show/hide item types
Don't worry, a better system will be implemented (see the file TODO).
With this new system, choosing the minimum level or show/hide item types
are useless (or, in all cases, less useful).
TODO | 13 ++-
data/org.gnome.latexila.gschema.xml | 28 -----
src/main_window.vala | 5 +-
src/structure.vala | 185 +++--------------------------------
4 files changed, 21 insertions(+), 210 deletions(-)
---
diff --git a/TODO b/TODO
index 1605d86..6771b14 100644
--- a/TODO
+++ b/TODO
@@ -7,12 +7,13 @@ LaTeXila 2.2
============
- Structure (list of chapters, sections, etc. to easily navigate in a document):
- - Add a show/hide button for sections.
- For example, to search the remaining TODOs and FIXMEs, it's boring to have all the sections.
-
- - Show/hide buttons: find a way to easily select only one item, and unselect the others.
- Also, find a way to easily select all the items.
- An idea is to add a menu on a right click on a button.
+ - Items overview:
+ The problem: if we search an item, for example a figure or a TODO, it takes time to
+ find it if there are a lot of sections.
+ Solution: possibility to view a simple list of a certain item type. The list would be
+ displayed below the mini-toolbar. If we click on a item in this list, the corresponding
+ item in the complete tree is selected. The show/hide buttons would be used to change
+ the item type of the simple list.
- Right click: cut, copy, paste below, select, delete, comment, shift left/right.
Shift left/right is new comparated to Kile. For example we have a big section (with
diff --git a/data/org.gnome.latexila.gschema.xml b/data/org.gnome.latexila.gschema.xml
index 1d0a495..9b86c26 100644
--- a/data/org.gnome.latexila.gschema.xml
+++ b/data/org.gnome.latexila.gschema.xml
@@ -121,34 +121,6 @@
<default>true</default>
<summary>Show build output badboxes</summary>
</key>
- <key name="structure-show-label" type="b">
- <default>true</default>
- <summary>Show labels in structure</summary>
- </key>
- <key name="structure-show-include" type="b">
- <default>true</default>
- <summary>Show includes in structure</summary>
- </key>
- <key name="structure-show-table" type="b">
- <default>true</default>
- <summary>Show tables in structure</summary>
- </key>
- <key name="structure-show-figure" type="b">
- <default>true</default>
- <summary>Show figures in structure</summary>
- </key>
- <key name="structure-show-todo" type="b">
- <default>true</default>
- <summary>Show TODOs in structure</summary>
- </key>
- <key name="structure-show-fixme" type="b">
- <default>true</default>
- <summary>Show FIXMEs in structure</summary>
- </key>
- <key name="structure-min-level" type="i">
- <default>6</default>
- <summary>Minimum structure level</summary>
- </key>
</schema>
<schema id="org.gnome.latexila.preferences.latex" path="/org/gnome/latexila/preferences/latex/">
diff --git a/src/main_window.vala b/src/main_window.vala
index 01b276a..150ab10 100644
--- a/src/main_window.vala
+++ b/src/main_window.vala
@@ -168,7 +168,6 @@ public class MainWindow : Window
private SidePanel side_panel;
private Symbols symbols;
private FileBrowser file_browser;
- private Structure structure;
private HPaned main_hpaned;
private VPaned vpaned;
@@ -290,7 +289,7 @@ public class MainWindow : Window
file_browser = new FileBrowser (this);
side_panel.add_component (_("File Browser"), Stock.OPEN, file_browser);
- structure = new Structure (this);
+ Structure structure = new Structure (this);
side_panel.add_component (_("Structure"), Stock.INDEX, structure);
side_panel.restore_state ();
@@ -1115,8 +1114,6 @@ public class MainWindow : Window
action = (ToggleAction) action_group.get_action ("BuildShowBadBoxes");
settings_ui.set_boolean ("show-build-badboxes", action.active);
- structure.save_state ();
-
if (sync)
{
settings_window.sync ();
diff --git a/src/structure.vala b/src/structure.vala
index a32d606..3aea701 100644
--- a/src/structure.vala
+++ b/src/structure.vala
@@ -40,10 +40,7 @@ public enum StructType
public class Structure : VBox
{
private unowned MainWindow _main_window;
- private GLib.Settings _settings;
- private TreeModelFilter _tree_filter;
private TreeView _tree_view;
- private bool[] _visible_types;
private static string[] _icons = null;
private static string[] _names = null;
@@ -53,11 +50,7 @@ public class Structure : VBox
GLib.Object (spacing: 3);
_main_window = main_window;
- _settings = new GLib.Settings ("org.gnome.latexila.preferences.ui");
-
- init_visible_types ();
init_toolbar ();
- init_choose_min_level ();
init_tree_view ();
show_all ();
@@ -65,66 +58,6 @@ public class Structure : VBox
hide.connect (disconnect_parsing);
}
- private void init_visible_types ()
- {
- _visible_types = new bool[StructType.N_TYPES];
-
- _visible_types[StructType.LABEL] =
- _settings.get_boolean ("structure-show-label");
-
- _visible_types[StructType.INCLUDE] =
- _settings.get_boolean ("structure-show-include");
-
- _visible_types[StructType.TABLE] =
- _settings.get_boolean ("structure-show-table");
-
- _visible_types[StructType.FIGURE] =
- _settings.get_boolean ("structure-show-figure");
-
- _visible_types[StructType.TODO] =
- _settings.get_boolean ("structure-show-todo");
-
- _visible_types[StructType.FIXME] =
- _settings.get_boolean ("structure-show-fixme");
-
- // the other types are initialized in init_choose_min_level()
- }
-
- public void save_state ()
- {
- /* Save visible types */
-
- _settings.set_boolean ("structure-show-label",
- _visible_types[StructType.LABEL]);
-
- _settings.set_boolean ("structure-show-include",
- _visible_types[StructType.INCLUDE]);
-
- _settings.set_boolean ("structure-show-table",
- _visible_types[StructType.TABLE]);
-
- _settings.set_boolean ("structure-show-figure",
- _visible_types[StructType.FIGURE]);
-
- _settings.set_boolean ("structure-show-todo",
- _visible_types[StructType.TODO]);
-
- _settings.set_boolean ("structure-show-fixme",
- _visible_types[StructType.FIXME]);
-
- /* save min level */
-
- int min_level = StructType.PART;
- for (int level = min_level ; is_section ((StructType) level) ; level++)
- {
- if (! _visible_types[level])
- break;
- min_level = level;
- }
-
- _settings.set_int ("structure-min-level", min_level);
- }
-
private void init_toolbar ()
{
HBox hbox = new HBox (true, 0);
@@ -154,34 +87,32 @@ public class Structure : VBox
collapse_button.clicked.connect (() => _tree_view.collapse_all ());
- // show/hide buttons
- ToggleButton toggle_button = create_show_hide_button ({ StructType.LABEL },
+ // simple list buttons
+ ToggleButton toggle_button = create_simple_list_button ({ StructType.LABEL },
_("Show labels"));
hbox.pack_start (toggle_button);
- toggle_button = create_show_hide_button ({ StructType.INCLUDE },
+ toggle_button = create_simple_list_button ({ StructType.INCLUDE },
_("Show files included"));
hbox.pack_start (toggle_button);
- toggle_button = create_show_hide_button ({ StructType.TABLE },
+ toggle_button = create_simple_list_button ({ StructType.TABLE },
_("Show tables"));
hbox.pack_start (toggle_button);
- toggle_button = create_show_hide_button ({ StructType.FIGURE },
+ toggle_button = create_simple_list_button ({ StructType.FIGURE },
_("Show figures"));
hbox.pack_start (toggle_button);
- toggle_button = create_show_hide_button ({ StructType.TODO, StructType.FIXME },
+ toggle_button = create_simple_list_button ({ StructType.TODO, StructType.FIXME },
_("Show TODOs and FIXMEs"));
hbox.pack_start (toggle_button);
}
- /* Create a show/hide button for hiding some types.
- * One button can hide several types, that's why it's an array.
- * The button image is the same as for the first type. If needed, we could add a new
- * parameter.
- */
- private ToggleButton? create_show_hide_button (StructType[] types, string tooltip)
+ // Only one button can be activated at the same time.
+ // If no button is selected, the simple list is hidden.
+ // If a button is selected, the simple list contains only items specified by 'types'.
+ private ToggleButton? create_simple_list_button (StructType[] types, string tooltip)
{
return_val_if_fail (types.length > 0, null);
@@ -189,16 +120,6 @@ public class Structure : VBox
Utils.get_toolbar_toggle_button (get_icon_from_type (types[0]));
button.tooltip_text = tooltip;
- button.active = _visible_types[types[0]];
-
- button.toggled.connect (() =>
- {
- foreach (StructType type in types)
- _visible_types[type] = button.active;
-
- if (_tree_filter != null)
- _tree_filter.refilter ();
- });
return button;
}
@@ -234,72 +155,6 @@ public class Structure : VBox
pack_start (sw);
}
- private enum MinLevelColumn
- {
- PIXBUF,
- NAME,
- TYPE,
- N_COLUMNS
- }
-
- private void init_choose_min_level ()
- {
- ListStore list_store = new ListStore (MinLevelColumn.N_COLUMNS,
- typeof (string),
- typeof (string),
- typeof (StructType));
-
- ComboBox combo_box = new ComboBox.with_model (list_store);
- combo_box.tooltip_text = _("Minimum level");
-
- CellRendererPixbuf pixbuf_renderer = new CellRendererPixbuf ();
- combo_box.pack_start (pixbuf_renderer, false);
- combo_box.set_attributes (pixbuf_renderer,
- "stock-id", MinLevelColumn.PIXBUF, null);
-
- CellRendererText text_renderer = new CellRendererText ();
- combo_box.pack_start (text_renderer, true);
- combo_box.set_attributes (text_renderer, "text", MinLevelColumn.NAME, null);
-
- // populate the combo box
- for (int type = StructType.PART ; type <= StructType.SUBPARAGRAPH ; type++)
- {
- TreeIter iter;
- list_store.append (out iter);
- list_store.set (iter,
- MinLevelColumn.PIXBUF, get_icon_from_type ((StructType) type),
- MinLevelColumn.NAME, get_type_name ((StructType) type),
- MinLevelColumn.TYPE, type,
- -1);
- }
-
- combo_box.changed.connect (() =>
- {
- TreeIter iter;
- if (! combo_box.get_active_iter (out iter))
- return;
-
- StructType selected_type;
- TreeModel model = (TreeModel) list_store;
- model.get (iter, MinLevelColumn.TYPE, out selected_type, -1);
-
- for (int type = 0 ; is_section ((StructType) type) ; type++)
- _visible_types[type] = type <= selected_type;
-
- if (_tree_filter != null)
- _tree_filter.refilter ();
- if (_tree_view != null)
- _tree_view.expand_all ();
- });
-
- // restore state
- int min_level = _settings.get_int ("structure-min-level");
- min_level = min_level.clamp (StructType.PART, StructType.SUBPARAGRAPH);
- combo_box.set_active (min_level);
-
- pack_start (combo_box, false, false);
- }
-
private bool on_row_selection (TreeSelection selection, TreeModel model,
TreePath path, bool path_currently_selected)
{
@@ -336,6 +191,7 @@ public class Structure : VBox
return;
_tree_view.set_model (null);
+ _tree_view.columns_autosize ();
DocumentStructure doc_struct = doc.get_structure ();
@@ -344,26 +200,11 @@ public class Structure : VBox
doc_struct.parsing_done.connect (() =>
{
- set_model (doc_struct.get_model ());
+ _tree_view.set_model (doc_struct.get_model ());
+ _tree_view.expand_all ();
});
}
- private void set_model (StructureModel model)
- {
- _tree_filter = new TreeModelFilter (model, null);
- _tree_filter.set_visible_func ((mod, iter) =>
- {
- StructType type;
- mod.get (iter, StructColumn.TYPE, out type, -1);
-
- return _visible_types[type];
- });
-
- _tree_view.set_model (_tree_filter);
- _tree_view.expand_all ();
- _tree_view.columns_autosize ();
- }
-
public void connect_parsing ()
{
_main_window.notify["active-document"].connect (show_active_document);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]