Commit 2b3a16ba authored by Alberts Muktupāvels's avatar Alberts Muktupāvels

libgnome-panel: add support for initial settings

parent 5de566dc
Pipeline #30771 failed with stage
in 3 minutes and 58 seconds
......@@ -190,6 +190,7 @@ gp_applet_manager_load_applet (PanelAppletsManager *manager,
PanelOrientation panel_orientation;
GtkOrientation orientation;
GtkPositionType position;
GVariant *initial_settings;
GError *error;
GpApplet *applet;
GpAppletFrame *frame;
......@@ -238,8 +239,13 @@ gp_applet_manager_load_applet (PanelAppletsManager *manager,
break;
}
initial_settings = NULL;
error = NULL;
applet = gp_module_applet_new (module, applet_id, settings_path, &error);
applet = gp_module_applet_new (module, applet_id, settings_path,
initial_settings, &error);
g_clear_pointer (&initial_settings, g_variant_unref);
g_free (settings_path);
if (!applet)
......
......@@ -62,6 +62,7 @@ typedef struct
gchar *id;
gchar *settings_path;
GVariant *initial_settings;
gchar *gettext_domain;
gboolean locked_down;
GtkOrientation orientation;
......@@ -86,6 +87,7 @@ enum
PROP_ID,
PROP_SETTINGS_PATH,
PROP_INITIAL_SETTINGS,
PROP_GETTEXT_DOMAIN,
PROP_LOCKED_DOWN,
PROP_ORIENTATION,
......@@ -291,6 +293,7 @@ static void
gp_applet_constructed (GObject *object)
{
GpApplet *applet;
GpAppletClass *applet_class;
GpAppletPrivate *priv;
GActionGroup *group;
GtkStyleContext *context;
......@@ -298,8 +301,13 @@ gp_applet_constructed (GObject *object)
G_OBJECT_CLASS (gp_applet_parent_class)->constructed (object);
applet = GP_APPLET (object);
applet_class = GP_APPLET_GET_CLASS (applet);
priv = gp_applet_get_instance_private (applet);
if (applet_class->initial_setup != NULL && priv->initial_settings != NULL)
applet_class->initial_setup (applet, priv->initial_settings);
g_clear_pointer (&priv->initial_settings, g_variant_unref);
gtk_builder_set_translation_domain (priv->builder, priv->gettext_domain);
group = G_ACTION_GROUP (priv->action_group);
......@@ -327,6 +335,7 @@ gp_applet_dispose (GObject *object)
priv->size_hints_idle = 0;
}
g_clear_pointer (&priv->initial_settings, g_variant_unref);
g_clear_object (&priv->general_settings);
G_OBJECT_CLASS (gp_applet_parent_class)->dispose (object);
......@@ -371,6 +380,10 @@ gp_applet_get_property (GObject *object,
g_value_set_string (value, priv->settings_path);
break;
case PROP_INITIAL_SETTINGS:
g_value_set_variant (value, priv->initial_settings);
break;
case PROP_GETTEXT_DOMAIN:
g_value_set_string (value, priv->gettext_domain);
break;
......@@ -429,6 +442,11 @@ gp_applet_set_property (GObject *object,
priv->settings_path = g_value_dup_string (value);
break;
case PROP_INITIAL_SETTINGS:
g_assert (priv->initial_settings == NULL);
priv->initial_settings = g_value_dup_variant (value);
break;
case PROP_GETTEXT_DOMAIN:
g_assert (priv->gettext_domain == NULL);
priv->gettext_domain = g_value_dup_string (value);
......@@ -572,6 +590,17 @@ install_properties (GObjectClass *object_class)
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS);
/**
* GpApplet:initial-settings:
*
* The GVariant with initial settings.
*/
properties[PROP_INITIAL_SETTINGS] =
g_param_spec_variant ("initial-settings", "Initial Settings", "Initial Settings",
G_VARIANT_TYPE ("a{sv}"), NULL,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE |
G_PARAM_STATIC_STRINGS);
/**
* GpApplet:gettext-domain:
*
......
......@@ -59,6 +59,7 @@ typedef enum
/**
* GpAppletClass:
* @parent_class: The parent class.
* @initial_setup: virtual method called when applet has initial settings
* @placement_changed: Signal is emitted when the orientation or position
* properties of applet has changed.
*
......@@ -68,6 +69,9 @@ struct _GpAppletClass
{
GtkEventBoxClass parent_class;
void (* initial_setup) (GpApplet *applet,
GVariant *initial_settings);
void (* placement_changed) (GpApplet *applet,
GtkOrientation orientation,
GtkPositionType position);
......
......@@ -51,6 +51,7 @@ const gchar *gp_module_get_applet_id_from_iid (GpModule *module,
GpApplet *gp_module_applet_new (GpModule *module,
const gchar *applet,
const gchar *settings_path,
GVariant *initial_settings,
GError **error);
G_END_DECLS
......
......@@ -560,6 +560,7 @@ gp_module_get_applet_id_from_iid (GpModule *module,
* @module: a #GpModule
* @applet: the applet id
* @settings_path: the #GSettings path to the per-instance settings
* @initial_settings: initial settings
* @error: return location for a #GError, or %NULL
*
* Returns a newly allocated applet.
......@@ -570,6 +571,7 @@ GpApplet *
gp_module_applet_new (GpModule *module,
const gchar *applet,
const gchar *settings_path,
GVariant *initial_settings,
GError **error)
{
GpAppletInfo *info;
......@@ -606,6 +608,7 @@ gp_module_applet_new (GpModule *module,
return g_object_new (type,
"id", applet,
"settings-path", settings_path,
"initial-settings", initial_settings,
"gettext-domain", module->gettext_domain,
NULL);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment