[gitg/wip/simplify-arch: 7/7] Move history to core



commit 5b37e305128760e8f2d704a6d9751a234b751cd6
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Mon Jul 1 09:30:30 2013 +0200

    Move history to core

 configure.ac                                       |    2 -
 data/org.gnome.gitg.gschema.xml.in.in              |   68 ++++++----
 gitg/Makefile.am                                   |    3 +
 .../history/gitg-history-navigation.vala           |   15 +--
 {plugins => gitg}/history/gitg-history.vala        |   42 ++----
 gitg/preferences/gitg-preferences-history.vala     |  144 ++++++++++++++++++++
 gitg/resources/gitg-resources.xml                  |    2 +
 .../resources/ui/gitg-preferences-history.ui       |    0
 .../resources/ui/gitg-view-history.ui              |    0
 plugins/Makefile.am                                |    2 +-
 plugins/history/Makefile.am                        |   61 --------
 plugins/history/gitg-history-command-line.vala     |   47 -------
 plugins/history/gitg-history-preferences.vala      |  141 -------------------
 plugins/history/history.plugin                     |   12 --
 .../org.gnome.gitg.history.gschema.xml.in.in       |   61 --------
 plugins/history/resources/resources.xml            |    9 --
 16 files changed, 204 insertions(+), 405 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 1a3fa4e..7c250d0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -294,8 +294,6 @@ data/org.gnome.gitg.gschema.xml.in
 po/Makefile.in
 tests/Makefile
 plugins/Makefile
-plugins/history/Makefile
-plugins/history/org.gnome.gitg.history.gschema.xml.in
 plugins/diff/Makefile
 plugins/diff/icons/Makefile
 plugins/files/Makefile
diff --git a/data/org.gnome.gitg.gschema.xml.in.in b/data/org.gnome.gitg.gschema.xml.in.in
index e0b2bef..8e67a45 100644
--- a/data/org.gnome.gitg.gschema.xml.in.in
+++ b/data/org.gnome.gitg.gschema.xml.in.in
@@ -6,6 +6,7 @@
 
   <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gitg.preferences" 
path="/org/gnome/gitg/preferences/">
     <child name="main" schema="org.gnome.gitg.preferences.main" />
+    <child name="history" schema="org.gnome.gitg.preferences.history" />
     <child name="commit" schema="org.gnome.gitg.preferences.commit" />
     <child name="diff" schema="org.gnome.gitg.preferences.diff" />
     <child name="hidden" schema="org.gnome.gitg.preferences.hidden" />
@@ -16,59 +17,59 @@
       <!-- TODO: add _descriptions -->
     </key>
   </schema>
-  <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gitg.preferences.view.history" 
path="/org/gnome/gitg/preferences/view/history/">
-    <key name="search-filter" type="b">
-      <default>false</default>
-      <_summary>Filter Revisions When Searching</_summary>
+  <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gitg.preferences.interface" 
path="/org/gnome/gitg/preferences/interface/">
+    <key name="orientation" enum="org.gnome.gitg.Layout">
+      <default>'vertical'</default>
+      <_summary>Orientation of the main interface (vertical or horizontal)</_summary>
       <_description>
-        Whether searching filters the revisions in the history view instead of 
-        jumping to the first match.
+        Setting that sets the orientation of the main interface.
       </_description>
     </key>
+  </schema>
+  <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gitg.preferences.history" 
path="/org/gnome/gitg/preferences/history/">
     <key name="collapse-inactive-lanes" type="i">
       <default>2</default>
       <_summary>When to Collapse Inactive Lanes</_summary>
       <_description>
-        Setting that indicates when an inactive lane should be collapsed. 
+        Setting that indicates when an inactive lane should be collapsed.
         Valid values are 0 - 4, where 0 indicates 'early' and 4 indicates 'late'.
       </_description>
     </key>
-    <key name="collapse-inactive-lanes-active" type="b">
+    <key name="collapse-inactive-lanes-enabled" type="b">
       <default>true</default>
-      <!-- TODO: add _descriptions -->
+      <_description>
+        Setting that indicates whether to collapse history lanes which do not
+        show activity. Enabling this can provide a cleaner history view when
+        there is a lot of parallel development. See collapse-inactive-lanes
+        to control when lanes should be collapsed.
+      </_description>
     </key>
-    <key name="topo-order" type="b">
+    <key name="topological-order" type="b">
       <default>false</default>
       <_summary>Show History in Topological Order</_summary>
       <_description>
         Setting that indicates whether to show the history in topological order.
       </_description>
     </key>
-    <key name="show-virtual-stash" type="b">
+    <key name="show-stash" type="b">
       <default>true</default>
-      <!-- TODO: add _descriptions -->
+      <_description>
+        Setting that indicates whether to show items for the stash in the
+        history.
+      </_description>
     </key>
