mirror of
https://gitlab.gnome.org/GNOME/gitg
synced 2024-07-05 01:19:31 +00:00
Implement expand/collapse all
This commit is contained in:
parent
c1205431cd
commit
898af29264
|
@ -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");
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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 auto_change_expanded(bool expanded)
|
||||
{
|
||||
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.LinkedList<Gitg.DiffViewFile>();
|
||||
|
||||
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,12 +379,33 @@ 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()
|
||||
{
|
||||
// TODO
|
||||
|
|
|
@ -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>
|
||||
|
@ -128,24 +129,6 @@
|
|||
<property name="width">2</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="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>
|
||||
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue
Block a user