Skip to content

Commit

Permalink
using ENGINES dict to check if 'Custom' option is selected plus added…
Browse files Browse the repository at this point in the history
… Neeva search engine
  • Loading branch information
PhantomLel authored and Davidy22 committed Oct 20, 2022
1 parent b963d66 commit 0c07f80
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
11 changes: 2 additions & 9 deletions guake/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,9 @@
from guake.utils import FullscreenManager
from guake.utils import HidePrevention
from guake.utils import get_server_time
from guake.globals import ENGINES
from urllib.parse import quote_plus

# the urls of the search engine options
ENGINES = {
0: "www.google.com/search?safe=off&q=",
1: "www.duckduckgo.com/",
2: "www.bing.com/search?q=",
3: "www.yandex.com/search?text=",
}


class TerminalContextMenuCallbacks:
def __init__(self, terminal, window, settings, notebook):
Expand Down Expand Up @@ -68,7 +61,7 @@ def on_search_on_web(self, *args):

selected = self.settings.general.get_int("search-engine")
# if custom search is selected, get the engine from the 'custom-search-engine' setting
if selected == 4:
if selected not in ENGINES:
engine = self.settings.general.get_string("custom-search-engine")
else:
engine = ENGINES[selected]
Expand Down
1 change: 1 addition & 0 deletions guake/data/prefs.glade
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@
<item translatable="yes">DuckDuckGo</item>
<item translatable="yes">Bing</item>
<item translatable="yes">Yandex</item>
<item translatable="yes">Neeva</item>
<item translatable="yes">Custom</item>
</items>
<signal name="changed" handler="on_search_engine_changed" swapped="no"/>
Expand Down
10 changes: 10 additions & 0 deletions guake/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,13 @@ def is_run_from_git_workdir():
# Constants for vte regex matching are documented in the pcre2 api:
# https://www.pcre.org/current/doc/html/pcre2api.html
PCRE2_MULTILINE = 0x00000400

# the urls of the search engine options for the search on web feature.
# Additional engines should be added
ENGINES = {
0: "www.google.com/search?safe=off&q=",
1: "www.duckduckgo.com/",
2: "www.bing.com/search?q=",
3: "www.yandex.com/search?text=",
4: "neeva.com/search?q=",
}
5 changes: 3 additions & 2 deletions guake/prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
from guake.globals import MAX_TRANSPARENCY
from guake.globals import NAME
from guake.globals import QUICK_OPEN_MATCHERS
from guake.globals import ENGINES
from guake.palettes import PALETTES
from guake.paths import AUTOSTART_FOLDER
from guake.paths import LOCALE_DIR
Expand Down Expand Up @@ -303,7 +304,7 @@ def on_search_engine_changed(self, combo):
"""
custom_search = self.prefDlg.get_widget("custom_search")
# if 'Custom' is selected make the search engine input editable
if combo.get_active() == 4:
if combo.get_active() not in ENGINES:
custom_search.set_sensitive(True)
else:
# make read-only
Expand Down Expand Up @@ -1069,7 +1070,7 @@ def load_configs(self):
custom_search.set_text(self.settings.general.get_string("custom-search-engine"))
self.get_widget("search_engine_select").set_active(value)
# if 'Custom' is selected make the search engine input editable
if value == 4:
if value not in ENGINES:
# make read-only
custom_search.set_sensitive(True)
else:
Expand Down

0 comments on commit 0c07f80

Please sign in to comment.