[gitg] Add revealer with diff options
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Add revealer with diff options
- Date: Wed, 30 Dec 2015 22:29:36 +0000 (UTC)
commit c8d8a0ef8c33daca6550b2aa67030a80fad1cc21
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Wed Dec 30 23:29:19 2015 +0100
Add revealer with diff options
libgitg/gitg-diff-view-file.vala | 2 +-
libgitg/gitg-diff-view-options.vala | 261 ++++++++++++--------
libgitg/gitg-diff-view.vala | 109 ++++++---
libgitg/resources/resources.xml | 1 +
.../resources/ui/gitg-diff-view-options-spacing.ui | 95 +++++++
libgitg/resources/ui/gitg-diff-view-options.ui | 179 ++++----------
libgitg/resources/ui/gitg-diff-view.ui | 45 +++-
libgitg/resources/ui/libgitg-style.css | 9 +
plugins/diff/gitg-diff.vala | 6 +-
9 files changed, 433 insertions(+), 274 deletions(-)
---
diff --git a/libgitg/gitg-diff-view-file.vala b/libgitg/gitg-diff-view-file.vala
index ccf360d..757e4ad 100644
--- a/libgitg/gitg-diff-view-file.vala
+++ b/libgitg/gitg-diff-view-file.vala
@@ -72,7 +72,7 @@ class Gitg.DiffViewFile : Gtk.Grid
}
}
- public bool wrap
+ public bool wrap_lines
{
get { return d_sourceview_hunks.wrap_mode != Gtk.WrapMode.NONE; }
set
diff --git a/libgitg/gitg-diff-view-options.vala b/libgitg/gitg-diff-view-options.vala
index bd24591..3ff92a3 100644
--- a/libgitg/gitg-diff-view-options.vala
+++ b/libgitg/gitg-diff-view-options.vala
@@ -17,142 +17,205 @@
* along with gitg. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Gitg
-{
-
[GtkTemplate ( ui = "/org/gnome/gitg/ui/gitg-diff-view-options.ui" )]
-public class DiffViewOptions : Gtk.Grid
+public class Gitg.DiffViewOptions : Gtk.Toolbar
{
- [GtkChild (name = "switch_changes_inline")]
- private Gtk.Switch d_switch_changes_inline;
-
- [GtkChild (name = "label_changes_inline")]
- private Gtk.Label d_label_changes_inline;
+ [GtkChild (name = "adjustment_context")]
+ private Gtk.Adjustment d_adjustment_context;
- [GtkChild (name = "switch_ignore_whitespace")]
- private Gtk.Switch d_switch_ignore_whitespace;
+ [GtkChild (name = "tool_button_spacing")]
+ private Gtk.ToolButton d_tool_button_spacing;
- [GtkChild (name = "label_ignore_whitespace")]
- private Gtk.Label d_label_ignore_whitespace;
+ public int context_lines { get; set; }
- [GtkChild (name = "wrap")]
- private Gtk.Switch d_switch_wrap;
+ private Gee.List<Binding> d_bindings;
+ private DiffView? d_view;
+ private ulong d_notify_commit_id;
- [GtkChild (name = "adjustment_context")]
- private Gtk.Adjustment d_adjustment_context;
+ private DiffViewOptionsSpacing d_popover_spacing;
- [GtkChild (name = "adjustment_tab_width")]
- private Gtk.Adjustment d_adjustment_tab_width;
+ public DiffView? view
+ {
+ get { return d_view; }
- [GtkChild (name = "separator_first_options")]
- private Gtk.Separator d_separator_first_options;
+ construct set
+ {
+ if (d_view == value)
+ {
+ return;
+ }
- public bool changes_inline { get; set; }
- public bool ignore_whitespace { get; set; }
- public bool wrap { get; set; }
- public int context_lines { get; set; }
- public int tab_width { get; set; }
+ var old_view = d_view;
+ d_view = value;
- public DiffView view { get; construct set; }
+ view_changed(old_view);
+ }
+ }
- public DiffViewOptions(DiffView view)
+ public DiffViewOptions(DiffView? view = null)
{
Object(view: view);
}
- private bool transform_double_to_int(Binding binding,
- Value source_value,
- ref Value target_value)
+ construct
{
- target_value.set_int((int)source_value.get_double());
- return true;
+ d_bindings = new Gee.LinkedList<Binding>();
+
+ d_popover_spacing = new DiffViewOptionsSpacing();
+ d_popover_spacing.relative_to = d_tool_button_spacing;
}
- private bool transform_int_to_double(Binding binding,
- Value source_value,
- ref Value target_value)
+ public override void dispose()
{
- target_value.set_double((double)source_value.get_int());
- return true;
+ this.view = null;
+ base.dispose();
}
- protected override void constructed()
+ private void view_changed(DiffView? old_view)
{
- view.bind_property("changes-inline",
- this,
- "changes-inline",
- BindingFlags.BIDIRECTIONAL |
- BindingFlags.SYNC_CREATE);
-
- view.bind_property("ignore-whitespace",
- this,
- "ignore-whitespace",
- BindingFlags.BIDIRECTIONAL |
- BindingFlags.SYNC_CREATE);
-
- view.bind_property("wrap",
- this,
- "wrap",
- BindingFlags.BIDIRECTIONAL |
- BindingFlags.SYNC_CREATE);
-
- view.bind_property("context-lines",
- this,
- "context-lines",
- BindingFlags.BIDIRECTIONAL |
- BindingFlags.SYNC_CREATE);
-
- view.bind_property("tab-width",
- this,
- "tab-width",
- BindingFlags.BIDIRECTIONAL |
- BindingFlags.SYNC_CREATE);
-
- bind_property("changes-inline",
- d_switch_changes_inline,
- "active",
- BindingFlags.BIDIRECTIONAL |
- BindingFlags.SYNC_CREATE);
+ foreach (var binding in d_bindings)
+ {
+ binding.unbind();
+ }
- bind_property("ignore-whitespace",
- d_switch_ignore_whitespace,
- "active",
- BindingFlags.BIDIRECTIONAL |
- BindingFlags.SYNC_CREATE);
+ d_bindings.clear();
- bind_property("wrap",
- d_switch_wrap,
- "active",
- BindingFlags.BIDIRECTIONAL |
- BindingFlags.SYNC_CREATE);
+ if (d_notify_commit_id != 0)
+ {
+ old_view.disconnect(d_notify_commit_id);
+ d_notify_commit_id = 0;
+ }
+
+ if (d_view == null)
+ {
+ update_commit();
+ return;
+ }
+
+ d_bindings.add(
+ d_view.bind_property("ignore-whitespace",
+ d_popover_spacing,
+ "ignore-whitespace",
+ BindingFlags.BIDIRECTIONAL | BindingFlags.SYNC_CREATE)
+ );
+
+ d_bindings.add(
+ d_view.bind_property("wrap-lines",
+ d_popover_spacing,
+ "wrap-lines",
+ BindingFlags.BIDIRECTIONAL | BindingFlags.SYNC_CREATE)
+ );
+
+ d_bindings.add(
+ d_view.bind_property("tab-width",
+ d_popover_spacing,
+ "tab-width",
+ BindingFlags.BIDIRECTIONAL | BindingFlags.SYNC_CREATE)
+ );
+
+ d_bindings.add(
+ d_view.bind_property("context-lines",
+ this,
+ "context-lines",
+ BindingFlags.BIDIRECTIONAL | BindingFlags.SYNC_CREATE)
+ );
+
+ d_notify_commit_id = d_view.notify["commit"].connect(update_commit);
+
+ update_commit();
+ }
+
+ private void update_commit()
+ {
+ var iscommit = d_view != null && d_view.commit != null;
+ d_popover_spacing.ignore_whitespace_visible = iscommit;
+ }
+ protected override void constructed()
+ {
bind_property("context-lines",
d_adjustment_context,
"value",
BindingFlags.BIDIRECTIONAL |
BindingFlags.SYNC_CREATE,
- transform_int_to_double,
- transform_double_to_int);
+ Transforms.int_to_double,
+ Transforms.double_to_int);
+ }
+
+ [GtkCallback]
+ private void clicked_on_tool_button_spacing(Gtk.Widget widget)
+ {
+ d_popover_spacing.show();
+ }
+}
+
+[GtkTemplate ( ui = "/org/gnome/gitg/ui/gitg-diff-view-options-spacing.ui" )]
+private class Gitg.DiffViewOptionsSpacing : Gtk.Popover
+{
+ [GtkChild (name = "switch_ignore_whitespace")]
+ private Gtk.Switch d_switch_ignore_whitespace;
+
+ [GtkChild (name = "label_ignore_whitespace")]
+ private Gtk.Label d_label_ignore_whitespace;
+
+ [GtkChild (name = "switch_wrap_lines")]
+ private Gtk.Switch d_switch_wrap_lines;
+
+ [GtkChild (name = "adjustment_tab_width")]
+ private Gtk.Adjustment d_adjustment_tab_width;
+
+ public bool ignore_whitespace { get; set; }
+ public bool wrap_lines { get; set; }
+ public int tab_width { get; set; }
+
+ public bool ignore_whitespace_visible { get; set; }
+
+ protected override void constructed()
+ {
+ bind_property("ignore-whitespace",
+ d_switch_ignore_whitespace,
+ "active",
+ BindingFlags.BIDIRECTIONAL | BindingFlags.SYNC_CREATE);
+
+ bind_property("wrap-lines",
+ d_switch_wrap_lines,
+ "active",
+ BindingFlags.BIDIRECTIONAL | BindingFlags.SYNC_CREATE);
bind_property("tab-width",
d_adjustment_tab_width,
"value",
- BindingFlags.BIDIRECTIONAL |
- BindingFlags.SYNC_CREATE,
- transform_int_to_double,
- transform_double_to_int);
+ BindingFlags.BIDIRECTIONAL | BindingFlags.SYNC_CREATE,
+ Transforms.int_to_double,
+ Transforms.double_to_int);
- if (view.commit == null)
- {
- d_label_changes_inline.visible = false;
- d_switch_changes_inline.visible = false;
-
- d_label_ignore_whitespace.visible = false;
- d_switch_ignore_whitespace.visible = false;
+ bind_property("ignore-whitespace-visible",
+ d_switch_ignore_whitespace,
+ "visible",
+ BindingFlags.BIDIRECTIONAL | BindingFlags.SYNC_CREATE);
- d_separator_first_options.visible = false;
- }
+ bind_property("ignore-whitespace-visible",
+ d_label_ignore_whitespace,
+ "visible",
+ BindingFlags.BIDIRECTIONAL | BindingFlags.SYNC_CREATE);
}
}
+private class Gitg.Transforms
+{
+ public static bool double_to_int(Binding binding,
+ Value source_value,
+ ref Value target_value)
+ {
+ target_value.set_int((int)source_value.get_double());
+ return true;
+ }
+
+ public static bool int_to_double(Binding binding,
+ Value source_value,
+ ref Value target_value)
+ {
+ target_value.set_double((double)source_value.get_int());
+ return true;
+ }
}
diff --git a/libgitg/gitg-diff-view.vala b/libgitg/gitg-diff-view.vala
index d8bfa3e..c30c036 100644
--- a/libgitg/gitg-diff-view.vala
+++ b/libgitg/gitg-diff-view.vala
@@ -29,6 +29,15 @@ public class Gitg.DiffView : Gtk.Grid
[GtkChild( name = "grid_files" )]
private Gtk.Grid d_grid_files;
+ [GtkChild( name = "event_box" )]
+ private Gtk.EventBox d_event_box;
+
+ [GtkChild( name = "revealer_options" )]
+ private Gtk.Revealer d_revealer_options;
+
+ [GtkChild( name = "diff_view_options" )]
+ private DiffViewOptions d_diff_view_options;
+
private Ggit.Diff? d_diff;
private Commit? d_commit;
private Ggit.DiffOptions? d_options;
@@ -37,6 +46,9 @@ public class Gitg.DiffView : Gtk.Grid
private ulong d_parent_commit_notify;
private bool d_changes_inline;
+ private uint d_reveal_options_timeout;
+ private uint d_unreveal_options_timeout;
+
public Ggit.DiffOptions options
{
get
@@ -93,7 +105,7 @@ public class Gitg.DiffView : Gtk.Grid
}
}
- public bool wrap { get; construct set; default = true; }
+ public bool wrap_lines { get; construct set; default = true; }
public bool staged { get; set; default = false; }
public bool unstaged { get; set; default = false; }
public bool show_parents { get; set; default = false; }
@@ -172,6 +184,9 @@ public class Gitg.DiffView : Gtk.Grid
d_parent_commit_notify =
d_commit_details.notify["parent-commit"].connect(parent_commit_changed);
bind_property("use-gravatar", d_commit_details, "use-gravatar", BindingFlags.SYNC_CREATE);
+
+ d_event_box.motion_notify_event.connect(motion_notify_event_on_event_box);
+ d_diff_view_options.view = this;
}
private void parent_commit_changed()
@@ -389,7 +404,7 @@ public class Gitg.DiffView : Gtk.Grid
file.notify["expanded"].connect(auto_update_expanded);
- this.bind_property("wrap", file, "wrap", BindingFlags.DEFAULT |
BindingFlags.SYNC_CREATE);
+ this.bind_property("wrap-lines", file, "wrap-lines", BindingFlags.DEFAULT |
BindingFlags.SYNC_CREATE);
this.bind_property("tab-width", file, "tab-width", BindingFlags.DEFAULT |
BindingFlags.SYNC_CREATE);
if (i == files.size - 1)
@@ -433,49 +448,85 @@ public class Gitg.DiffView : Gtk.Grid
}
}
- private void do_popup(Gdk.EventButton? event)
+ private void update_hide_show_options(Gdk.Window window, int ex, int ey)
{
- var popover = new Gtk.Popover(this);
- var opts = new DiffViewOptions(this);
+ void *data;
+ window.get_user_data(out data);
- popover.add(opts);
+ var w = data as Gtk.Widget;
- if (event != null)
+ if (w == null)
{
- var r = Gdk.Rectangle() {
- x = (int)event.x,
- y = (int)event.y,
- width = 1,
- height = 1
- };
-
- popover.set_pointing_to(r);
+ return;
}
- opts.show();
- popover.show();
+ int x, y;
+ w.translate_coordinates(d_event_box, ex, ey, out x, out y);
+
+ Gtk.Allocation alloc, revealer_alloc;
+
+ d_event_box.get_allocation(out alloc);
+ d_revealer_options.get_allocation(out revealer_alloc);
- popover.notify["visible"].connect(() => {
- popover.destroy();
- });
+ if (!d_revealer_options.reveal_child && y >= alloc.height - 18 && d_reveal_options_timeout ==
0)
+ {
+ if (d_unreveal_options_timeout != 0)
+ {
+ Source.remove(d_unreveal_options_timeout);
+ d_unreveal_options_timeout = 0;
+ }
+
+ d_reveal_options_timeout = Timeout.add(300, () => {
+ d_reveal_options_timeout = 0;
+ d_revealer_options.reveal_child = true;
+ return false;
+ });
+ }
+ else if (d_revealer_options.reveal_child)
+ {
+ var above = (y <= alloc.height - 6 - revealer_alloc.height);
+
+ if (above && d_unreveal_options_timeout == 0)
+ {
+ if (d_reveal_options_timeout != 0)
+ {
+ Source.remove(d_reveal_options_timeout);
+ d_reveal_options_timeout = 0;
+ }
+
+ d_unreveal_options_timeout = Timeout.add(1000, () => {
+ d_unreveal_options_timeout = 0;
+ d_revealer_options.reveal_child = false;
+ return false;
+ });
+ }
+ else if (!above && d_unreveal_options_timeout != 0)
+ {
+ Source.remove(d_unreveal_options_timeout);
+ d_unreveal_options_timeout = 0;
+ }
+ }
}
[GtkCallback]
- private bool button_press_event_handler(Gdk.EventButton event)
+ private bool leave_notify_event_on_event_box(Gtk.Widget widget, Gdk.EventCrossing event)
{
- if (event.triggers_context_menu() && event.type == Gdk.EventType.BUTTON_PRESS)
- {
- do_popup(event);
- return true;
- }
+ update_hide_show_options(event.window, (int)event.x, (int)event.y);
+ return false;
+ }
+ [GtkCallback]
+ private bool enter_notify_event_on_event_box(Gtk.Widget widget, Gdk.EventCrossing event)
+ {
+ update_hide_show_options(event.window, (int)event.x, (int)event.y);
return false;
}
- protected override bool popup_menu()
+ [GtkCallback]
+ private bool motion_notify_event_on_event_box(Gtk.Widget widget, Gdk.EventMotion event)
{
- do_popup(null);
- return true;
+ update_hide_show_options(event.window, (int)event.x, (int)event.y);
+ return false;
}
}
diff --git a/libgitg/resources/resources.xml b/libgitg/resources/resources.xml
index f946de7..60e63be 100644
--- a/libgitg/resources/resources.xml
+++ b/libgitg/resources/resources.xml
@@ -6,6 +6,7 @@
<file compressed="true" preprocess="xml-stripblanks">ui/gitg-diff-view.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/gitg-diff-view-file.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/gitg-diff-view-options.ui</file>
+ <file compressed="true" preprocess="xml-stripblanks">ui/gitg-diff-view-options-spacing.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/gitg-diff-view-commit-details.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/gitg-sidebar.ui</file>
diff --git a/libgitg/resources/ui/gitg-diff-view-options-spacing.ui
b/libgitg/resources/ui/gitg-diff-view-options-spacing.ui
new file mode 100644
index 0000000..31a0f92
--- /dev/null
+++ b/libgitg/resources/ui/gitg-diff-view-options-spacing.ui
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="3.12"/>
+ <template class="GitgDiffViewOptionsSpacing" parent="GtkPopover">
+ <property name="visible">False</property>
+ <property name="can_focus">False</property>
+ <property name="position">bottom</property>
+ <child>
+ <object class="GtkGrid" id="grid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
+ <property name="margin">12</property>
+ <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">0</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">0</property>
+ </packing>
+ </child>
+ <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">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="switch_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">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_ignore_whitespace">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">Ignore whitespace:</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="switch_ignore_whitespace">
+ <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">2</property>
+ </packing>
+ </child>
+ </object>
+ </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>
+</interface>
diff --git a/libgitg/resources/ui/gitg-diff-view-options.ui b/libgitg/resources/ui/gitg-diff-view-options.ui
index 7d301c3..3b05377 100644
--- a/libgitg/resources/ui/gitg-diff-view-options.ui
+++ b/libgitg/resources/ui/gitg-diff-view-options.ui
@@ -2,163 +2,74 @@
<!-- Generated with glade 3.18.1 -->
<interface>
<requires lib="gtk+" version="3.12"/>
- <object class="GtkAdjustment" id="adjustment_context">
- <property name="upper">12</property>
- <property name="value">3</property>
- <property name="step_increment">1</property>
- <property name="page_increment">3</property>
- </object>
- <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>
- <template class="GitgDiffViewOptions" parent="GtkGrid">
+ <template class="GitgDiffViewOptions" parent="GtkToolbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="border_width">12</property>
- <property name="row_spacing">12</property>
- <property name="column_spacing">12</property>
- <child>
- <object class="GtkSwitch" id="switch_ignore_whitespace">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="halign">center</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">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="hexpand">True</property>
- <property name="label" translatable="yes">Ignore whitespace changes</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkSwitch" id="switch_changes_inline">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="halign">center</property>
- <property name="hexpand">False</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label_changes_inline">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="hexpand">True</property>
- <property name="label" translatable="yes">Show changes inline</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkSwitch" id="wrap">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="halign">center</property>
- <property name="hexpand">False</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">2</property>
- </packing>
- </child>
<child>
- <object class="GtkLabel" id="label_wrap">
+ <object class="GtkSeparatorToolItem" id="separator_tool_item1">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="hexpand">True</property>
- <property name="label" translatable="yes">Wrap lines</property>
+ <property name="draw">False</property>
</object>
<packing>
- <property name="left_attach">0</property>
- <property name="top_attach">2</property>
+ <property name="expand">True</property>
</packing>
</child>
<child>
- <object class="GtkSeparator" id="separator_first_options">
+ <object class="GtkToolItem" id="tool_item_context">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <child>
+ <object class="GtkGrid" id="grid_context">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="column_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label_context">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Context:</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">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="adjustment">adjustment_context</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
</object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">3</property>
- <property name="width">2</property>
- </packing>
</child>
<child>
- <object class="GtkLabel" id="label_context1">
+ <object class="GtkSeparatorToolItem" id="separator_tool_item2">
<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">5</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="adjustment">adjustment_tab_width</property>
- <property name="snap_to_ticks">True</property>
- <property name="numeric">True</property>
- <property name="value">4</property>
</object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">5</property>
- </packing>
</child>
<child>
- <object class="GtkLabel" id="label_context">
+ <object class="GtkToolButton" id="tool_button_spacing">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="hexpand">True</property>
- <property name="label" translatable="yes">Context</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">4</property>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="spin_button_context">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="input_purpose">digits</property>
- <property name="adjustment">adjustment_context</property>
- <property name="snap_to_ticks">True</property>
- <property name="numeric">True</property>
- <property name="value">3</property>
+ <property name="label" translatable="yes">Spacing</property>
+ <property name="use_underline">True</property>
+ <signal name="clicked" handler="clicked_on_tool_button_spacing"/>
</object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">4</property>
- </packing>
</child>
</template>
+ <object class="GtkAdjustment" id="adjustment_context">
+ <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/libgitg/resources/ui/gitg-diff-view.ui b/libgitg/resources/ui/gitg-diff-view.ui
index 64b2ee0..76df5ec 100644
--- a/libgitg/resources/ui/gitg-diff-view.ui
+++ b/libgitg/resources/ui/gitg-diff-view.ui
@@ -2,13 +2,12 @@
<!-- Generated with glade 3.19.0 -->
<interface>
<requires lib="gtk+" version="3.16"/>
- <template class="GitgDiffView" parent="GtkGrid">
+ <template class="GitgDiffView">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
- <signal name="button-press-event" handler="button_press_event_handler" />
<child>
<object class="GitgDiffViewCommitDetails" id="commit_details">
<property name="visible">True</property>
@@ -17,21 +16,55 @@
</object>
</child>
<child>
- <object class="GtkScrolledWindow" id="scrolledwindow">
+ <object class="GtkEventBox" id="event_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
+ <signal name="motion-notify-event" handler="motion_notify_event_on_event_box"/>
+ <signal name="leave-notify-event" handler="leave_notify_event_on_event_box"/>
+ <signal name="enter-notify-event" handler="enter_notify_event_on_event_box"/>
<child>
- <object class="GtkViewport" id="viewport">
+ <object class="GtkOverlay" id="overlay">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
<child>
- <object class="GtkGrid" id="grid_files">
+ <object class="GtkScrolledWindow" id="scrolledwindow">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <child>
+ <object class="GtkViewport" id="viewport">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkGrid" id="grid_files">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="overlay">
+ <object class="GtkRevealer" id="revealer_options">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="valign">end</property>
+ <child>
+ <object class="GitgDiffViewOptions" id="diff_view_options">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ </object>
+ </child>
</object>
</child>
</object>
diff --git a/libgitg/resources/ui/libgitg-style.css b/libgitg/resources/ui/libgitg-style.css
index 20b7441..37eb778 100644
--- a/libgitg/resources/ui/libgitg-style.css
+++ b/libgitg/resources/ui/libgitg-style.css
@@ -93,3 +93,12 @@ GitgDiffStat.no-frame.removed-only,
GitgDiffStat.no-frame.added-only {
border-radius: 3px;
}
+
+GitgDiffViewOptions GtkSpinButton,
+GitgDiffViewOptions GtkButton {
+ padding: 3px 6px 3px 6px;
+}
+
+GitgDiffViewOptions {
+ border-top: 1px solid @borders;
+}
diff --git a/plugins/diff/gitg-diff.vala b/plugins/diff/gitg-diff.vala
index fb03617..bf3e385 100644
--- a/plugins/diff/gitg-diff.vala
+++ b/plugins/diff/gitg-diff.vala
@@ -66,7 +66,7 @@ namespace GitgDiff
settings.bind("wrap",
d_diff,
- "wrap",
+ "wrap-lines",
SettingsBindFlags.GET |
SettingsBindFlags.SET);
@@ -78,10 +78,6 @@ namespace GitgDiff
SettingsBindFlags.GET |
SettingsBindFlags.SET);
- d_diff.notify["visible"].connect(() => {
- stdout.printf(@"visible: $(d_diff.visible)\n");
- });
-
d_whenMapped = new Gitg.WhenMapped(d_diff);
d_selection_changed_id = history.selection_changed.connect(on_selection_changed);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]