[gnome-panel/wip/muktupavels/api: 3/7] libgnome-panel: add GpApplet:lockdowns property
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel/wip/muktupavels/api: 3/7] libgnome-panel: add GpApplet:lockdowns property
- Date: Tue, 14 Apr 2020 22:19:09 +0000 (UTC)
commit 3bd329d323947e987ec5a27dea99e4ea89bf5fcd
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Tue Apr 14 17:29:10 2020 +0300
libgnome-panel: add GpApplet:lockdowns property
gnome-panel/panel-applet-frame.c | 18 +++--------
libgnome-panel/gp-applet-private.h | 5 ++-
libgnome-panel/gp-applet.c | 65 ++++++++++++++++++++++++++++++++++++--
libgnome-panel/gp-applet.h | 5 ++-
4 files changed, 75 insertions(+), 18 deletions(-)
---
diff --git a/gnome-panel/panel-applet-frame.c b/gnome-panel/panel-applet-frame.c
index a2fba679e..3c79fe6f2 100644
--- a/gnome-panel/panel-applet-frame.c
+++ b/gnome-panel/panel-applet-frame.c
@@ -637,29 +637,19 @@ panel_applet_frame_init_properties (PanelAppletFrame *self)
update_size_hints (self);
}
-static void
-frame_sync_menu_state (PanelAppletFrame *self,
- gboolean movable,
- gboolean removable,
- gboolean locked_down)
-{
- gp_applet_set_locked_down (self->priv->applet, locked_down);
-}
-
static void
panel_applet_frame_sync_menu_state (PanelLockdown *lockdown,
gpointer user_data)
{
PanelAppletFrame *frame = PANEL_APPLET_FRAME (user_data);
gboolean locked_down;
- gboolean movable;
- gboolean removable;
+ GpLockdownFlags lockdowns;
- movable = panel_applet_can_freely_move (frame->priv->applet_info);
- removable = panel_layout_is_writable ();
locked_down = panel_lockdown_get_panels_locked_down_s ();
+ lockdowns = panel_lockdown_get_flags_s (frame->priv->iid);
- frame_sync_menu_state (frame, movable, removable, locked_down);
+ gp_applet_set_locked_down (frame->priv->applet, locked_down);
+ gp_applet_set_lockdowns (frame->priv->applet, lockdowns);
}
static void
diff --git a/libgnome-panel/gp-applet-private.h b/libgnome-panel/gp-applet-private.h
index a597facdb..26f6b845f 100644
--- a/libgnome-panel/gp-applet-private.h
+++ b/libgnome-panel/gp-applet-private.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001 Sun Microsystems, Inc.
- * Copyright (C) 2016 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
@@ -30,6 +30,9 @@ G_BEGIN_DECLS
void gp_applet_set_locked_down (GpApplet *applet,
gboolean locked_down);
+void gp_applet_set_lockdowns (GpApplet *applet,
+ GpLockdownFlags lockdowns);
+
void gp_applet_set_orientation (GpApplet *applet,
GtkOrientation orientation);
diff --git a/libgnome-panel/gp-applet.c b/libgnome-panel/gp-applet.c
index 3d1c2bf95..9395e6fc6 100644
--- a/libgnome-panel/gp-applet.c
+++ b/libgnome-panel/gp-applet.c
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2001 Sun Microsystems, Inc.
* Copyright (c) 2010 Carlos Garcia Campos
- * 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
@@ -68,6 +68,7 @@ typedef struct
GVariant *initial_settings;
gchar *gettext_domain;
gboolean locked_down;
+ GpLockdownFlags lockdowns;
GtkOrientation orientation;
GtkPositionType position;
@@ -99,6 +100,7 @@ enum
PROP_INITIAL_SETTINGS,
PROP_GETTEXT_DOMAIN,
PROP_LOCKED_DOWN,
+ PROP_LOCKDOWNS,
PROP_ORIENTATION,
PROP_POSITION,
@@ -435,6 +437,10 @@ gp_applet_get_property (GObject *object,
g_value_set_boolean (value, priv->locked_down);
break;
+ case PROP_LOCKDOWNS:
+ g_value_set_flags (value, priv->lockdowns);
+ break;
+
case PROP_ORIENTATION:
g_value_set_enum (value, priv->orientation);
break;
@@ -508,6 +514,10 @@ gp_applet_set_property (GObject *object,
gp_applet_set_locked_down (applet, g_value_get_boolean (value));
break;
+ case PROP_LOCKDOWNS:
+ gp_applet_set_lockdowns (applet, g_value_get_flags (value));
+ break;
+
case PROP_ORIENTATION:
gp_applet_set_orientation (applet, g_value_get_enum (value));
break;
@@ -684,12 +694,28 @@ install_properties (GObjectClass *object_class)
* GpApplet:locked-down:
*
* Whether the applet is on locked down panel.
+ *
+ * Deprecated: 3.38: Use #GpApplet:lockdowns instead
*/
properties[PROP_LOCKED_DOWN] =
g_param_spec_boolean ("locked-down", "Locked Down", "Locked Down",
FALSE,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY |
- G_PARAM_STATIC_STRINGS);
+ G_PARAM_STATIC_STRINGS | G_PARAM_DEPRECATED);
+
+ /**
+ * GpApplet:lockdowns:
+ *
+ * Active lockdowns.
+ */
+ properties[PROP_LOCKDOWNS] =
+ g_param_spec_flags ("lockdowns",
+ "Lockdowns",
+ "Lockdowns",
+ GP_TYPE_LOCKDOWN_FLAGS,
+ GP_LOCKDOWN_FLAGS_NONE,
+ G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS);
/**
* GpApplet:orientation:
@@ -885,6 +911,41 @@ gp_applet_set_locked_down (GpApplet *applet,
g_object_notify_by_pspec (G_OBJECT (applet), properties[PROP_LOCKED_DOWN]);
}
+/**
+ * gp_applet_get_lockdowns:
+ * @applet: a #GpApplet
+ *
+ * Gets active lockdowns.
+ *
+ * Returns: the #GpLockdownFlags of @applet.
+ */
+GpLockdownFlags
+gp_applet_get_lockdowns (GpApplet *applet)
+{
+ GpAppletPrivate *priv;
+
+ g_return_val_if_fail (GP_IS_APPLET (applet), GP_LOCKDOWN_FLAGS_NONE);
+ priv = gp_applet_get_instance_private (applet);
+
+ return priv->lockdowns;
+}
+
+void
+gp_applet_set_lockdowns (GpApplet *applet,
+ GpLockdownFlags lockdowns)
+{
+ GpAppletPrivate *priv;
+
+ priv = gp_applet_get_instance_private (applet);
+
+ if (priv->lockdowns == lockdowns)
+ return;
+
+ priv->lockdowns = lockdowns;
+
+ g_object_notify_by_pspec (G_OBJECT (applet), properties[PROP_LOCKDOWNS]);
+}
+
/**
* gp_applet_get_orientation:
* @applet: a #GpApplet
diff --git a/libgnome-panel/gp-applet.h b/libgnome-panel/gp-applet.h
index 005411419..9c61703df 100644
--- a/libgnome-panel/gp-applet.h
+++ b/libgnome-panel/gp-applet.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 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
@@ -19,6 +19,7 @@
#define GP_APPLET_H
#include <gtk/gtk.h>
+#include <libgnome-panel/gp-lockdown.h>
G_BEGIN_DECLS
@@ -86,6 +87,8 @@ struct _GpAppletClass
gboolean gp_applet_get_locked_down (GpApplet *applet);
+GpLockdownFlags gp_applet_get_lockdowns (GpApplet *applet);
+
GtkOrientation gp_applet_get_orientation (GpApplet *applet);
GtkPositionType gp_applet_get_position (GpApplet *applet);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]