[shotwell/wip/phako/configure-sidebar: 246/254] wip: Make sidebar configurable
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell/wip/phako/configure-sidebar: 246/254] wip: Make sidebar configurable
- Date: Sat, 25 May 2019 17:48:49 +0000 (UTC)
commit 3fb28ea5e0e335d540f26b21cb52e3a200282bae
Author: Jens Georg <mail jensge org>
Date: Wed Jun 27 10:16:52 2018 +0200
wip: Make sidebar configurable
data/gsettings/org.yorba.shotwell.gschema.xml | 7 +++
data/ui/preferences_dialog.ui | 37 ++++++++++++++--
data/ui/preferences_dialog_list_row.ui | 64 +++++++++++++++++++++++++++
src/Resources.vala | 5 +++
src/config/ConfigurationInterfaces.vala | 34 ++++++++++++++
src/config/GSettingsEngine.vala | 27 +++++++++++
src/dialogs/Preferences.vala | 27 +++++++++++
7 files changed, 197 insertions(+), 4 deletions(-)
---
diff --git a/data/gsettings/org.yorba.shotwell.gschema.xml b/data/gsettings/org.yorba.shotwell.gschema.xml
index 6ac75cf5..4c924f24 100644
--- a/data/gsettings/org.yorba.shotwell.gschema.xml
+++ b/data/gsettings/org.yorba.shotwell.gschema.xml
@@ -185,6 +185,13 @@
<summary>Selection state of “hide photos” option</summary>
<description>Last used selection state of the “hide photos already imported” option in the import
page.</description>
</key>
+
+ <key name="sidebar-order" type="as">
+ <default>['library', 'cameras', 'saved-searches', 'events', 'import-roll', 'folders', 'faces',
'tags']</default>
+ <summary>Which entries to show in the sidebar</summary>
+ <description>Order of entries in the left sidebar. If an entry is not mentioned, it will not be shown.
Note,
+ however, that the main library entry cannot be moved or removed</description>
+ </key>
</schema>
<schema id="org.yorba.shotwell.preferences.slideshow" path="/org/yorba/shotwell/preferences/slideshow/">
diff --git a/data/ui/preferences_dialog.ui b/data/ui/preferences_dialog.ui
index f020c974..41256eac 100644
--- a/data/ui/preferences_dialog.ui
+++ b/data/ui/preferences_dialog.ui
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.22.0 -->
<interface domain="shotwell">
<requires lib="gtk+" version="3.18"/>
<template class="PreferencesDialog" parent="GtkDialog">
@@ -600,10 +600,38 @@
</packing>
</child>
<child>
- <placeholder/>
+ <object class="GtkScrolledWindow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkViewport">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkListBox" id="sidebar_content">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="selection_mode">none</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">3</property>
+ </packing>
</child>
<child type="tab">
- <placeholder/>
+ <object class="GtkLabel" id="sidebar-tab">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Sidebar</property>
+ </object>
+ <packing>
+ <property name="position">3</property>
+ <property name="tab_fill">False</property>
+ </packing>
</child>
</object>
<packing>
@@ -618,7 +646,8 @@
<object class="GtkHeaderBar" id="headerbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="title" translatable="yes">Shotwell Preferences</property>
+ <property name="title">Shotwell Preferences</property>
+ <property name="has_subtitle">False</property>
<property name="show_close_button">True</property>
</object>
</child>
diff --git a/data/ui/preferences_dialog_list_row.ui b/data/ui/preferences_dialog_list_row.ui
new file mode 100644
index 00000000..e58b8555
--- /dev/null
+++ b/data/ui/preferences_dialog_list_row.ui
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.0 -->
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <template class="SidebarPreferencesListRow" parent="GtkListBoxRow">
+ <property name="width_request">100</property>
+ <property name="height_request">80</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">10</property>
+ <child>
+ <object class="GtkEventBox" id="handle">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">open-menu-symbolic</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">Library</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton">
+ <property name="label" translatable="yes">Visible</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">end</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/Resources.vala b/src/Resources.vala
index 6d2b8851..d9b3f043 100644
--- a/src/Resources.vala
+++ b/src/Resources.vala
@@ -1180,5 +1180,10 @@ along with Shotwell; if not, write to the Free Software Foundation, Inc.,
public const string ONIMAGE_FONT_COLOR = "#000000";
public const string ONIMAGE_FONT_BACKGROUND = "rgba(255,255,255,0.5)";
+
+
+ public static string map_subtree_name(string name) {
+ return name;
+ }
}
diff --git a/src/config/ConfigurationInterfaces.vala b/src/config/ConfigurationInterfaces.vala
index 195a28f7..c40c3dc8 100644
--- a/src/config/ConfigurationInterfaces.vala
+++ b/src/config/ConfigurationInterfaces.vala
@@ -85,6 +85,7 @@ public enum ConfigurableProperty {
RAW_DEVELOPER_DEFAULT,
SHOW_WELCOME_DIALOG,
SIDEBAR_POSITION,
+ SIDEBAR_CONTENT,
SLIDESHOW_DELAY,
SLIDESHOW_TRANSITION_DELAY,
SLIDESHOW_TRANSITION_EFFECT_ID,
@@ -292,6 +293,9 @@ public enum ConfigurableProperty {
case SIDEBAR_POSITION:
return "SIDEBAR_POSITION";
+
+ case SIDEBAR_CONTENT:
+ return "SIDEBAR_CONTENT";
case SLIDESHOW_DELAY:
return "SLIDESHOW_DELAY";
@@ -333,6 +337,9 @@ public interface ConfigurationEngine : GLib.Object {
public abstract string get_string_property(ConfigurableProperty p) throws ConfigurationError;
public abstract void set_string_property(ConfigurableProperty p, string val) throws ConfigurationError;
+
+ public abstract string[] get_string_list_property(ConfigurableProperty p) throws ConfigurationError;
+ public abstract void set_string_list_property(ConfigurableProperty p, string[] val) throws
ConfigurationError;
public abstract bool get_bool_property(ConfigurableProperty p) throws ConfigurationError;
public abstract void set_bool_property(ConfigurableProperty p, bool val) throws ConfigurationError;
@@ -364,6 +371,7 @@ public abstract class ConfigurationFacade : Object {
public signal void commit_metadata_to_masters_changed();
public signal void events_sort_ascending_changed();
public signal void external_app_changed();
+ public signal void sidebar_content_changed();
public signal void import_directory_changed();
protected ConfigurationFacade(ConfigurationEngine engine) {
@@ -408,6 +416,10 @@ public abstract class ConfigurationFacade : Object {
case ConfigurableProperty.IMPORT_DIR:
import_directory_changed();
break;
+
+ case ConfigurableProperty.SIDEBAR_CONTENT:
+ sidebar_content_changed();
+ break;
}
}
@@ -1692,6 +1704,28 @@ public abstract class ConfigurationFacade : Object {
}
}
+ //
+ // sidebar content
+ //
+ public virtual string[] get_sidebar_content() {
+ try {
+ return get_engine().get_string_list_property(ConfigurableProperty.SIDEBAR_CONTENT);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ string[] config = {"library", "cameras", "saved-searches", "events", "import-roll", "folders",
"faces", "tags" };
+ return config;
+ }
+ }
+
+ public virtual void set_sidebar_content(string[] val) {
+ try {
+ get_engine().set_string_list_property(ConfigurableProperty.SIDEBAR_CONTENT, val);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
//
// slideshow delay
//
diff --git a/src/config/GSettingsEngine.vala b/src/config/GSettingsEngine.vala
index dcc05c6d..920351ac 100644
--- a/src/config/GSettingsEngine.vala
+++ b/src/config/GSettingsEngine.vala
@@ -58,6 +58,7 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object {
schema_names[ConfigurableProperty.EVENT_PHOTOS_SORT_ASCENDING] = UI_PREFS_SCHEMA_NAME;
schema_names[ConfigurableProperty.EVENT_PHOTOS_SORT_BY] = UI_PREFS_SCHEMA_NAME;
schema_names[ConfigurableProperty.EVENTS_SORT_ASCENDING] = UI_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.SIDEBAR_CONTENT] = UI_PREFS_SCHEMA_NAME;
schema_names[ConfigurableProperty.EXPORT_CONSTRAINT] = EXPORT_PREFS_SCHEMA_NAME;
schema_names[ConfigurableProperty.EXPORT_EXPORT_FORMAT_MODE] = EXPORT_PREFS_SCHEMA_NAME;
schema_names[ConfigurableProperty.EXPORT_EXPORT_METADATA] = EXPORT_PREFS_SCHEMA_NAME;
@@ -170,6 +171,7 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object {
key_names[ConfigurableProperty.RAW_DEVELOPER_DEFAULT] = "raw-developer-default";
key_names[ConfigurableProperty.SHOW_WELCOME_DIALOG] = "show-welcome-dialog";
key_names[ConfigurableProperty.SIDEBAR_POSITION] = "sidebar-position";
+ key_names[ConfigurableProperty.SIDEBAR_CONTENT] = "sidebar-content";
key_names[ConfigurableProperty.SLIDESHOW_DELAY] = "delay";
key_names[ConfigurableProperty.SLIDESHOW_TRANSITION_DELAY] = "transition-delay";
key_names[ConfigurableProperty.SLIDESHOW_TRANSITION_EFFECT_ID] = "transition-effect-id";
@@ -277,6 +279,22 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object {
schema_object.set_string(key, value);
}
+ private string[] get_gs_string_list(string schema, string key) throws ConfigurationError {
+ check_key_valid(schema, key);
+
+ Settings schema_object = new Settings(schema);
+
+ return schema_object.get_strv(key);
+ }
+
+ private void set_gs_string_list(string schema, string key, string[] value) throws ConfigurationError {
+ check_key_valid(schema, key);
+
+ Settings schema_object = new Settings(schema);
+
+ schema_object.set_strv(key, value);
+ }
+
private void reset_gs_to_default(string schema, string key) throws ConfigurationError {
check_key_valid(schema, key);
@@ -363,6 +381,15 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object {
property_changed(p);
}
+ public string[] get_string_list_property(ConfigurableProperty p) throws ConfigurationError {
+ return get_gs_string_list(schema_names[p], key_names[p]);
+ }
+
+ public void set_string_list_property(ConfigurableProperty p, string[] val) throws ConfigurationError {
+ set_gs_string_list(schema_names[p], key_names[p], val);
+ property_changed(p);
+ }
+
public bool get_bool_property(ConfigurableProperty p) throws ConfigurationError {
return get_gs_bool(schema_names[p], key_names[p]);
}
diff --git a/src/dialogs/Preferences.vala b/src/dialogs/Preferences.vala
index 846a9b8e..28609d47 100644
--- a/src/dialogs/Preferences.vala
+++ b/src/dialogs/Preferences.vala
@@ -5,6 +5,26 @@
* See the COPYING file in this distribution.
*/
+[GtkTemplate (ui = "/org/gnome/Shotwell/ui/preferences_dialog_list_row.ui")]
+public class SidebarPreferencesListRow : Gtk.ListBoxRow {
+ [GtkChild]
+ private Gtk.EventBox handle;
+
+ [GtkChild]
+ private Gtk.Label label;
+
+ private const Gtk.TargetEntry[] SOURCE_TARGET_ENTRIES = {
+ { "GTK_LIST_BOX_ROW", Gtk.TargetFlags.SAME_APP, 0}
+ };
+
+ public SidebarPreferencesListRow(string name) {
+ Object();
+ Gtk.drag_source_set (this.handle, Gdk.ModifierType.BUTTON1_MASK, SOURCE_TARGET_ENTRIES,
Gdk.DragAction.MOVE);
+ Gtk.drag_dest_set (this, Gtk.DestDefaults.ALL, SOURCE_TARGET_ENTRIES, Gdk.DragAction.MOVE);
+ label.set_text (name);
+ }
+}
+
[GtkTemplate (ui = "/org/gnome/Shotwell/ui/preferences_dialog.ui")]
public class PreferencesDialog : Gtk.Dialog {
private class PathFormat {
@@ -62,6 +82,8 @@ public class PreferencesDialog : Gtk.Dialog {
private Gtk.ColorButton transparent_solid_color;
[GtkChild]
private Gtk.RadioButton transparent_none_radio;
+ [GtkChild]
+ private Gtk.ListBox sidebar_content;
private PreferencesDialog() {
Object (use_header_bar: Resources.use_header_bar());
@@ -146,6 +168,11 @@ public class PreferencesDialog : Gtk.Dialog {
}
public void populate_preference_options() {
+ var content = Config.Facade.get_instance().get_sidebar_content();
+ foreach (var tree in content) {
+ var row = new SidebarPreferencesListRow(Resources.map_subtree_name(tree));
+ sidebar_content.add(row);
+ }
populate_app_combo_box(photo_editor_combo, PhotoFileFormat.get_editable_mime_types(),
Config.Facade.get_instance().get_external_photo_app(), out external_photo_apps);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]