Commit c72ebce7 authored by Harish Fulara's avatar Harish Fulara Committed by Alexandru Băluț

greeter: search projects functionality

parent 067d896c
Pipeline #19022 passed with stage
in 45 minutes and 51 seconds
...@@ -9,6 +9,23 @@ ...@@ -9,6 +9,23 @@
<property name="margin_top">30</property> <property name="margin_top">30</property>
<property name="margin_bottom">10</property> <property name="margin_bottom">10</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child>
<object class="GtkSearchEntry" id="search_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">center</property>
<property name="margin_bottom">32</property>
<property name="width_chars">35</property>
<property name="primary_icon_name">edit-find-symbolic</property>
<property name="primary_icon_activatable">False</property>
<property name="primary_icon_sensitive">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child> <child>
<object class="GtkBox" id="recent_projects_labelbox"> <object class="GtkBox" id="recent_projects_labelbox">
<property name="name">recent_projects_labelbox</property> <property name="name">recent_projects_labelbox</property>
...@@ -47,7 +64,7 @@ ...@@ -47,7 +64,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">0</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child> <child>
...@@ -59,7 +76,7 @@ ...@@ -59,7 +76,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">1</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
</object> </object>
......
...@@ -46,13 +46,13 @@ class ProjectInfoRow(Gtk.ListBoxRow): ...@@ -46,13 +46,13 @@ class ProjectInfoRow(Gtk.ListBoxRow):
def __init__(self, recent_project_item): def __init__(self, recent_project_item):
Gtk.ListBoxRow.__init__(self) Gtk.ListBoxRow.__init__(self)
self.uri = recent_project_item.get_uri() self.uri = recent_project_item.get_uri()
self.name = os.path.splitext(recent_project_item.get_display_name())[0]
builder = Gtk.Builder() builder = Gtk.Builder()
builder.add_from_file(os.path.join(get_ui_dir(), "project_info.ui")) builder.add_from_file(os.path.join(get_ui_dir(), "project_info.ui"))
self.add(builder.get_object("project_info_vbox")) self.add(builder.get_object("project_info_vbox"))
builder.get_object("project_name_label").set_text( builder.get_object("project_name_label").set_text(self.name)
os.path.splitext(recent_project_item.get_display_name())[0])
builder.get_object("project_uri_label").set_text( builder.get_object("project_uri_label").set_text(
beautify_project_path(recent_project_item.get_uri_display())) beautify_project_path(recent_project_item.get_uri_display()))
builder.get_object("project_last_updated_label").set_text( builder.get_object("project_last_updated_label").set_text(
...@@ -79,6 +79,8 @@ class GreeterPerspective(Perspective): ...@@ -79,6 +79,8 @@ class GreeterPerspective(Perspective):
self.__topvbox = None self.__topvbox = None
self.__welcome_vbox = None self.__welcome_vbox = None
self.__recent_projects_vbox = None self.__recent_projects_vbox = None
self.__search_entry = None
self.__recent_projects_labelbox = None
self.__recent_projects_listbox = None self.__recent_projects_listbox = None
self.__project_filter = self.__create_project_filter() self.__project_filter = self.__create_project_filter()
self.__infobar = None self.__infobar = None
...@@ -94,10 +96,16 @@ class GreeterPerspective(Perspective): ...@@ -94,10 +96,16 @@ class GreeterPerspective(Perspective):
builder.add_from_file(os.path.join(get_ui_dir(), "greeter.ui")) builder.add_from_file(os.path.join(get_ui_dir(), "greeter.ui"))
self.toplevel_widget = builder.get_object("scrolled_window") self.toplevel_widget = builder.get_object("scrolled_window")
self.__topvbox = builder.get_object("topvbox") self.__topvbox = builder.get_object("topvbox")
self.__welcome_vbox = builder.get_object("welcome_vbox") self.__welcome_vbox = builder.get_object("welcome_vbox")
self.__recent_projects_vbox = builder.get_object("recent_projects_vbox") self.__recent_projects_vbox = builder.get_object("recent_projects_vbox")
self.__recent_projects_labelbox = builder.get_object("recent_projects_labelbox")
self.__search_entry = builder.get_object("search_entry")
self.__search_entry.connect("search-changed", self.__search_changed_cb)
self.__recent_projects_listbox = builder.get_object("recent_projects_listbox") self.__recent_projects_listbox = builder.get_object("recent_projects_listbox")
self.__recent_projects_listbox.set_selection_mode(Gtk.SelectionMode.NONE) self.__recent_projects_listbox.set_selection_mode(Gtk.SelectionMode.NONE)
self.__recent_projects_listbox.connect( self.__recent_projects_listbox.connect(
...@@ -114,7 +122,13 @@ class GreeterPerspective(Perspective): ...@@ -114,7 +122,13 @@ class GreeterPerspective(Perspective):
def refresh(self): def refresh(self):
"""Refreshes the perspective.""" """Refreshes the perspective."""
self.toplevel_widget.grab_focus() # We are assuming that the users name their projects meaningfully
# and are sure of what project they want to search for. Once they
# find the project and open it they don't want to come back to the
# previous search results. So, we clear out the search entry before
# the greeter is shown again.
self.__search_entry.set_text("")
self.__search_entry.grab_focus()
# Clear the currently displayed list of recent projects. # Clear the currently displayed list of recent projects.
for child in self.__recent_projects_listbox.get_children(): for child in self.__recent_projects_listbox.get_children():
...@@ -254,3 +268,18 @@ class GreeterPerspective(Perspective): ...@@ -254,3 +268,18 @@ class GreeterPerspective(Perspective):
def __projects_row_activated_cb(self, unused_listbox, row): def __projects_row_activated_cb(self, unused_listbox, row):
self.app.project_manager.loadProject(row.uri) self.app.project_manager.loadProject(row.uri)
def __search_changed_cb(self, search_entry):
search_hit = False
search_text = search_entry.get_text().lower()
for recent_project_item in self.__recent_projects_listbox.get_children():
if search_text in recent_project_item.name.lower():
recent_project_item.show()
search_hit = True
else:
recent_project_item.hide()
if search_hit:
self.__recent_projects_labelbox.show()
else:
self.__recent_projects_labelbox.hide()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment