File gnome-panel-disable-movement.patch of Package gnome-panel-nld

Index: gnome-panel/panel-context-menu.c
================================================================================
--- gnome-panel/panel-context-menu.c
+++ gnome-panel/panel-context-menu.c
@@ -151,6 +151,21 @@
 }
 
 static void
+cb_disable_movement_activate (GtkWidget *menuitem)
+{
+	PanelWidget *panel_widget;
+	gboolean     disable_movement;
+
+	panel_widget = menu_get_panel (menuitem);
+	disable_movement = panel_profile_get_toplevel_disable_movement (panel_widget->toplevel);
+	
+	gtk_label_set_label (GTK_LABEL (GTK_BIN(menuitem)->child),
+		       	     disable_movement ? _("_Lock Panel Postion") :_( "_Allow Panel to be Moved"));
+	
+	panel_profile_set_toplevel_disable_movement (panel_widget->toplevel, !disable_movement);
+}
+
+static void
 panel_context_menu_remove_panel (GtkWidget *menuitem,
 				 gpointer data)
 {
@@ -222,6 +237,7 @@
 make_panel_submenu (PanelWidget *panel_widget,
 		    GtkWidget   *menu)
 {
+	gboolean   disable_movement;
 	GtkWidget *menuitem;
 
 	menuitem = gtk_image_menu_item_new ();
@@ -270,6 +286,20 @@
 	add_menu_separator (menu);
 
 	menuitem = gtk_image_menu_item_new ();
+	
+	disable_movement = panel_profile_get_toplevel_disable_movement (panel_widget->toplevel);
+	setup_menuitem (menuitem,
+			GTK_ICON_SIZE_MENU,
+			gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_MENU),
+			disable_movement ? _("_Allow Panel to be Moved") : _("_Lock Panel Postion"),
+			FALSE);
+		
+	gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+	g_signal_connect (menuitem, "activate",
+			  G_CALLBACK (cb_disable_movement_activate),
+			  menuitem);
+	
+	menuitem = gtk_image_menu_item_new ();	
 	setup_menuitem (menuitem, 
 			GTK_ICON_SIZE_MENU,
 			gtk_image_new_from_stock (GTK_STOCK_NEW,
--- gnome-panel/panel-default-setup.entries.in
+++ gnome-panel/panel-default-setup.entries.in
@@ -96,6 +96,13 @@
       </value>
     </entry>
     <entry>
+      <key>toplevels/top_panel/disable_movement</key>
+      <schema_key>/schemas/apps/panel/toplevels/disable_movement</schema_key>
+      <value>
+        <bool>true</bool>
+      </value>
+    </entry>
+    <entry>      
       <key>toplevels/top_panel/orientation</key>
       <schema_key>/schemas/apps/panel/toplevels/orientation</schema_key>
       <value>
@@ -143,6 +150,13 @@
       </value>
     </entry>
     <entry>
+      <key>toplevels/bottom_panel/disable_movement</key>
+      <schema_key>/schemas/apps/panel/toplevels/disable_movement</schema_key>
+      <value>
+        <bool>true</bool>
+      </value>
+    </entry>
+    <entry>      
       <key>toplevels/bottom_panel/orientation</key>
       <schema_key>/schemas/apps/panel/toplevels/orientation</schema_key>
       <value>
--- gnome-panel/panel-global.schemas.in
+++ gnome-panel/panel-global.schemas.in
@@ -33,6 +33,18 @@
       </schema>
 
       <schema>
+        <key>/schemas/apps/panel/global/disable_movement</key>
+        <applyto>/apps/panel/global/disable_movement</applyto>
+        <owner>panel</owner>
+        <type>bool</type>
+        <default>true</default>
+        <locale name="C">
+          <short>Lock Panel Position</short>
+          <long>Disable support for moving a panel with a mouse drag.  It has been know to cause problems
+	  for users that accidentally move or resize their panels.</long>
+        </locale>
+	</schema>
+      <schema>      
         <key>/schemas/apps/panel/global/enable_animations</key>
         <applyto>/apps/panel/global/enable_animations</applyto>
         <owner>panel</owner>
--- gnome-panel/panel-profile.c
+++ gnome-panel/panel-profile.c
@@ -532,6 +532,19 @@
 		gconf_client_unset (client, key, NULL);
 }
 
+void 
+panel_profile_set_toplevel_disable_movement (PanelToplevel *toplevel,
+					     gboolean disable_movement)
+{
+	GConfClient *client;
+	const char *key;
+	
+	client = panel_gconf_get_client ();
+	key = panel_profile_get_toplevel_key (toplevel, "disable_movement");
+	
+	gconf_client_set_bool (client, key, disable_movement, NULL);
+}
+
 char *
 panel_profile_get_toplevel_name (PanelToplevel *toplevel)
 {
@@ -549,6 +562,19 @@
 
 TOPLEVEL_IS_WRITABLE_FUNC ("name", toplevel, name)
 
+gboolean 
+panel_profile_get_toplevel_disable_movement (PanelToplevel *toplevel)
+{
+
+	GConfClient *client;
+	const char *key;
+	gboolean disable_movement;
+	client = panel_gconf_get_client ();
+       
+	key = panel_profile_get_toplevel_key (toplevel, "disable_movement");
+	disable_movement = gconf_client_get_bool (client, key, NULL);
+	return disable_movement;	
+}
 void
 panel_profile_set_toplevel_orientation (PanelToplevel    *toplevel,
 					PanelOrientation  orientation)
--- gnome-panel/panel-profile.h
+++ gnome-panel/panel-profile.h
@@ -83,6 +83,9 @@
             panel_profile_get_toplevel_orientation    (PanelToplevel *toplevel);
 gboolean    panel_profile_is_writable_toplevel_orientation (PanelToplevel *toplevel);
 
+gboolean panel_profile_get_toplevel_disable_movement (PanelToplevel *toplevel);
+void panel_profile_set_toplevel_disable_movement (PanelToplevel *toplevel, gboolean disable_movement);
+
 void        panel_profile_set_toplevel_size           (PanelToplevel *toplevel,
 						       int            size);
 int         panel_profile_get_toplevel_size           (PanelToplevel *toplevel);
--- gnome-panel/panel-properties-dialog.c
+++ gnome-panel/panel-properties-dialog.c
@@ -73,6 +73,7 @@
 
 	guint          toplevel_notify;
 	guint          background_notify;
+	guint          disable_movement_notify;
 
 	/* The theme directory of the icon, see bug #119209 */
 	char          *icon_theme_dir;
@@ -95,6 +96,10 @@
 		gconf_client_notify_remove (client, dialog->background_notify);
 	dialog->background_notify = 0;
 
+	if (dialog->disable_movement_notify)
+		gconf_client_notify_remove (client, dialog->disable_movement_notify);
+	dialog->disable_movement_notify = 0;
+
 	if (dialog->properties_dialog)
 		gtk_widget_destroy (dialog->properties_dialog);
 	dialog->properties_dialog = NULL;
@@ -146,6 +151,24 @@
 }
 
 static void
+panel_properties_dialog_disable_movement_notify (GConfClient           *client,
+					      guint                 cnxn_id,
+					      GConfEntry            *entry,
+					      PanelPropertiesDialog *dialog)
+{
+	gboolean panel_locked = panel_profile_get_toplevel_disable_movement (dialog->toplevel);
+        
+	gtk_widget_set_sensitive (dialog->orientation_combo, !panel_locked);
+	gtk_widget_set_sensitive (dialog->orientation_label, !panel_locked);
+        
+	if (panel_locked)
+		gtk_widget_show (dialog->writability_warn_general);
+	else
+		gtk_widget_hide (dialog->writability_warn_general);
+		
+}
+
+static void
 panel_properties_dialog_setup_orientation_combo (PanelPropertiesDialog *dialog,
 						 GladeXML              *gui)
 {
@@ -190,7 +213,7 @@
 				  G_CALLBACK (panel_properties_dialog_orientation_changed),
 				  dialog);
 
-	if (! panel_profile_is_writable_toplevel_orientation (dialog->toplevel)) {
+	if (! panel_profile_is_writable_toplevel_orientation (dialog->toplevel) || panel_profile_get_toplevel_disable_movement (dialog->toplevel)) {
 		gtk_widget_set_sensitive (dialog->orientation_combo, FALSE);
 		gtk_widget_set_sensitive (dialog->orientation_label, FALSE);
 		gtk_widget_show (dialog->writability_warn_general);
@@ -920,6 +943,13 @@
 	panel_properties_dialog_setup_hidebuttons_toggle (dialog, gui);
 	panel_properties_dialog_setup_arrows_toggle      (dialog, gui);
 
+	dialog->disable_movement_notify =
+		panel_profile_toplevel_notify_add (
+			dialog->toplevel,
+			"disable_movement",
+			(GConfClientNotifyFunc) panel_properties_dialog_disable_movement_notify,
+			dialog);
+
 	panel_properties_update_arrows_toggle_visible (
 		dialog, GTK_TOGGLE_BUTTON (dialog->hidebuttons_toggle));
 	g_signal_connect_swapped (dialog->hidebuttons_toggle, "toggled",
--- gnome-panel/panel-toplevel.c
+++ gnome-panel/panel-toplevel.c
@@ -423,7 +423,8 @@
 	    toplevel->priv->grab_op != PANEL_GRAB_OP_NONE)
 		return;
 
-	if (panel_lockdown_get_locked_down ())
+	if (panel_lockdown_get_locked_down ()||
+	    panel_profile_get_toplevel_disable_movement (toplevel))
 		return;
 
 	/* If any of the position/orientation are not writable,
--- gnome-panel/panel-toplevel.schemas.in
+++ gnome-panel/panel-toplevel.schemas.in
@@ -47,6 +47,19 @@
         </long>
       </locale>
     </schema>
+
+    <schema> 
+      <key>/schemas/apps/panel/toplevels/disable_movement</key>
+      <owner>panel</owner>
+      <type>bool</type>
+      <default>true</default>
+      <locale name="C">
+        <short>Lock the panel position</short>
+	<long>Disable support for moving a panel with a mouse drag.  It has
+	been know to cause problems for users that accidentally move or resize
+	their panels.</long>
+      </locale>
+    </schema>
  
     <schema>
       <key>/schemas/apps/panel/toplevels/expand</key>