[shotwell/wip/phako/configure-sidebar: 247/254] wip



commit c3ce290cd4cdc17d690bed652e6d5f7f033e425f
Author: Jens Georg <mail jensge org>
Date:   Tue Jul 10 16:02:52 2018 +0200

    wip

 data/gsettings/org.yorba.shotwell.gschema.xml | 10 +++-
 data/themes/org.gnome.Shotwell.css            |  5 ++
 data/ui/preferences_dialog_list_row.ui        |  8 +--
 src/config/ConfigurationInterfaces.vala       | 27 +++++++++++
 src/config/GSettingsEngine.vala               |  2 +
 src/dialogs/Preferences.vala                  | 70 +++++++++++++++++++++++++--
 src/plugins/Plugins.vala                      |  2 +-
 7 files changed, 115 insertions(+), 9 deletions(-)
---
diff --git a/data/gsettings/org.yorba.shotwell.gschema.xml b/data/gsettings/org.yorba.shotwell.gschema.xml
index 4c924f24..16ac8de2 100644
--- a/data/gsettings/org.yorba.shotwell.gschema.xml
+++ b/data/gsettings/org.yorba.shotwell.gschema.xml
@@ -186,12 +186,18 @@
         <description>Last used selection state of the “hide photos already imported” option in the import 
page.</description>
     </key>
 
-    <key name="sidebar-order" type="as">
+    <key name="sidebar-content" 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,
+      <description>Visibility 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>
+
+    <key name="sidebar-content-order" type="as">
+      <default>['library', 'cameras', 'saved-searches', 'events', 'import-roll', 'folders', 'faces', 
'tags']</default>
+      <summary>Order of entries in the sidebar</summary>
+      <description>Order of entries in the left sidebar. The visibility of the entries is handled by the key 
sidebar-content</description>
+    </key>
 </schema>
 
 <schema id="org.yorba.shotwell.preferences.slideshow" path="/org/yorba/shotwell/preferences/slideshow/">
