[gitg] Add diff preferences



commit d65f02532f9ddac41a4f4963d9766b8cffae8951
Author: Jesse van den Kieboom <jessevdk gnome org>
Date:   Thu Dec 31 01:54:55 2015 +0100

    Add diff preferences

 gitg/Makefile.am                              |    1 +
 gitg/preferences/gitg-preferences-dialog.vala |    1 +
 gitg/preferences/gitg-preferences-diff.vala   |  104 +++++++++++++
 gitg/resources/gitg-resources.xml.in          |    2 +-
 gitg/resources/ui/gitg-preferences-diff.ui    |  192 +++++++++++++++++++++++++
 po/POTFILES.in                                |    2 +
 po/POTFILES.skip                              |    1 +
 7 files changed, 302 insertions(+), 1 deletions(-)
---
diff --git a/gitg/Makefile.am b/gitg/Makefile.am
index cba3577..e57c41a 100644
--- a/gitg/Makefile.am
+++ b/gitg/Makefile.am
@@ -98,6 +98,7 @@ gitg_gitg_VALASOURCES =                                               \
        gitg/history/gitg-history.vala                          \
        gitg/preferences/gitg-preferences-commit.vala           \
        gitg/preferences/gitg-preferences-dialog.vala           \
+       gitg/preferences/gitg-preferences-diff.vala             \
        gitg/preferences/gitg-preferences-history.vala          \
        gitg/preferences/gitg-preferences-interface.vala        \
        libgitg-ext/libgitg-ext-1.0.vapi                        \
diff --git a/gitg/preferences/gitg-preferences-dialog.vala b/gitg/preferences/gitg-preferences-dialog.vala
index c013b9f..84a47ed 100644
--- a/gitg/preferences/gitg-preferences-dialog.vala
+++ b/gitg/preferences/gitg-preferences-dialog.vala
@@ -67,6 +67,7 @@ class PreferencesDialog : Gtk.Dialog, Gtk.Buildable
                add_page(new PreferencesInterface(), pages);
                add_page(new PreferencesHistory(), pages);
                add_page(new PreferencesCommit(), pages);
