[gnome-panel/wip/3.0-freeze-break] panel: Port code to check if panel can be dragged to GSettings



commit 21cf50781dbf1d4ab7fcccd67b6e42dbec43d106
Author: Vincent Untz <vuntz gnome org>
Date:   Fri Mar 25 12:23:55 2011 +0100

    panel: Port code to check if panel can be dragged to GSettings

 gnome-panel/panel-profile.c  |  112 ------------------------------------------
 gnome-panel/panel-toplevel.c |   34 ++++++++++++-
 2 files changed, 33 insertions(+), 113 deletions(-)
---
diff --git a/gnome-panel/panel-profile.c b/gnome-panel/panel-profile.c
index f803c4e..68b0752 100644
--- a/gnome-panel/panel-profile.c
+++ b/gnome-panel/panel-profile.c
@@ -72,25 +72,6 @@ static void panel_profile_object_id_list_update (GConfClient       *client,
 						 GConfValue        *value,
 						 PanelGConfKeyType  type);
 
-gboolean
-panel_profile_map_orientation_string (const char       *str,
-				      PanelOrientation *orientation)
-{
-	int mapped;
-
-	g_return_val_if_fail (orientation != NULL, FALSE);
-
-	if (!str)
-		return FALSE;
-
-	if (!gconf_string_to_enum (panel_orientation_map, str, &mapped))
-		return FALSE;
-
-	*orientation = mapped;
-
-	return TRUE;
-}
-
 const char *
 panel_profile_map_orientation (PanelOrientation orientation)
 {
@@ -171,51 +152,6 @@ panel_profile_find_new_id (PanelGConfKeyType type)
 	return retval;
 }
 
-static const char *
-panel_profile_get_toplevel_key (PanelToplevel *toplevel,
-				const char    *key)
-{
-	const char *id;
-
-	id = panel_toplevel_get_toplevel_id (toplevel);
-
-	return panel_gconf_full_key (PANEL_GCONF_TOPLEVELS, id, key);
-}
-
-#define TOPLEVEL_IS_WRITABLE_FUNC(k, p, s)                            \
-	gboolean                                                      \
-	panel_profile_is_writable_##p##_##s (PanelToplevel *toplevel) \
-	{                                                             \
-		GConfClient *client;                                  \
-		const char  *key;                                     \
-		client = panel_gconf_get_client ();                   \
-		key = panel_profile_get_toplevel_key (toplevel, k);   \
-		return gconf_client_key_is_writable (client, key, NULL); \
-	}
-
-PanelOrientation
-panel_profile_get_toplevel_orientation (PanelToplevel *toplevel)
-{
-	PanelOrientation  orientation;
-	GConfClient      *client;
-	const char       *key;
-	char             *str;
-
-	client = panel_gconf_get_client ();
-
-	key = panel_profile_get_toplevel_key (toplevel, "orientation");
-	str = gconf_client_get_string (client, key, NULL);
-
-	if (!panel_profile_map_orientation_string (str, &orientation))
-	    orientation = panel_toplevel_get_orientation (toplevel);
-
-	g_free (str);
-
-	return orientation;
-}
-
-TOPLEVEL_IS_WRITABLE_FUNC ("orientation", toplevel, orientation)
-
 static void
 panel_profile_save_id_list (PanelGConfKeyType  type,
 			    GSList            *list,
@@ -1013,51 +949,3 @@ panel_profile_load (void)
 
 	panel_applet_load_queued_applets (TRUE);
 }
