Merge lp:~shokry/pantheon-terminal/fix-1426470 into lp:~elementary-apps/pantheon-terminal/trunk

Proposed by Shokry
Status: Work in progress
Proposed branch: lp:~shokry/pantheon-terminal/fix-1426470
Merge into: lp:~elementary-apps/pantheon-terminal/trunk
Diff against target: 106 lines (+45/-10) (has conflicts)
1 file modified
src/SearchToolbar.vala (+45/-10)
Text conflict in src/SearchToolbar.vala
To merge this branch: bzr merge lp:~shokry/pantheon-terminal/fix-1426470
Reviewer Review Type Date Requested Status
xapantu (community) Needs Fixing
Review via email: mp+268103@code.launchpad.net
To post a comment you must log in.
Revision history for this message
xapantu (xapantu) wrote :

Thanks for your patch! However, there are a few things that could be improved:

Code style (not the most important):
* you don't need to use private, it is private by default (this one is a subjective one, I agree)
* you don't need to use "this" unless it is absolutely necessary (i.e. if you use an object it will by default be the attribute of "this" object unless superseded)

Bugs that I found (that must be fixed before merging):
* if you search something that only appear once, the arrows are disabled once it has been found, I don't think this is what we want.
* if I type "x" and then backward so as the search entry is empty, I still jump between "x" because the terminal search is not updated in "search_changed_cb"

review: Needs Fixing
Revision history for this message
Shokry (shokry) wrote :

Thank you for the really helpful comment.

As for the first bug, I think it's a limitation in the VTE widget's search functions, if a search term appears only once, it'll be highlighted once, next call to the find next/previous function doesn't highlight it again and looks like it's treated as a not-found even if the search wrapping is enabled, I don't know if this behavior can be overridden.

I can try to mimic the desired (normal) search behavior but I'm not sure if that's the right thing to do

Revision history for this message
xapantu (xapantu) wrote :

The problem with the first bug is that I have that :
- Type "unique_word" in the search box
- Click on next -> that selects the word
- Click on next -> that unselects the word, and makes the arrow unsensitive.

If that's a vte bug, then it should be reported. Reading your code I tend to agree with you, but that may need more investigation.

Another problem is that the search should be more responsive : when something is typed, it should automatically go to the first occurence of the word (that is linked with the other behaviour problems).

So, to sum up, the expected behaviour would be (maybe not entirely doable with our current vte version) :
* Type something in the search entry : the terminals jump to the first occurrence, if available.
* If not available, everything go unsensitive
* No backward problem if the search entry == "" (and the buttons must be unsensitive too)
* If there is only one occurence, the next buttons should be unsensitive

748. By Shokry

highlight first occurence while typing in search entry

749. By Shokry

button sensitivity changes only in search functions

750. By Shokry

code style fix

Revision history for this message
Shokry (shokry) wrote :

The desired behavior should now be present except for the last point.

Unmerged revisions

750. By Shokry

code style fix

749. By Shokry

button sensitivity changes only in search functions

748. By Shokry

highlight first occurence while typing in search entry

747. By Shokry

sensitivity is set by a function

746. By Shokry

search buttons insinsitive when created

745. By Shokry

buttons insinsitive when no text entered or no match

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/SearchToolbar.vala'
2--- src/SearchToolbar.vala 2015-09-16 22:16:20 +0000
3+++ src/SearchToolbar.vala 2015-10-03 10:27:06 +0000
4@@ -28,6 +28,9 @@
5
6 public Gtk.SearchEntry search_entry;
7
8+ private Gtk.ToolButton previous_button;
9+ private Gtk.ToolButton next_button;
10+
11 public signal void clear ();
12
13 public SearchToolbar (PantheonTerminalWindow window) {
14@@ -45,18 +48,20 @@
15 var i = new Gtk.Image.from_icon_name ("go-up-symbolic",
16 Gtk.IconSize.SMALL_TOOLBAR);
17 i.pixel_size = 16;
18- var previous_button = new Gtk.ToolButton (i, null);
19- previous_button.set_tooltip_text (_("Previous result"));
20+ this.previous_button = new Gtk.ToolButton (i, null);
21+ this.previous_button.set_tooltip_text (_("Previous result"));
22
23 i = new Gtk.Image.from_icon_name ("go-down-symbolic",
24 Gtk.IconSize.SMALL_TOOLBAR);
25 i.pixel_size = 16;
26- var next_button = new Gtk.ToolButton (i, null);
27- next_button.set_tooltip_text (_("Next result"));
28+ this.next_button = new Gtk.ToolButton (i, null);
29+ this.next_button.set_tooltip_text (_("Next result"));
30+
31+ set_search_buttons_sensitivity (false);
32
33 this.add (tool_search_entry);
34- this.add (previous_button);
35- this.add (next_button);
36+ this.add (this.previous_button);
37+ this.add (this.next_button);
38
39 this.show_all ();
40 this.set_style (Gtk.ToolbarStyle.ICONS);
41@@ -66,8 +71,8 @@
42 this.clear.connect (clear_cb);
43 this.grab_focus.connect (grab_focus_cb);
44 this.search_entry.search_changed.connect (search_changed_cb);
45- previous_button.clicked.connect (previous_search);
46- next_button.clicked.connect (next_search);
47+ this.previous_button.clicked.connect (previous_search);
48+ this.next_button.clicked.connect (next_search);
49 }
50
51 void clear_cb () {
52@@ -80,22 +85,52 @@
53
54 void search_changed_cb () {
55 try {
56+<<<<<<< TREE
57 // FIXME Have a configuration menu or something.
58 var regex = new Regex (Regex.escape_string (search_entry.text),
59 RegexCompileFlags.CASELESS);
60 this.window.current_terminal.search_set_gregex (regex, 0);
61 this.window.current_terminal.search_set_wrap_around (true);
62+=======
63+ if (search_entry.text == "") {
64+ this.window.current_terminal.search_set_gregex (null);
65+ this.window.current_terminal.select_none ();
66+ set_search_buttons_sensitivity (false);
67+ } else {
68+ // FIXME Have a configuration menu or something.
69+ var regex = new Regex (Regex.escape_string (search_entry.text),
70+ RegexCompileFlags.CASELESS);
71+ this.window.current_terminal.search_set_gregex (regex);
72+ this.window.current_terminal.search_set_wrap_around (true);
73+
74+ this.window.current_terminal.select_none ();
75+ next_search ();
76+ }
77+>>>>>>> MERGE-SOURCE
78 } catch (RegexError er) {
79 warning ("There was an error to compile the regex: %s", er.message);
80 }
81 }
82
83 public void previous_search () {
84- this.window.current_terminal.search_find_previous ();
85+ if (this.window.current_terminal.search_find_previous () == false) {
86+ set_search_buttons_sensitivity (false);
87+ } else {
88+ set_search_buttons_sensitivity (true);
89+ }
90 }
91
92 public void next_search () {
93- this.window.current_terminal.search_find_next ();
94+ if (this.window.current_terminal.search_find_next () == false) {
95+ set_search_buttons_sensitivity (false);
96+ } else {
97+ set_search_buttons_sensitivity (true);
98+ }
99+ }
100+
101+ void set_search_buttons_sensitivity (bool sensitivity) {
102+ this.previous_button.set_sensitive (sensitivity);
103+ this.next_button.set_sensitive (sensitivity);
104 }
105 }
106 }

Subscribers

People subscribed via source and target branches