[gnome-panel] libgnome-panel: make few properties read-only



commit ba763879c0eb3b5ccee617bd6a417ddf82a57f1c
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Wed Jan 10 18:23:02 2018 +0200

    libgnome-panel: make few properties read-only

 .../libpanel-applet-private/gp-applet-manager.c    |    8 +++--
 libgnome-panel/gp-applet.c                         |   14 ++++++---
 libgnome-panel/gp-module-private.h                 |   29 +++++++++-----------
 libgnome-panel/gp-module.c                         |   19 +++---------
 4 files changed, 32 insertions(+), 38 deletions(-)
---
diff --git a/gnome-panel/libpanel-applet-private/gp-applet-manager.c 
b/gnome-panel/libpanel-applet-private/gp-applet-manager.c
index 38b9743..5d44700 100644
--- a/gnome-panel/libpanel-applet-private/gp-applet-manager.c
+++ b/gnome-panel/libpanel-applet-private/gp-applet-manager.c
@@ -239,9 +239,7 @@ gp_applet_manager_load_applet (PanelAppletsManager        *manager,
     }
 
   error = NULL;
-  applet = gp_module_applet_new (module, applet_id, settings_path, locked_down,
-                                 orientation, position, &error);
-
+  applet = gp_module_applet_new (module, applet_id, settings_path, &error);
   g_free (settings_path);
 
   if (!applet)
@@ -252,6 +250,10 @@ gp_applet_manager_load_applet (PanelAppletsManager        *manager,
       return FALSE;
     }
 
+  gp_applet_set_locked_down (applet, locked_down);
+  gp_applet_set_orientation (applet, orientation);
+  gp_applet_set_position (applet, position);
+
   frame = g_object_new (GP_TYPE_APPLET_FRAME, NULL);
   gp_applet_frame_set_applet (frame, applet);
 
diff --git a/libgnome-panel/gp-applet.c b/libgnome-panel/gp-applet.c
index a0da020..c0ea2c1 100644
--- a/libgnome-panel/gp-applet.c
+++ b/libgnome-panel/gp-applet.c
@@ -470,8 +470,8 @@ install_properties (GObjectClass *object_class)
   properties[PROP_LOCKED_DOWN] =
     g_param_spec_boolean ("locked-down", "Locked Down", "Locked Down",
                           FALSE,
-                          G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
-                          G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
+                          G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY |
+                          G_PARAM_STATIC_STRINGS);
 
   /**
    * GpApplet:orientation:
@@ -481,7 +481,7 @@ install_properties (GObjectClass *object_class)
   properties[PROP_ORIENTATION] =
     g_param_spec_enum ("orientation", "Orientation", "Orientation",
                        GTK_TYPE_ORIENTATION, GTK_ORIENTATION_HORIZONTAL,
-                       G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
+                       G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY |
                        G_PARAM_STATIC_STRINGS);
 
   /**
@@ -492,7 +492,7 @@ install_properties (GObjectClass *object_class)
   properties[PROP_POSITION] =
     g_param_spec_enum ("position", "Position", "Position",
                        GTK_TYPE_POSITION_TYPE, GTK_POS_TOP,
-                       G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
+                       G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY |
                        G_PARAM_STATIC_STRINGS);
 
   /**
@@ -502,7 +502,7 @@ install_properties (GObjectClass *object_class)
    */
   properties[PROP_ENABLE_TOOLTIPS] =
     g_param_spec_boolean ("enable-tooltips", "Enable Tooltips", "Enable Tooltips",
-                          FALSE,
+                          TRUE,
                           G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY |
                           G_PARAM_STATIC_STRINGS);
 
@@ -663,6 +663,8 @@ gp_applet_set_orientation (GpApplet       *applet,
                  orientation, priv->position);
 
   priv->orientation = orientation;