-    <key name="show-virtual-staged" type="b">
+    <key name="show-staged" type="b">
       <default>true</default>
-      <!-- TODO: add _descriptions -->
+      <_description>
+         Setting that indicates whether to show a virtual item for the currently
+         staged changes in the history.
+      </_description>
     </key>
-    <key name="show-virtual-unstaged" type="b">
+    <key name="show-unstaged" type="b">
       <default>true</default>
-      <!-- TODO: add _descriptions -->
-    </key>
-  </schema>
-  <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gitg.preferences.view.main" 
path="/org/gnome/gitg/preferences/view/main/">
-    <key name="clone-directory" type="s">
-      <default>""</default>
-      <!-- TODO: add _descriptions -->
-    </key>
-  </schema>
-  <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gitg.preferences.interface" 
path="/org/gnome/gitg/preferences/interface/">
-    <key name="orientation" enum="org.gnome.gitg.Layout">
-      <default>'vertical'</default>
-      <_summary>Orientation of the main interface (vertical or horizontal)</_summary>
       <_description>
-        Setting that sets the orientation of the main interface.
+         Setting that indicates whether to show a virtual item for the currently
+         unstaged changes in the history.
       </_description>
     </key>
   </schema>
@@ -111,6 +112,7 @@
   </schema>
   <schema id="org.gnome.gitg.state" path="/org/gnome/gitg/state/">
     <child name="window" schema="org.gnome.gitg.state.window"/>
+    <child name="history" schema="org.gnome.gitg.state.history"/>
   </schema>
   <schema id="org.gnome.gitg.state.window" path="/org/gnome/gitg/state/window/">
     <key name="state" type="i">
@@ -132,4 +134,12 @@
       <default>200</default>
     </key>
   </schema>
+  <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gitg.state.history" 
path="/org/gnome/gitg/state/history/">
+    <key name="paned-views-position" type="i">
+      <default>200</default>
+    </key>
+    <key name="paned-panels-position" type="i">
+      <default>450</default>
+    </key>
+  </schema>
 </schemalist>
diff --git a/gitg/Makefile.am b/gitg/Makefile.am
index 5fbe790..3edefb5 100644
--- a/gitg/Makefile.am
+++ b/gitg/Makefile.am
@@ -43,6 +43,9 @@ VALASOURCES =                                                 \
        gitg-ui-elements.vala                                   \
        preferences/gitg-preferences-dialog.vala                \
        preferences/gitg-preferences-interface.vala             \
+       preferences/gitg-preferences-history.vala               \
+       history/gitg-history.vala                               \
+       history/gitg-history-navigation.vala
 
 BUILT_SOURCES =                                                \
        gitg-resources.c                                        \
diff --git a/plugins/history/gitg-history-navigation.vala b/gitg/history/gitg-history-navigation.vala
similarity index 98%
rename from plugins/history/gitg-history-navigation.vala
rename to gitg/history/gitg-history-navigation.vala
index c74b780..c0c26e7 100644
--- a/plugins/history/gitg-history-navigation.vala
+++ b/gitg/history/gitg-history-navigation.vala
@@ -187,14 +187,7 @@ namespace GitgHistory
 
                        begin_section();
 
-                       if (CommandLine.all)
-                       {
-                               append_default(_("All commits"), null, null, (nc) => activate_ref(null));
-                       }
-                       else
-                       {
-                               append_normal(_("All commits"), null, null, (nc) => activate_ref(null));
-                       }
+                       append_normal(_("All commits"), null, null, (nc) => activate_ref(null));
 
                        // Branches
                        begin_header(_("Branches"), null);
@@ -210,11 +203,7 @@ namespace GitgHistory
                                        if (branch.is_head())
                                        {
                                                icon = "object-select-symbolic";
-
-                                               if (!CommandLine.all)
-                                               {
-                                                       isdef = true;
-                                               }
+                                               isdef = true;
                                        }
                                }
                                catch {}
diff --git a/plugins/history/gitg-history.vala b/gitg/history/gitg-history.vala
similarity index 89%
rename from plugins/history/gitg-history.vala
rename to gitg/history/gitg-history.vala
index 9665a2a..f9249e0 100644
--- a/plugins/history/gitg-history.vala
+++ b/gitg/history/gitg-history.vala
@@ -22,7 +22,7 @@ namespace GitgHistory
        /* The main history view. This view shows the equivalent of git log, but
         * in a nice way with lanes, merges, ref labels etc.
         */
-       public class View : Object, GitgExt.UIElement, GitgExt.View, GitgExt.ObjectSelection
+       public class View : Object, GitgExt.UIElement, GitgExt.View, GitgExt.History
        {
                // Do this to pull in config.h before glib.h (for gettext...)
                private const string version = Gitg.Config.VERSION;
@@ -63,7 +63,7 @@ namespace GitgHistory
                        }
                }
 
