mirror of
https://gitlab.gnome.org/GNOME/gitg
synced 2024-11-04 21:16:52 +00:00
Add buttons to move from search results
This commit is contained in:
parent
e3d76a0b11
commit
566d2e0532
4 changed files with 107 additions and 4 deletions
|
@ -90,6 +90,10 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
|
|||
private Gtk.SearchBar d_search_bar;
|
||||
[GtkChild]
|
||||
private Gtk.SearchEntry d_search_entry;
|
||||
[GtkChild]
|
||||
private Gtk.Button d_search_up_button;
|
||||
[GtkChild]
|
||||
private Gtk.Button d_search_down_button;
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.Stack d_main_stack;
|
||||
|
@ -246,12 +250,25 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
|
|||
d_search_entry.text = searchable.search_text;
|
||||
searchable.search_visible = true;
|
||||
searchable.search_entry = d_search_entry;
|
||||
var has_text = d_search_entry.text.length > 0;
|
||||
d_search_up_button.set_sensitive(has_text);
|
||||
d_search_down_button.set_sensitive(has_text);
|
||||
}
|
||||
else
|
||||
{
|
||||
searchable.search_visible = false;
|
||||
searchable.search_entry = null;
|
||||
d_search_up_button.set_sensitive(false);
|
||||
d_search_down_button.set_sensitive(false);
|
||||
}
|
||||
|
||||
var show_buttons = false;
|
||||
if (current_activity is GitgExt.Searchable)
|
||||
{
|
||||
show_buttons = searchable.show_buttons();
|
||||
}
|
||||
d_search_up_button.set_visible(show_buttons);
|
||||
d_search_down_button.set_visible(show_buttons);
|
||||
}
|
||||
|
||||
[GtkCallback]
|
||||
|
@ -263,6 +280,9 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
|
|||
if (ntext != searchable.search_text)
|
||||
{
|
||||
searchable.search_text = ntext;
|
||||
var has_text = ntext.length > 0;
|
||||
d_search_up_button.set_sensitive(has_text);
|
||||
d_search_down_button.set_sensitive(has_text);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -277,6 +297,18 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
|
|||
return ret;
|
||||
}
|
||||
|
||||
[GtkCallback]
|
||||
private void search_up_clicked(Gtk.Button button)
|
||||
{
|
||||
search_move(true);
|
||||
}
|
||||
|
||||
[GtkCallback]
|
||||
private void search_down_clicked(Gtk.Button button)
|
||||
{
|
||||
search_move(false);
|
||||
}
|
||||
|
||||
construct
|
||||
{
|
||||
if (Gitg.PlatformSupport.use_native_window_controls())
|
||||
|
@ -1326,6 +1358,26 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
|
|||
{
|
||||
owned get { return d_notifications; }
|
||||
}
|
||||
|
||||
private void search_move(bool up)
|
||||
{
|
||||
if (current_activity is GitgExt.Searchable)
|
||||
{
|
||||
var searchable = current_activity as GitgExt.Searchable;
|
||||
var key = d_search_entry.text;
|
||||
var result = searchable.search_move(key, up);
|
||||
if (up)
|
||||
{
|
||||
d_search_up_button.set_sensitive(result);
|
||||
d_search_down_button.set_sensitive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
d_search_up_button.set_sensitive(true);
|
||||
d_search_down_button.set_sensitive(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1167,6 +1167,16 @@ namespace GitgHistory
|
|||
|
||||
public string search_text { owned get; set; default = ""; }
|
||||
public bool search_visible { get; set; }
|
||||
|
||||
public override bool search_move(string key, bool up)
|
||||
{
|
||||
return d_main.commit_list_view.search_move(up);
|
||||
}
|
||||
|
||||
public override bool show_buttons()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -244,11 +244,50 @@
|
|||
<property name="can_focus">False</property>
|
||||
<property name="show-close-button">False</property>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="d_search_entry">
|
||||
<object class="GtkBox" id="d_search_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="width-request">500</property>
|
||||
<signal name="changed" handler="search_entry_changed" swapped="no"/>
|
||||
<property name="orientation">horizontal</property>
|
||||
<style>
|
||||
<class name="linked"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="d_search_entry">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="width-request">500</property>
|
||||
<signal name="changed" handler="search_entry_changed" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="d_search_up_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<signal name="clicked" handler="search_up_clicked" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkImage" id="up_image">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_size">1</property>
|
||||
<property name="icon_name">go-up-symbolic</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="d_search_down_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<signal name="clicked" handler="search_down_clicked" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkImage" id="down_image">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_size">1</property>
|
||||
<property name="icon_name">go-down-symbolic</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
|
|
@ -32,6 +32,8 @@ public interface Searchable : Object, Activity
|
|||
public abstract bool search_visible { get; set; }
|
||||
public abstract bool search_available { get; }
|
||||
public abstract Gtk.Entry? search_entry { set; }
|
||||
public virtual bool search_move(string key, bool up) { return false; }
|
||||
public virtual bool show_buttons() { return false; }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue