summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAylur <[email protected]>2024-11-01 14:01:05 +0000
committerAylur <[email protected]>2024-11-01 14:01:05 +0000
commitdf4c505097b0394d1a75565c2a5e8b47837c3050 (patch)
tree7e945e57131c64fdf3a92170d59cbbb11efe80a9
parent0608b6b8aebb3d85993411b6c07f2850c404bd29 (diff)
apps: remove redundant properties
there is no need for the enable properties since setting the multiplier to a non zero or zero value is the same thing
-rw-r--r--docs/guide/libraries/apps.md25
-rw-r--r--lib/apps/application.vala3
-rw-r--r--lib/apps/apps.vala69
3 files changed, 40 insertions, 57 deletions
diff --git a/docs/guide/libraries/apps.md b/docs/guide/libraries/apps.md
index 7f9ee6e..d778e87 100644
--- a/docs/guide/libraries/apps.md
+++ b/docs/guide/libraries/apps.md
@@ -55,8 +55,9 @@ astal-apps --help
import Apps from "gi://AstalApps"
const apps = new Apps.Apps({
- includeEntry: true,
- includeExecutable: true,
+ nameMultiplier: 2,
+ entryMultiplier: 0,
+ executableMultiplier: 2,
})
for (const app of apps.fuzzy_query("spotify")) {
@@ -68,8 +69,9 @@ for (const app of apps.fuzzy_query("spotify")) {
from gi.repository import AstalApps as Apps
apps = Apps.Apps(
- include_entry=True,
- include_executable=True,
+ name_multiplier=2,
+ entry_multiplier=0,
+ executable_multiplier=2,
)
for app in apps.fuzzy_query("obsidian"):
@@ -81,8 +83,9 @@ for app in apps.fuzzy_query("obsidian"):
local Apps = require("lgi").require("AstalApps")
local apps = Apps.Apps({
- include_entry = true,
- include_executable = true,
+ name_multiplier = 2,
+ entry_multiplier = 0,
+ executable_multiplier = 2,
})
for _, app in ipairs(apps:fuzzy_query("lutris")) do
@@ -91,7 +94,15 @@ end
```
```vala [<i class="devicon-vala-plain"></i> Vala]
-// Not yet documented, contributions are appreciated
+var apps = new AstalApps.Apps() {
+ name_multiplier = 2,
+ entry_multiplier = 0,
+ executable_multiplier = 2,
+};
+
+foreach (var app in apps.fuzzy_query("firefox")) {
+ print(app.name);
+}
```
:::
diff --git a/lib/apps/application.vala b/lib/apps/application.vala
index 75b47e9..3a9900a 100644
--- a/lib/apps/application.vala
+++ b/lib/apps/application.vala
@@ -1,3 +1,6 @@
+/**
+ * Object representing an applications .desktop file.
+ */
public class AstalApps.Application : Object {
/**
* The underlying DesktopAppInfo.
diff --git a/lib/apps/apps.vala b/lib/apps/apps.vala
index 30c305a..999643c 100644
--- a/lib/apps/apps.vala
+++ b/lib/apps/apps.vala
@@ -1,3 +1,8 @@
+/**
+ * This object can be used to query applications.
+ * Multipliers can be set to customize [[email protected]] results
+ * from queries which then are summed and sorted accordingly.
+ */
public class AstalApps.Apps : Object {
private string cache_directory;
private string cache_file;
@@ -27,21 +32,21 @@ public class AstalApps.Apps : Object {
/**
* Extra multiplier to apply when matching the entry of an application.
- * Defaults to `1`
+ * Defaults to `0`
*/
- public double entry_multiplier { get; set; default = 1; }
+ public double entry_multiplier { get; set; default = 0; }
/**
* Extra multiplier to apply when matching the executable of an application.
- * Defaults to `1`
+ * Defaults to `0.5`
*/
- public double executable_multiplier { get; set; default = 1; }
+ public double executable_multiplier { get; set; default = 0.5; }
/**
* Extra multiplier to apply when matching the description of an application.
- * Defaults to `0.5`
+ * Defaults to `0`
*/
- public double description_multiplier { get; set; default = 0.5; }
+ public double description_multiplier { get; set; default = 0; }
/**
* Extra multiplier to apply when matching the keywords of an application.
@@ -51,45 +56,9 @@ public class AstalApps.Apps : Object {
/**
* Extra multiplier to apply when matching the categories of an application.
- * Defaults to `0.5`
- */
- public double categories_multiplier { get; set; default = 0.5; }
-
- /**
- * Consider the name of an application during queries.
- * Defaults to `true`
- */
- public bool include_name { get; set; default = true; }
-
- /**
- * Consider the entry of an application during queries.
- * Defaults to `false`
- */
- public bool include_entry { get; set; default = false; }
-
- /**
- * Consider the executable of an application during queries.
- * Defaults to `false`
- */
- public bool include_executable { get; set; default = false; }
-
- /**
- * Consider the description of an application during queries.
- * Defaults to `false`
- */
- public bool include_description { get; set; default = false; }
-
- /**
- * Consider the keywords of an application during queries.
- * Defaults to `false`
- */
- public bool include_keywords { get; set; default = false; }
-
- /**
- * Consider the categories of an application during queries.
- * Defaults to `false`
+ * Defaults to `0`
*/
- public bool include_categories { get; set; default = false; }
+ public double categories_multiplier { get; set; default = 0; }
construct {
cache_directory = Environment.get_user_cache_dir() + "/astal";
@@ -127,12 +96,12 @@ public class AstalApps.Apps : Object {
if (alg == FUZZY) s = a.fuzzy_match(search);
if (alg == EXACT) s = a.exact_match(search);
- if (include_name) r += s.name * name_multiplier;
- if (include_entry) r += s.entry * entry_multiplier;
- if (include_executable) r += s.executable * executable_multiplier;
- if (include_description) r += s.description * description_multiplier;
- if (include_keywords) r += s.keywords * keywords_multiplier;
- if (include_categories) r += s.categories * categories_multiplier;
+ r += s.name * name_multiplier;
+ r += s.entry * entry_multiplier;
+ r += s.executable * executable_multiplier;
+ r += s.description * description_multiplier;
+ r += s.keywords * keywords_multiplier;
+ r += s.categories * categories_multiplier;
return r;
}