-               public void foreach_selected(GitgExt.ForeachObjectSelectionFunc func)
+               public void foreach_selected(GitgExt.ForeachCommitSelectionFunc func)
                {
                        bool breakit = false;
 
@@ -77,7 +77,7 @@ namespace GitgHistory
 
                construct
                {
-                       d_settings = new Settings("org.gnome.gitg.history.preferences");
+                       d_settings = new Settings("org.gnome.gitg.preferences.history");
                        d_settings.changed["topological-order"].connect((s, k) => {
                                update_sort_mode();
                        });
@@ -151,11 +151,7 @@ namespace GitgHistory
 
                public bool available
                {
-                       get
-                       {
-                               // The history view is available only when there is a repository
-                               return application.repository != null;
-                       }
+                       get { return true; }
                }
 
                public string display_name
@@ -191,7 +187,7 @@ namespace GitgHistory
                        update_walker(n, r);
                }
 
-               public void on_view_activated()
+               public void activate()
                {
                        d_navigation.expand_all();
                        d_navigation.select_first();
@@ -200,9 +196,11 @@ namespace GitgHistory
                public void reload()
                {
                        double vadj = d_navigation.get_vadjustment().get_value();
+
                        d_navigation_model.reload();
                        d_navigation.expand_all();
                        d_navigation.select();
+
                        d_navigation.size_allocate.connect((a) => {
                                d_navigation.get_vadjustment().set_value(vadj);
                        });
@@ -229,6 +227,7 @@ namespace GitgHistory
 
                        d_commit_list = ret["commit_list_view"] as Gtk.TreeView;
                        d_commit_list.model = d_commit_list_model;
+
                        d_commit_list.get_selection().changed.connect((sel) => {
                                selection_changed();
                        });
@@ -236,17 +235,20 @@ namespace GitgHistory
                        (ret["renderer_commit_list_author"] as Gd.StyledTextRenderer).add_class("dim-label");
                        (ret["renderer_commit_list_author_date"] as 
Gd.StyledTextRenderer).add_class("dim-label");
 
-                       var state_settings = new Settings("org.gnome.gitg.history.state");
+                       var state_settings = new Settings("org.gnome.gitg.state.history");
+
                        state_settings.bind("paned-views-position",
                                            d_main,
                                            "position",
                                            SettingsBindFlags.GET | SettingsBindFlags.SET);
+
                        state_settings.bind("paned-panels-position",
                                            d_paned_panels,
                                            "position",
                                            SettingsBindFlags.GET | SettingsBindFlags.SET);
 
                        var interface_settings = new Settings("org.gnome.gitg.preferences.interface");
+
                        interface_settings.bind("orientation",
                                                  d_paned_panels,
                                                  "orientation",
@@ -311,10 +313,7 @@ namespace GitgHistory
 
                public bool enabled
                {
-                       get
-                       {
-                               return true;
-                       }
+                       get { return true; }
                }
 
                public int negotiate_order(GitgExt.UIElement other)
@@ -324,19 +323,4 @@ namespace GitgHistory
        }
 }
 
-[ModuleInit]
-public void peas_register_types(TypeModule module)
-{
-       Peas.ObjectModule mod = module as Peas.ObjectModule;
-
-       mod.register_extension_type(typeof(GitgExt.View),
-                                   typeof(GitgHistory.View));
-
-       mod.register_extension_type(typeof(GitgExt.CommandLine),
-                                   typeof(GitgHistory.CommandLine));
-
-       mod.register_extension_type(typeof(GitgExt.Preferences),
-                                   typeof(GitgHistory.Preferences));
-}
-
 // ex: ts=4 noet
diff --git a/gitg/preferences/gitg-preferences-history.vala b/gitg/preferences/gitg-preferences-history.vala
new file mode 100644
index 0000000..b0fa59d
--- /dev/null
+++ b/gitg/preferences/gitg-preferences-history.vala
@@ -0,0 +1,144 @@
+/*
+ * This file is part of gitg
+ *
+ * Copyright (C) 2012 - Jesse van den Kieboom
+ *
+ * gitg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * gitg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with gitg. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Gitg
+{
+
+public class PreferencesHistory : Object, GitgExt.Preferences
+{
+       // Do this to pull in config.h before glib.h (for gettext...)
+       private const string version = Gitg.Config.VERSION;
+
+       private Gtk.Widget? d_widget;
+       private bool d_block;
+
+       private void bind_check(Settings settings, string setting, Object obj)
+       {
+               settings.bind(setting,
+                             obj,
+                             "active",
+                             SettingsBindFlags.GET |
+                             SettingsBindFlags.SET);
+       }
+
+       private static int round_val(double val)
+       {
+               int ival = (int)val;
+
+               return ival + (int)(val - ival > 0.5);
+       }
+
+       private Gtk.Widget build_ui()
+       {
+               if (d_widget != null)
+               {
+                       return d_widget;
+               }
+
+               var settings = new Settings("org.gnome.gitg.preferences.history");
+
+               var ret = GitgExt.UI.from_builder("ui/gitg-preferences-history.ui",
+                                                 "main",
+                                                 "collapse_inactive_lanes_enabled",
+                                                 "collapse_inactive_lanes",
+                                                 "topological_order",
+                                                 "show_stash",
+                                                 "show_staged",
+                                                 "show_unstaged");
+
+               d_widget = ret["main"] as Gtk.Widget;
+
+               bind_check(settings,
+                          "collapse-inactive-lanes-enabled",
+                          ret["collapse_inactive_lanes_enabled"]);
+
+               bind_check(settings, "topological-order", ret["topological_order"]);
+               bind_check(settings, "show-stash", ret["show_stash"]);
+               bind_check(settings, "show-staged", ret["show_staged"]);
+               bind_check(settings, "show-unstaged", ret["show_unstaged"]);
+
+               var collapse = ret["collapse_inactive_lanes"] as Gtk.Scale;
+
+               collapse.get_adjustment().value_changed.connect((adj) => {
+                       if (d_block)
+                       {
+                               return;
+                       }
+
+                       var nval = round_val(adj.get_value());
+                       var val = settings.get_int("collapse-inactive-lanes");
+
+                       if (val != nval)
+                       {
+                               settings.set_int("collapse-inactive-lanes", nval);
+                       }
+
+                       d_block = true;
+                       adj.set_value(nval);
+                       d_block = false;
+               });
+
+               var monsig = settings.changed["collapse-inactive-lanes"].connect((s, k) => {
+                       d_block = true;
+                       update_collapse_inactive_lanes(settings, collapse);
+                       d_block = false;
+               });
+
+               d_widget.destroy.connect((w) => {
+                       settings.disconnect(monsig);
+               });
+
+               update_collapse_inactive_lanes(settings, collapse);
+
+               return d_widget;
+       }
+
+       private static void update_collapse_inactive_lanes(Settings settings, Gtk.Scale collapse)
+       {
+               var val = round_val(collapse.get_value());
+               var nval = settings.get_int("collapse-inactive-lanes");
+
+               if (val != nval)
+               {
+                       collapse.set_value((double)nval);
+               }
+       }
+
+       public Gtk.Widget widget
+       {
+               owned get
+               {
+                       return build_ui();
+               }
+       }
+
+       public string id
+       {
+               owned get { return "/org/gnome/gitg/Preferences/History"; }
+       }
+
+       public string display_name
+       {
+               owned get { return _("History"); }
+       }
+}
+
+}
+
+// vi:ts=4
diff --git a/gitg/resources/gitg-resources.xml b/gitg/resources/gitg-resources.xml
index d9b745e..398a127 100644
--- a/gitg/resources/gitg-resources.xml
+++ b/gitg/resources/gitg-resources.xml
@@ -3,10 +3,12 @@
   <gresource prefix="/org/gnome/gitg">
     <file compressed="true" preprocess="xml-stripblanks">ui/gitg-window.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">ui/gitg-menus.ui</file>
+    <file compressed="true" preprocess="xml-stripblanks">ui/gitg-preferences-history.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">ui/gitg-preferences-interface.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">ui/gitg-preferences.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">ui/gitg-clone-dialog.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">ui/gitg-user-dialog.ui</file>
+    <file compressed="true" preprocess="xml-stripblanks">ui/gitg-view-history.ui</file>
     <file compressed="true">ui/style.css</file>
     <file alias="icons/gitg.svg" compressed="true" 
preprocess="xml-stripblanks">../../data/icons/gitg.svg</file>
     <file alias="icons/gitg128x128.png">../../data/icons/gitg128x128.png</file>
diff --git a/plugins/history/resources/preferences.ui b/gitg/resources/ui/gitg-preferences-history.ui
similarity index 100%
rename from plugins/history/resources/preferences.ui
rename to gitg/resources/ui/gitg-preferences-history.ui
diff --git a/plugins/history/resources/view-history.ui b/gitg/resources/ui/gitg-view-history.ui
similarity index 100%
rename from plugins/history/resources/view-history.ui
rename to gitg/resources/ui/gitg-view-history.ui
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index d1fccaf..d3665db 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -1,3 +1,3 @@
-SUBDIRS = history diff files
+SUBDIRS = diff files
 
 -include $(top_srcdir)/git.mk


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