[gitg] Implement expand/collapse all
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Implement expand/collapse all
- Date: Wed, 23 Sep 2015 06:58:08 +0000 (UTC)
commit 898af292648921c7836703261993a06cc1e08ff8
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Wed Aug 26 19:54:35 2015 +0200
Implement expand/collapse all
libgitg/gitg-diff-view-commit-details.vala | 18 +++---
libgitg/gitg-diff-view.vala | 49 +++++++++++++++++-
.../resources/ui/gitg-diff-view-commit-details.ui | 52 +++++++++++---------
libgitg/resources/ui/gitg-diff-view-file.ui | 1 +
4 files changed, 85 insertions(+), 35 deletions(-)
---
diff --git a/libgitg/gitg-diff-view-commit-details.vala b/libgitg/gitg-diff-view-commit-details.vala
index 00b87d6..bd50e78 100644
--- a/libgitg/gitg-diff-view-commit-details.vala
+++ b/libgitg/gitg-diff-view-commit-details.vala
@@ -58,15 +58,6 @@ class Gitg.DiffViewCommitDetails : Gtk.Grid
if (d_expander_files.expanded != value)
{
d_expander_files.expanded = value;
-
- if (value)
- {
- d_expander_files.label = _("Collapse all");
- }
- else
- {
- d_expander_files.label = _("Expand all");
- }
}
}
}
@@ -132,6 +123,15 @@ class Gitg.DiffViewCommitDetails : Gtk.Grid
construct
{
d_expander_files.notify["expanded"].connect(() => {
+ if (d_expander_files.expanded)
+ {
+ d_expander_files.label = _("Collapse all");
+ }
+ else
+ {
+ d_expander_files.label = _("Expand all");
+ }
+
notify_property("expanded");
});
}
diff --git a/libgitg/gitg-diff-view.vala b/libgitg/gitg-diff-view.vala
index 95e76a9..9974558 100644
--- a/libgitg/gitg-diff-view.vala
+++ b/libgitg/gitg-diff-view.vala
@@ -201,6 +201,23 @@ public class Gitg.DiffView : Gtk.Grid
default = 3;
}
+ private ulong d_expanded_notify;
+
+ protected override void constructed()
+ {
+ d_expanded_notify = d_commit_details.notify["expanded"].connect(update_expanded_files);
+ }
+
+ private void update_expanded_files()
+ {
+ var expanded = d_commit_details.expanded;
+
+ foreach (var file in d_grid_files.get_children())
+ {
+ (file as Gitg.DiffViewFile).expanded = expanded;
+ }
+ }
+
private void update_wrap()
{
}
@@ -262,10 +279,16 @@ public class Gitg.DiffView : Gtk.Grid
private delegate void Anon();
- private void update_diff(Ggit.Diff diff, Cancellable? cancellable)
+ private void auto_change_expanded(bool expanded)
{
- var files = new Gee.LinkedList<Gitg.DiffViewFile>();
+ SignalHandler.block(d_commit_details, d_expanded_notify);
+ d_commit_details.expanded = expanded;
+ SignalHandler.unblock(d_commit_details, d_expanded_notify);
+ }
+ private void update_diff(Ggit.Diff diff, Cancellable? cancellable)
+ {
+ var files = new Gee.ArrayList<Gitg.DiffViewFile>();
Gitg.DiffViewFile? current_file = null;
Ggit.DiffHunk? current_hunk = null;
Gee.ArrayList<Ggit.DiffLine>? current_lines = null;
@@ -288,7 +311,6 @@ public class Gitg.DiffView : Gtk.Grid
if (current_file != null)
{
current_file.show();
- d_grid_files.add(current_file);
files.add(current_file);
@@ -357,10 +379,31 @@ public class Gitg.DiffView : Gtk.Grid
add_hunk();
add_file();
+ d_commit_details.expanded = (files.size <= 1);
+
foreach (var file in files)
{
+ file.expanded = d_commit_details.expanded;
file.maxlines = maxlines;
+
+ d_grid_files.add(file);
+
+ file.notify["expanded"].connect(auto_update_expanded);
+ }
+ }
+
+ private void auto_update_expanded()
+ {
+ foreach (var file in d_grid_files.get_children())
+ {
+ if (!(file as Gitg.DiffViewFile).expanded)
+ {
+ auto_change_expanded(false);
+ return;
+ }
}
+
+ auto_change_expanded(true);
}
public async PatchSet[] get_selection()
diff --git a/libgitg/resources/ui/gitg-diff-view-commit-details.ui
b/libgitg/resources/ui/gitg-diff-view-commit-details.ui
index d9cddc5..df1bccd 100644
--- a/libgitg/resources/ui/gitg-diff-view-commit-details.ui
+++ b/libgitg/resources/ui/gitg-diff-view-commit-details.ui
@@ -5,6 +5,7 @@
<template class="GitgDiffViewCommitDetails" parent="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
<child>
<object class="GtkGrid" id="grid_inner">
<property name="visible">True</property>
@@ -129,24 +130,6 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label_sha1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">end</property>
- <property name="valign">start</property>
- <property name="label">0000000000000000000000000000000000000000</property>
- <property name="selectable">True</property>
- <property name="ellipsize">end</property>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">3</property>
- </packing>
- </child>
- <child>
<object class="GtkGrid" id="grid_parents_container">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -187,26 +170,49 @@
<property name="width">2</property>
</packing>
</child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkGrid" id="grid_bottom">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">horizontal</property>
+ <property name="margin_start">3</property>
+ <property name="margin_end">12</property>
+ <property name="margin_top">12</property>
+ <property name="margin_bottom">6</property>
<child>
<object class="GtkExpander" id="expander_files">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="valign">baseline</property>
+ <property name="hexpand">True</property>
<child type="label">
<object class="GtkLabel" id="label_expand_collapse_files">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">Collapse all</property>
+ <property name="label" translatable="yes">Expand all</property>
</object>
</child>
<style>
<class name="dim-label"/>
</style>
</object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">3</property>
- </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_sha1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="valign">start</property>
+ <property name="hexpand">True</property>
+ <property name="label">0000000000000000000000000000000000000000</property>
+ <property name="selectable">True</property>
+ <property name="ellipsize">end</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
</child>
</object>
</child>
diff --git a/libgitg/resources/ui/gitg-diff-view-file.ui b/libgitg/resources/ui/gitg-diff-view-file.ui
index ba07b3d..fed5076 100644
--- a/libgitg/resources/ui/gitg-diff-view-file.ui
+++ b/libgitg/resources/ui/gitg-diff-view-file.ui
@@ -15,6 +15,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
+ <property name="margin_start">3</property>
<child type="label">
<object class="GtkGrid" id="grid_file_header">
<property name="visible">True</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]