-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from t00m/0.0.31
0.0.31
- Loading branch information
Showing
15 changed files
with
93 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
# File: searchbar.py | ||
# Author: Tomás Vírseda | ||
# License: GPL v3 | ||
# Description: Custom SearchBar widget | ||
# Borrowed from: https://github.com/timlau/gtk4-python | ||
""" | ||
|
||
from gi.repository import Gtk | ||
|
||
class SearchBar(Gtk.SearchBar): | ||
""" Wrapper for Gtk.Searchbar Gtk.SearchEntry""" | ||
|
||
def __init__(self, app): | ||
super(SearchBar, self).__init__() | ||
self.app = app | ||
window = self.app.get_widget('window') | ||
box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) | ||
box.set_spacing(24) | ||
|
||
# Add SearchEntry | ||
entry = self.app.add_widget('searchbar_entry', Gtk.SearchEntry()) | ||
entry.set_hexpand(True) | ||
box.append(entry) | ||
self.set_child(box) | ||
|
||
# connect search entry to seach bar | ||
self.connect_entry(entry) | ||
|
||
# set key capture from main window, it will show searchbar, when you start typing | ||
if window: | ||
self.set_key_capture_widget(window) | ||
|
||
# show close button in search bar | ||
self.set_show_close_button(True) | ||
|
||
# Set search mode to off by default | ||
self.set_search_mode(False) | ||
|
||
def set_callback(self, callback): | ||
""" Connect the search entry activate to an callback handler""" | ||
entry = self.app.get_widget('searchbar_entry') | ||
entry.connect('changed', callback) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.