diff options
author | William Wold <[email protected]> | 2019-06-18 05:57:35 +0000 |
---|---|---|
committer | raveit65 <[email protected]> | 2019-06-20 08:15:12 +0200 |
commit | 17b300a83857eeed10c14b4c1ec1bb0b9ccb5ff2 (patch) | |
tree | 5bb4182424fe04c65d915c01d1871c93a248eca7 | |
parent | d6f085fe853cedcf612c0b4a8b3a40585414dfa4 (diff) | |
download | mate-panel-17b300a83857eeed10c14b4c1ec1bb0b9ccb5ff2.tar.bz2 mate-panel-17b300a83857eeed10c14b4c1ec1bb0b9ccb5ff2.tar.xz |
Load and store what platforms applets support
-rw-r--r-- | mate-panel/libmate-panel-applet-private/panel-applets-manager-dbus.c | 32 | ||||
-rw-r--r-- | mate-panel/panel-addto.c | 19 | ||||
-rw-r--r-- | mate-panel/panel-applet-info.c | 36 | ||||
-rw-r--r-- | mate-panel/panel-applet-info.h | 15 |
4 files changed, 87 insertions, 15 deletions
diff --git a/mate-panel/libmate-panel-applet-private/panel-applets-manager-dbus.c b/mate-panel/libmate-panel-applet-private/panel-applets-manager-dbus.c index e0aacc0b..496190b7 100644 --- a/mate-panel/libmate-panel-applet-private/panel-applets-manager-dbus.c +++ b/mate-panel/libmate-panel-applet-private/panel-applets-manager-dbus.c @@ -97,6 +97,9 @@ _mate_panel_applets_manager_get_applet_info (GKeyFile *applet_file, char *comment; char *icon; char **old_ids; + char **supported_platforms; + gboolean x11_supported; + gboolean wayland_supported; iid = g_strdup_printf ("%s::%s", factory_id, group); name = g_key_file_get_locale_string (applet_file, group, @@ -108,13 +111,40 @@ _mate_panel_applets_manager_get_applet_info (GKeyFile *applet_file, old_ids = g_key_file_get_string_list (applet_file, group, "MateComponentId", NULL, NULL); - info = mate_panel_applet_info_new (iid, name, comment, icon, (const char **) old_ids); + supported_platforms = g_key_file_get_string_list (applet_file, group, + "Platforms", NULL, NULL); + if (supported_platforms == NULL) { + // If supported platforms are not specified, assume all are supported + x11_supported = TRUE; + wayland_supported = TRUE; + } else { + int len, i; + + x11_supported = FALSE; + wayland_supported = FALSE; + len = g_strv_length ((gchar **) supported_platforms); + for (i = 0; i < len; i++) { + if (g_strcmp0 (supported_platforms[i], "X11") == 0) { + x11_supported = TRUE; + } else if (g_strcmp0 (supported_platforms[i], "Wayland") == 0) { + wayland_supported = TRUE; + } else { + g_warning ("Unknown platform in %s applet: %s. " + "Valid platforms are X11 and Wayland", + name, supported_platforms[i]); + } + } + } + + info = mate_panel_applet_info_new (iid, name, comment, icon, (const char **) old_ids, + x11_supported, wayland_supported); g_free (iid); g_free (name); g_free (comment); g_free (icon); g_strfreev (old_ids); + g_strfreev (supported_platforms); return info; } diff --git a/mate-panel/panel-addto.c b/mate-panel/panel-addto.c index 6a9d9536..3f6fa11e 100644 --- a/mate-panel/panel-addto.c +++ b/mate-panel/panel-addto.c @@ -397,6 +397,7 @@ panel_addto_query_applets (GSList *list) for (l = applet_list; l; l = g_list_next (l)) { MatePanelAppletInfo *info; const char *iid, *name, *description, *icon; + gboolean enabled; PanelAddtoItemInfo *applet; info = (MatePanelAppletInfo *)l->data; @@ -410,13 +411,29 @@ panel_addto_query_applets (GSList *list) continue; } + enabled = TRUE; +#ifdef HAVE_X11 + if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()) && + !mate_panel_applet_info_get_x11_supported (info)) { + enabled = FALSE; + description = _("Not compatible with X11"); + } +#endif +#ifdef HAVE_WAYLAND + if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ()) && + !mate_panel_applet_info_get_wayland_supported (info)) { + enabled = FALSE; + description = _("Not compatible with Wayland"); + } +#endif + applet = g_new0 (PanelAddtoItemInfo, 1); applet->type = PANEL_ADDTO_APPLET; applet->name = g_strdup (name); applet->description = g_strdup (description); applet->icon = g_strdup (icon); applet->iid = g_strdup (iid); - applet->enabled = TRUE; + applet->enabled = enabled; applet->static_data = FALSE; list = g_slist_prepend (list, applet); diff --git a/mate-panel/panel-applet-info.c b/mate-panel/panel-applet-info.c index 10023ea5..55d91dfd 100644 --- a/mate-panel/panel-applet-info.c +++ b/mate-panel/panel-applet-info.c @@ -32,17 +32,20 @@ struct _MatePanelAppletInfo { gchar *icon; gchar **old_ids; + gboolean x11_supported; + gboolean wayland_supported; }; MatePanelAppletInfo * mate_panel_applet_info_new (const gchar *iid, - const gchar *name, - const gchar *comment, - const gchar *icon, - const gchar **old_ids) + const gchar *name, + const gchar *comment, + const gchar *icon, + const gchar **old_ids, + gboolean x11_supported, + gboolean wayland_supported) { MatePanelAppletInfo *info; - int len; info = g_slice_new0 (MatePanelAppletInfo); @@ -53,17 +56,22 @@ mate_panel_applet_info_new (const gchar *iid, /* MateComponent compatibility */ if (old_ids != NULL) { + int i, len; + len = g_strv_length ((gchar **) old_ids); if (len > 0) { - int i; - info->old_ids = g_new0 (gchar *, len + 1); - for (i = 0; i < len; i++) info->old_ids[i] = g_strdup (old_ids[i]); } } + info->x11_supported = x11_supported; + info->wayland_supported = wayland_supported; + + if (!x11_supported && !wayland_supported) + g_warning ("Applet %s has no supported platforms", name); + return info; } @@ -111,3 +119,15 @@ mate_panel_applet_info_get_old_ids (MatePanelAppletInfo *info) { return (const gchar * const *) info->old_ids; } + +gboolean +mate_panel_applet_info_get_x11_supported (MatePanelAppletInfo *info) +{ + return info->x11_supported; +} + +gboolean +mate_panel_applet_info_get_wayland_supported (MatePanelAppletInfo *info) +{ + return info->wayland_supported; +} diff --git a/mate-panel/panel-applet-info.h b/mate-panel/panel-applet-info.h index fafef8b5..1588b012 100644 --- a/mate-panel/panel-applet-info.h +++ b/mate-panel/panel-applet-info.h @@ -31,11 +31,14 @@ extern "C" { typedef struct _MatePanelAppletInfo MatePanelAppletInfo; -MatePanelAppletInfo *mate_panel_applet_info_new (const gchar *iid, - const gchar *name, - const gchar *comment, - const gchar *icon, - const gchar **old_ids); +MatePanelAppletInfo *mate_panel_applet_info_new (const gchar *iid, + const gchar *name, + const gchar *comment, + const gchar *icon, + const gchar **old_ids, + gboolean x11_supported, + gboolean wayland_supported); + void mate_panel_applet_info_free (MatePanelAppletInfo *info); const gchar *mate_panel_applet_info_get_iid (MatePanelAppletInfo *info); @@ -43,6 +46,8 @@ const gchar *mate_panel_applet_info_get_name (MatePan const gchar *mate_panel_applet_info_get_description (MatePanelAppletInfo *info); const gchar *mate_panel_applet_info_get_icon (MatePanelAppletInfo *info); const gchar * const *mate_panel_applet_info_get_old_ids (MatePanelAppletInfo *info); +gboolean mate_panel_applet_info_get_x11_supported (MatePanelAppletInfo *info); +gboolean mate_panel_applet_info_get_wayland_supported (MatePanelAppletInfo *info); #ifdef __cplusplus } |