[gitg/gnome-3-20] Disable commit context items if there is no real selection
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg/gnome-3-20] Disable commit context items if there is no real selection
- Date: Thu, 25 Aug 2016 14:53:54 +0000 (UTC)
commit c0edb613e7b214e8ac18686b1b83c759d5ab1a7b
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Mon Aug 15 08:22:24 2016 +0200
Disable commit context items if there is no real selection
https://bugzilla.gnome.org/show_bug.cgi?id=769897
gitg/commit/gitg-commit.vala | 26 ++++++++++++++++++++------
1 files changed, 20 insertions(+), 6 deletions(-)
---
diff --git a/gitg/commit/gitg-commit.vala b/gitg/commit/gitg-commit.vala
index 640a724..5412adf 100644
--- a/gitg/commit/gitg-commit.vala
+++ b/gitg/commit/gitg-commit.vala
@@ -1633,11 +1633,14 @@ namespace GitgCommit
Sidebar.Item.Type type;
var sitems = items_for_items(items, out type);
+ var hasitems = sitems.length > 0;
if (type == Sidebar.Item.Type.UNSTAGED ||
type == Sidebar.Item.Type.UNTRACKED)
{
var stage = new Gtk.MenuItem.with_mnemonic(_("_Stage changes"));
+ stage.sensitive = hasitems;
+
menu.append(stage);
stage.activate.connect(() => {
@@ -1648,6 +1651,8 @@ namespace GitgCommit
if (type == Sidebar.Item.Type.STAGED)
{
var stage = new Gtk.MenuItem.with_mnemonic(_("_Unstage changes"));
+ stage.sensitive = hasitems;
+
menu.append(stage);
stage.activate.connect(() => {
@@ -1658,6 +1663,8 @@ namespace GitgCommit
if (type == Sidebar.Item.Type.UNSTAGED)
{
var discard = new Gtk.MenuItem.with_mnemonic(_("_Discard changes"));
+ discard.sensitive = hasitems;
+
menu.append(discard);
discard.activate.connect(() => {
@@ -1668,6 +1675,8 @@ namespace GitgCommit
if (type == Sidebar.Item.Type.UNTRACKED)
{
var del = new Gtk.MenuItem.with_mnemonic(dngettext(null, "D_elete file",
"D_elete files", sitems.length));
+ del.sensitive = hasitems;
+
menu.append(del);
del.activate.connect(() => {
@@ -1675,16 +1684,21 @@ namespace GitgCommit
});
}
- var canedit = true;
+ bool canedit = false;
- foreach (var item in sitems)
+ if (hasitems)
{
- var file = item as Gitg.StageStatusFile;
+ canedit = true;
- if (file == null || (file.flags & Ggit.StatusFlags.WORKING_TREE_DELETED) != 0)
+ foreach (var item in sitems)
{
- canedit = false;
- break;
+ var file = item as Gitg.StageStatusFile;
+
+ if (file == null || (file.flags &
Ggit.StatusFlags.WORKING_TREE_DELETED) != 0)
+ {
+ canedit = false;
+ break;
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]