Removed unused files
This commit is contained in:
parent
e2c7961a2a
commit
91f203fc23
@ -1,6 +0,0 @@
|
|||||||
[Shell Search Provider]
|
|
||||||
DesktopId=@appid@.desktop
|
|
||||||
BusName=@appid@.SearchProvider
|
|
||||||
ObjectPath=/com/jeffser/Alpaca/SearchProvider
|
|
||||||
Version=2
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
|||||||
[D-BUS Service]
|
|
||||||
Name=@appid@.SearchProvider
|
|
||||||
Exec=@libexecdir@/alpaca_search_provider
|
|
@ -1,127 +0,0 @@
|
|||||||
#!@PYTHON@
|
|
||||||
|
|
||||||
import sys
|
|
||||||
from gi.repository import Gio, GLib
|
|
||||||
|
|
||||||
DBUS_NAME = "com.jeffser.Alpaca.SearchProvider"
|
|
||||||
DBUS_OBJECT_PATH = "/com/jeffser/Alpaca/SearchProvider"
|
|
||||||
DBUS_INTERFACE = "org.gnome.Shell.SearchProvider2"
|
|
||||||
|
|
||||||
class SearchProvider:
|
|
||||||
def __init__(self):
|
|
||||||
print("ALPACA __init__")
|
|
||||||
self.connection = Gio.bus_get_sync(Gio.BusType.SESSION, None)
|
|
||||||
if not self.connection:
|
|
||||||
print("ALPACA Failed to get D-Bus connection")
|
|
||||||
return
|
|
||||||
|
|
||||||
print("ALPACA D-Bus connection obtained")
|
|
||||||
interface_info = self.get_interface_info()
|
|
||||||
|
|
||||||
self.registration_id = self.connection.register_object(
|
|
||||||
DBUS_OBJECT_PATH,
|
|
||||||
interface_info,
|
|
||||||
self.handle_method_call,
|
|
||||||
None,
|
|
||||||
None
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.registration_id > 0:
|
|
||||||
print(f"ALPACA Object registered with ID: {self.registration_id}")
|
|
||||||
else:
|
|
||||||
print("ALPACA Failed to register object")
|
|
||||||
|
|
||||||
def get_interface_info(self):
|
|
||||||
print("ALPACA get_interface_info")
|
|
||||||
xml = """
|
|
||||||
<node>
|
|
||||||
<interface name="org.gnome.Shell.SearchProvider2">
|
|
||||||
|
|
||||||
<method name="GetInitialResultSet">
|
|
||||||
<arg type="as" name="terms" direction="in" />
|
|
||||||
<arg type="as" name="results" direction="out" />
|
|
||||||
</method>
|
|
||||||
|
|
||||||
<method name="GetSubsearchResultSet">
|
|
||||||
<arg type="as" name="previous_results" direction="in" />
|
|
||||||
<arg type="as" name="terms" direction="in" />
|
|
||||||
<arg type="as" name="results" direction="out" />
|
|
||||||
</method>
|
|
||||||
|
|
||||||
<method name="GetResultMetas">
|
|
||||||
<arg type="as" name="identifiers" direction="in" />
|
|
||||||
<arg type="aa{sv}" name="metas" direction="out" />
|
|
||||||
</method>
|
|
||||||
|
|
||||||
<method name="ActivateResult">
|
|
||||||
<arg type="s" name="identifier" direction="in" />
|
|
||||||
<arg type="as" name="terms" direction="in" />
|
|
||||||
<arg type="u" name="timestamp" direction="in" />
|
|
||||||
</method>
|
|
||||||
|
|
||||||
<method name="LaunchSearch">
|
|
||||||
<arg type="as" name="terms" direction="in" />
|
|
||||||
<arg type="u" name="timestamp" direction="in" />
|
|
||||||
</method>
|
|
||||||
|
|
||||||
</interface>
|
|
||||||
</node>
|
|
||||||
"""
|
|
||||||
return Gio.DBusNodeInfo.new_for_xml(xml).interfaces[0]
|
|
||||||
|
|
||||||
def handle_method_call(self, connection, sender, object_path, interface_name, method_name, parameters, invocation):
|
|
||||||
print(f"ALPACA handle_method_call: {method_name}")
|
|
||||||
if method_name == "GetInitialResultSet":
|
|
||||||
self.handle_get_initial_result_set(invocation, parameters)
|
|
||||||
elif method_name == "GetSubsearchResultSet":
|
|
||||||
self.handle_get_subsearch_result_set(invocation, parameters)
|
|
||||||
elif method_name == "GetResultMetas":
|
|
||||||
self.handle_get_result_metas(invocation, parameters)
|
|
||||||
elif method_name == "ActivateResult":
|
|
||||||
self.handle_activate_result(invocation, parameters)
|
|
||||||
|
|
||||||
def handle_get_initial_result_set(self, invocation, parameters):
|
|
||||||
print("ALPACA handle_get_initial_result_set")
|
|
||||||
terms = parameters.unpack()[0]
|
|
||||||
print(f"Initial search terms: {terms}")
|
|
||||||
results = ["result1", "result2"]
|
|
||||||
if "Alpaca" in terms:
|
|
||||||
results.append("alpaca_placeholder_result")
|
|
||||||
print(f"Returning results: {results}")
|
|
||||||
invocation.return_value(GLib.Variant("(as)", [results]))
|
|
||||||
|
|
||||||
def handle_get_subsearch_result_set(self, invocation, parameters):
|
|
||||||
print("ALPACA handle_get_subsearch_result_set")
|
|
||||||
previous_results, terms = parameters.unpack()
|
|
||||||
print(f"Subsearch terms: {terms}, previous results: {previous_results}")
|
|
||||||
results = ["result3", "result4"]
|
|
||||||
if "Alpaca" in terms:
|
|
||||||
results.append("sub_alpaca_placeholder_result")
|
|
||||||
print(f"Returning subsearch results: {results}")
|
|
||||||
invocation.return_value(GLib.Variant("(as)", [results]))
|
|
||||||
|
|
||||||
def handle_get_result_metas(self, invocation, parameters):
|
|
||||||
print("ALPACA handle_get_result_metas")
|
|
||||||
identifiers = parameters.unpack()[0]
|
|
||||||
print(f"Result metas for identifiers: {identifiers}")
|
|
||||||
metas = []
|
|
||||||
for identifier in identifiers:
|
|
||||||
meta = {"name": GLib.Variant("s", "Placeholder result for " + identifier)}
|
|
||||||
metas.append(GLib.Variant("a{sv}", meta))
|
|
||||||
print(f"Returning metas: {metas}")
|
|
||||||
invocation.return_value(GLib.Variant("(a{sv})", [metas]))
|
|
||||||
|
|
||||||
def handle_activate_result(self, invocation, parameters):
|
|
||||||
print("ALPACA handle_activate_result")
|
|
||||||
identifier, terms, timestamp = parameters.unpack()
|
|
||||||
print(f"Activated result: {identifier}, terms: {terms}, timestamp: {timestamp}")
|
|
||||||
invocation.return_value(None)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
provider = SearchProvider()
|
|
||||||
if provider.registration_id > 0:
|
|
||||||
loop = GLib.MainLoop()
|
|
||||||
print("ALPACA Running main loop")
|
|
||||||
loop.run()
|
|
||||||
else:
|
|
||||||
print("ALPACA Failed to start main loop due to object registration failure")
|
|
Loading…
x
Reference in New Issue
Block a user