[gnome-latex/wip/style-scheme-chooser] PreferencesDialog: use TeplStyleSchemeChooserWidget
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-latex/wip/style-scheme-chooser] PreferencesDialog: use TeplStyleSchemeChooserWidget
- Date: Tue, 21 Apr 2020 23:16:46 +0000 (UTC)
commit 1fb7846d24f28e7a156be3f2cd795921974cabdf
Author: Sébastien Wilmet <swilmet gnome org>
Date: Wed Apr 22 01:06:30 2020 +0200
PreferencesDialog: use TeplStyleSchemeChooserWidget
src/preferences_dialog.vala | 89 ++------------------------------------------
src/ui/preferences_dialog.ui | 18 +--------
2 files changed, 4 insertions(+), 103 deletions(-)
---
diff --git a/src/preferences_dialog.vala b/src/preferences_dialog.vala
index 8cb408a..a9fc9c1 100644
--- a/src/preferences_dialog.vala
+++ b/src/preferences_dialog.vala
@@ -221,51 +221,9 @@ public class PreferencesDialog : Dialog
BindingFlags.DEFAULT | BindingFlags.SYNC_CREATE |
BindingFlags.INVERT_BOOLEAN);
- TreeView schemes_treeview = builder.get_object ("schemes_treeview") as TreeView;
- string current_scheme_id = settings.get_string ("scheme");
- init_schemes_treeview (schemes_treeview, current_scheme_id);
-
- // the scheme has changed in the treeview -> update gsettings
- TreeSelection schemes_select = schemes_treeview.get_selection ();
- schemes_select.changed.connect (() =>
- {
- unowned TreeModel model;
- GLib.List<TreePath> rows = schemes_select.get_selected_rows (out model);
- if (rows.length () != 1)
- return;
-
- TreePath path = rows.nth_data (0);
- TreeIter iter;
- model.get_iter (out iter, path);
-
- string id;
- model.get (iter, StyleSchemes.ID, out id);
-
- settings.set_string ("scheme", id);
- });
-
- // the scheme has changed in gsettings -> update the treeview
- settings.changed["scheme"].connect ((setting, key) =>
- {
- string val = setting.get_string (key);
-
- TreeModel model = schemes_treeview.model;
- TreeIter iter;
- bool valid = model.get_iter_first (out iter);
-
- while (valid)
- {
- string scheme;
- model.get (iter, StyleSchemes.ID, out scheme, -1);
- if (scheme == val)
- {
- TreeSelection select = schemes_treeview.get_selection ();
- select.select_iter (iter);
- return;
- }
- valid = model.iter_next (ref iter);
- }
- });
+// Tepl.StyleSchemeChooserWidget style_scheme_chooser =
+// builder.get_object ("style_scheme_chooser") as Tepl.StyleSchemeChooserWidget;
+ //string current_scheme_id = settings.get_string ("scheme");
}
private void init_interactive_completion_setting (Builder builder)
@@ -377,45 +335,4 @@ public class PreferencesDialog : Dialog
(double) max, 1.0, 0, 0);
spin_button.set_adjustment (adjustment);
}
-
- private enum StyleSchemes
- {
- ID,
- DESC,
- N_COLUMNS
- }
-
- private void init_schemes_treeview (TreeView treeview, string current_id)
- {
- Gtk.ListStore list_store = new Gtk.ListStore (StyleSchemes.N_COLUMNS, typeof (string),
- typeof (string));
- list_store.set_sort_column_id (StyleSchemes.ID, SortType.ASCENDING);
- treeview.set_model (list_store);
-
- CellRendererText renderer = new CellRendererText ();
- TreeViewColumn column = new TreeViewColumn.with_attributes (
- "Name and description", renderer,
- "markup", StyleSchemes.DESC, null);
- treeview.append_column (column);
-
- TreeSelection select = treeview.get_selection ();
- select.set_mode (SelectionMode.SINGLE);
-
- /* fill style scheme list store */
- SourceStyleSchemeManager manager = SourceStyleSchemeManager.get_default ();
- foreach (string id in manager.get_scheme_ids ())
- {
- SourceStyleScheme scheme = manager.get_scheme (id);
- string desc = "<b>%s</b> - %s".printf (scheme.name, scheme.description);
- TreeIter iter;
- list_store.append (out iter);
- list_store.set (iter,
- StyleSchemes.ID, scheme.id,
- StyleSchemes.DESC, desc,
- -1);
-
- if (id == current_id)
- select.select_iter (iter);
- }
- }
}
diff --git a/src/ui/preferences_dialog.ui b/src/ui/preferences_dialog.ui
index ddfe566..e37233a 100644
--- a/src/ui/preferences_dialog.ui
+++ b/src/ui/preferences_dialog.ui
@@ -376,25 +376,9 @@
</packing>
</child>
<child>
- <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <object class="TeplStyleSchemeChooserWidget" id="style_scheme_chooser">
<property name="visible">True</property>
- <property name="can_focus">True</property>
<property name="margin_start">12</property>
- <property name="overlay_scrolling">False</property>
- <child>
- <object class="GtkTreeView" id="schemes_treeview">
- <property name="height_request">150</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="headers_visible">False</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection" id="treeview-selection4"/>
- </child>
- </object>
- </child>
</object>
<packing>
<property name="left_attach">0</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]