+               add_page(new PreferencesDiff(), pages);
 
                ext.foreach((s, info, e) => {
                        add_page(e as GitgExt.Preferences, pages);
diff --git a/gitg/preferences/gitg-preferences-diff.vala b/gitg/preferences/gitg-preferences-diff.vala
new file mode 100644
index 0000000..3b5bd0b
--- /dev/null
+++ b/gitg/preferences/gitg-preferences-diff.vala
@@ -0,0 +1,104 @@
+/*
+ * This file is part of gitg
+ *
+ * Copyright (C) 2015 - 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/>.
+ */
+
+[GtkTemplate (ui = "/org/gnome/gitg/ui/gitg-preferences-diff.ui")]
+public class Gitg.PreferencesDiff : Gtk.Grid, GitgExt.Preferences
+{
+       // Do this to pull in config.h before glib.h (for gettext...)
+       private const string version = Gitg.Config.VERSION;
+
+       [GtkChild (name = "check_button_wrap_lines")]
+       private Gtk.CheckButton d_check_button_wrap_lines;
+
+       [GtkChild (name = "check_button_ignore_whitespace_changes")]
+       private Gtk.CheckButton d_check_button_ignore_whitespace_changes;
+
+       [GtkChild (name = "spin_button_tab_width")]
+       private Gtk.SpinButton d_spin_button_tab_width;
+
+       [GtkChild (name = "spin_button_context_lines")]
+       private Gtk.SpinButton d_spin_button_context_lines;
+
+       construct
+       {
+               var settings = new Settings("org.gnome.gitg.preferences.diff");
+
+               settings.bind("wrap",
+                             d_check_button_wrap_lines,
+                             "active",
+                             SettingsBindFlags.GET | SettingsBindFlags.SET);
+
+               settings.bind("ignore-whitespace",
+                             d_check_button_ignore_whitespace_changes,
+                             "active",
+                             SettingsBindFlags.GET | SettingsBindFlags.SET);
+
+               settings.bind_with_mapping("context-lines",
+                                          d_spin_button_context_lines.adjustment,
+                                          "value",
+                                          SettingsBindFlags.GET | SettingsBindFlags.SET,
+                       (value, variant) => {
+                               value.set_double(variant.get_int32());
+                               return true;
+                       },
+
+                       (value, expected_type) => {
+                               return new Variant.int32((int32)value.get_double());
+                       },
+
+                       null, null
+               );
+
+               settings.bind_with_mapping("tab-width",
+                                          d_spin_button_tab_width.adjustment,
+                                          "value",
+                                          SettingsBindFlags.GET | SettingsBindFlags.SET,
+                       (value, variant) => {
+                               value.set_double(variant.get_int32());
+                               return true;
+                       },
+
+                       (value, expected_type) => {
+                               return new Variant.int32((int32)value.get_double());
+                       },
+
+                       null, null
+               );
+       }
+
+       public Gtk.Widget widget
+       {
+               owned get
+               {
+                       return this;
+               }
+       }
+
+       public string id
+       {
+               owned get { return "/org/gnome/gitg/Preferences/Diff"; }
+       }
+
+       public string display_name
+       {
+               owned get { return C_("Preferences", "Diff"); }
+       }
+}
+
+// vi:ts=4
diff --git a/gitg/resources/gitg-resources.xml.in b/gitg/resources/gitg-resources.xml.in
index ed48baa..3d1fb5e 100644
--- a/gitg/resources/gitg-resources.xml.in
+++ b/gitg/resources/gitg-resources.xml.in
@@ -5,7 +5,7 @@
     <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-commit.ui</file>
-
+    <file compressed="true" preprocess="xml-stripblanks">ui/gitg-preferences-diff.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>
diff --git a/gitg/resources/ui/gitg-preferences-diff.ui b/gitg/resources/ui/gitg-preferences-diff.ui
new file mode 100644
index 0000000..f6f11f7
--- /dev/null
+++ b/gitg/resources/ui/gitg-preferences-diff.ui
@@ -0,0 +1,192 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.3 -->
+<interface>
+  <requires lib="gtk+" version="3.12"/>
+  <template class="GitgPreferencesDiff" parent="GtkGrid">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="hexpand">True</property>
+    <property name="vexpand">True</property>
+    <property name="border_width">12</property>
+    <property name="row_spacing">18</property>
+    <property name="column_spacing">18</property>
+    <child>
+      <object class="GtkGrid" id="grid_settings">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="hexpand">True</property>
+        <property name="row_spacing">6</property>
+        <child>
+          <object class="GtkLabel" id="label_spacing">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="halign">start</property>
+            <property name="label" translatable="yes">Spacing</property>
+            <attributes>
+              <attribute name="weight" value="bold"/>
+            </attributes>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkGrid" id="grid_spacing">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="margin_start">12</property>
+            <property name="hexpand">True</property>
+            <property name="row_spacing">6</property>
+            <property name="column_spacing">6</property>
+            <child>
+              <object class="GtkLabel" id="label_wrap_lines">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">Wrap lines:</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkCheckButton" id="check_button_wrap_lines">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="halign">start</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label_ignore_whitespace_changes">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">Ignore whitespace changes:</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkCheckButton" id="check_button_ignore_whitespace_changes">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="halign">start</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label_tab_width">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">Tab width:</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkSpinButton" id="spin_button_tab_width">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="halign">start</property>
+                <property name="adjustment">adjustment_tab_width</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">2</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label_context">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="halign">start</property>
+            <property name="label" translatable="yes">Context</property>
+            <property name="margin_top">12</property>
+            <attributes>
+              <attribute name="weight" value="bold"/>
+            </attributes>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkGrid" id="grid_context">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="margin_start">12</property>
+            <property name="hexpand">True</property>
+            <property name="row_spacing">6</property>
+            <property name="column_spacing">6</property>
+            <child>
+              <object class="GtkLabel" id="label_context_lines">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">Context lines:</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkSpinButton" id="spin_button_context_lines">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="halign">start</property>
+                <property name="adjustment">adjustment_context_lines</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">0</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">3</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="top_attach">0</property>
+      </packing>
+    </child>
+  </template>
+  <object class="GtkAdjustment" id="adjustment_tab_width">
+    <property name="lower">1</property>
+    <property name="upper">16</property>
+    <property name="value">4</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">4</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment_context_lines">
+    <property name="upper">12</property>
+    <property name="value">3</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">3</property>
+  </object>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 1db2072..bfb1ed6 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -29,6 +29,7 @@ gitg/history/gitg-history-command-line.vala
 gitg/history/gitg-history-refs-list.vala
 gitg/history/gitg-history.vala
 gitg/preferences/gitg-preferences-commit.vala
+gitg/preferences/gitg-preferences-diff.vala
 gitg/preferences/gitg-preferences-history.vala
 gitg/preferences/gitg-preferences-interface.vala
 libgitg/gitg-date.vala
@@ -51,6 +52,7 @@ plugins/files/gitg-files.vala
 [type: gettext/glade]gitg/resources/ui/gitg-history-paned.ui
 [type: gettext/glade]gitg/resources/ui/gitg-menus.ui
 [type: gettext/glade]gitg/resources/ui/gitg-preferences-commit.ui
+[type: gettext/glade]gitg/resources/ui/gitg-preferences-diff.ui
 [type: gettext/glade]gitg/resources/ui/gitg-preferences-history.ui
 [type: gettext/glade]gitg/resources/ui/gitg-preferences-interface.ui
 [type: gettext/glade]gitg/resources/ui/gitg-preferences.ui
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index 9807321..1a7de8c 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -28,6 +28,7 @@ gitg/history/gitg-history.c
 gitg/history/gitg-history-command-line.c
 gitg/history/gitg-history-refs-list.c
 gitg/preferences/gitg-preferences-commit.c
+gitg/preferences/gitg-preferences-diff.c
 gitg/preferences/gitg-preferences-history.c
 gitg/preferences/gitg-preferences-interface.c
 libgitg/gitg-authentication-dialog.c


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