mirror of
https://gitlab.gnome.org/GNOME/gitg
synced 2024-06-30 23:29:33 +00:00
Compare commits
12 Commits
e2119e239f
...
387e7f626d
Author | SHA1 | Date | |
---|---|---|---|
|
387e7f626d | ||
|
7121d995ee | ||
|
c11411a992 | ||
|
b921968bd7 | ||
|
ca07a21850 | ||
|
8a2206ad4a | ||
|
0286ec88d7 | ||
|
04a4bd4c2c | ||
|
30dd1292b7 | ||
|
b87e34813d | ||
|
dfd3f3b61e | ||
|
e9835559bd |
|
@ -591,7 +591,17 @@ namespace GitgHistory
|
|||
|
||||
d_main.commit_list_view.model = d_commit_list_model;
|
||||
|
||||
d_main.commit_list_view.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE);
|
||||
d_main.commit_list_view.get_selection().changed.connect((sel) => {
|
||||
Gtk.TreePath commit_cursor_path;
|
||||
d_main.commit_list_view.get_cursor(out commit_cursor_path, null);
|
||||
var selected_commits_count = sel.count_selected_rows();
|
||||
if(selected_commits_count > 2)
|
||||
{
|
||||
sel.unselect_all();
|
||||
sel.select_path(commit_cursor_path);
|
||||
}
|
||||
|
||||
selection_changed();
|
||||
|
||||
// Set primary selection to sha1 of first selected commit
|
||||
|
@ -721,17 +731,19 @@ namespace GitgHistory
|
|||
|
||||
private Gdk.Rectangle? on_commit_list_request_menu_position()
|
||||
{
|
||||
var selection = d_main.commit_list_view.get_selection();
|
||||
|
||||
Gtk.TreeModel model;
|
||||
Gtk.TreeIter iter;
|
||||
Gtk.TreePath path;
|
||||
|
||||
if (!selection.get_selected(out model, out iter))
|
||||
path = d_main.commit_list_view.get_path_at_focused();
|
||||
if(path == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var path = model.get_path(iter);
|
||||
if (!d_commit_list_model.get_iter(out iter, path))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Gdk.Rectangle rect = { 0 };
|
||||
|
||||
|
@ -814,11 +826,16 @@ namespace GitgHistory
|
|||
|
||||
private Gtk.Menu? popup_menu_for_selection()
|
||||
{
|
||||
var selection = d_main.commit_list_view.get_selection();
|
||||
|
||||
Gtk.TreeIter iter;
|
||||
Gtk.TreePath path;
|
||||
|
||||
if (!selection.get_selected(null, out iter))
|
||||
path = d_main.commit_list_view.get_path_at_focused();
|
||||
if(path == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!d_commit_list_model.get_iter(out iter, path))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -862,7 +879,19 @@ namespace GitgHistory
|
|||
return null;
|
||||
}
|
||||
|
||||
d_main.commit_list_view.get_selection().select_path(path);
|
||||
var selection = d_main.commit_list_view.get_selection();
|
||||
|
||||
// Only unselect the selected paths, instead of unselecting all commits
|
||||
var selected_paths = selection.get_selected_rows(null);
|
||||
foreach(var selected_path in selected_paths)
|
||||
{
|
||||
if(selected_path != null)
|
||||
{
|
||||
selection.unselect_path(selected_path);
|
||||
}
|
||||
}
|
||||
|
||||
selection.select_path(path);
|
||||
|
||||
return populate_menu_for_commit(commit);
|
||||
}
|
||||
|
|
|
@ -120,6 +120,31 @@ namespace Gitg
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Gtk.TreePath? get_path_at_focused()
|
||||
{
|
||||
var selection = get_selection();
|
||||
|
||||
if(selection.count_selected_rows() == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Gtk.TreePath path;
|
||||
|
||||
get_cursor(out path, null);
|
||||
|
||||
if(!selection.path_is_selected(path))
|
||||
{
|
||||
path = (Gtk.TreePath) selection.get_selected_rows(null).nth_data(0);
|
||||
if(path == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -158,6 +158,37 @@ public class Commit : Ggit.Commit
|
|||
return diff;
|
||||
}
|
||||
|
||||
public Ggit.Diff get_diff_with_commit(Ggit.DiffOptions? options, Commit commit)
|
||||
{
|
||||
var repo = get_owner();
|
||||
Ggit.Diff? diff = null;
|
||||
try
|
||||
{
|
||||
diff = new Ggit.Diff.tree_to_tree(repo,
|
||||
commit.get_tree(),
|
||||
get_tree(),
|
||||
options);
|
||||
}
|
||||
catch(Error e)
|
||||
{
|
||||
stderr.printf("Error when getting diff:%s\n", e.message);
|
||||
}
|
||||
|
||||
if(diff != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
diff.find_similar(null);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return diff;
|
||||
}
|
||||
|
||||
public Ggit.Note get_note()
|
||||
{
|
||||
Ggit.Note note = null;
|
||||
|
|
107
libgitg/gitg-diff-view-commits-holder.vala
Normal file
107
libgitg/gitg-diff-view-commits-holder.vala
Normal file
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
* This file is part of gitg
|
||||
*
|
||||
* Copyright (C) 2020 - Mahmoud Ahmed Khalil
|
||||
*
|
||||
* 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 DiffViewCommitsHolder : Object
|
||||
{
|
||||
private Commit? d_first_commit;
|
||||
private Commit? d_second_commit;
|
||||
private uint d_commits_counter;
|
||||
|
||||
public uint commits_counter
|
||||
{
|
||||
get { return d_commits_counter; }
|
||||
}
|
||||
|
||||
public Commit? first_commit
|
||||
{
|
||||
get { return d_first_commit; }
|
||||
}
|
||||
|
||||
public Commit? second_commit
|
||||
{
|
||||
get { return d_second_commit; }
|
||||
}
|
||||
|
||||
construct
|
||||
{
|
||||
clear_commits();
|
||||
}
|
||||
|
||||
public void clear_commits()
|
||||
{
|
||||
d_first_commit = null;
|
||||
d_second_commit = null;
|
||||
d_commits_counter = 0;
|
||||
}
|
||||
|
||||
public bool append_commit(Commit c)
|
||||
{
|
||||
if(d_commits_counter >= 2 || c == null)
|
||||
return false;
|
||||
|
||||
if(d_commits_counter == 0)
|
||||
{
|
||||
d_first_commit = c;
|
||||
}
|
||||
else if(d_commits_counter == 1)
|
||||
{
|
||||
d_second_commit = c;
|
||||
}
|
||||
|
||||
d_commits_counter++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Ggit.Diff? get_diff(Ggit.DiffOptions? options, Ggit.Commit parent_commit)
|
||||
{
|
||||
Ggit.Diff? diff = null;
|
||||
|
||||
if(d_commits_counter == 1)
|
||||
{
|
||||
int parent = 0;
|
||||
var parents = d_first_commit.get_parents();
|
||||
|
||||
if (parent_commit != null)
|
||||
{
|
||||
for (var i = 0; i < parents.size; i++)
|
||||
{
|
||||
var id = parents.get_id(i);
|
||||
|
||||
if (id.equal(parent_commit.get_id()))
|
||||
{
|
||||
parent = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
diff = d_first_commit.get_diff(options, parent);
|
||||
}
|
||||
else if(d_commits_counter == 2)
|
||||
{
|
||||
diff = d_first_commit.get_diff_with_commit(options, d_second_commit);
|
||||
}
|
||||
|
||||
return diff;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -41,8 +41,10 @@ public class Gitg.DiffView : Gtk.Grid
|
|||
[GtkChild( name = "text_view_message" )]
|
||||
private unowned Gtk.TextView d_text_view_message;
|
||||
|
||||
public delegate void UpdateCommitsCallback(Gitg.DiffViewCommitsHolder holder);
|
||||
|
||||
private Ggit.Diff? d_diff;
|
||||
private Commit? d_commit;
|
||||
private Gitg.DiffViewCommitsHolder d_commits_holder;
|
||||
private Ggit.DiffOptions? d_options;
|
||||
private Cancellable d_cancellable;
|
||||
private ulong d_expanded_notify;
|
||||
|
@ -85,31 +87,21 @@ public class Gitg.DiffView : Gtk.Grid
|
|||
if (d_diff != value)
|
||||
{
|
||||
d_diff = value;
|
||||
d_commit = null;
|
||||
d_commits_holder.clear_commits();
|
||||
}
|
||||
|
||||
update(false);
|
||||
}
|
||||
}
|
||||
|
||||
public Commit? commit
|
||||
public Gitg.Commit? commit
|
||||
{
|
||||
get { return d_commit; }
|
||||
set
|
||||
{
|
||||
if (d_commit != value)
|
||||
{
|
||||
d_commit = value;
|
||||
d_diff = null;
|
||||
}
|
||||
|
||||
update(false);
|
||||
}
|
||||
get { return d_commits_holder.first_commit; }
|
||||
}
|
||||
|
||||
public virtual signal void options_changed()
|
||||
{
|
||||
if (d_commit != null)
|
||||
if (d_commits_holder.commits_counter != 0)
|
||||
{
|
||||
update(true);
|
||||
}
|
||||
|
@ -234,6 +226,19 @@ public class Gitg.DiffView : Gtk.Grid
|
|||
base.dispose();
|
||||
}
|
||||
|
||||
public void update_diff_view(UpdateCommitsCallback func)
|
||||
{
|
||||
d_commits_holder.clear_commits();
|
||||
|
||||
if(func != null)
|
||||
{
|
||||
func(d_commits_holder);
|
||||
}
|
||||
d_diff = null;
|
||||
|
||||
update(false);
|
||||
}
|
||||
|
||||
private void parent_commit_changed()
|
||||
{
|
||||
update(false);
|
||||
|
@ -272,6 +277,7 @@ public class Gitg.DiffView : Gtk.Grid
|
|||
construct
|
||||
{
|
||||
context_lines = 3;
|
||||
d_commits_holder = new DiffViewCommitsHolder();
|
||||
}
|
||||
|
||||
private string message_without_subject(Commit commit)
|
||||
|
@ -525,9 +531,9 @@ public class Gitg.DiffView : Gtk.Grid
|
|||
private void update(bool preserve_expanded)
|
||||
{
|
||||
|
||||
// If both `d_diff` and `d_commit` are null, clear
|
||||
// If `d_diff` is null, and `d_commits_holder.commits_counter` is zero, clear
|
||||
// the diff content
|
||||
if (d_diff == null && d_commit == null)
|
||||
if (d_diff == null && d_commits_holder.commits_counter == 0)
|
||||
{
|
||||
d_commit_details.hide();
|
||||
d_scrolledwindow.hide();
|
||||
|
@ -541,35 +547,16 @@ public class Gitg.DiffView : Gtk.Grid
|
|||
d_cancellable.cancel();
|
||||
d_cancellable = new Cancellable();
|
||||
|
||||
if (d_commit != null)
|
||||
if (d_commits_holder.commits_counter != 0)
|
||||
{
|
||||
SignalHandler.block(d_commit_details, d_parent_commit_notify);
|
||||
d_commit_details.commit = d_commit;
|
||||
d_commit_details.commit = d_commits_holder.first_commit;
|
||||
SignalHandler.unblock(d_commit_details, d_parent_commit_notify);
|
||||
|
||||
int parent = 0;
|
||||
var parents = d_commit.get_parents();
|
||||
|
||||
var parent_commit = d_commit_details.parent_commit;
|
||||
|
||||
if (parent_commit != null)
|
||||
{
|
||||
for (var i = 0; i < parents.size; i++)
|
||||
{
|
||||
var id = parents.get_id(i);
|
||||
|
||||
if (id.equal(parent_commit.get_id()))
|
||||
{
|
||||
parent = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
d_diff = d_commit.get_diff(options, parent);
|
||||
d_diff = d_commits_holder.get_diff(options, d_commit_details.parent_commit);
|
||||
d_commit_details.show();
|
||||
|
||||
var message = message_without_subject(d_commit);
|
||||
var message = message_without_subject(d_commits_holder.first_commit);
|
||||
|
||||
d_text_view_message.buffer.set_text(message);
|
||||
var buffer = d_text_view_message.get_buffer();
|
||||
|
|
|
@ -40,6 +40,7 @@ sources = files(
|
|||
'gitg-diff-selectable.vala',
|
||||
'gitg-diff-stat.vala',
|
||||
'gitg-diff-view-commit-details.vala',
|
||||
'gitg-diff-view-commits-holder.vala',
|
||||
'gitg-diff-view-file-info.vala',
|
||||
'gitg-diff-view-file-renderer-binary.vala',
|
||||
'gitg-diff-view-file-renderer-image.vala',
|
||||
|
|
|
@ -132,28 +132,20 @@ namespace GitgDiff
|
|||
|
||||
private void on_selection_changed(GitgExt.History history)
|
||||
{
|
||||
var hasset = false;
|
||||
d_whenMapped.update(() => {
|
||||
d_diff.update_diff_view((holder) => {
|
||||
history.foreach_selected((commit) => {
|
||||
var c = commit as Gitg.Commit;
|
||||
|
||||
history.foreach_selected((commit) => {
|
||||
var c = commit as Gitg.Commit;
|
||||
if(c != null)
|
||||
{
|
||||
return holder.append_commit(c);
|
||||
}
|
||||
|
||||
if (c != null)
|
||||
{
|
||||
d_whenMapped.update(() => {
|
||||
d_diff.commit = c;
|
||||
hasset = true;
|
||||
}, this);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
if (!hasset)
|
||||
{
|
||||
d_diff.commit = null;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
});
|
||||
}, this);
|
||||
}
|
||||
|
||||
public Gtk.Widget? widget
|
||||
|
|
29
po/uk.po
29
po/uk.po
|
@ -8,8 +8,8 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: gitg\n"
|
||||
"Report-Msgid-Bugs-To: https://gitlab.gnome.org/GNOME/gitg/issues\n"
|
||||
"POT-Creation-Date: 2024-04-01 21:44+0000\n"
|
||||
"PO-Revision-Date: 2024-04-02 09:42+0300\n"
|
||||
"POT-Creation-Date: 2024-06-19 10:42+0000\n"
|
||||
"PO-Revision-Date: 2024-06-20 18:38+0300\n"
|
||||
"Last-Translator: Yuri Chornoivan <yurchor@ukr.net>\n"
|
||||
"Language-Team: Ukrainian\n"
|
||||
"Language: uk\n"
|
||||
|
@ -18,7 +18,7 @@ msgstr ""
|
|||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=4; plural=n==1 ? 3 : n%10==1 && n%100!=11 ? 0 : n"
|
||||
"%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
|
||||
"X-Generator: Lokalize 23.04.1\n"
|
||||
"X-Generator: Lokalize 23.04.3\n"
|
||||
|
||||
#: contrib/xml/xml-reader.c:327
|
||||
#, c-format
|
||||
|
@ -999,8 +999,8 @@ msgstr "Перевизначення загальних параметрів с
|
|||
msgid ""
|
||||
"Disable override will clean existing local author details. Are you sure?"
|
||||
msgstr ""
|
||||
"Вимикання перевизначення призведе до вилучення наявних локальних даних щодо"
|
||||
" авторства. Ви впевнені?"
|
||||
"Вимикання перевизначення призведе до вилучення наявних локальних даних щодо "
|
||||
"авторства. Ви впевнені?"
|
||||
|
||||
# Не вдалося створити тег
|
||||
#: gitg/gitg-author-details-dialog.vala:228
|
||||
|
@ -1619,7 +1619,7 @@ msgstr "Вибрати елементи"
|
|||
msgid "“%s” is not a Git repository."
|
||||
msgstr "«%s» — не сховище Git."
|
||||
|
||||
#: gitg/gitg-window.vala:1245
|
||||
#: gitg/gitg-window.vala:1243
|
||||
msgid ""
|
||||
"Your user name and email are not configured yet. Please go to the user "
|
||||
"configuration and provide your name and email."
|
||||
|
@ -1627,7 +1627,7 @@ msgstr ""
|
|||
"Ще не налаштовано користувача та пошту. Перейдіть у користувацькі параметри "
|
||||
"і вкажіть їх."
|
||||
|
||||
#: gitg/gitg-window.vala:1249
|
||||
#: gitg/gitg-window.vala:1247
|
||||
msgid ""
|
||||
"Your user name is not configured yet. Please go to the user configuration "
|
||||
"and provide your name."
|
||||
|
@ -1635,7 +1635,7 @@ msgstr ""
|
|||
"Ще не налаштовано користувача. Перейдіть у користувацькі параметри і вкажіть "
|
||||
"його."
|
||||
|
||||
#: gitg/gitg-window.vala:1253
|
||||
#: gitg/gitg-window.vala:1251
|
||||
msgid ""
|
||||
"Your email is not configured yet. Please go to the user configuration and "
|
||||
"provide your email."
|
||||
|
@ -1643,7 +1643,7 @@ msgstr ""
|
|||
"Ще не налаштовано пошту. Перейдіть у користувацькі параметри і вкажіть її."
|
||||
|
||||
# Детальна інформація
|
||||
#: gitg/gitg-window.vala:1256
|
||||
#: gitg/gitg-window.vala:1254
|
||||
msgid "Missing author details"
|
||||
msgstr "Немає подробиць щодо автора"
|
||||
|
||||
|
@ -2349,6 +2349,16 @@ msgstr "Знайти слово або фразу"
|
|||
msgid "General settings and options"
|
||||
msgstr "Загальні параметри"
|
||||
|
||||
#: gitg/resources/ui/gitg-window.ui:266
|
||||
#| msgctxt "shortcut window"
|
||||
#| msgid "Move to previous search result"
|
||||
msgid "Previous result"
|
||||
msgstr "Попередній результат"
|
||||
|
||||
#: gitg/resources/ui/gitg-window.ui:282
|
||||
msgid "Next result"
|
||||
msgstr "Наступний результат"
|
||||
|
||||
#. Translators: %s will be replaced with a URL indicating the resource
|
||||
#. for which the authentication is required.
|
||||
#: libgitg/gitg-authentication-dialog.vala:69
|
||||
|
@ -2466,7 +2476,6 @@ msgstr "<small>Авторство</small> %s"
|
|||
#: libgitg/gitg-diff-view-commit-details.vala:243
|
||||
#: libgitg/gitg-diff-view-commit-details.vala:247
|
||||
#, c-format
|
||||
#| msgid "Committed by %s"
|
||||
msgid "<small>Committed by</small> %s"
|
||||
msgstr "<small>Внесено</small> %s"
|
||||
|
||||
|
|
|
@ -115,7 +115,9 @@ class TestDiffView
|
|||
v.show();
|
||||
sw.add(v);
|
||||
|
||||
v.commit = commit;
|
||||
v.update_diff_view((holder) => {
|
||||
holder.append_commit(commit);
|
||||
});
|
||||
|
||||
wnd.delete_event.connect((w, ev) => {
|
||||
Gtk.main_quit();
|
||||
|
|
Loading…
Reference in New Issue
Block a user