[gitg] Stage/unstage all selected items when pressing Enter in list
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Stage/unstage all selected items when pressing Enter in list
- Date: Tue, 4 Aug 2015 18:22:19 +0000 (UTC)
commit c8ce18e5e5bdb10ccb6593e8efb9b5bc50d67875
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Tue Aug 4 20:21:51 2015 +0200
Stage/unstage all selected items when pressing Enter in list
gitg/commit/gitg-commit.vala | 44 ++++++++++++++++++++----
libgitg/gitg-repository-list-box.vala | 1 +
libgitg/gitg-sidebar.vala | 59 +++++++++++++++++++++++++++++++++
3 files changed, 96 insertions(+), 8 deletions(-)
---
diff --git a/gitg/commit/gitg-commit.vala b/gitg/commit/gitg-commit.vala
index d0e0830..5d49443 100644
--- a/gitg/commit/gitg-commit.vala
+++ b/gitg/commit/gitg-commit.vala
@@ -821,8 +821,15 @@ namespace GitgCommit
Sidebar.Item.Type.STAGED,
selected_paths,
(item) => {
- on_staged_activated(new
Gitg.StageStatusItem[] {item.item});
- });
+ if (d_main.sidebar.is_selected(item))
+ {
+ on_unstage_selected_items();
+ }
+ else
+ {
+ on_staged_activated(new Gitg.StageStatusItem[]
{item.item});
+ }
+ });
}
model.end_header();
@@ -845,8 +852,15 @@ namespace GitgCommit
Sidebar.Item.Type.UNSTAGED,
selected_paths,
(item) => {
- on_unstaged_activated(new
Gitg.StageStatusItem[] {item.item});
- });
+ if (d_main.sidebar.is_selected(item))
+ {
+ on_stage_selected_items();
+ }
+ else
+ {
+ on_unstaged_activated(new Gitg.StageStatusItem[]
{item.item});
+ }
+ });
}
model.end_header();
@@ -865,8 +879,15 @@ namespace GitgCommit
Sidebar.Item.Type.UNTRACKED,
selected_paths,
(item) => {
-
on_unstaged_activated(new Gitg.StageStatusItem[] {item.item});
- });
+ if (d_main.sidebar.is_selected(item))
+ {
+ on_stage_selected_items();
+ }
+ else
+ {
+ on_unstaged_activated(new Gitg.StageStatusItem[]
{item.item});
+ }
+ });
}
model.end_header();
@@ -887,8 +908,15 @@ namespace GitgCommit
Sidebar.Item.Type.SUBMODULE,
selected_paths,
(item) => {
-
on_unstaged_activated(new Gitg.StageStatusItem[] {item.item});
- });
+ if (d_main.sidebar.is_selected(item))
+ {
+ on_stage_selected_items();
+ }
+ else
+ {
+ on_unstaged_activated(new
Gitg.StageStatusItem[] {item.item});
+ }
+ });
}
model.end_header();
diff --git a/libgitg/gitg-repository-list-box.vala b/libgitg/gitg-repository-list-box.vala
index b5a9620..f530ae4 100644
--- a/libgitg/gitg-repository-list-box.vala
+++ b/libgitg/gitg-repository-list-box.vala
@@ -195,6 +195,7 @@ namespace Gitg
{
var box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 3);
var tip = @"$(module.get_path())/ ($(module.get_url()))";
+
box.set_tooltip_text(tip);
box.show();
diff --git a/libgitg/gitg-sidebar.vala b/libgitg/gitg-sidebar.vala
index 90a934e..36aa66a 100644
--- a/libgitg/gitg-sidebar.vala
+++ b/libgitg/gitg-sidebar.vala
@@ -383,6 +383,23 @@ public class Sidebar : Gtk.TreeView
});
}
+ public bool is_selected(SidebarItem item)
+ {
+ bool retval = false;
+
+ model.foreach((m, path, iter) => {
+ if (model.item_for_iter(iter) == item)
+ {
+ retval = get_selection().iter_is_selected(iter);
+ return true;
+ }
+
+ return false;
+ });
+
+ return retval;
+ }
+
protected override void row_activated(Gtk.TreePath path, Gtk.TreeViewColumn column)
{
if (model.clearing)
@@ -398,6 +415,48 @@ public class Sidebar : Gtk.TreeView
}
}
+ protected override bool key_press_event(Gdk.EventKey event)
+ {
+ if ((event.state & Gtk.accelerator_get_default_mod_mask()) != 0)
+ {
+ return base.key_press_event(event);
+ }
+
+ switch (event.keyval) {
+ case Gdk.Key.Return:
+ case Gdk.Key.ISO_Enter:
+ case Gdk.Key.KP_Enter:
+ case Gdk.Key.space:
+ case Gdk.Key.KP_Space:
+ Gtk.TreePath? path = null;
+ Gtk.TreeIter iter;
+
+ get_cursor(out path, null);
+
+ var sel = get_selection();
+
+ if (path != null)
+ {
+ if (model.get_iter(out iter, path))
+ {
+ if (sel.iter_is_selected(iter))
+ {
+ model.activate(iter, 2);
+ }
+ else
+ {
+ sel.unselect_all();
+ sel.select_iter(iter);
+ }
+ }
+ }
+
+ return true;
+ }
+
+ return base.key_press_event(event);
+ }
+
public new SidebarStore model
{
get { return base.get_model() as SidebarStore; }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]