[shotwell/wip/phako/configure-sidebar: 251/254] WIP
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell/wip/phako/configure-sidebar: 251/254] WIP
- Date: Sat, 25 May 2019 17:49:14 +0000 (UTC)
commit 78a5389f78287aab838df277f065e6bebbf5ab38
Author: Jens Georg <mail jensge org>
Date: Sun Jul 15 21:45:32 2018 +0200
WIP
src/dialogs/Preferences.vala | 7 +++---
src/library/LibraryWindow.vala | 53 +++++++++++++++++++++++++++++++++++-------
2 files changed, 49 insertions(+), 11 deletions(-)
---
diff --git a/src/dialogs/Preferences.vala b/src/dialogs/Preferences.vala
index a504faa4..57c00b0e 100644
--- a/src/dialogs/Preferences.vala
+++ b/src/dialogs/Preferences.vala
@@ -32,6 +32,8 @@ public class SidebarPreferencesListRow : Gtk.ListBoxRow {
{ "GTK_LIST_BOX_ROW", Gtk.TargetFlags.SAME_APP, 0}
};
+ public signal void moved();
+
public SidebarPreferencesListRow(string name) {
Object();
this.row_name = name;
@@ -56,6 +58,7 @@ public class SidebarPreferencesListRow : Gtk.ListBoxRow {
source.get_parent().remove(source);
(target.get_parent() as Gtk.ListBox).insert(source, pos);
source.unref();
+ this.moved();
}
private void on_drag_data_get(Gtk.Widget source, Gdk.DragContext ctx, Gtk.SelectionData data, uint info,
uint time) {
@@ -225,8 +228,6 @@ public class PreferencesDialog : Gtk.Dialog {
default_raw_developer_combo.changed.connect(on_default_raw_developer_changed);
switch_dark.active = Gtk.Settings.get_default().gtk_application_prefer_dark_theme;
switch_dark.notify["active"].connect(on_theme_variant_changed);
-
- this.sidebar_content_updated_handler = sidebar_content.add.connect(this.on_update_sidebar_order);
}
public void populate_preference_options() {
@@ -242,6 +243,7 @@ public class PreferencesDialog : Gtk.Dialog {
var row = new SidebarPreferencesListRow(tree);
row.tree_visibility = tree in visibility;
row.notify["tree-visibility"].connect (this.on_update_sidebar_visibility);
+ row.moved.connect(this.on_update_sidebar_order);
sidebar_content.add(row);
}
if (this.sidebar_content_updated_handler != 0)
@@ -273,7 +275,6 @@ public class PreferencesDialog : Gtk.Dialog {
}
private void on_update_sidebar_order () {
- critical ("=> Updating sidebar");
var config = Config.Facade.get_instance();
string[] rows = new string[0];
sidebar_content.foreach ((child) => {
diff --git a/src/library/LibraryWindow.vala b/src/library/LibraryWindow.vala
index 4ced992c..e48fe37b 100644
--- a/src/library/LibraryWindow.vala
+++ b/src/library/LibraryWindow.vala
@@ -162,6 +162,14 @@ public class LibraryWindow : AppWindow {
//UnityProgressBar: init
UnityProgressBar uniprobar = UnityProgressBar.get_instance();
#endif
+
+ private int get_branch_position(string[] list, string key) {
+ for (int i = 0; i < list.length; i++) {
+ if (key == list[i])
+ return i;
+ }
+ return -1;
+ }
public LibraryWindow(ProgressMonitor progress_monitor) {
base();
@@ -174,18 +182,20 @@ public class LibraryWindow : AppWindow {
sidebar_tree.destroying_page.connect(on_destroying_page);
sidebar_tree.entry_selected.connect(on_sidebar_entry_selected);
sidebar_tree.selected_entry_removed.connect(on_sidebar_selected_entry_removed);
+
+ var order = Config.Facade.get_instance().get_sidebar_content_order();
- sidebar_tree.graft(library_branch, SidebarRootPosition.LIBRARY);
- sidebar_tree.graft(tags_branch, SidebarRootPosition.TAGS);
- sidebar_tree.graft(folders_branch, SidebarRootPosition.FOLDERS);
+ sidebar_tree.graft(library_branch, this.get_branch_position (order, Library.Branch.HANDLE));
+ sidebar_tree.graft(tags_branch, this.get_branch_position (order, Tags.Branch.HANDLE));
+ sidebar_tree.graft(folders_branch, this.get_branch_position (order, Folders.Branch.HANDLE));
#if ENABLE_FACES
- sidebar_tree.graft(faces_branch, SidebarRootPosition.FACES);
+ sidebar_tree.graft(faces_branch, this.get_branch_position (order, Faces.Branch.HANDLE));
#endif
- sidebar_tree.graft(events_branch, SidebarRootPosition.EVENTS);
- sidebar_tree.graft(camera_branch, SidebarRootPosition.CAMERAS);
- sidebar_tree.graft(saved_search_branch, SidebarRootPosition.SAVED_SEARCH);
- sidebar_tree.graft(import_roll_branch, SidebarRootPosition.IMPORT_ROLL);
+ sidebar_tree.graft(events_branch, this.get_branch_position (order, Events.Branch.HANDLE));
+ sidebar_tree.graft(camera_branch, this.get_branch_position (order, Camera.Branch.HANDLE));
+ sidebar_tree.graft(saved_search_branch, this.get_branch_position (order, Searches.Branch.HANDLE));
+ sidebar_tree.graft(import_roll_branch, this.get_branch_position (order, ImportRoll.Branch.HANDLE));
properties_scheduler = new OneShotScheduler("LibraryWindow properties",
on_update_properties_now);
@@ -233,6 +243,33 @@ public class LibraryWindow : AppWindow {
// by the menu
const string[] accels = { "<Primary>f", "F8", null };
Application.set_accels_for_action("win.CommonDisplaySearchbar", accels);
+
+ Config.Facade.get_instance().sidebar_content_changed.connect (() => {
+ sidebar_tree.prune (library_branch);
+ sidebar_tree.prune (tags_branch);
+ sidebar_tree.prune (folders_branch);
+#if ENABLE_FACES
+ sidebar_tree.prune (faces_branch);
+#endif
+ sidebar_tree.prune (events_branch);
+ sidebar_tree.prune (camera_branch);
+ sidebar_tree.prune (saved_search_branch);
+ sidebar_tree.prune (import_roll_branch);
+
+ order = Config.Facade.get_instance().get_sidebar_content_order();
+
+ sidebar_tree.graft(library_branch, this.get_branch_position (order, Library.Branch.HANDLE));
+ sidebar_tree.graft(tags_branch, this.get_branch_position (order, Tags.Branch.HANDLE));
+ sidebar_tree.graft(folders_branch, this.get_branch_position (order, Folders.Branch.HANDLE));
+ #if ENABLE_FACES
+ sidebar_tree.graft(faces_branch, this.get_branch_position (order, Faces.Branch.HANDLE));
+ #endif
+
+ sidebar_tree.graft(events_branch, this.get_branch_position (order, Events.Branch.HANDLE));
+ sidebar_tree.graft(camera_branch, this.get_branch_position (order, Camera.Branch.HANDLE));
+ sidebar_tree.graft(saved_search_branch, this.get_branch_position (order,
Searches.Branch.HANDLE));
+ sidebar_tree.graft(import_roll_branch, this.get_branch_position (order,
ImportRoll.Branch.HANDLE));
+ });
}
~LibraryWindow() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]