gmc-holle / xfdashboard

Maybe a Gnome shell like dashboard for Xfce
GNU General Public License v2.0
121 stars 14 forks source link

Add support for keywords #159

Closed gsantner closed 7 years ago

gsantner commented 7 years ago

I contributed to garcon, especially with xfdashboard in mind, to allow parsing and getting/settings Keywords of freedesktop compliant files, see Keywords= on Spec. My patch was added to garcon recently (https://bugzilla.xfce.org/show_bug.cgi?id=10683#c10, https://git.xfce.org/xfce/garcon/commit/?id=a38922c0892262294c88813c4bf0c72e2f438d54).

It would be great if xfdashboard could too browse keywords when searching. So if theres e.g. "Keywords=maths;calculation;" in the .desktop file, and "math" gets typed, that the calculator shows up as one of the results.

I tried to compile xfdashboard with git version of garcon, and printed out the first item to check if it would work (which did):

diff --git a/libxfdashboard/desktop-app-info.c b/libxfdashboard/desktop-app-info.c
index 78942bd..32a2c6d 100644
--- a/libxfdashboard/desktop-app-info.c
+++ b/libxfdashboard/desktop-app-info.c
@@ -33,6 +33,7 @@
 #include <libxfdashboard/compat.h>
 #include <libxfdashboard/debug.h>

+#include <stdio.h>

 /* Define this class in GObject system */
 static void _xfdashboard_desktop_app_info_gappinfo_iface_init(GAppInfoIface *iface);
@@ -826,6 +827,8 @@ static const gchar* _xfdashboard_desktop_app_info_gappinfo_get_description(GAppI
        XfdashboardDesktopAppInfo                       *self;
        XfdashboardDesktopAppInfoPrivate        *priv;

+
+
        g_return_val_if_fail(XFDASHBOARD_IS_DESKTOP_APP_INFO(inAppInfo), NULL);

:...skipping...
diff --git a/libxfdashboard/desktop-app-info.c b/libxfdashboard/desktop-app-info.c
index 78942bd..32a2c6d 100644
--- a/libxfdashboard/desktop-app-info.c
+++ b/libxfdashboard/desktop-app-info.c
@@ -33,6 +33,7 @@
 #include <libxfdashboard/compat.h>
 #include <libxfdashboard/debug.h>

+#include <stdio.h>

 /* Define this class in GObject system */
 static void _xfdashboard_desktop_app_info_gappinfo_iface_init(GAppInfoIface *iface);
@@ -826,6 +827,8 @@ static const gchar* _xfdashboard_desktop_app_info_gappinfo_get_description(GAppI
        XfdashboardDesktopAppInfo                       *self;
        XfdashboardDesktopAppInfoPrivate        *priv;

        g_return_val_if_fail(XFDASHBOARD_IS_DESKTOP_APP_INFO(inAppInfo), NULL);

        self=XFDASHBOARD_DESKTOP_APP_INFO(inAppInfo);
@@ -833,8 +836,17 @@ static const gchar* _xfdashboard_desktop_app_info_gappinfo_get_description(GAppI

        /* If desktop app info has no item return NULL here */
        if(!priv->item) return(NULL);
+    GList* keywords = garcon_menu_item_get_keywords(priv->item);

       /* Return comment of menu item as description */
+     printf("xfdashboard Debug:] %s ::: ", garcon_menu_item_get_name(priv->item) );
+     if (keywords != NULL){
+        gpointer data1 = g_list_first(keywords)->data;
+        char* data2 = (char *) data1;
+        printf("%s", data2);
+     }
+  printf("\n");
+
        return(garcon_menu_item_get_comment(priv->item));
 }
gmc-holle commented 7 years ago

No problem. Any data provided by garcon can be used. But 1) it is not official released, so I cannot include it with a #ifdef GARCON_CHECK_VERSION(...) switch and 2) as older garcon version are also supported I have to include a fallback function. It's the same as with desktop action (see #158) for 2).

gmc-holle commented 7 years ago

Support for keyword is added to XfdashboardDesktopAppInfo at least. Using them in the application search provider is a little bit harder :/

Keeping this issue open until the keywords are used in search.

gmc-holle commented 7 years ago

It's now fully implemented so keywords are also checked when searching for matching applications. Could you test it also?

gsantner commented 7 years ago

works, thanks!