diff --git a/data/themes/org.gnome.Shotwell.css b/data/themes/org.gnome.Shotwell.css
index c6b08c2c..aa6d206b 100644
--- a/data/themes/org.gnome.Shotwell.css
+++ b/data/themes/org.gnome.Shotwell.css
@@ -5,3 +5,8 @@ textview.shotwell-static text {
 label.map-attribution {
     font-size: 66%;
 }
+
+.drag-icon {
+    background: white;
+    border: 1px solid black;
+}
\ No newline at end of file
diff --git a/data/ui/preferences_dialog_list_row.ui b/data/ui/preferences_dialog_list_row.ui
index e58b8555..db3fc047 100644
--- a/data/ui/preferences_dialog_list_row.ui
+++ b/data/ui/preferences_dialog_list_row.ui
@@ -3,14 +3,16 @@
 <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="margin_left">10</property>
+        <property name="margin_right">10</property>
+        <property name="margin_top">4</property>
+        <property name="margin_bottom">4</property>
         <property name="spacing">10</property>
         <child>
           <object class="GtkEventBox" id="handle">
@@ -44,7 +46,7 @@
           </packing>
         </child>
         <child>
-          <object class="GtkCheckButton">
+          <object class="GtkCheckButton" id="visibility">
             <property name="label" translatable="yes">Visible</property>
             <property name="visible">True</property>
             <property name="can_focus">True</property>
diff --git a/src/config/ConfigurationInterfaces.vala b/src/config/ConfigurationInterfaces.vala
index c40c3dc8..885c889f 100644
--- a/src/config/ConfigurationInterfaces.vala
+++ b/src/config/ConfigurationInterfaces.vala
@@ -86,6 +86,7 @@ public enum ConfigurableProperty {
     SHOW_WELCOME_DIALOG,
     SIDEBAR_POSITION,
     SIDEBAR_CONTENT,
+    SIDEBAR_CONTENT_ORDER,
     SLIDESHOW_DELAY,
     SLIDESHOW_TRANSITION_DELAY,
     SLIDESHOW_TRANSITION_EFFECT_ID,
@@ -296,6 +297,9 @@ public enum ConfigurableProperty {
 
             case SIDEBAR_CONTENT:
                 return "SIDEBAR_CONTENT";
+
+            case SIDEBAR_CONTENT_ORDER:
+                return "SIDEBAR_CONTENT_ORDER";
                 
             case SLIDESHOW_DELAY:
                 return "SLIDESHOW_DELAY";
@@ -418,6 +422,7 @@ public abstract class ConfigurationFacade : Object {
             break;
 
             case ConfigurableProperty.SIDEBAR_CONTENT:
+            case ConfigurableProperty.SIDEBAR_CONTENT_ORDER:
                 sidebar_content_changed();
             break;
         }
@@ -1726,6 +1731,28 @@ public abstract class ConfigurationFacade : Object {
         }
     }
 
+    //
+    // sidebar content order
+    //
+    public virtual string[] get_sidebar_content_order() {
+        try {
+            return get_engine().get_string_list_property(ConfigurableProperty.SIDEBAR_CONTENT_ORDER);
+        } 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_order(string[] val) {
+        try {
+            get_engine().set_string_list_property(ConfigurableProperty.SIDEBAR_CONTENT_ORDER, val);
+        } catch (ConfigurationError err) {
+            on_configuration_error(err);
+        }
+    }
+
     //
     // slideshow delay
     //
diff --git a/src/config/GSettingsEngine.vala b/src/config/GSettingsEngine.vala
index 920351ac..695b9cc0 100644
--- a/src/config/GSettingsEngine.vala
+++ b/src/config/GSettingsEngine.vala
@@ -59,6 +59,7 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object {
         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.SIDEBAR_CONTENT_ORDER] = 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;
@@ -172,6 +173,7 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object {
         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.SIDEBAR_CONTENT_ORDER] = "sidebar-content-order";
         key_names[ConfigurableProperty.SLIDESHOW_DELAY] = "delay";
         key_names[ConfigurableProperty.SLIDESHOW_TRANSITION_DELAY] = "transition-delay";
         key_names[ConfigurableProperty.SLIDESHOW_TRANSITION_EFFECT_ID] = "transition-effect-id";
diff --git a/src/dialogs/Preferences.vala b/src/dialogs/Preferences.vala
index 28609d47..954e431f 100644
--- a/src/dialogs/Preferences.vala
+++ b/src/dialogs/Preferences.vala
@@ -13,15 +13,73 @@ public class SidebarPreferencesListRow : Gtk.ListBoxRow {
     [GtkChild]
     private Gtk.Label label;
 
+    [GtkChild]
+    private Gtk.CheckButton visibility;
+
+    public bool tree_visibility {
+        set {
+            this.visibility.active = value;
+        }
+
+        get {
+            return this.visibility.active;
+        }
+    }
+
+    public string row_name { get; set; }
+
     private const Gtk.TargetEntry[] SOURCE_TARGET_ENTRIES = {
         { "GTK_LIST_BOX_ROW", Gtk.TargetFlags.SAME_APP, 0}
     };
 
     public SidebarPreferencesListRow(string name) {
         Object();
+        this.row_name = name;
         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);
+        handle.drag_data_get.connect(this.on_drag_data_get);
+        handle.drag_begin.connect(this.on_drag_begin);
+        label.set_text (Resources.map_subtree_name(name));
+        drag_data_received.connect(this.on_drag_data_received);
+    }
+
+    private void on_drag_data_received(Gtk.Widget target, Gdk.DragContext ctx, int x, int y, 
Gtk.SelectionData data, uint info, uint time) {
+        Gtk.Widget row  = *((Gtk.Widget **) data.get_data());
+        var pos = (target as Gtk.ListBoxRow).get_index();
+
+        var source = row.get_ancestor (typeof (Gtk.ListBoxRow));
+        if (source == target)
+            return;
+
+        source.ref();
+        source.get_parent().remove(source);
+        (target.get_parent() as Gtk.ListBox).insert(source, pos);
+        source.unref();
+    }
+
+    private void on_drag_data_get(Gtk.Widget source, Gdk.DragContext ctx, Gtk.SelectionData data, uint info, 
uint time) {
+        unowned uint8[] p2;
+        p2 = (uint8[]) &source;
+        p2.length = (int) sizeof(void *);
+
+        data.@set (Gdk.Atom.intern_static_string ("GTK_LIST_BOX_ROW"), 32, p2);
+    }
+
+    private void on_drag_begin(Gtk.Widget widget, Gdk.DragContext ctx) {
+        Gtk.Allocation allocation;
+
+        var row = widget.get_ancestor(typeof(Gtk.ListBoxRow));
+        row.get_allocation(out allocation);
+        var surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, allocation.width, allocation.height);
+        var cr = new Cairo.Context (surface);
+        row.get_style_context().add_class("drag-icon");
+        row.draw(cr);
+        row.get_style_context().remove_class("drag-icon");
+
+        int x, y;
+        widget.translate_coordinates(row, 0, 0, out x, out y);
+        surface.set_device_offset(-x, -y);
+        Gtk.drag_set_icon_surface(ctx, surface);
     }
 }
 
@@ -168,11 +226,17 @@ public class PreferencesDialog : Gtk.Dialog {
     }
 
     public void populate_preference_options() {
-        var content = Config.Facade.get_instance().get_sidebar_content();
+        var visibility = Config.Facade.get_instance().get_sidebar_content();
+        var content = Config.Facade.get_instance().get_sidebar_content_order();
+        foreach (var child in sidebar_content.get_children())
+            child.destroy();
+
         foreach (var tree in content) {
-            var row = new SidebarPreferencesListRow(Resources.map_subtree_name(tree));
+            var row = new SidebarPreferencesListRow(tree);
+            row.tree_visibility = tree in visibility;
             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);
 
diff --git a/src/plugins/Plugins.vala b/src/plugins/Plugins.vala
index 6aff4616..87eb59d4 100644
--- a/src/plugins/Plugins.vala
+++ b/src/plugins/Plugins.vala
@@ -112,7 +112,7 @@ private Gee.HashSet<string> core_ids;
 
 public void init() throws Error {
     search_dirs = new File[0];
-    unowned string plugin_dir = Environment.get_variable("SHOTWELL_PLUGIN_PATH");
+    unowned string plugin_dir = Environment.get_variable("SHOTWELL_PLUGIN_DIR");
     if (plugin_dir != null && plugin_dir != "") {
         search_dirs += File.new_for_commandline_arg(plugin_dir);
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]