Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify PluginInfo #588

Merged
merged 3 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions src/synapse-core/data-sink.vala
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,17 @@ namespace Synapse {
public class PluginRegistry : Object {
public class PluginInfo {
public Type plugin_type;
public string title;
public string description;
public string icon_name;
public PluginRegisterFunc register_func;
public bool runnable;
public string runnable_error;

public PluginInfo (
Type type,
string title,
string desc,
string icon_name,
PluginRegisterFunc reg_func,
bool runnable,
string runnable_error
bool runnable
) {
this.plugin_type = type;
this.title = title;
this.description = desc;
this.icon_name = icon_name;
this.register_func = reg_func;
this.runnable = runnable;
this.runnable_error = runnable_error;
}
}

Expand All @@ -86,12 +74,9 @@ namespace Synapse {

public void register_plugin (
Type plugin_type,
string title,
string description,
string icon_name,
PluginRegisterFunc reg_func,
bool runnable = true,
string runnable_error = ""
bool runnable = true
) {
// FIXME: how about a frickin Type -> PluginInfo map?!
int index = -1;
Expand All @@ -105,7 +90,7 @@ namespace Synapse {
plugins.remove_at (index);
}

var p = new PluginInfo (plugin_type, title, description, icon_name, reg_func, runnable, runnable_error);
var p = new PluginInfo (plugin_type, reg_func, runnable);
plugins.add (p);
}

Expand Down
5 changes: 1 addition & 4 deletions src/synapse-plugins/appcenter-plugin.vala
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,9 @@ namespace Synapse {
}

DataSink.PluginRegistry.get_default ().register_plugin (typeof (AppcenterPlugin),
_("AppCenter"),
_("Search for applications"),
"system-software-install",
register_plugin,
appcenter_installed,
_("AppCenter is not installed"));
appcenter_installed);
}

static construct {
Expand Down
5 changes: 1 addition & 4 deletions src/synapse-plugins/calculator-plugin/calculator-plugin.vala
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,9 @@ namespace Synapse {
static void register_plugin () {
DataSink.PluginRegistry.get_default ().register_plugin (
typeof (CalculatorPlugin),
_("Calculator"),
_("Calculate basic expressions."),
"accessories-calculator",
register_plugin,
Environment.find_program_in_path ("bc") != null,
_("bc is not installed")
Environment.find_program_in_path ("bc") != null
);
}

Expand Down
2 changes: 0 additions & 2 deletions src/synapse-plugins/command-plugin.vala
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ namespace Synapse {
static void register_plugin () {
DataSink.PluginRegistry.get_default ().register_plugin (
typeof (CommandPlugin),
"Command Search",
_("Find and execute arbitrary commands."),
"system-run",
register_plugin
);
Expand Down
5 changes: 1 addition & 4 deletions src/synapse-plugins/converter-plugin/converter-plugin.vala
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,9 @@ namespace Synapse {
static void register_plugin () {
DataSink.PluginRegistry.get_default ().register_plugin (
typeof (ConverterPlugin),
_("Converter"),
_("Convert between units."),
"accessories-converter",
register_plugin,
Environment.find_program_in_path ("bc") != null,
_("bc is not installed")
Environment.find_program_in_path ("bc") != null
);
}

Expand Down
2 changes: 0 additions & 2 deletions src/synapse-plugins/desktop-file-plugin.vala
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ namespace Synapse {
static void register_plugin () {
DataSink.PluginRegistry.get_default ().register_plugin (
typeof (DesktopFilePlugin),
"Application Search",
_("Search for and run applications on your computer."),
"system-run",
register_plugin
);
Expand Down
5 changes: 1 addition & 4 deletions src/synapse-plugins/file-bookmarks-plugin.vala
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,9 @@ namespace Synapse {

static void register_plugin () {
DataSink.PluginRegistry.get_default ().register_plugin (typeof (FileBookmarkPlugin),
_("Folder Bookmarks"),
_("Bookmarked Folders"),
"help-about",
register_plugin,
true,
"");
true);
}

static construct {
Expand Down
2 changes: 0 additions & 2 deletions src/synapse-plugins/link-plugin.vala
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ namespace Synapse {

static void register_plugin () {
DataSink.PluginRegistry.get_default ().register_plugin (typeof (LinkPlugin),
_("Link"),
_("Open link in default browser"),
"web-browser",
register_plugin);
}
Expand Down
2 changes: 0 additions & 2 deletions src/synapse-plugins/switchboard-plugin.vala
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ public class Synapse.SwitchboardPlugin : Object, Activatable, ItemProvider {
static void register_plugin () {
DataSink.PluginRegistry.get_default ().register_plugin (
typeof (SwitchboardPlugin),
"Switchboard Search",
_("Find switchboard plugs and open them."),
"preferences-desktop",
register_plugin
);
Expand Down
5 changes: 1 addition & 4 deletions src/synapse-plugins/system-managment.vala
Original file line number Diff line number Diff line change
Expand Up @@ -503,13 +503,10 @@ namespace Synapse {
static void register_plugin () {
DataSink.PluginRegistry.get_default ().register_plugin (
typeof (SystemManagementPlugin),
"System Management",
_("Lock the session or Log Out from it. Suspend, hibernate, restart or shutdown your computer."),
"system-restart",
register_plugin,
DBusService.get_default ().service_is_available (SystemdObject.UNIQUE_NAME) ||
DBusService.get_default ().service_is_available (ConsoleKitObject.UNIQUE_NAME),
_("ConsoleKit wasn't found")
DBusService.get_default ().service_is_available (ConsoleKitObject.UNIQUE_NAME)
);
}

Expand Down
Loading