-
-gboolean
-panel_profile_can_be_moved_freely (PanelToplevel *toplevel)
-{
-	const char *key;
-	GConfClient *client;
-
-	if (panel_lockdown_get_panels_locked_down_s () ||
-	    !panel_profile_is_writable_toplevel_orientation (toplevel))
-		return FALSE;
-
-	client = panel_gconf_get_client ();
-
-	key = panel_profile_get_toplevel_key (toplevel, "screen");
-	if (!gconf_client_key_is_writable (client, key, NULL))
-		return FALSE;
-
-	key = panel_profile_get_toplevel_key (toplevel, "monitor");
-	if (!gconf_client_key_is_writable (client, key, NULL))
-		return FALSE;
-
-	/* For expanded panels we don't really have to check 
-	   x and y */
-	if (panel_toplevel_get_expand (toplevel))
-		return TRUE;
-
-	key = panel_profile_get_toplevel_key (toplevel, "x");
-	if (!gconf_client_key_is_writable (client, key, NULL))
-		return FALSE;
-	key = panel_profile_get_toplevel_key (toplevel, "x_right");
-	if (!gconf_client_key_is_writable (client, key, NULL))
-		return FALSE;
-	key = panel_profile_get_toplevel_key (toplevel, "x_centered");
-	if (!gconf_client_key_is_writable (client, key, NULL))
-		return FALSE;
-
-	key = panel_profile_get_toplevel_key (toplevel, "y");
-	if (!gconf_client_key_is_writable (client, key, NULL))
-		return FALSE;
-	key = panel_profile_get_toplevel_key (toplevel, "y_bottom");
-	if (!gconf_client_key_is_writable (client, key, NULL))
-		return FALSE;
-	key = panel_profile_get_toplevel_key (toplevel, "y_centered");
-	if (!gconf_client_key_is_writable (client, key, NULL))
-		return FALSE;
-
-	return TRUE;
-}
diff --git a/gnome-panel/panel-toplevel.c b/gnome-panel/panel-toplevel.c
index e032fc7..df94030 100644
--- a/gnome-panel/panel-toplevel.c
+++ b/gnome-panel/panel-toplevel.c
@@ -236,6 +236,8 @@ static GSList       *toplevel_list = NULL;
 
 static void panel_toplevel_calculate_animation_end_geometry (PanelToplevel *toplevel);
 
+static gboolean panel_toplevel_position_is_writable (PanelToplevel *toplevel);
+
 static void panel_toplevel_bind_gsettings       (PanelToplevel *toplevel);
 static void panel_toplevel_set_toplevel_id      (PanelToplevel *toplevel,
 						 const char    *toplevel_id);
@@ -465,7 +467,7 @@ panel_toplevel_begin_grab_op (PanelToplevel   *toplevel,
 	/* If any of the position/orientation are not writable,
 	   then we can't really move freely */
 	if (op_type == PANEL_GRAB_OP_MOVE &&
-	    ! panel_profile_can_be_moved_freely (toplevel))
+	    !panel_toplevel_position_is_writable (toplevel))
 		return;
 
 	/* If size is not writable, then we can't resize */
@@ -4291,6 +4293,36 @@ panel_toplevel_get_panel_widget (PanelToplevel *toplevel)
 }
 
 static gboolean
+panel_toplevel_position_is_writable (PanelToplevel *toplevel)
+{
+	if (panel_lockdown_get_panels_locked_down_s () ||
+	    !(g_settings_is_writable (toplevel->priv->settings,
+				      PANEL_TOPLEVEL_SCREEN_KEY) &&
+	      g_settings_is_writable (toplevel->priv->settings,
+				      PANEL_TOPLEVEL_MONITOR_KEY) &&
+	      g_settings_is_writable (toplevel->priv->settings,
+				      PANEL_TOPLEVEL_ORIENTATION_KEY)))
+		return FALSE;
+
+	/* For expanded panels we don't really have to check x and y */
+	if (panel_toplevel_get_expand (toplevel))
+		return TRUE;
+
+	return (g_settings_is_writable (toplevel->priv->settings,
+					PANEL_TOPLEVEL_X_KEY) &&
+		g_settings_is_writable (toplevel->priv->settings,
+					PANEL_TOPLEVEL_Y_KEY) &&
+		g_settings_is_writable (toplevel->priv->settings,
+					PANEL_TOPLEVEL_X_RIGHT_KEY) &&
+		g_settings_is_writable (toplevel->priv->settings,
+					PANEL_TOPLEVEL_Y_BOTTOM_KEY) &&
+		g_settings_is_writable (toplevel->priv->settings,
+					PANEL_TOPLEVEL_X_CENTERED_KEY) &&
+		g_settings_is_writable (toplevel->priv->settings,
+					PANEL_TOPLEVEL_Y_CENTERED_KEY));
+}
+
+static gboolean
 panel_toplevel_apply_delayed_settings (PanelToplevel *toplevel)
 {
 	g_settings_apply (toplevel->priv->delayed_settings);



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