+
+  g_object_notify_by_pspec (G_OBJECT (applet), properties[PROP_ORIENTATION]);
 }
 
 /**
@@ -699,6 +701,8 @@ gp_applet_set_position (GpApplet        *applet,
                  priv->orientation, position);
 
   priv->position = position;
+
+  g_object_notify_by_pspec (G_OBJECT (applet), properties[PROP_POSITION]);
 }
 
 /**
diff --git a/libgnome-panel/gp-module-private.h b/libgnome-panel/gp-module-private.h
index 9fb6380..8c85752 100644
--- a/libgnome-panel/gp-module-private.h
+++ b/libgnome-panel/gp-module-private.h
@@ -33,28 +33,25 @@ typedef enum
 #define GP_MODULE_ERROR gp_module_error_quark ()
 GQuark gp_module_error_quark (void);
 
-GpModule            *gp_module_new_from_path         (const gchar           *path);
+GpModule            *gp_module_new_from_path         (const gchar   *path);
 
-const gchar         *gp_module_get_id                (GpModule              *module);
+const gchar         *gp_module_get_id                (GpModule      *module);
 
-const gchar         *gp_module_get_version           (GpModule              *module);
+const gchar         *gp_module_get_version           (GpModule      *module);
 
-const gchar * const *gp_module_get_applets           (GpModule              *module);
+const gchar * const *gp_module_get_applets           (GpModule      *module);
 
-GpAppletInfo        *gp_module_get_applet_info       (GpModule              *module,
-                                                      const gchar           *applet,
-                                                      GError               **error);
+GpAppletInfo        *gp_module_get_applet_info       (GpModule      *module,
+                                                      const gchar   *applet,
+                                                      GError       **error);
 
-const gchar         *gp_module_get_applet_id_from_iid (GpModule              *module,
-                                                       const gchar           *old_iid);
+const gchar         *gp_module_get_applet_id_from_iid (GpModule     *module,
+                                                       const gchar  *old_iid);
 
-GpApplet            *gp_module_applet_new             (GpModule              *module,
-                                                       const gchar           *applet,
-                                                       const gchar           *settings_path,
-                                                       gboolean               locked_down,
-                                                       GtkOrientation         orientation,
-                                                       GtkPositionType        position,
-                                                       GError               **error);
+GpApplet            *gp_module_applet_new             (GpModule     *module,
+                                                       const gchar  *applet,
+                                                       const gchar  *settings_path,
+                                                       GError      **error);
 
 G_END_DECLS
 
diff --git a/libgnome-panel/gp-module.c b/libgnome-panel/gp-module.c
index 6d1f945..c6b76b1 100644
--- a/libgnome-panel/gp-module.c
+++ b/libgnome-panel/gp-module.c
@@ -505,7 +505,7 @@ gp_module_set_get_applet_info (GpModule            *module,
 }
 
 /**
- * gp_module_applet_new:
+ * gp_module_get_applet_info:
  * @module: a #GpModule
  * @applet: the applet id
  * @error: return location for a #GError, or %NULL
@@ -560,9 +560,6 @@ 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
- * @locked_down: whether applet is on locked down panel
- * @orientation: the orientation of the panel
- * @position: the position of the panel
  * @error: return location for a #GError, or %NULL
  *
  * Returns a newly allocated applet.
@@ -570,13 +567,10 @@ gp_module_get_applet_id_from_iid (GpModule    *module,
  * Returns: (transfer full): a newly created #GpApplet, or %NULL.
  */
 GpApplet *
-gp_module_applet_new (GpModule         *module,
-                      const gchar      *applet,
-                      const gchar      *settings_path,
-                      gboolean          locked_down,
-                      GtkOrientation    orientation,
-                      GtkPositionType   position,
-                      GError          **error)
+gp_module_applet_new (GpModule     *module,
+                      const gchar  *applet,
+                      const gchar  *settings_path,
+                      GError      **error)
 {
   GpAppletInfo *info;
   GType type;
@@ -613,8 +607,5 @@ gp_module_applet_new (GpModule         *module,
                        "id", applet,
                        "settings-path", settings_path,
                        "translation-domain", module->gettext_domain,
-                       "locked-down", locked_down,
-                       "orientation", orientation,
-                       "position", position,
                        NULL);
 }


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