[gitg] diff-view-hunk: add property to know if there is a selection
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] diff-view-hunk: add property to know if there is a selection
- Date: Fri, 18 Dec 2015 16:54:54 +0000 (UTC)
commit dcf6367148b8135c70633eaa53252d88b8302e5e
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Fri Dec 18 15:27:19 2015 +0100
diff-view-hunk: add property to know if there is a selection
libgitg/gitg-diff-view-hunk.vala | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/libgitg/gitg-diff-view-hunk.vala b/libgitg/gitg-diff-view-hunk.vala
index 3060be5..ea3d550 100644
--- a/libgitg/gitg-diff-view-hunk.vala
+++ b/libgitg/gitg-diff-view-hunk.vala
@@ -97,6 +97,13 @@ class Gitg.DiffViewHunk : Gtk.Grid
}
}
+ private bool d_has_selection;
+
+ public bool has_selection
+ {
+ get { return d_has_selection; }
+ }
+
private DiffViewLinesRenderer d_old_lines;
private DiffViewLinesRenderer d_new_lines;
private DiffViewLinesRenderer d_sym_lines;
@@ -369,6 +376,32 @@ class Gitg.DiffViewHunk : Gtk.Grid
return false;
}
+ private void update_has_selection()
+ {
+ var text_view = d_sourceview_hunk as Gtk.TextView;
+ var buffer = text_view.get_buffer();
+
+ Gtk.TextIter iter;
+ buffer.get_start_iter(out iter);
+
+ bool something_selected = false;
+
+ if (get_line_selected(iter))
+ {
+ something_selected = true;
+ }
+ else
+ {
+ something_selected = (buffer as Gtk.SourceBuffer).forward_iter_to_source_mark(iter,
d_selection_category);
+ }
+
+ if (something_selected != d_has_selection)
+ {
+ d_has_selection = something_selected;
+ notify_property("has-selection");
+ }
+ }
+
private bool button_release_event_on_view(Gdk.EventButton event)
{
if (event.button != 1)
@@ -388,6 +421,8 @@ class Gitg.DiffViewHunk : Gtk.Grid
buffer.delete_mark(d_end_selection_mark);
d_end_selection_mark = null;
+ update_has_selection();
+
return false;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]