[gnome-panel/wip/muktupavels/api: 4/7] libgnome-panel: add gp_applet_info_set_is_disabled



commit f208e683f2d630e9cb28c5f7f8b1906e759daa65
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Tue Apr 14 18:00:06 2020 +0300

    libgnome-panel: add gp_applet_info_set_is_disabled

 libgnome-panel/gp-applet-info-private.h |  4 +++-
 libgnome-panel/gp-applet-info.c         | 18 +++++++++++++++++-
 libgnome-panel/gp-applet-info.h         | 24 +++++++++++++++++++++++-
 3 files changed, 43 insertions(+), 3 deletions(-)
---
diff --git a/libgnome-panel/gp-applet-info-private.h b/libgnome-panel/gp-applet-info-private.h
index 4a1f111d0..2e8f33651 100644
--- a/libgnome-panel/gp-applet-info-private.h
+++ b/libgnome-panel/gp-applet-info-private.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2018 Alberts Muktupāvels
+ * Copyright (C) 2016-2020 Alberts Muktupāvels
  *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published by
@@ -36,6 +36,8 @@ struct _GpAppletInfo
   GpAboutDialogFunc         about_dialog_func;
 
   gchar                    *backends;
+
+  GpIsDisabledFunc          is_disabled_func;
 };
 
 void gp_applet_info_free (GpAppletInfo *info);
diff --git a/libgnome-panel/gp-applet-info.c b/libgnome-panel/gp-applet-info.c
index d93b688d3..5e0376452 100644
--- a/libgnome-panel/gp-applet-info.c
+++ b/libgnome-panel/gp-applet-info.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2018 Alberts Muktupāvels
+ * Copyright (C) 2016-2020 Alberts Muktupāvels
  *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published by
@@ -62,6 +62,8 @@ gp_applet_info_new (GpGetAppletTypeFunc  func,
 
   info->backends = NULL;
 
+  info->is_disabled_func = NULL;
+
   return info;
 }
 
@@ -124,6 +126,20 @@ gp_applet_info_set_backends (GpAppletInfo *info,
   info->backends = g_strdup (backends);
 }
 
+/**
+ * gp_applet_info_set_is_disabled:
+ * @info: a #GpAppletInfo
+ * @func: the function to call to check if applet should be disabled
+ *
+ * Specifies a function to be used to check if applet should be disabled.
+ */
+void
+gp_applet_info_set_is_disabled (GpAppletInfo     *info,
+                                GpIsDisabledFunc  func)
+{
+  info->is_disabled_func = func;
+}
+
 void
 gp_applet_info_free (GpAppletInfo *info)
 {
diff --git a/libgnome-panel/gp-applet-info.h b/libgnome-panel/gp-applet-info.h
index b6e7aabd6..f149ca431 100644
--- a/libgnome-panel/gp-applet-info.h
+++ b/libgnome-panel/gp-applet-info.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2018 Alberts Muktupāvels
+ * Copyright (C) 2016-2020 Alberts Muktupāvels
  *
  * This library is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published by
@@ -22,6 +22,7 @@
 
 #include <glib.h>
 #include <gtk/gtk.h>
+#include <libgnome-panel/gp-lockdown.h>
 
 G_BEGIN_DECLS
 
@@ -63,6 +64,24 @@ typedef void  (* GpInitialSetupDialogFunc) (GpInitialSetupDialog *dialog);
  */
 typedef void  (* GpAboutDialogFunc) (GtkAboutDialog *dialog);
 
+/**
+ * GpIsDisabledFunc:
+ * @flags: a #GpLockdownFlags with active lockdowns
+ * @reason: (out) (transfer full) (allow-none): return location for reason, or %NULL
+ *
+ * This function must return #TRUE if applet must be fully disabled (applet
+ * will not be loaded not user will be able to add it to panel). Function also
+ * should return reason why applet is disabled if @reason is not %NULL.
+ *
+ * If applet is usable with some active lockdowns it should return %FALSE and
+ * use #GpApplet:lockdows property to adjust behaviour/functionality.
+ *
+ * Returns: #TRUE if applet should be disabled.
+ */
+typedef gboolean (* GpIsDisabledFunc) (GpLockdownFlags   flags,
+                                       char            **reason);
+
+
 GpAppletInfo *gp_applet_info_new                      (GpGetAppletTypeFunc       func,
                                                        const gchar              *name,
                                                        const gchar              *description,
@@ -80,6 +99,9 @@ void          gp_applet_info_set_about_dialog         (GpAppletInfo
 void          gp_applet_info_set_backends             (GpAppletInfo             *info,
                                                        const gchar              *backends);
 
+void          gp_applet_info_set_is_disabled          (GpAppletInfo             *info,
+                                                       GpIsDisabledFunc          func);
+
 G_END_DECLS
 
 #endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]